aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2018-02-24 18:18:33 +0100
committerArthurHoaro <arthur@hoa.ro>2018-03-26 19:29:20 +0200
commitd78c23e00d3007c3fee8c3603acac00efc1ce14e (patch)
treee4c14ee76b143de59a9fcb2c18f185df53b2f650 /inc
parentfaa5b2ce61ddc871eab2919f92d683c917730b10 (diff)
downloadShaarli-d78c23e00d3007c3fee8c3603acac00efc1ce14e.tar.gz
Shaarli-d78c23e00d3007c3fee8c3603acac00efc1ce14e.tar.zst
Shaarli-d78c23e00d3007c3fee8c3603acac00efc1ce14e.zip
Webpack / Remove frontend dependencies from tpl/ & inc/ and move them to assets/
Diffstat (limited to 'inc')
-rw-r--r--inc/awesomplete-multiple-tags.js66
-rw-r--r--inc/awesomplete.css97
-rw-r--r--inc/awesomplete.js450
-rw-r--r--inc/blazy-1.3.1.js232
-rw-r--r--inc/plugin_admin.js103
5 files changed, 0 insertions, 948 deletions
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 @@
1/** @licstart The following is the entire license notice for the
2 * JavaScript code in this page.
3 *
4 * Copyright: (c) 2011-2015 Sébastien SAUVAGE <sebsauvage@sebsauvage.net>
5 * (c) 2011-2017 The Shaarli Community, see AUTHORS
6 *
7 * This software is provided 'as-is', without any express or implied warranty.
8 * In no event will the authors be held liable for any damages arising from
9 * the use of this software.
10 *
11 * Permission is granted to anyone to use this software for any purpose,
12 * including commercial applications, and to alter it and redistribute it
13 * freely, subject to the following restrictions:
14 *
15 * 1. The origin of this software must not be misrepresented; you must not
16 * claim that you wrote the original software. If you use this software
17 * in a product, an acknowledgment in the product documentation would
18 * be appreciated but is not required.
19 *
20 * 2. Altered source versions must be plainly marked as such, and must
21 * not be misrepresented as being the original software.
22 *
23 * 3. This notice may not be removed or altered from any source distribution.
24 *
25 * @licend The above is the entire license notice
26 * for the JavaScript code in this page.
27 */
28
29var awp = Awesomplete.$;
30var autocompleteFields = document.querySelectorAll('input[data-multiple]');
31[].forEach.call(autocompleteFields, function(autocompleteField) {
32 awesomplete = new Awesomplete(awp(autocompleteField), {
33 filter: function (text, input) {
34 return Awesomplete.FILTER_CONTAINS(text, input.match(/[^ ]*$/)[0]);
35 },
36 replace: function (text) {
37 var before = this.input.value.match(/^.+ \s*|/)[0];
38 this.input.value = before + text + " ";
39 },
40 minChars: 1
41 })
42});
43
44/**
45 * Remove already selected items from autocompletion list.
46 * HTML list is never updated, so removing a tag will add it back to awesomplete.
47 *
48 * FIXME: This a workaround waiting for awesomplete to handle this.
49 * https://github.com/LeaVerou/awesomplete/issues/16749
50 */
51function awesompleteUniqueTag(selector) {
52 var input = document.querySelector(selector);
53 input.addEventListener('input', function()
54 {
55 proposedTags = input.getAttribute('data-list').replace(/,/g, '').split(' ');
56 reg = /(\w+) /g;
57 while((match = reg.exec(input.value)) !== null) {
58 id = proposedTags.indexOf(match[1]);
59 if(id != -1 ) {
60 proposedTags.splice(id, 1);
61 }
62 }
63
64 awesomplete.list = proposedTags;
65 });
66}
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 @@
1[hidden] { display: none; }
2
3.visually-hidden {
4 position: absolute;
5 clip: rect(0, 0, 0, 0);
6}
7
8div.awesomplete {
9 display: inline-block;
10 position: relative;
11 width: 100%;
12}
13
14div.awesomplete > input {
15 display: block;
16}
17
18div.awesomplete > ul {
19 position: absolute;
20 left: 0;
21 z-index: 1;
22 min-width: 100%;
23 box-sizing: border-box;
24 list-style: none;
25 padding: 0;
26 border-radius: .3em;
27 margin: .2em 0 0;
28 background: #FFF;
29 border: 1px solid rgba(0,0,0,.3);
30 box-shadow: .05em .2em .6em rgba(0,0,0,.2);
31 text-shadow: none;
32}
33
34div.awesomplete > ul[hidden],
35div.awesomplete > ul:empty {
36 display: none;
37}
38
39@supports (transform: scale(0)) {
40 div.awesomplete > ul {
41 transition: .3s cubic-bezier(.4,.2,.5,1.4);
42 transform-origin: 1.43em -.43em;
43 }
44
45 div.awesomplete > ul[hidden],
46 div.awesomplete > ul:empty {
47 opacity: 0;
48 transform: scale(0);
49 display: block;
50 transition-timing-function: ease;
51 }
52}
53
54/* Pointer */
55div.awesomplete > ul:before {
56 content: "";
57 position: absolute;
58 top: -.43em;
59 left: 1em;
60 width: 0; height: 0;
61 padding: .4em;
62 background: white;
63 border: inherit;
64 border-right: 0;
65 border-bottom: 0;
66 -webkit-transform: rotate(45deg);
67 transform: rotate(45deg);
68}
69
70div.awesomplete > ul > li {
71 position: relative;
72 padding: .2em .5em;
73 cursor: pointer;
74}
75
76div.awesomplete > ul > li:hover {
77 background: hsl(200, 40%, 80%);
78 color: black;
79}
80
81div.awesomplete > ul > li[aria-selected="true"] {
82 background: hsl(205, 40%, 40%);
83 color: white;
84}
85
86div.awesomplete mark {
87 background: hsl(65, 100%, 50%);
88}
89
90div.awesomplete li:hover mark {
91 background: hsl(68, 101%, 41%);
92}
93
94div.awesomplete li[aria-selected="true"] mark {
95 background: hsl(86, 102%, 21%);
96 color: inherit;
97}
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 @@
1/**
2 * Simple, lightweight, usable local autocomplete library for modern browsers
3 * Because there weren’t enough autocomplete scripts in the world? Because I’m completely insane and have NIH syndrome? Probably both. :P
4 * @author Lea Verou http://leaverou.github.io/awesomplete
5 * MIT license
6 */
7
8(function () {
9
10 var _ = function (input, o) {
11 var me = this;
12
13 // Setup
14
15 this.isOpened = false;
16
17 this.input = $(input);
18 this.input.setAttribute("autocomplete", "off");
19 this.input.setAttribute("aria-autocomplete", "list");
20
21 o = o || {};
22
23 configure(this, {
24 minChars: 2,
25 maxItems: 10,
26 autoFirst: false,
27 data: _.DATA,
28 filter: _.FILTER_CONTAINS,
29 sort: _.SORT_BYLENGTH,
30 item: _.ITEM,
31 replace: _.REPLACE
32 }, o);
33
34 this.index = -1;
35
36 // Create necessary elements
37
38 this.container = $.create("div", {
39 className: "awesomplete",
40 around: input
41 });
42
43 this.ul = $.create("ul", {
44 hidden: "hidden",
45 inside: this.container
46 });
47
48 this.status = $.create("span", {
49 className: "visually-hidden",
50 role: "status",
51 "aria-live": "assertive",
52 "aria-relevant": "additions",
53 inside: this.container
54 });
55
56 // Bind events
57
58 $.bind(this.input, {
59 "input": this.evaluate.bind(this),
60 "blur": this.close.bind(this, { reason: "blur" }),
61 "keydown": function(evt) {
62 var c = evt.keyCode;
63
64 // If the dropdown `ul` is in view, then act on keydown for the following keys:
65 // Enter / Esc / Up / Down
66 if(me.opened) {
67 if (c === 13 && me.selected) { // Enter
68 evt.preventDefault();
69 me.select();
70 }
71 else if (c === 27) { // Esc
72 me.close({ reason: "esc" });
73 }
74 else if (c === 38 || c === 40) { // Down/Up arrow
75 evt.preventDefault();
76 me[c === 38? "previous" : "next"]();
77 }
78 }
79 }
80 });
81
82 $.bind(this.input.form, {"submit": this.close.bind(this, { reason: "submit" })});
83
84 $.bind(this.ul, {"mousedown": function(evt) {
85 var li = evt.target;
86
87 if (li !== this) {
88
89 while (li && !/li/i.test(li.nodeName)) {
90 li = li.parentNode;
91 }
92
93 if (li && evt.button === 0) { // Only select on left click
94 evt.preventDefault();
95 me.select(li, evt.target);
96 }
97 }
98 }});
99
100 if (this.input.hasAttribute("list")) {
101 this.list = "#" + this.input.getAttribute("list");
102 this.input.removeAttribute("list");
103 }
104 else {
105 this.list = this.input.getAttribute("data-list") || o.list || [];
106 }
107
108 _.all.push(this);
109 };
110
111 _.prototype = {
112 set list(list) {
113 if (Array.isArray(list)) {
114 this._list = list;
115 }
116 else if (typeof list === "string" && list.indexOf(",") > -1) {
117 this._list = list.split(/\s*,\s*/);
118 }
119 else { // Element or CSS selector
120 list = $(list);
121
122 if (list && list.children) {
123 var items = [];
124 slice.apply(list.children).forEach(function (el) {
125 if (!el.disabled) {
126 var text = el.textContent.trim();
127 var value = el.value || text;
128 var label = el.label || text;
129 if (value !== "") {
130 items.push({ label: label, value: value });
131 }
132 }
133 });
134 this._list = items;
135 }
136 }
137
138 if (document.activeElement === this.input) {
139 this.evaluate();
140 }
141 },
142
143 get selected() {
144 return this.index > -1;
145 },
146
147 get opened() {
148 return this.isOpened;
149 },
150
151 close: function (o) {
152 if (!this.opened) {
153 return;
154 }
155
156 this.ul.setAttribute("hidden", "");
157 this.isOpened = false;
158 this.index = -1;
159
160 $.fire(this.input, "awesomplete-close", o || {});
161 },
162
163 open: function () {
164 this.ul.removeAttribute("hidden");
165 this.isOpened = true;
166
167 if (this.autoFirst && this.index === -1) {
168 this.goto(0);
169 }
170
171 $.fire(this.input, "awesomplete-open");
172 },
173
174 next: function () {
175 var count = this.ul.children.length;
176 this.goto(this.index < count - 1 ? this.index + 1 : (count ? 0 : -1) );
177 },
178
179 previous: function () {
180 var count = this.ul.children.length;
181 var pos = this.index - 1;
182
183 this.goto(this.selected && pos !== -1 ? pos : count - 1);
184 },
185
186 // Should not be used, highlights specific item without any checks!
187 goto: function (i) {
188 var lis = this.ul.children;
189
190 if (this.selected) {
191 lis[this.index].setAttribute("aria-selected", "false");
192 }
193
194 this.index = i;
195
196 if (i > -1 && lis.length > 0) {
197 lis[i].setAttribute("aria-selected", "true");
198 this.status.textContent = lis[i].textContent;
199
200 // scroll to highlighted element in case parent's height is fixed
201 this.ul.scrollTop = lis[i].offsetTop - this.ul.clientHeight + lis[i].clientHeight;
202
203 $.fire(this.input, "awesomplete-highlight", {
204 text: this.suggestions[this.index]
205 });
206 }
207 },
208
209 select: function (selected, origin) {
210 if (selected) {
211 this.index = $.siblingIndex(selected);
212 } else {
213 selected = this.ul.children[this.index];
214 }
215
216 if (selected) {
217 var suggestion = this.suggestions[this.index];
218
219 var allowed = $.fire(this.input, "awesomplete-select", {
220 text: suggestion,
221 origin: origin || selected
222 });
223
224 if (allowed) {
225 this.replace(suggestion);
226 this.close({ reason: "select" });
227 $.fire(this.input, "awesomplete-selectcomplete", {
228 text: suggestion
229 });
230 }
231 }
232 },
233
234 evaluate: function() {
235 var me = this;
236 var value = this.input.value;
237
238 if (value.length >= this.minChars && this._list.length > 0) {
239 this.index = -1;
240 // Populate list with options that match
241 this.ul.innerHTML = "";
242
243 this.suggestions = this._list
244 .map(function(item) {
245 return new Suggestion(me.data(item, value));
246 })
247 .filter(function(item) {
248 return me.filter(item, value);
249 })
250 .sort(this.sort)
251 .slice(0, this.maxItems);
252
253 this.suggestions.forEach(function(text) {
254 me.ul.appendChild(me.item(text, value));
255 });
256
257 if (this.ul.children.length === 0) {
258 this.close({ reason: "nomatches" });
259 } else {
260 this.open();
261 }
262 }
263 else {
264 this.close({ reason: "nomatches" });
265 }
266 }
267 };
268
269// Static methods/properties
270
271 _.all = [];
272
273 _.FILTER_CONTAINS = function (text, input) {
274 return RegExp($.regExpEscape(input.trim()), "i").test(text);
275 };
276
277 _.FILTER_STARTSWITH = function (text, input) {
278 return RegExp("^" + $.regExpEscape(input.trim()), "i").test(text);
279 };
280
281 _.SORT_BYLENGTH = function (a, b) {
282 if (a.length !== b.length) {
283 return a.length - b.length;
284 }
285
286 return a < b? -1 : 1;
287 };
288
289 _.ITEM = function (text, input) {
290 var html = input.trim() === '' ? text : text.replace(RegExp($.regExpEscape(input.trim()), "gi"), "<mark>$&</mark>");
291 return $.create("li", {
292 innerHTML: html,
293 "aria-selected": "false"
294 });
295 };
296
297 _.REPLACE = function (text) {
298 this.input.value = text.value;
299 };
300
301 _.DATA = function (item/*, input*/) { return item; };
302
303// Private functions
304
305 function Suggestion(data) {
306 var o = Array.isArray(data)
307 ? { label: data[0], value: data[1] }
308 : typeof data === "object" && "label" in data && "value" in data ? data : { label: data, value: data };
309
310 this.label = o.label || o.value;
311 this.value = o.value;
312 }
313 Object.defineProperty(Suggestion.prototype = Object.create(String.prototype), "length", {
314 get: function() { return this.label.length; }
315 });
316 Suggestion.prototype.toString = Suggestion.prototype.valueOf = function () {
317 return "" + this.label;
318 };
319
320 function configure(instance, properties, o) {
321 for (var i in properties) {
322 var initial = properties[i],
323 attrValue = instance.input.getAttribute("data-" + i.toLowerCase());
324
325 if (typeof initial === "number") {
326 instance[i] = parseInt(attrValue);
327 }
328 else if (initial === false) { // Boolean options must be false by default anyway
329 instance[i] = attrValue !== null;
330 }
331 else if (initial instanceof Function) {
332 instance[i] = null;
333 }
334 else {
335 instance[i] = attrValue;
336 }
337
338 if (!instance[i] && instance[i] !== 0) {
339 instance[i] = (i in o)? o[i] : initial;
340 }
341 }
342 }
343
344// Helpers
345
346 var slice = Array.prototype.slice;
347
348 function $(expr, con) {
349 return typeof expr === "string"? (con || document).querySelector(expr) : expr || null;
350 }
351
352 function $$(expr, con) {
353 return slice.call((con || document).querySelectorAll(expr));
354 }
355
356 $.create = function(tag, o) {
357 var element = document.createElement(tag);
358
359 for (var i in o) {
360 var val = o[i];
361
362 if (i === "inside") {
363 $(val).appendChild(element);
364 }
365 else if (i === "around") {
366 var ref = $(val);
367 ref.parentNode.insertBefore(element, ref);
368 element.appendChild(ref);
369 }
370 else if (i in element) {
371 element[i] = val;
372 }
373 else {
374 element.setAttribute(i, val);
375 }
376 }
377
378 return element;
379 };
380
381 $.bind = function(element, o) {
382 if (element) {
383 for (var event in o) {
384 var callback = o[event];
385
386 event.split(/\s+/).forEach(function (event) {
387 element.addEventListener(event, callback);
388 });
389 }
390 }
391 };
392
393 $.fire = function(target, type, properties) {
394 var evt = document.createEvent("HTMLEvents");
395
396 evt.initEvent(type, true, true );
397
398 for (var j in properties) {
399 evt[j] = properties[j];
400 }
401
402 return target.dispatchEvent(evt);
403 };
404
405 $.regExpEscape = function (s) {
406 return s.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&");
407 };
408
409 $.siblingIndex = function (el) {
410 /* eslint-disable no-cond-assign */
411 for (var i = 0; el = el.previousElementSibling; i++);
412 return i;
413 };
414
415// Initialization
416
417 function init() {
418 $$("input.awesomplete").forEach(function (input) {
419 new _(input);
420 });
421 }
422
423// Are we in a browser? Check for Document constructor
424 if (typeof Document !== "undefined") {
425 // DOM already loaded?
426 if (document.readyState !== "loading") {
427 init();
428 }
429 else {
430 // Wait for it
431 document.addEventListener("DOMContentLoaded", init);
432 }
433 }
434
435 _.$ = $;
436 _.$$ = $$;
437
438// Make sure to export Awesomplete on self when in a browser
439 if (typeof self !== "undefined") {
440 self.Awesomplete = _;
441 }
442
443// Expose Awesomplete as a CJS module
444 if (typeof module === "object" && module.exports) {
445 module.exports = _;
446 }
447
448 return _;
449
450}()); \ 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 @@
1/*!
2 hey, [be]Lazy.js - v1.3.1 - 2015.02.01
3 A lazy loading and multi-serving image script
4 (c) Bjoern Klinggaard - @bklinggaard - http://dinbror.dk/blazy
5*/
6;(function(root, blazy) {
7 if (typeof define === 'function' && define.amd) {
8 // AMD. Register bLazy as an anonymous module
9 define(blazy);
10 } else if (typeof exports === 'object') {
11 // Node. Does not work with strict CommonJS, but
12 // only CommonJS-like environments that support module.exports,
13 // like Node.
14 module.exports = blazy();
15 } else {
16 // Browser globals. Register bLazy on window
17 root.Blazy = blazy();
18 }
19})(this, function () {
20 'use strict';
21
22 //vars
23 var source, options, viewport, images, count, isRetina, destroyed;
24 //throttle vars
25 var validateT, saveViewportOffsetT;
26
27 // constructor
28 function Blazy(settings) {
29 //IE7- fallback for missing querySelectorAll support
30 if (!document.querySelectorAll) {
31 var s=document.createStyleSheet();
32 document.querySelectorAll = function(r, c, i, j, a) {
33 a=document.all, c=[], r = r.replace(/\[for\b/gi, '[htmlFor').split(',');
34 for (i=r.length; i--;) {
35 s.addRule(r[i], 'k:v');
36 for (j=a.length; j--;) a[j].currentStyle.k && c.push(a[j]);
37 s.removeRule(0);
38 }
39 return c;
40 };
41 }
42 //init vars
43 destroyed = true;
44 images = [];
45 viewport = {};
46 //options
47 options = settings || {};
48 options.error = options.error || false;
49 options.offset = options.offset || 100;
50 options.success = options.success || false;
51 options.selector = options.selector || '.b-lazy';
52 options.separator = options.separator || '|';
53 options.container = options.container ? document.querySelectorAll(options.container) : false;
54 options.errorClass = options.errorClass || 'b-error';
55 options.breakpoints = options.breakpoints || false;
56 options.successClass = options.successClass || 'b-loaded';
57 options.src = source = options.src || 'data-src';
58 isRetina = window.devicePixelRatio > 1;
59 viewport.top = 0 - options.offset;
60 viewport.left = 0 - options.offset;
61 //throttle, ensures that we don't call the functions too often
62 validateT = throttle(validate, 25);
63 saveViewportOffsetT = throttle(saveViewportOffset, 50);
64
65 saveViewportOffset();
66
67 //handle multi-served image src
68 each(options.breakpoints, function(object){
69 if(object.width >= window.screen.width) {
70 source = object.src;
71 return false;
72 }
73 });
74
75 // start lazy load
76 initialize();
77 }
78
79 /* public functions
80 ************************************/
81 Blazy.prototype.revalidate = function() {
82 initialize();
83 };
84 Blazy.prototype.load = function(element, force){
85 if(!isElementLoaded(element)) loadImage(element, force);
86 };
87 Blazy.prototype.destroy = function(){
88 if(options.container){
89 each(options.container, function(object){
90 unbindEvent(object, 'scroll', validateT);
91 });
92 }
93 unbindEvent(window, 'scroll', validateT);
94 unbindEvent(window, 'resize', validateT);
95 unbindEvent(window, 'resize', saveViewportOffsetT);
96 count = 0;
97 images.length = 0;
98 destroyed = true;
99 };
100
101 /* private helper functions
102 ************************************/
103 function initialize(){
104 // First we create an array of images to lazy load
105 createImageArray(options.selector);
106 // Then we bind resize and scroll events if not already binded
107 if(destroyed) {
108 destroyed = false;
109 if(options.container) {
110 each(options.container, function(object){
111 bindEvent(object, 'scroll', validateT);
112 });
113 }
114 bindEvent(window, 'resize', saveViewportOffsetT);
115 bindEvent(window, 'resize', validateT);
116 bindEvent(window, 'scroll', validateT);
117 }
118 // And finally, we start to lazy load. Should bLazy ensure domready?
119 validate();
120 }
121
122 function validate() {
123 for(var i = 0; i<count; i++){
124 var image = images[i];
125 if(elementInView(image) || isElementLoaded(image)) {
126 Blazy.prototype.load(image);
127 images.splice(i, 1);
128 count--;
129 i--;
130 }
131 }
132 if(count === 0) {
133 Blazy.prototype.destroy();
134 }
135 }
136
137 function loadImage(ele, force){
138 // if element is visible
139 if(force || (ele.offsetWidth > 0 && ele.offsetHeight > 0)) {
140 var dataSrc = ele.getAttribute(source) || ele.getAttribute(options.src); // fallback to default data-src
141 if(dataSrc) {
142 var dataSrcSplitted = dataSrc.split(options.separator);
143 var src = dataSrcSplitted[isRetina && dataSrcSplitted.length > 1 ? 1 : 0];
144 var img = new Image();
145 // cleanup markup, remove data source attributes
146 each(options.breakpoints, function(object){
147 ele.removeAttribute(object.src);
148 });
149 ele.removeAttribute(options.src);
150 img.onerror = function() {
151 if(options.error) options.error(ele, "invalid");
152 ele.className = ele.className + ' ' + options.errorClass;
153 };
154 img.onload = function() {
155 // Is element an image or should we add the src as a background image?
156 ele.nodeName.toLowerCase() === 'img' ? ele.src = src : ele.style.backgroundImage = 'url("' + src + '")';
157 ele.className = ele.className + ' ' + options.successClass;
158 if(options.success) options.success(ele);
159 };
160 img.src = src; //preload image
161 } else {
162 if(options.error) options.error(ele, "missing");
163 ele.className = ele.className + ' ' + options.errorClass;
164 }
165 }
166 }
167
168 function elementInView(ele) {
169 var rect = ele.getBoundingClientRect();
170
171 return (
172 // Intersection
173 rect.right >= viewport.left
174 && rect.bottom >= viewport.top
175 && rect.left <= viewport.right
176 && rect.top <= viewport.bottom
177 );
178 }
179
180 function isElementLoaded(ele) {
181 return (' ' + ele.className + ' ').indexOf(' ' + options.successClass + ' ') !== -1;
182 }
183
184 function createImageArray(selector) {
185 var nodelist = document.querySelectorAll(selector);
186 count = nodelist.length;
187 //converting nodelist to array
188 for(var i = count; i--; images.unshift(nodelist[i])){}
189 }
190
191 function saveViewportOffset(){
192 viewport.bottom = (window.innerHeight || document.documentElement.clientHeight) + options.offset;
193 viewport.right = (window.innerWidth || document.documentElement.clientWidth) + options.offset;
194 }
195
196 function bindEvent(ele, type, fn) {
197 if (ele.attachEvent) {
198 ele.attachEvent && ele.attachEvent('on' + type, fn);
199 } else {
200 ele.addEventListener(type, fn, false);
201 }
202 }
203
204 function unbindEvent(ele, type, fn) {
205 if (ele.detachEvent) {
206 ele.detachEvent && ele.detachEvent('on' + type, fn);
207 } else {
208 ele.removeEventListener(type, fn, false);
209 }
210 }
211
212 function each(object, fn){
213 if(object && fn) {
214 var l = object.length;
215 for(var i = 0; i<l && fn(object[i], i) !== false; i++){}
216 }
217 }
218
219 function throttle(fn, minDelay) {
220 var lastCall = 0;
221 return function() {
222 var now = +new Date();
223 if (now - lastCall < minDelay) {
224 return;
225 }
226 lastCall = now;
227 fn.apply(images, arguments);
228 };
229 }
230
231 return Blazy;
232});
diff --git a/inc/plugin_admin.js b/inc/plugin_admin.js
deleted file mode 100644
index 4b55e0f3..00000000
--- a/inc/plugin_admin.js
+++ /dev/null
@@ -1,103 +0,0 @@
1/** @licstart The following is the entire license notice for the
2 * JavaScript code in this page.
3 *
4 * Copyright: (c) 2011-2015 Sébastien SAUVAGE <sebsauvage@sebsauvage.net>
5 * (c) 2011-2017 The Shaarli Community, see AUTHORS
6 *
7 * This software is provided 'as-is', without any express or implied warranty.
8 * In no event will the authors be held liable for any damages arising from
9 * the use of this software.
10 *
11 * Permission is granted to anyone to use this software for any purpose,
12 * including commercial applications, and to alter it and redistribute it
13 * freely, subject to the following restrictions:
14 *
15 * 1. The origin of this software must not be misrepresented; you must not
16 * claim that you wrote the original software. If you use this software
17 * in a product, an acknowledgment in the product documentation would
18 * be appreciated but is not required.
19 *
20 * 2. Altered source versions must be plainly marked as such, and must
21 * not be misrepresented as being the original software.
22 *
23 * 3. This notice may not be removed or altered from any source distribution.
24 *
25 * @licend The above is the entire license notice
26 * for the JavaScript code in this page.
27 */
28
29/**
30 * Change the position counter of a row.
31 *
32 * @param elem Element Node to change.
33 * @param toPos int New position.
34 */
35function changePos(elem, toPos)
36{
37 var elemName = elem.getAttribute('data-line')
38
39 elem.setAttribute('data-order', toPos);
40 var hiddenInput = document.querySelector('[name="order_'+ elemName +'"]');
41 hiddenInput.setAttribute('value', toPos);
42}
43
44/**
45 * Move a row up or down.
46 *
47 * @param pos Element Node to move.
48 * @param move int Move: +1 (down) or -1 (up)
49 */
50function changeOrder(pos, move)
51{
52 var newpos = parseInt(pos) + move;
53 var lines = document.querySelectorAll('[data-order="'+ pos +'"]');
54 var changelines = document.querySelectorAll('[data-order="'+ newpos +'"]');
55
56 // If we go down reverse lines to preserve the rows order
57 if (move > 0) {
58 lines = [].slice.call(lines).reverse();
59 }
60
61 for (var i = 0 ; i < lines.length ; i++) {
62 var parent = changelines[0].parentNode;
63 changePos(lines[i], newpos);
64 changePos(changelines[i], parseInt(pos));
65 var changeItem = move < 0 ? changelines[0] : changelines[changelines.length - 1].nextSibling;
66 parent.insertBefore(lines[i], changeItem);
67 }
68
69}
70
71/**
72 * Move a row up in the table.
73 *
74 * @param pos int row counter.
75 *
76 * @returns false
77 */
78function orderUp(pos)
79{
80 if (pos == 0) {
81 return false;
82 }
83 changeOrder(pos, -1);
84 return false;
85}
86
87/**
88 * Move a row down in the table.
89 *
90 * @param pos int row counter.
91 *
92 * @returns false
93 */
94function orderDown(pos)
95{
96 var lastpos = document.querySelector('[data-order]:last-child').getAttribute('data-order');
97 if (pos == lastpos) {
98 return false;
99 }
100
101 changeOrder(pos, +1);
102 return false;
103}