Show More
@@ -52,7 +52,7 b'' | |||||
52 | "<%= dirs.js.src %>/plugins/jquery.auto-grow-input.js", |
|
52 | "<%= dirs.js.src %>/plugins/jquery.auto-grow-input.js", | |
53 | "<%= dirs.js.src %>/plugins/jquery.autocomplete.js", |
|
53 | "<%= dirs.js.src %>/plugins/jquery.autocomplete.js", | |
54 | "<%= dirs.js.src %>/plugins/jquery.debounce.js", |
|
54 | "<%= dirs.js.src %>/plugins/jquery.debounce.js", | |
55 |
"<%= dirs.js. |
|
55 | "<%= dirs.js.node_modules %>/mark.js/dist/jquery.mark.min.js", | |
56 | "<%= dirs.js.src %>/plugins/jquery.timeago.js", |
|
56 | "<%= dirs.js.src %>/plugins/jquery.timeago.js", | |
57 | "<%= dirs.js.src %>/plugins/jquery.timeago-extension.js", |
|
57 | "<%= dirs.js.src %>/plugins/jquery.timeago-extension.js", | |
58 | "<%= dirs.js.src %>/select2/select2.js", |
|
58 | "<%= dirs.js.src %>/select2/select2.js", |
@@ -22,6 +22,7 b'' | |||||
22 | "grunt-contrib-watch": "^0.6.1", |
|
22 | "grunt-contrib-watch": "^0.6.1", | |
23 | "grunt-webpack": "^3.1.3", |
|
23 | "grunt-webpack": "^3.1.3", | |
24 | "jquery": "1.11.3", |
|
24 | "jquery": "1.11.3", | |
|
25 | "mark.js": "8.11.1", | |||
25 | "jshint": "^2.9.1-rc3", |
|
26 | "jshint": "^2.9.1-rc3", | |
26 | "moment": "^2.18.1", |
|
27 | "moment": "^2.18.1", | |
27 | "mousetrap": "^1.6.1", |
|
28 | "mousetrap": "^1.6.1", |
@@ -4676,6 +4676,15 b' let' | |||||
4676 | sha1 = "ecdca8f13144e660f1b5bd41f12f3479d98dfb8f"; |
|
4676 | sha1 = "ecdca8f13144e660f1b5bd41f12f3479d98dfb8f"; | |
4677 | }; |
|
4677 | }; | |
4678 | }; |
|
4678 | }; | |
|
4679 | "mark.js-8.11.1" = { | |||
|
4680 | name = "mark.js"; | |||
|
4681 | packageName = "mark.js"; | |||
|
4682 | version = "8.11.1"; | |||
|
4683 | src = fetchurl { | |||
|
4684 | url = "https://registry.npmjs.org/mark.js/-/mark.js-8.11.1.tgz"; | |||
|
4685 | sha1 = "180f1f9ebef8b0e638e4166ad52db879beb2ffc5"; | |||
|
4686 | }; | |||
|
4687 | }; | |||
4679 | "math-expression-evaluator-1.2.17" = { |
|
4688 | "math-expression-evaluator-1.2.17" = { | |
4680 | name = "math-expression-evaluator"; |
|
4689 | name = "math-expression-evaluator"; | |
4681 | packageName = "math-expression-evaluator"; |
|
4690 | packageName = "math-expression-evaluator"; | |
@@ -8510,6 +8519,7 b' let' | |||||
8510 | sources."map-age-cleaner-0.1.3" |
|
8519 | sources."map-age-cleaner-0.1.3" | |
8511 | sources."map-cache-0.2.2" |
|
8520 | sources."map-cache-0.2.2" | |
8512 | sources."map-visit-1.0.0" |
|
8521 | sources."map-visit-1.0.0" | |
|
8522 | sources."mark.js-8.11.1" | |||
8513 | sources."math-expression-evaluator-1.2.17" |
|
8523 | sources."math-expression-evaluator-1.2.17" | |
8514 | sources."md5.js-1.3.5" |
|
8524 | sources."md5.js-1.3.5" | |
8515 | sources."mem-4.0.0" |
|
8525 | sources."mem-4.0.0" |
@@ -1,490 +0,0 b'' | |||||
1 | /*!*************************************************** |
|
|||
2 | * mark.js v6.1.0 |
|
|||
3 | * https://github.com/julmot/mark.js |
|
|||
4 | * Copyright (c) 2014–2016, Julian Motz |
|
|||
5 | * Released under the MIT license https://git.io/vwTVl |
|
|||
6 | *****************************************************/ |
|
|||
7 |
|
||||
8 | "use strict"; |
|
|||
9 |
|
||||
10 | var _extends = Object.assign || 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; }; |
|
|||
11 |
|
||||
12 | var _createClass = 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
|
|||
13 |
|
||||
14 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; |
|
|||
15 |
|
||||
16 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
|
|||
17 |
|
||||
18 | (function (factory, window, document) { |
|
|||
19 | if (typeof define === "function" && define.amd) { |
|
|||
20 | define(["jquery"], function (jQuery) { |
|
|||
21 | return factory(window, document, jQuery); |
|
|||
22 | }); |
|
|||
23 | } else if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) === "object") { |
|
|||
24 | factory(window, document, require("jquery")); |
|
|||
25 | } else { |
|
|||
26 | factory(window, document, jQuery); |
|
|||
27 | } |
|
|||
28 | })(function (window, document, $) { |
|
|||
29 | var Mark = function () { |
|
|||
30 | function Mark(ctx) { |
|
|||
31 | _classCallCheck(this, Mark); |
|
|||
32 |
|
||||
33 | this.ctx = ctx; |
|
|||
34 | } |
|
|||
35 |
|
||||
36 | _createClass(Mark, [{ |
|
|||
37 | key: "log", |
|
|||
38 | value: function log(msg) { |
|
|||
39 | var level = arguments.length <= 1 || arguments[1] === undefined ? "debug" : arguments[1]; |
|
|||
40 |
|
||||
41 | var log = this.opt.log; |
|
|||
42 | if (!this.opt.debug) { |
|
|||
43 | return; |
|
|||
44 | } |
|
|||
45 | if ((typeof log === "undefined" ? "undefined" : _typeof(log)) === "object" && typeof log[level] === "function") { |
|
|||
46 | log[level]("mark.js: " + msg); |
|
|||
47 | } |
|
|||
48 | } |
|
|||
49 | }, { |
|
|||
50 | key: "escapeStr", |
|
|||
51 | value: function escapeStr(str) { |
|
|||
52 | return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); |
|
|||
53 | } |
|
|||
54 | }, { |
|
|||
55 | key: "createRegExp", |
|
|||
56 | value: function createRegExp(str) { |
|
|||
57 | str = this.escapeStr(str); |
|
|||
58 | if (Object.keys(this.opt.synonyms).length) { |
|
|||
59 | str = this.createSynonymsRegExp(str); |
|
|||
60 | } |
|
|||
61 | if (this.opt.diacritics) { |
|
|||
62 | str = this.createDiacriticsRegExp(str); |
|
|||
63 | } |
|
|||
64 | str = this.createAccuracyRegExp(str); |
|
|||
65 | return str; |
|
|||
66 | } |
|
|||
67 | }, { |
|
|||
68 | key: "createSynonymsRegExp", |
|
|||
69 | value: function createSynonymsRegExp(str) { |
|
|||
70 | var syn = this.opt.synonyms; |
|
|||
71 | for (var index in syn) { |
|
|||
72 | if (syn.hasOwnProperty(index)) { |
|
|||
73 | var value = syn[index], |
|
|||
74 | k1 = this.escapeStr(index), |
|
|||
75 | k2 = this.escapeStr(value); |
|
|||
76 | str = str.replace(new RegExp("(" + k1 + "|" + k2 + ")", "gmi"), "(" + k1 + "|" + k2 + ")"); |
|
|||
77 | } |
|
|||
78 | } |
|
|||
79 | return str; |
|
|||
80 | } |
|
|||
81 | }, { |
|
|||
82 | key: "createDiacriticsRegExp", |
|
|||
83 | value: function createDiacriticsRegExp(str) { |
|
|||
84 | var dct = ["aÀÁÂÃÄÅàáâãäåĀāąĄ", "cÇçćĆčČ", "dđĐďĎ", "eÈÉÊËèéêëěĚĒēęĘ", "iÌÍÎÏìíîïĪī", "lłŁ", "nÑñňŇńŃ", "oÒÓÔÕÕÖØòóôõöøŌō", "rřŘ", "sŠšśŚ", "tťŤ", "uÙÚÛÜùúûüůŮŪū", "yŸÿýÝ", "zŽžżŻźŹ"]; |
|
|||
85 | var handled = []; |
|
|||
86 | str.split("").forEach(function (ch) { |
|
|||
87 | dct.every(function (dct) { |
|
|||
88 | if (dct.indexOf(ch) !== -1) { |
|
|||
89 | if (handled.indexOf(dct) > -1) { |
|
|||
90 | return false; |
|
|||
91 | } |
|
|||
92 |
|
||||
93 | str = str.replace(new RegExp("[" + dct + "]", "gmi"), "[" + dct + "]"); |
|
|||
94 | handled.push(dct); |
|
|||
95 | } |
|
|||
96 | return true; |
|
|||
97 | }); |
|
|||
98 | }); |
|
|||
99 | return str; |
|
|||
100 | } |
|
|||
101 | }, { |
|
|||
102 | key: "createAccuracyRegExp", |
|
|||
103 | value: function createAccuracyRegExp(str) { |
|
|||
104 | switch (this.opt.accuracy) { |
|
|||
105 | case "partially": |
|
|||
106 | return "()(" + str + ")"; |
|
|||
107 | case "complementary": |
|
|||
108 | return "()(\\S*" + str + "\\S*)"; |
|
|||
109 | case "exactly": |
|
|||
110 | return "(^|\\s)(" + str + ")(?=\\s|$)"; |
|
|||
111 | } |
|
|||
112 | } |
|
|||
113 | }, { |
|
|||
114 | key: "getSeparatedKeywords", |
|
|||
115 | value: function getSeparatedKeywords(sv) { |
|
|||
116 | var _this = this; |
|
|||
117 |
|
||||
118 | var stack = []; |
|
|||
119 | sv.forEach(function (kw) { |
|
|||
120 | if (!_this.opt.separateWordSearch) { |
|
|||
121 | if (kw.trim()) { |
|
|||
122 | stack.push(kw); |
|
|||
123 | } |
|
|||
124 | } else { |
|
|||
125 | kw.split(" ").forEach(function (kwSplitted) { |
|
|||
126 | if (kwSplitted.trim()) { |
|
|||
127 | stack.push(kwSplitted); |
|
|||
128 | } |
|
|||
129 | }); |
|
|||
130 | } |
|
|||
131 | }); |
|
|||
132 | return { |
|
|||
133 | "keywords": stack, |
|
|||
134 | "length": stack.length |
|
|||
135 | }; |
|
|||
136 | } |
|
|||
137 | }, { |
|
|||
138 | key: "getElements", |
|
|||
139 | value: function getElements() { |
|
|||
140 | var ctx = void 0, |
|
|||
141 | stack = []; |
|
|||
142 | if (typeof this.ctx === "undefined") { |
|
|||
143 | ctx = []; |
|
|||
144 | } else if (this.ctx instanceof HTMLElement) { |
|
|||
145 | ctx = [this.ctx]; |
|
|||
146 | } else if (Array.isArray(this.ctx)) { |
|
|||
147 | ctx = this.ctx; |
|
|||
148 | } else { |
|
|||
149 | ctx = Array.prototype.slice.call(this.ctx); |
|
|||
150 | } |
|
|||
151 | ctx.forEach(function (ctx) { |
|
|||
152 | stack.push(ctx); |
|
|||
153 | var childs = ctx.querySelectorAll("*"); |
|
|||
154 | if (childs.length) { |
|
|||
155 | stack = stack.concat(Array.prototype.slice.call(childs)); |
|
|||
156 | } |
|
|||
157 | }); |
|
|||
158 | if (!ctx.length) { |
|
|||
159 | this.log("Empty context", "warn"); |
|
|||
160 | } |
|
|||
161 | return { |
|
|||
162 | "elements": stack, |
|
|||
163 | "length": stack.length |
|
|||
164 | }; |
|
|||
165 | } |
|
|||
166 | }, { |
|
|||
167 | key: "matches", |
|
|||
168 | value: function matches(el, selector) { |
|
|||
169 | return (el.matches || el.matchesSelector || el.msMatchesSelector || el.mozMatchesSelector || el.webkitMatchesSelector || el.oMatchesSelector).call(el, selector); |
|
|||
170 | } |
|
|||
171 | }, { |
|
|||
172 | key: "matchesFilter", |
|
|||
173 | value: function matchesFilter(el, exclM) { |
|
|||
174 | var _this2 = this; |
|
|||
175 |
|
||||
176 | var remain = true; |
|
|||
177 | var fltr = this.opt.filter.concat(["script", "style", "title"]); |
|
|||
178 | if (!this.opt.iframes) { |
|
|||
179 | fltr = fltr.concat(["iframe"]); |
|
|||
180 | } |
|
|||
181 | if (exclM) { |
|
|||
182 | fltr = fltr.concat(["*[data-markjs='true']"]); |
|
|||
183 | } |
|
|||
184 | fltr.every(function (filter) { |
|
|||
185 | if (_this2.matches(el, filter)) { |
|
|||
186 | return remain = false; |
|
|||
187 | } |
|
|||
188 | return true; |
|
|||
189 | }); |
|
|||
190 | return !remain; |
|
|||
191 | } |
|
|||
192 | }, { |
|
|||
193 | key: "onIframeReady", |
|
|||
194 | value: function onIframeReady(ifr, successFn, errorFn) { |
|
|||
195 | try { |
|
|||
196 | (function () { |
|
|||
197 | var ifrWin = ifr.contentWindow, |
|
|||
198 | bl = "about:blank", |
|
|||
199 | compl = "complete"; |
|
|||
200 | var callCallback = function callCallback() { |
|
|||
201 | try { |
|
|||
202 | if (ifrWin.document === null) { |
|
|||
203 | throw new Error("iframe inaccessible"); |
|
|||
204 | } |
|
|||
205 | successFn(ifrWin.document); |
|
|||
206 | } catch (e) { |
|
|||
207 | errorFn(); |
|
|||
208 | } |
|
|||
209 | }; |
|
|||
210 | var isBlank = function isBlank() { |
|
|||
211 | var src = ifr.getAttribute("src").trim(), |
|
|||
212 | href = ifrWin.location.href; |
|
|||
213 | return href === bl && src !== bl && src; |
|
|||
214 | }; |
|
|||
215 | var observeOnload = function observeOnload() { |
|
|||
216 | var listener = function listener() { |
|
|||
217 | try { |
|
|||
218 | if (!isBlank()) { |
|
|||
219 | ifr.removeEventListener("load", listener); |
|
|||
220 | callCallback(); |
|
|||
221 | } |
|
|||
222 | } catch (e) { |
|
|||
223 | errorFn(); |
|
|||
224 | } |
|
|||
225 | }; |
|
|||
226 | ifr.addEventListener("load", listener); |
|
|||
227 | }; |
|
|||
228 | if (ifrWin.document.readyState === compl) { |
|
|||
229 | if (isBlank()) { |
|
|||
230 | observeOnload(); |
|
|||
231 | } else { |
|
|||
232 | callCallback(); |
|
|||
233 | } |
|
|||
234 | } else { |
|
|||
235 | observeOnload(); |
|
|||
236 | } |
|
|||
237 | })(); |
|
|||
238 | } catch (e) { |
|
|||
239 | errorFn(); |
|
|||
240 | } |
|
|||
241 | } |
|
|||
242 | }, { |
|
|||
243 | key: "forEachElementInIframe", |
|
|||
244 | value: function forEachElementInIframe(ifr, cb) { |
|
|||
245 | var _this3 = this; |
|
|||
246 |
|
||||
247 | var end = arguments.length <= 2 || arguments[2] === undefined ? function () {} : arguments[2]; |
|
|||
248 |
|
||||
249 | var open = 0; |
|
|||
250 | var checkEnd = function checkEnd() { |
|
|||
251 | if (--open < 1) { |
|
|||
252 | end(); |
|
|||
253 | } |
|
|||
254 | }; |
|
|||
255 | this.onIframeReady(ifr, function (con) { |
|
|||
256 | var stack = Array.prototype.slice.call(con.querySelectorAll("*")); |
|
|||
257 | if ((open = stack.length) === 0) { |
|
|||
258 | checkEnd(); |
|
|||
259 | } |
|
|||
260 | stack.forEach(function (el) { |
|
|||
261 | if (el.tagName.toLowerCase() === "iframe") { |
|
|||
262 | (function () { |
|
|||
263 | var j = 0; |
|
|||
264 | _this3.forEachElementInIframe(el, function (iel, len) { |
|
|||
265 | cb(iel, len); |
|
|||
266 | if (len - 1 === j) { |
|
|||
267 | checkEnd(); |
|
|||
268 | } |
|
|||
269 | j++; |
|
|||
270 | }, checkEnd); |
|
|||
271 | })(); |
|
|||
272 | } else { |
|
|||
273 | cb(el, stack.length); |
|
|||
274 | checkEnd(); |
|
|||
275 | } |
|
|||
276 | }); |
|
|||
277 | }, function () { |
|
|||
278 | var src = ifr.getAttribute("src"); |
|
|||
279 | _this3.log("iframe '" + src + "' could not be accessed", "warn"); |
|
|||
280 | checkEnd(); |
|
|||
281 | }); |
|
|||
282 | } |
|
|||
283 | }, { |
|
|||
284 | key: "forEachElement", |
|
|||
285 | value: function forEachElement(cb) { |
|
|||
286 | var _this4 = this; |
|
|||
287 |
|
||||
288 | var end = arguments.length <= 1 || arguments[1] === undefined ? function () {} : arguments[1]; |
|
|||
289 | var exclM = arguments.length <= 2 || arguments[2] === undefined ? true : arguments[2]; |
|
|||
290 |
|
||||
291 | var _getElements = this.getElements(); |
|
|||
292 |
|
||||
293 | var stack = _getElements.elements; |
|
|||
294 | var open = _getElements.length; |
|
|||
295 |
|
||||
296 | var checkEnd = function checkEnd() { |
|
|||
297 | if (--open === 0) { |
|
|||
298 | end(); |
|
|||
299 | } |
|
|||
300 | }; |
|
|||
301 | checkEnd(++open); |
|
|||
302 | stack.forEach(function (el) { |
|
|||
303 | if (!_this4.matchesFilter(el, exclM)) { |
|
|||
304 | if (el.tagName.toLowerCase() === "iframe") { |
|
|||
305 | _this4.forEachElementInIframe(el, function (iel) { |
|
|||
306 | if (!_this4.matchesFilter(iel, exclM)) { |
|
|||
307 | cb(iel); |
|
|||
308 | } |
|
|||
309 | }, checkEnd); |
|
|||
310 | return; |
|
|||
311 | } else { |
|
|||
312 | cb(el); |
|
|||
313 | } |
|
|||
314 | } |
|
|||
315 | checkEnd(); |
|
|||
316 | }); |
|
|||
317 | } |
|
|||
318 | }, { |
|
|||
319 | key: "forEachNode", |
|
|||
320 | value: function forEachNode(cb) { |
|
|||
321 | var end = arguments.length <= 1 || arguments[1] === undefined ? function () {} : arguments[1]; |
|
|||
322 |
|
||||
323 | this.forEachElement(function (n) { |
|
|||
324 | for (n = n.firstChild; n; n = n.nextSibling) { |
|
|||
325 | if (n.nodeType === 3 && n.textContent.trim()) { |
|
|||
326 | cb(n); |
|
|||
327 | } |
|
|||
328 | } |
|
|||
329 | }, end); |
|
|||
330 | } |
|
|||
331 | }, { |
|
|||
332 | key: "wrapMatches", |
|
|||
333 | value: function wrapMatches(node, regex, custom, cb) { |
|
|||
334 | var hEl = !this.opt.element ? "mark" : this.opt.element, |
|
|||
335 | index = custom ? 0 : 2; |
|
|||
336 | var match = void 0; |
|
|||
337 | while ((match = regex.exec(node.textContent)) !== null) { |
|
|||
338 | var pos = match.index; |
|
|||
339 | if (!custom) { |
|
|||
340 | pos += match[index - 1].length; |
|
|||
341 | } |
|
|||
342 | var startNode = node.splitText(pos); |
|
|||
343 |
|
||||
344 | node = startNode.splitText(match[index].length); |
|
|||
345 | if (startNode.parentNode !== null) { |
|
|||
346 | var repl = document.createElement(hEl); |
|
|||
347 | repl.setAttribute("data-markjs", "true"); |
|
|||
348 | if (this.opt.className) { |
|
|||
349 | repl.setAttribute("class", this.opt.className); |
|
|||
350 | } |
|
|||
351 | repl.textContent = match[index]; |
|
|||
352 | startNode.parentNode.replaceChild(repl, startNode); |
|
|||
353 | cb(repl); |
|
|||
354 | } |
|
|||
355 | regex.lastIndex = 0; |
|
|||
356 | } |
|
|||
357 | } |
|
|||
358 | }, { |
|
|||
359 | key: "unwrapMatches", |
|
|||
360 | value: function unwrapMatches(node) { |
|
|||
361 | var parent = node.parentNode; |
|
|||
362 | var docFrag = document.createDocumentFragment(); |
|
|||
363 | while (node.firstChild) { |
|
|||
364 | docFrag.appendChild(node.removeChild(node.firstChild)); |
|
|||
365 | } |
|
|||
366 | parent.replaceChild(docFrag, node); |
|
|||
367 | parent.normalize(); |
|
|||
368 | } |
|
|||
369 | }, { |
|
|||
370 | key: "markRegExp", |
|
|||
371 | value: function markRegExp(regexp, opt) { |
|
|||
372 | var _this5 = this; |
|
|||
373 |
|
||||
374 | this.opt = opt; |
|
|||
375 | this.log("Searching with expression \"" + regexp + "\""); |
|
|||
376 | var found = false; |
|
|||
377 | var eachCb = function eachCb(element) { |
|
|||
378 | found = true; |
|
|||
379 | _this5.opt.each(element); |
|
|||
380 | }; |
|
|||
381 | this.forEachNode(function (node) { |
|
|||
382 | _this5.wrapMatches(node, regexp, true, eachCb); |
|
|||
383 | }, function () { |
|
|||
384 | if (!found) { |
|
|||
385 | _this5.opt.noMatch(regexp); |
|
|||
386 | } |
|
|||
387 | _this5.opt.complete(); |
|
|||
388 | _this5.opt.done(); |
|
|||
389 | }); |
|
|||
390 | } |
|
|||
391 | }, { |
|
|||
392 | key: "mark", |
|
|||
393 | value: function mark(sv, opt) { |
|
|||
394 | var _this6 = this; |
|
|||
395 |
|
||||
396 | this.opt = opt; |
|
|||
397 | sv = typeof sv === "string" ? [sv] : sv; |
|
|||
398 |
|
||||
399 | var _getSeparatedKeywords = this.getSeparatedKeywords(sv); |
|
|||
400 |
|
||||
401 | var kwArr = _getSeparatedKeywords.keywords; |
|
|||
402 | var kwArrLen = _getSeparatedKeywords.length; |
|
|||
403 |
|
||||
404 | if (kwArrLen === 0) { |
|
|||
405 | this.opt.complete(); |
|
|||
406 | this.opt.done(); |
|
|||
407 | } |
|
|||
408 | kwArr.forEach(function (kw) { |
|
|||
409 | var regex = new RegExp(_this6.createRegExp(kw), "gmi"), |
|
|||
410 | found = false; |
|
|||
411 | var eachCb = function eachCb(element) { |
|
|||
412 | found = true; |
|
|||
413 | _this6.opt.each(element); |
|
|||
414 | }; |
|
|||
415 | _this6.log("Searching with expression \"" + regex + "\""); |
|
|||
416 | _this6.forEachNode(function (node) { |
|
|||
417 | _this6.wrapMatches(node, regex, false, eachCb); |
|
|||
418 | }, function () { |
|
|||
419 | if (!found) { |
|
|||
420 | _this6.opt.noMatch(kw); |
|
|||
421 | } |
|
|||
422 | if (kwArr[kwArrLen - 1] === kw) { |
|
|||
423 | _this6.opt.complete(); |
|
|||
424 | _this6.opt.done(); |
|
|||
425 | } |
|
|||
426 | }); |
|
|||
427 | }); |
|
|||
428 | } |
|
|||
429 | }, { |
|
|||
430 | key: "unmark", |
|
|||
431 | value: function unmark(opt) { |
|
|||
432 | var _this7 = this; |
|
|||
433 |
|
||||
434 | this.opt = opt; |
|
|||
435 | var sel = this.opt.element ? this.opt.element : "*"; |
|
|||
436 | sel += "[data-markjs]"; |
|
|||
437 | if (this.opt.className) { |
|
|||
438 | sel += "." + this.opt.className; |
|
|||
439 | } |
|
|||
440 | this.log("Removal selector \"" + sel + "\""); |
|
|||
441 | this.forEachElement(function (el) { |
|
|||
442 | if (_this7.matches(el, sel)) { |
|
|||
443 | _this7.unwrapMatches(el); |
|
|||
444 | } |
|
|||
445 | }, function () { |
|
|||
446 | _this7.opt.complete(); |
|
|||
447 | _this7.opt.done(); |
|
|||
448 | }, false); |
|
|||
449 | } |
|
|||
450 | }, { |
|
|||
451 | key: "opt", |
|
|||
452 | set: function set(val) { |
|
|||
453 | this._opt = _extends({}, { |
|
|||
454 | "element": "", |
|
|||
455 | "className": "", |
|
|||
456 | "filter": [], |
|
|||
457 | "iframes": false, |
|
|||
458 | "separateWordSearch": true, |
|
|||
459 | "diacritics": true, |
|
|||
460 | "synonyms": {}, |
|
|||
461 | "accuracy": "partially", |
|
|||
462 | "each": function each() {}, |
|
|||
463 | "noMatch": function noMatch() {}, |
|
|||
464 | "done": function done() {}, |
|
|||
465 | "complete": function complete() {}, |
|
|||
466 | "debug": false, |
|
|||
467 | "log": window.console |
|
|||
468 | }, val); |
|
|||
469 | }, |
|
|||
470 | get: function get() { |
|
|||
471 | return this._opt; |
|
|||
472 | } |
|
|||
473 | }]); |
|
|||
474 |
|
||||
475 | return Mark; |
|
|||
476 | }(); |
|
|||
477 |
|
||||
478 | $.fn.mark = function (sv, opt) { |
|
|||
479 | new Mark(this).mark(sv, opt); |
|
|||
480 | return this; |
|
|||
481 | }; |
|
|||
482 | $.fn.markRegExp = function (regexp, opt) { |
|
|||
483 | new Mark(this).markRegExp(regexp, opt); |
|
|||
484 | return this; |
|
|||
485 | }; |
|
|||
486 | $.fn.unmark = function (opt) { |
|
|||
487 | new Mark(this).unmark(opt); |
|
|||
488 | return this; |
|
|||
489 | }; |
|
|||
490 | }, window, document); |
|
General Comments 0
You need to be logged in to leave comments.
Login now