1var device = new BDevice(); 2 3var TINY = TINY || {}, 4 T$ = T$ || function(i) { 5 return document.getElementById(i) 6 }, 7 T$$$ = T$$$ || function() { 8 return document.all ? 1 : 0 9 }; 10 11TINY.editor = function() { 12 var c = [], offset = -30; 13 c['bold'] = [4, 'Bold', 'a', 'bold']; 14 c['italic'] = [5, 'Italic', 'a', 'italic']; 15 c['underline'] = [6, 'Underline', 'a', 'underline']; 16 c['strikethrough'] = [7, 'Strikethrough', 'a', 'strikethrough']; 17 c['subscript'] = [8, 'Subscript', 'a', 'subscript']; 18 c['superscript'] = [9, 'Superscript', 'a', 'superscript']; 19 c['orderedlist'] = [10, 'Insert Ordered List', 'a', 'insertorderedlist']; 20 c['unorderedlist'] = [11, 'Insert Unordered List', 'a', 'insertunorderedlist']; 21 c['outdent'] = [12, 'Outdent', 'a', 'outdent']; 22 c['indent'] = [13, 'Indent', 'a', 'indent']; 23 c['leftalign'] = [14, 'Left Align', 'a', 'justifyleft']; 24 c['centeralign'] = [15, 'Center Align', 'a', 'justifycenter']; 25 c['rightalign'] = [16, 'Right Align', 'a', 'justifyright']; 26 c['blockjustify'] = [17, 'Block Justify', 'a', 'justifyfull']; 27 c['undo'] = [18, 'Undo', 'a', 'undo']; 28 c['redo'] = [19, 'Redo', 'a', 'redo']; 29 c['image'] = [20, 'Insert Image', 'i', 'insertimage', 'Enter Image URL:', 'http://']; 30 c['hr'] = [21, 'Insert Horizontal Rule', 'a', 'inserthorizontalrule']; 31 c['link'] = [22, 'Insert Hyperlink', 'i', 'createlink', 'Enter URL:', 'http://']; 32 c['unlink'] = [23, 'Remove Hyperlink', 'a', 'unlink']; 33 c['unformat'] = [24, 'Remove Formatting', 'a', 'removeformat']; 34 c['print'] = [25, 'Print', 'a', 'print']; 35 function edit(n, obj) { 36 this.n = n; 37 window[n] = this; 38 this.t = T$(obj.id); 39 this.obj = obj; 40 this.xhtml = obj.xhtml; 41 var p = document.createElement('div'), w = document.createElement('div'), h = document.createElement('div'), 42 l = obj.controls.length, i = 0; 43 this.i = document.createElement('iframe'); 44 this.i.width = obj.width || '500'; 45 this.i.height = obj.height || '250'; 46 this.ie = T$$$(); 47 h.className = obj.rowclass || 'tinyeditor-header'; 48 p.className = obj.cssclass || 'tinyeditor'; 49 p.style.width = this.i.width + 'px'; 50 p.appendChild(h); 51 for (i; i < l; i++) { 52 var id = obj.controls[i]; 53 if (id == 'n') { 54 h = document.createElement('div'); 55 h.className = obj.rowclass || 'tinyeditor-header'; 56 p.appendChild(h); 57 } else if (id == '|') { 58 var d = document.createElement('div'); 59 d.className = obj.dividerclass || 'tinyeditor-divider'; 60 h.appendChild(d); 61 } else if (id == 'font') { 62 var sel = document.createElement('select'), fonts = obj.fonts || ['Verdana', 'Arial', 'Georgia'], fl = fonts.length, x = 0; 63 sel.className = 'tinyeditor-font'; 64 sel.onchange = new Function(this.n + '.ddaction(this, "fontname")'); 65 sel.options[0] = new Option('Font', ''); 66 for (x; x < fl; x++) { 67 var font = fonts[x]; 68 sel.options[x + 1] = new Option(font, font); 69 } 70 h.appendChild(sel) 71 } else if (id == 'size') { 72 var sel = document.createElement('select'), sizes = obj.sizes || [1, 2, 3, 4, 5, 6, 7], sl = sizes.length, x = 0; 73 sel.className = 'tinyeditor-size'; 74 sel.onchange = new Function(this.n + '.ddaction(this, "fontsize")'); 75 for (x; x < sl; x++) { 76 var size = sizes[x]; 77 sel.options[x] = new Option(size, size); 78 } 79 h.appendChild(sel) 80 } else if (id == 'style') { 81 var sel = document.createElement('select'), 82 styles = obj.styles || [['Style', ''], ['Paragraph', '<p>'], ['Header 1', '<h1>'], ['Header 2', '<h2>'], ['Header 3', '<h3>'], ['Header 4', '<h4>'], ['Header 5', '<h5>'], ['Header 6', '<h6>']], 83 sl = styles.length, x = 0; 84 sel.className = 'tinyeditor-style'; 85 sel.onchange = new Function(this.n + '.ddaction(this, "formatblock")'); 86 for (x; x < sl; x++) { 87 var style = styles[x]; 88 sel.options[x] = new Option(style[0], style[1]); 89 } 90 h.appendChild(sel); 91 } else if (c[id]) { 92 var div = document.createElement('div'), x = c[id], func = x[2], ex, pos = x[0] * offset; 93 div.className = obj.controlclass; 94 div.unselectable = 'on'; 95 div.style.backgroundPosition = '0px ' + pos + 'px'; 96 div.title = x[1]; 97 ex = func == 'a' ? '.action("' + x[3] + '", 0, ' + (x[4] || 0) + ')' : '.insert("' + x[4] + '", "' + x[5] + '", "' + x[3] + '")'; 98 div.onmousedown = new Function(this.n + (id == 'print' ? '.print()' : ex)); 99 div.onmouseover = new Function(this.n + '.hover(this, ' + pos + ', 1)'); 100 div.onmouseout = new Function(this.n + '.hover(this, ' + pos + ', 0)'); 101 h.appendChild(div); 102 if (this.ie) { 103 div.unselectable = 'on' 104 } 105 } 106 } 107 this.t.parentNode.insertBefore(p, this.t); 108 this.t.style.width = this.i.width + 'px'; 109 w.appendChild(this.t); 110 w.appendChild(this.i); 111 w.className = obj.textblockcss || 'tinytext-wrapper'; 112 p.appendChild(w); 113 this.t.style.display = 'none'; 114 if (obj.footer) { 115 var f = document.createElement('div'); 116 f.className = obj.footerclass || 'tinyeditor-footer'; 117 if (obj.toggle) { 118 var to = obj.toggle, ts = document.createElement('div'); 119 ts.className = to.cssclass || 'toggle'; 120 ts.innerHTML = obj.toggletext || 'source'; 121 ts.onclick = new Function(this.n + '.toggle(0, this);return false'); 122 f.appendChild(ts); 123 } 124 if (obj.resize) { 125 var ro = obj.resize, rs = document.createElement('div'); 126 rs.className = ro.cssclass || 'resize'; 127 rs.onmousedown = new Function('event', this.n + '.resize(event);return false'); 128 rs.onselectstart = function() { 129 return false 130 }; 131 f.appendChild(rs); 132 } 133 p.appendChild(f); 134 } 135 this.e = this.i.contentWindow.document; 136 this.e.open(); 137 var m = '<html><head>', bodyid = obj.bodyid ? " id=\"" + obj.bodyid + "\"" : ""; 138 if (obj.cssfile) { 139 m += '<link rel="stylesheet" href="' + obj.cssfile + '" />' 140 } 141 if (obj.css) { 142 m += '<style type="text/css">' + obj.css + '</style>' 143 } 144 m += '</head><body' + bodyid + ' contenteditable="true" style = "font-family: Tahoma; font-size: 12px;">' + (obj.content || this.t.value); 145 m += '</body></html>'; 146 this.e.write(m); 147 this.e.close(); 148 this.e.designMode = 'On'; 149 this.d = 1; 150 if (this.xhtml) { 151 try {
152 this.e.execCommand("styleWithCSS", 0, 0) 153 } 154 catch (e) { 155 try { 156 this.e.execCommand("useCSS", 0, 1) 157 } catch (e) { 158 } 159 } 160 } 161 } 162 ; 163 edit.prototype.print = function() { 164 this.i.contentWindow.print(); 165 }; 166 edit.prototype.hover = function(div, pos, dir) { 167 this.getSelection(); 168 div.style.backgroundPosition = (dir ? '34px ' : '0px ') + (pos) + 'px'; 169 }; 170 edit.prototype.getSelection = function() { 171 if (this.ie && this.e.getSelection) { 172 this.sel = this.e.getSelection(); 173 if (this.sel.getRangeAt && this.sel.rangeCount) { 174 this.range = this.sel.getRangeAt(0); 175 } 176 } 177 }; 178 edit.prototype.restoreSelection = function() { 179 if (this.range && this.ie) { 180 if (this.e.getSelection) { 181 this.sel = this.e.getSelection(); 182 this.sel.removeAllRanges(); 183 this.sel.addRange(this.range); 184 } 185 } 186 }; 187 edit.prototype.ddaction = function(dd, a) { 188 var i = dd.selectedIndex, v = dd.options[i].value; 189 this.action(a, v); 190 }; 191 edit.prototype.action = function(cmd, val, ie) { 192 if (ie && !this.ie) { 193 alert('Your browser does not support this function.') 194 } else { 195 this.restoreSelection(); 196 this.e.execCommand(cmd, 0, val || null); 197 } 198 }; 199 edit.prototype.insert = function(pro, msg, cmd) { 200 var val = prompt(pro, msg); 201 if (val != null && val != '') { 202 this.e.execCommand(cmd, 0, val) 203 } 204 }; 205 edit.prototype.setfont = function() { 206 this.restoreSelection(); 207 execCommand('formatblock', 0, hType); 208 }; 209 edit.prototype.resize = function(e) { 210 if (this.mv) { 211 this.freeze() 212 } 213 this.i.bcs = TINY.cursor.top(e); 214 this.mv = new Function('event', this.n + '.move(event)'); 215 this.sr = new Function(this.n + '.freeze()'); 216 if (this.ie) { 217 document.attachEvent('onmousemove', this.mv); 218 document.attachEvent('onmouseup', this.sr); 219 } else { 220 document.addEventListener('mousemove', this.mv, 1); 221 document.addEventListener('mouseup', this.sr, 1); 222 } 223 }; 224 edit.prototype.move = function(e) { 225 var pos = TINY.cursor.top(e); 226 this.i.height = parseInt(this.i.height) + pos - this.i.bcs; 227 this.i.bcs = pos; 228 }; 229 edit.prototype.freeze = function() { 230 if (this.ie) { 231 document.detachEvent('onmousemove', this.mv); 232 document.detachEvent('onmouseup', this.sr); 233 } else { 234 document.removeEventListener('mousemove', this.mv, 1); 235 document.removeEventListener('mouseup', this.sr, 1); 236 } 237 }; 238 edit.prototype.toggle = function(post, div) { 239 if (!this.d) { 240 var v = this.t.value; 241 if (div) { 242 div.innerHTML = this.obj.toggletext || 'source' 243 } 244 if (this.xhtml && !this.ie) { 245 v = v.replace(/<strong>(.*)<\/strong>/gi, '<span style="font-weight:bold;">$1</span>'); 246 v = v.replace(/<em>(.*)<\/em>/gi, '<span style="font-weight:italic;">$1</span>'); 247 } 248 this.e.body.innerHTML = v; 249 this.t.style.display = 'none'; 250 this.i.style.display = 'block'; 251 this.d = 1; 252 } else { 253 var v = this.e.body.innerHTML; 254 if (this.xhtml) { 255 v = v.replace(/<span class="apple-style-span">(.*)<\/span>/gi, '$1'); 256 v = v.replace(/ class="apple-style-span"/gi, ''); 257 v = v.replace(/<span style="">/gi, ''); 258 v = v.replace(/<br>/gi, '<br />'); 259 v = v.replace(/<br ?\/?>$/gi, ''); 260 v = v.replace(/^<br ?\/?>/gi, ''); 261 v = v.replace(/(<img [^>]+[^\/])>/gi, '$1 />'); 262 v = v.replace(/<b\b[^>]*>(.*?)<\/b[^>]*>/gi, '<strong>$1</strong>'); 263 v = v.replace(/<i\b[^>]*>(.*?)<\/i[^>]*>/gi, '<em>$1</em>'); 264 v = v.replace(/<u\b[^>]*>(.*?)<\/u[^>]*>/gi, '<span style="text-decoration:underline">$1</span>'); 265 v = v.replace(/<(b|strong|em|i|u) style="font-weight:normal;?">(.*)<\/(b|strong|em|i|u)>/gi, '$2'); 266 v = v.replace(/<(b|strong|em|i|u) style="(.*)">(.*)<\/(b|strong|em|i|u)>/gi, '<span style="$2"><$4>$3</$4></span>'); 267 v = v.replace(/<span style="font-weight:normal;?">(.*)<\/span>/gi, '$1'); 268 v = v.replace(/<span style="font-weight:bold;?">(.*)<\/span>/gi, '<strong>$1</strong>'); 269 v = v.replace(/<span style="font-style:italic;?">(.*)<\/span>/gi, '<em>$1</em>'); 270 v = v.replace(/<span style="font-weight:bold;?">(.*)<\/span>|<b\b[^>]*>(.*?)<\/b[^>]*>/gi, '<strong>$1</strong>'); 271 } 272 if (div) { 273 div.innerHTML = this.obj.toggletext || 'wysiwyg' 274 } 275 this.t.value = v; 276 if (!post) { 277 this.t.style.height = this.i.height + 'px'; 278 this.i.style.display = 'none'; 279 this.t.style.display = 'block'; 280 this.d = 0; 281 } 282 } 283 }; 284 edit.prototype.post = function() { 285 if (this.d) { 286 this.toggle(1); 287 } 288 }; 289 return {edit: edit} 290}(); 291 292TINY.cursor = function() { 293 return { 294 top: function(e) { 295 return T$$$() ? window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop : e.clientY + window.scrollY; 296 } 297 } 298}(); 299 300/* 301 jQuery Masked Input Plugin 302 Copyright (c) 2007 - 2014 Josh Bush (digitalbush.com) 303 http://digitalbush.com/projects/masked-input-plugin/ 304 Licensed under the MIT license (http://digitalbush.com/projects/masked-input-plugin/#license) 305 Version: 1.4.0 306 DEMO: 307 $("#date").mask("99/99/9999",{placeholder:"mm/dd/yyyy"}); 308 $("#phone").mask("(999) 999-9999"); 309 $("#tin").mask("99-9999999"); 310 $("#ssn").mask("999-99-9999"); 311 */ 312 313 314/*!function(factory) { 315 "function" == typeof define && define.amd ? define(["jquery"], factory) : factory("object" == typeof exports ? require("jquery") : "jQuery"); 316}*/(function($) { 317 var caretTimeoutId, ua = navigator.userAgent, iPhone = /iphone/i.test(ua), chrome = /chrome/i.test(ua), android = /android/i.test(ua); 318 $.mask = { 319 definitions: { 320 "9": "[0-9]", 321 a: "[A-Za-z]", 322 "*": "[A-Za-z0-9]" 323 }, 324 autoclear: !0, 325 dataName: "rawMaskFn", 326 placeholder: "_" 327 },$.fn.extend({ 328 caret: function(begin, end) { 329 var range; 330 if (0 !== this.length && !this.is(":hidden")) 331 return "number" == typeof begin ? (end = "number" == typeof end ? end : begin, 332 this.each(function() { 333 this.setSelectionRange ? this.setSelectionRange(begin, end) : this.createTextRange && (range = this.createTextRange(), 334 range.collapse(!0), range.moveEnd("character", end), range.moveStart("character", begin), 335 range.select()); 336 })) : (this[0].setSelectionRange ? (begin = this[0].selectionStart, end = this[0].selectionEnd) : document.selection && document.selection.createRange && (range = document.selection.createRange(), 337 begin = 0 - range.duplicate().moveStart("character", -1e5), end = begin + range.text.length), 338 { 339 begin: begin, 340 end: end 341 }); 342 }, 343 unmask: function() { 344 return this.trigger("unmask"); 345 }, 346 mask: function(mask, settings) { 347 var input, defs, tests, partialPosition, firstNonMaskPos, lastRequiredNonMaskPos, len, oldVal; 348 if (!mask && this.length > 0) { 349 input = $(this[0]); 350 var fn = input.data($.mask.dataName); 351 return fn ? fn() : void 0; 352 } 353 return settings = $.extend({ 354 autoclear: $.mask.autoclear, 355 placeholder: $.mask.placeholder, 356 completed: null 357 }, settings), defs = $.mask.definitions, tests = [], partialPosition = len = mask.length, 358 firstNonMaskPos = null, $.each(mask.split(""), function(i, c) { 359 "?" == c ? (len--, partialPosition = i) : defs[c] ? (tests.push(new RegExp(defs[c])), 360 null === firstNonMaskPos && (firstNonMaskPos = tests.length - 1), partialPosition > i && (lastRequiredNonMaskPos = tests.length - 1)) : tests.push(null); 361 }), this.trigger("unmask").each(function() { 362 function tryFireCompleted() { 363 if (settings.completed) { 364 for (var i = firstNonMaskPos; lastRequiredNonMaskPos >= i; i++) 365 if (tests[i] && buffer[i] === getPlaceholder(i)) 366 return; 367 settings.completed.call(input); 368 } 369 } 370 function getPlaceholder(i) { 371 return settings.placeholder.charAt(i < settings.placeholder.length ? i : 0); 372 } 373 function seekNext(pos) { 374 for (; ++pos < len && !tests[pos]; ) 375 ; 376 return pos; 377 } 378 function seekPrev(pos) { 379 for (; --pos >= 0 && !tests[pos]; ) 380 ; 381 return pos; 382 } 383 function shiftL(begin, end) { 384 var i, j; 385 if (!(0 > begin)) { 386 for (i = begin, j = seekNext(end); len > i; i++) 387 if (tests[i]) { 388 if (!(len > j && tests[i].test(buffer[j]))) 389 break; 390 buffer[i] = buffer[j], buffer[j] = getPlaceholder(j), j = seekNext(j); 391 } 392 writeBuffer(), input.caret(Math.max(firstNonMaskPos, begin)); 393 } 394 } 395 function shiftR(pos) { 396 var i, c, j, t; 397 for (i = pos, c = getPlaceholder(pos); len > i; i++) 398 if (tests[i]) { 399 if (j = seekNext(i), t = buffer[i], buffer[i] = c, !(len > j && tests[j].test(t))) 400 break; 401 c = t; 402 } 403 } 404 function androidInputEvent() { 405 var curVal = input.val(), pos = input.caret(); 406 if (curVal.length < oldVal.length) { 407 for (checkVal(!0); pos.begin > 0 && !tests[pos.begin - 1]; ) 408 pos.begin--; 409 if (0 === pos.begin) 410 for (; pos.begin < firstNonMaskPos && !tests[pos.begin]; ) 411 pos.begin++; 412 input.caret(pos.begin, pos.begin); 413 } else { 414 for (checkVal(!0); pos.begin < len && !tests[pos.begin]; ) 415 pos.begin++; 416 input.caret(pos.begin, pos.begin); 417 }
418 tryFireCompleted(); 419 } 420 function blurEvent() { 421 checkVal(), input.val() != focusText && input.change(); 422 } 423 function keydownEvent(e) { 424 if (!input.prop("readonly")) { 425 var pos, begin, end, k = e.which || e.keyCode; 426 oldVal = input.val(), 8 === k || 46 === k || iPhone && 127 === k ? (pos = input.caret(), 427 begin = pos.begin, end = pos.end, end - begin === 0 && (begin = 46 !== k ? seekPrev(begin) : end = seekNext(begin - 1), 428 end = 46 === k ? seekNext(end) : end), clearBuffer(begin, end), shiftL(begin, end - 1), 429 e.preventDefault()) : 13 === k ? blurEvent.call(this, e) : 27 === k && (input.val(focusText), 430 input.caret(0, checkVal()), e.preventDefault()); 431 } 432 } 433 function keypressEvent(e) { 434 if (!input.prop("readonly")) { 435 var p, c, next, k = e.which || e.keyCode, pos = input.caret(); 436 if (!(e.ctrlKey || e.altKey || e.metaKey || 32 > k) && k && 13 !== k) { 437 if (pos.end - pos.begin !== 0 && (clearBuffer(pos.begin, pos.end), shiftL(pos.begin, pos.end - 1)), 438 p = seekNext(pos.begin - 1), len > p && (c = String.fromCharCode(k), tests[p].test(c))) { 439 if (shiftR(p), buffer[p] = c, writeBuffer(), next = seekNext(p), android) { 440 var proxy = function() { 441 $.proxy($.fn.caret, input, next)(); 442 }; 443 setTimeout(proxy, 0); 444 } else 445 input.caret(next); 446 pos.begin <= lastRequiredNonMaskPos && tryFireCompleted(); 447 } 448 e.preventDefault(); 449 } 450 } 451 } 452 function clearBuffer(start, end) { 453 var i; 454 for (i = start; end > i && len > i; i++) 455 tests[i] && (buffer[i] = getPlaceholder(i)); 456 } 457 function writeBuffer() { 458 input.val(buffer.join("")); 459 } 460 function checkVal(allow) { 461 var i, c, pos, test = input.val(), lastMatch = -1; 462 for (i = 0, pos = 0; len > i; i++) 463 if (tests[i]) { 464 for (buffer[i] = getPlaceholder(i); pos++ < test.length; ) 465 if (c = test.charAt(pos - 1), 466 tests[i].test(c)) { 467 buffer[i] = c, lastMatch = i; 468 break; 469 } 470 if (pos > test.length) { 471 clearBuffer(i + 1, len); 472 break; 473 } 474 } else 475 buffer[i] === test.charAt(pos) && pos++, partialPosition > i && (lastMatch = i); 476 return allow ? writeBuffer() : partialPosition > lastMatch + 1 ? settings.autoclear || buffer.join("") === defaultBuffer ? (input.val() && input.val(""), 477 clearBuffer(0, len)) : writeBuffer() : (writeBuffer(), input.val(input.val().substring(0, lastMatch + 1))), 478 partialPosition ? i : firstNonMaskPos; 479 } 480 var input = $(this), buffer = $.map(mask.split(""), function(c, i) { 481 return "?" != c ? defs[c] ? getPlaceholder(i) : c : void 0; 482 }), defaultBuffer = buffer.join(""), focusText = input.val(); 483 input.data($.mask.dataName, function() { 484 return $.map(buffer, function(c, i) { 485 return tests[i] && c != getPlaceholder(i) ? c : null; 486 }).join(""); 487 }), input.one("unmask", function() { 488 input.off(".mask").removeData($.mask.dataName); 489 }).on("focus.mask", function() { 490 if (!input.prop("readonly")) { 491 clearTimeout(caretTimeoutId); 492 var pos; 493 focusText = input.val(), pos = checkVal(), caretTimeoutId = setTimeout(function() { 494 writeBuffer(), pos == mask.replace("?", "").length ? input.caret(0, pos) : input.caret(pos); 495 }, 10); 496 } 497 }).on("blur.mask", blurEvent).on("keydown.mask", keydownEvent).on("keypress.mask", keypressEvent).on("input.mask paste.mask", function() { 498 input.prop("readonly") || setTimeout(function() { 499 var pos = checkVal(!0); 500 input.caret(pos), tryFireCompleted(); 501 }, 0); 502 }), chrome && android && input.off("input.mask").on("input.mask", androidInputEvent), 503 checkVal(); 504 }); 505 } 506 }); 507}); 508/** 509 * Get cookie value 510 */ 511function getCookie(name) { 512 var matches = document.cookie.match(new RegExp("(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)")); 513 return matches ? decodeURIComponent(matches[1]) : undefined; 514 } 515 516function setCookie(maxage, path, domain, data) { 517 if (maxage == '') { 518 maxage = 'max-age=86400;';//one max - one day 519 }else{ 520 maxage = 'max-age=' + maxage + ';'; 521 } 522 if (path == '') { 523 path = 'path=/;'; 524 }else{ 525 path = 'path=' + path + ';'; 526 } 527 if (domain == '') { 528 domain = 'domain=' + roothostname + ';'; 529 } else { 530 domain = 'domain=' + domain + ';'; 531 } 532 document.cookie = data + maxage + path + domain; 533} 534 535 536/** 537 * Get currently user ID, if user is anonymous - return 0; 538 */ 539function getUID() { 540 var vidsecret = getCookie('vidsecret');
541 if((vidsecret==undefined)||(vidsecret=='')){ 542 return 0; 543 } 544 var parts = vidsecret.split("%3A"); 545 if(parts.length!=2){ 546 var parts = vidsecret.split(":"); 547 } 548 if (parts.length >= 1) { 549 return parseInt(parts[0]); 550 } 551 return 0; 552} 553 554/** 555 * get user avatar 556 */ 557function getUserAvatar(size) { 558 var useravatar = window.useravatar; 559 if((useravatar==undefined)||(useravatar=='')){ 560 return ''; 561 } 562 return useravatar.replace('%size%',size); 563 } 564 565 566 567function scrolltop(){ 568 window.scrollBy(0,-300); 569 var doc=document.documentElement; 570 var top=(window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0); 571 if(top>0){ 572 scrolldelay=setTimeout('scrolltop()',50); 573 } 574 } 575 576 577function scroll_check(){ 578 var top = $(window).scrollTop(); 579 if(top>400){ 580 $('#gotop').addClass('visible'); 581 }else{ 582 $('#gotop').removeClass('visible'); 583 } 584 } 585window.CenterModal = function(element){ 586 var initModalHeight = $(element).outerHeight(); 587 var userScreenHeight = $(window).outerHeight(); 588 if(userScreenHeight > initModalHeight){ 589 $(element).css({ 590 'margin-top': function () { 591 return ((userScreenHeight / 2) - (initModalHeight / 2)); 592 } 593 }); 594 } 595}; 596 597$(document).ready(function() { 598 window.console&&console.log('-------------------------------------------'); 599 window.console&&console.log(' acc.cv.ua '); 600 window.console&&console.log(' '); 601 window.console&&console.log(' Made by Brilliant IT (it.brilliant.ua) '); 602 window.console&&console.log('-------------------------------------------'); 603 604 setTimeout(function(){ 605 $( "img" ).each(function( index ) { 606 let data = $( this ).data( "src" ); 607 if(typeof(data) != "undefined" && data !== null) { 608 console.log( $( this ).data( "src" ) ); 609 $( this ).attr('src', data); 610 } 611 }); 612 }, 1000); 613 614 615 616 $( "iframe" ).each(function( index ) { 617 let data = $( this ).data( "src" ); 618 if(typeof(data) != "undefined" && data !== null) { 619 console.log( $( this ).data( "src" ) ); 620 $( this ).attr('src', data); 621 } 622 }); 623 624 scroll_check(); 625 $(window).scroll(function(){ 626 scroll_check(); 627 // 628 if(window.disablemenustick!=true){ 629 var h_hght_before=parseInt($('#before-head').outerHeight(true)); 630 if(isNaN(h_hght_before)){ 631 h_hght_before=0; 632 } 633 // 634 var h_hght_topbanner=parseInt($('#topbigbanner').outerHeight(true)); 635 if(isNaN(h_hght_topbanner)){ 636 h_hght_topbanner=0; 637 } 638 // 639 var h_hght_bgstyling=parseInt($('#bgstyling').outerHeight(true)); 640 if(isNaN(h_hght_bgstyling)){ 641 h_hght_bgstyling=0; 642 } 643 // 644 var h_hght_head=parseInt($('#head').outerHeight(false)); 645 if(isNaN(h_hght_head)){ 646 h_hght_head=0; 647 } 648 var h_hght=h_hght_before+h_hght_topbanner+h_hght_head+h_hght_bgstyling; 649 // 650 var h_mrg=0; 651 var top = $(this).scrollTop(); 652 var elem = $('#menusbar'); 653 if(top+h_mrg < h_hght){ 654 elem.removeClass('fixed'); 655 $('#head').css('margin-bottom','0px'); 656 }else { 657 elem.addClass('fixed'); 658 $('#head').css('margin-bottom','76px'); 659 } 660 } 661 }); 662 663 $('.message').each(function(ind,msg){ 664 $('.close',msg).click(function(){ 665 $(msg).hide(500); 666 return false; 667 }); 668 }); 669 $('.dropdown').each(function(ind,drp){ 670 $('.title',drp).click(function(){ 671 $(drp).toggleClass('opened'); 672 }); 673 }); 674 675 676 $('#gotop').click(function(){ 677 scrolltop(); 678 return false; 679 }); 680 //start commit Natali 681 $('iframe').wrap('<div class="iframeDiv"></div>'); 682 683 // Module blog 684 $(".blogs-mod-latestside").each(function(k,value){ 685 $('.arrow-left',value).css({'color':'black', "pointer-events":"none"}); 686 var bajaxslider = new BAjaxSlider($(".mod-latestside-container",value),$(".arrows",value),1); 687 bajaxslider.nav.find("span").on("click",function(){ 688 bajaxslider.navigation($(this).data("dir")); 689 }); 690 setInterval( function() { 691 bajaxslider.nav.find("span.arrow.arrow-right").click(); 692 }, 8000); 693 }); 694 // Module news by category 695 $('.news-mod-cathalf').each(function(k,value){ 696 //console.log(value); 697 $('.arrow-left',value).css({"color":"black", "pointer-events":"none"}); 698 var bajaxslider = new BAjaxSlider($(".news-mod-cathalf-content",value),$(".arrows",value),4); 699 bajaxslider.nav.find("span").on("click",function(){ 700 bajaxslider.navigation($(this).data("dir")); 701 }); 702 setInterval( function() {
703 bajaxslider.nav.find("span.arrow.arrow-right").click(); 704 }, 8000); 705 }); 706 //Module news by tag 707 708 $(".news-mod-tag").each(function(k,value){ 709 $(".arrow-left",value).css({"color":"black", "pointer-events":"none"}); 710 var bajaxslider = new BAjaxSlider($(".news-mod-tagsidebar-content",value),$(".arrows",value),1); 711 bajaxslider.nav.find("span").on("click",function(){ 712 bajaxslider.navigation($(this).data("dir")); 713 }); 714 setInterval( function() { 715 bajaxslider.nav.find("span.arrow.arrow-right").click(); 716 }, 8000); 717 }); 718 //Module news photo 719 $('.news-mod-photo').each(function(k,photo){ 720 //console.log('[News.mod_photos] element found.'); 721 $('.arrow-left',photo).css({"color":"black", "pointer-events":"none"}); 722 var bajaxslider = new BAjaxSlider($(".news-mod-photo-content",photo),$(".arrows",photo),2); 723 bajaxslider.nav.find("span").on("click",function(){ 724 bajaxslider.navigation($(this).data("dir")); 725 }); 726 setInterval( function() { 727 bajaxslider.nav.find("span.arrow.arrow-right").click(); 728 }, 8000); 729 }); 730 //Module news photo 731 732 // shordcode collapse 733 $(".collapse .collapse-heading").each(function(){ 734 var _this = $(this); 735 _this.click(function(){_this.next().slideToggle("slow"); }) 736 }); 737 738 //tabs 739 var index=1; 740 $('.tabs-content').each(function(i,item){ 741 $(item).attr('id', 'tab-'+index); 742 index++; 743 }); 744 var indexli=1; 745 $('.tabs-nav a').each(function(i,itemli){ 746 $(itemli).attr('id', +indexli); 747 indexli++; 748 }); 749 750 $('.tabs').each(function(k,v){ 751 $('.tabs-content',v).hide(); 752 $('.tabs-content:first',v).show(); 753 $('.tabs-nav li:first',v).addClass('tab-active'); 754 $('.tabs-nav a',v).on('click', function(event){ 755 event.preventDefault(); 756 var id = $(this).attr('id'); 757 $('.tabs-nav li',v).removeClass('tab-active'); 758 $(this).parent().addClass('tab-active'); 759 $('.tabs-content',v).hide(); 760 $('#tab-'+id).show(); 761 }); 762 }); 763 764 if(device.is_tablet()) { 765 $('.tablet li.deeper>a').click(function(e){ 766 e.preventDefault(); 767 $(this).parent().toggleClass('opened'); 768 }); 769 $(document).click(function(e){ 770 if($('.deeper').hasClass('opened') && $(e.target).parents('.deeper').length == 0){ 771 $('.deeper').removeClass('opened'); 772 } 773 }); 774 //11.06.2019 oleg fix strange menu https://bugtracker.brilliant.in.ua/view.php?id=27481 775 // new ChildrenSplitter({ 776 // selector: '.deeper .nav-child', 777 // wrapperClass: 'deeper-section-wr', 778 // size: 3 779 // }).split(); 780 781 var buttons_location = { 782 selector: '.buttons' 783 }; 784 var search_relocator = new elementRelocator({ 785 selector: '.redmenusearch', 786 new_location: buttons_location 787 }); 788 var addoffer_relocator = new elementRelocator({ 789 selector: '.redmenubutton', 790 new_location: buttons_location 791 }); 792 793 $('#news-top').prependTo($('.firstcolumns .fcol-left .wr').first()); 794 795 if(window.matchMedia('(max-width: 1015px)').matches) { 796 search_relocator.relocate(); 797 addoffer_relocator.relocate(); 798 } 799 800 $(window).resize(function(){ 801 if(window.matchMedia('(max-width: 1015px)').matches) { 802 search_relocator.relocate(); 803 addoffer_relocator.relocate(); 804 } 805 else { 806 search_relocator.rollback(); 807 addoffer_relocator.rollback(); 808 } 809 }); 810 } 811 $(".switch2").click(function(e){ 812 e.preventDefault(); 813 if ($(this).prev().css("display") == "block") 814 { 815 $(this).prev().animate({height: "hide"}, 500); 816 $(this).removeClass("_minus"); 817 } 818 else 819 { 820 $(this).prev().animate({height: "show"}, 500); 821 $(this).addClass("_minus"); 822 } 823 }); 824 825 $('.switch').click(function(e){ 826 e.preventDefault(); 827 if ($(this).next().css('display') == 'block') 828 { 829 $(this).next().animate({height: 'hide'}, 500); 830 $(this).removeClass('_minus'); 831 } 832 else 833 { 834 $(this).next().animate({height: 'show'}, 500); 835 $(this).addClass('_minus'); 836 } 837 }); 838 839 //add Natali 840 $('.seo_readmore_btn').click(function(e){ 841 e.preventDefault(); 842 $('.seo_readmore').slideToggle('fast'); 843 $(this).toggleClass('opened'); 844 }); 845 846 if(device.is_mobile()){ 847 $(".Center").after($('.category-desc, .tag-desc')); 848 $('.moduletable_menu .deeper>a').click(function(e){ 849 e.preventDefault(); 850 if($(this).next('ul').css('display')=='none'){ 851 $(this).next('ul').slideDown(300); 852 }else{ 853 $(this).next('ul').slideUp(300); 854 } 855 }); 856 var bannerAfterSevenNews = $('.Center .news_feed').nextAll('.htmlblock.htmlblock-picture').eq(0); 857 var bannerAfterSevenNews2 = $('.Center .news_feed').nextAll('.htmlblock.htmlblock-picture').eq(1); 858 $(".Center .tab-latest .tab-latest-articles-perdate:nth-child(1) .ColumnItem:nth-child(7)").after(bannerAfterSevenNews); 859 $(".Center .tab-latest .tab-latest-articles-perdate:nth-child(2) .ColumnItem:nth-child(15)").after(bannerAfterSevenNews2); 860 //$(".Center .tab-latest .ColumnItem:nth-child(7)").after(bannerAfterSevenNews); 861 //$(".Center .tab-latest .ColumnItem:nth-child(15)").after(bannerAfterSevenNews2); 862 }; 863 864 var mywindow = $(window); 865 var menu = $('.HeaderMenu'); 866 var myHeight = $(".Wrapper_main.top_banner").outerHeight() + $(".Header").outerHeight() + $(".HeaderMenu").outerHeight(); 867 868 if($(".Wrapper_storystorynka .partnersmenu").outerHeight() > 0){ 869 myHeight = myHeight + $(".Wrapper_storystorynka .partnersmenu").outerHeight() - 1; 870 myHeightImgOld = myHeight; 871 }else if($("#footer-pusher >.Wrapper_default >.google-auto-placed").outerHeight() > 0){ 872 //myHeight = myHeight - $("#footer-pusher >.Wrapper_default >.google-auto-placed").outerHeight(); 873 myHeight = myHeight - 1; 874 myHeightImgOld = myHeight + 10; 875 }else if($("#footer-pusher >.Wrapper_default > .MainContent >.partnersmenu").outerHeight() > 0){ 876 myHeight = myHeight - 10; 877 myHeightImgOld = myHeight + 10; 878 }else{ 879 myHeight = myHeight - 1; 880 myHeightImgOld = myHeight + 10; 881 } 882 883 $(".bannerBeforeContent").delay(2000).fadeIn(200); 884 $(".bannerBeforeContent a div").css("top", myHeight + "px"); 885 $(".custom.N7_news img, .custom.N8_news img").css("top", myHeightImgOld + "px"); 886 var menu_top_pos = menu.lenght > 0 ? menu.position().top : null; 887 888 var objToStick = $(".bannerBeforeContent a div"); 889 if(objToStick.length){ 890 //var topOfObjToStick = $(objToStick).offset().top; 891 892 $(window).scroll(function () { 893 var windowScroll = $(window).scrollTop(); 894 if (menu.hasClass('fixed')){ 895 $(objToStick).css("top", "56px"); 896 } else { 897 $(objToStick).css("top", (myHeight - windowScroll) + "px"); 898 }; 899 }); 900 901 }; 902 903 if($('.left-banner').length > 1){ 904 setTimeout(function(){ 905 changeBannerImg(); 906 }, 1500); 907 }; 908 909 $('.htmlblock-picture').each(function (i) { 910 indexBannerCenter = i+1; 911 var divImg = $(this).addClass("index-" + indexBannerCenter); 912 var elBanner = divImg.find('.custom'); 913 if(elBanner.length > 1){ 914 elBanner.hide(); 915 elBanner.eq(0).show(); 916 var slider3 = new AllBannerNav({ 917 images: '.index-'+indexBannerCenter+' > .custom' 918 }); 919 }; 920 }); 921 922 923 mywindow.scroll(function () { 924 menu_top_pos_down = $('#footer-pusher').position().top - 54; 925 if ($(this).scrollTop() > menu_top_pos_down) { 926 var x = $(".Wrapper_main.top_banner").outerHeight() + $(".Header").outerHeight(); 927 var top_scroll = $(window).scrollTop() - x; 928 //$(".custom.N7_news, .custom.N8_news").css("top", top_scroll + "px"); 929 //$(".custom.N7_news img, .custom.N8_news img").css("top", myHeightImgOld + "px"); + 930 931 if (!menu.hasClass('fixed')){ 932 $('<div class="header_push" style="height:' + menu.outerHeight() + 'px;"></div>').insertBefore(menu); 933 menu.addClass('fixed'); 934 //$(".bannerBeforeContent a div").css("top", $(".HeaderMenu").outerHeight() + "px");//+ 935 $('.Header__logo_fix').removeClass('hide'); 936 $('.moduletable_menu').removeClass('show'); 937 } 938 menu_top_pos = menu_top_pos_down; 939 } else if ($(this).scrollTop() <= menu_top_pos) { 940 console.log($(this).scrollTop() + ' ' +menu_top_pos) 941 $(".custom.N7_news img, .custom.N8_news img").css("top", myHeightImgOld + "px"); 942 //$(".bannerBeforeContent a div").css("top", myHeightImgOld + "px");//+ 943 if (menu.hasClass('fixed')){ 944 $('.header_push').remove(); 945 menu.removeClass('fixed'); 946 //$(".bannerBeforeContent a div").css("top", myHeight + "px");//+ 947 $('.Header__logo_fix').addClass('hide'); 948 } 949 } 950 }); 951 952function AllBannerNav(obj){
953 this.images = document.querySelectorAll(obj.images); 954 this.rate = obj.rate || 6500; 955 var i = 0; 956 var slider = this; 957 958 /* 959 this.prev = function(){ 960 slider.images[i].classList.remove('showed'); 961 i--; 962 if(i < 0){ 963 i = slider.images.length-1; 964 } 965 slider.images[i].classList.add('showed'); 966 } 967 */ 968 969 this.next = function(){ 970 slider.images[i].style.display = 'none'; 971 i++; 972 if(i >= slider.images.length){ 973 i = 0; 974 } 975 slider.images[i].style.display = 'block'; 976 } 977 setInterval(slider.next, slider.rate); 978} 979 980function randomImg(min, max) { 981 var rand = min - 0.5 + Math.random() * (max - min + 1); 982 rand = Math.round(rand); 983 return rand; 984} 985 986function changeBannerImg() { 987 $('.left-banner').each(function (i) { 988 cur_num = i+1; 989 $(this).addClass("banner_left_elem_" + cur_num); 990 }); 991 leftDiv = $('.left-banner').length; 992 993 994 $('.right-banner').each(function (i) { 995 cur_num = i+1; 996 $(this).addClass("banner_right_elem_" + cur_num); 997 }); 998 rightDiv = $('.right-banner').length; 999 1000 $(".left-banner").hide(); 1001 $(".right-banner").hide(); 1002 1003 1004 1005 if ((leftDiv > 1) && (rightDiv > 1)){ 1006 var numdiv = randomImg(1, leftDiv); 1007 $(".banner_left_elem_" + numdiv + ", .banner_right_elem_" + numdiv).show(); 1008 //$(".banner_right_elem_" + numdiv).show(); 1009 }; 1010 console.log('bannerShowLeft '+randomImg(1, leftDiv)); 1011 1012} 1013 1014 //N6 START 1015 $('.N6_news').each(function (i) { 1016 cur_num = i+1; 1017 $(this).addClass("N6_news_elem_" + cur_num); 1018 }); 1019 N6_count = $('.N6_news').length; 1020 N6_current_banner = 1; 1021 if (N6_count>1){ 1022 setInterval(function(){ 1023 $(".N6_news").hide(); 1024 $(".N6_news_elem_" + N6_current_banner).show(); 1025 N6_current_banner++; 1026 if (N6_current_banner > N6_count){ 1027 N6_current_banner = 1; 1028 } 1029 //console.log(N6_current_banner); 1030 }, 5000); 1031 } 1032 //N6 (Р±Р°РРРРРµСÐС⹠СÐÐ ÑСÐР°РÐР° Ð ÑСâ Р»РÑÐ ÑÐ Ñ Ð Ð Ð Â° СÐСâСÐР°РРРÑСâ Рµ Ð Ð Ð ÑÐ ÐÐ ÑСÐСâÐ Ñ) FINISH 1033 1034 function show(state) { 1035 console.log('function show'); 1036 //console.log(document.getElementById('window')); 1037 document.getElementById('window').style.display = state; 1038 document.getElementById('wrap').style.display = state; 1039 window.scroll(0, 0); 1040 } 1041 1042 $('a.burger').click(function () { 1043 $(this).toggleClass('active'); 1044 $('.Header').toggleClass('active-menu'); 1045 //$('.Mob_MainSearch').slideToggle(); 1046 $('.Mob_tabs_wrap').slideToggle(); 1047 }); 1048 1049 $('.Mob_HeaderMenu_spec .title').click(function () { 1050 $('.moduletablespec_mob').slideToggle(); 1051 $(this).toggleClass('active_menu'); 1052 }); 1053 1054 $('.Mob_HeaderSearch').click(function () { 1055 $('.Header').toggleClass('active-menu'); 1056 $('.Mob_MainSearch').slideToggle(); 1057 }); 1058 $('.bannersslider').slick({ 1059 slidesToShow: 1, 1060 slidesToScroll: 1, 1061 dots: true, 1062 arrows: false, 1063 autoplay: true, 1064 autoplaySpeed: 3000, 1065 fade: true, 1066 infinite: true, 1067 }); 1068 if(device.is_mobile()) { 1069 if(document.title!='Ð ÐСâСÐР°РРРÑСâ Р° РРРµ РРР°РâÐ ÒРµРРР°!'){ 1070 //if(window.location.pathname == '/'){ 1071 1072 $('.moduletable_menu li:first > ul li:last').after('<li><a class="item commentable" for="tab-commentable">' + $('div.commentable').text() + '</a></li>'); 1073 $('.moduletable_menu li:first > ul li:last').after('<li><a class="item popular" for="tab-popular">' + $('div.popular').text() + '</a></li>'); 1074 //} 1075 $('a.commentable').click(function () { 1076 $('a.burger').toggleClass('active'); 1077 $('.Mob_tabs_wrap').slideToggle(); 1078 var top_scr = $('.news_feed').offset().top; 1079 var body = $("html, body"); 1080 if(window.location.pathname != '/'){ 1081 body.stop().animate({scrollTop: top_scr - 60}, '600'); 1082 } 1083 $('.tab-popular').hide(); 1084 $('.tab-latest').hide(); 1085 $('.tab-commentable').show(); 1086 }); 1087 $('a.popular').click(function () { 1088 $('a.burger').toggleClass('active'); 1089 $('.Mob_tabs_wrap').slideToggle(); 1090 var top_scr = $('.news_feed').offset().top; 1091 var body = $("html, body"); 1092 if(window.location.pathname != '/'){ 1093 body.stop().animate({scrollTop: top_scr - 60}, '600'); 1094 } 1095 $('.tab-latest').hide(); 1096 $('.tab-commentable').hide(); 1097 $('.tab-popular').show(); 1098 }); 1099 } 1100 $('.delivery_list').click(function(){ 1101 $(".cities_list").slideToggle('fast'); 1102 }); 1103 1104 $('ul.cities_list li').click(function(){ 1105 var tx = $(this).html(); 1106 var tv = $(this).attr('alt'); 1107 $(".cities_list").slideUp('fast'); 1108 $(".delivery_list span").html(tx); 1109 $(".delivery_text").html(tv); 1110 }); 1111 1112 } 1113 1114// facebookCounter 1115 var facebookCounter = 0; 1116 var facebookCounterCookie = parseInt(getCookie("facebookCounter")); 1117 console.log(facebookCounterCookie); 1118 1119 if (isNaN(facebookCounterCookie)) { 1120 createCookie("facebookCounter", 0); 1121 facebookCounterCookie = 0; 1122 } 1123 1124 jQuery(window).scroll(function () { 1125 var scrollTop = jQuery(document).scrollTop(); // scroll from top in pixels 1126 var contentHeight = jQuery('.MainContent').height() - 250; 1127 1128 jQuery('.facebook-close').on('click', function () { 1129 jQuery('#facebookLikeBox').hide(); 1130 createCookie("facebookCounter", 1); 1131 facebookCounterCookie = 1; 1132 }); 1133 1134 jQuery('#facebookLikeBox p').on('click', function () { 1135 jQuery('#facebookLikeBox').hide(); 1136 createCookie("facebookCounter", 1); 1137 facebookCounterCookie = 1; 1138 }); 1139 1140 //facebook show/hide 1141 if (contentHeight < (scrollTop + 50)) { 1142 if (facebookCounterCookie === 0 & facebookCounter === 0) { 1143 jQuery('#facebookLikeBox').show(); 1144 } 1145 } else {
1146 jQuery('#facebookLikeBox').slideUp(300); 1147 } 1148 ; 1149 }); 1150 1151 1152function createCookie(name, value, expires, path, domain) { 1153 var cookie = name + "=" + escape(value) + ";"; 1154 1155 if (expires) { 1156 // If it's a date 1157 if (expires instanceof Date) { 1158 // If it isn't a valid date 1159 if (isNaN(expires.getTime())) 1160 expires = new Date(); 1161 } else 1162 //expires = new Date(new Date().getTime() + parseInt(expires) * 1000 * 60 * 60 * 24); 1163 expires = new Date(new Date().getTime() + parseInt(expires) * 604800000); 1164 1165 cookie += "expires=" + expires.toGMTString() + ";"; 1166 } 1167 1168 if (path) 1169 cookie += "path=" + path + ";"; 1170 if (domain) 1171 cookie += "domain=" + domain + ";"; 1172 1173 document.cookie = cookie; 1174} 1175 1176function deleteCookie(name, path, domain) { 1177 // If the cookie exists 1178 if (getCookie(name)) 1179 createCookie(name, "", -1, path, domain); 1180} 1181 1182function getCookie(name) { 1183 var value = "; " + document.cookie; 1184 var parts = value.split("; " + name + "="); 1185 if (parts.length == 2) 1186 return parts.pop().split(";").shift(); 1187} 1188 1189 //end Natali 1190}); 1191 1192function Relocators() { 1193 this.relocators = []; 1194 1195 this.register_relocator = function(options) { 1196 this.relocators.push( 1197 new elementRelocator(options) 1198 ); 1199 }; 1200 this.relocate = function() { 1201 $.each(this.relocators, function(){ 1202 this.relocate(); 1203 }); 1204 }; 1205 this.rollback = function() { 1206 $.each(this.relocators, function(){ 1207 this.rollback(); 1208 }); 1209 }; 1210} 1211 1212function elementRelocator(options) { 1213 var _this = this; 1214 1215 this.defines = $.extend({ 1216 selector: '', 1217 new_location: { 1218 selector: '', 1219 method: undefined 1220 } 1221 }, options); 1222 1223 this.$element = $(this.defines.selector); 1224 1225 this.locationHistory = { 1226 parent: _this.$element.parent(), 1227 index: _this.$element.index(), 1228 start_location: { 1229 parent: undefined, 1230 selector: '', 1231 index: undefined 1232 }, 1233 current_location: { 1234 parent: undefined, 1235 selector: '', 1236 method: undefined, 1237 index: undefined 1238 }, 1239 init: function(options) { 1240 this.set_start_location(options); 1241 }, 1242 set_current_location: function(options) { 1243 this.current_location.parent = options.parent; 1244 this.current_location.selector = options.selector; 1245 this.current_location.index = options.index; 1246 }, 1247 set_start_location: function(options) { 1248 this.start_location.parent = options.parent; 1249 this.start_location.selector = options.selector; 1250 this.start_location.method = options.method; 1251 this.start_location.index = options.index; 1252 }, 1253 same_location: function(location) { 1254 var other_parent = this.current_location.selector != location.selector; 1255 1256 return !other_parent || 1257 ( 1258 this.current_location.selector == location.selector && 1259 this.current_location.method == location.method 1260 ) || 1261 ( 1262 this.current_location.selector == location.selector && 1263 this.current_location.index == location.index 1264 ); 1265 }, 1266 reset_current_location: function(){ 1267 this.current_location.parent = undefined; 1268 this.current_location.selector = ''; 1269 this.current_location.index = undefined; 1270 } 1271 }; 1272 1273 this.locationHistory.init({ 1274 parent: _this.$element.parent(), 1275 selector: _this.defines.selector, 1276 index: _this.$element.index() 1277 }); 1278 1279 var insert_at_index = function(index, parent, element) { 1280 if(index == 0) { 1281 element.prependTo(parent); return; 1282 } 1283 else if(parent.children().length == 0 || index > parent.children().length - 1) { 1284 element.appendTo(parent); 1285 }else{ 1286 element.insertAfter($(">:nth-child(" + index + ")", parent)); 1287 } 1288 }; 1289 1290 this.relocate = function(location) { 1291 var new_location = location || this.defines.new_location; 1292 var new_location_el = $(new_location.selector); 1293 var relocation_method = new_location.method; 1294 1295 var new_location_data = { 1296 selector: new_location.selector, 1297 method: relocation_method 1298 }; 1299 1300 if(this.locationHistory.same_location(new_location_data)){ 1301 console.log('%c[Relocation:] Relocation to same location.', 'color: green;'); 1302 return; 1303 }else{ 1304 console.log('%c[Relocation:] Relocated element "'+ this.defines.selector +'" to new location: "' + new_location.selector + '"', 'color: green;'); 1305 this.locationHistory.set_current_location({ 1306 parent: new_location_el, 1307 selector: new_location.selector, 1308 method: relocation_method 1309 }); 1310 } 1311 1312 if(new_location_el.length == 1) { 1313 if(!relocation_method) { 1314 insert_at_index( 1315 this.locationHistory.index, 1316 new_location_el, 1317 this.$element 1318 ); 1319 }else{ 1320 this.$element[relocation_method](new_location_el); 1321 } 1322 }else if(new_location_el.length > 1) { 1323 console.log('%c[Relocation:] Can not relocate element: "' + this.defines.selector + '"', 'color: red;'); 1324 console.log('%cToo many elements with selector: "' + this.defines.new_location.selector + '"', 'color: red;'); 1325 }else{ 1326 console.log('%c[Relocation:] Can not relocate element: "' + this.defines.selector + '"', 'color: red;'); 1327 console.log('%cNo elements match. ', 'color: red;'); 1328 } 1329 }; 1330 1331 this.rollback = function() { 1332 console.log('%c[Relocation:] Rollback element: "' + this.defines.selector + '"', 'color: green;'); 1333 insert_at_index( 1334 this.locationHistory.index, 1335 this.locationHistory.parent, 1336 this.$element 1337 ); 1338 this.locationHistory.reset_current_location(); 1339 }; 1340} 1341 1342function BDevice() { 1343 const 1344 MOBILE = 'm', 1345 TABLET = 't', 1346 DESKTOP = 'd'; 1347 1348 this.detect_type = function() { 1349 return getCookie('v'); 1350 }; 1351 this.is_tablet = function() { 1352 return this.detect_type() == TABLET; 1353 }; 1354 this.is_desctop = function() { 1355 return this.detect_type() == DESKTOP; 1356 }; 1357 this.is_mobile = function() { 1358 return this.detect_type() == MOBILE; 1359 }; 1360} 1361 1362$.fn.chunk = function(size) { 1363 var result = [], 1364 length = this.length, i; 1365 for(i = 0; i < length; i += size){ 1366 result.push(this.slice(i, i + size)); 1367 } 1368 return this.pushStack(result, "chunk", size); 1369}; 1370 1371function ChildrenSplitter(options) { 1372 this.options = $.extend({}, { 1373 selector: '', 1374 size: null, 1375 wrapperClass: 'parts-wrapper' 1376 }, options); 1377 1378 this.$element = $(this.options.selector); 1379 this.children = this.$element.length > 0 ? this.$element.children() : []; 1380 1381 this.split = function() { 1382 if(this.children.length > 0 && this.options.size) { 1383 this.children.chunk(this.options.size).wrap('<div class="'+ this.options.wrapperClass +'"></div>'); 1384 }else{ 1385 console.log('%c[ChildrenSpliter]: Something went wrong...', 'color: red;'); 1386 } 1387 }; 1388} 1389 1390/* 1391 * // using id and custom settings 1392 * $('#countable3').jqEasyCounter({ 1393 * 'maxChars': 50, // max number of characters 1394 * 'maxCharsWarning': 40, //max number of characters before warning is shown 1395 * 'msgFontSize': '12px', //css font size for counter 1396 * 'msgFontColor': '#000', // css font color for counter 1397 * 'msgFontFamily': 'Arial', //css font family for counter 1398 * 'msgTextAlign': 'left', //css text-align for counter (left, right, center) 1399 * 'msgWarningColor': '#F00', //css font color for warning 1400 * 'msgAppendMethod': 'insertBefore' //position of counter relative to the input element
1400(insertAfter, insertBefore) 1401 * }); 1402 */ 1403(function($) { 1404 $.fn.extend({ 1405 jqEasyCounter: function(givenOptions) { 1406 return this.each(function() { 1407 var $this = $(this), 1408 options = $.extend({ 1409 maxChars: 100, 1410 maxCharsWarning: 80, 1411 msgFontSize: '', 1412 msgFontColor: '', 1413 msgFontFamily: '', 1414 msgTextAlign: 'right', 1415 msgWarningColor: '#d46967', 1416 msgAppendMethod: 'insertAfter', 1417 msgHeading: '' 1418 }, givenOptions); 1419 1420 if (options.maxChars <= 0) 1421 return; 1422 1423 // create counter element 1424 var jqEasyCounterMsg = $("<div class=\"jqEasyCounterMsg\"> </div>"); 1425 var jqEasyCounterMsgStyle = { 1426 'font-size': options.msgFontSize, 1427 'font-family': options.msgFontFamily, 1428 'color': options.msgFontColor, 1429 'text-align': options.msgTextAlign, 1430 'width': $this.width(), 1431 'opacity': 0.7 1432 }; 1433 jqEasyCounterMsg.css(jqEasyCounterMsgStyle); 1434 // append counter element to DOM 1435 jqEasyCounterMsg[options.msgAppendMethod]($this); 1436 1437 // bind events to this element 1438 $this 1439 .bind('keydown keyup keypress', doCount) 1440 .bind('focus paste', function() { 1441 setTimeout(doCount, 10); 1442 }) 1443 .bind('blur', function() { 1444 jqEasyCounterMsg.stop().fadeTo('fast', 0.7); 1445 return false; 1446 }); 1447 1448 function doCount() { 1449 var val = $this.val(), 1450 length = val.length 1451 1452 if (length >= options.maxChars) { 1453 val = val.substring(0, options.maxChars); 1454 } 1455 ; 1456 1457 if (length >= options.maxChars) { 1458 // keep scroll bar position 1459 var originalScrollTopPosition = $this.scrollTop(); 1460 $this.val(val.substring(0, options.maxChars)); 1461 $this.scrollTop(originalScrollTopPosition); 1462 } 1463 ; 1464 1465 if (length >= options.maxCharsWarning) { 1466 jqEasyCounterMsg.css({"color": options.msgWarningColor}); 1467 } else { 1468 jqEasyCounterMsg.css({"color": options.msgFontColor}); 1469 } 1470 ; 1471 1472 jqEasyCounterMsg.html(options.msgHeading + $this.val().length + "/" + options.maxChars); 1473 jqEasyCounterMsg.stop().fadeTo('fast', 1); 1474 } 1475 ; 1476 }); 1477 } 1478 }); 1479 1480})(jQuery);
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.