1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2024-10-30 23:52:40 +01:00
BookStack/resources/assets/js/global.js

62 lines
1.7 KiB
JavaScript
Raw Normal View History

2015-12-29 17:39:25 +01:00
// Configure ZeroClipboard
window.ZeroClipboard = require('zeroclipboard');
window.ZeroClipboard.config({
swfPath: '/ZeroClipboard.swf'
});
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
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
$.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
// Global jQuery Elements
$(function () {
// Notification hiding
$('.notification').click(function () {
$(this).fadeOut(100);
});
// Chapter page list toggles
$('.chapter-toggle').click(function (e) {
e.preventDefault();
$(this).toggleClass('open');
2015-09-06 15:35:53 +02:00
$(this).closest('.chapter').find('.inset-list').slideToggle(180);
});
2015-10-08 00:17:48 +02:00
});
2015-12-30 19:38:18 +01:00
function elemExists(selector) {
return document.querySelector(selector) !== null;
}
// TinyMCE editor
if (elemExists('#html-editor')) {
var tinyMceOptions = require('./pages/page-form');
tinymce.init(tinyMceOptions);
2015-12-29 17:39:25 +01:00
}