<commit_before>define(['app',
	'./view-abs-checkpoint.directive.js',
    './view-abs-checkpoint-communique.directive.js',
    './view-abs-permit.directive.js',
    './view-authority.directive.js',
    './view-authority-reference.directive.js',
    './view-contact.directive.js',
    './view-contact-reference.directive.js',
    './view-database.directive.js',
    './view-measure.directive.js',
    './view-organization.directive.js',
    './view-organization-reference.directive.js',
    './view-resource.directive.js',
    './view-focalpoint.directive.html.js',
    './view-meeting.directive.html.js',
    './view-statement.directive.html.js',
    './view-pressrelease.directive.html.js',
    './view-notification.directive.html.js',
	'./view-history-directive.html.js',
    '/app/js/common.js',
    '/app/views/directives/document-metadata-directive.html.js',
	'/app/views/forms/view/view-news.directive.html.js'
    ], function (app) {
app.directive('recordLoader', [function () {
	return {
		restrict: 'EAC',
		templateUrl: '/app/views/forms/view/record-loader.directive.html',
		replace: true,
		transclude: false,
		scope: {
			linkTarget: "@",
			document: "=",
			locale  : "=",
			hide: "@"
		},
		link: function($scope) {

			//debugger;
			$scope.internalDocument     = undefined;
			$scope.internalDocumentInfo = undefined;

			$scope.$watch("document", function(_new) {
				$scope.error = null;
				$scope.internalDocument = _new;

			});

			if(!$scope.document)
				$scope.init();
		},
		controller: ['$scope', "$route", 'IStorage', "authentication", "localization", "$q", "$location", "commonjs","$timeout","$filter","authHttp","$http",
			function ($scope, $route, storage, authentication, localization, $q, $location,commonjs,$timeout, $filter, $http, $httpAWS) {

			//==================================
			//
			//==================================
			$scope.init = function () {

				if ($scope.internalDocument && !$scope.revisionNo)
					return;

				if ($scope.document || $scope.schema)
					return;

				var documentSchema = $route.current.params.documentSchema;
				var documentRevision = $route.current.params.revision;

				var documentID = documentSchema ? commonjs.integerToHex($route.current.params.documentID, documentSchema) : $route.current.params.documentID;

				if($scope.revisionNo)
					documentRevision = $scope.revisionNo;

				if($route.current.params.documentNumber)
					var documentID = $route.current.params.documentNumber;

				if(documentID && documentID.toLowerCase().indexOf('absch')==0){
					var docNum = documentID.split('-');
					if(docNum.length ==5){
						documentID = documentID.toLowerCase();//.replace('absch','ABSCH');
						$scope.documentUID = documentID.toUpperCase();
						$scope.documentUrl = "https://s3.amazonaws.com/absch.documents/" + documentID + '.pdf?id=' + new Date();

						$httpAWS.head($scope.documentUrl,{cache:false}).then(function(success){
							$scope.documentSuccess = true;
							window.location.href = $scope.documentUrl;
							closeWindow();
						},
						function(error){
							$scope.documentError = true;
							console.log(error);
						});

						return;
					}
					if(docNum.length <= 4)
						documentID = docNum[docNum.length-1];

				}

				$scope.loadDocument(documentSchema,documentID,documentRevision);
				// else
				// 	$scope.error = "documentID not specified";

			}

			$scope.loadDocument = function(documentSchema,documentID,documentRevision){

				if(documentSchema && (documentSchema.toUpperCase()=="FOCALPOINT" || documentSchema.toUpperCase()=="MEETING" || documentSchema.toUpperCase()=="NOTIFICATION"
				|| documentSchema.toUpperCase()=="PRESSRELEASE" || documentSchema.toUpperCase()=="STATEMENT" || documentSchema.toUpperCase()=="NEWS"))
				{
					commonjs.getReferenceRecordIndex(documentSchema,documentID).then(function(data){
						$scope.internalDocument = data.data;
					//console.log($scope.internalDocument );
					});
				}
				else if (documentID){
					console.log(documentID);
					$scope.load(documentID,documentRevision);
				}
			}

			$scope.timeLaspe = 20;
			function closeWindow(){
				if($scope.timeLaspe==0)
					window.close();
				$scope.timeLaspe--;
				$timeout(function(){closeWindow();},1000)
			}
			//==================================
			//
			//==================================
			$scope.getLocale = function () {
				return $scope.$root.locale;
			}

			//==================================
			//
			//==================================
			$scope.load = function (identifier, version) {

				$scope.error = undefined;
				var qDocument;
				var qDocumentInfo;
				if(version==undefined){

					qDocument = storage.documents.get(identifier)
									   .then(function(result) { return result.data || result });
				}
				else{
					qDocument = storage.documentVersions.get(identifier,{'version':version})
									   .then(function(result) { return result.data || result });

				//	qDocumentInfo = storage.documentVersions.get(identifier,{ info: true,'version':version }).then(function(result) { return result.data || result });

				}
				qDocumentInfo = storage.documents.get(identifier,{ info: true}).then(function(result) { return result.data || result });

				$q.all([qDocument, qDocumentInfo]).then(function(results) {

					$scope.internalDocument     = results[0];
					$scope.internalDocumentInfo = results[1];
					$scope.internalDocument.info = results[1];

					$scope.documentVersionCount = $scope.internalDocumentInfo.revision

					if(version && $scope.internalDocumentInfo.revision != version){
						$scope.internalDocumentInfo.revision = version;
					}
					if(version)
						$scope.revisionNo  = version
					else
						$scope.revisionNo  = $scope.documentVersionCount

				}).then(null, function(error) {
					//debugger;
					 // $scope.error = error.Message || error || "Http Error: " + errorCode;
					 console.log( $scope.error );
				})

			};

			//==================================
			//
			//==================================
			$scope.getUser = function() {

				if(!$scope.user)
				 	$q.when(authentication.getUser(), function(user){ $scope.user = user; });

				return $scope.user
			};

			//==================================
			//
			//==================================
			$scope.edit = function() {
				if (!$scope.canEdit())
					throw "Cannot edit form";

				var schema     = $scope.internalDocumentInfo.type;
				var identifier = $scope.internalDocumentInfo.identifier;
				$timeout(function(){
					$location.path("/register/" + $filter("mapSchema")(schema) + "/" + identifier + '/edit');},1);

			}

			//==================================
			//
			//==================================
			$scope.canEdit = function() {

				if ($scope.getUser() && !$scope.getUser().isAuthenticated)
					return false;

				if(!$scope.internalDocumentInfo && $scope.internalDocument && $scope.internalDocument.info)
				{
					$scope.internalDocumentInfo = $scope.internalDocument.info;
				}

				if (!$scope.internalDocumentInfo)
					return false;
				if ($scope.internalCanEdit === undefined) {

					$scope.internalCanEdit = null; // avoid recall => null !== undefined

					var hasDraft   = !!$scope.internalDocumentInfo.workingDocumentCreatedOn;
					var identifier =   $scope.internalDocumentInfo.identifier;
					var schema     =   $scope.internalDocumentInfo.type;

					var qCanEdit = hasDraft
							     ? storage.drafts.security.canUpdate(identifier, schema)  // has draft
								 : storage.drafts.security.canCreate(identifier, schema); // has no draft

					qCanEdit.then(function(isAllowed) {

						$scope.internalCanEdit = isAllowed || false;

					}).then(null, function(error) {

						$scope.internalCanEdit = false;
					});
				}

				return $scope.internalCanEdit===true;
			};

			$scope.loadRevision = function(val){

				if($scope.revisionNo!=val){
					$scope.revisionNo=val;
					//$scope.internalDocument = null
					$scope.init();
				}
			}

			$scope.$on('loadDocument', function(evt, evtData){

				if(evtData.documentId && evtData.schema && !$scope.document){

					$scope.loadDocument(evtData.schema,evtData.documentId);
				}

			});

		}]
	}
}]);
});
<commit_msg>handle new pdf folder structure<commit_after>define(['app',
	'./view-abs-checkpoint.directive.js',
    './view-abs-checkpoint-communique.directive.js',
    './view-abs-permit.directive.js',
    './view-authority.directive.js',
    './view-authority-reference.directive.js',
    './view-contact.directive.js',
    './view-contact-reference.directive.js',
    './view-database.directive.js',
    './view-measure.directive.js',
    './view-organization.directive.js',
    './view-organization-reference.directive.js',
    './view-resource.directive.js',
    './view-focalpoint.directive.html.js',
    './view-meeting.directive.html.js',
    './view-statement.directive.html.js',
    './view-pressrelease.directive.html.js',
    './view-notification.directive.html.js',
	'./view-history-directive.html.js',
    '/app/js/common.js',
    '/app/views/directives/document-metadata-directive.html.js',
	'/app/views/forms/view/view-news.directive.html.js'
    ], function (app) {
app.directive('recordLoader', [function () {
	return {
		restrict: 'EAC',
		templateUrl: '/app/views/forms/view/record-loader.directive.html',
		replace: true,
		transclude: false,
		scope: {
			linkTarget: "@",
			document: "=",
			locale  : "=",
			hide: "@"
		},
		link: function($scope) {

			//debugger;
			$scope.internalDocument     = undefined;
			$scope.internalDocumentInfo = undefined;

			$scope.$watch("document", function(_new) {
				$scope.error = null;
				$scope.internalDocument = _new;

			});

			if(!$scope.document)
				$scope.init();
		},
		controller: ['$scope', "$route", 'IStorage', "authentication", "localization", "$q", "$location", "commonjs","$timeout","$filter","authHttp","$http","realm",
			function ($scope, $route, storage, authentication, localization, $q, $location,commonjs,$timeout, $filter, $http, $httpAWS, realm) {

			//==================================
			//
			//==================================
			$scope.init = function () {

				if ($scope.internalDocument && !$scope.revisionNo)
					return;

				if ($scope.document || $scope.schema)
					return;

				var documentSchema = $route.current.params.documentSchema;
				var documentRevision = $route.current.params.revision;

				var documentID = documentSchema ? commonjs.integerToHex($route.current.params.documentID, documentSchema) : $route.current.params.documentID;

				if($scope.revisionNo)
					documentRevision = $scope.revisionNo;

				if($route.current.params.documentNumber)
					var documentID = $route.current.params.documentNumber;

				if(documentID && documentID.toLowerCase().indexOf('absch')==0){
					var docNum = documentID.split('-');
					if(docNum.length ==5){
						documentID = documentID.toLowerCase();//.replace('absch','ABSCH');
						$scope.documentUID = documentID.toUpperCase();
						var schemaFolder = $filter("mapSchema")(docNum[1]);
						$scope.documentUrl = "https://s3.amazonaws.com/absch.documents." + realm.value.toLowerCase() + "/" + schemaFolder + '/' +  documentID + '.pdf?id=' + new Date();

						$httpAWS.head($scope.documentUrl,{cache:false}).then(function(success){
							$scope.documentSuccess = true;
							window.location.href = $scope.documentUrl;
							closeWindow();
						},
						function(error){
							$scope.documentError = true;
							console.log(error);
						});

						return;
					}
					if(docNum.length <= 4)
						documentID = docNum[docNum.length-1];

				}

				$scope.loadDocument(documentSchema,documentID,documentRevision);
				// else
				// 	$scope.error = "documentID not specified";

			}

			$scope.loadDocument = function(documentSchema,documentID,documentRevision){

				if(documentSchema && (documentSchema.toUpperCase()=="FOCALPOINT" || documentSchema.toUpperCase()=="MEETING" || documentSchema.toUpperCase()=="NOTIFICATION"
				|| documentSchema.toUpperCase()=="PRESSRELEASE" || documentSchema.toUpperCase()=="STATEMENT" || documentSchema.toUpperCase()=="NEWS"))
				{
					commonjs.getReferenceRecordIndex(documentSchema,documentID).then(function(data){
						$scope.internalDocument = data.data;
					//console.log($scope.internalDocument );
					});
				}
				else if (documentID){
					console.log(documentID);
					$scope.load(documentID,documentRevision);
				}
			}

			$scope.timeLaspe = 20;
			function closeWindow(){
				if($scope.timeLaspe==0)
					window.close();
				$scope.timeLaspe--;
				$timeout(function(){closeWindow();},1000)
			}
			//==================================
			//
			//==================================
			$scope.getLocale = function () {
				return $scope.$root.locale;
			}

			//==================================
			//
			//==================================
			$scope.load = function (identifier, version) {

				$scope.error = undefined;
				var qDocument;
				var qDocumentInfo;
				if(version==undefined){

					qDocument = storage.documents.get(identifier)
									   .then(function(result) { return result.data || result });
				}
				else{
					qDocument = storage.documentVersions.get(identifier,{'version':version})
									   .then(function(result) { return result.data || result });

				//	qDocumentInfo = storage.documentVersions.get(identifier,{ info: true,'version':version }).then(function(result) { return result.data || result });

				}
				qDocumentInfo = storage.documents.get(identifier,{ info: true}).then(function(result) { return result.data || result });

				$q.all([qDocument, qDocumentInfo]).then(function(results) {

					$scope.internalDocument     = results[0];
					$scope.internalDocumentInfo = results[1];
					$scope.internalDocument.info = results[1];

					$scope.documentVersionCount = $scope.internalDocumentInfo.revision

					if(version && $scope.internalDocumentInfo.revision != version){
						$scope.internalDocumentInfo.revision = version;
					}
					if(version)
						$scope.revisionNo  = version
					else
						$scope.revisionNo  = $scope.documentVersionCount

				}).then(null, function(error) {
					//debugger;
					 // $scope.error = error.Message || error || "Http Error: " + errorCode;
					 console.log( $scope.error );
				})

			};

			//==================================
			//
			//==================================
			$scope.getUser = function() {

				if(!$scope.user)
				 	$q.when(authentication.getUser(), function(user){ $scope.user = user; });

				return $scope.user
			};

			//==================================
			//
			//==================================
			$scope.edit = function() {
				if (!$scope.canEdit())
					throw "Cannot edit form";

				var schema     = $scope.internalDocumentInfo.type;
				var identifier = $scope.internalDocumentInfo.identifier;
				$timeout(function(){
					$location.path("/register/" + $filter("mapSchema")(schema) + "/" + identifier + '/edit');},1);

			}

			//==================================
			//
			//==================================
			$scope.canEdit = function() {

				if ($scope.getUser() && !$scope.getUser().isAuthenticated)
					return false;

				if(!$scope.internalDocumentInfo && $scope.internalDocument && $scope.internalDocument.info)
				{
					$scope.internalDocumentInfo = $scope.internalDocument.info;
				}

				if (!$scope.internalDocumentInfo)
					return false;
				if ($scope.internalCanEdit === undefined) {

					$scope.internalCanEdit = null; // avoid recall => null !== undefined

					var hasDraft   = !!$scope.internalDocumentInfo.workingDocumentCreatedOn;
					var identifier =   $scope.internalDocumentInfo.identifier;
					var schema     =   $scope.internalDocumentInfo.type;

					var qCanEdit = hasDraft
							     ? storage.drafts.security.canUpdate(identifier, schema)  // has draft
								 : storage.drafts.security.canCreate(identifier, schema); // has no draft

					qCanEdit.then(function(isAllowed) {

						$scope.internalCanEdit = isAllowed || false;

					}).then(null, function(error) {

						$scope.internalCanEdit = false;
					});
				}

				return $scope.internalCanEdit===true;
			};

			$scope.loadRevision = function(val){

				if($scope.revisionNo!=val){
					$scope.revisionNo=val;
					//$scope.internalDocument = null
					$scope.init();
				}
			}

			$scope.$on('loadDocument', function(evt, evtData){

				if(evtData.documentId && evtData.schema && !$scope.document){

					$scope.loadDocument(evtData.schema,evtData.documentId);
				}

			});

		}]
	}
}]);
});
<|endoftext|>


