]> BookStack Code Mirror - bookstack/blob - resources/assets/js/global.js
Updated page pointer to sit near mouse location and extracted page js into browserify...
[bookstack] / resources / assets / js / global.js
1
2
3 // AngularJS - Create application and load components
4 var angular = require('angular');
5 var ngResource = require('angular-resource');
6 var ngAnimate = require('angular-animate');
7 var ngSanitize = require('angular-sanitize');
8
9 var ngApp = angular.module('bookStack', ['ngResource', 'ngAnimate', 'ngSanitize']);
10 var services = require('./services')(ngApp);
11 var directives = require('./directives')(ngApp);
12 var controllers = require('./controllers')(ngApp);
13
14 //Global jQuery Config & Extensions
15
16 // Smooth scrolling
17 jQuery.fn.smoothScrollTo = function () {
18     if (this.length === 0) return;
19     $('body').animate({
20         scrollTop: this.offset().top - 60 // Adjust to change final scroll position top margin
21     }, 800); // Adjust to change animations speed (ms)
22     return this;
23 };
24
25 // Making contains text expression not worry about casing
26 $.expr[":"].contains = $.expr.createPseudo(function (arg) {
27     return function (elem) {
28         return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
29     };
30 });
31
32 // Global jQuery Elements
33 $(function () {
34
35     // Notification hiding
36     $('.notification').click(function () {
37         $(this).fadeOut(100);
38     });
39
40     // Chapter page list toggles
41     $('.chapter-toggle').click(function (e) {
42         e.preventDefault();
43         $(this).toggleClass('open');
44         $(this).closest('.chapter').find('.inset-list').slideToggle(180);
45     });
46
47 });
48
49
50 function elemExists(selector) {
51     return document.querySelector(selector) !== null;
52 }
53
54 // TinyMCE editor
55 if (elemExists('#html-editor')) {
56     var tinyMceOptions = require('./pages/page-form');
57     tinymce.init(tinyMceOptions);
58 }
59
60 // Page specific items
61 require('./pages/page-show');