<commit_before>/*global angular */

/**
 * @ngdoc directive
 * @name TatUi.directive:messagesItem
 * @restrict AE
 * @description
 * display a route message
 */
angular.module('TatUi').directive('messagesStandardviewItem', function($compile) {
  'use strict';

  return {
    restrict: 'E',
    scope: {
      message: '=',
      topic: '=',
      isTopicDeletableMsg: '=',
      isTopicUpdatableMsg: '=',
      isTopicDeletableAllMsg: '=',
      isTopicUpdatableAllMsg: '=',
      isTopicRw: '='
    },
    replace: true,
    templateUrl: '../build/tatwebui-plugin-standardview/standardview/list/standardview-item.directive.html',
    controllerAs: 'ctrl',
    /**
     * @ngdoc controller
     * @name TatUi.controller:messagesItem
     * @requires TatUi.Authentication       Tat Authentication
     * @requires TatUi.TatEngineMessageRsc  Tat Engine Resource Message
     * @requires TatUi.TatEngine            Global Tat Engine service
     *
     * @description Directive controller
     */
    controller: function($scope, $rootScope, TatEngineMessageRsc,
      TatEngineMessagesRsc, TatEngine, TatMessage, Authentication) {
      var self = this;
      this.answerPanel = false;
      this.isTopicTasks = false;

      this.canDoneMessage = false;
      this.canDeleteFromTasksMessage = false;
      this.canAddToTasksMessage = true;
      this.privateTasksTopic = 'Private/' + Authentication.getIdentity().username + '/Tasks';

      this.getBrightness = function(rgb) {
        var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(rgb);
        return result ?
          0.2126 * parseInt(result[1], 16) +
          0.7152 * parseInt(result[2], 16) +
          0.0722 * parseInt(result[3], 16) : 0;
      };

      this.addLabelDoing = function(message) {
        TatMessage.addLabel(message, $scope.topic.topic, "doing", "#5484ed",
          function() {
              TatMessage.addLabel(message,
              $scope.topic.topic,
              "doing:" + Authentication.getIdentity().username,
              "#5484ed" //blue
          )}
        );
        self.removeLabel(message, "done");
      };

      /**
       * @ngdoc function
       * @name toggleTaskMessage
       * @methodOf TatUi.controller:messagesItem
       * @description create or remove a task from one message
       */
      this.addToTasksMessage = function(message) {
        if (message.topics.length == 1 && self.isTopicTasks) {
          self.addLabelDoing(message);
          return;
        }

        TatEngineMessageRsc.update({
          'idReference': message._id,
          'action': 'task',
          'topic': self.privateTasksTopic
        }).$promise.then(function(resp) {
          TatEngine.displayReturn(resp);
          self.addLabelDoing(message);
          message.topics.push("/" + self.privateTasksTopic);
          self.computeFlagsTask(message);
        }, function(resp) {
          TatEngine.displayReturn(resp);
        });
      };

      this.deleteFromTasksMessage = function(message) {
        // msg only in tasks topic
        if (message.topics.length == 1 && self.isTopicTasks) {
          self.removeLabel(message, "doing");
          return;
        }

        $scope.setInToDone = false;
        TatEngineMessageRsc.update({
          'idReference': $scope.message._id,
          'action': 'untask',
          'topic': self.privateTasksTopic
        }).$promise.then(function(resp) {
          TatEngine.displayReturn(resp);
          self.removeLabel(message, "doing");
          if (self.isTopicTasks) {
            message.hide = true;
          }
          self.removePrivateTopicOnLocalMsg(message);
          self.computeFlagsTask(message);
        }, function(resp) {
          TatEngine.displayReturn(resp);
        });
      };

      this.addLabelDone = function(message) {
        TatMessage.addLabel(message, $scope.topic.topic, "done", "#14892c"); // green
        self.removeLabel(message, "doing");
        self.canDoneMessage = false;
      };

      this.removePrivateTopicOnLocalMsg = function(message) {
        message.topics = _.remove(message.topics, function(t) {
          if (t.indexOf("/" + self.privateTasksTopic) === 0) {
            return false;
          }
          return true;
        });
      };

      this.doneMessage = function(message) {
        // msg only in tasks topic
        if (message.topics.length == 1 && self.isTopicTasks) {
          self.addLabelDone(message);
          return;
        }

        $scope.setInToDone = false;
        TatEngineMessageRsc.update({
          'idReference': $scope.message._id,
          'action': 'untask',
          'topic': self.privateTasksTopic
        }).$promise.then(function(resp) {
          TatEngine.displayReturn(resp);
          self.addLabelDone(message);
          if (self.isTopicTasks) {
            message.hide = true;
          }
          self.removePrivateTopicOnLocalMsg(message);
          self.computeFlagsTask(message);
        }, function(resp) {
          TatEngine.displayReturn(resp);
        });
      };

      /**
       * @ngdoc function
       * @name deleteMessage
       * @methodOf TatUi.controller:messagesItem
       * @description delete a message from a Private topic
       */
      this.deleteMessage = function(message) {
        TatEngineMessagesRsc.delete({
          'idMessageToDelete': message._id,
          'cascade': 'cascade/'
        }).$promise.then(function(resp) {
          TatEngine.displayReturn(resp);
          message.hide = true;
          message.displayed = false;
        }, function(response) {
          TatEngine.displayReturn(response);
        });
      };

      /**
       * @ngdoc function
       * @name updateMessage
       * @methodOf TatUi.controller:messagesItem
       * @description Update a message
       */
      this.updateMessage = function(message) {
        message.updating = false;
        TatEngineMessageRsc.update({
          'topic': $scope.topic.topic.indexOf("/") === 0 ? $scope.topic.topic.substr(1) : $scope.topic.topic,
          'idReference': message._id,
          'text': message.text,
          'action': 'update',
        }).$promise.then(function(resp) {
          message.text = resp.message.text;
        }, function(resp) {
          message.updating = true;
          TatEngine.displayReturn(resp);
        });
      };

      /**
       * @ngdoc function
       * @name hasLiked
       * @methodOf TatUi.controller:messagesItem
       * @description Define if the message is marked 'like'
       * @return {bool} If true, 'like'
       */
      this.hasLiked = function(message) {
        if (message && message.likers) {
          return _.include(message.likers, Authentication.getIdentity().username);
        }
        return false;
      };

      /**
       * @ngdoc function
       * @name toggleLikeMessage
       * @methodOf TatUi.controller:messagesItem
       * @description toggle 'like' state on the message
       *
       */
      this.toggleLikeMessage = function(message) {
        var action = self.hasLiked(message) ? 'unlike' : 'like';
        TatEngineMessageRsc.update({
          'topic': $scope.topic.topic.indexOf("/") === 0 ? $scope.topic.topic.substr(1) : $scope.topic.topic,
          'idReference': message._id,
          'action': action
        }).$promise.then(function(resp) {
          if (action === 'like') {
            if (!message.likers) {
              message.likers = [];
            }
            message.likers.push(Authentication.getIdentity().username);
            message.nbLikes++;
          } else {
            message.likers = _.remove(message.likers,
              Authentication.getIdentity().username);
            message.nbLikes--;
          }
        }, function(err) {
          TatEngine.displayReturn(err);
        });
      };

      /**
       * @ngdoc function
       * @name removeLabel
       * @methodOf TatUi.controller:messagesItem
       * @description remove a label
       * @param {object} message Message on which to add a label
       * @param {object} label   Label {text} to remove
       */
      this.removeLabel = function(message, labelText) {
        if (!message.labels) {
          return;
        }
        var toRefresh = false;
        var newList = [];
        for (var i = 0; i < message.labels.length; i++) {
          var l = message.labels[i];
          if (l.text === labelText ||  (labelText === 'doing' && l.text
              .indexOf('doing:') === 0)) {
            toRefresh = true;
            TatEngineMessageRsc.update({
              'action': 'unlabel',
              'topic': $scope.topic.topic.indexOf("/") === 0 ? $scope.topic.topic.substr(1) : $scope.topic.topic,
              'idReference': $scope.message._id,
              'text': l.text
            }).$promise.then(function(resp) {
              //nothing here
            }, function(resp) {
              TatEngine.displayReturn(resp);
            });
          } else {
            newList.push(l);
          }
        }

        if (toRefresh)  {
          message.labels = newList;
        }
        self.computeFlagsTask(message);
      };

      this.urlMessage = function(message) {
        $rootScope.$broadcast('topic-change', {
          topic: $scope.topic.topic.indexOf("/") === 0 ? $scope.topic.topic.substr(1) : $scope.topic.topic,
          idMessage: message._id,
          reload: true
        });
      };

      this.containsLabel = function(message, labelText) {
        if (message.inReplyOfIDRoot) {
          return false;
        }
        var r = false;
        if (message.labels) {
          for (var i = 0; i < message.labels.length; i++) {
            var l = message.labels[i];
            if (l.text === labelText) {
              return true;
            }
          }
        }
        return r;
      };

      this.init = function(message) {
        message.loading = true;
        return TatEngineMessagesRsc.list({
          topic: $scope.topic.topic.indexOf("/") === 0 ? $scope.topic.topic.substr(1) : $scope.topic.topic,
          treeView: "onetree",
          idMessage: message._id,
          limit: 1,
          skip: 0
        }).$promise.then(function(data) {
          message.loading = false;
          if (!data.messages || data.messages.length != 1) {
            TatEngine.displayReturn("Invalid return while getting message");
          } else {
            message.replies = data.messages[0].replies;
          }
        }, function(err) {
          message.loading = false;
          TatEngine.displayReturn(err);
        });

        if ($scope.topic.topic.indexOf(self.privateTasksTopic) === 0) {
          self.isTopicTasks = true;
        }
        this.computeFlagsTask(message);
      };

      this.computeFlagsTask = function(message) {
        self.canDoneMessage = false;
        self.canDeleteFromTasksMessage = false;
        self.canAddToTasksMessage = true;
        for (var i = 0; i < message.topics.length; i++) {
          if (message.topics[i].indexOf("/" + self.privateTasksTopic) === 0) {
            if (!self.containsLabel(message, "done")) {
              self.canDoneMessage = true;
            }
            // if msg is not only in tasks topic
            if (message.topics.length > 1) {
              self.canDeleteFromTasksMessage = true;
              $scope.isTopicDeletableMsg = false;
              $scope.isTopicDeletableAllMsg = false;
            } else {
              $scope.isTopicDeletableMsg = true;
              $scope.isTopicDeletableAllMsg = true;
            }
          }
        };
        if (self.canDoneMessage || self.isTopicTasks) {
          self.canAddToTasksMessage = false;
        }
      };

      this.init($scope.message);

    }
  };
});
<commit_msg>feat: add done:username<commit_after>/*global angular */