<commit_before>angular.module('tattva')
.config(['$stateProvider','$urlRouterProvider',
function($stateProvider){
  $stateProvider
  .state('design.watchlist',
  {
    url:'/watchlist',
    templateUrl: "/design/watchlists/template/watchlistNamespaceBasedView.html"
  })
  .state('design.watchlist.viewwatchlist',
  {
    url:'/:namespaceobject',
    templateUrl: "design/watchlists/template/viewwatchlist.html",
    controller: 'watchlistviewctrl'
  })
  .state('design.viewdata',
  {
    url:'/detailview/:watchlistName',
    templateUrl: "design/watchlists/template/createWatchlist.html",
    controller: 'WatchListCtrl',
    resolve:{
      selectedWlstdef:function(loadExprData, $stateParams){
        return loadExprData.getWatchlistData($stateParams.watchlistName).then(function(response){
          //console.log(response);
          return response;
        });
      }
    }
  })
  .state('design.createwatchlist',
  {
    url: '/new',
    templateUrl: "design/watchlists/template/createWatchlist.html",
    controller: 'WatchListCtrl',
    resolve:{
      selectedWlstdef:function(){
        return undefined;
      }
    }
  })

}]);
<commit_msg>Minor file name casing issues inside docker<commit_after>angular.module('tattva')
  .config(['$stateProvider', '$urlRouterProvider',
    function($stateProvider) {
      $stateProvider
        .state('design.watchlist', {
          url: '/watchlist',
          templateUrl: "/design/watchlists/template/watchlistNamespaceBasedView.html"
        })
        .state('design.watchlist.viewwatchlist', {
          url: '/:namespaceobject',
          templateUrl: "design/watchlists/template/viewWatchList.html",
          controller: 'watchlistviewctrl'
        })
        .state('design.viewdata', {
          url: '/detailview/:watchlistName',
          templateUrl: "design/watchlists/template/createWatchlist.html",
          controller: 'WatchListCtrl',
          resolve: {
            selectedWlstdef: function(loadExprData, $stateParams) {
              return loadExprData.getWatchlistData($stateParams.watchlistName).then(function(response) {
                //console.log(response);
                return response;
              });
            }
          }
        })
        .state('design.createwatchlist', {
          url: '/new',
          templateUrl: "design/watchlists/template/createWatchlist.html",
          controller: 'WatchListCtrl',
          resolve: {
            selectedWlstdef: function() {
              return undefined;
            }
          }
        })

    }
  ]);<|endoftext|>


<commit_before>(function (global) {
  System.config({
    paths: {
      'npm:': 'node_modules/'
    },
    map: {
      app: 'app',

      // angular bundles
      '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
      '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
      '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
      '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
      '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
      '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
      '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',

      // other libraries
      'rxjs':                      'npm:rxjs',
      "angular2-materialize": "node_modules/angular2-materialize",
      "materialize-css": "node-modules/materialize-css",
    },
    packages: {
      'app': {
        main: './main.js',
        defaultExtension: 'js'
      },
      'rxjs': {
        defaultExtension: 'js'
      },
      'angular2-materialize': {
        main: 'dist/materialize-directive',
        defaultExtension: 'js'
      }
    }
  });
})(this);
<commit_msg>Removing materialize-css<commit_after>(function (global) {
  System.config({
    paths: {
      'npm:': 'node_modules/'
    },
    map: {
      app: 'app',

      // angular bundles
      '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
      '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
      '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
      '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
      '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
      '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
      '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',

      // other libraries
      'rxjs':                      'npm:rxjs',
      "angular2-materialize": "node_modules/angular2-materialize",
    },
    packages: {
      'app': {
        main: './main.js',
        defaultExtension: 'js'
      },
      'rxjs': {
        defaultExtension: 'js'
      },
      'angular2-materialize': {
        main: 'dist/materialize-directive',
        defaultExtension: 'js'
      }
    }
  });
})(this);
<|endoftext|>


<commit_before>
var CabooseModal = function(w, h) {
  if (!h)
  {
    $('#modal_content').css('width', w);
    h = $('#modal_content').outerHeight(true);
  }
  if (parent.$.fn.colorbox)
    this.resize(w, h);
};

