]> 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 d4fe7020bcac72e697a1bb7970225afbf08e3cbf..1c300ad26b209a671146bc657e2176308823c2bb 100644 (file)
@@ -7,6 +7,14 @@ 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', 'ui.sortable']);
 
 // Global Event System
@@ -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);
@@ -112,16 +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;
-}
-
 // Page specific items
 require('./pages/page-show');