/**
 * @ngdoc directive
 * @name TatUi.directive:messagesItem
 * @restrict AE
 * @description
 * display a route message
 */
angular.module('TatUi').directive('messagesStandardviewItem', function($compile) {
  'use strict';

  return {
    restrict: 'E',
    scope: {
      message: '=',
      topic: '=',
      isTopicDeletableMsg: '=',
      isTopicUpdatableMsg: '=',
      isTopicDeletableAllMsg: '=',
      isTopicUpdatableAllMsg: '=',
      isTopicRw: '='
    },
    replace: true,
    templateUrl: '../build/tatwebui-plugin-standardview/standardview/list/standardview-item.directive.html',
    controllerAs: 'ctrl',
    /**
     * @ngdoc controller
     * @name TatUi.controller:messagesItem
     * @requires TatUi.Authentication       Tat Authentication
     * @requires TatUi.TatEngineMessageRsc  Tat Engine Resource Message
     * @requires TatUi.TatEngine            Global Tat Engine service
     *
     * @description Directive controller
     */
    controller: function($scope, $rootScope, TatEngineMessageRsc,
      TatEngineMessagesRsc, TatEngine, TatMessage, Authentication) {
      var self = this;
      this.answerPanel = false;
      this.isTopicTasks = false;

      this.canDoneMessage = false;
      this.canDeleteFromTasksMessage = false;
      this.canAddToTasksMessage = true;
      this.privateTasksTopic = 'Private/' + Authentication.getIdentity().username + '/Tasks';

      this.getBrightness = function(rgb) {
        var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(rgb);
        return result ?
          0.2126 * parseInt(result[1], 16) +
          0.7152 * parseInt(result[2], 16) +
          0.0722 * parseInt(result[3], 16) : 0;
      };

      this.addLabelDoing = function(message) {
        TatMessage.addLabel(message, $scope.topic.topic, "doing", "#5484ed",
          function() {
              TatMessage.addLabel(message,
              $scope.topic.topic,
              "doing:" + Authentication.getIdentity().username,
              "#5484ed" //blue
          )}
        );
        self.removeLabel(message, "done");
      };

      /**
       * @ngdoc function
       * @name toggleTaskMessage
       * @methodOf TatUi.controller:messagesItem
       * @description create or remove a task from one message
       */
      this.addToTasksMessage = function(message) {
        if (message.topics.length == 1 && self.isTopicTasks) {
          self.addLabelDoing(message);
          return;
        }

        TatEngineMessageRsc.update({
          'idReference': message._id,
          'action': 'task',
          'topic': self.privateTasksTopic
        }).$promise.then(function(resp) {
          TatEngine.displayReturn(resp);
          self.addLabelDoing(message);
          message.topics.push("/" + self.privateTasksTopic);
          self.computeFlagsTask(message);
        }, function(resp) {
          TatEngine.displayReturn(resp);
        });
      };

      this.deleteFromTasksMessage = function(message) {
        // msg only in tasks topic
        if (message.topics.length == 1 && self.isTopicTasks) {
          self.removeLabel(message, "doing");
          return;
        }

        $scope.setInToDone = false;
        TatEngineMessageRsc.update({
          'idReference': $scope.message._id,
          'action': 'untask',
          'topic': self.privateTasksTopic
        }).$promise.then(function(resp) {
          TatEngine.displayReturn(resp);
          self.removeLabel(message, "doing");
          if (self.isTopicTasks) {
            message.hide = true;
          }
          self.removePrivateTopicOnLocalMsg(message);
          self.computeFlagsTask(message);
        }, function(resp) {
          TatEngine.displayReturn(resp);
        });
      };

      this.addLabelDone = function(message) {
        TatMessage.addLabel(message, $scope.topic.topic, "done", "#14892c", function() {
          TatMessage.addLabel(message,
            $scope.topic.topic,
            "done:" + Authentication.getIdentity().username,
            "#14892c", //green,
            function() { self.addToMasterTicket(message);}
          );
        }); // green
        self.removeLabel(message, "doing");
        self.canDoneMessage = false;
      };

      this.removePrivateTopicOnLocalMsg = function(message) {
        message.topics = _.remove(message.topics, function(t) {
          if (t.indexOf("/" + self.privateTasksTopic) === 0) {
            return false;
          }
          return true;
        });
      };

      this.doneMessage = function(message) {
        // msg only in tasks topic
        if (message.topics.length == 1 && self.isTopicTasks) {
          self.addLabelDone(message);
          return;
        }

        $scope.setInToDone = false;
        TatEngineMessageRsc.update({
          'idReference': $scope.message._id,
          'action': 'untask',
          'topic': self.privateTasksTopic
        }).$promise.then(function(resp) {
          TatEngine.displayReturn(resp);
          self.addLabelDone(message);
          if (self.isTopicTasks) {
            message.hide = true;
          }
          self.removePrivateTopicOnLocalMsg(message);
          self.computeFlagsTask(message);
        }, function(resp) {
          TatEngine.displayReturn(resp);
        });
      };

      /**
       * @ngdoc function
       * @name deleteMessage
       * @methodOf TatUi.controller:messagesItem
       * @description delete a message from a Private topic
       */
      this.deleteMessage = function(message) {
        TatEngineMessagesRsc.delete({
          'idMessageToDelete': message._id,
          'cascade': 'cascade/'
        }).$promise.then(function(resp) {
          TatEngine.displayReturn(resp);
          message.hide = true;
          message.displayed = false;
        }, function(response) {
          TatEngine.displayReturn(response);
        });
      };

      /**
       * @ngdoc function
       * @name updateMessage
       * @methodOf TatUi.controller:messagesItem
       * @description Update a message
       */
      this.updateMessage = function(message) {
        message.updating = false;
        TatEngineMessageRsc.update({
          'topic': $scope.topic.topic.indexOf("/") === 0 ? $scope.topic.topic.substr(1) : $scope.topic.topic,
          'idReference': message._id,
          'text': message.text,
          'action': 'update',
        }).$promise.then(function(resp) {
          message.text = resp.message.text;
        }, function(resp) {
          message.updating = true;
          TatEngine.displayReturn(resp);
        });
      };

      /**
       * @ngdoc function
       * @name hasLiked
       * @methodOf TatUi.controller:messagesItem
       * @description Define if the message is marked 'like'
       * @return {bool} If true, 'like'
       */
      this.hasLiked = function(message) {
        if (message && message.likers) {
          return _.include(message.likers, Authentication.getIdentity().username);
        }
        return false;
      };

      /**
       * @ngdoc function
       * @name toggleLikeMessage
       * @methodOf TatUi.controller:messagesItem
       * @description toggle 'like' state on the message
       *
       */
      this.toggleLikeMessage = function(message) {
        var action = self.hasLiked(message) ? 'unlike' : 'like';
        TatEngineMessageRsc.update({
          'topic': $scope.topic.topic.indexOf("/") === 0 ? $scope.topic.topic.substr(1) : $scope.topic.topic,
          'idReference': message._id,
          'action': action
        }).$promise.then(function(resp) {
          if (action === 'like') {
            if (!message.likers) {
              message.likers = [];
            }
            message.likers.push(Authentication.getIdentity().username);
            message.nbLikes++;
          } else {
            message.likers = _.remove(message.likers,
              Authentication.getIdentity().username);
            message.nbLikes--;
          }
        }, function(err) {
          TatEngine.displayReturn(err);
        });
      };

      /**
       * @ngdoc function
       * @name removeLabel
       * @methodOf TatUi.controller:messagesItem
       * @description remove a label
       * @param {object} message Message on which to add a label
       * @param {object} label   Label {text} to remove
       */
      this.removeLabel = function(message, labelText) {
        if (!message.labels) {
          return;
        }
        var toRefresh = false;
        var newList = [];
        for (var i = 0; i < message.labels.length; i++) {
          var l = message.labels[i];
          if (l.text === labelText ||  (labelText === 'doing' && l.text
              .indexOf('doing:') === 0)) {
            toRefresh = true;
            TatEngineMessageRsc.update({
              'action': 'unlabel',
              'topic': $scope.topic.topic.indexOf("/") === 0 ? $scope.topic.topic.substr(1) : $scope.topic.topic,
              'idReference': $scope.message._id,
              'text': l.text
            }).$promise.then(function(resp) {
              //nothing here
            }, function(resp) {
              TatEngine.displayReturn(resp);
            });
          } else {
            newList.push(l);
          }
        }

        if (toRefresh)  {
          message.labels = newList;
        }
        self.computeFlagsTask(message);
      };

      this.urlMessage = function(message) {
        $rootScope.$broadcast('topic-change', {
          topic: $scope.topic.topic.indexOf("/") === 0 ? $scope.topic.topic.substr(1) : $scope.topic.topic,
          idMessage: message._id,
          reload: true
        });
      };

      this.containsLabel = function(message, labelText) {
        if (message.inReplyOfIDRoot) {
          return false;
        }
        var r = false;
        if (message.labels) {
          for (var i = 0; i < message.labels.length; i++) {
            var l = message.labels[i];
            if (l.text === labelText) {
              return true;
            }
          }
        }
        return r;
      };

      this.init = function(message) {
        message.loading = true;
        return TatEngineMessagesRsc.list({
          topic: $scope.topic.topic.indexOf("/") === 0 ? $scope.topic.topic.substr(1) : $scope.topic.topic,
          treeView: "onetree",
          idMessage: message._id,
          limit: 1,
          skip: 0
        }).$promise.then(function(data) {
          message.loading = false;
          if (!data.messages || data.messages.length != 1) {
            TatEngine.displayReturn("Invalid return while getting message");
          } else {
            message.replies = data.messages[0].replies;
          }
        }, function(err) {
          message.loading = false;
          TatEngine.displayReturn(err);
        });

        if ($scope.topic.topic.indexOf(self.privateTasksTopic) === 0) {
          self.isTopicTasks = true;
        }
        this.computeFlagsTask(message);
      };

      this.computeFlagsTask = function(message) {
        self.canDoneMessage = false;
        self.canDeleteFromTasksMessage = false;
        self.canAddToTasksMessage = true;
        for (var i = 0; i < message.topics.length; i++) {
          if (message.topics[i].indexOf("/" + self.privateTasksTopic) === 0) {
            if (!self.containsLabel(message, "done")) {
              self.canDoneMessage = true;
            }
            // if msg is not only in tasks topic
            if (message.topics.length > 1) {
              self.canDeleteFromTasksMessage = true;
              $scope.isTopicDeletableMsg = false;
              $scope.isTopicDeletableAllMsg = false;
            } else {
              $scope.isTopicDeletableMsg = true;
              $scope.isTopicDeletableAllMsg = true;
            }
          }
        };
        if (self.canDoneMessage || self.isTopicTasks) {
          self.canAddToTasksMessage = false;
        }
      };

      this.init($scope.message);

    }
  };
});
<|endoftext|>