CabooseModal.prototype = {

  width: 0,
  height: 0,
  set_width:  function(w) { this.width = w; this.colorbox(); },
  set_height: function(h) { this.height = h; this.colorbox(); },
  resize: function(w, h) { this.width = w; this.height = h; this.colorbox(); },

  // Resizes the height of the modal based on the content height
  autosize: function(msg, msg_container) {
    if (msg)
      $('#' + (msg_container ? msg_container : 'message')).empty().append(msg);
    this.height = $('#modal_content').outerHeight(true);
    this.colorbox();
  },

  colorbox: function() {
    if (parent && parent.$.fn.colorbox)
    {
      parent.$.fn.colorbox.resize({
        innerWidth:  '' + this.width + 'px',
        innerHeight: '' + this.height + 'px'
      });
    }
  },

  close: function() {
    if (parent && parent.$.fn.colorbox)
      parent.$.fn.colorbox.close();
  }
};

$(document).ready(function() {
  $('#caboose_login'    ).colorbox({ iframe: true, initialWidth: 400, initialHeight: 200, innerWidth: 400, innerHeight: 200, scrolling: false, transition: 'fade', closeButton: false, onComplete: fix_colorbox, opacity: 0.50 });
  $('#caboose_register' ).colorbox({ iframe: true, initialWidth: 400, initialHeight: 324, innerWidth: 400, innerHeight: 324, scrolling: false, transition: 'fade', closeButton: false, onComplete: fix_colorbox, opacity: 0.50 });
  $('#caboose_station'  ).colorbox({ iframe: true, initialWidth: 200, initialHeight: 50,  innerWidth: 200, innerHeight:  50, scrolling: false, transition: 'fade', closeButton: false, onComplete: fix_colorbox, opacity: 0.50 });
});

function fix_colorbox() {
  var padding = 21; // 21 is default
  $("#cboxTopLeft"      ).css('background', '#111');
  $("#cboxTopRight"     ).css('background', '#111');
  $("#cboxBottomLeft"   ).css('background', '#111');
  $("#cboxBottomRight"  ).css('background', '#111');
  $("#cboxMiddleLeft"   ).css('background', '#111');
  $("#cboxMiddleRight"  ).css('background', '#111');
  $("#cboxTopCenter"    ).css('background', '#111');
  $("#cboxBottomCenter" ).css('background', '#111');
  $("#cboxClose"        ).hide();

  //var p = (padding-21)*2;
  //$("#cboxWrapper"      ).css('padding', '0 ' + p + ' ' + p + ' 0');
  //$('#cboxLoadedContent').css('margin-bottom', 0);
  //h = $('#cboxLoadedContent').height();
  //$('#cboxLoadedContent').css('height', ''+(h+28)+'px');
}
<commit_msg>Added a generic caboose_modal javascript function.<commit_after>
var CabooseModal = function(w, h) {
  if (!h)
  {
    $('#modal_content').css('width', w);
    h = $('#modal_content').outerHeight(true);
  }
  if (parent.$.fn.colorbox)
    this.resize(w, h);
};

CabooseModal.prototype = {

  width: 0,
  height: 0,
  set_width:  function(w) { this.width = w; this.colorbox(); },
  set_height: function(h) { this.height = h; this.colorbox(); },
  resize: function(w, h) { this.width = w; this.height = h; this.colorbox(); },

  // Resizes the height of the modal based on the content height
  autosize: function(msg, msg_container) {
    if (msg)
      $('#' + (msg_container ? msg_container : 'message')).empty().append(msg);
    this.height = $('#modal_content').outerHeight(true);
    this.colorbox();
  },

  colorbox: function() {
    if (parent && parent.$.fn.colorbox)
    {
      parent.$.fn.colorbox.resize({
        innerWidth:  '' + this.width + 'px',
        innerHeight: '' + this.height + 'px'
      });
    }
  },

  close: function() {
    if (parent && parent.$.fn.colorbox)
      parent.$.fn.colorbox.close();
  }
};

$(document).ready(function() {
  caboose_modal('caboose_login');
  caboose_modal('caboose_register');
  caboose_modal('caboose_station');
  //$('#caboose_login'    ).colorbox({ iframe: true, initialWidth: 400, initialHeight: 200, innerWidth: 400, innerHeight: 200, scrolling: false, transition: 'fade', closeButton: false, onComplete: fix_colorbox, opacity: 0.50 });
  //$('#caboose_register' ).colorbox({ iframe: true, initialWidth: 400, initialHeight: 324, innerWidth: 400, innerHeight: 324, scrolling: false, transition: 'fade', closeButton: false, onComplete: fix_colorbox, opacity: 0.50 });
  //$('#caboose_station'  ).colorbox({ iframe: true, initialWidth: 200, initialHeight: 50,  innerWidth: 200, innerHeight:  50, scrolling: false, transition: 'fade', closeButton: false, onComplete: fix_colorbox, opacity: 0.50 });
});

function caboose_modal(el)
{
  $('#'+el).colorbox({
    iframe: true,
    initialWidth: 400,
    initialHeight: 200,
    innerWidth: 400,
    innerHeight: 200,
    scrolling: false,
    transition: 'fade',
    closeButton: false,
    onComplete: caboose_fix_colorbox,
    opacity: 0.50
  });
}

function caboose_fix_colorbox() {
  var padding = 21; // 21 is default
  $("#cboxTopLeft"      ).css('background', '#111');
  $("#cboxTopRight"     ).css('background', '#111');
  $("#cboxBottomLeft"   ).css('background', '#111');
  $("#cboxBottomRight"  ).css('background', '#111');
  $("#cboxMiddleLeft"   ).css('background', '#111');
  $("#cboxMiddleRight"  ).css('background', '#111');
  $("#cboxTopCenter"    ).css('background', '#111');
  $("#cboxBottomCenter" ).css('background', '#111');
  $("#cboxClose"        ).hide();
}
<|endoftext|>


<commit_before>$("#users-form-signup").submit(function() {
  if ($(this).find("#email").val().length == 0)
  {
    $(this).find("#form-group-email").addClass("has-error");
    return false;
  }
  else
  {
    $(this).find("#form-group-email").removeClass("has-error");
    $(this).find("#form-group-email").addClass("has-success");
  }

  if ($(this).find("#password").val().length == 0)
  {
    $(this).find("#form-group-password").addClass("has-error");
    return false;
  }
  else
  {
    $(this).find("#form-group-password").removeClass("has-error");
    $(this).find("#form-group-password").addClass("has-success");
  }

  if ($(this).find("#password-duplicate").val().length == 0
    || $(this).find("#password").val() != $(this).find("#password-duplicate").val())
  {
    alert("Пароли не совпали!");
    return false;
  }
  else
  {
    $.ajax({
      type: "POST",
      url: "/users/users",
      data: $("#users-form-signup").serialize(),
      success: function (data) {
        showAlert(data.msg, "info", 2000, function() {
          if (data.status) {
            app.isLoggedIn = true;
            app.user = data.user;
            $('*').trigger('users-login');
            if (!(window.history && history.pushState)) {
              loadPage('/main.json');
            }
            else {
              history.back();
            }
          }
        });
      }
    });
  }
  return false;
});

$("#users-form-signup #email").blur(function() {
  if (!$(this).val())
  {
    $("#users-form-signup #form-group-email").addClass("has-error");
    $(this).next("span").addClass("glyphicon-remove");
  }
  else
  {
    $("#users-form-signup #form-group-email").removeClass("has-error");
    $("#users-form-signup #form-group-email").addClass("has-success");
    $(this).next("span").removeClass("glyphicon-remove");
    $(this).next("span").addClass("glyphicon-ok");
  }
});

$("#users-form-signup #password").blur(function() {
  if (!$(this).val())
  {
    $("#users-form-signup #form-group-password").addClass("has-error");
    $(this).next("span").addClass("glyphicon-remove");
  }
  else
  {
    $("#users-form-signup #form-group-password").removeClass("has-error");
    $("#users-form-signup #form-group-password").addClass("has-success");
    $(this).next("span").removeClass("glyphicon-remove");
    $(this).next("span").addClass("glyphicon-ok");
  }
});

$("#users-form-signup #password-duplicate").blur(function() {
  if (!$(this).val())
  {
    $("#users-form-signup #form-group-password-duplicate").addClass("has-error");
    $(this).next("span").addClass("glyphicon-remove");
  }
  else
  {
    $("#users-form-signup #form-group-password-duplicate").removeClass("has-error");
    $("#users-form-signup #form-group-password-duplicate").addClass("has-success");
    $(this).next("span").removeClass("glyphicon-remove");
    $(this).next("span").addClass("glyphicon-ok");
  }
});

$("#users-form-signup #email").focus(function() {
  $("#users-form-signup #form-group-email").removeClass("has-error");
  $("#users-form-signup #form-group-email").removeClass("has-success");
  $(this).next("span").removeClass("glyphicon-remove");
  $(this).next("span").removeClass("glyphicon-ok");
});

$("#users-form-signup #password").focus(function() {
  $("#users-form-signup #form-group-password").removeClass("has-error");
  $("#users-form-signup #form-group-password").removeClass("has-success");
  $(this).next("span").removeClass("glyphicon-remove");
  $(this).next("span").removeClass("glyphicon-ok");
});

$("#users-form-signup #password-duplicate").focus(function() {
  $("#users-form-signup #form-group-password-duplicate").removeClass("has-error");
  $("#users-form-signup #form-group-password-duplicate").removeClass("has-success");
  $(this).next("span").removeClass("glyphicon-remove");
  $(this).next("span").removeClass("glyphicon-ok");
});

