2015-12-29 17:39:25 +01:00
|
|
|
// Configure ZeroClipboard
|
2015-10-10 19:57:52 +02:00
|
|
|
window.ZeroClipboard = require('zeroclipboard');
|
|
|
|
window.ZeroClipboard.config({
|
|
|
|
swfPath: '/ZeroClipboard.swf'
|
|
|
|
});
|
2015-10-09 00:49:18 +02:00
|
|
|
|
2015-12-29 17:39:25 +01:00
|
|
|
// AngularJS - Create application and load components
|
|
|
|
var angular = require('angular');
|
2015-12-30 19:38:18 +01: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 20:57:17 +01:00
|
|
|
jQuery.fn.smoothScrollTo = function () {
|
|
|
|
if (this.length === 0) return;
|
2015-12-30 19:38:18 +01: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 20:57:17 +01:00
|
|
|
$.expr[":"].contains = $.expr.createPseudo(function (arg) {
|
|
|
|
return function (elem) {
|
2015-12-30 19:38:18 +01:00
|
|
|
return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
|
|
|
|
};
|
|
|
|
});
|
2015-12-29 17:39:25 +01:00
|
|
|
|
2015-10-09 00:49:18 +02:00
|
|
|
// Global jQuery Elements
|
2015-09-03 17:51:10 +02:00
|
|
|
$(function () {
|
|
|
|
|
2015-09-03 20:05:45 +02:00
|
|
|
// Notification hiding
|
2015-09-03 17:51:10 +02:00
|
|
|
$('.notification').click(function () {
|
|
|
|
$(this).fadeOut(100);
|
|
|
|
});
|
|
|
|
|
2015-09-03 20:05:45 +02:00
|
|
|
// Chapter page list toggles
|
2015-12-30 20:57:17 +01:00
|
|
|
$('.chapter-toggle').click(function (e) {
|
2015-09-03 20:05:45 +02:00
|
|
|
e.preventDefault();
|
|
|
|
$(this).toggleClass('open');
|
2015-09-06 15:35:53 +02:00
|
|
|
$(this).closest('.chapter').find('.inset-list').slideToggle(180);
|
2015-09-03 20:05:45 +02:00
|
|
|
});
|
|
|
|
|
2015-10-08 00:17:48 +02:00
|
|
|
});
|
|
|
|
|
2015-12-30 19:38:18 +01:00
|
|
|
|
|
|
|
function elemExists(selector) {
|
|
|
|
return document.querySelector(selector) !== null;
|
|
|
|
}
|
|
|
|
|
2015-10-10 19:57:52 +02:00
|
|
|
// TinyMCE editor
|
2015-12-30 20:57:17 +01:00
|
|
|
if (elemExists('#html-editor')) {
|
2015-10-10 19:57:52 +02:00
|
|
|
var tinyMceOptions = require('./pages/page-form');
|
|
|
|
tinymce.init(tinyMceOptions);
|
2015-12-29 17:39:25 +01:00
|
|
|
}
|