<commit_before>angular.module("messages", ["messages.tpls","messages.directives"]);
angular.module("messages.tpls", ["template/messages/messages.html","template/messages/message.html"]);

angular.module('messages.directives', ['BioshareResources'])
.directive('messageList', function(Message,$uibModal) {//Subscription,Notification
	  return {
	    restrict: 'AE',
	    templateUrl: 'template/messages/messages.html',
	    scope: {
	    },
	    controller: function($scope, $http, $element){
	    	this.$scope = $scope;
	    	$scope.messages = Message.query();
//	    	{},
//	    			function(subscriptions){
//	    				console.log('subscriptions',subscriptions);
//	    				if (subscriptions.length > 1)
//	    					throw 'A singular subscription object was not found';
//	    				else if (subscriptions.length == 1)
//	    					$scope.subscription = subscriptions[0];
//	    				else
//	    					$scope.subscription = new Subscription({object_id:$scope.objectId,content_type:$scope.contentType})
////	    				$scope.$watch('subscription.email',function(){
////	    					$scope.save();
////	    				});
//	    			},
//	    			function(subscriptions){console.log('error',subscriptions);}
//	    	);
//	    	$scope.notifications = Notification.query({object_id:$scope.objectId,content_type:$scope.contentType});
	    	$scope.open = function (message,index) {

	    	    var modalInstance = $uibModal.open({
	    	      animation: $scope.animationsEnabled,
	    	      templateUrl: 'template/messages/message.html',
	    	      controller: 'MessageCtrl',
	    	      size: 'lg',
	    	      resolve: {
	    	        message: function () {
	    	          return message;
	    	        }
	    	      }
	    	    });

	    	    modalInstance.result.then(function (selectedItem) {
	    	      $scope.messages.splice(index,1);
	    	    }, function () {

	    	    });
	    	  };

	    	$scope.dismiss = function(message){
	    		message.$dismiss();
	    	}
	    }
	  }
	}).controller('MessageCtrl', function ($scope, $uibModalInstance, message) {
		  $scope.message = message;
		  $scope.dismiss = function () {
//		    $uibModalInstance.close($scope.message);
		    $scope.message.$dismiss(function(){$uibModalInstance.close($scope.message);});
		  };

		  $scope.close = function () {
		    $uibModalInstance.dismiss('cancel');
		  };
});

