2014-11-12 11:00:18 +00:00
|
|
|
(function($) {
|
2014-06-04 08:55:57 +00:00
|
|
|
|
2014-11-12 11:00:18 +00:00
|
|
|
"use strict"
|
2015-01-06 07:22:41 +00:00
|
|
|
|
2014-11-12 11:00:18 +00:00
|
|
|
function init () {
|
2015-01-06 07:22:41 +00:00
|
|
|
var doc = document;
|
|
|
|
|
|
|
|
var orbit = {
|
|
|
|
// Cross browser add class function
|
|
|
|
addClass : function(el, className) {
|
|
|
|
if( el.classList ) {
|
|
|
|
el.classList.add(className);
|
|
|
|
} else {
|
|
|
|
el.className += ' ' + className;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// Cross browser has class function
|
|
|
|
hasClass : function(el, cls) {
|
|
|
|
return (' ' + el.className + ' ').indexOf(' ' + cls + ' ') > -1;
|
|
|
|
},
|
|
|
|
// Add class name to the menu item when its children items are more than eight
|
|
|
|
addMegaDropdownClass : function(el, len) {
|
|
|
|
for( var i = 0; i < el.length; i++ ) {
|
|
|
|
if( el[i].children.length > len ) {
|
|
|
|
orbit.addClass(el[i].parentNode, 'mega-dropdown');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// Append caret to menu item if it has dropdown
|
|
|
|
addCaret : function() {
|
|
|
|
var list = doc.querySelectorAll('.page_menu.level_2');
|
|
|
|
for( var i = 0, len = list.length; i < len; i++ ) {
|
|
|
|
var node = doc.createElement('span');
|
|
|
|
node.className = 'caret';
|
|
|
|
list[i].parentNode.appendChild(node);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// Add link and cursor class name on element that has data-link attribute
|
|
|
|
addLinkOnADBanner : function(els) {
|
|
|
|
$.each(els, function(i) {
|
|
|
|
if ($(this).data('link') !== "" && !$(this).hasClass('youtube')) {
|
|
|
|
$(this).on('click', function() {
|
|
|
|
var target = $(this).data('target'),
|
|
|
|
link = $(this).data('link');
|
|
|
|
if (target === '_blank') {
|
|
|
|
window.open(link, target);
|
|
|
|
} else {
|
|
|
|
window.location.href = link;
|
|
|
|
}
|
|
|
|
}).addClass('cursor');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
// Announcement text truncation
|
|
|
|
truncation : function (el, len) {
|
2014-12-08 06:54:40 +00:00
|
|
|
for( var i = 0; i < el.length; i ++ ) {
|
|
|
|
if ( el[i].firstChild !== null ) {
|
2015-01-06 07:22:41 +00:00
|
|
|
if( el[i].firstChild.length > len ) {
|
|
|
|
var newStr = el[i].firstChild.nodeValue,
|
|
|
|
newStr = newStr.substring(0, len) + '...'
|
2014-12-08 06:54:40 +00:00
|
|
|
el
|
|
|
|
.eq(i)
|
2015-01-06 07:22:41 +00:00
|
|
|
.text(newStr);
|
2014-12-08 06:54:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-01-06 07:22:41 +00:00
|
|
|
},
|
|
|
|
// Sitemenu dropdown
|
|
|
|
sitemenuDropdown : function() {
|
|
|
|
var el = doc.querySelectorAll('.sitemenu__list.level-2');
|
|
|
|
for( var i = 0, len = el.length; i < len; i++ ) {
|
|
|
|
if( el[i].hasChildNodes() ) {
|
|
|
|
var caret = doc.createElement('span');
|
|
|
|
caret.className = 'sitemenu___dropdown-toggle fa fa-caret-down';
|
|
|
|
caret.setAttribute('data-toggle', 'dropdown');
|
|
|
|
|
|
|
|
el[i].parentNode.insertBefore(caret, el[i]);
|
|
|
|
orbit.addClass(el[i], 'dropdown-menu');
|
|
|
|
}
|
|
|
|
}
|
2014-12-08 06:54:40 +00:00
|
|
|
}
|
|
|
|
}
|
2014-11-12 11:00:18 +00:00
|
|
|
|
2015-01-06 07:22:41 +00:00
|
|
|
var plugin = {
|
|
|
|
// RWD image resize script
|
|
|
|
bullEye : function() {
|
|
|
|
$(".bullseye").bullseye({
|
|
|
|
fadeEffect: false
|
|
|
|
});
|
2014-12-08 06:54:40 +00:00
|
|
|
}
|
2014-11-12 11:00:18 +00:00
|
|
|
}
|
|
|
|
|
2015-01-06 07:22:41 +00:00
|
|
|
// Specific functions that will be running on homepage
|
|
|
|
if( doc.body.getAttribute('data-module') === 'home' ) {
|
2014-11-12 11:00:18 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-01-06 07:22:41 +00:00
|
|
|
// Functions that will be running on every page
|
|
|
|
orbit.sitemenuDropdown();
|
|
|
|
plugin.bullEye();
|
2014-06-04 08:55:57 +00:00
|
|
|
}
|
2014-11-12 11:00:18 +00:00
|
|
|
|
2015-01-06 07:22:41 +00:00
|
|
|
|
2014-11-12 11:00:18 +00:00
|
|
|
$(document).ready(function($) {
|
|
|
|
init();
|
|
|
|
});
|
|
|
|
|
|
|
|
}(jQuery));
|