]> BookStack Code Mirror - bookstack/blobdiff - resources/assets/js/controllers.js
Added issue template
[bookstack] / resources / assets / js / controllers.js
index bec96f319b68cb41ff5a6ad307b969b5cd635245..406fd7e77ee30b639cb5426a8efeca8450d452be 100644 (file)
@@ -379,6 +379,15 @@ module.exports = function (ngApp, events) {
             saveDraft();
         };
 
+        // Listen to shortcuts coming via events
+        $scope.$on('editor-keydown', (event, data) => {
+            // Save shortcut (ctrl+s)
+            if (data.keyCode == 83 && (navigator.platform.match("Mac") ? data.metaKey : data.ctrlKey)) {
+                data.preventDefault();
+                saveDraft();
+            }
+        });
+
         /**
          * Discard the current draft and grab the current page
          * content from the system via an AJAX request.
@@ -405,6 +414,13 @@ module.exports = function (ngApp, events) {
 
             const pageId = Number($attrs.pageId);
             $scope.tags = [];
+            
+            $scope.sortOptions = {
+                handle: '.handle',
+                items: '> tr',
+                containment: "parent",
+                axis: "y"
+            };
 
             /**
              * Push an empty tag to the end of the scope tags.
@@ -415,6 +431,7 @@ module.exports = function (ngApp, events) {
                     value: ''
                 });
             }
+            $scope.addEmptyTag = addEmptyTag;
 
             /**
              * Get all tags for the current book and add into scope.
@@ -463,6 +480,9 @@ module.exports = function (ngApp, events) {
                 }
             };
 
+            /**
+             * Save the tags to the current page.
+             */
             $scope.saveTags = function() {
                 setTagOrder();
                 let postData = {tags: $scope.tags};
@@ -473,6 +493,15 @@ module.exports = function (ngApp, events) {
                 })
             };
 
+            /**
+             * Remove a tag from the current list.
+             * @param tag
+             */
+            $scope.removeTag = function(tag) {
+                let cIndex = $scope.tags.indexOf(tag);
+                $scope.tags.splice(cIndex, 1);
+            };
+
         }]);
 
 };