1/** 2Core script to handle the entire theme and core functions 3**/ 4 5 6var Metronic = function() { 7 8 // IE mode 9 var isRTL = false; 10 var isIE8 = false; 11 var isIE9 = false; 12 var isIE10 = false; 13 14 var resizeHandlers = []; 15 16 var assetsPath = '../../assets/'; 17 18 var globalImgPath = assetsPath + 'global/img/'; 19 20 var globalPluginsPath = assetsPath + 'global/plugins/'; 21 22 var loadedResources = {}; 23 24 // theme layout color set 25 26 var brandColors = { 27 'blue': '#89C4F4', 28 'red': '#F3565D', 29 'green': '#1bbc9b', 30 'purple': '#9b59b6', 31 'grey': '#95a5a6', 32 'yellow': '#F8CB00' 33 }; 34 35 // initializes main settings 36 var handleInit = function() { 37 38 if ($('body').css('direction') === 'rtl') { 39 isRTL = true; 40 } 41 42 isIE8 = !!navigator.userAgent.match(/MSIE 8.0/); 43 isIE9 = !!navigator.userAgent.match(/MSIE 9.0/); 44 isIE10 = !!navigator.userAgent.match(/MSIE 10.0/); 45 46 if (isIE10) { 47 $('html').addClass('ie10'); // detect IE10 version 48 } 49 50 if (isIE10 || isIE9 || isIE8) { 51 $('html').addClass('ie'); // detect IE10 version 52 } 53 }; 54 55 // runs callback functions set by Metronic.addResponsiveHandler(). 56 var _runResizeHandlers = function() { 57 // reinitialize other subscribed elements 58 for (var i = 0; i < resizeHandlers.length; i++) { 59 var each = resizeHandlers[i]; 60 each.call(); 61 } 62 }; 63 64 // handle the layout reinitialization on window resize 65 var handleOnResize = function() { 66 var resize; 67 if (isIE8) { 68 var currheight; 69 $(window).resize(function() { 70 if (currheight == document.documentElement.clientHeight) { 71 return; //quite event since only body resized not window. 72 } 73 if (resize) { 74 clearTimeout(resize); 75 } 76 resize = setTimeout(function() { 77 _runResizeHandlers(); 78 }, 50); // wait 50ms until window resize finishes. 79 currheight = document.documentElement.clientHeight; // store last body client height 80 }); 81 } else { 82 $(window).resize(function() { 83 if (resize) { 84 clearTimeout(resize); 85 } 86 resize = setTimeout(function() { 87 _runResizeHandlers(); 88 }, 50); // wait 50ms until window resize finishes. 89 }); 90 } 91 }; 92 93 // Handles portlet tools & actions 94 var handlePortletTools = function() { 95 // handle portlet remove 96 $('body').on('click', '.portlet > .portlet-title > .tools > a.remove', function(e) { 97 e.preventDefault(); 98 $(this).closest(".portlet").remove(); 99 if ($('body').hasClass('page-portlet-fullscreen')) { 100 $('body').removeClass('page-portlet-fullscreen'); 101 } 102 }); 103 104 // handle portlet fullscreen 105 $('body').on('click', '.portlet > .portlet-title .fullscreen', function(e) { 106 e.preventDefault(); 107 var portlet = $(this).closest(".portlet"); 108 if (portlet.hasClass('portlet-fullscreen')) { 109 $(this).removeClass('on'); 110 portlet.removeClass('portlet-fullscreen'); 111 $('body').removeClass('page-portlet-fullscreen'); 112 portlet.children('.portlet-body').css('height', 'auto'); 113 } else { 114 var height = Metronic.getViewPort().height - 115 portlet.children('.portlet-title').outerHeight() - 116 parseInt(portlet.children('.portlet-body').css('padding-top')) - 117 parseInt(portlet.children('.portlet-body').css('padding-bottom')); 118 119 $(this).addClass('on'); 120 portlet.addClass('portlet-fullscreen'); 121 $('body').addClass('page-portlet-fullscreen'); 122 portlet.children('.portlet-body').css('height', height); 123 } 124 }); 125 126 $('body').on('click', '.portlet > .portlet-title > .tools > a.reload', function(e) { 127 e.preventDefault(); 128 var el = $(this).closest(".portlet").children(".portlet-body"); 129 var url = $(this).attr("data-url"); 130 var error = $(this).attr("data-error-display"); 131 if (url) { 132 Metronic.blockUI({ 133 target: el, 134 animate: true, 135 overlayColor: 'none' 136 }); 137 $.ajax({
138 type: "GET", 139 cache: false, 140 url: url, 141 dataType: "html", 142 success: function(res) { 143 Metronic.unblockUI(el); 144 el.html(res); 145 DilTara(el); // yüklenince diltara fonksiyonu cagirilsin 146 TemplateTara(el); 147 }, 148 error: function(xhr, ajaxOptions, thrownError) { 149 Metronic.unblockUI(el); 150 var msg = 'Error on reloading the content. Please check your connection and try again.'; 151 if (error == "toastr" && toastr) { 152 toastr.error(msg); 153 } else if (error == "notific8" && $.notific8) { 154 $.notific8('zindex', 11500); 155 $.notific8(msg, { 156 theme: 'ruby', 157 life: 3000 158 }); 159 } else { 160 alert(msg); 161 } 162 } 163 }); 164 } else { 165 // for demo purpose 166 Metronic.blockUI({ 167 target: el, 168 animate: true, 169 overlayColor: 'none' 170 }); 171 window.setTimeout(function() { 172 Metronic.unblockUI(el); 173 }, 1000); 174 } 175 }); 176 177 178 179 180 181 182 183 184 // load ajax data on page init 185 $('.portlet .portlet-title a.reload[data-load="true"]').click(); 186 187 188 189 190 191 192 $('body').on('click', '.popajax', function(e) { 193 $('.popover').remove(); 194 e.preventDefault(); 195 var elm=$(this); 196 $(this).attr('style'); 197 $.get(elm.attr('href'),function(d) { 198 elm.popover({content: d,"html": true,trigger:'click'}).popover('show'); 199 }); 200 201 }); 202 203 204 205 $('body').on('click', '.portlet > .portlet-title > .tools > .collapse, .portlet .portlet-title > .tools > .expand', function(e) { 206 e.preventDefault(); 207 var el = $(this).closest(".portlet").children(".portlet-body"); 208 if ($(this).hasClass("collapse")) { 209 $(this).removeClass("collapse").addClass("expand"); 210 el.slideUp(200); 211 } else { 212 $(this).removeClass("expand").addClass("collapse"); 213 el.slideDown(200); 214 } 215 }); 216 }; 217 218 // Handles custom checkboxes & radios using jQuery Uniform plugin 219 var handleUniform = function() { 220 if (!$().uniform) { 221 return; 222 } 223 var test = $("input[type=checkbox]:not(.toggle, .make-switch, .icheck), input[type=radio]:not(.toggle, .star, .make-switch, .icheck)"); 224 if (test.size() > 0) { 225 test.each(function() { 226 if ($(this).parents(".checker").size() === 0) { 227 $(this).show(); 228 $(this).uniform(); 229 } 230 }); 231 } 232 }; 233 234 // Handles custom checkboxes & radios using jQuery iCheck plugin 235 var handleiCheck = function() { 236 if (!$().iCheck) { 237 return; 238 } 239 240 $('.icheck').each(function() { 241 var checkboxClass = $(this).attr('data-checkbox') ? $(this).attr('data-checkbox') : 'icheckbox_minimal-grey'; 242 var radioClass = $(this).attr('data-radio') ? $(this).attr('data-radio') : 'iradio_minimal-grey'; 243 244 if (checkboxClass.indexOf('_line') > -1 || radioClass.indexOf('_line') > -1) { 245 $(this).iCheck({ 246 checkboxClass: checkboxClass, 247 radioClass: radioClass, 248 insert: '<div class="icheck_line-icon"></div>' + $(this).attr("data-label") 249 }); 250 } else { 251 $(this).iCheck({ 252 checkboxClass: checkboxClass, 253 radioClass: radioClass 254 }); 255 } 256 }); 257 }; 258 259 // Handles Bootstrap switches 260 var handleBootstrapSwitch = function() { 261 if (!$().bootstrapSwitch) { 262 return; 263 } 264 $('.make-switch').bootstrapSwitch(); 265 }; 266 267 // Handles Bootstrap Accordions. 268 var handleAccordions = function() { 269 $('body').on('shown.bs.collapse', '.accordion.scrollable', function(e) { 270 Metronic.scrollTo($(e.target)); 271 }); 272 }; 273 274 // Handles Bootstrap Tabs. 275 var handleTabs = function() { 276 //activate tab if tab id provided in the URL 277 if (location.hash) { 278 var tabid = location.hash.substr(1); 279 $('a[href="#' + tabid + '"]').parents('.tab-pane:hidden').each(function() { 280 var tabid = $(this).attr("id"); 281 $('a[href="#' + tabid + '"]').click(); 282 }); 283 $('a[href="#' + tabid + '"]').click(); 284 } 285 }; 286 287 // Handles Bootstrap Modals. 288 var handleModals = function() { 289 // fix stackable modal issue: when 2 or more modals opened, closing one of modal will remove .modal
289-open class. 290 $('body').on('hide.bs.modal', function() { 291 if ($('.modal:visible').size() > 1 && $('html').hasClass('modal-open') === false) { 292 $('html').addClass('modal-open'); 293 } else if ($('.modal:visible').size() <= 1) { 294 $('html').removeClass('modal-open'); 295 } 296 }); 297 298 $('body').on('show.bs.modal', '.modal', function() { 299 if ($(this).hasClass("modal-scroll")) { 300 $('body').addClass("modal-open-noscroll"); 301 } 302 }); 303 304 $('body').on('hide.bs.modal', '.modal', function() { 305 $('body').removeClass("modal-open-noscroll"); 306 }); 307 }; 308 309 // Handles Bootstrap Tooltips. 310 var handleTooltips = function() { 311 // global tooltips 312 $('.tooltips').tooltip(); 313 314 // portlet tooltips 315 $('.portlet > .portlet-title .fullscreen').tooltip({container: 'body', title: 'Fullscreen'}); 316 $('.portlet > .portlet-title > .tools > .reload').tooltip({container: 'body', title: 'Reload'}); 317 $('.portlet > .portlet-title > .tools > .remove').tooltip({container: 'body', title: 'Remove'}); 318 $('.portlet > .portlet-title > .tools > .config').tooltip({container: 'body', title: 'Settings'}); 319 $('.portlet > .portlet-title > .tools > .collapse, .portlet > .portlet-title > .tools > .expand').tooltip({container: 'body', title: 'Collapse/Expand'}); 320 }; 321 322 // Handles Bootstrap Dropdowns 323 var handleDropdowns = function() { 324 /* 325 Hold dropdown on click 326 */ 327 $('body').on('click', '.dropdown-menu.hold-on-click', function(e) { 328 e.stopPropagation(); 329 }); 330 }; 331 332 var handleAlerts = function() { 333 $('body').on('click', '[data-close="alert"]', function(e) { 334 $(this).parent('.alert').hide(); 335 e.preventDefault(); 336 }); 337 }; 338 339 // Handle Hower Dropdowns 340 var handleDropdownHover = function() { 341 $('[data-hover="dropdown"]').not('.hover-initialized').each(function() { 342 $(this).dropdownHover(); 343 $(this).addClass('hover-initialized'); 344 }); 345 }; 346 347 // Handles Bootstrap Popovers 348 349 // last popep popover 350 var lastPopedPopover; 351 352 var handlePopovers = function() { 353 $('.popovers').popover(); 354 355 // close last displayed popover 356 357 $(document).on('click.bs.popover.data-api', function(e) { 358 if (lastPopedPopover) { 359 lastPopedPopover.popover('hide'); 360 } 361 }); 362 }; 363 364 // Handles scrollable contents using jQuery SlimScroll plugin. 365 var handleScrollers = function() { 366 Metronic.initSlimScroll('.scroller'); 367 }; 368 369 // Handles Image Preview using jQuery Fancybox plugin 370 var handleFancybox = function() { 371 if (!jQuery.fancybox) { 372 return; 373 } 374 375 if ($(".fancybox-button").size() > 0) { 376 $(".fancybox-button").fancybox({ 377 groupAttr: 'data-rel', 378 prevEffect: 'none', 379 nextEffect: 'none', 380 closeBtn: true, 381 helpers: { 382 title: { 383 type: 'inside' 384 } 385 } 386 }); 387 } 388 }; 389 390 // Fix input placeholder issue for IE8 and IE9 391 var handleFixInputPlaceholderForIE = function() { 392 //fix html5 placeholder attribute for ie7 & ie8 393 if (isIE8 || isIE9) { // ie8 & ie9 394 // this is html5 placeholder fix for inputs, inputs with placeholder-no-fix class will be skipped(e.g: we need this for password fields) 395 $('input[placeholder]:not(.placeholder-no-fix), textarea[placeholder]:not(.placeholder-no-fix)').each(function() { 396 var input = $(this); 397 398 if (input.val() === '' && input.attr("placeholder") !== '') { 399 input.addClass("placeholder").val(input.attr('placeholder')); 400 } 401 402 input.focus(function() { 403 if (input.val() == input.attr('placeholder')) { 404 input.val(''); 405 } 406 }); 407 408 input.blur(function() { 409 if (input.val() === '' || input.val() == input.attr('placeholder')) { 410 input.val(input.attr('placeholder')); 411 } 412 }); 413 }); 414 } 415 }; 416 417 // Handle Select2 Dropdowns 418 var handleSelect2 = function() { 419 if ($().select2) { 420 $('.select2me').select2({ 421 placeholder: "Select", 422 allowClear: true 423 }); 424 } 425 }; 426 427 //* END:CORE HANDLERS *// 428 429 return { 430 431 //main function to initiate the theme 432 init: function() { 433 //IMPORTANT!!!: Do not modify the core handlers call order. 434 435 //Core handlers 436 handleInit(); // initialize core variables 437 handleOnResize(); // set and handle responsive 438 439 //UI Component handlers 440 handleUniform(); // hanfle custom radio & checkboxes 441 handleiCheck(); // handles custom icheck radio and checkboxes 442 handleBootstrapSwitch(); // handle bootstrap switch plugin 443 handleScrollers(); // handles slim scrolling contents 444 handleFancybox(); // handle fancy box 445 handleSelect2(); // handle custom Select2 dropdowns 446 handlePortletTools(); // handles portlet action bar functionality(refresh, configure, toggle, remove) 447 handleAlerts(); //handle closabled alerts 448 handleDropdowns(); // handle dropdowns 449 handleTabs(); // handle tabs 450 handleTooltips(); // handle bootstrap tooltips 451 handlePopovers(); // handles bootstrap popovers 452 handleAccordions(); //handles accordions 453 handleModals(); // handle modals 454 455 // Hacks 456 handleFixInputPlaceholderForIE(); //IE8 & IE9 input placeholder issue fix 457 }, 458
459 //main function to initiate core javascript after ajax complete 460 initAjax: function() { 461 handleUniform(); // handles custom radio & checkboxes 462 handleiCheck(); // handles custom icheck radio and checkboxes 463 handleBootstrapSwitch(); // handle bootstrap switch plugin 464 handleDropdownHover(); // handles dropdown hover 465 handleScrollers(); // handles slim scrolling contents 466 handleSelect2(); // handle custom Select2 dropdowns 467 handleFancybox(); // handle fancy box 468 handleDropdowns(); // handle dropdowns 469 handleTooltips(); // handle bootstrap tooltips 470 handlePopovers(); // handles bootstrap popovers 471 handleAccordions(); //handles accordions 472 }, 473 474 //public function to remember last opened popover that needs to be closed on click 475 setLastPopedPopover: function(el) { 476 lastPopedPopover = el; 477 }, 478 479 //public function to add callback a function which will be called on window resize 480 addResizeHandler: function(func) { 481 resizeHandlers.push(func); 482 }, 483 484 //public functon to call _runresizeHandlers 485 runResizeHandlers: function() { 486 _runResizeHandlers(); 487 }, 488 489 // wrMetronicer function to scroll(focus) to an element 490 scrollTo: function(el, offeset) { 491 var pos = (el && el.size() > 0) ? el.offset().top : 0; 492 493 if (el) { 494 if ($('body').hasClass('page-header-fixed')) { 495 pos = pos - $('.page-header').height(); 496 } 497 pos = pos + (offeset ? offeset : -1 * el.height()); 498 } 499 500 $('html,body').animate({ 501 scrollTop: pos 502 }, 'slow'); 503 }, 504 505 initSlimScroll: function(el) { 506 $(el).each(function() { 507 if ($(this).attr("data-initialized")) { 508 return; // exit 509 } 510 511 var height; 512 513 if ($(this).attr("data-height")) { 514 height = $(this).attr("data-height"); 515 } else { 516 height = $(this).css('height'); 517 } 518 519 $(this).slimScroll({ 520 allowPageScroll: true, // allow page scroll when the element scroll is ended 521 size: '7px', 522 color: ($(this).attr("data-handle-color") ? $(this).attr("data-handle-color") : '#bbb'), 523 wrapperClass: ($(this).attr("data-wrapper-class") ? $(this).attr("data-wrapper-class") : 'slimScrollDiv'), 524 railColor: ($(this).attr("data-rail-color") ? $(this).attr("data-rail-color") : '#eaeaea'), 525 position: isRTL ? 'left' : 'right', 526 height: height, 527 alwaysVisible: ($(this).attr("data-always-visible") == "1" ? true : false), 528 railVisible: ($(this).attr("data-rail-visible") == "1" ? true : false), 529 disableFadeOut: true 530 }); 531 532 $(this).attr("data-initialized", "1"); 533 }); 534 }, 535 536 destroySlimScroll: function(el) { 537 $(el).each(function() { 538 if ($(this).attr("data-initialized") === "1") { // destroy existing instance before updating the height 539 $(this).removeAttr("data-initialized"); 540 $(this).removeAttr("style"); 541 542 var attrList = {}; 543 544 // store the custom attribures so later we will reassign. 545 if ($(this).attr("data-handle-color")) { 546 attrList["data-handle-color"] = $(this).attr("data-handle-color"); 547 } 548 if ($(this).attr("data-wrapper-class")) { 549 attrList["data-wrapper-class"] = $(this).attr("data-wrapper-class"); 550 } 551 if ($(this).attr("data-rail-color")) { 552 attrList["data-rail-color"] = $(this).attr("data-rail-color"); 553 } 554 if ($(this).attr("data-always-visible")) { 555 attrList["data-always-visible"] = $(this).attr("data-always-visible"); 556 } 557 if ($(this).attr("data-rail-visible")) { 558 attrList["data-rail-visible"] = $(this).attr("data-rail-visible"); 559 } 560 561 $(this).slimScroll({ 562 wrapperClass: ($(this).attr("data-wrapper-class") ? $(this).attr("data-wrapper-class") : 'slimScrollDiv'), 563 destroy: true 564 }); 565 566 var the = $(this); 567 568 // reassign custom attributes 569 $.each(attrList, function(key, value) { 570 the.attr(key, value); 571 }); 572 573 } 574 }); 575 }, 576 577 // function to scroll to the top 578 scrollTop: function() { 579 Metronic.scrollTo(); 580 }, 581 582 // wrMetronicer function to block element(indicate loading) 583 blockUI: function(options) { 584 options = $.extend(true, {}, options); 585 var html = ''; 586 if (options.animate) { 587 html = '<div class="loading-message ' + (options.boxed ? 'loading-message-boxed' : '') + '">' + '<div class="block-spinner-bar"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div>' + '</div>'; 588 } else if (options.iconOnly) { 589 html = '<div class="loading-message ' + (options.boxed ? 'loading-message-boxed' : '') + '"><img src="' + this.getGlobalImgPath() + 'loading-spinner-grey.gif" align=""></div>'; 590 } else if (options.textOnly) { 591 html = '<div class="loading-message ' + (options.boxed ? 'loading-message-boxed' : '') + '"><span> ' + (options.message ? options.message : 'LOADING...') + '</span></div>'; 592 } else { 593 html = '<div class="loading-message ' + (options.boxed ? 'loading-message-boxed' : '') + '"><img src="' + this.getGlobalImgPath() + 'loading-spinner-grey.gif" align=""><span> ' + (options.message ? options.message : 'LOADING...') + '</span></div>'; 594 } 595 596 if (options.target) { // element blocking 597 var el = $(options.target); 598 if (el.height() <= ($(window).height())) { 599 options.cenrerY = true; 600 } 601 el.block({ 602 message: html, 603 baseZ: options.zIndex ? options.zIndex : 1000, 604 centerY: options.cenrerY !== undefined ? options.cenrerY : false, 605 css: { 606 top: '10%', 607 border: '0', 608 padding: '0', 609 backgroundColor: 'none' 610 }, 611 overlayCSS: { 612 backgroundColor: options.overlayColor ? options.overlayColor : '#555', 613 opacity: options.boxed ? 0.05 : 0.1, 614 cursor: 'wait' 615 } 616 }); 617 } else { // page blocking 618 $.blockUI({ 619 message: html, 620 baseZ: options.zIndex ? options.zIndex : 1000, 621 css: { 622 border: '0', 623 padding: '0', 624 backgroundColor: 'none' 625 }, 626 overlayCSS: { 627 backgroundColor: options.overlayColor ? options.overlayColor : '#555', 628 opacity: options.boxed ? 0.05 : 0.1, 629 cursor: 'wait' 630 } 631 }); 632 } 633 }, 634 635 // wrMetronicer function to un-block element(finish loading) 636 unblockUI: function(target) { 637 if (target) { 638 $(target).unblock({ 639 onUnblock: function() { 640 $(target).css('position', ''); 641 $(target).css('zoom', ''); 642 } 643 }); 644 } else { 645 $.unblockUI(); 646 } 647 }, 648 649 startPageLoading: function(options) { 650 if (options && options.animate) { 651 $('.page-spinner-bar').remove(); 652 $('body').append('<div class="page-spinner-bar"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div>'); 653 } else { 654 $('.page-loading').remove(); 655 $('body').append('<div class="page-loading"><img src="' + this.getGlobalImgPath() + 'loading-spinner-grey.gif"/> <span>' + (options && options.message ? options.message : 'Loading...') + '</span></div>'); 656 } 657 }, 658 659 stopPageLoading: function() { 660 $('.page-loading, .page-spinner-bar').remove(); 661 }, 662 663 alert: function(options) { 664 665 options = $.extend(true, { 666 container: "", // alerts parent container(by default placed after the page breadcrumbs) 667 place: "append", // append or prepent in container 668 type: 'success', // alert's type 669 message: "", // alert's message 670 close: true, // make alert closable 671 reset: true, // close all previouse alerts first 672 focus: true, // auto scroll to the alert after shown 673 closeInSeconds: 0, // auto close after defined seconds 674 icon: "" // put icon before the message 675 }, options); 676 677 var id = Metronic.getUniqueID("Metronic_alert"); 678 679 var html = '<div id="' + id + '" class="Metronic-alerts alert alert-' + options.type + ' fade in">' + (options.close ? '<button type="button" class="close" data-dismiss="alert" aria-hidden="true"></button>' : '') + (options.icon !== "" ? '<i class="fa-lg fa fa-' + options.icon + '"></i> ' : '') + options.message + '</div>'; 680 681 if (options.reset) { 682 $('.Metronic-alerts').remove(); 683 } 684 685 if (!options.container) { 686 if ($('body').hasClass("page-container-bg-solid")) { 687 $('.page-title').after(html); 688 } else { 689 if ($('.page-bar').size() > 0) { 690 $('.page-bar').after(html); 691 } else { 692 $('.page-breadcrumb').after(html); 693 } 694 } 695 } else { 696 if (options.place == "append") { 697 $(options.container).append(html); 698 } else { 699 $(options.container).prepend(html); 700 } 701 } 702 703 if (options.focus) { 704 Metronic.scrollTo($('#' + id)); 705 } 706 707 if (options.closeInSeconds > 0) { 708 setTimeout(function() { 709 $('#' + id).remove(); 710 }, options.closeInSeconds * 1000); 711 } 712 713 return id; 714 }, 715 716 // initializes uniform elements 717 initUniform: function(els) { 718 if (els) { 719 $(els).each(function() { 720 if ($(this).parents(".checker").size() === 0) { 721 $(this).show(); 722 $(this).uniform(); 723 } 724 }); 725 } else { 726 handleUniform(); 727 } 728 }, 729 730 //wrMetronicer function to update/sync jquery uniform checkbox & radios 731 updateUniform: function(els) { 732 $.uniform.update(els); // update the uniform checkbox & radios UI after the actual input control state changed 733 }, 734 735 //public function to initialize the fancybox plugin 736 initFancybox: function() { 737 handleFancybox(); 738 }, 739 740 //public helper function to get actual input value(used in IE9 and IE8 due to placeholder attribute not supported) 741 getActualVal: function(el) { 742 el = $(el); 743 if (el.val() === el.attr("placeholder")) { 744 return ""; 745 } 746 return el.val(); 747 }, 748 749 //public function to get a paremeter by name from URL 750 getURLParameter: function(paramName) { 751 var searchString = window.location.search.substring(1), 752 i, val, params = searchString.split("&"); 753 754 for (i = 0; i < params.length; i++) { 755 val = params[i].split("="); 756 if (val[0] == paramName) { 757 return unescape(val[1]); 758 } 759 } 760 return null; 761 }, 762 763 // check for device touch support 764 isTouchDevice: function() { 765 try { 766 document.createEvent("TouchEvent"); 767 return true; 768 } catch (e) { 769 return false; 770 } 771 }, 772 773 // To get the correct viewport width based on http://andylangton.co.uk/articles/javascript/get-viewport-size-javascript/ 774 getViewPort: function() { 775 var e = window, 776 a = 'inner'; 777 if (!('innerWidth' in window)) { 778 a = 'client'; 779 e = document.documentElement || document.body; 780 } 781 782 return { 783 width: e[a + 'Width'], 784 height: e[a + 'Height'] 785 }; 786 }, 787 788 getUniqueID: function(prefix) { 789 return 'prefix_' + Math.floor(Math.random() * (new Date()).getTime()); 790 }, 791 792 // check IE8 mode 793 isIE8: function() { 794 return isIE8; 795 }, 796 797 // check IE9 mode 798 isIE9: function() { 799 return isIE9; 800 }, 801 802 //check RTL mode 803 isRTL: function() { 804 return isRTL; 805 }, 806 807 getAssetsPath: function() { 808 return assetsPath; 809 }, 810 811 setAssetsPath: function(path) { 812 assetsPath = path; 813 }, 814 815 setGlobalImgPath: function(path) { 816 globalImgPath = assetsPath + path; 817 }, 818 819 getGlobalImgPath: function() { 820 return globalImgPath; 821 }, 822 823 setGlobalPluginsPath: function(path) { 824 globalPluginsPath = assetsPath + path; 825 }, 826 827 getGlobalPluginsPath: function() { 828 return globalPluginsPath; 829 }, 830 831 // get layout color code by color name 832 getBrandColor: function(name) { 833 if (brandColors[name]) { 834 return brandColors[name]; 835 } else { 836 return ''; 837 } 838 }, 839 840 loadResources: function(resources, callback) { 841 var counter = 0; 842 var loaded = 0; 843 844 for(var i in resources) { 845 var resource = resources[i];
846 847 if (!loadedResources[resource.path]) { 848 var el; 849 loadedResources[resource.path] = true; 850 if (resource.type === 'js') { 851 counter++; 852 var body = document.getElementsByTagName("body")[0]; 853 el = document.createElement("script"); 854 el.type = "text/javascript"; 855 el.src = resource.path; 856 // do callback only based on scripts 857 if (callback) { 858 el.onload = function(){ 859 loaded++; 860 if (loaded === counter) { 861 callback(); 862 } 863 }; 864 } 865 body.appendChild(el); 866 } else if (resource.type === 'css') { 867 var head = document.getElementsByTagName("head")[0]; 868 el = document.createElement("link"); 869 el.type = "text/css"; 870 el.href = resource.path; 871 head.appendChild(el); 872 } 873 874 875 } 876 } 877 } 878 }; 879 880}();
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.