mirror of
https://github.com/searxng/searxng
synced 2024-01-01 18:24:07 +00:00
[build] /static
This commit is contained in:
parent
7dc9cc91a8
commit
4798acc661
@ -327,8 +327,19 @@ $(document).ready(function(){
|
|||||||
*
|
*
|
||||||
* @license Free to use under the MIT License.
|
* @license Free to use under the MIT License.
|
||||||
*
|
*
|
||||||
|
* @example <caption>Example usage of searxng.ImageLayout class.</caption>
|
||||||
|
* searxng.image_thumbnail_layout = new searxng.ImageLayout(
|
||||||
|
* '#urls', // container_selector
|
||||||
|
* '#urls .result-images', // results_selector
|
||||||
|
* 'img.image_thumbnail', // img_selector
|
||||||
|
* 14, // verticalMargin
|
||||||
|
* 6, // horizontalMargin
|
||||||
|
* 200 // maxHeight
|
||||||
|
* );
|
||||||
|
* searxng.image_thumbnail_layout.watch();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
(function (w, d) {
|
(function (w, d) {
|
||||||
function ImageLayout(container_selector, results_selector, img_selector, verticalMargin, horizontalMargin, maxHeight) {
|
function ImageLayout(container_selector, results_selector, img_selector, verticalMargin, horizontalMargin, maxHeight) {
|
||||||
this.container_selector = container_selector;
|
this.container_selector = container_selector;
|
||||||
@ -455,6 +466,11 @@ $(document).ready(function(){
|
|||||||
var results_nodes = d.querySelectorAll(this.results_selector);
|
var results_nodes = d.querySelectorAll(this.results_selector);
|
||||||
var results_length = results_nodes.length;
|
var results_length = results_nodes.length;
|
||||||
|
|
||||||
|
function img_load_error(event) {
|
||||||
|
// console.log("ERROR can't load: " + event.originalTarget.src);
|
||||||
|
event.originalTarget.src = w.searxng.static_path + w.searxng.theme.img_load_error;
|
||||||
|
}
|
||||||
|
|
||||||
function throttleAlign() {
|
function throttleAlign() {
|
||||||
if (obj.isAlignDone) {
|
if (obj.isAlignDone) {
|
||||||
obj.isAlignDone = false;
|
obj.isAlignDone = false;
|
||||||
@ -465,15 +481,22 @@ $(document).ready(function(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/API/Window/pageshow_event
|
||||||
w.addEventListener('pageshow', throttleAlign);
|
w.addEventListener('pageshow', throttleAlign);
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/API/FileReader/load_event
|
||||||
w.addEventListener('load', throttleAlign);
|
w.addEventListener('load', throttleAlign);
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/API/Window/resize_event
|
||||||
w.addEventListener('resize', throttleAlign);
|
w.addEventListener('resize', throttleAlign);
|
||||||
|
|
||||||
for (i = 0; i < results_length; i++) {
|
for (i = 0; i < results_length; i++) {
|
||||||
img = results_nodes[i].querySelector(this.img_selector);
|
img = results_nodes[i].querySelector(this.img_selector);
|
||||||
if (img !== null && img !== undefined) {
|
if (img !== null && img !== undefined) {
|
||||||
img.addEventListener('load', throttleAlign);
|
img.addEventListener('load', throttleAlign);
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror
|
||||||
img.addEventListener('error', throttleAlign);
|
img.addEventListener('error', throttleAlign);
|
||||||
|
if (w.searxng.theme.img_load_error) {
|
||||||
|
img.addEventListener('error', img_load_error, {once: true});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
12
searx/static/themes/oscar/js/searxng.min.js
vendored
12
searx/static/themes/oscar/js/searxng.min.js
vendored
@ -60,6 +60,16 @@ $(document).ready(function(){$("#allow-all-engines").click(function(){$(".onoffs
|
|||||||
*
|
*
|
||||||
* @license Free to use under the MIT License.
|
* @license Free to use under the MIT License.
|
||||||
*
|
*
|
||||||
|
* @example <caption>Example usage of searxng.ImageLayout class.</caption>
|
||||||
|
* searxng.image_thumbnail_layout = new searxng.ImageLayout(
|
||||||
|
* '#urls', // container_selector
|
||||||
|
* '#urls .result-images', // results_selector
|
||||||
|
* 'img.image_thumbnail', // img_selector
|
||||||
|
* 14, // verticalMargin
|
||||||
|
* 6, // horizontalMargin
|
||||||
|
* 200 // maxHeight
|
||||||
|
* );
|
||||||
|
* searxng.image_thumbnail_layout.watch();
|
||||||
*/
|
*/
|
||||||
function(o,c){function t(t,e,a,n,i,s){this.container_selector=t,this.results_selector=e,this.img_selector=a,this.verticalMargin=n,this.horizontalMargin=i,this.maxHeight=s,this.isAlignDone=!0}t.prototype._getHeigth=function(t,e){for(var a,n=0,i=0;i<t.length;i++)0<(a=t[i]).naturalWidth&&0<a.naturalHeight?n+=a.naturalWidth/a.naturalHeight:n+=1;return(e-t.length*this.verticalMargin)/n},t.prototype._setSize=function(t,e){for(var a,n,i=t.length,s=0;s<i;s++)a=0<(n=t[s]).naturalWidth&&0<n.naturalHeight?e*n.naturalWidth/n.naturalHeight:e,n.style.width=a+"px",n.style.height=e+"px",n.style.marginLeft=this.horizontalMargin+"px",n.style.marginTop=this.horizontalMargin+"px",n.style.marginRight=this.verticalMargin-7+"px",n.style.marginBottom=this.verticalMargin-7+"px",(n=n.parentNode.parentNode).classList.contains("js")||n.classList.add("js")},t.prototype._alignImgs=function(t){for(var e,a,n,i,s=c.querySelector(this.container_selector),o=window.getComputedStyle(s),r=parseInt(o.getPropertyValue("padding-left"),10),o=parseInt(o.getPropertyValue("padding-right"),10),l=s.clientWidth-r-o;0<t.length;){for(e=!0,n=1;n<=t.length&&e;n++)a=t.slice(0,n),(i=this._getHeigth(a,l))<this.maxHeight&&(this._setSize(a,i),t=t.slice(n),e=!1);if(e){this._setSize(a,Math.min(this.maxHeight,i));break}}},t.prototype.align=function(){for(var t=c.querySelectorAll(this.results_selector),e=t.length,a=null,n=null,i=[],s=0;s<e;s++)(n=t[s]).previousElementSibling!==a&&0<i.length&&(this._alignImgs(i),i=[]),i.push(n.querySelector(this.img_selector)),a=n;0<i.length&&this._alignImgs(i)},t.prototype.watch=function(){var t,e,a=this,n=c.querySelectorAll(this.results_selector),i=n.length;function s(){a.isAlignDone&&(a.isAlignDone=!1,setTimeout(function(){a.align(),a.isAlignDone=!0},100))}for(o.addEventListener("pageshow",s),o.addEventListener("load",s),o.addEventListener("resize",s),t=0;t<i;t++)null!=(e=n[t].querySelector(this.img_selector))&&(e.addEventListener("load",s),e.addEventListener("error",s))},o.searxng.ImageLayout=t}(window,document);
|
function(r,c){function t(t,e,a,n,i,s){this.container_selector=t,this.results_selector=e,this.img_selector=a,this.verticalMargin=n,this.horizontalMargin=i,this.maxHeight=s,this.isAlignDone=!0}t.prototype._getHeigth=function(t,e){for(var a,n=0,i=0;i<t.length;i++)0<(a=t[i]).naturalWidth&&0<a.naturalHeight?n+=a.naturalWidth/a.naturalHeight:n+=1;return(e-t.length*this.verticalMargin)/n},t.prototype._setSize=function(t,e){for(var a,n,i=t.length,s=0;s<i;s++)a=0<(n=t[s]).naturalWidth&&0<n.naturalHeight?e*n.naturalWidth/n.naturalHeight:e,n.style.width=a+"px",n.style.height=e+"px",n.style.marginLeft=this.horizontalMargin+"px",n.style.marginTop=this.horizontalMargin+"px",n.style.marginRight=this.verticalMargin-7+"px",n.style.marginBottom=this.verticalMargin-7+"px",(n=n.parentNode.parentNode).classList.contains("js")||n.classList.add("js")},t.prototype._alignImgs=function(t){for(var e,a,n,i,s=c.querySelector(this.container_selector),o=window.getComputedStyle(s),r=parseInt(o.getPropertyValue("padding-left"),10),o=parseInt(o.getPropertyValue("padding-right"),10),l=s.clientWidth-r-o;0<t.length;){for(e=!0,n=1;n<=t.length&&e;n++)a=t.slice(0,n),(i=this._getHeigth(a,l))<this.maxHeight&&(this._setSize(a,i),t=t.slice(n),e=!1);if(e){this._setSize(a,Math.min(this.maxHeight,i));break}}},t.prototype.align=function(){for(var t=c.querySelectorAll(this.results_selector),e=t.length,a=null,n=null,i=[],s=0;s<e;s++)(n=t[s]).previousElementSibling!==a&&0<i.length&&(this._alignImgs(i),i=[]),i.push(n.querySelector(this.img_selector)),a=n;0<i.length&&this._alignImgs(i)},t.prototype.watch=function(){var t,e,a=this,n=c.querySelectorAll(this.results_selector),i=n.length;function s(t){t.originalTarget.src=r.searxng.static_path+r.searxng.theme.img_load_error}function o(){a.isAlignDone&&(a.isAlignDone=!1,setTimeout(function(){a.align(),a.isAlignDone=!0},100))}for(r.addEventListener("pageshow",o),r.addEventListener("load",o),r.addEventListener("resize",o),t=0;t<i;t++)null!=(e=n[t].querySelector(this.img_selector))&&(e.addEventListener("load",o),e.addEventListener("error",o),r.searxng.theme.img_load_error&&e.addEventListener("error",s,{once:!0}))},r.searxng.ImageLayout=t}(window,document);
|
||||||
//# sourceMappingURL=searxng.min.js.map
|
//# sourceMappingURL=searxng.min.js.map
|
File diff suppressed because one or more lines are too long
BIN
searx/static/themes/simple/img/img_load_error.svg
Normal file
BIN
searx/static/themes/simple/img/img_load_error.svg
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
@ -24,6 +24,10 @@
|
|||||||
hotkeys: script.getAttribute('data-hotkeys') === 'true',
|
hotkeys: script.getAttribute('data-hotkeys') === 'true',
|
||||||
static_path: script.getAttribute('data-static-path'),
|
static_path: script.getAttribute('data-static-path'),
|
||||||
translations: JSON.parse(script.getAttribute('data-translations')),
|
translations: JSON.parse(script.getAttribute('data-translations')),
|
||||||
|
theme : {
|
||||||
|
// image that is displayed if load of <img src='...'> failed
|
||||||
|
img_load_error: 'img/img_load_error.svg'
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// update the css
|
// update the css
|
||||||
|
@ -4,5 +4,5 @@
|
|||||||
* (C) Copyright Contributors to the searx project (2014 - 2021).
|
* (C) Copyright Contributors to the searx project (2014 - 2021).
|
||||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
(function(t,e){"use strict";var a=e.currentScript||function(){var t=e.getElementsByTagName("script");return t[t.length-1]}();t.searxng={touch:"ontouchstart"in t||t.DocumentTouch&&document instanceof DocumentTouch||false,method:a.getAttribute("data-method"),autocompleter:a.getAttribute("data-autocompleter")==="true",search_on_category_select:a.getAttribute("data-search-on-category-select")==="true",infinite_scroll:a.getAttribute("data-infinite-scroll")==="true",hotkeys:a.getAttribute("data-hotkeys")==="true",static_path:a.getAttribute("data-static-path"),translations:JSON.parse(a.getAttribute("data-translations"))};var r=e.getElementsByTagName("html")[0];r.classList.remove("no-js");r.classList.add("js");if(t.searxng.touch){r.classList.add("touch")}})(window,document);
|
(function(t,e){"use strict";var a=e.currentScript||function(){var t=e.getElementsByTagName("script");return t[t.length-1]}();t.searxng={touch:"ontouchstart"in t||t.DocumentTouch&&document instanceof DocumentTouch||false,method:a.getAttribute("data-method"),autocompleter:a.getAttribute("data-autocompleter")==="true",search_on_category_select:a.getAttribute("data-search-on-category-select")==="true",infinite_scroll:a.getAttribute("data-infinite-scroll")==="true",hotkeys:a.getAttribute("data-hotkeys")==="true",static_path:a.getAttribute("data-static-path"),translations:JSON.parse(a.getAttribute("data-translations")),theme:{img_load_error:"img/img_load_error.svg"}};var r=e.getElementsByTagName("html")[0];r.classList.remove("no-js");r.classList.add("js");if(t.searxng.touch){r.classList.add("touch")}})(window,document);
|
||||||
//# sourceMappingURL=searxng.head.min.js.map
|
//# sourceMappingURL=searxng.head.min.js.map
|
@ -1 +1 @@
|
|||||||
{"version":3,"file":"searxng.head.min.js","sources":["searxng.head.js"],"names":["w","d","script","currentScript","scripts","getElementsByTagName","length","searxng","touch","DocumentTouch","document","method","getAttribute","autocompleter","search_on_category_select","infinite_scroll","hotkeys","static_path","translations","JSON","parse","hmtlElement","classList","remove","add","window"],"mappings":";;;;;;CAOA,SAAUA,EAAGC,gBAIT,IAAIC,EAASD,EAAEE,eAAkB,WAC7B,IAAIC,EAAUH,EAAEI,qBAAqB,UACrC,OAAOD,EAAQA,EAAQE,OAAS,GAFH,GAMjCN,EAAEO,QAAU,CACRC,MAAS,iBAAkBR,GAAMA,EAAES,eAAiBC,oBAAoBD,eAAkB,MAC1FE,OAAQT,EAAOU,aAAa,eAC5BC,cAAeX,EAAOU,aAAa,wBAA0B,OAC7DE,0BAA2BZ,EAAOU,aAAa,oCAAsC,OACrFG,gBAAiBb,EAAOU,aAAa,0BAA4B,OACjEI,QAASd,EAAOU,aAAa,kBAAoB,OACjDK,YAAaf,EAAOU,aAAa,oBACjCM,aAAcC,KAAKC,MAAMlB,EAAOU,aAAa,uBAIjD,IAAIS,EAAcpB,EAAEI,qBAAqB,QAAQ,GACjDgB,EAAYC,UAAUC,OAAO,SAC7BF,EAAYC,UAAUE,IAAI,MAC1B,GAAIxB,EAAEO,QAAQC,MAAO,CACjBa,EAAYC,UAAUE,IAAI,WA1BlC,CA4BGC,OAAQf"}
|
{"version":3,"file":"searxng.head.min.js","sources":["searxng.head.js"],"names":["w","d","script","currentScript","scripts","getElementsByTagName","length","searxng","touch","DocumentTouch","document","method","getAttribute","autocompleter","search_on_category_select","infinite_scroll","hotkeys","static_path","translations","JSON","parse","theme","img_load_error","hmtlElement","classList","remove","add","window"],"mappings":";;;;;;CAOA,SAAUA,EAAGC,gBAIT,IAAIC,EAASD,EAAEE,eAAkB,WAC7B,IAAIC,EAAUH,EAAEI,qBAAqB,UACrC,OAAOD,EAAQA,EAAQE,OAAS,GAFH,GAMjCN,EAAEO,QAAU,CACRC,MAAS,iBAAkBR,GAAMA,EAAES,eAAiBC,oBAAoBD,eAAkB,MAC1FE,OAAQT,EAAOU,aAAa,eAC5BC,cAAeX,EAAOU,aAAa,wBAA0B,OAC7DE,0BAA2BZ,EAAOU,aAAa,oCAAsC,OACrFG,gBAAiBb,EAAOU,aAAa,0BAA4B,OACjEI,QAASd,EAAOU,aAAa,kBAAoB,OACjDK,YAAaf,EAAOU,aAAa,oBACjCM,aAAcC,KAAKC,MAAMlB,EAAOU,aAAa,sBAC7CS,MAAQ,CAEJC,eAAgB,2BAKxB,IAAIC,EAActB,EAAEI,qBAAqB,QAAQ,GACjDkB,EAAYC,UAAUC,OAAO,SAC7BF,EAAYC,UAAUE,IAAI,MAC1B,GAAI1B,EAAEO,QAAQC,MAAO,CACjBe,EAAYC,UAAUE,IAAI,WA9BlC,CAgCGC,OAAQjB"}
|
@ -879,8 +879,19 @@ searxng.ready(function() {
|
|||||||
*
|
*
|
||||||
* @license Free to use under the MIT License.
|
* @license Free to use under the MIT License.
|
||||||
*
|
*
|
||||||
|
* @example <caption>Example usage of searxng.ImageLayout class.</caption>
|
||||||
|
* searxng.image_thumbnail_layout = new searxng.ImageLayout(
|
||||||
|
* '#urls', // container_selector
|
||||||
|
* '#urls .result-images', // results_selector
|
||||||
|
* 'img.image_thumbnail', // img_selector
|
||||||
|
* 14, // verticalMargin
|
||||||
|
* 6, // horizontalMargin
|
||||||
|
* 200 // maxHeight
|
||||||
|
* );
|
||||||
|
* searxng.image_thumbnail_layout.watch();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
(function (w, d) {
|
(function (w, d) {
|
||||||
function ImageLayout(container_selector, results_selector, img_selector, verticalMargin, horizontalMargin, maxHeight) {
|
function ImageLayout(container_selector, results_selector, img_selector, verticalMargin, horizontalMargin, maxHeight) {
|
||||||
this.container_selector = container_selector;
|
this.container_selector = container_selector;
|
||||||
@ -1007,6 +1018,11 @@ searxng.ready(function() {
|
|||||||
var results_nodes = d.querySelectorAll(this.results_selector);
|
var results_nodes = d.querySelectorAll(this.results_selector);
|
||||||
var results_length = results_nodes.length;
|
var results_length = results_nodes.length;
|
||||||
|
|
||||||
|
function img_load_error(event) {
|
||||||
|
// console.log("ERROR can't load: " + event.originalTarget.src);
|
||||||
|
event.originalTarget.src = w.searxng.static_path + w.searxng.theme.img_load_error;
|
||||||
|
}
|
||||||
|
|
||||||
function throttleAlign() {
|
function throttleAlign() {
|
||||||
if (obj.isAlignDone) {
|
if (obj.isAlignDone) {
|
||||||
obj.isAlignDone = false;
|
obj.isAlignDone = false;
|
||||||
@ -1017,15 +1033,22 @@ searxng.ready(function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/API/Window/pageshow_event
|
||||||
w.addEventListener('pageshow', throttleAlign);
|
w.addEventListener('pageshow', throttleAlign);
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/API/FileReader/load_event
|
||||||
w.addEventListener('load', throttleAlign);
|
w.addEventListener('load', throttleAlign);
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/API/Window/resize_event
|
||||||
w.addEventListener('resize', throttleAlign);
|
w.addEventListener('resize', throttleAlign);
|
||||||
|
|
||||||
for (i = 0; i < results_length; i++) {
|
for (i = 0; i < results_length; i++) {
|
||||||
img = results_nodes[i].querySelector(this.img_selector);
|
img = results_nodes[i].querySelector(this.img_selector);
|
||||||
if (img !== null && img !== undefined) {
|
if (img !== null && img !== undefined) {
|
||||||
img.addEventListener('load', throttleAlign);
|
img.addEventListener('load', throttleAlign);
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror
|
||||||
img.addEventListener('error', throttleAlign);
|
img.addEventListener('error', throttleAlign);
|
||||||
|
if (w.searxng.theme.img_load_error) {
|
||||||
|
img.addEventListener('error', img_load_error, {once: true});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
16
searx/static/themes/simple/js/searxng.min.js
vendored
16
searx/static/themes/simple/js/searxng.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user