angular.module('template/messages/messages.html', []).run(['$templateCache', function($templateCache) {
	  $templateCache.put('template/messages/messages.html',
	'
\

  System message: "{{message.title}}"
\

'
	  );
	}]);
angular.module('template/messages/message.html', []).run(['$templateCache', function($templateCache) {
	  $templateCache.put('template/messages/message.html',
			  '
\

{{message.title}}
\

\

{{message.description}}
\

\
				  <button class="btn btn-primary" type="button" ng-click="dismiss()">Dismiss</button><button class="btn btn-warning" type="button" ng-click="close()">Close</button>\

'
	  );
	}]);

<commit_msg>Cleanup, Closes issue #18<commit_after>angular.module("messages", ["messages.tpls","messages.directives"]);
angular.module("messages.tpls", ["template/messages/messages.html","template/messages/message.html"]);

angular.module('messages.directives', ['BioshareResources'])
.directive('messageList', function(Message,$uibModal) {//Subscription,Notification
	  return {
	    restrict: 'AE',
	    templateUrl: 'template/messages/messages.html',
	    scope: {
	    },
	    controller: function($scope, $http, $element){
	    	this.$scope = $scope;
	    	$scope.messages = Message.query();
	    	$scope.open = function (message,index) {

	    	    var modalInstance = $uibModal.open({
	    	      animation: $scope.animationsEnabled,
	    	      templateUrl: 'template/messages/message.html',
	    	      controller: 'MessageCtrl',
	    	      size: 'lg',
	    	      resolve: {
	    	        message: function () {
	    	          return message;
	    	        }
	    	      }
	    	    });

	    	    modalInstance.result.then(function (selectedItem) {
	    	      $scope.messages.splice(index,1);
	    	    }, function () {

	    	    });
	    	  };

	    	$scope.dismiss = function(message){
	    		message.$dismiss();
	    	}
	    }
	  }
	}).controller('MessageCtrl', function ($scope, $uibModalInstance, message) {
		  $scope.message = message;
		  $scope.dismiss = function () {
		    $scope.message.$dismiss(function(){$uibModalInstance.close($scope.message);});
		  };

		  $scope.close = function () {
		    $uibModalInstance.dismiss('cancel');
		  };
});

angular.module('template/messages/messages.html', []).run(['$templateCache', function($templateCache) {
	  $templateCache.put('template/messages/messages.html',
	'
\

  System message: "{{message.title}}"
\

'
	  );
	}]);
angular.module('template/messages/message.html', []).run(['$templateCache', function($templateCache) {
	  $templateCache.put('template/messages/message.html',
			  '
\

{{message.title}}
\

\

{{message.description}}
\

\
				  <button class="btn btn-primary" type="button" ng-click="dismiss()">Dismiss</button><button class="btn btn-warning" type="button" ng-click="close()">Close</button>\

'
	  );
	}]);

<|endoftext|>


<commit_before>angular.module("Prometheus.controllers", []);
angular.module("Prometheus.directives", []);
angular.module("Prometheus.resources", []);
angular.module("Prometheus.services", []);
angular.module("Prometheus.filters", []);

angular.module("Prometheus",
  ["ui.sortable", "ui.bootstrap", "ui.slider", "Prometheus.controllers", "Prometheus.directives", "Prometheus.resources", "Prometheus.services", "Prometheus.filters"])
.run(['$rootScope', '$location', function($rootScope, $location) {
  // adds some basic utilities to the $rootScope for debugging purposes
  $rootScope.log = function(thing) {
    console.log(thing);
  };

  $rootScope.alert = function(thing) {
    alert(thing);
  };

  if ($location.hash()[0] === "?") {
    $location.url($location.path() + $location.hash());
  }
}]).config(['$locationProvider', '$httpProvider', function($locationProvider, $httpProvider) {
  $httpProvider.useApplyAsync(true);
  $locationProvider.html5Mode({
      enabled: true,
      requireBase: false
  });
}]);
<commit_msg>Set debugInfoEnabled to false<commit_after>angular.module("Prometheus.controllers", []);
angular.module("Prometheus.directives", []);
angular.module("Prometheus.resources", []);
angular.module("Prometheus.services", []);
angular.module("Prometheus.filters", []);

angular.module("Prometheus",
  ["ui.sortable", "ui.bootstrap", "ui.slider", "Prometheus.controllers", "Prometheus.directives", "Prometheus.resources", "Prometheus.services", "Prometheus.filters"])
.run(['$rootScope', '$location', function($rootScope, $location) {
  // adds some basic utilities to the $rootScope for debugging purposes
  $rootScope.log = function(thing) {
    console.log(thing);
  };

  $rootScope.alert = function(thing) {
    alert(thing);
  };

  if ($location.hash()[0] === "?") {
    $location.url($location.path() + $location.hash());
  }
}]).config(['$locationProvider', '$httpProvider', '$compileProvider', function($locationProvider, $httpProvider, $compileProvider) {
  $compileProvider.debugInfoEnabled(false);
  $httpProvider.useApplyAsync(true);
  $locationProvider.html5Mode({
      enabled: true,
      requireBase: false
  });
}]);
<|endoftext|>


<commit_before>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require bootstrap
//= require jquery
//= require jquery_ujs
//= require_tree .
<commit_msg>fix order of requiring javascripts<commit_after>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require_tree .
//= require bootstrap
<|endoftext|>


