]> BookStack Code Mirror - bookstack/blobdiff - resources/assets/js/global.js
Update Ldap.php
[bookstack] / resources / assets / js / global.js
index eeb1e4ea735c75d6e25e2f4024ee0b2b4186224d..9aa5dff527adcf04298e80dc28003f004080448f 100644 (file)
@@ -7,10 +7,18 @@ 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
-class Events {
+class EventManager {
     constructor() {
         this.listeners = {};
     }
@@ -30,12 +38,17 @@ class Events {
         this.listeners[eventName].push(callback);
         return this;
     }
-};
-window.Events = new Events();
+}
 
-var services = require('./services')(ngApp, Events);
-var directives = require('./directives')(ngApp, Events);
-var controllers = require('./controllers')(ngApp, Events);
+window.Events = new EventManager();
+
+// Load in angular specific items
+import Services from './services';
+import Directives from './directives';
+import Controllers from './controllers';
+Services(ngApp, window.Events);
+Directives(ngApp, window.Events);
+Controllers(ngApp, window.Events);
 
 //Global jQuery Config & Extensions
 
@@ -121,6 +134,27 @@ $(function () {
         $('.entity-list.compact').find('p').not('.empty-text').slideToggle(240);
     });
 
+    // Popup close
+    $('.popup-close').click(function() {
+        $(this).closest('.overlay').fadeOut(240);
+    });
+    $('.overlay').click(function(event) {
+        if (!$(event.target).hasClass('overlay')) return;
+        $(this).fadeOut(240);
+    });
+
+    // Prevent markdown display link click redirect
+    $('.markdown-display').on('click', 'a', function(event) {
+        event.preventDefault();
+        window.open($(this).attr('href'));
+    });
+
+    // Detect IE for css
+    if(navigator.userAgent.indexOf('MSIE')!==-1
+        || navigator.appVersion.indexOf('Trident/') > 0
+        || navigator.userAgent.indexOf('Safari') !== -1){
+        $('body').addClass('flexbox-support');
+    }
 
 });