$("#agreement-dialog #accept-button").click(function() {
  $("#users-form-signup #email").removeAttr("disabled");
  $("#users-form-signup #password").removeAttr("disabled");
  $("#users-form-signup #password-duplicate").removeAttr("disabled");
  $("#users-form-signup #signup-submit").removeAttr("disabled");
  $("#agreement-dialog").modal("hide");
});
<commit_msg>Подправил автоматический вход в систему после регистрации пользователя.<commit_after>$("#users-form-signup").submit(function() {
  if ($(this).find("#email").val().length == 0)
  {
    $(this).find("#form-group-email").addClass("has-error");
    return false;
  }
  else
  {
    $(this).find("#form-group-email").removeClass("has-error");
    $(this).find("#form-group-email").addClass("has-success");
  }

  if ($(this).find("#password").val().length == 0)
  {
    $(this).find("#form-group-password").addClass("has-error");
    return false;
  }
  else
  {
    $(this).find("#form-group-password").removeClass("has-error");
    $(this).find("#form-group-password").addClass("has-success");
  }

  if ($(this).find("#password-duplicate").val().length == 0
    || $(this).find("#password").val() != $(this).find("#password-duplicate").val())
  {
    alert("Пароли не совпали!");
    return false;
  }
  else
  {
    $.ajax({
      type: "POST",
      url: "/users/users",
      data: $("#users-form-signup").serialize(),
      success: function (data) {
        var user = data.user;
        user.password = $("#users-form-signup #password").val();
        showAlert(data.msg, data.level, 1000, function() {
          if (!!data.status) {
            $.ajax({
              type: 'POST',
              url: '/users/login',
              data: user,
              success: function(data) {
                showAlert(data.msg, data.level, 1000, function() {
                  if (!!data.status) {
                    app.isLoggedIn = true;
                    delete user.password;
                    app.user = user;
                    localStorage.user_id = user._id;
                    $('*').trigger('users-login');
                    if (window.history && history.pushState) {
                      history.pushState(null, null, '/#!main');
                    }
                    loadPage('/main.json');
                  }
                });
              }
            });
          }
        });
      },
      error: function() {
        showAlert("Сервер недоступен. Попробуйте позже.", "danger");
      }
    });
  }
  return false;
});

$("#users-form-signup #email").blur(function() {
  if (!$(this).val())
  {
    $("#users-form-signup #form-group-email").addClass("has-error");
    $(this).next("span").addClass("glyphicon-remove");
  }
  else
  {
    $("#users-form-signup #form-group-email").removeClass("has-error");
    $("#users-form-signup #form-group-email").addClass("has-success");
    $(this).next("span").removeClass("glyphicon-remove");
    $(this).next("span").addClass("glyphicon-ok");
  }
});

$("#users-form-signup #password").blur(function() {
  if (!$(this).val())
  {
    $("#users-form-signup #form-group-password").addClass("has-error");
    $(this).next("span").addClass("glyphicon-remove");
  }
  else
  {
    $("#users-form-signup #form-group-password").removeClass("has-error");
    $("#users-form-signup #form-group-password").addClass("has-success");
    $(this).next("span").removeClass("glyphicon-remove");
    $(this).next("span").addClass("glyphicon-ok");
  }
});

$("#users-form-signup #password-duplicate").blur(function() {
  if (!$(this).val())
  {
    $("#users-form-signup #form-group-password-duplicate").addClass("has-error");
    $(this).next("span").addClass("glyphicon-remove");
  }
  else
  {
    $("#users-form-signup #form-group-password-duplicate").removeClass("has-error");
    $("#users-form-signup #form-group-password-duplicate").addClass("has-success");
    $(this).next("span").removeClass("glyphicon-remove");
    $(this).next("span").addClass("glyphicon-ok");
  }
});

$("#users-form-signup #email").focus(function() {
  $("#users-form-signup #form-group-email").removeClass("has-error");
  $("#users-form-signup #form-group-email").removeClass("has-success");
  $(this).next("span").removeClass("glyphicon-remove");
  $(this).next("span").removeClass("glyphicon-ok");
});

$("#users-form-signup #password").focus(function() {
  $("#users-form-signup #form-group-password").removeClass("has-error");
  $("#users-form-signup #form-group-password").removeClass("has-success");
  $(this).next("span").removeClass("glyphicon-remove");
  $(this).next("span").removeClass("glyphicon-ok");
});

$("#users-form-signup #password-duplicate").focus(function() {
  $("#users-form-signup #form-group-password-duplicate").removeClass("has-error");
  $("#users-form-signup #form-group-password-duplicate").removeClass("has-success");
  $(this).next("span").removeClass("glyphicon-remove");
  $(this).next("span").removeClass("glyphicon-ok");
});

$("#agreement-dialog #accept-button").click(function() {
  $("#users-form-signup #email").removeAttr("disabled");
  $("#users-form-signup #password").removeAttr("disabled");
  $("#users-form-signup #password-duplicate").removeAttr("disabled");
  $("#users-form-signup #signup-submit").removeAttr("disabled");
  $("#agreement-dialog").modal("hide");
});
<|endoftext|>


<commit_before>module = {
	exports: {}
};

<%= contents %>

var reqwest = module.exports.reqwest;

module = undefined;
<commit_msg>fixed reqwest export.<commit_after>module = {
	exports: {}
};

<%= contents %>

var reqwest = module.exports;

module = undefined;
<|endoftext|>


