From b3375c7f86f35fce723185bb76d3b5f9c4ff7a07 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 24 Feb 2018 18:18:33 +0100 Subject: Webpack / Remove frontend dependencies from tpl/ & inc/ and move them to assets/ --- inc/awesomplete-multiple-tags.js | 66 ------ inc/awesomplete.css | 97 --------- inc/awesomplete.js | 450 --------------------------------------- inc/blazy-1.3.1.js | 232 -------------------- inc/plugin_admin.js | 103 --------- 5 files changed, 948 deletions(-) delete mode 100644 inc/awesomplete-multiple-tags.js delete mode 100644 inc/awesomplete.css delete mode 100644 inc/awesomplete.js delete mode 100644 inc/blazy-1.3.1.js delete mode 100644 inc/plugin_admin.js (limited to 'inc') diff --git a/inc/awesomplete-multiple-tags.js b/inc/awesomplete-multiple-tags.js deleted file mode 100644 index c38dc38e..00000000 --- a/inc/awesomplete-multiple-tags.js +++ /dev/null @@ -1,66 +0,0 @@ -/** @licstart The following is the entire license notice for the - * JavaScript code in this page. - * - * Copyright: (c) 2011-2015 Sébastien SAUVAGE - * (c) 2011-2017 The Shaarli Community, see AUTHORS - * - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from - * the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would - * be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must - * not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source distribution. - * - * @licend The above is the entire license notice - * for the JavaScript code in this page. - */ - -var awp = Awesomplete.$; -var autocompleteFields = document.querySelectorAll('input[data-multiple]'); -[].forEach.call(autocompleteFields, function(autocompleteField) { - awesomplete = new Awesomplete(awp(autocompleteField), { - filter: function (text, input) { - return Awesomplete.FILTER_CONTAINS(text, input.match(/[^ ]*$/)[0]); - }, - replace: function (text) { - var before = this.input.value.match(/^.+ \s*|/)[0]; - this.input.value = before + text + " "; - }, - minChars: 1 - }) -}); - -/** - * Remove already selected items from autocompletion list. - * HTML list is never updated, so removing a tag will add it back to awesomplete. - * - * FIXME: This a workaround waiting for awesomplete to handle this. - * https://github.com/LeaVerou/awesomplete/issues/16749 - */ -function awesompleteUniqueTag(selector) { - var input = document.querySelector(selector); - input.addEventListener('input', function() - { - proposedTags = input.getAttribute('data-list').replace(/,/g, '').split(' '); - reg = /(\w+) /g; - while((match = reg.exec(input.value)) !== null) { - id = proposedTags.indexOf(match[1]); - if(id != -1 ) { - proposedTags.splice(id, 1); - } - } - - awesomplete.list = proposedTags; - }); -} diff --git a/inc/awesomplete.css b/inc/awesomplete.css deleted file mode 100644 index 47c1928f..00000000 --- a/inc/awesomplete.css +++ /dev/null @@ -1,97 +0,0 @@ -[hidden] { display: none; } - -.visually-hidden { - position: absolute; - clip: rect(0, 0, 0, 0); -} - -div.awesomplete { - display: inline-block; - position: relative; - width: 100%; -} - -div.awesomplete > input { - display: block; -} - -div.awesomplete > ul { - position: absolute; - left: 0; - z-index: 1; - min-width: 100%; - box-sizing: border-box; - list-style: none; - padding: 0; - border-radius: .3em; - margin: .2em 0 0; - background: #FFF; - border: 1px solid rgba(0,0,0,.3); - box-shadow: .05em .2em .6em rgba(0,0,0,.2); - text-shadow: none; -} - -div.awesomplete > ul[hidden], -div.awesomplete > ul:empty { - display: none; -} - -@supports (transform: scale(0)) { - div.awesomplete > ul { - transition: .3s cubic-bezier(.4,.2,.5,1.4); - transform-origin: 1.43em -.43em; - } - - div.awesomplete > ul[hidden], - div.awesomplete > ul:empty { - opacity: 0; - transform: scale(0); - display: block; - transition-timing-function: ease; - } -} - -/* Pointer */ -div.awesomplete > ul:before { - content: ""; - position: absolute; - top: -.43em; - left: 1em; - width: 0; height: 0; - padding: .4em; - background: white; - border: inherit; - border-right: 0; - border-bottom: 0; - -webkit-transform: rotate(45deg); - transform: rotate(45deg); -} - -div.awesomplete > ul > li { - position: relative; - padding: .2em .5em; - cursor: pointer; -} - -div.awesomplete > ul > li:hover { - background: hsl(200, 40%, 80%); - color: black; -} - -div.awesomplete > ul > li[aria-selected="true"] { - background: hsl(205, 40%, 40%); - color: white; -} - -div.awesomplete mark { - background: hsl(65, 100%, 50%); -} - -div.awesomplete li:hover mark { - background: hsl(68, 101%, 41%); -} - -div.awesomplete li[aria-selected="true"] mark { - background: hsl(86, 102%, 21%); - color: inherit; -} diff --git a/inc/awesomplete.js b/inc/awesomplete.js deleted file mode 100644 index 32f49e5b..00000000 --- a/inc/awesomplete.js +++ /dev/null @@ -1,450 +0,0 @@ -/** - * Simple, lightweight, usable local autocomplete library for modern browsers - * Because there weren’t enough autocomplete scripts in the world? Because I’m completely insane and have NIH syndrome? Probably both. :P - * @author Lea Verou http://leaverou.github.io/awesomplete - * MIT license - */ - -(function () { - - var _ = function (input, o) { - var me = this; - - // Setup - - this.isOpened = false; - - this.input = $(input); - this.input.setAttribute("autocomplete", "off"); - this.input.setAttribute("aria-autocomplete", "list"); - - o = o || {}; - - configure(this, { - minChars: 2, - maxItems: 10, - autoFirst: false, - data: _.DATA, - filter: _.FILTER_CONTAINS, - sort: _.SORT_BYLENGTH, - item: _.ITEM, - replace: _.REPLACE - }, o); - - this.index = -1; - - // Create necessary elements - - this.container = $.create("div", { - className: "awesomplete", - around: input - }); - - this.ul = $.create("ul", { - hidden: "hidden", - inside: this.container - }); - - this.status = $.create("span", { - className: "visually-hidden", - role: "status", - "aria-live": "assertive", - "aria-relevant": "additions", - inside: this.container - }); - - // Bind events - - $.bind(this.input, { - "input": this.evaluate.bind(this), - "blur": this.close.bind(this, { reason: "blur" }), - "keydown": function(evt) { - var c = evt.keyCode; - - // If the dropdown `ul` is in view, then act on keydown for the following keys: - // Enter / Esc / Up / Down - if(me.opened) { - if (c === 13 && me.selected) { // Enter - evt.preventDefault(); - me.select(); - } - else if (c === 27) { // Esc - me.close({ reason: "esc" }); - } - else if (c === 38 || c === 40) { // Down/Up arrow - evt.preventDefault(); - me[c === 38? "previous" : "next"](); - } - } - } - }); - - $.bind(this.input.form, {"submit": this.close.bind(this, { reason: "submit" })}); - - $.bind(this.ul, {"mousedown": function(evt) { - var li = evt.target; - - if (li !== this) { - - while (li && !/li/i.test(li.nodeName)) { - li = li.parentNode; - } - - if (li && evt.button === 0) { // Only select on left click - evt.preventDefault(); - me.select(li, evt.target); - } - } - }}); - - if (this.input.hasAttribute("list")) { - this.list = "#" + this.input.getAttribute("list"); - this.input.removeAttribute("list"); - } - else { - this.list = this.input.getAttribute("data-list") || o.list || []; - } - - _.all.push(this); - }; - - _.prototype = { - set list(list) { - if (Array.isArray(list)) { - this._list = list; - } - else if (typeof list === "string" && list.indexOf(",") > -1) { - this._list = list.split(/\s*,\s*/); - } - else { // Element or CSS selector - list = $(list); - - if (list && list.children) { - var items = []; - slice.apply(list.children).forEach(function (el) { - if (!el.disabled) { - var text = el.textContent.trim(); - var value = el.value || text; - var label = el.label || text; - if (value !== "") { - items.push({ label: label, value: value }); - } - } - }); - this._list = items; - } - } - - if (document.activeElement === this.input) { - this.evaluate(); - } - }, - - get selected() { - return this.index > -1; - }, - - get opened() { - return this.isOpened; - }, - - close: function (o) { - if (!this.opened) { - return; - } - - this.ul.setAttribute("hidden", ""); - this.isOpened = false; - this.index = -1; - - $.fire(this.input, "awesomplete-close", o || {}); - }, - - open: function () { - this.ul.removeAttribute("hidden"); - this.isOpened = true; - - if (this.autoFirst && this.index === -1) { - this.goto(0); - } - - $.fire(this.input, "awesomplete-open"); - }, - - next: function () { - var count = this.ul.children.length; - this.goto(this.index < count - 1 ? this.index + 1 : (count ? 0 : -1) ); - }, - - previous: function () { - var count = this.ul.children.length; - var pos = this.index - 1; - - this.goto(this.selected && pos !== -1 ? pos : count - 1); - }, - - // Should not be used, highlights specific item without any checks! - goto: function (i) { - var lis = this.ul.children; - - if (this.selected) { - lis[this.index].setAttribute("aria-selected", "false"); - } - - this.index = i; - - if (i > -1 && lis.length > 0) { - lis[i].setAttribute("aria-selected", "true"); - this.status.textContent = lis[i].textContent; - - // scroll to highlighted element in case parent's height is fixed - this.ul.scrollTop = lis[i].offsetTop - this.ul.clientHeight + lis[i].clientHeight; - - $.fire(this.input, "awesomplete-highlight", { - text: this.suggestions[this.index] - }); - } - }, - - select: function (selected, origin) { - if (selected) { - this.index = $.siblingIndex(selected); - } else { - selected = this.ul.children[this.index]; - } - - if (selected) { - var suggestion = this.suggestions[this.index]; - - var allowed = $.fire(this.input, "awesomplete-select", { - text: suggestion, - origin: origin || selected - }); - - if (allowed) { - this.replace(suggestion); - this.close({ reason: "select" }); - $.fire(this.input, "awesomplete-selectcomplete", { - text: suggestion - }); - } - } - }, - - evaluate: function() { - var me = this; - var value = this.input.value; - - if (value.length >= this.minChars && this._list.length > 0) { - this.index = -1; - // Populate list with options that match - this.ul.innerHTML = ""; - - this.suggestions = this._list - .map(function(item) { - return new Suggestion(me.data(item, value)); - }) - .filter(function(item) { - return me.filter(item, value); - }) - .sort(this.sort) - .slice(0, this.maxItems); - - this.suggestions.forEach(function(text) { - me.ul.appendChild(me.item(text, value)); - }); - - if (this.ul.children.length === 0) { - this.close({ reason: "nomatches" }); - } else { - this.open(); - } - } - else { - this.close({ reason: "nomatches" }); - } - } - }; - -// Static methods/properties - - _.all = []; - - _.FILTER_CONTAINS = function (text, input) { - return RegExp($.regExpEscape(input.trim()), "i").test(text); - }; - - _.FILTER_STARTSWITH = function (text, input) { - return RegExp("^" + $.regExpEscape(input.trim()), "i").test(text); - }; - - _.SORT_BYLENGTH = function (a, b) { - if (a.length !== b.length) { - return a.length - b.length; - } - - return a < b? -1 : 1; - }; - - _.ITEM = function (text, input) { - var html = input.trim() === '' ? text : text.replace(RegExp($.regExpEscape(input.trim()), "gi"), "$&"); - return $.create("li", { - innerHTML: html, - "aria-selected": "false" - }); - }; - - _.REPLACE = function (text) { - this.input.value = text.value; - }; - - _.DATA = function (item/*, input*/) { return item; }; - -// Private functions - - function Suggestion(data) { - var o = Array.isArray(data) - ? { label: data[0], value: data[1] } - : typeof data === "object" && "label" in data && "value" in data ? data : { label: data, value: data }; - - this.label = o.label || o.value; - this.value = o.value; - } - Object.defineProperty(Suggestion.prototype = Object.create(String.prototype), "length", { - get: function() { return this.label.length; } - }); - Suggestion.prototype.toString = Suggestion.prototype.valueOf = function () { - return "" + this.label; - }; - - function configure(instance, properties, o) { - for (var i in properties) { - var initial = properties[i], - attrValue = instance.input.getAttribute("data-" + i.toLowerCase()); - - if (typeof initial === "number") { - instance[i] = parseInt(attrValue); - } - else if (initial === false) { // Boolean options must be false by default anyway - instance[i] = attrValue !== null; - } - else if (initial instanceof Function) { - instance[i] = null; - } - else { - instance[i] = attrValue; - } - - if (!instance[i] && instance[i] !== 0) { - instance[i] = (i in o)? o[i] : initial; - } - } - } - -// Helpers - - var slice = Array.prototype.slice; - - function $(expr, con) { - return typeof expr === "string"? (con || document).querySelector(expr) : expr || null; - } - - function $$(expr, con) { - return slice.call((con || document).querySelectorAll(expr)); - } - - $.create = function(tag, o) { - var element = document.createElement(tag); - - for (var i in o) { - var val = o[i]; - - if (i === "inside") { - $(val).appendChild(element); - } - else if (i === "around") { - var ref = $(val); - ref.parentNode.insertBefore(element, ref); - element.appendChild(ref); - } - else if (i in element) { - element[i] = val; - } - else { - element.setAttribute(i, val); - } - } - - return element; - }; - - $.bind = function(element, o) { - if (element) { - for (var event in o) { - var callback = o[event]; - - event.split(/\s+/).forEach(function (event) { - element.addEventListener(event, callback); - }); - } - } - }; - - $.fire = function(target, type, properties) { - var evt = document.createEvent("HTMLEvents"); - - evt.initEvent(type, true, true ); - - for (var j in properties) { - evt[j] = properties[j]; - } - - return target.dispatchEvent(evt); - }; - - $.regExpEscape = function (s) { - return s.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&"); - }; - - $.siblingIndex = function (el) { - /* eslint-disable no-cond-assign */ - for (var i = 0; el = el.previousElementSibling; i++); - return i; - }; - -// Initialization - - function init() { - $$("input.awesomplete").forEach(function (input) { - new _(input); - }); - } - -// Are we in a browser? Check for Document constructor - if (typeof Document !== "undefined") { - // DOM already loaded? - if (document.readyState !== "loading") { - init(); - } - else { - // Wait for it - document.addEventListener("DOMContentLoaded", init); - } - } - - _.$ = $; - _.$$ = $$; - -// Make sure to export Awesomplete on self when in a browser - if (typeof self !== "undefined") { - self.Awesomplete = _; - } - -// Expose Awesomplete as a CJS module - if (typeof module === "object" && module.exports) { - module.exports = _; - } - - return _; - -}()); \ No newline at end of file diff --git a/inc/blazy-1.3.1.js b/inc/blazy-1.3.1.js deleted file mode 100644 index cfc2dbde..00000000 --- a/inc/blazy-1.3.1.js +++ /dev/null @@ -1,232 +0,0 @@ -/*! - hey, [be]Lazy.js - v1.3.1 - 2015.02.01 - A lazy loading and multi-serving image script - (c) Bjoern Klinggaard - @bklinggaard - http://dinbror.dk/blazy -*/ -;(function(root, blazy) { - if (typeof define === 'function' && define.amd) { - // AMD. Register bLazy as an anonymous module - define(blazy); - } else if (typeof exports === 'object') { - // Node. Does not work with strict CommonJS, but - // only CommonJS-like environments that support module.exports, - // like Node. - module.exports = blazy(); - } else { - // Browser globals. Register bLazy on window - root.Blazy = blazy(); - } -})(this, function () { - 'use strict'; - - //vars - var source, options, viewport, images, count, isRetina, destroyed; - //throttle vars - var validateT, saveViewportOffsetT; - - // constructor - function Blazy(settings) { - //IE7- fallback for missing querySelectorAll support - if (!document.querySelectorAll) { - var s=document.createStyleSheet(); - document.querySelectorAll = function(r, c, i, j, a) { - a=document.all, c=[], r = r.replace(/\[for\b/gi, '[htmlFor').split(','); - for (i=r.length; i--;) { - s.addRule(r[i], 'k:v'); - for (j=a.length; j--;) a[j].currentStyle.k && c.push(a[j]); - s.removeRule(0); - } - return c; - }; - } - //init vars - destroyed = true; - images = []; - viewport = {}; - //options - options = settings || {}; - options.error = options.error || false; - options.offset = options.offset || 100; - options.success = options.success || false; - options.selector = options.selector || '.b-lazy'; - options.separator = options.separator || '|'; - options.container = options.container ? document.querySelectorAll(options.container) : false; - options.errorClass = options.errorClass || 'b-error'; - options.breakpoints = options.breakpoints || false; - options.successClass = options.successClass || 'b-loaded'; - options.src = source = options.src || 'data-src'; - isRetina = window.devicePixelRatio > 1; - viewport.top = 0 - options.offset; - viewport.left = 0 - options.offset; - //throttle, ensures that we don't call the functions too often - validateT = throttle(validate, 25); - saveViewportOffsetT = throttle(saveViewportOffset, 50); - - saveViewportOffset(); - - //handle multi-served image src - each(options.breakpoints, function(object){ - if(object.width >= window.screen.width) { - source = object.src; - return false; - } - }); - - // start lazy load - initialize(); - } - - /* public functions - ************************************/ - Blazy.prototype.revalidate = function() { - initialize(); - }; - Blazy.prototype.load = function(element, force){ - if(!isElementLoaded(element)) loadImage(element, force); - }; - Blazy.prototype.destroy = function(){ - if(options.container){ - each(options.container, function(object){ - unbindEvent(object, 'scroll', validateT); - }); - } - unbindEvent(window, 'scroll', validateT); - unbindEvent(window, 'resize', validateT); - unbindEvent(window, 'resize', saveViewportOffsetT); - count = 0; - images.length = 0; - destroyed = true; - }; - - /* private helper functions - ************************************/ - function initialize(){ - // First we create an array of images to lazy load - createImageArray(options.selector); - // Then we bind resize and scroll events if not already binded - if(destroyed) { - destroyed = false; - if(options.container) { - each(options.container, function(object){ - bindEvent(object, 'scroll', validateT); - }); - } - bindEvent(window, 'resize', saveViewportOffsetT); - bindEvent(window, 'resize', validateT); - bindEvent(window, 'scroll', validateT); - } - // And finally, we start to lazy load. Should bLazy ensure domready? - validate(); - } - - function validate() { - for(var i = 0; i 0 && ele.offsetHeight > 0)) { - var dataSrc = ele.getAttribute(source) || ele.getAttribute(options.src); // fallback to default data-src - if(dataSrc) { - var dataSrcSplitted = dataSrc.split(options.separator); - var src = dataSrcSplitted[isRetina && dataSrcSplitted.length > 1 ? 1 : 0]; - var img = new Image(); - // cleanup markup, remove data source attributes - each(options.breakpoints, function(object){ - ele.removeAttribute(object.src); - }); - ele.removeAttribute(options.src); - img.onerror = function() { - if(options.error) options.error(ele, "invalid"); - ele.className = ele.className + ' ' + options.errorClass; - }; - img.onload = function() { - // Is element an image or should we add the src as a background image? - ele.nodeName.toLowerCase() === 'img' ? ele.src = src : ele.style.backgroundImage = 'url("' + src + '")'; - ele.className = ele.className + ' ' + options.successClass; - if(options.success) options.success(ele); - }; - img.src = src; //preload image - } else { - if(options.error) options.error(ele, "missing"); - ele.className = ele.className + ' ' + options.errorClass; - } - } - } - - function elementInView(ele) { - var rect = ele.getBoundingClientRect(); - - return ( - // Intersection - rect.right >= viewport.left - && rect.bottom >= viewport.top - && rect.left <= viewport.right - && rect.top <= viewport.bottom - ); - } - - function isElementLoaded(ele) { - return (' ' + ele.className + ' ').indexOf(' ' + options.successClass + ' ') !== -1; - } - - function createImageArray(selector) { - var nodelist = document.querySelectorAll(selector); - count = nodelist.length; - //converting nodelist to array - for(var i = count; i--; images.unshift(nodelist[i])){} - } - - function saveViewportOffset(){ - viewport.bottom = (window.innerHeight || document.documentElement.clientHeight) + options.offset; - viewport.right = (window.innerWidth || document.documentElement.clientWidth) + options.offset; - } - - function bindEvent(ele, type, fn) { - if (ele.attachEvent) { - ele.attachEvent && ele.attachEvent('on' + type, fn); - } else { - ele.addEventListener(type, fn, false); - } - } - - function unbindEvent(ele, type, fn) { - if (ele.detachEvent) { - ele.detachEvent && ele.detachEvent('on' + type, fn); - } else { - ele.removeEventListener(type, fn, false); - } - } - - function each(object, fn){ - if(object && fn) { - var l = object.length; - for(var i = 0; i - * (c) 2011-2017 The Shaarli Community, see AUTHORS - * - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from - * the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would - * be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must - * not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source distribution. - * - * @licend The above is the entire license notice - * for the JavaScript code in this page. - */ - -/** - * Change the position counter of a row. - * - * @param elem Element Node to change. - * @param toPos int New position. - */ -function changePos(elem, toPos) -{ - var elemName = elem.getAttribute('data-line') - - elem.setAttribute('data-order', toPos); - var hiddenInput = document.querySelector('[name="order_'+ elemName +'"]'); - hiddenInput.setAttribute('value', toPos); -} - -/** - * Move a row up or down. - * - * @param pos Element Node to move. - * @param move int Move: +1 (down) or -1 (up) - */ -function changeOrder(pos, move) -{ - var newpos = parseInt(pos) + move; - var lines = document.querySelectorAll('[data-order="'+ pos +'"]'); - var changelines = document.querySelectorAll('[data-order="'+ newpos +'"]'); - - // If we go down reverse lines to preserve the rows order - if (move > 0) { - lines = [].slice.call(lines).reverse(); - } - - for (var i = 0 ; i < lines.length ; i++) { - var parent = changelines[0].parentNode; - changePos(lines[i], newpos); - changePos(changelines[i], parseInt(pos)); - var changeItem = move < 0 ? changelines[0] : changelines[changelines.length - 1].nextSibling; - parent.insertBefore(lines[i], changeItem); - } - -} - -/** - * Move a row up in the table. - * - * @param pos int row counter. - * - * @returns false - */ -function orderUp(pos) -{ - if (pos == 0) { - return false; - } - changeOrder(pos, -1); - return false; -} - -/** - * Move a row down in the table. - * - * @param pos int row counter. - * - * @returns false - */ -function orderDown(pos) -{ - var lastpos = document.querySelector('[data-order]:last-child').getAttribute('data-order'); - if (pos == lastpos) { - return false; - } - - changeOrder(pos, +1); - return false; -} -- cgit v1.2.3