1(function(expose){ 2 var helpers = { 3 fragment: function(){ 4 if(!this._fragment){ 5 this._fragment = document.createElement('div'); 6 this._fragment.style.visibility = 'hidden'; 7 this._fragment.style.position = 'absolute'; 8 this._fragment.style.width = '1px'; 9 this._fragment.style.height = '1px'; 10 document.body.appendChild(this._fragment); 11 } 12 return this._fragment; 13 }, 14 _isBlockCache:{}, 15 isBlockLevel:function(node){ 16 if(!node || node.nodeType === 3){ 17 return false; 18 } 19 var name = node.nodeName; 20 if(typeof this._isBlockCache[name] !== 'undefined'){ 21 return this._isBlockCache[name]; 22 } 23 var test = document.createElement(name); 24 this.fragment().appendChild(test); 25 this._isBlockCache[name] = getComputedStyle(test).display === 'block'; 26 this.fragment().removeChild(test); 27 return this._isBlockCache[name]; 28 }, 29 _isInlineCache:{}, 30 isInlineLevel:function(node){ 31 if(node.nodeType === 3){ 32 return false; 33 } 34 var name = node.nodeName; 35 if(typeof this._isInlineCache[name] !== 'undefined'){ 36 return this._isInlineCache[name]; 37 } 38 var test = document.createElement(name); 39 this.fragment().appendChild(test); 40 this._isInlineCache[name] = getComputedStyle(test).display === 'inline' && node.nodeName !== 'BR'; 41 this.fragment().removeChild(test); 42 return this._isInlineCache[name]; 43 }, 44 elementOptions: function(el) { 45 var opt = ( el.dataset.options || '').trim().split(','), final = {}; 46 if(!opt[0]) return final; 47 $.each(opt, function(){ 48 var arr = this.split(':'); 49 var val = arr[1].trim(); 50 if(!val){ 51 52 } 53 else if(val === 'true' || val === 'false'){ 54 val = val === 'true'; 55 } 56 else if(!/\D/.test(val)){ 57 val = parseInt(val, 10); 58 } 59 final[arr[0].trim()] = val; 60 }); 61 return final; 62 }, 63 createAutoHeight: function() { 64 if(window.thismodal && thismodal.iframe) { 65 mw.tools.iframeAutoHeight(thismodal.iframe, 'now'); 66 } 67 else if(mw.top().win.frameElement && mw.top().win.frameElement.contentWindow === window) { 68 mw.tools.iframeAutoHeight(mw.top().win.frameElement, 'now'); 69 } else if(window.top !== window) { 70 mw.top().$('iframe').each(function(){ 71 try{ 72 if(this.contentWindow === window) { 73 mw.tools.iframeAutoHeight(this, 'now'); 74 } 75 } catch(e){} 76 }) 77 } 78 }, 79 collision: function(el1, el2){ 80 if(!el1 || !el2) return; 81 el1 = mw.$(el1); 82 el2 = mw.$(el2); 83 var o1 = el1.offset(); 84 var o2 = el2.offset(); 85 o1.width = el1.width(); 86 o1.height = el1.height(); 87 o2.width = el2.width(); 88 o2.height = el2.height(); 89 return (o1.left < o2.left + o2.width && o1.left + o1.width > o2.left && o1.top < o2.top + o2.height && o1.top + o1.height > o2.top); 90 }, 91 distance: function (x1, y1, x2, y2) { 92 var a = x1 - x2; 93 var b = y1 - y2; 94 return Math.floor(Math.sqrt(a * a + b * b)); 95 }, 96 copy: function (value) { 97 var tempInput = document.createElement("input"); 98 tempInput.style = "position: absolute; left: -1000px; top: -1000px"; 99 tempInput.value = value; 100 document.body.appendChild(tempInput); 101 tempInput.select(); 102 document.execCommand("copy"); 103 document.body.removeChild(tempInput); 104 mw.notification.success(mw.lang('Copied') + ': "' + value + '"'); 105 }, 106 cloneObject: function (object) { 107 return jQuery.extend(true, {}, object); 108 }, 109 constructions: function () { 110 mw.$(".mw-image-holder").each(function () { 111 var img = this.querySelector('img'); 112 if (img && img.src) { 113 mw.$(this).css('backgroundImage', 'url(' + img.src + ')'); 114 } 115 }); 116 }, 117 isRtl: function (el) { 118 //todo 119 el = el || document.documentElement; 120 return document.documentElement.dir === 'rtl'; 121 }, 122 isEditable: function (item) { 123 var el = item; 124 if (!!item.type && !!item.target) { 125 el = item.target; 126 } 127 return mw.tools.parentsOrCurrentOrderMatchOrOnlyFirst(el, ['edit', 'module']); 128 }, 129 eachIframe: function (callback, root, ignore) { 130 root = root || document; 131 var scope = this; 132 ignore = ignore || []; 133 var all = root.querySelectorAll('iframe'), i = 0; 134 for (; i < all.length; i++) { 135 if (mw.tools.canAccessIFrame(all[i]) && ignore.indexOf(all[i]) === -1) { 136 callback.call(all[i].contentWindow, all[i].contentWindow); 137 scope.eachIframe(callback, all[i].contentWindow.document); 138 } 139 } 140 }, 141 eachWindow: function (callback, options) { 142 options = options || {}; 143 var curr = window; 144 callback.call(curr, curr); 145 while (curr !== top) { 146 this.eachIframe(function (iframeWindow) { 147 callback.call(iframeWindow, iframeWindow); 148 }, curr.parent.document, [curr]); 149 curr = curr.parent; 150 callback.call(curr, curr); 151 } 152 this.eachIframe(function (iframeWindow) { 153 callback.call(iframeWindow, iframeWindow); 154 }); 155 if (window.opener !== null && mw.tools.canAccessWindow(opener)) { 156 callback.call(window.opener, window.opener); 157 this.eachIframe(function (iframeWindow) { 158 callback.call(iframeWindow, iframeWindow); 159 }, window.opener.document); 160 } 161 }, 162 canAccessWindow: function (winObject) { 163 var can = false;
164 try { 165 var doc = winObject.document; 166 can = !!doc.body; 167 } catch (err) { 168 } 169 return can; 170 }, 171 canAccessIFrame: function (iframe) { 172 var can = false; 173 try { 174 var doc = iframe.contentDocument || iframe.contentWindow.document; 175 can = !!doc.body && !!doc.documentElement; 176 } catch (err) { 177 } 178 return can; 179 }, 180 createStyle: function (c, css, ins) { 181 ins = ins || mwd.getElementsByTagName('head')[0]; 182 var style = mw.$(c)[0]; 183 if (!style) { 184 style = mwd.createElement('style'); 185 ins.appendChild(style); 186 } 187 style.innerHTML = css; 188 return style; 189 }, 190 cssNumber: function (val) { 191 var units = ["px", "%", "in", "cm", "mm", "em", "ex", "pt", "pc"]; 192 if (typeof val === 'number') { 193 return val + 'px'; 194 } 195 else if (typeof val === 'string' && parseFloat(val).toString() === val) { 196 return val + 'px'; 197 } 198 else { 199 if (isNaN(parseFloat(val))) { 200 return '0px'; 201 } 202 else { 203 return val; 204 } 205 } 206 207 }, 208 isField: function (target) { 209 var t = target.nodeName.toLowerCase(); 210 var fields = /^(input|textarea|select)$/i; 211 return fields.test(t); 212 }, 213 214 toggleCheckbox: function (node) { 215 if (node === null || node === undefined) return false; 216 node.checked = !node.checked; 217 return node.checked; 218 }, 219 jQueryFields: function (root) { 220 if (typeof root === 'string') { 221 root = mwd.querySelector(root); 222 } 223 if (typeof root === 'undefined' || root === null) return false; 224 var allFields = "textarea, select, input[type='checkbox']:checked, input[type='color'], input[type='date'], input[type='datetime'], input[type='datetime-local'], input[type='email'], input[type='file'], input[type='hidden'], input[type='month'], input[type='number'], input[type='password'], input[type='radio']:checked, input[type='range'], input[type='search'], input[type='tel'], input[type='text'], input[type='time'], input[type='url'], input[type='week']"; 225 return mw.$(allFields, fields).not(':disabled'); 226 }, 227 toggle: function (who, toggler, callback) { 228 who = mw.$(who); 229 who.toggle(); 230 who.toggleClass('toggle-active'); 231 mw.$(toggler).toggleClass('toggler-active'); 232 mw.is.func(callback) ? callback.call(who) : ''; 233 }, 234 _confirm: function (question, callback) { 235 var conf = confirm(question); 236 if (conf && typeof callback === 'function') { 237 callback.call(window); 238 } 239 return conf; 240 }, 241 el_switch: function (arr, type) { 242 if (type === 'semi') { 243 mw.$(arr).each(function () { 244 var el = mw.$(this); 245 if (el.hasClass("semi_hidden")) { 246 el.removeClass("semi_hidden"); 247 } 248 else { 249 el.addClass("semi_hidden"); 250 } 251 }); 252 } 253 else { 254 mw.$(arr).each(function () { 255 var el = mw.$(this); 256 if (el.css('display') === 'none') { 257 el.show(); 258 } 259 else { 260 el.hide(); 261 } 262 }); 263 } 264 }, 265 focus_on: function (el) { 266 if (!$(el).hasClass('mw-focus')) { 267 mw.$(".mw-focus").each(function () { 268 this !== el ? mw.$(this).removeClass('mw-focus') : ''; 269 }); 270 mw.$(el).addClass('mw-focus'); 271 } 272 }, 273 scrollTo: function (el, callback, minus) { 274 minus = minus || 0; 275 if ($(el).length === 0) { 276 return false;
277 } 278 if (typeof callback === 'number') { 279 minus = callback; 280 } 281 mw.$('html,body').stop().animate({scrollTop: mw.$(el).offset().top - minus}, function () { 282 typeof callback === 'function' ? callback.call(el) : ''; 283 }); 284 }, 285 accordion: function (el, callback) { 286 mw.require('css_parser.js'); 287 var speed = 200; 288 var container = el.querySelector('.mw-accordion-content'); 289 if (container === null) return false; 290 var is_hidden = mw.CSSParser(container).get.display() === 'none'; 291 if (!$(container).is(":animated")) { 292 if (is_hidden) { 293 mw.$(container).slideDown(speed, function () { 294 mw.$(el).addClass('active'); 295 typeof callback === 'function' ? callback.call(el, 'visible') : ''; 296 }); 297 } 298 else { 299 mw.$(container).slideUp(speed, function () { 300 mw.$(el).removeClass('active'); 301 typeof callback === 'function' ? callback.call(el, 'hidden') : ''; 302 }); 303 } 304 } 305 }, 306 index: function (el, parent, selector) { 307 el = mw.$(el)[0]; 308 selector = selector || el.tagName.toLowerCase(); 309 parent = parent || el.parentNode; 310 var all; 311 if (parent.constructor === [].constructor) { 312 all = parent; 313 } 314 else { 315 all = mw.$(selector, parent) 316 } 317 var i = 0, l = all.length; 318 for (; i < l; i++) { 319 if (el === all[i]) return i; 320 } 321 }, 322 323 highlight: function (el, color, speed1, speed2) { 324 if (!el) return false; 325 mw.$(el).stop(); 326 color = color || '#48AD79'; 327 speed1 = speed1 || 777; 328 speed2 = speed2 || 777; 329 var curr = window.getComputedStyle(el, null).backgroundColor; 330 if (curr === 'transparent') { 331 curr = '#ffffff'; 332 } 333 mw.$(el).animate({backgroundColor: color}, speed1, function () { 334 mw.$(el).animate({backgroundColor: curr}, speed2, function () { 335 mw.$(el).css('backgroundColor', ''); 336 }); 337 }); 338 }, 339 highlightStop: function (el) { 340 mw.$(el).stop(); 341 mw.$(el).css('backgroundColor', ''); 342 }, 343 toCamelCase: function (str) { 344 return str.replace(/(\-[a-z])/g, function (a) { 345 return a.toUpperCase().replace('-', ''); 346 }); 347 }, 348 multihover: function () { 349 var l = arguments.length, i = 1; 350 var type = arguments[0].type; 351 var check = ( type === 'mouseover' || type === 'mouseenter'); 352 for ( ; i < l; i++ ) { 353 check ? mw.$(arguments[i]).addClass('hovered') : mw.$(arguments[i]).removeClass('hovered'); 354 } 355 }, 356 listSearch: function (val, list) { 357 val = val.trim().toLowerCase(); 358 if(!val) { 359 $('li', list).show(); 360 return; 361 } 362 this.search(val, 'li', function (found) { 363 if(found) { 364 $(this).show(); 365 } else { 366 $(this).hide(); 367 } 368 369 }, list); 370 }, 371 search: function (string, selector, callback, root) { 372 root = !!root ? $(root)[0] : mwd; 373 if (!root) { 374 return; 375 } 376 string = string.toLowerCase(); 377 var items; 378 if (typeof selector === 'object') { 379 items = selector; 380 } 381 else if (typeof selector === 'string') { 382 items = root.querySelectorAll(selector); 383 } 384 else { 385 return false; 386 } 387 var i = 0, l = items.length; 388 for (; i < l; i++) { 389 items[i].textContent.toLowerCase().contains(string) ? callback.call(items[i], true) : callback.call(items[i], false); 390 } 391 }, 392 ajaxIsSearching: false, 393 ajaxSearcSetting: { 394 limit: 10, 395 keyword: '', 396 order_by: 'updated_at desc',
397 search_in_fields: 'title' 398 }, 399 ajaxSearch: function (o, callback) { 400 if (!mw.tools.ajaxIsSearching) { 401 var obj = $.extend({}, mw.tools.ajaxSearcSetting, o); 402 mw.tools.ajaxIsSearching = $.post(mw.settings.site_url + "api/get_content_admin", obj, function (data) { 403 if (typeof callback === 'function') { 404 callback.call(data, data); 405 } 406 }).always(function () { 407 mw.tools.ajaxIsSearching = false 408 }); 409 } 410 return mw.tools.ajaxIsSearching; 411 }, 412 getPostById: function (id, callback) { 413 var config = { 414 limit: 10, 415 keyword: '', 416 order_by: 'updated_at desc', 417 search_in_fields: 'id', 418 id: id 419 }; 420 return this.ajaxSearch(config, callback); 421 }, 422 iframeLinksToParent: function (iframe) { 423 mw.$(iframe).contents().find('a').each(function () { 424 var href = this.href; 425 if (href.contains(mw.settings.site_url)) { 426 this.target = '_parent'; 427 } 428 }); 429 }, 430 get_filename: function (s) { 431 if (s.contains('.')) { 432 var d = s.lastIndexOf('.'); 433 return s.substring(s.lastIndexOf('/') + 1, d < 0 ? s.length : d); 434 } 435 else { 436 return undefined; 437 } 438 }, 439 is_field: function (obj) { 440 if (obj === null || typeof obj === 'undefined' || obj.nodeType === 3) { 441 return false; 442 } 443 if (!obj.nodeName) { 444 return false; 445 } 446 var t = obj.nodeName.toLowerCase(); 447 if (t === 'input' || t === 'textarea' || t === 'select') { 448 return true 449 } 450 return false; 451 }, 452 getAttrs: function (el) { 453 var attrs = el.attributes; 454 var obj = {}; 455 for (var x in attrs) { 456 if (attrs[x].nodeName) { 457 obj[attrs[x].nodeName] = attrs[x].nodeValue; 458 } 459 } 460 return obj; 461 }, 462 copyAttributes: function (from, to, except) { 463 except = except || []; 464 var attrs = mw.tools.getAttrs(from); 465 if (mw.tools.is_field(from) && mw.tools.is_field(to)) to.value = from.value; 466 for (var x in attrs) { 467 ( $.inArray(x, except) == -1 && x != 'undefined') ? to.setAttribute(x, attrs[x]) : ''; 468 } 469 }, 470 isEmptyObject: function (obj) { 471 for (var a in obj) { 472 if (obj.hasOwnProperty(a)) return false; 473 } 474 return true; 475 }, 476 objLenght: function (obj) { 477 var len = 0, x; 478 if (obj.constructor === {}.constructor) { 479 for ( x in obj ) { 480 len++; 481 } 482 } 483 return len; 484 }, 485 scaleTo: function (selector, w, h) { 486 w = w || 800; 487 h = h || 600; 488 var is_percent = w.toString().contains("%") ? true : false; 489 var item = mw.$(selector); 490 if (item.hasClass('mw-scaleto') || w == 'close') { 491 item.removeClass('mw-scaleto'); 492 item.removeAttr('style'); 493 } 494 else { 495 item.parent().height(item.height()); 496 item.addClass('mw-scaleto'); 497 if (is_percent) { 498 item.css({ 499 width: w, 500 height: h, 501 left: ((100 - parseFloat(w)) / 2) + "%", 502 top: ((100 - parseFloat(h)) / 2) + "%" 503 }); 504 } 505 else { 506 item.css({ 507 width: w, 508 height: h, 509 marginLeft: -w / 2, 510 marginTop: -h / 2 511 }); 512 } 513 } 514 }, 515 getFirstEqualFromTwoArrays: function (a, b) { 516 var ia = 0, ib = 0, la = a.length, lb = b.length; 517 loop: 518 for (; ia < la; ia++) { 519 var curr = a[ia]; 520 for (; ib < lb; ib++) { 521 if (b[ib] == curr) { 522 return curr; 523 } 524 } 525 } 526 }, 527 has: function (el, what) { 528 return el.querySelector(what) !== null; 529 }, 530 html_info: function (html) { 531 if (typeof mw._html_info === 'undefined') { 532 mw._html_info = mwd.createElement('div'); 533 mw._html_info.id = 'mw-html-info'; 534 mwd.body.appendChild(mw._html_info); 535 } 536 mw.$(mw._html_info).html(html); 537 return mw._html_info; 538 }, 539 image_info: function (a, callback) { 540 var img = mwd.createElement('img'); 541 img.className = 'semi_hidden'; 542 img.src = a.src; 543 mwd.body.appendChild(img); 544 img.onload = function () { 545 callback.call({width: mw.$(img).width(), height: mw.$(img).height()}); 546 mw.$(img).remove(); 547 }; 548 }, 549 refresh_image: function (node) { 550 node.src = mw.url.set_param('refresh_image', mw.random(), node.src); 551 return node; 552 }, 553 refresh: function (a) { 554 if (a === null || typeof a === 'undefined') { 555 return false;
556 } 557 if (a.src) { 558 a.src = mw.url.set_param('mwrefresh', mw.random(), a.src); 559 } 560 else if (a.href) { 561 a.href = mw.url.set_param('mwrefresh', mw.random(), a.href); 562 } 563 }, 564 getDiff: function (_new, _old) { 565 var diff = {}, x, y; 566 for (x in _new) { 567 if (!x in _old || _old[x] != _new[x]) { 568 diff[x] = _new[x]; 569 } 570 } 571 for (y in _old) { 572 if (typeof _new[y] === 'undefined') { 573 diff[y] = ""; 574 } 575 } 576 return diff; 577 }, 578 parseHtml: function (html) { 579 var doc = mwd.implementation.createHTMLDocument(""); 580 doc.body.innerHTML = html; 581 return doc; 582 }, 583 isEmpty: function (node) { 584 return ( node.innerHTML.trim() ).length === 0; 585 }, 586 isJSON: function (a) { 587 if (typeof a === 'object') { 588 if (a.constructor === {}.constructor) { 589 return true; 590 } 591 else { 592 return false; 593 } 594 } 595 else if (typeof a === 'string') { 596 try { 597 JSON.parse(a); 598 } 599 catch (e) { 600 return false; 601 } 602 return true; 603 } 604 else { 605 return false; 606 } 607 }, 608 toJSON: function (w) { 609 if (typeof w === 'object' && mw.tools.isJSON(w)) { 610 return w; 611 } 612 if (typeof w === 'string') { 613 try { 614 var r = JSON.parse(w); 615 } 616 catch (e) { 617 var r = {"0": w}; 618 } 619 return r; 620 } 621 if (typeof w === 'object' && w.constructor === [].constructor) { 622 var obj = {}, i = 0, l = w.length; 623 for (; i < l; i++) { 624 obj[i] = w[i]; 625 } 626 return obj; 627 } 628 }, 629 mwattr: function (el, a, b) { 630 if (!b && !!el) { 631 var data = mw.$(el).dataset(a); 632 if (!!$(el)[0].attributes) { 633 var attr = mw.$(el)[0].attributes[a]; 634 } 635 636 if (data !== '') { 637 return data; 638 } 639 if (!!attr) { 640 return attr.value; 641 } 642 return false; 643 } 644 else { 645 mw.$(el).dataset(a, b); 646 } 647 }, 648 disable: function (el, text, global) { 649 text = text || mw.msg.loading + '...'; 650 global = global || false; 651 var _el = mw.$(el); 652 if (!_el.length) { 653 return false; 654 } 655 if (!_el.hasClass("disabled")) { 656 _el.addClass('disabled'); 657 if (_el[0].tagName !== 'INPUT') { 658 _el.dataset("text", _el.html()); 659 _el.html(text); 660 } 661 else { 662 _el.dataset("text", _el.val()); 663 _el.val(text); 664 } 665 if (global) mw.$(mwd.body).addClass("loading"); 666 } 667 return el; 668 }, 669 enable: function (el) { 670 var _el = mw.$(el); 671 if (!_el.length) { 672 return false; 673 } 674 var text = _el.dataset("text"); 675 _el.removeClass("disabled"); 676 if (_el[0].tagName !== 'INPUT') { 677 _el.html(text); 678 } 679 else { 680 _el.val(text); 681 } 682 mw.$(mwd.body).removeClass("loading"); 683 return el; 684 }, 685 prependClass: function (el, cls) { 686 el.className = (cls + ' ' + el.className).trim() 687 }, 688 inview: function (el) { 689 var $el = mw.$(el); 690 if ($el.length === 0) { 691 return false;
692 } 693 var dt = mw.$(window).scrollTop(), 694 db = dt + mw.$(window).height(), 695 et = $el.offset().top; 696 return (et <= db) && !(dt > ($el.height() + et)); 697 }, 698 wholeinview: function (el) { 699 var $el = mw.$(el), 700 dt = mw.$(window).scrollTop(), 701 db = dt + mw.$(window).height(), 702 et = $el.offset().top, 703 eb = et + mw.$(el).height(); 704 return ((eb <= db) && (et >= dt)); 705 }, 706 preload: function (u, c) { 707 var im = new Image(); 708 if (typeof c === 'function') { 709 im.onload = function () { 710 c.call(u, im); 711 } 712 } 713 im.src = u; 714 }, 715 mapNodeValues: function (n1, n2) { 716 if (!n1 || !n2 || n1 === null || n2 === null) return false; 717 var setValue1 = ((!!n1.type && n1.nodeName !== 'BUTTON') || n1.nodeName === 'TEXTAREA') ? 'value' : 'textContent'; 718 var setValue2 = ((!!n2.type && n2.nodeName !== 'BUTTON') || n2.nodeName === 'TEXTAREA') ? 'value' : 'textContent'; 719 var events = 'keyup paste'; 720 mw.$(n1).bind(events, function () { 721 n2[setValue2] = n1[setValue1]; 722 mw.$(n2).trigger('change'); 723 }); 724 mw.$(n2).bind(events, function () { 725 n1[setValue1] = n2[setValue2]; 726 mw.$(n1).trigger('change'); 727 }); 728 }, 729 copyEvents: function (from, to) { 730 if (typeof $._data(from, 'events') === 'undefined') { 731 return false; 732 } 733 $.each($._data(from, 'events'), function () { 734 $.each(this, function () { 735 mw.$(to).bind(this.type, this.handler); 736 }); 737 }); 738 }, 739 setTag: function (node, tag) { 740 var el = mwd.createElement(tag); 741 mw.tools.copyAttributes(node, el); 742 while (node.firstChild) { 743 el.appendChild(node.firstChild); 744 } 745 mw.tools.copyEvents(node, el); 746 mw.$(node).replaceWith(el); 747 return el; 748 }, 749 750 module_settings: function (a, view, liveedit) { 751 var opts = {}; 752 if (typeof liveedit === 'undefined') { 753 opts.liveedit = true; 754 } 755 if (!!view) { 756 opts.view = view; 757 } 758 else { 759 opts.view = 'admin'; 760 } 761 return mw.live_edit.showSettings(a, opts); 762 }, 763 fav: function (a) { 764 var canvas = document.createElement("canvas"); 765 canvas.width = 16; 766 canvas.height = 16; 767 var context = canvas.getContext("2d"); 768 context.fillStyle = "#EF3D25"; 769 context.fillRect(0, 0, 16, 16); 770 context.font = "normal 10px Arial"; 771 context.textAlign = 'center'; 772 context.textBaseline = 'middle'; 773 context.fillStyle = "white"; 774 context.fillText(a, 8, 8); 775 var im = canvas.toDataURL(); 776 var l = document.createElement('link'); 777 l.className = 'mwfav'; 778 l.setAttribute('rel', 'icon'); 779 l.setAttribute('type', 'image/png'); 780 l.href = im; 781 mw.$(".mwfav").remove(); 782 mwd.getElementsByTagName('head')[0].appendChild(l); 783 }, 784 px2pt: function (px) { 785 var n = parseInt(px, 10); 786 if (isNaN(n)) { 787 return false; 788 } 789 return Math.round(((3 / 4) * n)); 790 }, 791 matches: function (node, what) { 792 if (node === 'init') { 793 if (!!mwd.documentElement.matches) mw.tools.matchesMethod = 'matches'; 794 else if (!!mwd.documentElement.matchesSelector) mw.tools.matchesMethod = 'matchesSelector'; 795 else if (!!mwd.documentElement.mozMatchesSelector) mw.tools.matchesMethod = 'mozMatchesSelector'; 796 else if (!!mwd.documentElement.webkitMatchesSelector) mw.tools.matchesMethod = 'webkitMatchesSelector';
797 else if (!!mwd.documentElement.msMatchesSelector) mw.tools.matchesMethod = 'msMatchesSelector'; 798 else if (!!mwd.documentElement.oMatchesSelector) mw.tools.matchesMethod = 'oMatchesSelector'; 799 else mw.tools.matchesMethod = undefined; 800 } 801 else { 802 if (node === null) { 803 return false; 804 } 805 if (typeof node === 'undefined') { 806 return false; 807 } 808 if (node.nodeType !== 1) { 809 return false; 810 } 811 if (!!mw.tools.matchesMethod) { 812 return node[mw.tools.matchesMethod](what) 813 } 814 else { 815 var doc = mwd.implementation.createHTMLDocument(""); 816 node = node.cloneNode(true); 817 doc.body.appendChild(node); 818 var all = doc.body.querySelectorAll(what), 819 l = all.length, 820 i = 0; 821 for (; i < l; i++) { 822 if (all[i] === node) { 823 return true; 824 } 825 } 826 return false; 827 } 828 } 829 } 830 } 831 832 Object.assign(expose, helpers); 833 expose.matches('init'); 834 835})(mw.tools);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.