2015-12-30 15:48:57 -05:00
|
|
|
|
2015-10-08 18:49:18 -04:00
|
|
|
|
2015-12-29 11:39:25 -05:00
|
|
|
// AngularJS - Create application and load components
|
|
|
|
var angular = require('angular');
|
2015-12-30 13:38:18 -05:00
|
|
|
var ngResource = require('angular-resource');
|
|
|
|
var ngAnimate = require('angular-animate');
|
|
|
|
var ngSanitize = require('angular-sanitize');
|
|
|
|
|
|
|
|
var ngApp = angular.module('bookStack', ['ngResource', 'ngAnimate', 'ngSanitize']);
|
|
|
|
var services = require('./services')(ngApp);
|
|
|
|
var directives = require('./directives')(ngApp);
|
|
|
|
var controllers = require('./controllers')(ngApp);
|
|
|
|
|
|
|
|
//Global jQuery Config & Extensions
|
|
|
|
|
|
|
|
// Smooth scrolling
|
2015-12-30 14:57:17 -05:00
|
|
|
jQuery.fn.smoothScrollTo = function () {
|
|
|
|
if (this.length === 0) return;
|
2015-12-30 13:38:18 -05:00
|
|
|
$('body').animate({
|
|
|
|
scrollTop: this.offset().top - 60 // Adjust to change final scroll position top margin
|
|
|
|
}, 800); // Adjust to change animations speed (ms)
|
|
|
|
return this;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Making contains text expression not worry about casing
|
2015-12-30 14:57:17 -05:00
|
|
|
$.expr[":"].contains = $.expr.createPseudo(function (arg) {
|
|
|
|
return function (elem) {
|
2015-12-30 13:38:18 -05:00
|
|
|
return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
|
|
|
|
};
|
|
|
|
});
|
2015-12-29 11:39:25 -05:00
|
|
|
|
2015-10-08 18:49:18 -04:00
|
|
|
// Global jQuery Elements
|
2015-09-03 11:51:10 -04:00
|
|
|
$(function () {
|
|
|
|
|
2015-09-03 14:05:45 -04:00
|
|
|
// Notification hiding
|
2015-09-03 11:51:10 -04:00
|
|
|
$('.notification').click(function () {
|
|
|
|
$(this).fadeOut(100);
|
|
|
|
});
|
|
|
|
|
2015-09-03 14:05:45 -04:00
|
|
|
// Chapter page list toggles
|
2015-12-30 14:57:17 -05:00
|
|
|
$('.chapter-toggle').click(function (e) {
|
2015-09-03 14:05:45 -04:00
|
|
|
e.preventDefault();
|
|
|
|
$(this).toggleClass('open');
|
2015-09-06 09:35:53 -04:00
|
|
|
$(this).closest('.chapter').find('.inset-list').slideToggle(180);
|
2015-09-03 14:05:45 -04:00
|
|
|
});
|
|
|
|
|
2015-10-07 18:17:48 -04:00
|
|
|
});
|
|
|
|
|
2015-12-30 13:38:18 -05:00
|
|
|
|
|
|
|
function elemExists(selector) {
|
|
|
|
return document.querySelector(selector) !== null;
|
|
|
|
}
|
|
|
|
|
2015-10-10 13:57:52 -04:00
|
|
|
// TinyMCE editor
|
2015-12-30 14:57:17 -05:00
|
|
|
if (elemExists('#html-editor')) {
|
2015-10-10 13:57:52 -04:00
|
|
|
var tinyMceOptions = require('./pages/page-form');
|
|
|
|
tinymce.init(tinyMceOptions);
|
2015-12-30 15:48:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Page specific items
|
|
|
|
require('./pages/page-show');
|