UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

1 lines 3.41 kB
module.exports=function(r){var n={};function s(t){if(n[t])return n[t].exports;var e=n[t]={exports:{},id:t,loaded:!1};return r[t].call(e.exports,e,e.exports,s),e.loaded=!0,e.exports}return s.m=r,s.c=n,s.p="",s(0)}({0:function(t,e,r){t.exports=r(1679)},3:function(t,e){t.exports=function(){throw Error("define cannot be used indirect")}},20:function(t,e){t.exports=require("../kendo.core")},1679:function(t,e,r){var n;r(3),r=[r(20)],void 0===(e="function"==typeof(n=function(){var a=window.kendo.jQuery,t=void 0,e=kendo.Class,r=a.extend,n=Array.isArray,s=e.extend({init:function(t){var e=this;e.options=r({},e.options,t);e.processDom()},options:{highlightClass:"k-search-highlight",charClass:"k-text-char"},processDom:function(){var e=this;e.targets=n(e.options.target)?e.options.target:[e.options.target];e.textNodes=[];e.charIndex=0;e.text="";e.targets.forEach(function(t){e.traverseToTextNode(t)});for(var t=0;t<e.textNodes.length;t++)e.processTextNode(e.textNodes[t])},traverseToTextNode:function(t){var e=this;if(t.nodeType===3)e.textNodes.push(t);else for(var r=0;r<t.childNodes.length;r++)e.traverseToTextNode(t.childNodes[r])},processTextNode:function(t){var e=this;var r=t.textContent;var n;e.text=e.text+r;if(r.length>0){n=a(t).wrap("<span>").parent();n.empty();e.splitChars(n.get(0),r);n.children().unwrap()}},splitChars:function(t,e){var r=this;var n="";for(var s=0;s<e.length;s++){n=n+"<span class='"+r.options.charClass+"' "+kendo.attr("char-index")+"="+r.charIndex+">"+e[s]+"</span>";r.charIndex++}t.innerHTML=n},search:function(t,e){var r=this;var n=new RegExp(t,!e?"gi":"g");var s;r.matches=[];r.resetMark();r.resetHighlight();r.resetMatchIndex();if(t==="")return;s=n.exec(r.text);while(s){r.matches.push({startOffset:s.index,endOffset:s.index+s[0].length});s=n.exec(r.text)}r.highlightAll();r.mark()},highlightAll:function(){var s=this;s.matches.forEach(function(t,e){var r=t.startOffset;var n=t.endOffset;s.highlight(r,n,e+1)})},highlight:function(t,e,r){var n=this;for(var s=t;s<e;s++)a(n.targets).find("."+n.options.charClass+"["+kendo.attr("char-index")+"="+s+"]").addClass(n.options.highlightClass).attr(kendo.attr("match-index"),r)},resetHighlight:function(){var t=this;a(t.targets).find("."+t.options.highlightClass).removeClass(t.options.highlightClass)},resetMatchIndex:function(){var t=this;a(t.targets).find("."+t.options.charClass+"["+kendo.attr("match-index")+"]").removeAttr(kendo.attr("match-index"))},mark:function(){var t=this;if(!t.currentIndex&&t.currentIndex!==0)t.currentIndex=0;else if(t.currentIndex>t.matches.length)t.currentIndex=t.matches.length;else t.resetMark();a(t.targets).find("."+t.options.charClass+"["+kendo.attr("match-index")+"="+t.currentIndex+"]").wrapInner("<mark>")},resetMark:function(){var t=this;a(t.targets).find("mark").contents().unwrap()},nextMatch:function(){var t=this;t.currentIndex++;if(t.currentIndex>t.matches.length)t.currentIndex=1;t.mark()},previousMatch:function(){var t=this;t.currentIndex--;if(t.currentIndex<1)t.currentIndex=t.matches.length;t.mark()},getMarkedIndex:function(){return this.matches.length?this.currentIndex:0},getFirstMarked:function(){return a(this.targets).find("mark").eq(0)},destroy:function(){var t=this;t.resetMark();a(t.targets).children("span:not(."+t.options.charClass+")").each(function(t,e){a(e).text(a(e).text())})}});return r(kendo.pdfviewer,{SearchDOM:s}),window.kendo})?n.apply(e,r):n)||(t.exports=e)}});