1var Eventx = { 2 addEvent: function(elem, type, func) { 3 if (document.addEventListener) { 4 elem.addEventListener(type, func, false); 5 } else { 6 elem.attachEvent('on' + type, func); 7 } 8 }, 9 onResizend: function(onResizend) { 10 var actionState = 'normal', 11 taskPtr = null, 12 timeOutTask = function() { 13 taskPtr && clearTimeout(taskPtr); 14 taskPtr = setTimeout(function() { 15 onResizend && onResizend(); 16 actionState = 'normal'; 17 }, 500) 18 }; 19 this.addEvent( 20 window, 'resize', function() { 21 actionState = 'resizing'; 22 timeOutTask(); 23 }); 24 }, 25 onResizestart: function(onResizestart) { 26 var isExecuted = false; 27 this.onResizend(function() { 28 isExecuted = false; 29 }); 30 this.addEvent( 31 window, 'resize', function() { 32 if (!isExecuted) { 33 onResizestart && onResizestart(); 34 isExecuted = true; 35 } 36 }); 37 } 38}; 39/* 40--- 41 42name: Array 43 44description: Contains Array Prototypes like each, contains, and erase. 45 46license: MIT-style license. 47 48requires: Type 49 50provides: Array 51 52... 53*/ 54Array.prototype.every = function(fn, bind) { 55 for (var i = 0, l = this.length >>> 0; i < l; i++) { 56 if ((i in this) && !fn.call(bind, this[i], i, this)) return false; 57 } 58 return true; 59}; 60Array.prototype.filter = function(fn, bind) { 61 var results = []; 62 for (var value, i = 0, l = this.length >>> 0; i < l; i++) if (i in this) { 63 value = this[i]; 64 if (fn.call(bind, value, i, this)) results.push(value); 65 } 66 return results; 67}; 68Array.prototype.indexOf = function(item, from) { 69 var length = this.length >>> 0; 70 for (var i = (from < 0) ? Math.max(0, length + from) : from || 0; i < length; i++) { 71 if (this[i] === item) return i; 72 } 73 return -1; 74}; 75Array.prototype.map = function(fn, bind) { 76 var length = this.length >>> 0, 77 results = Array(length); 78 for (var i = 0; i < length; i++) { 79 if (i in this) results[i] = fn.call(bind, this[i], i, this); 80 } 81 return results; 82}; 83Array.prototype.some = function(fn, bind) { 84 for (var i = 0, l = this.length >>> 0; i < l; i++) { 85 if ((i in this) && fn.call(bind, this[i], i, this)) return true; 86 } 87 return false; 88}; /*</!ES5>*/ 89Array.prototype.clean = function() { 90 return this.filter(function(item) { 91 return item != null; 92 }); 93}; 94Array.prototype.invoke = function(methodName) { 95 var args = Array.slice(arguments, 1); 96 return this.map(function(item) { 97 return item[methodName].apply(item, args); 98 }); 99}; 100Array.prototype.associate = function(keys) { 101 var obj = {}, 102 length = Math.min(this.length, keys.length); 103 for (var i = 0; i < length; i++) obj[keys[i]] = this[i]; 104 return obj; 105}; 106Array.prototype.link = function(object) { 107 var result = {}; 108 for (var i = 0, l = this.length; i < l; i++) { 109 for (var key in object) { 110 if (object[key](this[i])) { 111 result[key] = this[i]; 112 delete object[key]; 113 break; 114 } 115 } 116 } 117 return result; 118}; 119Array.prototype.contains = function(item, from) { 120 return this.indexOf(item, from) != -1; 121}; 122Array.prototype.append = function(array) { 123 this.push.apply(this, array); 124 return this; 125}; 126Array.prototype.getLast = function() { 127 return (this.length) ? this[this.length - 1] : null; 128}; 129Array.prototype.getRandom = function() { 130 return (this.length) ? this[Number.random(0, this.length - 1)] : null; 131}; 132Array.prototype.include = function(item) { 133 if (!this.contains(item)) this.push(item); 134 return this; 135}; 136Array.prototype.combine = function(array) { 137 for (var i = 0, l = array.length; i < l; i++) this.include(array[i]); 138 return this; 139}; 140Array.prototype.erase = function(item) { 141 for (var i = this.length; i--;) { 142 if (this[i] === item) this.splice(i, 1); 143 } 144 return this; 145}; 146Array.prototype.empty = function() { 147 this.length = 0; 148 return this; 149}; 150Array.prototype.flatten = function() { 151 var array = []; 152 for (var i = 0, l = this.length; i < l; i++) { 153 var type = typeOf(this[i]); 154 if (type == 'null') continue; 155 array = array.concat((type == 'array' || type == 'collection' || type == 'arguments' || instanceOf(this[i], Array)) ? Array.flatten(this[i]) : this[i]); 156 } 157 return array; 158}; 159Array.prototype.pick = function() { 160 for (var i = 0, l = this.length; i < l; i++) { 161 if (this[i] != null) return this[i]; 162 } 163 return null; 164}; 165Array.prototype.hexToRgb = function(array) { 166 if (this.length != 3) return null; 167 var rgb = this.map(function(value) { 168 if (value.length == 1) value += value; 169 return value.toInt(16); 170 }); 171 return (array) ? rgb : 'rgb(' + rgb + ')'; 172}; 173Array.prototype.rgbToHex = function(array) { 174 if (this.length < 3) return null; 175 if (this.length == 4 && this[3] == 0 && !array) return 'transparent'; 176 var hex = []; 177 for (var i = 0; i < 3; i++) { 178 var bit = (this[i] - 0).toString(16); 179 hex.push((bit.length == 1) ? '0' + bit : bit); 180 } 181 return (array) ? hex : '#' + hex.join(''); 182}; 183if (undefined == Function.prototype.bind) { 184 Function.prototype.bind = function(that) { 185 var self = this, 186 args = arguments.length > 1 ? Array.slice(arguments, 1) : null, 187 F = function() {}; 188 var bound = function() { 189 var context = that, 190 length = arguments.length; 191 if (this instanceof bound) { 192 F.prototype = self.prototype; 193 context = new F; 194 } 195 var result = (!args && !length) ? self.call(context) : self.apply(context, args && length ? args.concat(Array.slice(arguments)) : args || arguments); 196 return context == that ? result : context; 197 }; 198 return bound; 199 } 200}(function($) { 201 $.fn.getLast = function(n) {
202 return $(this).children().last(); 203 }; 204 $.fn.getPrevious = $.fn.prev; 205 $.fn.getFirst = function(n) { 206 return $(this).children().first(); 207 }; 208 $.fn.getNext = $.fn.next; 209 $.fn.fireEvents = function(n) { 210 $(this).each(function(i, d) { 211 $(d).trigger(n); 212 }); 213 }; 214 MenuMatic = window.MenuMatic = function(options) { 215 this.options = { 216 id: 's5_nav', 217 //the id of the main menu (ul or ol) 218 subMenusContainerId: 'subMenusContainer', 219 //id of the container div that will be generated to hold the submenus 220 tabletWidth: 800, 221 //subMenu behavior 222 effect: 'slide & fade', 223 // 'slide', 'fade', 'slide & fade', or null 224 duration: 600, 225 //duration of the effect in milliseconds 226 physics: 'easeOutQuad', 227 //how the effect behaves 228 hideDelay: 1000, 229 //in milliseconds, how long you have after moving your mouse off of the submenus before they dissapear 230 displayDelay: 0, 231 //in milliseconds, how long you have after moving your mouse on the submenus before they appear 232 //layout 233 stretchMainMenu: false, 234 //stretch main menu btn widths to fit within the width {set in the css} of the parent UL or OL 235 matchWidthMode: false, 236 //initial submenus match their parent button's width 237 orientation: 'horizontal', 238 //horizontal or vertical 239 direction: { 240 x: 'right', 241 y: 'down' 242 }, 243 //for submenus ( relative to the parent button )left or right, up or down 244 olddirection: { 245 x: 'right', 246 y: 'down' 247 }, 248 tweakInitial: { 249 x: 0, 250 y: 0 251 }, 252 //if you need to tweak the placement of the initial submenus 253 tweakSubsequent: { 254 x: 0, 255 y: 0 256 }, 257 //if you need to tweak the placement of the subsequent submenus 258 center: false, 259 // will attempt to center main nav element 260 //dynamic style 261 opacity: 95, 262 //of the submenus 263 mmbFocusedClassName: null, 264 //main menu button classname, used for morphing to focused state 265 mmbClassName: null, 266 //main menu button classname, used for morphing back to original state 267 killDivider: null, 268 fullWidth: null, 269 fixHasLayoutBug: false, 270 onHideAllSubMenusNow_begin: (function() {}), 271 onHideAllSubMenusNow_complete: (function() {}), 272 onInit_begin: (function() {}), 273 onInit_complete: (function() {}) 274 }, this.hideAllMenusTimeout = null, this.S5DisplayMenusTimeout = null, this.allSubMenus = [], this.subMenuZindex = 1; 275 this.initialize(options); 276 this.stretch(); 277 this.killDivider(); 278 this.center(); 279 this.fixHasLayoutBug(); 280 } 281 MenuMatic.prototype.initialize = function(options) { 282 //if(Browser.Engine.webkit419){return;} 283 //this.setOptions(options); 284 // var options = this.options = Object.merge.apply(null, [{}, this.options].append(arguments)); 285 this.options = $.extend(this.options, options); 286 this.options.olddirection.x = this.options.direction.x; 287 this.options.olddirection.y = this.options.direction.y; 288/* if (this.addEvent) for (var option in options){ 289 if (typeOf(options[option]) != 'function' || !(/^on[A-Z]/).test(option)) continue; 290 this.bind(option, options[option]); 291 delete options[option]; 292 }*/ 293 //console.log(this.options); 294 //this.options.onInit_begin(); 295 if (this.options.opacity > 99) { 296 this.options.opacity = 99.9; 297 } 298 this.options.opacity = this.options.opacity / 100; 299 //initialize directions 300 this.options.direction.x = this.options.direction.x.toLowerCase(); 301 this.options.direction.y = this.options.direction.y.toLowerCase(); 302 if (this.options.direction.x === 'right') { 303 this.options.direction.xInverse = 'left'; 304 } else if (this.options.direction.x === 'left') { 305 this.options.direction.xInverse = 'right'; 306 } 307 if (this.options.direction.y === 'up') { 308 this.options.direction.yInverse = 'down'; 309 } else if (this.options.direction.y === 'down') { 310 this.options.direction.yInverse = 'up'; 311 } 312 var links = $('#' + this.options.id + ' li, span.grouped_sub_parent_item'); // $('#'+this.options.id).getElements('a'); - silviu 313 //silviu create an array to keep the child LI index 314 var LiParent = new Array(); 315 $(links).each((function(index, item) { 316 //store parent links & child menu info 317 $(item).data('parentLinks', $(item). /*getParent().*/ parents('li')); 318 if ($(item).children('ul') && $(item).children('ul').length >= 1) { 319 var child_Menu = $(item).children('ul'); 320 LiParent[index] = ""; 321 } else { 322 var child_Menu = null; 323 } 324 $(item).data('childMenu', child_Menu); 325 if (child_Menu) child_Menu.data('parentMenu', $(item)); //westcowboy 326 //determine submenu type 327 theSubMenuType = 'subsequent'; 328 if ($($(item).parents('ul') || $(item).parents('ol')).attr('id') === this.options.id) { 329 theSubMenuType = 'initial'; 330 } 331 $(item).data('subMenuType', theSubMenuType); 332 //add classes to parents 333 if (theSubMenuType === 'initial' && $($(item).children('ul') || $(item).children('ol'))) { 334 $(item).addClass('mainMenuParentBtn'); 335 } else if ($($(item).children('ul') || $(item).children('ol'))) { 336 $(item).addClass('subMenuParentBtn'); 337 } 338 }).bind(this)); 339 //rip the submenus apart into separate divs inside of subMenusContainer
340 var subMenusContainer = $('<div></div>').attr('id', this.options.subMenusContainerId).appendTo($('body')); 341 var existing_index = new Array(); 342 $('#' + this.options.id + ' ul').each(function(index, item) { 343 //remove the ul elements inside a moduletable div, the module content which can contain ul 344 if ($(item).parents('div[class*=moduletable]').length == 0) { 345 //new index found, add it to existing index and create the div content 346 if ($(item).parents('span.grouped_sub_parent_item').size() > 0) { 347 var parent_li_index = links.index($(item).parents('span.grouped_sub_parent_item')); 348 } else { 349 var parent_li_index = links.index($(item).parent('li')); 350 } 351 if (false == existing_index.contains(parent_li_index)) { 352 existing_index.include(parent_li_index); 353 if ($(item).parent().data('subMenuType') == 'initial') { 354 var subMenusContainersmOW = $('<div></div>').addClass('s5_sub_wrap').attr('id', 'ul_child_' + parent_li_index).appendTo(subMenusContainer); 355 } else { 356 var subMenusContainersmOW = $('<div></div>').addClass('s5_sub_wrap_lower').attr('id', 'ul_child_' + parent_li_index).appendTo(subMenusContainer); 357 } 358 var subMenusContainerUl = $('<ul></ul>').appendTo(subMenusContainersmOW); 359 var subMenusContainerLI = $('<li></li>').attr('id', 'li_child_' + parent_li_index).appendTo(subMenusContainerUl).append(item); 360 //var subMenusContainers = new Element('div',{'class': 'smOW', 'id': 'ul_child_'+parent_li_index}).inject(subMenusContainer).grab(item); 361 } else { 362 //found existing index, so just add extra ul to the existing content 363 if ($('#li_child_' + parent_li_index)) { 364 $('#li_child_' + parent_li_index).append(item); 365 } 366 } 367 } 368 }); 369 //set tabindex to -1 so tabbing through links in page does not go through hidden links in submenus container, since arrow keys can be used to navigate through submenus 370 $('a', subMenusContainer).attr('tabindex', '-1'); 371 links.each((function(index, item) { 372 //item=$(item); 373 //only apply to links with subMenus 374 if (!$(item).data('childMenu')) { 375 return; 376 } 377 //update childMenu pointer to look at smOW DIVs 378 $(item).data('childMenu', $('#ul_child_' + index)); //$(item).data('childMenu').parents('div') 379 $('#ul_child_' + index).data('parentMenu', $(item)); //westcowboy 380 //add to allSubMenus array 381 this.allSubMenus.include($(item).data('childMenu')); 382 //store parentSubMenus 383 //$(item).data('parentSubMenus',$($(item).data('parentLinks')).data('childMenu')); 384 var tmp = []; 385 $(item).data('parentLinks').each(function(index, item2) { 386 // fix for grouped child menus, the else block actually gets the parent sub menu of the current descdent grouped submenu 387 if ($(item2).data('childMenu')) tmp.include($(item2).data('childMenu')[0]); 388 else { 389 tmp.include($(item2).parentsUntil('li').parentsUntil('div').parent()[0]); 390 } 391 }); 392 $(item).data('parentSubMenus', $(tmp)); 393 delete tmp; 394 //$(item).data('parentSubMenus',$(item).data('parentLinks').data('childMenu')); 395 //console.log($($(item).data('parentLinks')).data('childMenu')); 396 //now create the MenuMaticSubMenu class instances 397 //if($(item).data('parentLinks').length>0) { 398 var aSubMenu = new MenuMaticSubMenu(); 399 jQuery(item).data('subMenuInstance', aSubMenu); 400 aSubMenu.initialize(this.options, this, $(item), index); 401 ///} 402 }).bind(this)); 403 //attach event handlers to non-parent main menu buttons 404 var nonParentBtns = $('#' + this.options.id + ' li').filter(function(index, item) { 405 return !$(item).data('childMenu'); 406 }); // silviu removed a 407 //var nonParentBtns1 = $$('div.moduletable'); 408 //var nonParentBtns = nonParentBtns0.concat(nonParentBtns1); 409 //console.log(nonParentBtns); 410 nonParentBtns.each((function(index, item) { 411 $(item).bind('mouseenter', (function(e) { 412 e.preventDefault(); 413 this.hideAllSubMenusNow(); 414 if (this.options.mmbClassName && this.options.mmbFocusedClassName) { 415 if (!$(item).data('btnMorph')) $(item).switchClass(this.options.mmbFocusedClassName, '', this.options.duration / 2, this.options.physics); 416 else $(item).data('btnMorph'); 417 } 418 }).bind(this)); 419 $(item).bind('focus', (function(e) { 420 e.preventDefault(); 421 this.hideAllSubMenusNow(); 422 if (this.options.mmbClassName && this.options.mmbFocusedClassName) { 423 if (!$(item).data('btnMorph')) $(item).switchClass(this.options.mmbFocusedClassName, '', this.options.duration / 2, this.options.physics); 424 else $(item).data('btnMorph'); 425 } 426 }).bind(this)); 427 $(item).bind('mouseleave', (function(e) { 428 e.preventDefault(); 429 if (this.options.mmbClassName && this.options.mmbFocusedClassName) { 430 if (!$(item).data('btnMorph')) $(item).switchClass(this.options.mmbClassName, '', this.options.duration / 2, this.options.physics); 431 else $(item).data('btnMorph'); 432 } 433 }).bind(this)); 434 $(item).bind('blur', (function(e) { 435 e.preventDefault(); 436 if (this.options.mmbClassName && this.options.mmbFocusedClassName) { 437 if (!$(item).data('btnMorph')) $(item).switchClass(this.options.mmbClassName, '', this.options.duration / 2, this.options.physics); 438 else $(item).data('btnMorph'); 439 } 440 }).bind(this)); 441 $(item).bind('keydown', (function(e) { 442 var event = new Event(e); 443 if (e.key === 'up' || e.key === 'down' || e.key === 'left' || e.key === 'right') { 444 e.stop(); 445 } 446 if (e.key === 'left' && this.options.orientation === 'horizontal' || e.key === 'up' && this.options.orientation === 'vertical') { 447 if ($(item).parents('li').getPrevious('li')) { 448 $(item).parents('li').getPrevious('li').getFirst('a').focus(); 449 } else { 450 $(item).parents('li').parent().getLast('li').getFirst('a').focus(); 451 } 452 } else if (e.key === 'right' && this.options.orientation === 'horizontal' || e.key === 'down' && this.options.orientation === 'vertical') { 453 if ($(item).parents('li').getNext('li')) { 454 $(item).parents('li').getNext('li').getFirst('a').focus(); 455 } else { 456 $(item).parents('li').parent().getFirst('li').getFirst('a').focus(); 457 } 458 } 459 }).bind(this)); 460 }).bind(this)); 461 //showMessage(screen.width); 462 this.onResizeWindow(); 463 Eventx.onResizestart(this.hideAllSubMenusNow.bind(this)); 464 Eventx.onResizend(this.onResizeWindow.bind(this)); 465 } 466 MenuMatic.prototype.getWidth = function() { 467 if(this.options.fullWidth && typeof this.options.fullWidth === "function") { 468 return this.options.fullWidth(); 469 } 470 return "auto"; 471 } 472 /** 473 * For tablet devices with smaller widths, 474 * just swap the event handlers while window width under or above the WIDTH 475 */ 476 MenuMatic.prototype.onResizeWindow = function() { 477/*function showMessage(message, title, callback, buttonName){ 478 title = title || ""; 479 buttonName = buttonName || 'OK'; 480 if(navigator.notification){ 481 navigator.notification.alert( 482 message, // message 483 callback, // callback 484 title, // title 485 buttonName // buttonName 486 ); 487 }else{ 488 alert(message); 489 if(callback) 490 callback(); 491 } 492 } 493 showMessage(!!('ontouchstart' in window));*/ 494 var thisp = this; 495 //console.log(this.options.tabletWidth); 496 if ($(window).width() >= this.options.tabletWidth) { 497 var needTablet = window.needTablet = 0; 498 if (window.s5menuTablet) var needRevert = window.needRevert = 1; 499 else 500 var needRevert = window.needRevert = 0; 501 } else if ($(window).width() < this.options.tabletWidth && !! (('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0)) /* is tablet*/ ) { 502 var needRevert = window.needRevert = 0; 503 if (window.s5menuTablet) var needTablet = window.needTablet = 0; 504 else 505 var needTablet = window.needTablet = 1; 506 } 507 //console.log(needRevert,needTablet); 508 if (needTablet || needRevert) { 509 var links = jQuery('.mainMenuParentBtn,.subMenuParentBtn,.mainParentBtn,.subParentBtn'); 510 links.each(function(i, d) { 511 if (!$(d).data('childMenu')) { 512 if (needTablet) { 513 $(d).unbind('mouseenter').bind('mouseenter', function() { 514 jQuery('.mainParentBtnFocused').removeClass('mainParentBtnFocused'); 515 jQuery(this).addClass('mainParentBtnFocused'); 516 }); 517 $(d).unbind('mouseleave').bind('mouseleave', function() { 518 jQuery(this).removeClass('mainParentBtnFocused'); 519 }); 520 } 521 if (needRevert) { 522 $(d).unbind('mouseenter').bind('mouseenter', thisp.hideAllSubMenusNow.bind(thisp)); 523 } 524 return; 525 } 526 var that = $(d).data('subMenuInstance'); 527 if (needTablet) { 528 //console.log(needTablet); 529 window.s5menuTablet = 1; 530 var mouseEnterH = function(e) { 531 e.preventDefault(); 532 jQuery(this).css({ 533 background: '' 534 }); 535 if (that.subMenuType == 'initial') { 536 //jQuery('.mainMenuParentBtnFocused').removeClass('mainMenuParentBtnFocused'); 537 jQuery(this).addClass('mainMenuParentBtnFocused'); 538 } else { 539 //jQuery('.subMenuParentBtnFocused').removeClass('subMenuParentBtnFocused'); 540 jQuery(this).addClass('subMenuParentBtn').addClass('subMenuParentBtnFocused'); 541 //console.log('enter'); 542 } 543 if (that.subMenuType === 'initial' && that.options.mmbClassName && that.options.mmbFocusedClassName) { 544 if ($(this).data('btnMorph')) $(this).data('btnMorph'); 545 else $(this).switchClass(that.options.mmbFocusedClassName, '', that.options.duration / 2, that.options.physics); 546 } 547 }; 548 var mouseLeaveH = function(e) { 549 if (!$(this).data('menuOpened')) { 550 if (that.subMenuType == 'initial') jQuery(this).removeClass('mainMenuParentBtnFocused').removeClass('mainMenuParentBtnTablet'); 551 else jQuery(this).removeClass('subMenuParentBtnFocused'); 552 } 553 return false;
554 } 555 var clickH = function(e) { 556 //console.log(e.target, e.target.hasAttribute('onclick') && e.target.getAttribute('onclick').indexOf('javascript:;')); 557 if (e.target.nodeName == 'SPAN' && e.target.hasAttribute('onclick') && e.target.getAttribute('onclick').indexOf('javascript:;') == -1) { 558 e.target.click(); 559 return false; 560 } 561 if (that.subMenuType == 'initial') jQuery(this).removeClass('mainMenuParentBtnTablet'); 562 else jQuery(this).find('.S5_submenu_item').removeClass('S5_submenu_itemTablet'); 563 if ($(this).data('menuOpened')) { 564 that.hideSubMenu(true); 565 var tmp = $(this).data('childMenu').find('li').filter(function(i, cli) { 566 return $(cli).data('childMenu') && $(cli).data('menuOpened'); 567 }); 568 tmp.each(function(i, cli) { 569 $(cli).data('subMenuInstance').hideSubMenu(); 570 var tmp2 = $(cli).data('childMenu').find('li').filter(function(i, cli2) { 571 return $(cli2).data('childMenu') && $(cli2).data('menuOpened'); 572 }); 573 tmp2.each(function(i, cli3) { 574 $(cli3).data('subMenuInstance').hideSubMenu(); 575 }); 576 }); 577 $(this).data('menuOpened', false); 578 if (that.subMenuType == 'initial') { 579 jQuery(this).removeClass('mainMenuParentBtnFocused').addClass('mainMenuParentBtnTablet'); 580 } else { 581 jQuery(this).find('.S5_submenu_item'). /*removeClass('S5_submenu_item').*/ 582 addClass('S5_submenu_itemTablet'); 583 } 584 return false; 585 } 586 $(this).data('menuOpened', true); 587 e.preventDefault(); 588 that.cancellHideAllSubMenus(); 589 that.hideOtherSubMenus(); 590 //if(that.options.opacity == that.btn.parents('ul').getStyle('opacity') || that.btn.parents('ul').getStyle('opacity') == 1){ 591 setTimeout(function() { 592 that.showSubMenu(); 593 }, 10); 594 //} 595 if (that.subMenuType === 'initial' && that.options.mmbClassName && that.options.mmbFocusedClassName) { 596 if ($(this).data('btnMorph')) $(this).data('btnMorph'); 597 else $(this).switchClass(that.options.mmbFocusedClassName, '', that.options.duration / 2, that.options.physics); 598 } 599 }; 600 } 601 if (needRevert) { 602 window.s5menuTablet = 0; 603 var mouseEnterH = $(d).data('mouseenterH'); 604 var mouseLeaveH = $(d).data('mouseleaveH'); 605 var clickH = function(e) { 606 e.target.click(); 607 } 608 } 609 $(d).unbind('mouseenter').bind('mouseenter', mouseEnterH).unbind('mouseleave').bind('mouseleave', mouseLeaveH).unbind('click').bind('click', clickH); 610 }); 611 jQuery('li[id*=li_child_] ul').each(function(i, d) { 612 var pmenu = $(d).data('parentMenu'); 613 if (pmenu) { 614 var that = pmenu.data('subMenuInstance'); 615 if (needTablet || needRevert) { 616 if (needTablet) { 617 var mouseEnterH = function() { 618 if (that.subMenuType == 'initial') pmenu.addClass('mainMenuParentBtnFocused'); 619 else pmenu.addClass('subMenuParentBtnFocused'); 620 }; 621 } 622 if (needRevert) { 623 var mouseEnterH = pmenu.data('mouseenterH'); 624 } 625 $(d).bind('mouseenter', mouseEnterH); 626 } 627 } 628 $(d).children('li').each(function(i, dd) { 629 //return false; 630 if ($(dd).data('childMenu')) { 631 var that = $(dd).data('subMenuInstance'); 632 if (needTablet || needRevert) { 633 if (needTablet) { 634 var mouseLeaveH = function() { 635 if ($(dd).data('menuOpened') == false) { 636 if (that.subMenuType == 'initial') $(this).removeClass('mainMenuParentBtnFocused'); 637 else $(this).removeClass('subMenuParentBtnFocused'); 638 } 639 }; 640 var mouseEnterH = function() { 641 //console.log('enter'); 642 if (that.subMenuType == 'initial') $(this).addClass('mainMenuParentBtnFocused'); 643 else $(this).addClass('subMenuParentBtnFocused').find('.S5_submenu_itemTablet').removeClass('S5_submenu_itemTablet'); 644 }; 645 } 646 if (needRevert) { 647 var mouseLeaveH = $(dd).data('mouseleaveH'); 648 var mouseEnterH = $(dd).data('mouseenterH'); 649 //console.log(mouseEnterH); 650 } 651 $(dd).unbind('mouseleave').bind('mouseleave', mouseLeaveH).unbind('mouseenter').bind('mouseenter', mouseEnterH); 652 } 653 } else { 654 //if(needTablet)$(dd).unbind('mouseleave').unbind('mouseenter'); 655 //if(needRevert){ 656 var mouseLeaveH = $(dd).data('mouseleaveH'); 657 var mouseEnterH = $(dd).data('mouseenterH'); 658 //console.log(dd); 659 //console.log(mouseEnterH); 660 if (needRevert) { 661 $(dd).unbind('mouseleave').bind('mouseleave', mouseLeaveH).unbind('mouseenter').bind('mouseenter', mouseEnterH); 662 } 663 if (needTablet) { 664 // console.log(mouseEnterH); 665 $(dd).unbind('mouseleave').unbind('mouseenter').bind('click', mouseEnterH); 666 } 667 //} 668 } 669 }); 670 }); 671 } 672 }; 673 MenuMatic.prototype.fixHasLayoutBug = function() { 674 if ($.browser.msie && this.options.fixHasLayoutBug) {
675 $('#' + this.options.id).parents().css('zoom', 1); 676 $('#' + this.options.id).css('zoom', 1); 677 $('#' + this.options.id).children().css('zoom', 1); 678 $('#' + this.options.subMenusContainerId).css('zoom', 1); 679 $('#' + this.options.subMenusContainerId).children().css('zoom', 1); 680 } 681 }; 682 MenuMatic.prototype.center = function() { 683 if (!this.options.center) { 684 return; 685 } 686 $('#' + this.options.id).css({ 687 'left': '50%', 688 'marginLeft': -($('#' + this.options.id).width() / 2) 689 }); 690 }; 691 MenuMatic.prototype.stretch = function() { 692 //stretch main menu btn widths to fit within the width of the parent UL or OL 693 if (this.options.stretchMainMenu && this.options.orientation === 'horizontal') { 694 var targetWidth = parseFloat($('#' + this.options.id).width()); 695 var totalBtnWidth = 0; 696 var mainBtns = $('#' + this.options.id + ' li'); // silviu removed a 697 mainBtns.css({ 698 'paddingLeft': 0, 699 'paddingRight': 0 700 }); 701 mainBtns.each((function(index, item) { 702 totalBtnWidth += $(item).width(); 703 }).bind(this)); 704 if (targetWidth < totalBtnWidth) { 705 return; 706 } 707 var increment = (targetWidth - totalBtnWidth) / mainBtns.length; 708 mainBtns.each((function(index, item) { 709 $(item).css('width', $(item).width() + increment); 710 }).bind(this)); 711 mainBtns.getLast().css('width', mainBtns.getLast().width() - 1); 712 } 713 }; 714 MenuMatic.prototype.killDivider = function() { 715 if (this.options.killDivider && this.options.killDivider.toLowerCase() === 'first') { 716 $($('#' + this.options.id + ' li')[0]).css({ 717 'background': 'none' 718 }); 719 } else if (this.options.killDivider && this.options.killDivider.toLowerCase() === 'last') { 720 $($('#' + this.options.id + ' li').getLast()).css({ 721 'background': 'none' 722 }); 723 } 724 }; 725 MenuMatic.prototype.hideAllSubMenusNow = function() { 726 //this.options.onHideAllSubMenusNow_begin(); 727 clearTimeout(this.hideAllMenusTimeout); 728 $(this.allSubMenus).fireEvents('hidex'); 729 //this.options.onHideAllSubMenusNow_complete(); 730 }; 731 var MenuMaticSubMenu = function() { 732 this.options = { 733 onSubMenuInit_begin: (function(subMenuClass) {}), 734 onSubMenuInit_complete: (function(subMenuClass) {}), 735 onMatchWidth_begin: (function(subMenuClass) {}), 736 onMatchWidth_complete: (function(subMenuClass) {}), 737 onHideSubMenu_begin: (function(subMenuClass) {}), 738 onHideSubMenu_complete: (function(subMenuClass) {}), 739 onHideOtherSubMenus_begin: (function(subMenuClass) {}), 740 onHideOtherSubMenus_complete: (function(subMenuClass) {}), 741 onHideAllSubMenus_begin: (function(subMenuClass) {}), 742 onHideAllSubMenus_complete: (function(subMenuClass) {}), 743 onPositionSubMenu_begin: (function(subMenuClass) {}), 744 onPositionSubMenu_complete: (function(subMenuClass) {}), 745 onShowSubMenu_begin: (function(subMenuClass) {}), 746 onShowSubMenu_complete: (function(subMenuClass) {}) 747 }; 748 this.root = null; 749 this.btn = null;; 750 this.hidden = true; 751 this.myEffect = null; 752 } 753 MenuMaticSubMenu.prototype.matchWidth = function() { 754 if (this.widthMatched || !this.options.matchWidthMode || this.subMenuType === 'subsequent') { 755 return; 756 } 757 //this.options.onMatchWidth_begin(this); 758 if (this.btn.is('li') == false) var bw = this.btn.parentsUntil('li').eq(0).outerWidth(); 759 else 760 var bw = this.btn.outerWidth(); 761 var parentWidth = bw; 762 $('li', $(this.childMenu)).each((function(index, item) { // silviu removed a 763 var borderWidth = parseFloat($(this.childMenu).getFirst().getStyle('borderLeftWidth')) + parseFloat($(this.childMenu).getFirst().getStyle('borderRightWidth')); 764 var paddingWidth = parseFloat($(item).getStyle('paddingLeft')) + parseFloat($(item).getStyle('paddingRight')); 765 var offset = borderWidth + paddingWidth; 766 if (parentWidth > $(item).width()) { 767 $(item).css('width', parentWidth - offset); 768 $(item).css('margin-right', -borderWidth); 769 } 770 }).bind(this)); 771 this.width = this.childMenu.getFirst().width(); 772 this.widthMatched = true; 773 //this.options.onMatchWidth_complete(this); 774 }; 775 MenuMaticSubMenu.prototype.hideSubMenu = function(keepClass) { 776 if (this.childMenu.data('status') === 'closed') { 777 return; 778 } 779 //this.options.onHideSubMenu_begin(this); 780 if (keepClass == undefined) { 781 if (this.subMenuType == 'initial') { 782 if (this.options.mmbClassName && this.options.mmbFocusedClassName) { 783 if ($(this.btn).data('btnMorph')) $(this.btn).data('btnMorph'); 784 else this.btn.switchClass(this.options.mmbClassName, '', this.options.duration, this.options.physics, (function() { 785 $(this.btn).removeClass('mainMenuParentBtnFocused'); 786 $(this.btn).addClass('mainMenuParentBtn'); 787 }).bind(this)); 788 } else { 789 $(this.btn).removeClass('mainMenuParentBtnFocused'); 790 $(this.btn).addClass('mainMenuParentBtn'); 791 } 792 } else { 793 $(this.btn).removeClass('subMenuParentBtnFocused'); 794 $(this.btn).addClass('subMenuParentBtn'); 795 } 796 } 797 if (this.options.effect && this.options.effect.toLowerCase() === 'slide') { 798 if (this.subMenuType == 'initial' && this.options.orientation === 'horizontal' && this.options.direction.y === 'down') { 799 $(this.childMenu).getFirst().animate({ 800 'marginTop': -this.height 801 }, { 802 'duration': this.options.duration, 803 'easing': this.options.physics, 804 'queue': false, 805 'complete': (function() { 806 this.childMenu.css({ 807 left: 0, 808 display: 'none', 809 'zIndex': -100 810 }); 811 }).bind(this) 812 }).bind(this); 813 } else if (this.subMenuType == 'initial' && this.options.orientation === 'horizontal' && this.options.direction.y === 'up') { 814 $(this.childMenu).getFirst().animate({ 815 'marginTop': this.height 816 }, { 817 'duration': this.options.duration, 818 'easing': this.options.physics, 819 'queue': false, 820 'complete': (function() { 821 this.childMenu.css({ 822 left: 0, 823 display: 'none', 824 'zIndex': -100 825 }); 826 }).bind(this) 827 }).bind(this); 828 } else if (this.options.direction.x === 'right') { 829 $(this.childMenu).getFirst().animate({ 830 'marginLeft': -this.width 831 }, { 832 'duration': this.options.duration, 833 'easing': this.options.physics, 834 'queue': false, 835 'complete': (function() { 836 this.childMenu.css({ 837 left: 0, 838 display: 'none', 839 'zIndex': -100 840 }); 841 }).bind(this) 842 }).bind(this); 843 } else if (this.options.direction.x === 'left') { 844 $(this.childMenu).getFirst().animate({ 845 'marginLeft': this.width 846 }, { 847 'duration': this.options.duration, 848 'easing': this.options.physics, 849 'queue': false, 850 'complete': (function() { 851 this.childMenu.css({ 852 left: 0, 853 display: 'none', 854 'zIndex': -100 855 }); 856 }).bind(this) 857 }).bind(this); 858 } 859 } else if (this.options.effect == 'fade') { 860 $(this.childMenu).getFirst().animate({ 861 'opacity': 0 862 }, { 863 'duration': this.options.duration, 864 'easing': this.options.physics, 865 'queue': false, 866 'complete': (function() { 867 this.childMenu.css({ 868 left: 0, 869 display: 'none', 870 'zIndex': -100 871 }); 872 }).bind(this) 873 }).bind(this); 874 } else if (this.options.effect == 'slide & fade') { 875 //console.log(this.childMenu.css('display')); 876 if (this.subMenuType == 'initial' && this.options.orientation === 'horizontal' && this.options.direction.y === 'down') { 877 $(this.childMenu).getFirst().animate({ 878 'marginTop': -this.height, 879 opacity: 0 880 }, { 881 'duration': this.options.duration, 882 'easing': this.options.physics, 883 'queue': false, 884 'complete': (function() { 885 this.childMenu.css({ 886 left: 0, 887 display: 'none', 888 'zIndex': -100 889 }); 890 }).bind(this) 891 }).bind(this); 892 } else if (this.subMenuType == 'initial' && this.options.orientation === 'horizontal' && this.options.direction.y === 'up') { 893 $(this.childMenu).getFirst().animate({ 894 'marginTop': this.height, 895 opacity: 0 896 }, { 897 'duration': this.options.duration, 898 'easing': this.options.physics, 899 'queue': false, 900 'complete': (function() { 901 this.childMenu.css({ 902 left: 0, 903 display: 'none', 904 'zIndex': -100 905 }); 906 }).bind(this) 907 }).bind(this); 908 } else if (this.options.direction.x === 'right') { 909 $(this.childMenu).getFirst().animate({ 910 'marginLeft': -this.width, 911 opacity: 0 912 }, { 913 'duration': this.options.duration, 914 'easing': this.options.physics, 915 'queue': false, 916 'complete': (function() { 917 this.childMenu.css({ 918 left: 0, 919 display: 'none', 920 'zIndex': -100 921 }); 922 }).bind(this) 923 }).bind(this); 924 } else if (this.options.direction.x === 'left') { 925 $(this.childMenu).getFirst().animate({ 926 'marginLeft': this.width, 927 opacity: 0 928 }, { 929 'duration': this.options.duration, 930 'easing': this.options.physics, 931 'queue': false, 932 'complete': (function() { 933 this.childMenu.css({ 934 left: 0, 935 display: 'none', 936 'zIndex': -100 937 }); 938 }).bind(this) 939 }).bind(this); 940 } 941 } else {
942 this.childMenu[0].style.left = "0px"; 943 this.childMenu[0].style.visiblity = "hidden"; 944 this.childMenu.css('zIndex', -100); 945 } 946 this.childMenu.data('status', 'closed'); 947 //console.log(this.childMenu.css('display')); 948 //this.options.onHideSubMenu_complete(this); 949 }; 950 MenuMaticSubMenu.prototype.hideOtherSubMenus = function() { 951 //this.options.onHideOtherSubMenus_begin(this); 952 //set up otherSubMenus element collection 953 if (!this.btn.data('otherSubMenus')) { 954 this.btn.data('otherSubMenus', $(this.root.allSubMenus.filter((function(item) { 955 return this.btn.data('parentSubMenus').index(item) == -1 && item != this.childMenu; 956 }).bind(this)))); 957 } 958 this.parentSubMenus.fireEvents('show'); 959 //console.log(this.btn.data('otherSubMenus').size()); 960 this.btn.data('otherSubMenus').fireEvents('hidex'); 961 //console.log(this.btn.data('otherSubMenus')); 962 this.btn.data('otherSubMenus').each(function(i, d) { // westcowboy 963 $(d).data('parentMenu').data('menuOpened', false); 964 }); 965 //this.options.onHideOtherSubMenus_complete(this); 966 }; 967 MenuMaticSubMenu.prototype.hideAllSubMenus = function() { 968 //this.options.onHideAllSubMenus_begin(this); 969 clearTimeout(this.root.hideAllMenusTimeout); 970 this.root.hideAllMenusTimeout = setTimeout((function() { 971 clearTimeout(this.root.hideAllMenusTimeout); 972 $(this.root.allSubMenus).fireEvents('hidex'); 973 }).bind(this), this.options.hideDelay); 974 //this.options.onHideAllSubMenus_complete(this); 975 }; 976 MenuMaticSubMenu.prototype.cancellHideAllSubMenus = function() { 977 //this.childMenu.getFirst().stop(); 978 //$(this.root.allSubMenus).stop(); 979 //console.log($(this.root.allSubMenus.filter((function(item){ return this.btn.data('parentSubMenus').index(item)==-1 && item != this.childMenu;}).bind(this)))); 980 clearTimeout(this.root.hideAllMenusTimeout); 981 //$(this.root.allSubMenus.filter((function(item){ return this.btn.data('parentSubMenus').index(item)==-1 && item != this.childMenu;}).bind(this))).each(function(i,d){$(d).stop();}); 982 this.options.direction.x = this.options.olddirection.x; 983 }; 984 MenuMaticSubMenu.prototype.showSubMenu = function() { 985 //console.log('it is now '+this.options.direction.x); 986 S5DisplayMenusTimeout = setTimeout((function() { 987 this.S5showSubMenu(); 988 }).bind(this), this.options.displayDelay); 989 }; 990 MenuMaticSubMenu.prototype.S5showSubMenu = function(now) { 991 if (this.childMenu.data('status') === 'open') { 992 return; 993 } 994 //this.options.onShowSubMenu_begin(this); 995 if (this.subMenuType == 'initial') { 996 $(this.btn).removeClass('mainMenuParentBtn'); 997 $(this.btn).addClass('mainMenuParentBtnFocused'); 998 } else { 999 $(this.btn).removeClass('subMenuParentBtn'); 1000 $(this.btn).addClass('subMenuParentBtnFocused'); 1001 } 1002 this.root.subMenuZindex++; 1003 this.childMenu.css({ 1004 'display': 'block', 1005 'visibility': 'hidden', 1006 'zIndex': this.root.subMenuZindex 1007 }); 1008 if (!this.height || !this.width) { 1009 //console.log(this.childMenu.getFirst().outerHeight()); 1010 //this.height = this.childMenu.getFirst().getCoordinates().height; 1011 //silviu changes to get all the childrens content height 1012 //this.height = 0; 1013 this.height = this.childMenu.getFirst().outerHeight(); 1014 //this.width = this.childMenu.getFirst().getCoordinates().width; 1015 this.width = this.childMenu.getFirst().outerWidth(); 1016 //this.childMenu.css({'height':this.height,'width':this.width}/*,'border'*/); 1017 if (this.options.effect === 'slide' || this.options.effect === 'slide & fade') { 1018 if (this.subMenuType == 'initial' && this.options.orientation === 'horizontal') { 1019 this.childMenu.getFirst().css('marginTop', '0'); 1020 if (this.options.direction.y === 'down') { 1021 $(this.childMenu).getFirst().css({ 1022 'marginTop': -this.height 1023 }); 1024 } else if (this.options.direction.y === 'up') { 1025 $(this.childMenu).getFirst().css({ 1026 'marginTop': this.height 1027 }); 1028 } 1029 } else { 1030 if (this.options.direction.x === 'left') { 1031 $(this.childMenu).getFirst().css({ 1032 'marginLeft': this.width 1033 }); 1034 } else { 1035 $(this.childMenu).getFirst().css({ 1036 'marginLeft': -this.width 1037 }); 1038 } 1039 } 1040 } 1041 } 1042 this.matchWidth(); 1043 this.positionSubMenu(); 1044 if (this.options.effect === 'slide') { 1045 this.childMenu.css({ 1046 'display': 'block', 1047 'visibility': 'visible' 1048 }); 1049 if (this.subMenuType === 'initial' && this.options.orientation === 'horizontal') { 1050 if ($('#' + this.options.id).offset().top != $('#' + this.options.id).position().top /*&& $('#'+this.options.id)[0].offsetTop!=0*/ ) $(this.childMenu).css('top', $(this.btn).offset().top + $(this.btn).outerHeight() - $(window).scrollTop()); 1051/* else 1052 $(this.childMenu).css('top',$(this.btn).offset().top+$(this.btn).outerHeight());*/ 1053 if (now) { 1054 $(this.childMenu).getFirst().stop().animate({ 1055 'marginTop': 0 1056 }, { 1057 'duration': 0, 1058 'easing': this.options.physics, 1059 'queue': false, 1060 'complete': (function() { 1061 this.showSubMenuComplete(); 1062 }).bind(this) 1063 }); 1064 } else { 1065 $(this.childMenu).getFirst().stop().animate({ 1066 'marginTop': 0 1067 }, { 1068 'duration': this.options.duration, 1069 'queue': false, 1070 'easing': this.options.physics, 1071 'complete': (function() { 1072 this.showSubMenuComplete(); 1073 }).bind(this) 1074 }); 1075 } 1076 } else { 1077 if (this.subMenuType === 'subsequent') { 1078 if ($('#' + this.options.id).offset().top != $('#' + this.options.id).position().top && $('#' + this.options.id)[0].offsetTop != 0) $(this.childMenu).css('top', $(this.btn).offset().top - $(window).scrollTop()); 1079 else 1080 $(this.childMenu).css('top', $(this.btn).offset().top); 1081 } 1082 if (now) { 1083 $(this.childMenu).getFirst().stop().animate({ 1084 'marginLeft': 0 1085 }, { 1086 'duration': 0, 1087 'easing': this.options.physics, 1088 'queue': false, 1089 'complete': (function() { 1090 this.showSubMenuComplete(); 1091 }).bind(this) 1092 }); 1093 } else { 1094 $(this.childMenu).getFirst().stop().animate({ 1095 'marginLeft': 0 1096 }, { 1097 'duration': this.options.duration, 1098 'easing': this.options.physics, 1099 'queue': false, 1100 'complete': (function() { 1101 this.showSubMenuComplete(); 1102 }).bind(this) 1103 }); 1104 } 1105 } 1106 } else if (this.options.effect === 'fade') { 1107 this.childMenu.css({ 1108 'display': 'block', 1109 'visibility': 'visible' 1110 }); 1111 if (now) { 1112 $(this.childMenu).getFirst().stop().animate({ 1113 'opacity': this.options.opacity 1114 }, { 1115 'duration': 0, 1116 'easing': this.options.physics, 1117 'queue': false, 1118 'complete': (function() { 1119 this.showSubMenuComplete(); 1120 }).bind(this) 1121 }); 1122 } else { 1123 $(this.childMenu).getFirst().stop().animate({ 1124 'opacity': this.options.opacity 1125 }, { 1126 'duration': this.options.duration, 1127 'easing': this.options.physics, 1128 'queue': false, 1129 'complete': (function() { 1130 this.showSubMenuComplete(); 1131 }).bind(this) 1132 }); 1133 } 1134 } else if (this.options.effect == 'slide & fade') { 1135 this.childMenu.css({ 1136 'display': 'block', 1137 'visibility': 'visible' 1138 }); 1139 this.childMenu.getFirst().css({ 1140 'left': 0 1141 }); 1142 if (this.subMenuType === 'initial' && this.options.orientation === 'horizontal') { 1143 if ($('#' + this.options.id).offset().top != $('#' + this.options.id).position().top /*&& $('#'+this.options.id)[0].offsetTop!=0*/ ) $(this.childMenu).css('top', $(this.btn).offset().top + $(this.btn).outerHeight() - $(window).scrollTop()); 1144/*else 1145 $(this.childMenu).css('top',$(this.btn).offset().top+$(this.btn).outerHeight() - $(window).scrollTop()); 1146 */ 1147 if (now) { 1148 $(this.childMenu).getFirst().stop().animate({ 1149 'marginTop': 0, 1150 'opacity': this.options.opacity 1151 }, { 1152 'duration': 0, 1153 'queue': false, 1154 'easing': this.options.physics, 1155 'complete': (function() { 1156 this.showSubMenuComplete(); 1157 }).bind(this) 1158 }); 1159 } else { 1160 $(this.childMenu).getFirst().stop().animate({ 1161 'marginTop': 0, 1162 'opacity': this.options.opacity 1163 }, { 1164 'duration': this.options.duration, 1165 'queue': false, 1166 'easing': this.options.physics, 1167 'complete': (function() { 1168 this.showSubMenuComplete(); 1169 }).bind(this) 1170 }); 1171 } 1172 } else { 1173 if (this.subMenuType === 'subsequent') { 1174 if ($('#' + this.options.id).offset().top != $('#' + this.options.id).position().top /* && $('#'+this.options.id)[0].offsetTop!=0*/ ) $(this.childMenu).css('top', $(this.btn).offset().top - $(window).scrollTop()); 1175/*else 1176 $(this.childMenu).css('top',$(this.btn).offset().top);*/ 1177 } 1178 if (now) { 1179 if (this.options.direction.x === 'right') { 1180 $(this.childMenu).getFirst().stop().animate({ 1181 'marginLeft': 0, 1182 'opacity': this.options.opacity 1183 }, { 1184 'duration': 0, 1185 'easing': this.options.physics, 1186 'queue': false, 1187 'complete': (function() { 1188 this.showSubMenuComplete(); 1189 }).bind(this) 1190 }); 1191 } else if (this.options.direction.x === 'left') { 1192 $(this.childMenu).getFirst().stop().animate({ 1193 'marginLeft': 0, 1194 'opacity': this.options.opacity 1195 }, { 1196 'duration': 0, 1197 'easing': this.options.physics, 1198 'queue': false, 1199 'complete': (function() { 1200 this.showSubMenuComplete(); 1201 }).bind(this) 1202 }); 1203 } 1204 } else { 1205 if (this.options.direction.x === 'right') { 1206 $(this.childMenu).getFirst().css('marginLeft', -this.width); 1207 $(this.childMenu).getFirst().stop().animate({ 1208 'marginLeft': 0, 1209 'opacity': this.options.opacity 1210 }, { 1211 'duration': this.options.duration, 1212 'easing': this.options.physics, 1213 'queue': false, 1214 'complete': (function() { 1215 this.showSubMenuComplete(); 1216 }).bind(this) 1217 }); 1218 } else if (this.options.direction.x === 'left') { 1219 $(this.childMenu).getFirst().stop().animate({ 1220 'marginLeft': 0, 1221 'opacity': this.options.opacity 1222 }, { 1223 'duration': this.options.duration, 1224 'easing': this.options.physics, 1225 'queue': false, 1226 'complete': (function() { 1227 this.showSubMenuComplete(); 1228 }).bind(this) 1229 }); 1230 } 1231 } 1232 } 1233 } else { 1234 this.childMenu.stop().animate({ 1235 'display': 'block', 1236 'visibility': 'visible' 1237 }, { 1238 'duration': 0, 1239 'easing': this.options.physics, 1240 'queue': false, 1241 'complete': (function() { 1242 this.showSubMenuComplete(); 1243 }).bind(this) 1244 }); 1245 } 1246 this.childMenu.data('status', 'open'); 1247 }; 1248 MenuMaticSubMenu.prototype.showSubMenuComplete = function() { 1249 //this.options.onShowSubMenu_complete(this); 1250 if (this.options.olddirection.x) this.options.direction.x = this.options.olddirection.x; 1251 //S5 - silviu - rearange the submenu if mouse over fast bug 1252 if ((parseInt(this.childMenu[0].style.top) != this.btn.offset().top && this.btn.offset().top != $('#' + this.options.id).offset().top && parseInt(this.btn.css('marginTop')) == 0) && $('#' + this.options.id)[0].offsetTop != 0) { 1253 if (this.btn.data('subMenuType') == 'initial') { 1254 if (this.options.orientation == 'horizontal') { 1255 if (this.btn.is('li') == false) var t = this.btn.parentsUntil('li').eq(0).outerHeight(); 1256 else 1257 var t = this.btn.outerHeight(); 1258 } else 1259 var t = this.btn.offset().top + this.btn.outerHeight(); 1260 t -= this.subtractScrollTop(); 1261 $(this.childMenu).animate({ 1262 'top': t 1263 }, this.options.duration, this.options.physics); 1264 } else { 1265 var totop = this.btn.offset().top - this.subtractScrollTop(); 1266 $(this.childMenu).animate({ 1267 'top': totop 1268 }, this.options.duration, this.options.physics); 1269 } 1270 } 1271 }; 1272 MenuMaticSubMenu.prototype.positionSubMenu = function() { 1273 //this.options.onPositionSubMenu_begin(this); 1274 this.childMenu.css('width', this.width); 1275 this.childMenu.getFirst().css('width', this.width); 1276 //if parent is ltr className all childrens must be ltr 1277 if (this.btn.parents('div').className == 's5_sub_wrap_rtl' || this.btn.parents('div').className == 's5_sub_wrap_lower_rtl') { 1278 //this.childMenu.className = 's5_sub_wrap_rtl'; 1279 this.childMenu.className = 's5_sub_wrap_lower_rtl'; 1280 } 1281 //if any parent has bounced off a viewport edge, inherit that new direction 1282 if (this.subMenuType === 'subsequent') { 1283 if (this.parentSubMenu && this.options.direction.x != this.parentSubMenu.options.direction.x) { 1284 if (this.parentSubMenu.options.direction.x === 'left' && this.options.effect && this.options.effect.contains('slide')) { 1285 $(this.childMenu).getFirst().css({ 1286 'marginLeft': this.width 1287 }); 1288 } 1289 } 1290 this.options.direction.x = this.parentSubMenu.options.direction.x; 1291 this.options.direction.xInverse = this.parentSubMenu.options.direction.xInverse; 1292 this.options.direction.y = this.parentSubMenu.options.direction.y; 1293 this.options.direction.yInverse = this.parentSubMenu.options.direction.yInverse; 1294 } 1295 var top; 1296 var overlap 1297 if (this.subMenuType == 'initial') { 1298 if (this.options.direction.y === 'up') { 1299 if (this.options.orientation === 'vertical') { 1300 if (this.btn.is('li') == false) var t = this.btn.parentsUntil('li').eq(0).outerHeight(); 1301 else 1302 var t = this.btn.outerHeight(); 1303 top = this.btn.offset().top - this.subtractScrollTop() + t - this.height + this.options.tweakInitial.y; 1304 } else { 1305 top = this.btn.offset().top - this.subtractScrollTop() - this.height + this.options.tweakInitial.y; 1306 } 1307 //console.log(top); 1308 this.childMenu[0].style.top = top + 'px'; 1309 } else if (this.options.orientation == 'horizontal') { 1310 if (this.btn.is('li') == false) var t = this.btn.parentsUntil('li').eq(0).outerHeight(); 1311 else 1312 var t = this.btn.outerHeight(); 1313 this.childMenu[0].style.top = this.btn.offset().top - this.subtractScrollTop() + t + this.options.tweakInitial.y + 'px'; 1314 } else if (this.options.orientation == 'vertical') { 1315 top = this.btn.offset().top - this.subtractScrollTop() + this.options.tweakInitial.y; 1316 //console.log(top); 1317/* commented out at 3/15/2013 ,vertical menu bug 1318 * if((top + this.childMenu.height()) >= $(document.body).scrollTop()){ 1319 overlap = (top + this.childMenu.height()) - $(document.body).scrollTop() ; 1320 top = top - overlap - 20; 1321 } */ 1322 //console.log(top); 1323 top += this.btn.outerHeight(); 1324 this.childMenu[0].style.top = top + 'px'; 1325 } 1326 if (this.options.orientation == 'horizontal') { 1327 var child_width = this.childMenu.outerWidth(); 1328 var mouse_poz = this.btn.offset().left; 1329 if (this.btn.is('li') == false) var btn_width = this.btn.parentsUntil('li').eq(0).outerWidth(); 1330 else 1331 var btn_width = this.btn.outerWidth(); 1332 var sceen = $(window).width(); 1333 if (this.options.direction.x == 'left') { 1334 if ((mouse_poz - child_width)
1334 < 0) { 1335 if (this.btn.offset().left - child_width + btn_width < 0 && this.btn.offset().left + child_width > sceen) { //console.log(this.btn.offset().left + child_width > sceen); 1336 this.childMenu[0].style.width = this.root.getWidth(); 1337 this.childMenu[0].style['cssFloat'] = (this.childMenu[0].style.width=='auto')?'left':'none'; 1338 this.childMenu.children().each(function(ii, tt) { 1339 $(tt).css({ 1340 'float': 'none', 1341 'width': 'auto' 1342 }); 1343 $(tt).children().each(function(jj, zz) { 1344 $(zz).children().each(function(kk, zzz) { 1345 $(zzz).css({ 1346 'float': 'none' 1347 }); 1348 }); 1349 }); 1350 }); 1351 } else { 1352 this.childMenu[0].style.width = this.root.getWidth(); 1353 this.childMenu[0].style['cssFloat'] = (this.childMenu[0].style.width=='auto')?'left':'none'; 1354 this.childMenu.css({ 1355 /*'width': 'auto', 1356 'float': 'left',*/ 1357 'clear': 'none' 1358 }); 1359 this.childMenu.children().each(function(ii, tt) { 1360 $(tt).css({ 1361 'float': 'left', 1362 'width': 'auto', 1363 'clear': 'none' 1364 }).children().each(function(jj, zz) { 1365 $(zz).children().each(function(kk, zzz) { 1366 $(zzz).css({ 1367 'float': 'left', 1368 'clear': 'none' 1369 }); 1370 }); 1371 }); 1372 }); 1373 } 1374 child_width = $(this.childMenu).outerWidth(); 1375 if (this.btn.offset().left - child_width + btn_width < 20 /* changed from 0 to 20*/ ) { 1376 toleft = this.btn.offset().left; 1377 need = 1; 1378 toleft -= 24; // left+right padding of the menu item class 1379 } else { 1380 toleft = this.btn.offset().left - child_width + btn_width; 1381 need = 0; 1382 } 1383 this.childMenu[0].style.left = toleft + 'px'; 1384 if (need) this.childMenu.className = 's5_sub_wrap_rtl'; 1385 else this.childMenu.className = 's5_sub_wrap'; 1386 } else { 1387 this.childMenu[0].style.width = this.root.getWidth(); 1388 this.childMenu[0].style['cssFloat'] = (this.childMenu[0].style.width=='auto')?'left':'none'; 1389 this.childMenu.css({ 1390 /*'width': 'auto', 1391 'float': 'left',*/ 1392 'clear': 'none' 1393 }); 1394 this.childMenu.children().each(function(ii, tt) { 1395 $(tt).css({ 1396 'width': 'auto', 1397 'float': 'left', 1398 'clear': 'none' 1399 }).children().each(function(jj, zz) { 1400 $(zz).children().each(function(kk, zzz) { 1401 $(zzz).css({ 1402 'float': 'left', 1403 'clear': 'none' 1404 }); 1405 }); 1406 }); 1407 }); 1408 this.childMenu[0].className = 's5_sub_wrap'; 1409 this.childMenu[0].style.marginLeft = '5px'; 1410 child_width = this.childMenu.outerWidth(); 1411 this.childMenu[0].style.left = (this.btn.offset().left - child_width + btn_width) + 'px'; //this.btn.offset().left + this.options.tweakInitial.x + 'px'; 1412 } 1413 } else { 1414 if ((child_width + mouse_poz) > sceen) { 1415 if (this.btn.offset().left - child_width + btn_width < 0) { 1416 this.childMenu[0].style.width = this.root.getWidth(); 1417 this.childMenu[0].style['cssFloat'] = (this.childMenu[0].style.width=='auto')?'left':'none'; 1418 /*this.childMenu.css({ 1419 'width': 'auto', 1420 float: 'none' 1421 });*/ 1422 this.childMenu.children().each(function(ii, tt) { 1423 $(tt).css({ 1424 'width': 'auto', 1425 float: 'none' 1426 }).children().each(function(jj, zz) { 1427 $(zz).children().each(function(kk, zzz) { 1428 $(zzz).css('float', 'none'); 1429 }); 1430 }); 1431 }); 1432 this.childMenu.className = 's5_sub_wrap_rtl'; 1433 } else { 1434 this.childMenu[0].style.width = this.root.getWidth(); 1435 this.childMenu[0].style['cssFloat'] = (this.childMenu[0].style.width=='auto')?'left':'none'; 1436 this.childMenu.css({ 1437 /*'width': 'auto', 1438 'float': 'left',*/ 1439 'clear': 'none' 1440 }); 1441 this.childMenu.children().each(function(ii, tt) { 1442 $(tt).css({ 1443 'float': 'left', 1444 'width': 'auto', 1445 'clear': 'none' 1446 }).children().each(function(jj, zz) { 1447 $(zz).children().each(function(kk, zzz) { 1448 $(zzz).css({ 1449 'float': 'left', 1450 'clear': 'none' 1451 }); 1452 }); 1453 }); 1454 }); 1455 } 1456 child_width = this.childMenu.width(); 1457 if (child_width + this.btn.offset().left < sceen - 20 /* changed from sceen to sceen - 20*/ ) toleft = this.btn.offset().left; 1458 else { 1459 var toleft = this.btn.offset().left - child_width + btn_width; 1460 if (toleft < 0) toleft = this.btn.offset().left; 1461 } 1462 this.childMenu[0].style.left = toleft + 'px'; 1463 if (child_width + this.btn.offset().left < sceen) this.childMenu.className = 's5_sub_wrap'; 1464 else this.childMenu.className = 's5_sub_wrap_rtl'; 1465 } else { 1466 this.childMenu[0].style.width = this.root.getWidth(); 1467 this.childMenu[0].style['cssFloat'] = (this.childMenu[0].style.width=='auto')?'left':'none'; 1468 this.childMenu.children().each(function(ii, tt) { 1469 $(tt).css({ 1470 'float': 'left', 1471 'width': 'auto', 1472 'clear': 'none' 1473 }).children().each(function(jj, zz) { 1474 $(zz).children().each(function(kk, zzz) { 1475 $(zzz).css({ 1476 'float': 'left', 1477 'clear': 'none' 1478 }); 1479 }); 1480 }); 1481 }); 1482 this.childMenu.className = 's5_sub_wrap'; 1483 //this.childMenu[0].style.background='white'; 1484 this.childMenu[0].style.left = this.btn.offset().left + this.options.tweakInitial.x + 'px'; 1485 } 1486 } 1487 } else if (this.options.direction.x == 'left') { 1488 this.childMenu[0].style.left = this.btn.offset().left - this.childMenu.width() + this.options.tweakInitial.x + 'px'; 1489 } else if (this.options.direction.x == 'right') { 1490 if (this.btn.is('li') == false) var bw = this.btn.parentsUntil('li').eq(0).outerWidth(); 1491 else 1492 var bw = this.btn.outerWidth(); 1493 this.childMenu[0].style.left = this.btn.offset().left + bw + this.options.tweakInitial.x + 'px'; 1494 } 1495 } else if (this.subMenuType == 'subsequent') { 1496 if (this.options.direction.y === 'down') { 1497 if ((this.btn.offset().top + this.options.tweakSubsequent.y + this.childMenu.height()) >= $(document.body).scrollTop()) { 1498 overlap = (this.btn.offset().top - this.subtractScrollTop() + this.options.tweakSubsequent.y + this.childMenu.height()); 1499 this.childMenu[0].style.top = (this.btn.offset().top - this.subtractScrollTop() + this.options.tweakSubsequent.y) - overlap - 20 + 'px'; 1500 } else { 1501 this.childMenu[0].style.top = this.btn.offset().top - this.subtractScrollTop() + this.options.tweakSubsequent.y + 'px'; 1502 } 1503 } else if (this.options.direction.y === 'up') { 1504 if (this.btn.is('li') == false) var t = this.btn.parentsUntil('li').eq(0).outerHeight(); 1505 else 1506 var t = this.btn.outerHeight(); 1507 if ((this.btn.offset().top + t - this.subtractScrollTop() - this.height + this.options.tweakSubsequent.y) < 1) { 1508 this.options.direction.y = 'down'; 1509 this.options.direction.yInverse = 'up'; 1510 this.childMenu[0].style.top = this.btn.offset().top - this.subtractScrollTop() + this.options.tweakSubsequent.y + 'px'; 1511 } else { 1512 if (this.btn.is('li') == false) var t = this.btn.parentsUntil('li').eq(0).outerHeight(); 1513 else 1514 var t = this.btn.outerHeight(); 1515 this.childMenu[0].style.top = this.btn.offset().top - this.subtractScrollTop() + t - this.height + this.options.tweakSubsequent.y + 'px'; 1516 } 1517 } 1518 if (this.options.direction.x == 'left') { 1519 this.childMenu[0].style.left = this.btn.offset().left - this.childMenu.width() + this.options.tweakSubsequent.x + 'px'; 1520 this.childMenu[0].style.top = this.btn.offset().top - this.subtractScrollTop() + this.options.tweakSubsequent.x + 'px'; 1521 if (this.childMenu.offset().left < 20) { 1522 //console.log('it was '+this.options.direction.x); 1523 this.options.olddirection.x = this.options.direction.x; 1524 this.options.direction.x = 'right'; 1525 //console.log('to right'); 1526 this.options.direction.xInverse = 'left'; 1527 if (this.btn.is('li') == false) var bw = this.btn.parentsUntil('li').eq(0).outerWidth(); 1528 else 1529 var bw = this.btn.outerWidth(); 1530 this.childMenu[0].style.left = this.btn.offset().left + bw + this.options.tweakSubsequent.x + 'px'; 1531 this.childMenu.className = 's5_sub_wrap_lower_rtl'; 1532 if (this.options.effect === 'slide' || this.options.effect === 'slide & fade') { 1533 $(this.childMenu).getFirst().css({ 1534 'marginLeft': -this.width, 1535 'opacity': this.options.opacity 1536 }); 1537 } 1538 } 1539 } else if (this.options.direction.x == 'right') { 1540 if (this.btn.is('li') == false) var bw = this.btn.parentsUntil('li').eq(0).outerWidth(); 1541 else 1542 var bw = this.btn.outerWidth(); 1543 this.childMenu[0].style.top = this.btn.offset().top - this.subtractScrollTop() + this.options.tweakSubsequent.x + 'px'; 1544 this.childMenu[0].style.left = this.btn.offset().left + bw + this.options.tweakSubsequent.x + 'px'; 1545 var smRight = this.childMenu.offset().left + this.childMenu.width(); 1546 var viewportRightEdge = $(window).width() + $(window).scrollLeft() - 20; 1547 if (smRight > viewportRightEdge) { 1548 //console.log('it was '+this.options.direction.x); 1549 this.options.olddirection.x = this.options.direction.x; 1550 this.options.direction.x = 'left'; 1551 //console.log(' to left'); 1552 this.options.direction.xInverse = 'right'; 1553 var child_width = this.childMenu.outerWidth(); 1554 var mouse_poz = this.btn.offset().left; 1555 var sceen = $(window).width(); 1556 if ((child_width + mouse_poz) > sceen) { 1557 this.childMenu[0].style.right = this.btn.offset().left + this.options.tweakSubsequent.x + 'px'; 1558 } else { 1559 this.childMenu[0].style.left = this.btn.offset().left - this.childMenu.width() + this.options.tweakSubsequent.x + 'px'; 1560 this.childMenu.className = 's5_sub_wrap_lower_rtl'; 1561 } 1562 if (this.options.effect === 'slide' || this.options.effect === 'slide & fade') { 1563 $(this.childMenu).getFirst().css({ 1564 'marginLeft': this.width, 1565 'opacity': this.options.opacity 1566 }); 1567 } 1568 } 1569 } 1570 } 1571 //this.options.onPositionSubMenu_complete(this); 1572 }; 1573 MenuMaticSubMenu.prototype.subtractScrollTop = function() { 1574 return $('#' + this.options.id).offset().top != $('#' + this.options.id).position().top ? $(window).scrollTop() : 0; 1575 } 1576 MenuMaticSubMenu.prototype.initialize = function(options, root2, btn2, current_index) { 1577 //var options = this.options = Object.merge.apply(null, [{}, this.options].append(arguments)); 1578 this.options = $.extend(options, this.options); 1579/* if (this.addEvent) for (var option in options){ 1580 if (typeOf(options[option]) != 'function' || !(/^on[A-Z]/).test(option)) continue; 1581 this.bind(option, options[option]); 1582 delete options[option]; 1583 } 1584 */ 1585 this.root = root2; 1586 this.btn = btn2; 1587 this.childMenu = $(this.btn).data('childMenu'); 1588 if (!this.childMenu) return; 1589 this.subMenuType = this.btn.data('subMenuType'); 1590 //this.childMenu = this.btn.data('childMenu'); 1591 this.parentSubMenus = $(this.btn.data('parentSubMenus')); 1592 this.parentLinks = this.btn.data('parentLinks'); 1593 //console.log(this.btn.data('parentLinks')); 1594 //if(this.parentLinks.length==0) return; 1595 if (this.parentSubMenus) this.parentSubMenu = $(this.parentSubMenus[0]); 1596 else this.parentSubMenu = null; 1597 if (this.parentSubMenu) { 1598 this.parentSubMenu = this.parentSubMenu.data('class'); 1599 } 1600 this.childMenu.data('class', this); 1601 this.btn.data('class', this); 1602 this.childMenu.data('status', 'closed'); 1603 //this.options.onSubMenuInit_begin(this); 1604 //add hide Event 1605 this.childMenu.bind('hidex', (function() { 1606 this.hideSubMenu(); 1607 }).bind(this)); // silviu commented 1608 //add show Event 1609 this.childMenu.bind('show', (function() { 1610 this.showSubMenu(); 1611 }).bind(this)); 1612 if (this.options.effect) { 1613/*this.myEffect = new Fx.Morph( 1614 $(this.childMenu).getFirst(), { duration: this.options.duration, transition: this.options.physics, link: 'cancel' } 1615 );*/ 1616 } 1617 if (this.options.effect === 'slide' || this.options.effect === 'slide & fade') { 1618 if (this.subMenuType == 'initial' && this.options.orientation === 'horizontal') { 1619 this.childMenu.getFirst().css('marginTop', '0'); 1620 } else { 1621 this.childMenu.getFirst().css('marginLeft', '0'); 1622 } 1623 } else if (this.options.effect === 'fade' || this.options.effect === 'slide & fade') { 1624 this.childMenu.getFirst().css('opacity', 0); 1625 } 1626 if (this.options.effect != 'fade' && this.options.effect != 'slide & fade') { 1627 this.childMenu.getFirst().css('opacity', this.options.opacity); 1628 } 1629 this.childMenu.getFirst().css('float', 'left'); 1630 //attach event handlers to non-parent sub menu buttons 1631 //var nonParentBtns = $(this.childMenu).getElements('li').filter(function(item, index){ return !$(item).data('childMenu'); }); 1632 var nonParentBtnsP = $("#li_child_" + current_index + ' ul'); 1633 nonParentBtnsP.each((function(index, item) { 1634 var nonParentBtns = $('li', $(item)).filter(function(index, item) { 1635 return !$(item).data('childMenu'); 1636 }); 1637 nonParentBtns.each((function(index, item) { 1638 $(item).addClass('subMenuBtn'); 1639 $(item).bind('mouseenter', (function(e) { 1640 this.childMenu.trigger('show'); 1641 this.cancellHideAllSubMenus(); 1642 this.hideOtherSubMenus(); 1643 }).bind(this)); 1644 $(item).data('mouseenterH', (function(e) { 1645 this.childMenu.trigger('show'); 1646 this.cancellHideAllSubMenus(); 1647 this.hideOtherSubMenus(); 1648 }).bind(this)); 1649 $(item).bind('focus', (function(e) { 1650 this.childMenu.trigger('show'); 1651 this.cancellHideAllSubMenus(); 1652 this.hideOtherSubMenus(); 1653 }).bind(this)); 1654 $(item).bind('mouseleave', (function(e) { // return false;
1655 this.cancellHideAllSubMenus(); 1656 this.hideAllSubMenus(); 1657 }).bind(this)); 1658 $(item).data('mouseleaveH', (function(e) { // return false; 1659 this.cancellHideAllSubMenus(); 1660 this.hideAllSubMenus(); 1661 }).bind(this)); 1662 $(item).bind('blur', (function(e) { 1663 this.cancellHideAllSubMenus(); 1664 this.hideAllSubMenus(); 1665 }).bind(this)); 1666 $(item).bind('keydown', (function(e) { 1667 var event = new Event(e); 1668 if (e.key === 'up' || e.key === 'down' || e.key === 'left' || e.key === 'right' || e.key === 'tab') { 1669 e.stop(); 1670 } 1671 if (e.key === 'up') { 1672 if ($(item).parents('li').getPrevious('li')) { 1673 //move focus to the next link up if possible 1674 $(item).parents('li').getPrevious('li').getFirst('a').focus(); 1675 } else if (this.options.direction.y === 'down') { 1676 //move focus to the parent link 1677 this.btn.focus(); 1678 } else if (this.options.direction.y === 'up') { 1679 //move focus to the last link in the subMenu 1680 $(item).parents('li').parent().getLast('li').getFirst('a').focus(); 1681 } 1682 } else if (e.key === 'down') { 1683 if ($(item).parents('li').getNext('li')) { 1684 //move focus to the next link down if possible 1685 $(item).parents('li').getNext('li').getFirst('a').focus(); 1686 } else if (this.options.direction.y === 'down') { 1687 //move focus to the first link in the submenu 1688 $(item).parents('li').parent().getFirst('li').getFirst('a').focus(); 1689 } else if (this.options.direction.y === 'up') { 1690 //move focus to the parent link 1691 this.btn.focus(); 1692 } 1693 } else if (e.key === this.options.direction.xInverse) { 1694 this.btn.focus(); 1695 } 1696 }).bind(this)); 1697 }).bind(this)); 1698 }).bind(this)); 1699 this.btn.removeClass('subMenuBtn'); 1700 if (this.subMenuType == 'initial') { 1701 this.btn.addClass('mainParentBtn'); 1702 } else { 1703 this.btn.addClass('subParentBtn'); 1704 } 1705 //attach event handlers to parent button 1706 this.btn.bind('mouseenter', (function(e) { 1707 e.preventDefault(); 1708 this.cancellHideAllSubMenus(); 1709 this.hideOtherSubMenus(); 1710 //if(this.options.opacity == this.btn.parents('ul').getStyle('opacity') || this.btn.parents('ul').getStyle('opacity') == 1){ 1711 setTimeout((function() { 1712 this.showSubMenu(); 1713 }).bind(this), 10); 1714 //} 1715 if (this.subMenuType === 'initial' && this.options.mmbClassName && this.options.mmbFocusedClassName) { 1716 if ($(this.btn).data('btnMorph')) $(this.btn).data('btnMorph'); 1717 else this.btn.switchClass(this.options.mmbFocusedClassName, '', this.options.duration / 2, this.options.physics); 1718 } 1719 }).bind(this)).data('mouseenterH', (function(e) { 1720 e.preventDefault(); 1721 this.cancellHideAllSubMenus(); 1722 this.hideOtherSubMenus(); 1723 //if(this.options.opacity == this.btn.parents('ul').getStyle('opacity') || this.btn.parents('ul').getStyle('opacity') == 1){ 1724 setTimeout((function() { 1725 this.showSubMenu(); 1726 }).bind(this), 10); 1727 //} 1728 if (this.subMenuType === 'initial' && this.options.mmbClassName && this.options.mmbFocusedClassName) { 1729 if ($(this.btn).data('btnMorph')) $(this.btn).data('btnMorph'); 1730 else this.btn.switchClass(this.options.mmbFocusedClassName, '', this.options.duration / 2, this.options.physics); 1731 } 1732 }).bind(this)); 1733 this.btn.bind('focus', (function(e) { 1734 e.preventDefault(); 1735 this.cancellHideAllSubMenus(); 1736 this.hideOtherSubMenus(); 1737 this.showSubMenu(); 1738 if (this.subMenuType === 'initial' && this.options.mmbClassName && this.options.mmbFocusedClassName) { 1739 if ($(this.btn).data('btnMorph')) $(this.btn).data('btnMorph'); 1740 else this.btn.switchClass(this.options.mmbFocusedClassName, '', this.options.duration / 2, this.options.physics); 1741 } 1742 }).bind(this)); 1743 this.btn.bind('mouseleave', (function(e) { //return false;
1744 e.preventDefault(); 1745 this.cancellHideAllSubMenus(); 1746 this.hideAllSubMenus(); 1747 }).bind(this)).data('mouseleaveHander', (function(e) { //return false; 1748 e.preventDefault(); 1749 this.cancellHideAllSubMenus(); 1750 this.hideAllSubMenus(); 1751 }).bind(this));; 1752 this.btn.bind('blur', (function(e) { 1753 e.preventDefault(); 1754 this.cancellHideAllSubMenus(); 1755 this.hideAllSubMenus(); 1756 }).bind(this)); 1757 this.btn.bind('keydown', (function(e) { 1758 e = new Event(e) 1759 if (e.key === 'up' || e.key === 'down' || e.key === 'left' || e.key === 'right') { 1760 e.stop(); 1761 } 1762 if (!this.parentSubMenu) { 1763 //main menu parent buttons 1764 if ( 1765 this.options.orientation === 'horizontal' && e.key === this.options.direction.y || this.options.orientation === 'vertical' && e.key === this.options.direction.x) { 1766 if (this.options.direction.y === 'down') { 1767 //move focus to the first link in the child menu 1768 this.childMenu.getFirst().getFirst('li').getFirst('a').focus(); 1769 } else if (this.options.direction.y === 'up') { 1770 //move focus to the first link in the child menu 1771 this.childMenu.getFirst().getLast('li').getFirst('a').focus(); 1772 } 1773 } else if ( 1774 this.options.orientation === 'horizontal' && e.key === 'left' || this.options.orientation === 'vertical' && e.key === this.options.direction.yInverse) { 1775 //move focus to the previous link if possible, if not, move focus to the last link in the menu 1776 if (this.btn.parent().getPrevious()) { 1777 this.btn.parent().getPrevious().getFirst().focus(); 1778 } else { 1779 this.btn.parent().parent().getLast().getFirst().focus(); 1780 } 1781 } else if ( 1782 this.options.orientation === 'horizontal' && e.key === 'right' || this.options.orientation === 'vertical' && e.key === this.options.direction.y) { 1783 //move focus to the next link if possible, if not, move focus to the first link in the menu 1784 if (this.btn.parent().getNext()) { 1785 this.btn.parent().getNext().getFirst().focus(); 1786 } else { 1787 this.btn.parent().parent().getFirst().getFirst().focus(); 1788 } 1789 } 1790 } else { 1791 if (e.key === 'tab') { 1792 e.stop(); 1793 } 1794 //submenu parent buttons 1795 if (e.key === 'up') { 1796 if (this.btn.parents('li').getPrevious('li')) { 1797 //move focus to the next link up 1798 this.btn.parents('li').getPrevious('li').getFirst('a').focus(); 1799 } else if (this.options.direction.y === 'down') { 1800 //move focus to the parent link 1801 this.parentSubMenu.btn.focus(); 1802 } else if (this.options.direction.y === 'up') { 1803 //move focus to the bottom link in this submenu 1804 this.btn.parents('li').parent().getLast('li').getFirst('a').focus(); 1805 } 1806 } else if (e.key === 'down') { 1807 if (this.btn.parents('li').getNext('li')) { 1808 //move focus to the next link down 1809 this.btn.parents('li').getNext('li').getFirst('a').focus(); 1810 } else if (this.options.direction.y === 'down') { 1811 //move focus to the top link in this submenu 1812 this.btn.parents('li').parent().getFirst('li').getFirst('a').focus(); 1813 } else if (this.options.direction.y === 'up') { 1814 //move focus to the parent link 1815 this.parentSubMenu.btn.focus(); 1816 } 1817 } else if (e.key === this.options.direction.xInverse) { 1818 this.parentSubMenu.btn.focus(); 1819 } else if (e.key === this.options.direction.x) { 1820 if (this.options.direction.y === 'down') { 1821 this.childMenu.getFirst().getFirst('li').getFirst('a').focus(); 1822 } else if (this.options.direction.y === 'up') { 1823 // this.childMenu.getFirst().getLast('li').getFirst('a').focus(); 1824 } 1825 } 1826 } 1827 }).bind(this)); 1828 //this.options.onSubMenuInit_complete(this); 1829 } 1830})(jQuery); 1831 1832function s5_create_separator_class() { 1833 if (document.getElementById("subMenusContainer")) { 1834 var s5_create_separator_class = document.getElementById("subMenusContainer").getElementsByTagName("A"); 1835 for (var s5_create_separator_class_z = 0; s5_create_separator_class_z < s5_create_separator_class.length; s5_create_separator_class_z++) { 1836 if (s5_create_separator_class[s5_create_separator_class_z].href == "javascript:;") { 1837 if (s5_create_separator_class[s5_create_separator_class_z].parentNode.className == "S5_submenu_item") { 1838 s5_create_separator_class[s5_create_separator_class_z].parentNode.parentNode.className = s5_create_separator_class[s5_create_separator_class_z].parentNode.parentNode.className + " subSepBtn"; 1839 } 1840 } 1841 } 1842 } 1843} 1844window.onload = s5_create_separator_class;
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.