48 lines
21 KiB
JavaScript
48 lines
21 KiB
JavaScript
/*
|
|
***************************************************
|
|
mark.js v8.11.0
|
|
https://github.com/julmot/mark.js
|
|
Copyright (c) 2014?2017, Julian Motz
|
|
Released under the MIT license https://git.io/vwTVl
|
|
****************************************************/
|
|
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.owns=function(b,e){return Object.prototype.hasOwnProperty.call(b,e)};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(b,e,g){b!=Array.prototype&&b!=Object.prototype&&(b[e]=g.value)};
|
|
$jscomp.getGlobal=function(b){return"undefined"!=typeof window&&window===b?b:"undefined"!=typeof global&&null!=global?global:b};$jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(b,e,g,h){if(e){g=$jscomp.global;b=b.split(".");for(h=0;h<b.length-1;h++){var m=b[h];m in g||(g[m]={});g=g[m]}b=b[b.length-1];h=g[b];e=e(h);e!=h&&null!=e&&$jscomp.defineProperty(g,b,{configurable:!0,writable:!0,value:e})}};
|
|
$jscomp.polyfill("Object.assign",function(b){return b?b:function(b,g){for(var e=1;e<arguments.length;e++){var m=arguments[e];if(m)for(var q in m)$jscomp.owns(m,q)&&(b[q]=m[q])}return b}},"es6","es3");$jscomp.SYMBOL_PREFIX="jscomp_symbol_";$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.Symbol=function(){var b=0;return function(e){return $jscomp.SYMBOL_PREFIX+(e||"")+b++}}();
|
|
$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var b=$jscomp.global.Symbol.iterator;b||(b=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[b]&&$jscomp.defineProperty(Array.prototype,b,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};$jscomp.arrayIterator=function(b){var e=0;return $jscomp.iteratorPrototype(function(){return e<b.length?{done:!1,value:b[e++]}:{done:!0}})};
|
|
$jscomp.iteratorPrototype=function(b){$jscomp.initSymbolIterator();b={next:b};b[$jscomp.global.Symbol.iterator]=function(){return this};return b};$jscomp.iteratorFromArray=function(b,e){$jscomp.initSymbolIterator();b instanceof String&&(b+="");var g=0,h={next:function(){if(g<b.length){var m=g++;return{value:e(m,b[m]),done:!1}}h.next=function(){return{done:!0,value:void 0}};return h.next()}};h[Symbol.iterator]=function(){return h};return h};
|
|
$jscomp.polyfill("Array.prototype.keys",function(b){return b?b:function(){return $jscomp.iteratorFromArray(this,function(b){return b})}},"es6","es3");
|
|
var _extends=Object.assign||function(b){for(var e=1;e<arguments.length;e++){var g=arguments[e],h;for(h in g)Object.prototype.hasOwnProperty.call(g,h)&&(b[h]=g[h])}return b},_createClass=function(){function b(b,g){for(var e=0;e<g.length;e++){var m=g[e];m.enumerable=m.enumerable||!1;m.configurable=!0;"value"in m&&(m.writable=!0);Object.defineProperty(b,m.key,m)}}return function(e,g,h){g&&b(e.prototype,g);h&&b(e,h);return e}}(),_typeof="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(b){return typeof b}:
|
|
function(b){return b&&"function"===typeof Symbol&&b.constructor===Symbol&&b!==Symbol.prototype?"symbol":typeof b};function _classCallCheck(b,e){if(!(b instanceof e))throw new TypeError("Cannot call a class as a function");}
|
|
(function(b,e,g){"function"===typeof define&&define.amd?define(["jquery"],function(h){return b(e,g,h)}):"object"===("undefined"===typeof module?"undefined":_typeof(module))&&module.exports?module.exports=b(e,g,require("jquery")):b(e,g,jQuery)})(function(b,e,g){var h=function(){function g(a){_classCallCheck(this,g);this.ctx=a;this.ie=!1;a=b.navigator.userAgent;if(-1<a.indexOf("MSIE")||-1<a.indexOf("Trident"))this.ie=!0}_createClass(g,[{key:"log",value:function(a){var c=1<arguments.length&&void 0!==
|
|
arguments[1]?arguments[1]:"debug",d=this.opt.log;if(this.opt.debug&&"object"===("undefined"===typeof d?"undefined":_typeof(d))&&"function"===typeof d[c])d[c]("mark.js: "+a)}},{key:"escapeStr",value:function(a){return a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}},{key:"createRegExp",value:function(a){"disabled"!==this.opt.wildcards&&(a=this.setupWildcardsRegExp(a));a=this.escapeStr(a);Object.keys(this.opt.synonyms).length&&(a=this.createSynonymsRegExp(a));if(this.opt.ignoreJoiners||this.opt.ignorePunctuation.length)a=
|
|
this.setupIgnoreJoinersRegExp(a);this.opt.diacritics&&(a=this.createDiacriticsRegExp(a));a=this.createMergedBlanksRegExp(a);if(this.opt.ignoreJoiners||this.opt.ignorePunctuation.length)a=this.createJoinersRegExp(a);"disabled"!==this.opt.wildcards&&(a=this.createWildcardsRegExp(a));return a=this.createAccuracyRegExp(a)}},{key:"createSynonymsRegExp",value:function(a){var c=this.opt.synonyms,d=this.opt.caseSensitive?"":"i",l=this.opt.ignoreJoiners||this.opt.ignorePunctuation.length?"\x00":"",f;for(f in c)if(c.hasOwnProperty(f)){var k=
|
|
c[f],b="disabled"!==this.opt.wildcards?this.setupWildcardsRegExp(f):this.escapeStr(f);k="disabled"!==this.opt.wildcards?this.setupWildcardsRegExp(k):this.escapeStr(k);""!==b&&""!==k&&(a=a.replace(new RegExp("("+b+"|"+k+")","gm"+d),l+("("+this.processSynomyms(b)+"|")+(this.processSynomyms(k)+")")+l))}return a}},{key:"processSynomyms",value:function(a){if(this.opt.ignoreJoiners||this.opt.ignorePunctuation.length)a=this.setupIgnoreJoinersRegExp(a);return a}},{key:"setupWildcardsRegExp",value:function(a){a=
|
|
a.replace(/(?:\\)*\?/g,function(a){return"\\"===a.charAt(0)?"?":"\u0001"});return a.replace(/(?:\\)*\*/g,function(a){return"\\"===a.charAt(0)?"*":"\u0002"})}},{key:"createWildcardsRegExp",value:function(a){var c="withSpaces"===this.opt.wildcards;return a.replace(/\u0001/g,c?"[\\S\\s]?":"\\S?").replace(/\u0002/g,c?"[\\S\\s]*?":"\\S*")}},{key:"setupIgnoreJoinersRegExp",value:function(a){return a.replace(/[^(|)\\]/g,function(a,d,l){d=l.charAt(d+1);return/[(|)\\]/.test(d)||""===d?a:a+"\x00"})}},{key:"createJoinersRegExp",
|
|
value:function(a){var c=[],d=this.opt.ignorePunctuation;Array.isArray(d)&&d.length&&c.push(this.escapeStr(d.join("")));this.opt.ignoreJoiners&&c.push("\\u00ad\\u200b\\u200c\\u200d");return c.length?a.split(/\u0000+/).join("["+c.join("")+"]*"):a}},{key:"createDiacriticsRegExp",value:function(a){var c=this.opt.caseSensitive?"":"i",d=this.opt.caseSensitive?"a\u00e0\u00e1\u1ea3\u00e3\u1ea1\u0103\u1eb1\u1eaf\u1eb3\u1eb5\u1eb7\u00e2\u1ea7\u1ea5\u1ea9\u1eab\u1ead\u00e4\u00e5\u0101\u0105 A\u00c0\u00c1\u1ea2\u00c3\u1ea0\u0102\u1eb0\u1eae\u1eb2\u1eb4\u1eb6\u00c2\u1ea6\u1ea4\u1ea8\u1eaa\u1eac\u00c4\u00c5\u0100\u0104 c\u00e7\u0107\u010d C\u00c7\u0106\u010c d\u0111\u010f D\u0110\u010e e\u00e8\u00e9\u1ebb\u1ebd\u1eb9\u00ea\u1ec1\u1ebf\u1ec3\u1ec5\u1ec7\u00eb\u011b\u0113\u0119 E\u00c8\u00c9\u1eba\u1ebc\u1eb8\u00ca\u1ec0\u1ebe\u1ec2\u1ec4\u1ec6\u00cb\u011a\u0112\u0118 i\u00ec\u00ed\u1ec9\u0129\u1ecb\u00ee\u00ef\u012b I\u00cc\u00cd\u1ec8\u0128\u1eca\u00ce\u00cf\u012a l\u0142 L\u0141 n\u00f1\u0148\u0144 N\u00d1\u0147\u0143 o\u00f2\u00f3\u1ecf\u00f5\u1ecd\u00f4\u1ed3\u1ed1\u1ed5\u1ed7\u1ed9\u01a1\u1edf\u1ee1\u1edb\u1edd\u1ee3\u00f6\u00f8\u014d O\u00d2\u00d3\u1ece\u00d5\u1ecc\u00d4\u1ed2\u1ed0\u1ed4\u1ed6\u1ed8\u01a0\u1ede\u1ee0\u1eda\u1edc\u1ee2\u00d6\u00d8\u014c r\u0159 R\u0158 s\u0161\u015b\u0219\u015f S\u0160\u015a\u0218\u015e t\u0165\u021b\u0163 T\u0164\u021a\u0162 u\u00f9\u00fa\u1ee7\u0169\u1ee5\u01b0\u1eeb\u1ee9\u1eed\u1eef\u1ef1\u00fb\u00fc\u016f\u016b U\u00d9\u00da\u1ee6\u0168\u1ee4\u01af\u1eea\u1ee8\u1eec\u1eee\u1ef0\u00db\u00dc\u016e\u016a y\u00fd\u1ef3\u1ef7\u1ef9\u1ef5\u00ff Y\u00dd\u1ef2\u1ef6\u1ef8\u1ef4\u0178 z\u017e\u017c\u017a Z\u017d\u017b\u0179".split(" "):
|
|
"a\u00e0\u00e1\u1ea3\u00e3\u1ea1\u0103\u1eb1\u1eaf\u1eb3\u1eb5\u1eb7\u00e2\u1ea7\u1ea5\u1ea9\u1eab\u1ead\u00e4\u00e5\u0101\u0105A\u00c0\u00c1\u1ea2\u00c3\u1ea0\u0102\u1eb0\u1eae\u1eb2\u1eb4\u1eb6\u00c2\u1ea6\u1ea4\u1ea8\u1eaa\u1eac\u00c4\u00c5\u0100\u0104 c\u00e7\u0107\u010dC\u00c7\u0106\u010c d\u0111\u010fD\u0110\u010e e\u00e8\u00e9\u1ebb\u1ebd\u1eb9\u00ea\u1ec1\u1ebf\u1ec3\u1ec5\u1ec7\u00eb\u011b\u0113\u0119E\u00c8\u00c9\u1eba\u1ebc\u1eb8\u00ca\u1ec0\u1ebe\u1ec2\u1ec4\u1ec6\u00cb\u011a\u0112\u0118 i\u00ec\u00ed\u1ec9\u0129\u1ecb\u00ee\u00ef\u012bI\u00cc\u00cd\u1ec8\u0128\u1eca\u00ce\u00cf\u012a l\u0142L\u0141 n\u00f1\u0148\u0144N\u00d1\u0147\u0143 o\u00f2\u00f3\u1ecf\u00f5\u1ecd\u00f4\u1ed3\u1ed1\u1ed5\u1ed7\u1ed9\u01a1\u1edf\u1ee1\u1edb\u1edd\u1ee3\u00f6\u00f8\u014dO\u00d2\u00d3\u1ece\u00d5\u1ecc\u00d4\u1ed2\u1ed0\u1ed4\u1ed6\u1ed8\u01a0\u1ede\u1ee0\u1eda\u1edc\u1ee2\u00d6\u00d8\u014c r\u0159R\u0158 s\u0161\u015b\u0219\u015fS\u0160\u015a\u0218\u015e t\u0165\u021b\u0163T\u0164\u021a\u0162 u\u00f9\u00fa\u1ee7\u0169\u1ee5\u01b0\u1eeb\u1ee9\u1eed\u1eef\u1ef1\u00fb\u00fc\u016f\u016bU\u00d9\u00da\u1ee6\u0168\u1ee4\u01af\u1eea\u1ee8\u1eec\u1eee\u1ef0\u00db\u00dc\u016e\u016a y\u00fd\u1ef3\u1ef7\u1ef9\u1ef5\u00ffY\u00dd\u1ef2\u1ef6\u1ef8\u1ef4\u0178 z\u017e\u017c\u017aZ\u017d\u017b\u0179".split(" "),
|
|
l=[];a.split("").forEach(function(f){d.every(function(d){if(-1!==d.indexOf(f)){if(-1<l.indexOf(d))return!1;a=a.replace(new RegExp("["+d+"]","gm"+c),"["+d+"]");l.push(d)}return!0})});return a}},{key:"createMergedBlanksRegExp",value:function(a){return a.replace(/[\s]+/gmi,"[\\s]+")}},{key:"createAccuracyRegExp",value:function(a){var c=this,d=this.opt.accuracy,l="string"===typeof d?d:d.value,f="";("string"===typeof d?[]:d.limiters).forEach(function(a){f+="|"+c.escapeStr(a)});switch(l){default:return"()("+
|
|
a+")";case "complementary":return f="\\s"+(f?f:this.escapeStr("!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~\u00a1\u00bf")),"()([^"+f+"]*"+a+"[^"+f+"]*)";case "exactly":return"(^|\\s"+f+")("+a+")(?=$|\\s"+f+")"}}},{key:"getSeparatedKeywords",value:function(a){var c=this,d=[];a.forEach(function(a){c.opt.separateWordSearch?a.split(" ").forEach(function(a){a.trim()&&-1===d.indexOf(a)&&d.push(a)}):a.trim()&&-1===d.indexOf(a)&&d.push(a)});return{keywords:d.sort(function(a,d){return d.length-a.length}),length:d.length}}},
|
|
{key:"isNumeric",value:function(a){return Number(parseFloat(a))==a}},{key:"checkRanges",value:function(a){var c=this;if(!Array.isArray(a)||"[object Object]"!==Object.prototype.toString.call(a[0]))return this.log("markRanges() will only accept an array of objects"),this.opt.noMatch(a),[];var d=[],l=0;a.sort(function(a,d){return a.start-d.start}).forEach(function(a){var f=c.callNoMatchOnInvalidRanges(a,l),b=f.start,e=f.end;f.valid&&(a.start=b,a.length=e-b,d.push(a),l=e)});return d}},{key:"callNoMatchOnInvalidRanges",
|
|
value:function(a,c){var d=void 0,l=void 0,f=!1;a&&"undefined"!==typeof a.start?(d=parseInt(a.start,10),l=d+parseInt(a.length,10),this.isNumeric(a.start)&&this.isNumeric(a.length)&&0<l-c&&0<l-d?f=!0:(this.log("Ignoring invalid or overlapping range: "+JSON.stringify(a)),this.opt.noMatch(a))):(this.log("Ignoring invalid range: "+JSON.stringify(a)),this.opt.noMatch(a));return{start:d,end:l,valid:f}}},{key:"checkWhitespaceRanges",value:function(a,c,d){var l=!0,f=d.length;c-=f;var b=parseInt(a.start,10)-
|
|
c;b=b>f?f:b;c=b+parseInt(a.length,10);c>f&&(c=f,this.log("End range automatically set to the max value of "+f));0>b||0>c-b||b>f||c>f?(l=!1,this.log("Invalid range: "+JSON.stringify(a)),this.opt.noMatch(a)):""===d.substring(b,c).replace(/\s+/g,"")&&(l=!1,this.log("Skipping whitespace only range: "+JSON.stringify(a)),this.opt.noMatch(a));return{start:b,end:c,valid:l}}},{key:"getTextNodes",value:function(a){var c=this,d="",l=[];this.iterator.forEachNode(NodeFilter.SHOW_TEXT,function(a){l.push({start:d.length,
|
|
end:(d+=a.textContent).length,node:a})},function(a){return c.matchesExclude(a.parentNode)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},function(){a({value:d,nodes:l})})}},{key:"matchesExclude",value:function(a){return m.matches(a,this.opt.exclude.concat(["script","style","title","head","html"]))}},{key:"wrapRangeInTextNode",value:function(a,c,d,l){var f=this.opt.element?this.opt.element:"mark";a=a.splitText(c);c=a.splitText(d-c);f=e.createElement(f);this.opt.dataAttribute&&f.setAttribute("data-markjs",
|
|
"true");this.opt.className&&f.setAttribute("class",this.opt.className);this.opt.counter&&(f.setAttribute("data-cnt",l),f.setAttribute("class",this.opt.className+" mark_counter"));f.textContent=a.textContent;a.parentNode.replaceChild(f,a);return c}},{key:"wrapRangeInMappedTextNode",value:function(a,c,d,l,f){var b=this,e=0;a.nodes.every(function(k,g){var n=a.nodes[g+1];if("undefined"===typeof n||n.start>c){if(!l(k.node))return!1;n=c-k.start;var h=(d>k.end?k.end:d)-k.start,r=a.value.substr(0,k.start),
|
|
u=a.value.substr(h+k.start);e++;k.node=b.wrapRangeInTextNode(k.node,n,h,e);k.node.position=c;a.value=r+u;a.nodes.forEach(function(d,c){c>=g&&(0<a.nodes[c].start&&c!==g&&(a.nodes[c].start-=h),a.nodes[c].end-=h)});d-=h;f(k.node.previousSibling,k.start);if(d>k.end)c=k.end;else return!1}return!0})}},{key:"wrapMatches",value:function(a,c,d,b,f){var l=this,e=0,g=0,h=[];h.push(0);var p=0===c?0:c+1;this.getTextNodes(function(c){c.nodes.forEach(function(c){g=c.start;c=c.node;for(var f=void 0;null!==(f=a.exec(c.textContent))&&
|
|
""!==f[p];)if(d(f[p],c)){var k=f.index;if(0!==p)for(var n=1;n<p;n++)k+=f[n].length;e++;c=l.wrapRangeInTextNode(c,k,k+f[p].length,e);h.push(g+k);b(c.previousSibling);a.lastIndex=0}});f(h)})}},{key:"wrapMatchesAcrossElements",value:function(a,c,d,b,f){var l=this,e=0===c?0:c+1;this.getTextNodes(function(c){for(var k=void 0;null!==(k=a.exec(c.value))&&""!==k[e];){var g=k.index;if(0!==e)for(var h=1;h<e;h++)g+=k[h].length;l.wrapRangeInMappedTextNode(c,g,g+k[e].length,function(a){return d(k[e],a)},function(c,
|
|
d){a.lastIndex=d;b(c)})}f()})}},{key:"wrapRangeFromIndex",value:function(a,c,d,b){var f=this;this.getTextNodes(function(l){var k=l.value.length;a.forEach(function(a,b){var e=f.checkWhitespaceRanges(a,k,l.value),g=e.start,h=e.end;e.valid&&f.wrapRangeInMappedTextNode(l,g,h,function(d){return c(d,a,l.value.substring(g,h),b)},function(c){d(c,a)})});b()})}},{key:"unwrapMatches",value:function(a){for(var c=a.parentNode,d=e.createDocumentFragment();a.firstChild;)d.appendChild(a.removeChild(a.firstChild));
|
|
c.replaceChild(d,a);this.ie?this.normalizeTextNode(c):c.normalize()}},{key:"normalizeTextNode",value:function(a){if(a){if(3===a.nodeType)for(;a.nextSibling&&3===a.nextSibling.nodeType;)a.nodeValue+=a.nextSibling.nodeValue,a.parentNode.removeChild(a.nextSibling);else this.normalizeTextNode(a.firstChild);this.normalizeTextNode(a.nextSibling)}}},{key:"markRegExp",value:function(a,c){var d=this;this.opt=c;this.log('Searching with expression "'+a+'"');var b=0;c="wrapMatches";this.opt.acrossElements&&(c=
|
|
"wrapMatchesAcrossElements");this[c](a,this.opt.ignoreGroups,function(a,c){return d.opt.filter(c,a,b)},function(a){b++;d.opt.each(a)},function(){0===b&&d.opt.noMatch(a);d.opt.done(b)})}},{key:"mark",value:function(a,c){var d=this;this.opt=c;var b=0,f="wrapMatches";a=this.getSeparatedKeywords("string"===typeof a?[a]:a);var k=a.keywords,e=a.length,g=this.opt.caseSensitive?"":"i";a=function p(a){var c=new RegExp(d.createRegExp(a),"gm"+g),l=0;d.log('Searching with expression "'+c+'"');d[f](c,1,function(c,
|
|
f){return d.opt.filter(f,a,b,l)},function(a){l++;b++;d.opt.each(a)},function(c){0===l&&d.opt.noMatch(a);k[e-1]===a?d.opt.done(b,c):p(k[k.indexOf(a)+1])})};this.opt.acrossElements&&(f="wrapMatchesAcrossElements");0===e?this.opt.done(b):a(k[0])}},{key:"markRanges",value:function(a,c){var d=this;this.opt=c;var b=0;(a=this.checkRanges(a))&&a.length?(this.log("Starting to mark with the following ranges: "+JSON.stringify(a)),this.wrapRangeFromIndex(a,function(a,c,b,l){return d.opt.filter(a,c,b,l)},function(a,
|
|
c){b++;d.opt.each(a,c)},function(){d.opt.done(b)})):this.opt.done(b)}},{key:"unmark",value:function(a){var c=this;this.opt=a;var d=this.opt.element?this.opt.element:"*";d+="[data-markjs]";this.opt.className&&(d+="."+this.opt.className);this.log('Removal selector "'+d+'"');this.iterator.forEachNode(NodeFilter.SHOW_ELEMENT,function(a){c.unwrapMatches(a)},function(a){var b=m.matches(a,d);a=c.matchesExclude(a);return!b||a?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},this.opt.done)}},{key:"opt",
|
|
set:function(a){this._opt=_extends({},{element:"",counter:!1,className:"",dataAttribute:!0,exclude:[],iframes:!1,iframesTimeout:5E3,separateWordSearch:!0,diacritics:!0,synonyms:{},accuracy:"partially",acrossElements:!1,caseSensitive:!1,ignoreJoiners:!1,ignoreGroups:0,ignorePunctuation:[],wildcards:"disabled",each:function(){},noMatch:function(){},filter:function(){return!0},done:function(){},debug:!1,log:b.console},a)},get:function(){return this._opt}},{key:"iterator",get:function(){return new m(this.ctx,
|
|
this.opt.iframes,this.opt.exclude,this.opt.iframesTimeout)}}]);return g}(),m=function(){function b(a){var c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:!0,d=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[],l=3<arguments.length&&void 0!==arguments[3]?arguments[3]:5E3;_classCallCheck(this,b);this.ctx=a;this.iframes=c;this.exclude=d;this.iframesTimeout=l}_createClass(b,[{key:"getContexts",value:function(){var a=void 0,c=[];a="undefined"!==typeof this.ctx&&this.ctx?NodeList.prototype.isPrototypeOf(this.ctx)?
|
|
Array.prototype.slice.call(this.ctx):Array.isArray(this.ctx)?this.ctx:"string"===typeof this.ctx?Array.prototype.slice.call(e.querySelectorAll(this.ctx)):[this.ctx]:[];a.forEach(function(a){var d=0<c.filter(function(c){return c.contains(a)}).length;-1!==c.indexOf(a)||d||c.push(a)});return c}},{key:"getIframeContents",value:function(a,c){var d=2<arguments.length&&void 0!==arguments[2]?arguments[2]:function(){},b=void 0;try{var f=a.contentWindow;b=f.document;if(!f||!b)throw Error("iframe inaccessible");
|
|
}catch(k){d()}b&&c(b)}},{key:"isIframeBlank",value:function(a){var c=a.getAttribute("src").trim();return"about:blank"===a.contentWindow.location.href&&"about:blank"!==c&&c}},{key:"observeIframeLoad",value:function(a,c,d){var b=this,f=!1,e=null,g=function r(){if(!f){f=!0;clearTimeout(e);try{b.isIframeBlank(a)||(a.removeEventListener("load",r),b.getIframeContents(a,c,d))}catch(p){d()}}};a.addEventListener("load",g);e=setTimeout(g,this.iframesTimeout)}},{key:"onIframeReady",value:function(a,c,d){try{"complete"===
|
|
a.contentWindow.document.readyState?this.isIframeBlank(a)?this.observeIframeLoad(a,c,d):this.getIframeContents(a,c,d):this.observeIframeLoad(a,c,d)}catch(l){d()}}},{key:"waitForIframes",value:function(a,c){var d=this,b=0;this.forEachIframe(a,function(){return!0},function(a){b++;d.waitForIframes(a.querySelector("html"),function(){--b||c()})},function(a){a||c()})}},{key:"forEachIframe",value:function(a,c,d){var e=this,f=3<arguments.length&&void 0!==arguments[3]?arguments[3]:function(){},k=a.querySelectorAll("iframe"),
|
|
g=k.length,h=0;k=Array.prototype.slice.call(k);var m=function(){0>=--g&&f(h)};g||m();k.forEach(function(a){if(b.matches(a,e.exclude))m();else e.onIframeReady(a,function(b){c(a)&&(h++,d(b));m()},m)})}},{key:"createIterator",value:function(a,c,b){return e.createNodeIterator(a,c,b,!1)}},{key:"createInstanceOnIframe",value:function(a){return new b(a.querySelector("html"),this.iframes)}},{key:"compareNodeIframe",value:function(a,c,b){if(a.compareDocumentPosition(b)&Node.DOCUMENT_POSITION_PRECEDING)if(null!==
|
|
c){if(c.compareDocumentPosition(b)&Node.DOCUMENT_POSITION_FOLLOWING)return!0}else return!0;return!1}},{key:"getIteratorNode",value:function(a){var c=a.previousNode();a=null===c?a.nextNode():a.nextNode()&&a.nextNode();return{prevNode:c,node:a}}},{key:"checkIframeFilter",value:function(a,c,b,e){var d=!1,k=!1;e.forEach(function(a,c){a.val===b&&(d=c,k=a.handled)});if(this.compareNodeIframe(a,c,b))return!1!==d||k?!1===d||k||(e[d].handled=!0):e.push({val:b,handled:!0}),!0;!1===d&&e.push({val:b,handled:!1});
|
|
return!1}},{key:"handleOpenIframes",value:function(a,c,b,e){var d=this;a.forEach(function(a){a.handled||d.getIframeContents(a.val,function(a){d.createInstanceOnIframe(a).forEachNode(c,b,e)})})}},{key:"iterateThroughNodes",value:function(a,c,b,e,f){for(var d=this,g=this.createIterator(c,a,e),l=[],h=[],m=void 0,q=void 0,t=function(){var a=d.getIteratorNode(g);q=a.prevNode;return m=a.node};t();)this.iframes&&this.forEachIframe(c,function(a){return d.checkIframeFilter(m,q,a,l)},function(c){d.createInstanceOnIframe(c).forEachNode(a,
|
|
function(a){return h.push(a)},e)}),h.push(m);h.forEach(function(a){b(a)});this.iframes&&this.handleOpenIframes(l,a,b,e);f()}},{key:"forEachNode",value:function(a,c,b){var d=this,e=3<arguments.length&&void 0!==arguments[3]?arguments[3]:function(){},g=this.getContexts(),h=g.length;h||e();g.forEach(function(f){var g=function(){d.iterateThroughNodes(a,f,c,b,function(){0>=--h&&e()})};d.iframes?d.waitForIframes(f,g):g()})}}],[{key:"matches",value:function(a,c){c="string"===typeof c?[c]:c;var b=a.matches||
|
|
a.matchesSelector||a.msMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.webkitMatchesSelector;if(b){var e=!1;c.every(function(c){return b.call(a,c)?(e=!0,!1):!0});return e}return!1}}]);return b}();g.fn.sq_mark=function(b,a){(new h(this.get())).mark(b,a);return this};g.fn.sq_markRegExp=function(b,a){(new h(this.get())).markRegExp(b,a);return this};g.fn.sq_markRanges=function(b,a){(new h(this.get())).markRanges(b,a);return this};g.fn.sq_unmark=function(b){(new h(this.get())).unmark(b);return this};
|
|
return g},window,document);
|