<commit_before>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require_tree .
//= require bootstrap
$(function(){
	var $university_req_rate =$('#university_req_rate'),
	university_percent = parseInt($university_req_rate.data('percent')),
	university_deg = 360*university_percent/100;
	if (university_percent > 50) {
		$university_req_rate.addClass('gt-50');
	}
	$('#university_req_rate .ppc-progress-fill').css('transform','rotate('+ university_deg +'deg)');
	$('#university_req_rate .ppc-percents span').html(university_percent+'%');

	var $campus_req_rate =$('#campus_req_rate'),
	campus_percent = parseInt($campus_req_rate.data('percent')),
	campus_deg = 360*campus_percent/100;
	if (campus_percent > 50) {
		$campus_req_rate.addClass('gt-50');
	}
	$('#campus_req_rate .ppc-progress-fill').css('transform','rotate('+ campus_deg +'deg)');
	$('#campus_req_rate .ppc-percents span').html(campus_percent+'%');

	var $ls_college_req_rate =$('#ls_college_req_rate'),
	ls_percent = parseInt($ls_college_req_rate.data('percent')),
	ls_deg = 360*ls_percent/100;
	if (ls_percent > 50) {
		$ls_college_req_rate.addClass('gt-50');
	}
	$('#ls_college_req_rate .ppc-progress-fill').css('transform','rotate('+ ls_deg +'deg)');
	$('#ls_college_req_rate .ppc-percents span').html(ls_percent+'%');

	var $major_req_rate =$('#major_req_rate'),
	major_percent = parseInt($major_req_rate.data('percent')),
	major_deg = 360*major_percent/100;
	if (major_percent > 50) {
		$major_req_rate.addClass('gt-50');
	}
	$('#major_req_rate .ppc-progress-fill').css('transform','rotate('+ major_deg +'deg)');
	$('#major_req_rate .ppc-percents span').html(major_percent+'%');
}).call(this)<commit_msg>js bug 5<commit_after>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require_tree .
//= require bootstrap
alert('some-unique-string')
$(function(){
	var $university_req_rate =$('#university_req_rate'),
	university_percent = parseInt($university_req_rate.data('percent')),
	university_deg = 360*university_percent/100;
	if (university_percent > 50) {
		$university_req_rate.addClass('gt-50');
	}
	$('#university_req_rate .ppc-progress-fill').css('transform','rotate('+ university_deg +'deg)');
	$('#university_req_rate .ppc-percents span').html(university_percent+'%');

	var $campus_req_rate =$('#campus_req_rate'),
	campus_percent = parseInt($campus_req_rate.data('percent')),
	campus_deg = 360*campus_percent/100;
	if (campus_percent > 50) {
		$campus_req_rate.addClass('gt-50');
	}
	$('#campus_req_rate .ppc-progress-fill').css('transform','rotate('+ campus_deg +'deg)');
	$('#campus_req_rate .ppc-percents span').html(campus_percent+'%');

	var $ls_college_req_rate =$('#ls_college_req_rate'),
	ls_percent = parseInt($ls_college_req_rate.data('percent')),
	ls_deg = 360*ls_percent/100;
	if (ls_percent > 50) {
		$ls_college_req_rate.addClass('gt-50');
	}
	$('#ls_college_req_rate .ppc-progress-fill').css('transform','rotate('+ ls_deg +'deg)');
	$('#ls_college_req_rate .ppc-percents span').html(ls_percent+'%');

	var $major_req_rate =$('#major_req_rate'),
	major_percent = parseInt($major_req_rate.data('percent')),
	major_deg = 360*major_percent/100;
	if (major_percent > 50) {
		$major_req_rate.addClass('gt-50');
	}
	$('#major_req_rate .ppc-progress-fill').css('transform','rotate('+ major_deg +'deg)');
	$('#major_req_rate .ppc-percents span').html(major_percent+'%');
});<|endoftext|>


<commit_before>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require polyfills
//= require jquery
//= require jquery_ujs
//= require bootstrap-sprockets
//= require typeahead.min
//= require coderwall
//= require jquery.timeago
//= require jquery.datetimepicker
//= require emojione
//= require lodash
//= require gmaps/google
//= require_tree .
//= stub maps
//
<commit_msg>explicitly require emojify in application.js<commit_after>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require polyfills
//= require jquery
//= require jquery_ujs
//= require bootstrap-sprockets
//= require typeahead.min
//= require coderwall
//= require jquery.timeago
//= require jquery.datetimepicker
//= require emojione
//= require emoji
//= require lodash
//= require gmaps/google
//= require_tree .
//= stub maps
//
<|endoftext|>


<commit_before>//= require jquery
//= require jquery_ujs
//= require twitter/bootstrap
//= require lodash
//= require handlebars.runtime

// To use placeholders in inputs in browsers that do not support it
// natively yet.
//= require jquery/jquery.placeholder

// Notifications (flash messages).
//= require jquery/jquery.noty

// To crop logos.
//= require jquery/jquery.Jcrop

// Used internally in the chat.
//= require jquery/jquery.autosize

// For modals.
//= require bootstrap/bootstrap-modal
//= require bootstrap/bootstrap-modalmanager

// Used in crop, modals and possibly other places. Grep for `ajaxForm`
// and `ajaxSubmit`.
//= require jquery/jquery.form

// Use to search for models (e.g. users) dynamically.
//= require select2

// Use for XMPP in the chat.
//= require strophe

//= require i18n/translations

// Datetime picker for bootstrap
//= require bootstrap-datetimepicker

// Moment.js for dates
//= require moment
//= require moment/pt-br

// TODO: remove this dependecy, this is only used in attachments now and
//       can be easily replaced by standard jquery methods.
//= require jquery/jquery.livequery

// 'base' HAS to be the first one included
//= require ./app/application/base
//= require_tree ./templates
//= require_tree ./app/application/
//= require_tree ./app/_all/
<commit_msg>Fix moment.js not found in production<commit_after>//= require jquery
//= require jquery_ujs
//= require twitter/bootstrap
//= require lodash
//= require handlebars.runtime

// To use placeholders in inputs in browsers that do not support it
// natively yet.
//= require jquery/jquery.placeholder

// Notifications (flash messages).
//= require jquery/jquery.noty

// To crop logos.
//= require jquery/jquery.Jcrop

// Used internally in the chat.
//= require jquery/jquery.autosize

// For modals.
//= require bootstrap/bootstrap-modal
//= require bootstrap/bootstrap-modalmanager

// Used in crop, modals and possibly other places. Grep for `ajaxForm`
// and `ajaxSubmit`.
//= require jquery/jquery.form

// Use to search for models (e.g. users) dynamically.
//= require select2

// Use for XMPP in the chat.
//= require strophe

//= require i18n/translations

// Moment.js for dates
//= require moment
//= require moment/pt-br

// Datetime picker for bootstrap
//= require bootstrap-datetimepicker

// TODO: remove this dependecy, this is only used in attachments now and
//       can be easily replaced by standard jquery methods.
//= require jquery/jquery.livequery

// 'base' HAS to be the first one included
//= require ./app/application/base
//= require_tree ./templates
//= require_tree ./app/application/
//= require_tree ./app/_all/
<|endoftext|>


<commit_before>//= require jquery
//= require jquery_ujs
//= require material-design-lite/material
//= require moment/moment
//= require moment/locale/zh-tw.js
//= require_tree ./templates
//= require cable

componentHandler.registerUpgradedCallback('MaterialLayout', function(e){
  var $form = document.querySelector('.submit-form')
  var $textArea = $form.querySelector('textarea')
  var $main = document.getElementById('main')

  $form.addEventListener('submit', handleSubmit.bind(this))
  $textArea.addEventListener('input', handleInput.bind(this))
  $textArea.addEventListener('keypress', handleKeyPress.bind(this))

  setInterval(updateTime, 5)

  function handleSubmit(){
    e.preventDefault()
    sendMessage()
  }

  function handleInput(e) {
    var lines = e.target.value.split(/\r\n|\r|\n/).length
    if(lines > 10) lines = 10
    e.target.rows = lines
  }

  function handleKeyPress(e) {
    if(e.key == 'Enter' && !e.shiftKey){
      e.preventDefault()
      sendMessage()
    }
  }

  function sendMessage(){
    App.chat.send({ content: $textArea.value })
    $textArea.value = ''
  }

  function updateTime(){
    for (var time of document.querySelectorAll('[data-time]')) {
      time.childNodes[0].nodeValue = moment(time.dataset.time).fromNow()
    }
  }
})
<commit_msg>fix submission<commit_after>//= require jquery
//= require jquery_ujs
//= require material-design-lite/material
//= require moment/moment
//= require moment/locale/zh-tw.js
//= require_tree ./templates
//= require cable

componentHandler.registerUpgradedCallback('MaterialLayout', function(e){
  var $form = document.querySelector('.submit-form')
  var $textArea = $form.querySelector('textarea')
  var $main = document.getElementById('main')

  $form.addEventListener('submit', handleSubmit.bind(this))
  $textArea.addEventListener('input', handleInput.bind(this))
  $textArea.addEventListener('keypress', handleKeyPress.bind(this))

  setInterval(updateTime, 5)

  function handleSubmit(e){
    e.preventDefault()
    sendMessage()
  }

  function handleInput(e) {
    var lines = e.target.value.split(/\r\n|\r|\n/).length
    if(lines > 10) lines = 10
    e.target.rows = lines
  }

  function handleKeyPress(e) {
    if(e.key == 'Enter' && !e.shiftKey){
      e.preventDefault()
      sendMessage()
    }
  }

  function sendMessage(){
    App.chat.send({ content: $textArea.value })
    $textArea.value = ''
  }

  function updateTime(){
    for (var time of document.querySelectorAll('[data-time]')) {
      time.childNodes[0].nodeValue = moment(time.dataset.time).fromNow()
    }
  }
})
<|endoftext|>


