/*********************************************************************** * 3M.com Corporate JavaScript v 4.12 * Copyright (c) 3M 2012. All rights reserved * Last Modified: 02/09/2012 * Asset ID: 1273678258924 * Authors: @A1RQLZZ, @US338674 * to see unminified version view /3MContentRetrievalAPI/BlobServlet?locale=en_US&lmd=1307134823000&assetId=1273678258924&assetType=MMM_Image&blobAttribute=ThumbnailImage ************************************************************************/ function getUrlVars() { //function to extract parameters from URL var vars = [], urlHash, urlHashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'), i; for (i = 0; i < urlHashes.length; i = i + 1) { urlHash = urlHashes[i].split('='); vars.push(urlHash[0]); vars[urlHash[0]] = urlHash[1]; } return vars; } var urlHash = getUrlVars(); function $debug(msg, param){ //debug function (message to write to log, parameter to enable (default is debug=corpJS) if (!param) { var param = 'corpJS'; } if (urlHash.debug) { if (urlHash.debug.indexOf(param) != -1) { if (window.console && window.console.log) window.console.log(msg); } } }; $debug('Start Corp JS'); function readMetatagValue(tagname) { $debug('Read MetatagValue: ' + tagname); // rolled back for v4 temporarily var MetaTagList, MetaName, MetaContent, MetaTags, Success, i; // Initializiation of some variables MetaTags = ""; Success = 0; if (document.all) { MetaTagList=document.all.tags("meta"); } else if (document.documentElement) { MetaTagList=document.getElementsByTagName("meta"); } var ListLength = MetaTagList.length; for (i = 0; i < ListLength; i++) { MetaName = MetaTagList[i].name; if (MetaName == tagname) { Success = 1; return "" + MetaTagList[i].content; } } if (Success === 0) { return "No Meta Tag Found"; } } function clearCookies() { $debug('Clearing Cookies'); //CLEARS LTPATOKEN AND WPSJSESSION COOKIES document.cookie = 'LtpaToken=clear; expires=Thu, 2 Aug 2001 20:47:11 UTC; path=/; domain=.' + document.domain; document.cookie = 'WPSJSESSIONID=clear; expires=Thu, 2 Aug 2001 20:47:11 UTC; path=/;'; } function setActiveTabs(string, id) { $debug('setActiveTabs - This function is deprecated, please contact Corporate eBusiness'); } function setActiveTabs_dep(string, id) { //this will soon be deprecated $debug('Setting Active Tab (soon to be deprecated!): string=' + string + ', id=' + id); if (window.location.href.indexOf(string) !== -1) { jQuery(id).addClass("selected"); } else { jQuery(id).removeClass("selected"); } } function changePSNimage(string, id) { $debug('Changing Background Image of PSN: string=' + string + ', id=' + id); var newstr; //if string ends in / remove it if (string.charAt(string.length-1) == ("/")) { newstr = string.slice(0,-1); $debug('Removing last / from string so it does not break the implementation') $debug('string is now: ' + newstr); } else { newstr = string; } if (window.location.href.indexOf(newstr) !== -1) { jQuery('#psnwrap').css('background-image', 'url("/3MContentRetrievalAPI/BlobServlet?assetId=' + id + '&assetType=MMM_Image&blobAttribute=ImageFile&fallback=true")'); } } //CSS Browser Selector v0.4.0 (Nov 02, 2010) http://rafael.adm.br/css_browser_selector function css_browser_selector(u){var ua=u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1},g='gecko',w='webkit',s='safari',o='opera',m='mobile',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3.6')?g+' ff3 ff3_6':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('blackberry')?m+' blackberry':is('android')?m+' android':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?m+' j2me':is('iphone')?m+' iphone':is('ipod')?m+' ipod':is('ipad')?m+' ipad':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win'+(is('windows nt 6.0')?' vista':''):is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; // Corporate Tab Code -- Optimize or deprecate. IE5 = NN6 = false; if (document.all) { IE5 = true; } else if (document.getElementById) { NN6 = true; } function showDiv(what, which, numdivs) { $debug('ShowDiv: what=' + what + ', which=' + which + ', numdivs' + numdivs); var fullImage = document.getElementById("tab" + which), current, current2; // TURN OFF ALL LAYERS AND/OR TABS for (i = 0; i < numdivs; i = i + 1) { if (IE5) { eval("document.all." + what + i + ".style.display='none'"); } if (NN6) { eval("document.getElementById('" + what + i + "').style.display='none'"); } if (what === "table") { current = document.getElementById("tab" + i); current.className = ''; fullImage = document.getElementById("tab" + i); } } // GO BACK THROUGH AND TURN ON THE DESIRED LAYER AND/OR TABS if (IE5) { eval("document.all." + what + which + ".style.display='block'"); } if (NN6) { eval("document.getElementById('" + what + which + "').style.display='inline'"); } if (what === "table") { current2 = document.getElementById("tab" + which); current2.className = 'current'; fullImage = document.getElementById("tab" + which); } } function redirect(obj, pnumId, referrerId ) { $debug('Firing Redirect: obj=' + obj + ', pnumId=' + pnumId + ', referrerId=' + referrerId); MLTAstring = "http://www3.3m.com/metrics/redirect.jsp?"; MLTAstring += "pnum=" + pnumId; MLTAstring += "&referrer=" + referrerId + "&target="; MLTAstring += encodeURIComponent(document.all[obj.sourceIndex].href); document.all[obj.sourceIndex].href = MLTAstring; } /************************************************************************ * END Utility Functions ************************************************************************/ /************************************************************************ * 3M.com Theme Core Area ************************************************************************/ //default LSN Settings var $lsnSettings = { "actuatorOff" : "/wps/themes/html/3M.com/images/lsnoff.gif", "actuatorOn" : "/wps/themes/html/3M.com/images/lsnon.gif", "actuator1" : "/wps/themes/html/3M.com/images/lsnpg.gif", "actuatorLock" : "/wps/themes/html/3M.com/images/lsnlock.gif" } function setActuators(nav) { $debug('Firing setActuators: nav=' + nav); //THIS FUNCTION CAN BE OPTIMIZED??? var lis = nav.getElementsByTagName('li'), menudone = [], li, childMenu, parentMenu, a, actuator, selected, i, lastVisHidden, img; $debug('SetActuators: List Length = ' + lis.length); for (i = 0; i < lis.length; i = i + 1) { li = lis[i]; childMenu = li.getElementsByTagName('ul')[0]; selected = (li.className.indexOf('selected') !== -1) ? true : false; lastVisHidden = (li.className.indexOf('lastVis') !== -1) ? true : false; if (selected || lastVisHidden) { parentMenu = li.parentNode; while (parentMenu.nodeName === 'UL' || parentMenu.nodeName === 'LI') { if (parentMenu.nodeName === 'UL') { parentMenu.style.display = 'block'; } if (parentMenu.nodeName === 'LI') { parentMenu.getElementsByTagName('img')[0].src = $lsnSettings.actuatorLock; parentMenu.getElementsByTagName('img')[0].style.cursor = 'default'; parentMenu.className += ' locked'; } parentMenu = parentMenu.parentNode; } } if (childMenu && menudone[i] !== true) { actuator = document.createElement('a'); /* actuator.style.position = 'absolute'; actuator.style.left = '-13px'; actuator.style.top = '3px'; actuator.style.zIndex = '5'; actuator.style.backgroundColor = 'transparent'; actuator.style.cursor = 'pointer'; */ actuator.className += ' dontshow actuator'; img = document.createElement('img'); (selected || lastVisHidden) ? img.setAttribute('src', $lsnSettings.actuatorOn) : img.setAttribute('src', $lsnSettings.actuatorOff); actuator.appendChild(img); li.insertBefore(actuator, li.getElementsByTagName('a')[0]); li.getElementsByTagName('a')[0].style.backgroundImage = 'none'; li.getElementsByTagName('a')[1].style.backgroundImage = 'none'; li.style.position = 'relative'; if (selected) { childMenu.style.display = 'block'; } else { childMenu.style.display = 'none'; } if (lastVisHidden) { childMenu.style.display = 'block'; } menudone[i] = true; } } } jQuery(document).ready(function () { //Page is fully loaded $debug('CorpJS: Document is ready'); try { $debug('CorpJS: Hiding Empty Nav Items'); jQuery('#mmmlsnwrap h5').filter(function(){ if (jQuery.trim(jQuery(this).text()) == '') { jQuery(this).addClass('emptylabel'); } }); } catch (e) { $debug('CorpJS: Hiding Empty Nav Items FAILED: ' + e.message); } $debug('Loading LSNify'); try { (function($){ $.fn.LSNify = function($$options){ $debug('Entering LSNify'); // build main settings before element iteration var $settings = $.extend({}, $.fn.LSNify.defaults, $$options); jQuery('.actuator').remove(); if ($settings.iconSet !== null) { $debug('LSNify: Overriding Default Icons to ' + $settings.iconSet + ' set'); switch ($settings.iconSet) { case 'white': $lsnSettings.actuatorOff = '/wps/themes/html/3M.com/images/lsnoffwht.gif'; $lsnSettings.actuatorOn = '/wps/themes/html/3M.com/images/lsnonwht.gif'; $lsnSettings.actuator1 = '/wps/themes/html/3M.com/images/lsnpgwht.gif'; $lsnSettings.actuatorLock = '/wps/themes/html/3M.com/images/lsnlockwht.gif'; jQuery('#mmmlsnwrap UL LI.collapse A').css('background-image','url("/wps/themes/html/3M.com/images/lsnoffwht.gif")'); jQuery('#mmmlsnwrap UL LI.firstLI A').css('background-image','url("/wps/themes/html/3M.com/images/lsnonwht.gif")'); jQuery('#mmmlsnwrap UL LI.expanded A').css('background-image','url("/wps/themes/html/3M.com/images/lsnlockwht.gif")'); jQuery('#mmmlsnwrap UL LI.collapse LI A, #mmmlsnwrap UL LI A, #mmmlsnwrap UL LI.lastVis A, #mmmlsnwrap UL LI.selected A, #mmmlsnwrap UL LI.firstLI UL A, #mmmlsnwrap UL LI.expanded LI A, #mmmlsnwrap UL LI.expanded UL LI.expanded UL LI A, #mmmlsnwrap UL LI.expanded UL LI.expanded UL LI A, #mmmlsnwrap UL LI.selected A').css('background-image','url("/wps/themes/html/3M.com/images/lsnpgwht.gif")'); break; case 'gray': $lsnSettings.actuatorOff = '/wps/themes/html/3M.com/images/lsnoffgr.gif'; $lsnSettings.actuatorOn = '/wps/themes/html/3M.com/images/lsnongr.gif'; $lsnSettings.actuator1 = '/wps/themes/html/3M.com/images/lsnpggr.gif'; $lsnSettings.actuatorLock = '/wps/themes/html/3M.com/images/lsnlockgr.gif'; jQuery('#mmmlsnwrap UL LI.collapse A').css('background-image','url("/wps/themes/html/3M.com/images/lsnoffgr.gif")'); jQuery('#mmmlsnwrap UL LI.firstLI A').css('background-image','url("/wps/themes/html/3M.com/images/lsnongr.gif")'); jQuery('#mmmlsnwrap UL LI.expanded A').css('background-image','url("/wps/themes/html/3M.com/images/lsnlockgr.gif")'); jQuery('#mmmlsnwrap UL LI.collapse LI A, #mmmlsnwrap UL LI A, #mmmlsnwrap UL LI.lastVis A, #mmmlsnwrap UL LI.selected A, #mmmlsnwrap UL LI.firstLI UL A, #mmmlsnwrap UL LI.expanded LI A, #mmmlsnwrap UL LI.expanded UL LI.expanded UL LI A, #mmmlsnwrap UL LI.expanded UL LI.expanded UL LI A, #mmmlsnwrap UL LI.selected A').css('background-image','url("/wps/themes/html/3M.com/images/lsnpggr.gif")'); break; case 'dark-gray': $lsnSettings.actuatorOff = '/wps/themes/html/3M.com/images/lsnoffdkgr.gif'; $lsnSettings.actuatorOn = '/wps/themes/html/3M.com/images/lsnondkgr.gif'; $lsnSettings.actuator1 = '/wps/themes/html/3M.com/images/lsnpgdkgr.gif'; $lsnSettings.actuatorLock = '/wps/themes/html/3M.com/images/lsnlockdkgr.gif'; jQuery('#mmmlsnwrap UL LI.collapse A').css('background-image','url("/wps/themes/html/3M.com/images/lsnoffdkgr.gif")'); jQuery('#mmmlsnwrap UL LI.firstLI A').css('background-image','url("/wps/themes/html/3M.com/images/lsnondkgr.gif")'); jQuery('#mmmlsnwrap UL LI.expanded A').css('background-image','url("/wps/themes/html/3M.com/images/lsnlockdkgr.gif")'); jQuery('#mmmlsnwrap UL LI.collapse LI A, #mmmlsnwrap UL LI A, #mmmlsnwrap UL LI.lastVis A, #mmmlsnwrap UL LI.selected A, #mmmlsnwrap UL LI.firstLI UL A, #mmmlsnwrap UL LI.expanded LI A, #mmmlsnwrap UL LI.expanded UL LI.expanded UL LI A, #mmmlsnwrap UL LI.expanded UL LI.expanded UL LI A, #mmmlsnwrap UL LI.selected A').css('background-image','url("/wps/themes/html/3M.com/images/lsnpgdkgr.gif")'); break; } } if ($settings.contextualNav == true) { $debug('Firing Contextual Nav'); try { jQuery('#mmmlsnwrap h5').css({ 'border-top': 'none', 'padding-top': '1px' }); jQuery('#mmmlsnwrap h5').not(jQuery('#mmmlsnwrap ul:has(.selected)').prev()).css({ 'display': 'none' }); jQuery('#mmmlsnwrap h5:has(.selected)').css({ 'display': 'block' }); jQuery('#mmmlsnwrap h5.selected').css({ 'display': 'block' }); jQuery('#mmmlsnwrap>ul:not(:has(.selected))').not(jQuery('.selected').next()).css({ 'display': 'none' }); jQuery('#mmmlsnwrap a.activator').css({ 'top': '0px' }); if (!jQuery('#mmmlsnwrap h5:has(.selected)') && !jQuery('#mmmlsnwrap h5.selected')) { jQuery('a[href="' + jQuery('#cShellBcrumb a').last().attr('href') + '"]').last().parent().show().next().show(); } if ($settings.cap == false){ try { $debug('Contextual Nav Cap Hide'); jQuery('#mmmlsnwrap h4:first a').hide(); } catch (e) { $debug('Contextual Nav Cap Hide FAILED: ' + e.message); } } } catch (e) { $debug('Contextual Nav FAILED: ' + e.message); } } try { var menuElement = jQuery('#mmmlsnwrap'); if (menuElement.length > 0) { setActuators(document.getElementById('mmmlsnwrap')); //call left hand navigation actions }; } catch (e) { $debug('Call to Set Actuators Failed: ' + e.message); } // iterate and reformat each matched element - this is where you perform on your object. return this.each(function(){ $this = jQuery(this); }); // set the plugin defaults $.fn.LSNify.defaults = { "iconSet": null, "contextualNav": false, "cap": true }; } })(jQuery); } catch (e) { $debug('Loading LSNify Failed: ' + e.message); } try { $debug('Loading Placeholdize Plug-in'); //Placeholdize Plug-in from https://github.com/romac/jQuery.placeHoldize (function ($) {$.fn.placeHoldize = (function () {var supportsPlaceholder = (function (elem) {return !!(elem.placeholder === '')&&!!(elem.placeholder !== undefined);})(document.createElement('input'));function _placeHoldize(force){var $this=$(this);if(!force&&(supportsPlaceholder||!$this.attr('placeholder'))&&!$this.is('textarea')){return;}var placeHolder=$this.attr('placeholder');if($this.val().length<=0||$this.val()==placeHolder){$this.val('');$this.removeAttr('placeholder').addClass('placeholder-visible');$this.val(placeHolder);}else {$this.removeClass('placeholder-visible').addClass('placeholder-hidden');}$this.addClass('placeholdized');$this.focus(function(){var $this=$(this);if($this.val()===placeHolder){$this.val('');$this.removeClass('placeholder-visible').addClass('placeholder-hidden');}});$this.blur(function(){var $this=$(this);if($this.val()===''){$this.val(placeHolder);$this.removeClass('placeholder-hidden').addClass('placeholder-visible');}else {$this.removeClass('placeholder-visible').addClass('placeholder-hidden');}});}function _emptyFormOnSubmit($elements){var $forms=$elements.closest('form');$forms.submit(function(){var $this=$(this);if($this.data('placeHoldize.submitHandlerCalled')){return;}$this.find('.placeholder-visible').val('').data('placeHoldize.submitHandlerCalled',true);});return true;}return function(force){this.each(function(){_placeHoldize.call(this,force);});_emptyFormOnSubmit(this);return this;};})();})(jQuery); } catch (e){ $debug('Loading Placeholdize FAILED: ' + e.message); } try { $debug('Loading Scrollbar Height Fix Plug-in'); //Fix Scrollbar Height Plugin http://www.seangw.com/wordpress/index.php/plugins/fix-scrollbar-height-jquery-plugin/ (function($){$.fn.fixScrollbarHeight=function(){var winHeight=$(window).height();var docHeight=$("body>div").height();var scrollWidth=getScrollerWidth();if(docHeight 0) { setActuators(document.getElementById('mmmlsnwrap')); //call left hand navigation actions }; } catch (e) { $debug('Call to Set Actuators Failed: ' + e.message); } try {$debug('CSS Browser Selector Triggered: ' + navigator.userAgent); css_browser_selector(navigator.userAgent);} catch (e) {$debug('CSS Browser Selector Failed: ' + e.message);} try {$debug('Fix Scrollbar Height Triggered'); jQuery(document).fixScrollbarHeight();} catch (e) {$debug('Fix ScrollbarHeight Failed: ' + e.message);} try {$debug('Placeholder Text Triggered'); jQuery('input[placeholder], textarea[placeholder]').placeHoldize();} catch (e) {$debug('Placeholdize Failed: ' + e.message);} try {$debug('Button 1 Trigger'); jQuery(".primarybutton,.secondarybutton,.tertiarybutton").button();} catch (e) {$debug('Primary - Tertiary Buttons Failed: ' + e.message);} try {$debug('Button 2 Trigger'); jQuery(".productsearchbutton").button({text: false, icons: {primary: "ui-icon-search"}}).addClass('secondarybutton');} catch (e) {$debug('Product Buttons Failed: ' + e.message);} try {$debug('Carousel Left Trigger'); jQuery(".carouselleftbutton").button({text: false, icons: {primary: "ui-icon-triangle-1-w"}}).addClass('secondarybutton');} catch (e) {$debug('Carousel Left Button Failed: ' + e.message);} try {$debug('Carousel Right Trigger'); jQuery(".carouselrightbutton").button({text: false, icons: {primary: "ui-icon-triangle-1-e"}}).addClass('secondarybutton');} catch (e) {$debug('Carousel Right Button Failed: ' + e.message);} try {$debug("3M Tabs Triggered"); jQuery(".tabs3m").tabs();} catch (e) {$debug("Tabs Failed: "+e.message);} try {$debug('Accordion'); jQuery(".accordion3m").accordion({autoHeight: false, clearStyle: true, icons: {header: "ui-icon-plus", headerSelected: "ui-icon-minus"}, collapsible: true, navigation: true});} catch (e) {$debug('Accordion Failed: ' + e.message);} try { $debug('Mobile link cookie setting Triggered'); if (jQuery('.mobileLink').length) { $debug('There is a mobile link, FYI'); jQuery('.mobileLink').click(function(){ //set mobile pref = mobile; should this blow away the cookie? document.cookie="mobilePref=mobile; path=/; domain=." + (document.domain).substr(document.domain.indexOf('.') + 1); }); } } catch (e) { $debug('Setting mobile link cookie failed: ' + e.message); } try { if (jQuery('.desktopLink').length) { $debug('There is a desktop link, FYI'); jQuery('.desktopLink').click(function(){ //set mobile pref = desktop document.cookie="mobilePref=desktop; path=/; domain=." + (document.domain).substr(document.domain.indexOf('.') + 1); }); } } catch (e) { $debug('Setting desktop link cookie failed: ' + e.message); } try { $debug('seperating admin links'); $adminlinks = jQuery('.adminlinks').detach(); $pershello = jQuery('#personalization p').detach(); $perslinks = jQuery('#personalization ul').detach(); jQuery('#personalization').append($adminlinks).append($perslinks).append($pershello); $persblock = jQuery('#personalization').detach(); jQuery('#masterwrap').prepend($persblock); jQuery('#masterwrap').addClass('persTop'); if ((jQuery('#psnwrap').css("display") !== "none") && (jQuery('#mmmheader').css('background-image').search('header_bg_full') > 0)) { jQuery('#mmmheader').addClass('psnOn'); } } catch (e) { $debug('Seperating Admin Links FAILED: ' + e.message); } jQuery('.actuator').live('click', function(){ $debug('Actuator Clicked: ' + jQuery(this).next().text()); var li = this.parentNode; if (li.className.indexOf('locked') !== -1) { $debug('Actuator Debug: Parent Class = Locked'); return; } else { $debug('Actuator Debug: Parent Class != Locked'); childMenu = li.getElementsByTagName('ul')[0]; $debug('Actuator Debug: Child Menu: ' + childMenu); $debug('Actuator Debug: Child Menu Display: ' + childMenu.style.display); if (childMenu.style.display === 'block' || childMenu.style.display === '') { jQuery(childMenu).slideUp('fast'); this.getElementsByTagName('img')[0].src = $lsnSettings.actuatorOff; $debug('Actuator Debug: Slide Up, Src=' + $lsnSettings.actuatorOff); } else { jQuery(childMenu).slideDown('fast'); this.getElementsByTagName('img')[0].src = $lsnSettings.actuatorOn; $debug('Actuator Debug: Slide Down, Src=' + $lsnSettings.actuatorOn); } } }); // this is the base framerwork for creation of simple javascript dropdowns on the PSN ;(function (global) { jQuery.fn.hoverIntent = function(f,g) { // default configuration options var cfg = { sensitivity: 1, interval: $settings.mouseOverSensitivity, timeout: $settings.mouseOutSensitiivty } // override configuration options with user supplied object cfg = jQuery.extend(cfg, g ? { over: f, out: g } : f ) // instantiate variables // cX, cY = current X and Y position of mouse, updated by mousemove event // pX, pY = previous X and Y position of mouse, set by mouseover and polling interval var cX, cY, pX, pY // A private function for getting mouse position var track = function(ev) { cX = ev.pageX cY = ev.pageY } // A private function for comparing current and previous mouse position var compare = function(ev,ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t) // compare mouse positions to see if they've crossed the threshold if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) { jQuery(ob).unbind("mousemove",track) // set hoverIntent state to true (so mouseOut can be called) ob.hoverIntent_s = 1 return cfg.over.apply(ob,[ev]) } else { // set previous coordinates for next time pX = cX pY = cY // use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs) ob.hoverIntent_t = setTimeout( function(){compare(ev, ob)} , cfg.interval ) } } // A private function for delaying the mouseOut function var delay = function(ev,ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t) ob.hoverIntent_s = 0 return cfg.out.apply(ob,[ev]) } // A private function for handling mouse 'hovering' var handleHover = function(e) { // copy objects to be passed into t (required for event object to be passed in IE) var ev = jQuery.extend({},e) var ob = this // cancel hoverIntent timer if it exists if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t) } // if e.type == "mouseenter" if (e.type == "mouseenter") { // set "previous" X and Y position based on initial entry point pX = ev.pageX pY = ev.pageY // update "current" X and Y position based on mousemove jQuery(ob).bind("mousemove",track) // start polling interval (self-calling timeout) to compare mouse coordinates over time if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob)} , cfg.interval )} // else e.type == "mouseleave" } else { // unbind expensive mousemove event jQuery(ob).unbind("mousemove",track) // if hoverIntent state is true, then call the mouseOut function after the specified delay if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob)} , cfg.timeout )} } } // bind the function to the two event listeners return this.bind('mouseenter',handleHover).bind('mouseleave',handleHover) } //////////////////////// //END HOVERINTENT //////////////////////// var JSONdata,linkElements,listItem,linkText,settings //initialize retreval of JSON jQuery.fn.dropdownJSON = function () { try { $debug('trying initializing dropdownJSON'); return this.each(function () { jQuery(this).data('dropdownJSON', new JSONdata(jQuery(this))); }) } catch (e) { $debug('initializing dropdownJSON FAILED: ' + e.message); } } jQuery.fn.createNavInteraction = function($$options) { try { function dropdowns_Callback(){ $debug('dropdown creation default callback called'); } function dropdowns_Error(){ $debug('dropdown creation error called'); } $debug('trying setting PSN defaults'); var PSN_defaults = { "enable": true, "animation": true, "jsonLink":null, "dropdownWidth":null, "mouseOverSensitivity":50, "mouseOutSensitiivty":300, "speed":150, "dropdowns_callback": dropdowns_Callback, "dropdowns_error": dropdowns_Error } $settings = jQuery.extend(PSN_defaults, $$options) //console.log($settings.animation + ' run this 0 -- the defaults are created here') return this.each(function() { jQuery(this).data('navInteraction', new navInteraction(jQuery(this), $settings)) }) } catch (e) { $debug('setting PSN defaults FAILED: ' + e.message); } } // Initialize all dropdown elements on page, after page is ready jQuery.dropdownJSON = function () { try { $debug('trying running dropdownJSON'); jQuery(function () { jQuery('#psnwrap').dropdownJSON() }) } catch (e) { $debug('running dropdownJSON FAILED: ' + e.message); } } jQuery.createNavInteraction = function($$options) { try { $debug('running createNavInteraction'); jQuery(function () { //console.log('method createNavInteraction is running') }) $settings.dropdowns_callback(); } catch (e) { $debug('running createNavInteraction FAILED: ' + e.message); $settings.dropdowns_error(); } } navInteraction = function() { try { $debug('trying running navInteraction'); var items this.createHoverInteraction($settings) } catch (e) { $debug('running navInteraction FAILED: ' + e.message); } } //jQuery('#psninnerwrap').append(items) JSONdata = function () { try { $debug('trying running JSONdata') var items this.getjsonURL() // will empty the psn if there is js detected // otherwise there's hard markup in the code } catch (e) { $debug('running JSONdata FAILED: ' + e.message); } } JSONdata.prototype = { // need to get the json URL getjsonURL: function() { try { $debug('trying running getjsonURL') var metaLang, metaCoverage, metaLangCoverage, jsonURL, linkRel, linkRelString, linkAttrElements // parse through each list item tha has a link linkAttrElements = new Array() jQuery("#psn li").each(function (i){ // if there is a class psnsecondary ignore it if(!jQuery(this).hasClass('psnsecondary')){ // make our empty object // find the attributes if (jQuery(this).find('a').attr('data-psn')) { linkRel = jQuery(this).find('a').attr('data-psn') $debug('adding ' + linkRel + ' to our object','dropdowns') // add those data-psn attributes to our object linkAttrElements.push(linkRel) } else { $debug('data-psn attribute does not seem to be in place','dropdowns') } } }) metaLang = jQuery('meta[name|=DC_language]').attr('content') metaCoverage = jQuery('meta[name|=DC_coverage]').attr('content') //if any meta value is undefined we need to catch them before populating the JSON if(typeof metaLang !== 'undefined' || typeof metaCoverage !== 'undefined') { metaLangCoverage = '?locale='+metaLang+'_'+metaCoverage+'&a=Nav' $debug('dropdown: page language = '+ metaLang + ' and country = ' + metaCoverage,'dropdowns') } else { metaLangCoverage = '' } // compile our final string //jsonURL = "http://solutions.3m.com/wps/portal/!ut/p/c1/jY5BDoIwFETPwgn-76c0skRFWkJAbarAhnRBCImAC2M8vmVnjKgzyzeTPKjBdbT3vrO3fhrtBUqoRXNMZWgC8rEwKkAlUp9lUYxFSI5XLzzheoOUHRjPUbq5_887L8jsuGJsJWKGJCRfZyeFyfbXW7djYzScZ-nloaQ3_kFy5t80Zo4LiRByOQ0tXAdTPlS_7yLPewK6GLeB/dl2/d1/L0lJayEvUUd3QndNQSEvWUJwMXdBISEvNl9SSkg5VTUyMzBPVUk1MEk2SjMxTEFFME85Mi9KU09OJTBSb290/" if (typeof themeJSON !== 'undefined') { linkRelString = themeJSON + metaLangCoverage+'&uniqueNames='+linkAttrElements.join(',') $debug('using the following URL to get the JSON content: ' + linkRelString) } if ($settings.jsonLink !== null) { linkRelString = $settings.jsonLink } //console.log(linkRelString) this.pulljson(linkRelString) } catch (e) { $debug('running getjsonURL FAILED: ' + e.message) } }, pulljson: function(linkRelString) { $debug('trying running pulljson') if ($settings.enable == true) { //$debug('Settings.enable = true') if (jQuery.browser.msie == true && jQuery.browser.version == '6.0') { $debug('Did not fire dropdown code due to being IE6'); return(false); } else { $debug('Fired dropdown code because this is not IE6'); var jsonLinkTitle //jQuery('#psn').empty() // we need to detect current navigation before emptying it // also to append new items to existing items // if name == name append new children if existant // -- we need to loop through each list item in the navigation instead of JSON // if name !== name add the parent currNav = jQuery('#psn') initiateJSONparse(linkRelString) } } function initiateJSONparse(linkRelString) { try { $debug('trying running initiateJSONparse') jQuery.ajax({ dataType: "json", url: linkRelString, context: document.body, success: function(data){ $debug('AJAX call succeeded. Calling parseJSONdata right after this.');parseJSONdata(data,linkRelString) }, error: function(request,error){ $debug('AJAX call for dropdowns failed.') if (error == "timeout") { $debug("The AJAX request timed out; status on the request URL was: " + request.status); } else { $debug("Other AJAX ERROR: " + error + "; status on the request URL was: " + request.status); } } }) } catch (e) { $debug('running initiateJSONparse FAILED: ' + e.message) } } function parseJSONdata(data,linkRelSring) { try { $debug('trying running parseJSONdata') linkElements = {} jQuery("#psn li").each(function (i){ listItem = jQuery(this) linkText = listItem.find('a').attr('data-psn') if(!listItem.hasClass('psnsecondary')){ //add the link elements into the empty object to pull for later use linkElements[linkText] = listItem $debug('#psn li ' + i + ' = ' + linkText,'dropdowns') } else { $debug('#psn li ' + i + ' has a class of psnsecondary','dropdowns') } }) jQuery.each(data.navItems, function(j, data) { //get the title from the json objects jsonLinkTitle = data.UniqueName $debug('jsonLinkTitle ' + j + ' = '+jsonLinkTitle,'dropdowns') //jsonLinkLength = data.children.length // if there is a new element if (linkElements[jsonLinkTitle]) { $debug('trying adding elements to the dropdown','dropdowns') if(el = linkElements[jsonLinkTitle]) { //add new objects to the list item now appendNewLinks(el, data) //console.log('currently in the loop and '+ linkText +' DOES NOT have a class already of "mmmhasdropdown"') } } else { $debug('there is no JSON section where the Unique Name matches the given data-psn attribute - check that they match','dropdowns') } }) // create the nav interaction // no authoring should occur here jQuery.createNavInteraction() } catch (e) { $debug('running parseJSONdata FAILED: ' + e.message) } } } } function appendNewLinks(el, data) { try { $debug('trying running appendNewLinks') //console.log(el, data) dropdown = el.find('.mmmdropdown') //if the dropdown class does not exist we should make it if (!dropdown.length){ //append the list item inside the container if (data.children) { $debug('there is no dropdown and this item has children: '+data.UniqueName+', so create the ul for them','dropdowns') el.addClass('mmmhasdropdown') dropdown = jQuery('