BookStack/resources/assets/js/global.js

61 lines
1.7 KiB
JavaScript
Raw Normal View History

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
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
$.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
// 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 09:35:53 -04:00
$(this).closest('.chapter').find('.inset-list').slideToggle(180);
});
2015-10-07 18:17:48 -04:00
});
2015-12-30 13:38:18 -05:00
function elemExists(selector) {
return document.querySelector(selector) !== null;
}
// TinyMCE editor
if (elemExists('#html-editor')) {
var tinyMceOptions = require('./pages/page-form');
tinymce.init(tinyMceOptions);
}
// Page specific items
require('./pages/page-show');