<commit_before>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//

//= require jquery3
//= require jquery_ujs
//= require jquery-ui/autocomplete
//= require jquery-ui/datepicker
<commit_msg>Revert "Upgrade to jQUery 3.3"<commit_after>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//

//= require jquery
//= require jquery_ujs
//= require jquery-ui/autocomplete
//= require jquery-ui/datepicker
<|endoftext|>


<commit_before>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require foundation
//= require turbolinks
//= require_tree .
//= require_tree ../../../vendor/assets/javascripts

/* START: Google Analytics */
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-48052298-1', 'jonfaulkenberry.com');
ga('send', 'pageview');
/* END: Google Analytics */

$(document).ready(function() {
	$.fn.fullpage({
		slidesColor: ['#f2f2f2', '#4BBFC3', '#7BAABE', 'whitesmoke', '#ccddff'],
		anchors: ['firstPage', 'secondPage', '3rdPage', '4thpage', 'lastPage']
	});
});

$(function(){ $(document).foundation(); });
<commit_msg>Removed vendor javascripts reference in application.js<commit_after>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require foundation
//= require turbolinks
//= require_tree .
// require_tree ../../../vendor/assets/javascripts

/* START: Google Analytics */
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-48052298-1', 'jonfaulkenberry.com');
ga('send', 'pageview');
/* END: Google Analytics */

$(document).ready(function() {
	$.fn.fullpage({
		slidesColor: ['#f2f2f2', '#4BBFC3', '#7BAABE', 'whitesmoke', '#ccddff'],
		anchors: ['firstPage', 'secondPage', '3rdPage', '4thpage', 'lastPage']
	});
});

$(function(){ $(document).foundation(); });
<|endoftext|>


<commit_before>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require twitter/bootstrap
//= require_directory ./shared
//= require angular
//= require angular-animate
//= require angular-resource

//= require jquery-ias.min

//= require_directory ./application

//= require blueimp-gallery
//= require blueimp-gallery-fullscreen
//= require blueimp-gallery-indicator
//= require blueimp-gallery-video
//= require blueimp-gallery-youtube
//= require jquery.blueimp-gallery
//= require bootstrap-image-gallery

jQuery.ias({
    container : '.comments_block, .projects_block',
    item: '.comment_item, .project',
    pagination: '.pagination',
    next: 'span.next a',
    loader: '',
    onRenderComplete: function() {}
});
<commit_msg>fix more than 2 pages autoloading<commit_after>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require twitter/bootstrap
//= require_directory ./shared
//= require angular
//= require angular-animate
//= require angular-resource

//= require jquery-ias.min

//= require_directory ./application

//= require blueimp-gallery
//= require blueimp-gallery-fullscreen
//= require blueimp-gallery-indicator
//= require blueimp-gallery-video
//= require blueimp-gallery-youtube
//= require jquery.blueimp-gallery
//= require bootstrap-image-gallery

jQuery.ias({
    container: '.comments_block, .projects_block',
    triggerPageThreshold: 1000,
    item: '.comment_item, .project',
    pagination: '.pagination',
    next: 'span.next a',
    loader: '',
    onRenderComplete: function() {}
});
<|endoftext|>


<commit_before>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
// vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//

//= require jquery
//= require jquery_ujs
//= require jquery-ui/ui/widgets/autocomplete.js
//= require autocomplete-rails
//= require turbolinks
//= require tether/dist/js/tether.js
//= require bootstrap/dist/js/bootstrap.js
//= require_tree .
<commit_msg>Require jquery-ui widget module<commit_after>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
// vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//

//= require jquery
//= require jquery_ujs
//= require jquery-ui/ui/widget.js
//= require jquery-ui/ui/widgets/autocomplete.js
//= require autocomplete-rails
//= require turbolinks
//= require tether/dist/js/tether.js
//= require bootstrap/dist/js/bootstrap.js
//= require_tree .
<|endoftext|>


<commit_before>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require bootstrap
//= require jquery_ujs
//= require turbolinks
//= require notify
//= require_tree .
<commit_msg>add Holmes to application.js<commit_after>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require bootstrap
//= require jquery_ujs
//= require turbolinks
//= require notify
//= require holmes
//= require microlight
//= require_tree .
<|endoftext|>


<commit_before>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .

// $(document).ready(
//     function(){
//         document.onkeydown = function()
//         {
//             var oEvent = window.event;
//             if (oEvent.keyCode == 13 && oEvent.ctrlKey) {
//                 var control_id = document.activeElement.id;
//                 alert(control_id);
//                 switch(control_id) {
//                 	case "comment-content":
//                 		new_comment();
//                 		break;
//                 	case "current_reply_content":
//                 		new_reply_content();
//                 		break;
//                     default:break;
//                 }
//             }
//         }
//     }
// );  <commit_msg>update<commit_after>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .

$(document).ready(function(){
      var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
      document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F8d3998fdde7f193dfb5aaf8848fcf210' type='text/javascript'%3E%3C/script%3E"));
    }); <|endoftext|>


<commit_before>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
// vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require rails-ujs
//= require activestorage
//= require turbolinks
//= require_tree .
<commit_msg>Remove activestorage.<commit_after>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
// vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require rails-ujs
//= require turbolinks
//= require_tree .
<|endoftext|>


<commit_before>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
// vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require rails-ujs
//= require bootstrap.native
//= require_tree .
<commit_msg>Use npm package<commit_after>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
// vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require rails-ujs
//= require bootstrap.native/dist/bootstrap-native
//= require_tree .
<|endoftext|>


<commit_before>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//

// Rails Defaults
//////////////////
//= require jquery
//= require jquery_ujs
//= require turbolinks

// Bootstrap
/////////////
//= require bootstrap

// Handlebars, Ember, Ember-Data
/////////////////////////////////
//= require handlebars
//= require ember
//= require ember-data
//= require_self
//= require sisyphus

// Other 3rd Party Add ons
///////////////////////////
//= require_tree ./vendor

// for more details see: http://emberjs.com/guides/application/
Sis = Ember.Application.create({
  LOG_TRANSITIONS: true,
  // These will probably be useful down the road.
  // LOG_ACTIVE_GENERATION: true,
  // LOG_VIEW_LOOKUPS: true,
});

//= require_tree .
<commit_msg>Adds error logging for promises. Still not that useful.<commit_after>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//

// Rails Defaults
//////////////////
//= require jquery
//= require jquery_ujs
//= require turbolinks

// Bootstrap
/////////////
//= require bootstrap

// Handlebars, Ember, Ember-Data
/////////////////////////////////
//= require handlebars
//= require ember
//= require ember-data
//= require_self
//= require sisyphus

// Other 3rd Party Add ons
///////////////////////////
//= require_tree ./vendor

// for more details see: http://emberjs.com/guides/application/
Sis = Ember.Application.create({
  LOG_TRANSITIONS: true,
  // These will probably be useful down the road.
  // LOG_ACTIVE_GENERATION: true,
  // LOG_VIEW_LOOKUPS: true,
});

Ember.RSVP.configure('onerror', function(error) {
  Ember.Logger.assert(false, error);
});

//= require_tree .
<|endoftext|>


<commit_before>// Vendor assets
//= require jquery
//= require jquery_ujs
//= require jquery-ui-autocomplete
//= require modernizr-custom
//= require dest/respond.min

// GOVUK modules
//= require govuk_toolkit
//= require vendor/polyfills/bind
//= require govuk/selection-buttons

