news.tatooine.club/assets/mark.min.js

2 lines
16 KiB
JavaScript
Raw Normal View History

(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory():typeof define==="function"&&define.amd?define(factory):global.Mark=factory()})(this,function(){"use strict";function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},_typeof(obj)}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,_toPropertyKey(descriptor.key),descriptor)}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor}function _extends(){_extends=Object.assign?Object.assign.bind():function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};return _extends.apply(this,arguments)}function _toPrimitive(input,hint){if(typeof input!=="object"||input===null)return input;var prim=input[Symbol.toPrimitive];if(prim!==undefined){var res=prim.call(input,hint||"default");if(typeof res!=="object")return res;throw new TypeError("@@toPrimitive must return a primitive value.")}return(hint==="string"?String:Number)(input)}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return typeof key==="symbol"?key:String(key)}var DOMIterator=function(){function DOMIterator(ctx){_classCallCheck(this,DOMIterator);this.ctx=ctx}_createClass(DOMIterator,[{key:"getContexts",value:function getContexts(){var ctx,filteredCtx=[];if(typeof this.ctx==="undefined"||!this.ctx){ctx=[]}else if(NodeList.prototype.isPrototypeOf(this.ctx)){ctx=Array.prototype.slice.call(this.ctx)}else if(Array.isArray(this.ctx)){ctx=this.ctx}else if(typeof this.ctx==="string"){ctx=Array.prototype.slice.call(document.querySelectorAll(this.ctx))}else{ctx=[this.ctx]}ctx.forEach(function(ctx){var isDescendant=filteredCtx.filter(function(contexts){return contexts.contains(ctx)}).length>0;if(filteredCtx.indexOf(ctx)===-1&&!isDescendant){filteredCtx.push(ctx)}});return filteredCtx}},{key:"createIterator",value:function createIterator(ctx,whatToShow,filter){return document.createNodeIterator(ctx,whatToShow,filter,false)}},{key:"getIteratorNode",value:function getIteratorNode(itr){var prevNode=itr.previousNode();var node;if(prevNode===null){node=itr.nextNode()}else{node=itr.nextNode()&&itr.nextNode()}return{prevNode:prevNode,node:node}}},{key:"iterateThroughNodes",value:function iterateThroughNodes(whatToShow,ctx,eachCb,filterCb,doneCb){var _this=this;var itr=this.createIterator(ctx,whatToShow,filterCb);var elements=[],node,prevNode,retrieveNodes=function retrieveNodes(){var _this$getIteratorNode=_this.getIteratorNode(itr);prevNode=_this$getIteratorNode.prevNode;node=_this$getIteratorNode.node;return node};while(retrieveNodes()){elements.push(node)}elements.forEach(function(node){eachCb(node)});doneCb()}},{key:"forEachNode",value:function forEachNode(whatToShow,each,filter){var _this2=this;var done=arguments.length>3&&arguments[3]!==undefined?arguments[3]:function(){};var contexts=this.getContexts();var open=contexts.length;if(!open){done()}contexts.forEach(function(ctx){var ready=function ready(){_this2.iterateThroughNodes(whatToShow,ctx,each,filter,function(){if(--open<=0){done()}})};ready()})}}],[{key:"matches",value:function matches(element,selector){var selectors=typeof selector==="string"?[selector]:selector,fn=element.matches||element.matchesSelector||element.msMa