1/** 2Core script to handle the entire theme and core functions 3**/ 4 5var $ = jQuery; 6 7var App = function() { 8 9 // IE mode 10 var isRTL = false; 11 var isIE9 = false; 12 var isIE10 = false; 13 var isIE = false; 14 15 var resizeHandlers = []; 16 17 // initializes main settings 18 var handleInit = function() { 19 isIE9 = !!navigator.userAgent.match(/MSIE 9.0/); 20 isIE10 = !!navigator.userAgent.match(/MSIE 10.0/); 21 isIE = navigator.userAgent.indexOf("MSIE ") > -1 || navigator.userAgent.indexOf("Trident/") > -1; 22 23 if (isIE10) { 24 $('html').addClass('ie10'); // detect IE10 version 25 } 26 27 if (isIE9) { 28 $('html').addClass('ie9'); // detect IE10 version 29 } 30 31 if (isIE) { 32 $('html').addClass('ie'); // detect IE10 version 33 } 34 }; 35 36 // runs callback functions set by Jango.addResponsiveHandler(). 37 var _runResizeHandlers = function() { 38 // reinitialize other subscribed elements 39 for (var i = 0; i < resizeHandlers.length; i++) { 40 var each = resizeHandlers[i]; 41 each.call(); 42 } 43 }; 44 45 // handle group element heights 46 var handleHeight = function() { 47 $('[data-auto-height]').each(function() { 48 var parent = $(this); 49 var items = $('[data-height]', parent); 50 var height = 0; 51 var mode = parent.attr('data-mode'); 52 var offset = parseInt(parent.attr('data-offset') ? parent.attr('data-offset') : 0); 53 54 items.each(function() { 55 if ($(this).attr('data-height') == "height") { 56 $(this).css('height', ''); 57 } else { 58 $(this).css('min-height', ''); 59 } 60 61 var height_ = (mode == 'base-height' ? $(this).outerHeight() : $(this).outerHeight(true)); 62 if (height_ > height) { 63 height = height_; 64 } 65 }); 66 67 height = height + offset; 68 69 items.each(function() { 70 if ($(this).attr('data-height') == "height") { 71 $(this).css('height', height); 72 } else { 73 $(this).css('min-height', height); 74 } 75 }); 76 77 if(parent.attr('data-related')) { 78 $(parent.attr('data-related')).css('height', parent.height()); 79 } 80 }); 81 } 82 83 // handle the layout reinitialization on window resize 84 var handleOnResize = function() { 85 var resize; 86 $(window).resize(function() { 87 if (resize) { 88 clearTimeout(resize); 89 } 90 resize = setTimeout(function() { 91 _runResizeHandlers(); 92 }, 50); // wait 50ms until window resize finishes. 93 }); 94 }; 95 96 // Handles custom checkboxes & radios using jQuery Uniform plugin 97 var handleCheckboxRadios = function() { 98 // Material design ckeckbox and radio effects 99 $('body').on('click', '.c-checkbox > label, .c-radio > label', function() { 100 var the = $(this); 101 // find the first span which is our circle/bubble 102 var el = $(this).children('span:first-child'); 103 104 // add the bubble class (we do this so it doesnt show on page load) 105 el.addClass('inc'); 106 107 // clone it 108 var newone = el.clone(true); 109 110 // add the cloned version before our original 111 el.before(newone); 112 113 // remove the original so that it is ready to run on next click 114 $("." + el.attr("class") + ":last", the).remove(); 115 }); 116 }; 117 118 // Handles Bootstrap Accordions. 119 var handleAccordions = function() { 120 $('body').on('shown.bs.collapse', '.accordion.scrollable', function(e) { 121 Jango.scrollTo($(e.target)); 122 }); 123 }; 124 125 // Handles Bootstrap Tabs. 126 var handleTabs = function() { 127 //activate tab if tab id provided in the URL 128 if (location.hash) { 129 var tabid = encodeURI(location.hash.substr(1)); 130 $('a[href="#' + tabid + '"]').parents('.tab-pane:hidden').each(function() { 131 var tabid = $(this).attr("id"); 132 $('a[href="#' + tabid + '"]').click(); 133 }); 134 $('a[href="#' + tabid + '"]').click(); 135 } 136 }; 137 138 // Handles Bootstrap Modals. 139 var handleModals = function() { 140 // fix stackable modal issue: when 2 or more modals opened, closing one of modal will remove .modal
140-open class. 141 $('body').on('hide.bs.modal', function() { 142 if ($('.modal:visible').size() > 1 && $('html').hasClass('modal-open') === false) { 143 $('html').addClass('modal-open'); 144 } else if ($('.modal:visible').size() <= 1) { 145 $('html').removeClass('modal-open'); 146 } 147 }); 148 149 // fix page scrollbars issue 150 $('body').on('show.bs.modal', '.modal', function() { 151 if ($(this).hasClass("modal-scroll")) { 152 $('body').addClass("modal-open-noscroll"); 153 } 154 }); 155 156 // fix page scrollbars issue 157 $('body').on('hide.bs.modal', '.modal', function() { 158 $('body').removeClass("modal-open-noscroll"); 159 }); 160 161 // remove ajax content and remove cache on modal closed 162 $('body').on('hidden.bs.modal', '.modal:not(.modal-cached)', function() { 163 $(this).removeData('bs.modal'); 164 }); 165 }; 166 167 // Handles Bootstrap Tooltips. 168 var handleTooltips = function() { 169 // global tooltips 170 $('.tooltips').tooltip(); 171 }; 172 173 // Handles Bootstrap Dropdowns 174 var handleDropdowns = function() { 175 /* 176 Hold dropdown on click 177 */ 178 $('body').on('click', '.dropdown-menu.hold-on-click', function(e) { 179 e.stopPropagation(); 180 }); 181 }; 182 183 var handleAlerts = function() { 184 $('body').on('click', '[data-close="alert"]', function(e) { 185 $(this).parent('.alert').hide(); 186 $(this).closest('.note').hide(); 187 e.preventDefault(); 188 }); 189 190 $('body').on('click', '[data-close="note"]', function(e) { 191 $(this).closest('.note').hide(); 192 e.preventDefault(); 193 }); 194 195 $('body').on('click', '[data-remove="note"]', function(e) { 196 $(this).closest('.note').remove(); 197 e.preventDefault(); 198 }); 199 }; 200 201 // Handle Hower Dropdowns 202 var handleDropdownHover = function() { 203 $('[data-hover="dropdown"]').not('.hover-initialized').each(function() { 204 $(this).dropdownHover(); 205 $(this).addClass('hover-initialized'); 206 }); 207 }; 208 209 // Handles Bootstrap Popovers 210 211 // last popep popover 212 var lastPopedPopover; 213 214 var handlePopovers = function() { 215 $('.popovers').popover(); 216 217 // close last displayed popover 218 219 $(document).on('click.bs.popover.data-api', function(e) { 220 if (lastPopedPopover) { 221 lastPopedPopover.popover('hide'); 222 } 223 }); 224 }; 225 226 // Fix input placeholder issue for IE9 and IE10 227 var handleFixInputPlaceholderForIE = function() { 228 //fix html5 placeholder attribute for ie9 & ie10 229 if (isIE9 || isIE10) { 230 // this is html5 placeholder fix for inputs, inputs with placeholder-no-fix class will be skipped(e.g: we need this for password fields) 231 $('input[placeholder]:not(.placeholder-no-fix), textarea[placeholder]:not(.placeholder-no-fix)').each(function() { 232 var input = $(this); 233 234 if (input.val() === '' && input.attr("placeholder") !== '') { 235 input.addClass("placeholder").val(input.attr('placeholder')); 236 } 237 238 input.focus(function() { 239 if (input.val() == input.attr('placeholder')) { 240 input.val(''); 241 } 242 }); 243 244 input.blur(function() { 245 if (input.val() === '' || input.val() == input.attr('placeholder')) { 246 input.val(input.attr('placeholder')); 247 } 248 }); 249 }); 250 } 251 }; 252 253 //* END:CORE HANDLERS *// 254 255 return { 256 257 //main function to initiate the theme 258 init: function() { 259 //IMPORTANT!!!: Do not modify the core handlers call order. 260 261 //Core handlers 262 handleHeight(); 263 this.addResizeHandler(handleHeight); // handle auto calculating height on window resize 264 265 handleInit(); // initialize core variables 266 handleOnResize(); // set and handle responsive 267 268 //UI Component handlers 269 //handleAnimate(); // handle animate 270 handleCheckboxRadios() // handle checkbox & radios 271 handleAlerts(); //handle closabled alerts 272 handleDropdowns(); // handle dropdowns 273 handleTabs(); // handle tabs 274 handleTooltips(); // handle bootstrap tooltips 275 handlePopovers(); // handles bootstrap popovers 276 handleAccordions(); //handles accordions 277 handleModals(); // handle modals 278 279 // Hacks 280 handleFixInputPlaceholderForIE(); //IE9 & IE10 input placeholder issue fix 281 }, 282 283 changeLogo: function(filename) { 284 var path = '../assets/jango/img/layout/logos/' + filename + '.png'; 285 $('.c-brand img.c-desktop-logo').attr('src', path); 286 }, 287 288 //public function to remember last opened popover that needs to be closed on click
289 setLastPopedPopover: function(el) { 290 lastPopedPopover = el; 291 }, 292 293 //public function to add callback a function which will be called on window resize 294 addResizeHandler: function(func) { 295 resizeHandlers.push(func); 296 }, 297 298 //public functon to call _runresizeHandlers 299 runResizeHandlers: function() { 300 _runResizeHandlers(); 301 }, 302 303 // wrJangoer function to scroll(focus) to an element 304 scrollTo: function(el, offeset) { 305 var pos = (el && el.size() > 0) ? el.offset().top : 0; 306 307 if (el) { 308 if ($('body').hasClass('page-header-fixed')) { 309 pos = pos - $('.page-header').height(); 310 } 311 pos = pos + (offeset ? offeset : -1 * el.height()); 312 } 313 314 $('html,body').animate({ 315 scrollTop: pos 316 }, 'slow'); 317 }, 318 319 // function to scroll to the top 320 scrollTop: function() { 321 Jango.scrollTo(); 322 }, 323 324 325 //public function to initialize the fancybox plugin 326 initFancybox: function() { 327 handleFancybox(); 328 }, 329 330 //public helper function to get actual input value(used in IE9 and IE8 due to placeholder attribute not supported) 331 getActualVal: function(el) { 332 el = $(el); 333 if (el.val() === el.attr("placeholder")) { 334 return ""; 335 } 336 return el.val(); 337 }, 338 339 //public function to get a paremeter by name from URL 340 getURLParameter: function(paramName) { 341 var searchString = window.location.search.substring(1), 342 i, val, params = searchString.split("&"); 343 344 for (i = 0; i < params.length; i++) { 345 val = params[i].split("="); 346 if (val[0] == paramName) { 347 return unescape(val[1]); 348 } 349 } 350 return null; 351 }, 352 353 // check for device touch support 354 isTouchDevice: function() { 355 try { 356 document.createEvent("TouchEvent"); 357 return true; 358 } catch (e) { 359 return false; 360 } 361 }, 362 363 // To get the correct viewport width based on http://andylangton.co.uk/articles/javascript/get-viewport-size-javascript/ 364 getViewPort: function() { 365 var e = window, 366 a = 'inner'; 367 if (!('innerWidth' in window)) { 368 a = 'client'; 369 e = document.documentElement || document.body; 370 } 371 372 return { 373 width: e[a + 'Width'], 374 height: e[a + 'Height'] 375 }; 376 }, 377 378 // generate unique ID 379 getUniqueID: function(prefix) { 380 return 'prefix_' + Math.floor(Math.random() * (new Date()).getTime()); 381 }, 382 383 // check IE9 mode 384 isIE: function() { 385 return isIE; 386 }, 387 388 // check IE9 mode 389 isIE9: function() { 390 return isIE9; 391 }, 392 393 // check IE9 mode 394 isIE10: function() { 395 return isIE10; 396 }, 397 398 // responsive breakpoints 399 getBreakpoint: function(size) { 400 // bootstrap responsive breakpoints 401 var sizes = { 402 'xs': 480, // extra small 403 'sm': 768, // small 404 'md': 992, // medium 405 'lg': 1200 // large 406 }; 407 408 return sizes[size] ? sizes[size] : 0; 409 } 410 }; 411 412}();
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.