// MOJ elements
//= require moj
//= require src/moj.TimeoutPrompt

// Candidates for re-usable components
//= require modules/moj.analytics
//= require modules/moj.autocomplete
//= require modules/moj.hijacks
//= require modules/moj.submit-once
//= require modules/moj.Conditional
//= require modules/moj.RevealAdditional
//= require modules/moj.checkbox-summary
//= require modules/moj.AgeLabel.js
//= require modules/moj.booking-calendar
//= require modules/moj.set-dimension
//= require modules/moj.AsyncGA

(function() {
  'use strict';
  delete moj.Modules.devs;
  var selectionButtons = new GOVUK.SelectionButtons("label input[type='radio'], label input[type='checkbox']");
  moj.init();
}());<commit_msg>Add js-enabled class to body if doesn't exist<commit_after>// Vendor assets
//= require jquery
//= require jquery_ujs
//= require jquery-ui-autocomplete
//= require modernizr-custom
//= require dest/respond.min

// GOVUK modules
//= require govuk_toolkit
//= require vendor/polyfills/bind
//= require govuk/selection-buttons

// MOJ elements
//= require moj
//= require src/moj.TimeoutPrompt

// Candidates for re-usable components
//= require modules/moj.analytics
//= require modules/moj.autocomplete
//= require modules/moj.hijacks
//= require modules/moj.submit-once
//= require modules/moj.Conditional
//= require modules/moj.RevealAdditional
//= require modules/moj.checkbox-summary
//= require modules/moj.AgeLabel.js
//= require modules/moj.booking-calendar
//= require modules/moj.set-dimension
//= require modules/moj.AsyncGA

(function() {
  'use strict';
  if (!document.body.classList.contains('js-enabled')) {
    document.body.className = ((document.body.className) ? document.body.className + ' js-enabled' : 'js-enabled');
  }
  delete moj.Modules.devs;
  var selectionButtons = new GOVUK.SelectionButtons("label input[type='radio'], label input[type='checkbox']");
  moj.init();
}());<|endoftext|>


<commit_before>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
<commit_msg>Add require d3 to application.js<commit_after>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require d3
//= require_tree .
<|endoftext|>


<commit_before>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require foundation
//= require ckeditor/init
//= require d3
//= require js-routes
//= require_tree .

$(document).on('page:change', function(){
    $(document).foundation({
        offcanvas : {
            open_method: 'move' // Sets method in which offcanvas opens, can also be 'overlap'
        }
    });
});
<commit_msg>Fix missing require to correctly display local time<commit_after>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require foundation
//= require ckeditor/init
//= require d3
//= require js-routes
//= require local_time
//= require_tree .

$(document).on('page:change', function(){
    $(document).foundation({
        offcanvas : {
            open_method: 'move' // Sets method in which offcanvas opens, can also be 'overlap'
        }
    });
});
<|endoftext|>


<commit_before>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require_tree .

//  disabled= require turbolinks
<commit_msg>deploy<commit_after>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require_tree .

//  disabled= require turbolinks
<|endoftext|>


<commit_before>$(document).ready(function () {

  var collapsibleSection = $('.collapsible-section'),
      collapsibleButton = $('.collapsible');

  collapsibleSection.hide();

  collapsibleButton.append('Hide this section');

  collapsibleButton.on('click', function(event) {
    $(this).find('.icon').toggleClass('icon--open icon--closed');
    collapsibleSection.slideToggle(1000);
    event.stopPropagation();

  });
});<commit_msg>refactored js<commit_after>$(document).ready(function () {

  var showFirst = true,
      activeClass = 'js-active',
      sections = [],
      headingIcon = 'Hide this section';

  function toggleSection(e, options){
    var data = e.data;
    data.trigger.toggleClass(activeClass);
    data.target.toggleClass(activeClass);
  }

  $('.collapsible').each(function(i,el){
    var $el = $(el);

    sections[i] = {
      index: i,
      trigger: $el,
      target: $el.next('.collapsible-section')
    }

    var buttonTitle = sections[i].trigger.text();
    sections[i].trigger.html('<button class="noStyle">' + buttonTitle + '</button>' + headingIcon);
    sections[i].trigger.on('click', sections[i], toggleSection);

    if(showFirst && i >= 1){
      sections[i].trigger.trigger('click');
    }
  })

});<|endoftext|>


<commit_before>angular.module('ordercloud-infinite-scroll', ['ordercloud-search', 'ordercloud-paging-helpers']);
angular.module('ordercloud-infinite-scroll')

    .directive( 'ordercloudInfiniteScroll', InfiniteScrollDirective )
    .controller( 'InfiniteScrollCtrl', InfiniteScrollController )
;

function InfiniteScrollDirective(Paging) {
    return {
        restrict: 'A',
        scope: {
            servicename: '@',
            controlleras: '=',
            idname: '@',
            threshold: '@'
        },
        controller: 'InfiniteScrollCtrl',
        controllerAs: 'InfiniteScroll',
        link: function(scope, element) {
            var threshold = scope.threshold || 0;
            var ele = element[0];
            element.bind('scroll', function () {
                if (ele.scrollTop + ele.offsetHeight + threshold >= ele.scrollHeight) {
                    if (scope.controlleras && scope.controlleras.pagingfunction !== undefined) {
                        scope.controlleras.pagingfunction();
                    }
                    else if (scope.servicename && scope.controlleras && scope.controlleras.list) {
                        Paging.paging(scope.controlleras.list, scope.servicename);
                    }
                    /* Else display a console error */
                    else {
                        console.log('Error: Infinite scroll directive not fully defined.');
                    }
                }
            });
        }
    }
}

function InfiniteScrollController($scope, Paging, TrackSearch) {
    TrackSearch.SetTerm(null);
    $scope.$watchCollection(function() {
        if ($scope.controlleras && $scope.controlleras.list) {
            return $scope.controlleras.list;
        }
    }, function() {
        if ($scope.controlleras && $scope.controlleras.assignments && $scope.controlleras.list && $scope.idname) {
            Paging.setSelected($scope.controlleras.list.Items, $scope.controlleras.assignments.Items, $scope.idname);
        }
    });
}
<commit_msg>fixing oversight in infinite scroll. It should only look at the assignments array when doing the sec selected operation<commit_after>angular.module('ordercloud-infinite-scroll', ['ordercloud-search', 'ordercloud-paging-helpers']);
angular.module('ordercloud-infinite-scroll')

    .directive( 'ordercloudInfiniteScroll', InfiniteScrollDirective )
    .controller( 'InfiniteScrollCtrl', InfiniteScrollController )
;

function InfiniteScrollDirective(Paging) {
    return {
        restrict: 'A',
        scope: {
            servicename: '@',
            controlleras: '=',
            idname: '@',
            threshold: '@'
        },
        controller: 'InfiniteScrollCtrl',
        controllerAs: 'InfiniteScroll',
        link: function(scope, element) {
            var threshold = scope.threshold || 0;
            var ele = element[0];
            element.bind('scroll', function () {
                if (ele.scrollTop + ele.offsetHeight + threshold >= ele.scrollHeight) {
                    if (scope.controlleras && scope.controlleras.pagingfunction !== undefined) {
                        scope.controlleras.pagingfunction();
                    }
                    else if (scope.servicename && scope.controlleras && scope.controlleras.list) {
                        Paging.paging(scope.controlleras.list, scope.servicename);
                    }
                    /* Else display a console error */
                    else {
                        console.log('Error: Infinite scroll directive not fully defined.');
                    }
                }
            });
        }
    }
}

function InfiniteScrollController($scope, Paging, TrackSearch) {
    TrackSearch.SetTerm(null);
    $scope.$watchCollection(function() {
        if ($scope.controlleras && $scope.controlleras.assignments) {
            return $scope.controlleras.assignments;
        }
    }, function() {
        if ($scope.controlleras && $scope.controlleras.assignments && $scope.controlleras.list && $scope.idname) {
            Paging.setSelected($scope.controlleras.list.Items, $scope.controlleras.assignments.Items, $scope.idname);
        }
    });
}
<|endoftext|>