<commit_before>pageflow.pageType.register('video', _.extend({

  enhance: function(pageElement, configuration) {
    pageElement.find('.contentText').before(pageElement.find('.page_header'));
    this._initVideoPlayer(pageElement, configuration);
  },

  preload: function(pageElement, configuration) {
    return pageflow.preload.backgroundImage(pageElement.find('.background_image'));
  },

  prepare: function(pageElement, configuration) {
    this.videoPlayer.ensureCreated();
  },

  unprepare: function(pageElement, configuration) {
    this.videoPlayer.scheduleDispose();
  },

  activating: function(pageElement, configuration) {
    var videoPlayer = this.videoPlayer;

    // for SkipLinks
    $('#firstContent').attr("id","");
    var firstContentElement = pageElement.find('*[tabindex="4"], a');
    $(firstContentElement[0]).attr('id','firstContent');
    //

    this.videoPlayer.ensureCreated();
    pageElement.find('.controls')
      .autoHidePlayerControls('reset');

    pageElement.find('.videoPage')
      .markWithPlayedStates('reset', {
        autoplay: configuration.autoplay !== false
      });

    if (pageflow.browser.has('mobile platform')) {
      this.videoPlayer.showPosterImage();
    }

    $('body').on('keyup', function(e) {
      if(e.keyCode == 32){
        if(videoPlayer.paused()) {
          videoPlayer.play();
        }
        else {
          videoPlayer.pause();
        }
      }
    });
  },

  activated: function(pageElement, configuration) {
    this.pageElement = pageElement;
    var videoPlayer = this.videoPlayer;
    var that = this;

    if (pageflow.browser.has('ios platform')) {
      videoPlayer.src(videoPlayer.srcFromOptions());
    }

    if (!pageflow.browser.has('mobile platform')) {
      videoPlayer.prebuffer().done(function() {
        videoPlayer.hidePosterImage();

        if (configuration.autoplay !== false) {
          that.fadeInTimeout = setTimeout(function() {
            videoPlayer.playAndFadeIn(1000);
          }, 1000);
        }
      });
    }
  },

  deactivating: function(pageElement, configuration) {
    clearTimeout(this.fadeInTimeout);
    this.fadeSound(this.videoPlayer, 0, 400);
    this.stopListening();
    $('body').off('keyup');
  },

  deactivated: function(pageElement, configuration) {
    if (pageflow.browser.has('mobile platform')) {
      this.videoPlayer.showPosterImage();
    }
    this.videoPlayer.pause();
    this.videoPlayer.scheduleDispose();
  },

  update: function(pageElement, configuration) {
    pageElement.find('h2 .tagline').text(configuration.get('tagline') || '');
    pageElement.find('h2 .title').text(configuration.get('title') || '');
    pageElement.find('h2 .subtitle').text(configuration.get('subtitle') || '');

    pageElement.find('p').html(configuration.get('text') || '');

    this.updateInfoBox(pageElement, configuration);
    this.updateCommonPageCssClasses(pageElement, configuration);

    pageElement.find('.shadow').css({opacity: configuration.get('gradient_opacity') / 100});

    this.updateVideoPoster(pageElement, configuration.getVideoPosterUrl());
  },

  embeddedEditorViews: function() {
    return {
      '.videoWrapper': {
        view: pageflow.LazyVideoEmbeddedView,
        options: {
          propertyName: 'video_file_id'
        }
      }
    };
  },

  _initVideoPlayer: function(pageElement, configuration) {
    var scrollIndicator = this.scrollIndicator;
    var videoPlayer = new pageflow.VideoPlayer.Lazy(pageElement.find('[data-template=video]'), {
      bufferUnderrunWaiting: true,
      controls: true,
      customControlsOnMobile: true,

      volumeFading: true,
      hooks: pageflow.atmo.createMediaPlayerHooks(configuration),

      mediaEvents: true,
      context: {
        page: pageElement.page('instance')
      },

      width: '100%',
      height: '100%'
    });

    this.videoPlayer = videoPlayer;
    pageElement.find('.videoWrapper').data('videoPlayer', videoPlayer);

    videoPlayer.ready(function() {
      videoPlayer.showPosterImage();

      var pageContent = pageElement.find('.scroller, .controls, .shadow'),
          wrapper = pageElement.find('.videoPage'),
          controls = pageElement.find('.controls'),
          controlBar = pageElement.find('.vjs-control-bar'),
          playButton = pageElement.find('.vjs-play-control'),
          loadingSpinner = pageElement.find('.vjs-loading-spinner'),
          poster = pageElement.find('.vjs-poster');

      controlBar.appendTo(controls);

      var additionalControlsHtml =
        '

' +
        '

' +
        '
' +
        '
' +
        '
' +
        '

' +
        '

' +
        '
' +
        '
' +
        '

' +
        '
' +
        '
' +
        controls.data('controlBarText') +
        '
';

      $(additionalControlsHtml).appendTo(controlBar);

      controlBar.addClass('vjs-default-skin vjs-player');
      playButton.before(loadingSpinner);
      playButton.attr('tabindex','4');

      playButton.on({
        'mousedown touchstart': function() {
          $(this).addClass('pressed');
        },
        'mouseup touchend': function() {
          $(this).removeClass('pressed');
        }
      });

      controls.find('a, [tabindex]').on({
        focus: function() {
          controls.addClass('focussed');
        },

        blur: function() {
          controls.removeClass('focussed');
        }
      });

      videoPlayer.on('bufferunderrun', function() {
        loadingSpinner.addClass('showing-for-underrun');
      });

      videoPlayer.on('timeupdate', function() {
        loadingSpinner.removeClass('showing-for-underrun');
      });

      if (pageflow.browser.has('phone platform')) {
        // alternate poster image handling
        $("

").appendTo(pageElement.find(".videoWrapper"));
        poster.removeClass('vjs-poster').addClass('vjs-poster-mobile');

        // listening for exit fullscreen to force pausing
        $(document).on("fullscreenchange mozfullscreenchange webkitfullscreenchange", function() {
          if (!document.fullscreenElement && !document.mozFullScreen && !document.webkitIsFullScreen) {
            videoPlayer.pause();
          }
        });
      }

      videoPlayer.on('beforeplay', function() {
        loadingSpinner.addClass('showing-for-underrun');
      });

      videoPlayer.on("ended", function() {
        if (pageflow.browser.has('mobile platform')) {
          videoPlayer.showPosterImage();
        }

        if (pageElement.hasClass('active') && configuration.auto_change_page_on_ended) {
          pageflow.slides.next();
        }
      });

      pageElement
        .hideContentDuringPlayback({
          scrollIndicator: scrollIndicator
        })
        .hideContentDuringPlayback('attach', videoPlayer);

      wrapper
        .markWithPlayedStates({
          target: wrapper,
        })
        .markWithPlayedStates('attach', videoPlayer);

      controls
        .autoHidePlayerControls({
          pageElement: pageElement,
          target: wrapper,

          onShow: function() {
            pageContent.addClass('fade-in').removeClass('fade-out');
          },

          onHide: function() {
            pageContent.addClass('fade-out').removeClass('fade-in');
          }
        })
        .autoHidePlayerControls('attach', videoPlayer);

      pageElement.find('.volume-control').volumeSlider({
        orientation: 'v'
      });

      pageElement.find('.player_mute').muteButton();
      pageElement.find('.player_skip').skipPageButton();
      pageElement.find('.player_fullscreen').fullscreenButton();
    });
  }
}, pageflow.volumeFade, pageflow.videoHelpers, pageflow.infoBox, pageflow.commonPageCssClasses));
<commit_msg>Ensure fullscreen player controls dispaly on Android<commit_after>pageflow.pageType.register('video', _.extend({

  enhance: function(pageElement, configuration) {
    pageElement.find('.contentText').before(pageElement.find('.page_header'));
    this._initVideoPlayer(pageElement, configuration);
  },

  preload: function(pageElement, configuration) {
    return pageflow.preload.backgroundImage(pageElement.find('.background_image'));
  },

  prepare: function(pageElement, configuration) {
    this.videoPlayer.ensureCreated();
  },

  unprepare: function(pageElement, configuration) {
    this.videoPlayer.scheduleDispose();
  },

  activating: function(pageElement, configuration) {
    var videoPlayer = this.videoPlayer;

    // for SkipLinks
    $('#firstContent').attr("id","");
    var firstContentElement = pageElement.find('*[tabindex="4"], a');
    $(firstContentElement[0]).attr('id','firstContent');
    //

    this.videoPlayer.ensureCreated();
    pageElement.find('.controls')
      .autoHidePlayerControls('reset');

    pageElement.find('.videoPage')
      .markWithPlayedStates('reset', {
        autoplay: configuration.autoplay !== false
      });

    if (pageflow.browser.has('mobile platform')) {
      this.videoPlayer.showPosterImage();
    }

    $('body').on('keyup', function(e) {
      if(e.keyCode == 32){
        if(videoPlayer.paused()) {
          videoPlayer.play();
        }
        else {
          videoPlayer.pause();
        }
      }
    });
  },

  activated: function(pageElement, configuration) {
    this.pageElement = pageElement;
    var videoPlayer = this.videoPlayer;
    var that = this;

    if (pageflow.browser.has('ios platform')) {
      videoPlayer.src(videoPlayer.srcFromOptions());
    }

    if (!pageflow.browser.has('mobile platform')) {
      videoPlayer.prebuffer().done(function() {
        videoPlayer.hidePosterImage();

        if (configuration.autoplay !== false) {
          that.fadeInTimeout = setTimeout(function() {
            videoPlayer.playAndFadeIn(1000);
          }, 1000);
        }
      });
    }
  },

  deactivating: function(pageElement, configuration) {
    clearTimeout(this.fadeInTimeout);
    this.fadeSound(this.videoPlayer, 0, 400);
    this.stopListening();
    $('body').off('keyup');
  },

  deactivated: function(pageElement, configuration) {
    if (pageflow.browser.has('mobile platform')) {
      this.videoPlayer.showPosterImage();
    }
    this.videoPlayer.pause();
    this.videoPlayer.scheduleDispose();
  },

  update: function(pageElement, configuration) {
    pageElement.find('h2 .tagline').text(configuration.get('tagline') || '');
    pageElement.find('h2 .title').text(configuration.get('title') || '');
    pageElement.find('h2 .subtitle').text(configuration.get('subtitle') || '');

    pageElement.find('p').html(configuration.get('text') || '');

    this.updateInfoBox(pageElement, configuration);
    this.updateCommonPageCssClasses(pageElement, configuration);

    pageElement.find('.shadow').css({opacity: configuration.get('gradient_opacity') / 100});

    this.updateVideoPoster(pageElement, configuration.getVideoPosterUrl());
  },

  embeddedEditorViews: function() {
    return {
      '.videoWrapper': {
        view: pageflow.LazyVideoEmbeddedView,
        options: {
          propertyName: 'video_file_id'
        }
      }
    };
  },

  _initVideoPlayer: function(pageElement, configuration) {
    var that = this;
    var scrollIndicator = this.scrollIndicator;
    var videoPlayer = new pageflow.VideoPlayer.Lazy(pageElement.find('[data-template=video]'), {
      bufferUnderrunWaiting: true,
      controls: true,
      customControlsOnMobile: true,

      volumeFading: true,
      hooks: pageflow.atmo.createMediaPlayerHooks(configuration),

      mediaEvents: true,
      context: {
        page: pageElement.page('instance')
      },

      width: '100%',
      height: '100%'
    });

    this.videoPlayer = videoPlayer;
    pageElement.find('.videoWrapper').data('videoPlayer', videoPlayer);

    videoPlayer.ready(function() {
      videoPlayer.showPosterImage();

      var pageContent = pageElement.find('.scroller, .controls, .shadow'),
          wrapper = pageElement.find('.videoPage'),
          controls = pageElement.find('.controls'),
          controlBar = pageElement.find('.vjs-control-bar'),
          playButton = pageElement.find('.vjs-play-control'),
          loadingSpinner = pageElement.find('.vjs-loading-spinner'),
          poster = pageElement.find('.vjs-poster');

      controlBar.appendTo(controls);

      var additionalControlsHtml =
        '

' +
        '

' +
        '
' +
        '
' +
        '
' +
        '

' +
        '

' +
        '
' +
        '
' +
        '

' +
        '
' +
        '
' +
        controls.data('controlBarText') +
        '
';

      $(additionalControlsHtml).appendTo(controlBar);

      controlBar.addClass('vjs-default-skin vjs-player');
      playButton.before(loadingSpinner);
      playButton.attr('tabindex','4');

      playButton.on({
        'mousedown touchstart': function() {
          $(this).addClass('pressed');
        },
        'mouseup touchend': function() {
          $(this).removeClass('pressed');
        }
      });

      controls.find('a, [tabindex]').on({
        focus: function() {
          controls.addClass('focussed');
        },

        blur: function() {
          controls.removeClass('focussed');
        }
      });

      videoPlayer.on('bufferunderrun', function() {
        loadingSpinner.addClass('showing-for-underrun');
      });

      videoPlayer.on('timeupdate', function() {
        loadingSpinner.removeClass('showing-for-underrun');
      });

      if (pageflow.browser.has('phone platform')) {
        // alternate poster image handling
        $("

").appendTo(pageElement.find(".videoWrapper"));
        poster.removeClass('vjs-poster').addClass('vjs-poster-mobile');

        // listening for exit fullscreen to force pausing
        $(document).on("fullscreenchange mozfullscreenchange webkitfullscreenchange", function() {
          if (!document.fullscreenElement && !document.mozFullScreen && !document.webkitIsFullScreen) {
            videoPlayer.pause();
          }
        });
      }

      videoPlayer.on('beforeplay', function() {
        loadingSpinner.addClass('showing-for-underrun');
      });

      videoPlayer.on("ended", function() {
        if (pageflow.browser.has('mobile platform')) {
          videoPlayer.showPosterImage();
        }

        if (pageElement.hasClass('active') && configuration.auto_change_page_on_ended) {
          pageflow.slides.next();
        }
      });

      pageElement
        .hideContentDuringPlayback({
          scrollIndicator: scrollIndicator
        })
        .hideContentDuringPlayback('attach', videoPlayer);

      wrapper
        .markWithPlayedStates({
          target: wrapper,
        })
        .markWithPlayedStates('attach', videoPlayer);

      controls
        .autoHidePlayerControls({
          pageElement: pageElement,
          target: wrapper,

          onShow: function() {
            pageContent.addClass('fade-in').removeClass('fade-out');
          },

          onHide: function() {
            pageContent.addClass('fade-out').removeClass('fade-in');
          }
        })
        .autoHidePlayerControls('attach', videoPlayer);

      pageElement.find('.volume-control').volumeSlider({
        orientation: 'v'
      });

      pageElement.find('.player_mute').muteButton();
      pageElement.find('.player_skip').skipPageButton();
      pageElement.find('.player_fullscreen').fullscreenButton();

      that._ensureAndroidPhoneControlsCanBeDisplayedViaTouch(pageElement);
    });
  },

  _ensureAndroidPhoneControlsCanBeDisplayedViaTouch: function(pageElement) {
    if (pageflow.browser.has('phone platform')) {
      pageElement.find('video').on('touchend', function(event) {
        event.stopPropagation();
      });
    }
  }
}, pageflow.volumeFade, pageflow.videoHelpers, pageflow.infoBox, pageflow.commonPageCssClasses));
<|endoftext|>


<commit_before>ManageIQ.angular.app.service('topologyService', function() {
  this.tooltip = function tooltip(d) {
    var status = [
      __("Name: ") + d.item.name,
      __("Type: ") + d.item.display_kind,
      __("Status: ") + d.item.status
    ];

    if (d.item.kind == 'Host' || d.item.kind == 'Vm') {
      status.push(__("Provider: ") + d.item.provider);
    }

    return status;
  };

  this.addContextMenuOption = function(popup, text, data, callback) {
    popup.append("p").text(text)
      .on('click', function() { callback(data); });
  };

  this.searchNode = function(svg, query) {
    var nodes = svg.selectAll("g");
    if (query != "") {
      var selected = nodes.filter(function (d) {
        return d.item.name.indexOf(query) == -1;
      });
      selected.style("opacity", "0.2");
      var links = svg.selectAll("line");
      links.style("opacity", "0.2");
    }
  };

  this.resetSearch = function(d3) {
    // Display all topology nodes and links
    d3.selectAll("g, line").transition()
      .duration(2000)
      .style("opacity", 1);
  };

  this.geturl = function(d) {
    var entity_url = "";
    var action = '/show/' + d.item.miq_id;
    switch (d.item.kind) {
      case "ContainerManager":
        action = '/' + d.item.miq_id;
        entity_url = "ems_container";
        break;
      case "NetworkManager":
        entity_url = "ems_network";
        break;
      case "MiddlewareManager":
        entity_url = "ems_middleware";
        break;
      default : // for non provider entities, use the show action
        entity_url = _.snakeCase(d.item.kind);
      }

      return '/' + entity_url + action;
  };

  this.getSVG = function(d3) {
    var graph = d3.select("kubernetes-topology-graph");
    var svg = graph.select('svg');
    return svg;
  };

  this.defaultElementDimensions = function() {
    return { x: 0, y: 9, r: 17 };
  };

  this.getItemStatusClass = function(d) {
    switch (d.item.status) {
      case "OK":
      case "Active":
      case "Available":
      case "On":
      case "Ready":
      case "Running":
      case "Succeeded":
      case "Valid":
        return "success";
      case "NotReady":
      case "Failed":
      case "Error":
      case "Unreachable":
        return "error";
      case 'Warning':
      case 'Waiting':
      case 'Pending':
        return "warning";
      case 'Unknown':
      case 'Terminated':
        return "unknown";
    }
  };
});
<commit_msg>Properly generates the url to a Middleware Manager Provider.<commit_after>ManageIQ.angular.app.service('topologyService', function() {
  this.tooltip = function tooltip(d) {
    var status = [
      __("Name: ") + d.item.name,
      __("Type: ") + d.item.display_kind,
      __("Status: ") + d.item.status
    ];

    if (d.item.kind == 'Host' || d.item.kind == 'Vm') {
      status.push(__("Provider: ") + d.item.provider);
    }

    return status;
  };

  this.addContextMenuOption = function(popup, text, data, callback) {
    popup.append("p").text(text)
      .on('click', function() { callback(data); });
  };

  this.searchNode = function(svg, query) {
    var nodes = svg.selectAll("g");
    if (query != "") {
      var selected = nodes.filter(function (d) {
        return d.item.name.indexOf(query) == -1;
      });
      selected.style("opacity", "0.2");
      var links = svg.selectAll("line");
      links.style("opacity", "0.2");
    }
  };

  this.resetSearch = function(d3) {
    // Display all topology nodes and links
    d3.selectAll("g, line").transition()
      .duration(2000)
      .style("opacity", 1);
  };

  this.geturl = function(d) {
    var entity_url = "";
    var action = '/show/' + d.item.miq_id;
    switch (d.item.kind) {
      case "ContainerManager":
        action = '/' + d.item.miq_id;
        entity_url = "ems_container";
        break;
      case "NetworkManager":
        entity_url = "ems_network";
        break;
      case "MiddlewareManager":
        action = '/' + d.item.miq_id;
        entity_url = "ems_middleware";
        break;
      default : // for non provider entities, use the show action
        entity_url = _.snakeCase(d.item.kind);
      }

      return '/' + entity_url + action;
  };

  this.getSVG = function(d3) {
    var graph = d3.select("kubernetes-topology-graph");
    var svg = graph.select('svg');
    return svg;
  };

  this.defaultElementDimensions = function() {
    return { x: 0, y: 9, r: 17 };
  };

  this.getItemStatusClass = function(d) {
    switch (d.item.status) {
      case "OK":
      case "Active":
      case "Available":
      case "On":
      case "Ready":
      case "Running":
      case "Succeeded":
      case "Valid":
        return "success";
      case "NotReady":
      case "Failed":
      case "Error":
      case "Unreachable":
        return "error";
      case 'Warning':
      case 'Waiting':
      case 'Pending':
        return "warning";
      case 'Unknown':
      case 'Terminated':
        return "unknown";
    }
  };
});
<|endoftext|>


<commit_before>/*jshint undef: true, browser:true, jquery: true, devel: true */
/*global Raphael, TWEEN, OpenSpendings, vis4, vis4color */

/*
 * represents a bubble
 */
OpenSpendings.BubbleChart.Bubbles.Multi = function(node, bubblechart, origin, radius, angle, color) {

	var ns = OpenSpendings.BubbleChart, utils = ns.Utils, me = this;
	me.className = "bubble";
	me.node = node;
	me.paper = bubblechart.paper;
	me.origin = origin;
	me.bc = bubblechart;
	me.rad = radius;
	me.angle = angle;
	me.color = color;
	me.alpha = 1;
	me.visible = false;
	me.ns = ns;
	me.bubbleRad = utils.amount2rad(this.node.amount);

	/*
	 * child rotation is just used from outside to layout possible child bubbles
	 */
	me.childRotation = 0;

	/*
	 * convertes polar coordinates to x,y
	 */
	me.getXY = function() {
		var me = this, o = me.origin, a = me.angle, r = me.rad;
		me.pos.x = o.x + Math.cos(a) * r;
		me.pos.y = o.y - Math.sin(a) * r;
	};

	/*
	 * inistalizes the bubble
	 */
	me.init = function() {
		var me = this;
		me.pos = new OpenSpendings.BubbleChart.Vector(0,0);
		me.getXY();

		var breakdown = [], sum = 0, i, val;
		for (i=0; i<3; i++) {
			val = Math.random();
			breakdown.push(val);
			sum += val;
		}
		for (i in breakdown) {
			breakdown[i] = breakdown[i] / sum;
		}
		me.breakdown = breakdown;
		me.breakdownColors = [
			me.node.color, vis4color.fromHex(me.node.color).lightness('*1.2').x,
			vis4color.fromHex(me.node.color).lightness('*1.4').x
		];

		me.govRad = utils.amount2rad(me.node.amount * breakdown[0]);

		var showIcon = false; //this.bubbleRad * this.bc.bubbleScale > 30;
		// create label

		me.initialized = true;

		//me.show();
	};

	/*
	 *
	 */
	me.onclick = function(e) {
		var me = this;
		if (me.node.children.length > 0) {
			me.bc.navigateTo(me.node);
		}
	};

	me.onhover = function(e) {
		var me = this;
		e.node = me.node;
		e.position = { x:me.pos.x, y: me.pos.y };
		me.bc.onHover(e);
	};

	me.onunhover = function(e) {
		var me = this;
		e.node = me.node;
		e.position = { x:me.pos.x, y: me.pos.y };
		me.bc.onUnHover(e);
	};

	/*
	 * adds all visible elements to the page
	 */
	this.show = function() {
		var me = this, i;

		me.circle = me.paper.circle(me.pos.x, me.pos.y, me.govRad * me.bc.bubbleScale)
			.attr({ stroke: false, fill: me.color });

		me.label = $('

'+utils.formatNumber(me.node.amount)+'

'+me.node.label+'

');
		$('#bubble-chart').append(me.label);

		if (me.node.children.length > 0) {
			$(me.circle.node).css({ cursor: 'pointer'});
			$(me.label).css({ cursor: 'pointer'});
		}

		me.breakdownArcs = [];

		for (i in me.breakdown) {
			if (i < 1) {
				continue;
			}
			var arc = me.paper.path("M 0 0 L 2 2")
				.attr({ fill: me.breakdownColors[i], 'fill-opacity': 1, stroke: false });
			me.breakdownArcs.push(arc);
		}

		var list = [me.circle.node, me.label];
		for (i in me.breakdownArcs) {
			list.push(me.breakdownArcs[i].node);
		}
		var mgroup = new me.ns.MouseEventGroup(me, list);
		mgroup.click(me.onclick.bind(me));
		mgroup.hover(me.onhover.bind(me));
		mgroup.unhover(me.onunhover.bind(me));

		me.visible = true;

	};

	this.draw = function() {
		var me = this, ro = me.bubbleRad * me.bc.bubbleScale, ri = me.govRad * me.bc.bubbleScale,
			ox = me.pos.x, oy = me.pos.y, devnull = me.getXY();
		if (!me.visible) return;

		me.circle.attr({ cx: me.pos.x, cy: me.pos.y, r: ri, 'fill-opacity': me.alpha });

		// draw breakdown chart
		var i,x=me.pos.x,y=me.pos.y,x0,x1,x2,x3,y0,y1,y2,y3, oa = -Math.PI * 0.5, da;
		for (i in me.breakdown) {
			if (i < 1) continue;
			da = (me.breakdown[i] / (1 - me.breakdown[0])) * Math.PI * 2;
			x0 = x+Math.cos((oa))*ri;
			y0 = y+Math.sin((oa))*ri;
			x1 = x+Math.cos((oa+da))*ri;
			y1 = y+Math.sin((oa+da))*ri;
			x2 = x+Math.cos((oa+da))*ro;
			y2 = y+Math.sin((oa+da))*ro;
			x3 = x+Math.cos((oa))*ro;
			y3 = y+Math.sin((oa))*ro;
			oa += da;

			var path = "M"+x0+" "+y0+" A"+ri+","+ri+" 0 "+(da > Math.PI ? "1,1" : "0,1")+" "+x1+","+y1+" L"+x2+" "+y2+" A"+ro+","+ro+" 0 "+(da > Math.PI ? "1,0" : "0,0")+" "+x3+" "+y3+" Z";

			me.breakdownArcs[i-1]
				.attr({ path: path, 'fill-opacity': me.alpha*0.5 });
		}

		//me.label.attr({ x: me.pos.x, y: me.pos.y, 'font-size': Math.max(4, me.bubbleRad * me.bc.bubbleScale * 0.25) });
		if (ro < 20) me.label.hide();
		else {
			me.label.show();

			if (ro < 40) {
				me.label.find('.desc').hide();
			} else {
				// full label
				me.label.find('.desc').show();
			}
		}
		me.label.css({ width: 2*ro+'px', opacity: me.alpha });
		me.label.css({ left: (me.pos.x-ro)+'px', top: (me.pos.y-me.label.height()*0.5)+'px' });

		//if (me.icon) me.icon.translate(me.pos.x - ox, me.pos.y - oy);

	};

	/*
	 * removes all visible elements from the page
	 */
	this.hide = function() {
		var me = this, i;
		me.circle.remove();
		me.label.remove();
		//$('#bubble-chart')
		me.visible = false;
		for (i in me.breakdownArcs) {
			me.breakdownArcs[i].remove();
		}

		//if (me.icon) me.icon.remove();
	};

	this.init();
};<commit_msg>changed to absolute lightness<commit_after>/*jshint undef: true, browser:true, jquery: true, devel: true */
/*global Raphael, TWEEN, OpenSpendings, vis4, vis4color */

/*
 * represents a bubble
 */
OpenSpendings.BubbleChart.Bubbles.Multi = function(node, bubblechart, origin, radius, angle, color) {

	var ns = OpenSpendings.BubbleChart, utils = ns.Utils, me = this;
	me.className = "bubble";
	me.node = node;
	me.paper = bubblechart.paper;
	me.origin = origin;
	me.bc = bubblechart;
	me.rad = radius;
	me.angle = angle;
	me.color = color;
	me.alpha = 1;
	me.visible = false;
	me.ns = ns;
	me.bubbleRad = utils.amount2rad(this.node.amount);

	/*
	 * child rotation is just used from outside to layout possible child bubbles
	 */
	me.childRotation = 0;

	/*
	 * convertes polar coordinates to x,y
	 */
	me.getXY = function() {
		var me = this, o = me.origin, a = me.angle, r = me.rad;
		me.pos.x = o.x + Math.cos(a) * r;
		me.pos.y = o.y - Math.sin(a) * r;
	};

	/*
	 * inistalizes the bubble
	 */
	me.init = function() {
		var me = this;
		me.pos = new OpenSpendings.BubbleChart.Vector(0,0);
		me.getXY();

		var breakdown = [], sum = 0, i, val;
		for (i=0; i<3; i++) {
			val = Math.random();
			breakdown.push(val);
			sum += val;
		}
		for (i in breakdown) {
			breakdown[i] = breakdown[i] / sum;
		}
		me.breakdown = breakdown;
		me.breakdownColors = [
			me.node.color, vis4color.fromHex(me.node.color).lightness(0.8).x,
			vis4color.fromHex(me.node.color).lightness(0.9).x
		];

		me.govRad = utils.amount2rad(me.node.amount * breakdown[0]);

		var showIcon = false; //this.bubbleRad * this.bc.bubbleScale > 30;
		// create label

		me.initialized = true;

		//me.show();
	};

	/*
	 *
	 */
	me.onclick = function(e) {
		var me = this;
		if (me.node.children.length > 0) {
			me.bc.navigateTo(me.node);
		}
	};

	me.onhover = function(e) {
		var me = this;
		e.node = me.node;
		e.position = { x:me.pos.x, y: me.pos.y };
		me.bc.onHover(e);
	};

	me.onunhover = function(e) {
		var me = this;
		e.node = me.node;
		e.position = { x:me.pos.x, y: me.pos.y };
		me.bc.onUnHover(e);
	};

	/*
	 * adds all visible elements to the page
	 */
	this.show = function() {
		var me = this, i;

		me.circle = me.paper.circle(me.pos.x, me.pos.y, me.govRad * me.bc.bubbleScale)
			.attr({ stroke: false, fill: me.color });

		me.label = $('

'+utils.formatNumber(me.node.amount)+'

'+me.node.label+'

');
		$('#bubble-chart').append(me.label);

		if (me.node.children.length > 0) {
			$(me.circle.node).css({ cursor: 'pointer'});
			$(me.label).css({ cursor: 'pointer'});
		}

		me.breakdownArcs = [];

		for (i in me.breakdown) {
			if (i < 1) {
				continue;
			}
			var arc = me.paper.path("M 0 0 L 2 2")
				.attr({ fill: me.breakdownColors[i], 'fill-opacity': 1, stroke: false });
			me.breakdownArcs.push(arc);
		}

		var list = [me.circle.node, me.label];
		for (i in me.breakdownArcs) {
			list.push(me.breakdownArcs[i].node);
		}
		var mgroup = new me.ns.MouseEventGroup(me, list);
		mgroup.click(me.onclick.bind(me));
		mgroup.hover(me.onhover.bind(me));
		mgroup.unhover(me.onunhover.bind(me));

		me.visible = true;

	};

	this.draw = function() {
		var me = this, ro = me.bubbleRad * me.bc.bubbleScale, ri = me.govRad * me.bc.bubbleScale,
			ox = me.pos.x, oy = me.pos.y, devnull = me.getXY();
		if (!me.visible) return;

		me.circle.attr({ cx: me.pos.x, cy: me.pos.y, r: ri, 'fill-opacity': me.alpha });

		// draw breakdown chart
		var i,x=me.pos.x,y=me.pos.y,x0,x1,x2,x3,y0,y1,y2,y3, oa = -Math.PI * 0.5, da;
		for (i in me.breakdown) {
			if (i < 1) continue;
			da = (me.breakdown[i] / (1 - me.breakdown[0])) * Math.PI * 2;
			x0 = x+Math.cos((oa))*ri;
			y0 = y+Math.sin((oa))*ri;
			x1 = x+Math.cos((oa+da))*ri;
			y1 = y+Math.sin((oa+da))*ri;
			x2 = x+Math.cos((oa+da))*ro;
			y2 = y+Math.sin((oa+da))*ro;
			x3 = x+Math.cos((oa))*ro;
			y3 = y+Math.sin((oa))*ro;
			oa += da;

			var path = "M"+x0+" "+y0+" A"+ri+","+ri+" 0 "+(da > Math.PI ? "1,1" : "0,1")+" "+x1+","+y1+" L"+x2+" "+y2+" A"+ro+","+ro+" 0 "+(da > Math.PI ? "1,0" : "0,0")+" "+x3+" "+y3+" Z";

			me.breakdownArcs[i-1]
				.attr({ path: path, 'fill-opacity': me.alpha*0.5 });
		}

		//me.label.attr({ x: me.pos.x, y: me.pos.y, 'font-size': Math.max(4, me.bubbleRad * me.bc.bubbleScale * 0.25) });
		if (ro < 20) me.label.hide();
		else {
			me.label.show();

			if (ro < 40) {
				me.label.find('.desc').hide();
			} else {
				// full label
				me.label.find('.desc').show();
			}
		}
		me.label.css({ width: 2*ro+'px', opacity: me.alpha });
		me.label.css({ left: (me.pos.x-ro)+'px', top: (me.pos.y-me.label.height()*0.5)+'px' });

		//if (me.icon) me.icon.translate(me.pos.x - ox, me.pos.y - oy);

	};

	/*
	 * removes all visible elements from the page
	 */
	this.hide = function() {
		var me = this, i;
		me.circle.remove();
		me.label.remove();
		//$('#bubble-chart')
		me.visible = false;
		for (i in me.breakdownArcs) {
			me.breakdownArcs[i].remove();
		}

		//if (me.icon) me.icon.remove();
	};

	this.init();
};<|endoftext|>


<commit_before>'use strict';

require('./_mobile-header.scss');

module.exports = {
  template: require('./mobile-header.html'),
  controller: ['$log', '$http', '$location', '$mdToast', '$rootScope', '$state', 'authService', MobileHeaderController],
  controllerAs: 'mobileHeaderCtrl',
  bindings: {
    ways: '<'
  }
};

function MobileHeaderController($log, $http, $location, $mdToast, $rootScope, $state, authService) {

  this.currentUrl = $location.url();

  $rootScope.$on('$locationChangeSuccess', () => {
    this.currentUrl = $location.url();
  });

  this.gotoWay = function() {
    $location.url('/way');
  };
  this.gotoHome = function() {
    $location.url('/home');
  };
  this.gotoMessage = function() {
    $location.url('/message');
  };

  this.toggleProfile = function() {
    $rootScope.$emit('toggleProfile');
  };

  this.logout = function() {
    $log.debug('MobileHeaderController.logout');
    authService.logout()
    .then( () => {
      $mdToast.showSimple('You have logged out successfully')
      .then( $location.url('/join'));
    })
    .catch( err => {
      $log.error(err.message);
      $mdToast.showSimple(`Unable to log out | ${err}`);
    });
  };
}
<commit_msg>Removed unecessary dependency.<commit_after>'use strict';

require('./_mobile-header.scss');

module.exports = {
  template: require('./mobile-header.html'),
  controller: ['$log', '$http', '$location', '$mdToast', '$rootScope', 'authService', MobileHeaderController],
  controllerAs: 'mobileHeaderCtrl',
  bindings: {
    ways: '<'
  }
};

function MobileHeaderController($log, $http, $location, $mdToast, $rootScope, authService) {

  this.currentUrl = $location.url();

  $rootScope.$on('$locationChangeSuccess', () => {
    this.currentUrl = $location.url();
  });

  this.gotoWay = function() {
    $location.url('/way');
  };
  this.gotoHome = function() {
    $location.url('/home');
  };
  this.gotoMessage = function() {
    $location.url('/message');
  };

  this.toggleProfile = function() {
    $rootScope.$emit('toggleProfile');
  };

  this.logout = function() {
    $log.debug('MobileHeaderController.logout');
    authService.logout()
    .then( () => {
      $mdToast.showSimple('You have logged out successfully')
      .then( $location.url('/join'));
    })
    .catch( err => {
      $log.error(err.message);
      $mdToast.showSimple(`Unable to log out | ${err}`);
    });
  };
}
<|endoftext|>


<commit_before>import React from 'react';
import FontAwesome from 'react-fontawesome';

import styles from './styles.scss';
import Range from 'react-range-progress';

class VolumeSlider extends React.Component {

  handleClick(value) {
    this.props.handleClick(value);
  }

  render() {
    return (

        <Range
          value={this.props.fill}
          fillColor={volume_slider_colors.fillColor}
          trackColor={volume_slider_colors.trackColor}
          thumbColor={volume_slider_colors.thumbColor}
          height={4}
          width='100%'
          onChange={this.handleClick.bind(this)}
        />

    );
  }
}

const volume_slider_colors = {
  fillColor: { r: 248, g: 248, b: 242, a: 1 },
  trackColor: { r: 68, g: 71, b: 90, a: 1 },
  thumbColor: { r: 248, g: 248, b: 242, a: 1 }
};

export default VolumeSlider;
<commit_msg>Code quality VolumeSlider<commit_after>import React from 'react';

import styles from './styles.scss';
import Range from 'react-range-progress';

const volumeSliderColors = {
  fillColor: { r: 248, g: 248, b: 242, a: 1 },
  trackColor: { r: 68, g: 71, b: 90, a: 1 },
  thumbColor: { r: 248, g: 248, b: 242, a: 1 }
};

class VolumeSlider extends React.Component {

  handleClick (value) {
    this.props.handleClick(value);
  }

  render () {
    return (

        <Range
          value={this.props.fill}
          fillColor={volumeSliderColors.fillColor}
          trackColor={volumeSliderColors.trackColor}
          thumbColor={volumeSliderColors.thumbColor}
          height={4}
          width='100%'
          onChange={this.handleClick.bind(this)}
        />

    );
  }
}

export default VolumeSlider;
<|endoftext|>


<commit_before>import React, { PropTypes, Component } from 'react';
import { connect } from 'react-redux';
import IconButton from 'material-ui/IconButton';
import EditIcon from 'material-ui/svg-icons/editor/mode-edit';
import TrashIcon from 'material-ui/svg-icons/action/delete-forever';
import ArchiveIcon from 'material-ui/svg-icons/action/assignment-returned';
import Toggle from 'material-ui/Toggle';

import styles from './styles.css';
import { saveOffre } from 'containers/Commande/actions';
import OffreDetailsCard from 'components/OffreDetailsCard';

class Offre extends Component { // eslint-disable-line
  static propTypes = {
    offre: PropTypes.object.isRequired,
    typeProduit: PropTypes.object.isRequired,
    handleToggeState: PropTypes.func.isRequired,
    save: PropTypes.func.isRequired,
  }

  handleDelete = () => ({})

  handleStore = () => ({})

  handleToggle = () =>
    this.props.save({
      ...this.props.offre,
      active: !this.props.offre.active,
    }, null)

  render() {
    const { offre, typeProduit, handleToggeState } = this.props;
    return (

          {
            <div className={`row ${styles.offre}`}>

                <OffreDetailsCard offre={offre} typeProduit={typeProduit} />

          }

              <IconButton
                onClick={handleToggeState}
                tooltip="Modifier"
                tooltipPosition="top-center"
              >
                <EditIcon />
              </IconButton>

              <IconButton
                onClick={this.handleDelete}
                tooltip="Supprimer"
                tooltipPosition="top-center"
              >
                <TrashIcon />
              </IconButton>

              <IconButton
                onClick={this.handleStore}
                tooltip="Archiver"
                tooltipPosition="top-center"
              >
                <ArchiveIcon />
              </IconButton>

              <Toggle
                toggled={offre.active}
                label={offre.active ? 'active' : 'désactivée'}
                onToggle={this.handleToggle}
              />

    );
  }
}

const mapDispatchToProps = (dispatch) => ({
  save: (datas) => dispatch(saveOffre(datas)),
});

export default connect(null, mapDispatchToProps)(Offre);
<commit_msg>griser icones non implémentés<commit_after>import React, { PropTypes, Component } from 'react';
import { connect } from 'react-redux';
import IconButton from 'material-ui/IconButton';
import EditIcon from 'material-ui/svg-icons/editor/mode-edit';
import TrashIcon from 'material-ui/svg-icons/action/delete-forever';
import ArchiveIcon from 'material-ui/svg-icons/action/assignment-returned';
import Toggle from 'material-ui/Toggle';

import styles from './styles.css';
import { saveOffre } from 'containers/Commande/actions';
import OffreDetailsCard from 'components/OffreDetailsCard';

class Offre extends Component { // eslint-disable-line
  static propTypes = {
    offre: PropTypes.object.isRequired,
    typeProduit: PropTypes.object.isRequired,
    handleToggeState: PropTypes.func.isRequired,
    save: PropTypes.func.isRequired,
  }

  handleDelete = () => ({})

  handleStore = () => ({})

  handleToggle = () =>
    this.props.save({
      ...this.props.offre,
      active: !this.props.offre.active,
    }, null)

  render() {
    const { offre, typeProduit, handleToggeState } = this.props;
    return (

          {
            <div className={`row ${styles.offre}`}>

                <OffreDetailsCard offre={offre} typeProduit={typeProduit} />

          }

              <IconButton
                onClick={handleToggeState}
                tooltip="Modifier"
                tooltipPosition="top-center"
              >
                <EditIcon />
              </IconButton>

              <IconButton
                onClick={this.handleDelete}
                tooltip="Supprimer (non implémenté)"
                tooltipPosition="top-center"
              >
                <TrashIcon color="gray" />
              </IconButton>

              <IconButton
                onClick={this.handleStore}
                tooltip="Archiver (non implémenté)"
                tooltipPosition="top-center"
              >
                <ArchiveIcon color="gray" />
              </IconButton>

              <Toggle
                toggled={offre.active}
                label={offre.active ? 'active' : 'désactivée'}
                onToggle={this.handleToggle}
              />

    );
  }
}

const mapDispatchToProps = (dispatch) => ({
  save: (datas) => dispatch(saveOffre(datas)),
});

export default connect(null, mapDispatchToProps)(Offre);
<|endoftext|>


<commit_before>angular.module('it').controller('TemplateCtrl', function($scope, $location, TemplateService, template, mode) {
  $scope.template = template;
  $scope.mode = mode;

  if ($scope.mode === 'copy') {
    $scope.template.name = '';
  }

  $scope.titlePlaceholder = 'ex. Feature: {{title}}';

  (function(preload) {
    if (!preload || $scope.template) {
      return;
    }
    $scope.template = {
      name: 'template0',
      owner: 'kentcdodds',
      repo: 'issue-template',
      template: ['# Test Input: {{field0}}', '',
        '## Test Select: {{field1}}', '',
        'Test Radio: {{field2}}', '',
        'Test Checkbox: {{field3}}'].join('\n'),
      fields: [
        {
          name: 'Test Input',
          element: 'input',
          type: 'text',
          value: 'Pre loaded value'
        },
        {
          name: 'Test Select',
          element: 'select',
          type: 'empty',
          value: 'option1,option2,option3'
        },
        {
          name: 'Test Radio',
          element: 'input',
          type: 'radio',
          value: 'option1,option2,option3'
        },
        {
          name: 'Test Checkbox',
          element: 'input',
          type: 'checkbox',
          value: 'option1,option2,option3'
        }
      ]
    };
  })(false);

  $scope.deleteTemplate = function() {
    TemplateService.deleteTemplate($scope.template);
    $location.path('/');
  };

  $scope.copyTemplate = function() {
    $location.path('/new-template').search({
      copy: true,
      owner: $scope.template.owner,
      repo: $scope.template.repo,
      name: $scope.template.name
    });
  };

  $scope.removeField = function(index) {
    $scope.template.fields.splice(index, 1);
  };

  function getTemplateUrl() {
    var owner = $scope.template.owner;
    var project = $scope.template.repo;
    var name = $scope.template.name;
    return owner + '/' + project + '/' + name;
  }

  $scope.submitTemplate = function() {
    $scope.template.createdBy = $scope.user.login;
    TemplateService.saveTemplate(JSON.parse(angular.toJson($scope.template)));
    $scope.templateUrl = '#/' + getTemplateUrl();
  };

});<commit_msg>Cleanup template url generation.<commit_after>angular.module('it').controller('TemplateCtrl', function($scope, $location, util, TemplateService, template, mode) {
  $scope.template = template;
  $scope.mode = mode;

  if ($scope.mode === 'copy') {
    $scope.template.name = '';
  }

  $scope.titlePlaceholder = 'ex. Feature: {{title}}';

  (function(preload) {
    if (!preload || $scope.template) {
      return;
    }
    $scope.template = {
      name: 'template0',
      owner: 'kentcdodds',
      repo: 'issue-template',
      template: ['# Test Input: {{field0}}', '',
        '## Test Select: {{field1}}', '',
        'Test Radio: {{field2}}', '',
        'Test Checkbox: {{field3}}'].join('\n'),
      fields: [
        {
          name: 'Test Input',
          element: 'input',
          type: 'text',
          value: 'Pre loaded value'
        },
        {
          name: 'Test Select',
          element: 'select',
          type: 'empty',
          value: 'option1,option2,option3'
        },
        {
          name: 'Test Radio',
          element: 'input',
          type: 'radio',
          value: 'option1,option2,option3'
        },
        {
          name: 'Test Checkbox',
          element: 'input',
          type: 'checkbox',
          value: 'option1,option2,option3'
        }
      ]
    };
  })(false);

  $scope.deleteTemplate = function() {
    TemplateService.deleteTemplate($scope.template);
    $location.path('/');
  };

  $scope.copyTemplate = function() {
    $location.path('/new-template').search({
      copy: true,
      owner: $scope.template.owner,
      repo: $scope.template.repo,
      name: $scope.template.name
    });
  };

  $scope.removeField = function(index) {
    $scope.template.fields.splice(index, 1);
  };

  $scope.submitTemplate = function() {
    $scope.template.createdBy = $scope.user.login;
    TemplateService.saveTemplate(JSON.parse(angular.toJson($scope.template)));
    $scope.templateUrl = util.simpleCompile('#/:owner/:repo/:name', $scope.template);
  };

});<|endoftext|>