Current Directory: /home/astoriaah/www/old15/media/editors/codemirror/addon/search
Viewing File: /home/astoriaah/www/old15/media/editors/codemirror/addon/search/matchesonscrollbar.min.js
!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror"),require("./searchcursor"),require("../scroll/annotatescrollbar")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./searchcursor","../scroll/annotatescrollbar"],t):t(CodeMirror)}(function(t){"use strict";function e(t,e,i,o){this.cm=t;var a={listenForChanges:!1};for(var r in o)a[r]=o[r];a.className||(a.className="CodeMirror-search-match"),this.annotation=t.annotateScrollbar(a),this.query=e,this.caseFold=i,this.gap={from:t.firstLine(),to:t.lastLine()+1},this.matches=[],this.update=null,this.findMatches(),this.annotation.update(this.matches);var n=this;t.on("change",this.changeHandler=function(t,e){n.onChange(e)})}function i(t,e,i){return e>=t?t:Math.max(e,t+i)}t.defineExtension("showMatchesOnScrollbar",function(t,i,o){return"string"==typeof o&&(o={className:o}),o||(o={}),new e(this,t,i,o)});var o=1e3;e.prototype.findMatches=function(){if(this.gap){for(var e=0;e<this.matches.length;e++){var i=this.matches[e];if(i.from.line>=this.gap.to)break;i.to.line>=this.gap.from&&this.matches.splice(e--,1)}for(var a=this.cm.getSearchCursor(this.query,t.Pos(this.gap.from,0),this.caseFold);a.findNext();){var i={from:a.from(),to:a.to()};if(i.from.line>=this.gap.to)break;if(this.matches.splice(e++,0,i),this.matches.length>o)break}this.gap=null}},e.prototype.onChange=function(e){var o=e.from.line,a=t.changeEnd(e).line,r=a-e.to.line;if(this.gap?(this.gap.from=Math.min(i(this.gap.from,o,r),e.from.line),this.gap.to=Math.max(i(this.gap.to,o,r),e.from.line)):this.gap={from:e.from.line,to:a+1},r)for(var n=0;n<this.matches.length;n++){var s=this.matches[n],h=i(s.from.line,o,r);h!=s.from.line&&(s.from=t.Pos(h,s.from.ch));var c=i(s.to.line,o,r);c!=s.to.line&&(s.to=t.Pos(c,s.to.ch))}clearTimeout(this.update);var f=this;this.update=setTimeout(function(){f.updateAfterChange()},250)},e.prototype.updateAfterChange=function(){this.findMatches(),this.annotation.update(this.matches)},e.prototype.clear=function(){this.cm.off("change",this.changeHandler),this.annotation.clear()}});