<commit_before>// wysihtml5  tag component for code.
// https://github.com/xing/wysihtml5/issues/43
(function(wysihtml5) {
  "use strict";
  var NODE_NAME = 'CODE';

  wysihtml5.commands.createCode = {
    exec: function(composer, command) {
      var selection = composer.selection.getSelectedNode();
      var result = wysihtml5.commands.formatInline.exec(composer, command, 'code');

      // Make sure we do not have new  blocks split by
's
      $('br', selection).each(function(n, elem) {
        var $elem = $(elem);
        var $prev = $elem.prev();
        var $next = $elem.next();

        var $next_children = $next.contents();
        $next_children.detach();
        $prev.append(elem);
        $next_children.appendTo($prev);
        $next.remove();
      });
      $('code', selection).addClass('jfdiCode');
      return result;
    },

    state: function(composer, command) {
      // element.ownerDocument.queryCommandState("bold") results:
      // firefox: only
      // chrome: , ,
,
, ...
      // ie: ,
      // opera: ,
      return wysihtml5.commands.formatInline.state(composer, command, 'code');
    }
  };
})(wysihtml5);

$(document).ready(function() {
  // setup html editor
  var imgUploadHtml = $('#html-editor-image-upload-tab').html();
  var options = $.extend(true, {}, $.fn.wysihtml5.defaultOptions);
  options.toolbar = {
    code: '
' +
            '
' +
            '' +
            '
' +
          '
'
  };
  options.parserRules.classes['jfdiCode'] = 1;

  if (imgUploadHtml) {
    options.html = true;
    options.customTemplates = {
      image: function(locale) {
        return imgUploadHtml;
      }
    };
  }

  var handler = function() {
    var $this = $(this);
    if ($this.data('wysihtml5')) {
      // We need to reinitialise the component; otherwise the iframe is as good as dead
      // see https://github.com/xing/wysihtml5/issues/148
      $this.css('display', 'block');
      var input = $this.val();
      $this.siblings('.wysihtml5-sandbox, .wysihtml5-toolbar, input[name="_wysihtml5_mode"]').remove();
    }

    $(this).wysihtml5(options);
  };

  $(document).on('DOMNodeInserted', function(e) {
    $('textarea.html-editor', e.target).each(handler);
  });
});
<commit_msg>Replace my home-brew solution with the code already found in upstream.<commit_after>// Inspired by the implementation upstream in https://github.com/evereq/bootstrap-wysihtml5
// that has not made it to the Rails version.
(function(wysi) {
  "use strict";

  function exec(composer) {

    var pre = this.state(composer);

    if (pre) {
      // caret is already within a
...

      composer.selection.executeAndRestore(function () {
        var codeSelector = pre.querySelector("code");
        wysi.dom.replaceWithChildNodes(pre);
        if (codeSelector) {
          wysi.dom.replaceWithChildNodes(pre);
          hljs.highlightBlock(pre);
        }
      });
    } else {
      // Wrap in
...

      var range = composer.selection.getRange();
      if (!range) {
        return false;
      }

      var selectedNodes = range.extractContents(),
          preElem = composer.doc.createElement("pre"),
          code = composer.doc.createElement("code");

      preElem.appendChild(code);
      code.appendChild(selectedNodes);
      code.className = 'jfdiCode';
      range.insertNode(preElem);
      hljs.highlightBlock(preElem);
      composer.selection.selectNode(preElem);
    }
  }

  function state(composer) {
    var selectedNode = composer.selection.getSelectedNode();
    return wysi.dom.getParentElement(selectedNode, { nodeName: "CODE" }) &&
      wysi.dom.getParentElement(selectedNode, { nodeName: "PRE" });
  }

  wysi.commands.createCode = {
    exec: exec,
    state: state
  };
})(wysihtml5);

$(document).ready(function() {
  // setup html editor
  var imgUploadHtml = $('#html-editor-image-upload-tab').html();
  var options = $.extend(true, {}, $.fn.wysihtml5.defaultOptions);
  options.toolbar = {
    code: '
' +
            '
' +
            '' +
            '
' +
          '
'
  };
  options.parserRules.classes['jfdiCode'] = 1;

  if (imgUploadHtml) {
    options.html = true;
    options.customTemplates = {
      image: function(locale) {
        return imgUploadHtml;
      }
    };
  }

  var handler = function() {
    var $this = $(this);
    if ($this.data('wysihtml5')) {
      // We need to reinitialise the component; otherwise the iframe is as good as dead
      // see https://github.com/xing/wysihtml5/issues/148
      $this.css('display', 'block');
      var input = $this.val();
      $this.siblings('.wysihtml5-sandbox, .wysihtml5-toolbar, input[name="_wysihtml5_mode"]').remove();
    }

    $(this).wysihtml5(options);
  };

  $(document).on('DOMNodeInserted', function(e) {
    $('textarea.html-editor', e.target).each(handler);
  });
});
<|endoftext|>


<commit_before>import SandboxBrowser from '../sandboxes/SandboxBrowser';
import AppSandboxBrowser from '../sandboxes/AppSandboxBrowser';
import Request from '../browser/Request';
import {RuntimeCatalogue} from 'service-framework/dist/RuntimeCatalogue';
import PersistenceManager from 'service-framework/dist/PersistenceManager';
import StorageManagerFake from './StorageManagerFake';

// import Dexie from 'dexie';

const runtimeFactory = Object.create({
  createSandbox() {
    return new SandboxBrowser();
  },

  createAppSandbox() {
    return new AppSandboxBrowser();
  },

  createHttpRequest() {
    let request = new Request();
    return request;
  },

  atob(b64) {
    return atob(b64);
  },

  storageManager() {
    // const db = new Dexie('cache');
    // const storeName = 'objects';

    return new StorageManagerFake('a', 'b');
  },

  persistenceManager() {
    let localStorage = window.localStorage;
    return new PersistenceManager(localStorage);
  },

  createRuntimeCatalogue(development) {

    if (!this.catalogue)
      this.catalogue = new RuntimeCatalogue(this);

    return this.catalogue;
  }

});

export default runtimeFactory;
<commit_msg>Update the toolkit to use indexedDB Wrapper and the generic implementation of service-framework<commit_after>import SandboxBrowser from '../sandboxes/SandboxBrowser';
import AppSandboxBrowser from '../sandboxes/AppSandboxBrowser';
import Request from '../browser/Request';
import {RuntimeCatalogue} from 'service-framework/dist/RuntimeCatalogue';
import PersistenceManager from 'service-framework/dist/PersistenceManager';
import StorageManager from 'service-framework/dist/StorageManager';

// import StorageManagerFake from './StorageManagerFake';

import Dexie from 'dexie';

const runtimeFactory = Object.create({
  createSandbox() {
    return new SandboxBrowser();
  },

  createAppSandbox() {
    return new AppSandboxBrowser();
  },

  createHttpRequest() {
    let request = new Request();
    return request;
  },

  atob(b64) {
    return atob(b64);
  },

  storageManager() {

    // Using the implementation of Service Framework
    // Dexie is the IndexDB Wrapper
    const db = new Dexie('cache');
    const storeName = 'objects';

    return new StorageManager(db, storeName);

    // return new StorageManagerFake('a', 'b');
  },

  persistenceManager() {
    let localStorage = window.localStorage;
    return new PersistenceManager(localStorage);
  },

  createRuntimeCatalogue(development) {

    if (!this.catalogue)
      this.catalogue = new RuntimeCatalogue(this);

    return this.catalogue;
  }

});

export default runtimeFactory;
<|endoftext|>