]> BookStack Code Mirror - bookstack/blobdiff - resources/assets/js/global.js
Updated all application urls to allow path prefix.
[bookstack] / resources / assets / js / global.js
index 90b03e8568ed3593583a85635cc812e653890b40..1c300ad26b209a671146bc657e2176308823c2bb 100644 (file)
@@ -5,9 +5,17 @@ var angular = require('angular');
 var ngResource = require('angular-resource');
 var ngAnimate = require('angular-animate');
 var ngSanitize = require('angular-sanitize');
+require('angular-ui-sortable');
+
+// Url retrieval function
+window.baseUrl = function(path) {
+    let basePath = document.querySelector('meta[name="base-url"]').getAttribute('content');
+    if (basePath[basePath.length-1] === '/') basePath = basePath.slice(0, basePath.length-1);
+    if (path[0] === '/') path = path.slice(1);
+    return basePath + '/' + path;
+};
 
-var ngApp = angular.module('bookStack', ['ngResource', 'ngAnimate', 'ngSanitize']);
-
+var ngApp = angular.module('bookStack', ['ngResource', 'ngAnimate', 'ngSanitize', 'ui.sortable']);
 
 // Global Event System
 var Events = {
@@ -29,6 +37,7 @@ var Events = {
 };
 window.Events = Events;
 
+
 var services = require('./services')(ngApp, Events);
 var directives = require('./directives')(ngApp, Events);
 var controllers = require('./controllers')(ngApp, Events);
@@ -54,10 +63,10 @@ $.expr[":"].contains = $.expr.createPseudo(function (arg) {
 // Global jQuery Elements
 $(function () {
 
-
     var notifications = $('.notification');
     var successNotification = notifications.filter('.pos');
     var errorNotification = notifications.filter('.neg');
+    var warningNotification = notifications.filter('.warning');
     // Notification Events
     window.Events.listen('success', function (text) {
         successNotification.hide();
@@ -66,6 +75,10 @@ $(function () {
             successNotification.show();
         }, 1);
     });
+    window.Events.listen('warning', function (text) {
+        warningNotification.find('span').text(text);
+        warningNotification.show();
+    });
     window.Events.listen('error', function (text) {
         errorNotification.find('span').text(text);
         errorNotification.show();
@@ -95,7 +108,7 @@ $(function () {
             scrollTop.style.display = 'block';
             scrollTopShowing = true;
             setTimeout(() => {
-                scrollTop.style.opacity = 1;
+                scrollTop.style.opacity = 0.4;
             }, 1);
         } else if (scrollTopShowing && document.body.scrollTop < scrollTopBreakpoint) {
             scrollTop.style.opacity = 0;
@@ -108,22 +121,11 @@ $(function () {
 
     // Common jQuery actions
     $('[data-action="expand-entity-list-details"]').click(function() {
-        $('.entity-list.compact').find('p').slideToggle(240);
+        $('.entity-list.compact').find('p').not('.empty-text').slideToggle(240);
     });
 
 
 });
 
-
-function elemExists(selector) {
-    return document.querySelector(selector) !== null;
-}
-
-// TinyMCE editor
-if (elemExists('#html-editor')) {
-    var tinyMceOptions = require('./pages/page-form');
-    tinymce.init(tinyMceOptions);
-}
-
 // Page specific items
-require('./pages/page-show');
\ No newline at end of file
+require('./pages/page-show');