1/** 2 * @copyright Copyright (C) 2012 Cedric KEIFLIN alias ced1870 3 * http://www.joomlack.fr 4 * Module Maximenu CK 5 * @license GNU/GPL 6 * */ 7 8(function($) { 9 10 //define the defaults for the plugin and how to call it 11 $.fn.DropdownMaxiMenu = function(options) { 12 //set default options 13 var defaults = { 14 fxtransition: 'linear', 15 fxduration: 500, 16 menuID: 'maximenuck', 17 testoverflow: '0', 18 orientation: 'horizontal', 19 behavior: 'mouseover', 20 opentype: 'open', 21 direction: 'normal', 22 directionoffset1: '30', 23 directionoffset2: '30', 24 dureeIn: 0, 25 dureeOut: 500, 26 ismobile: false, 27 menuposition: '0', 28 showactivesubitems: '0', 29 topfixedeffect: '1', 30 effecttype: 'dropdown' 31 }; 32 33 //call in the default otions 34 var options = $.extend(defaults, options); 35 var maximenuObj = this; 36 37 //act upon the element that is passed into the design 38 return maximenuObj.each(function(options) { 39 40 var fxtransition = defaults.fxtransition; 41 var fxduration = defaults.fxduration; 42 var dureeOut = defaults.dureeOut; 43 var dureeIn = defaults.dureeIn; 44 // var useOpacity = defaults.useOpacity; 45 var menuID = defaults.menuID; 46 var orientation = defaults.orientation; 47 var behavior = defaults.behavior; 48 var opentype = defaults.opentype; 49 var fxdirection = defaults.fxdirection; 50 var directionoffset1 = defaults.directionoffset1; 51 var directionoffset2 = defaults.directionoffset2; 52 var ismobile = defaults.ismobile; 53 var showactivesubitems = defaults.showactivesubitems; 54 var testoverflow = defaults.testoverflow; 55 var effecttype = defaults.effecttype; 56 var transitiontype = 0; 57 var status = new Array(); 58 59 maximenuInit(); 60 61 if (defaults.menuposition == 'topfixed') { 62 var menuy = $(this).offset().top; 63 $(document.body).attr('data-margintop', $(document.body).css('margin-top')); 64 maximenuObj.menuHeight = $(this).height(); 65 $(window).bind('scroll', function() { 66 if ($(window).scrollTop() > menuy && !maximenuObj.hasClass('maximenufixed')) { 67 if (defaults.topfixedeffect == '0') { 68 maximenuObj.after('<div id="'+maximenuObj.attr('id')+'tmp"></div>') 69// $('#'+maximenuObj.attr('id')+'tmp').css('visibility', 'hidden').html(maximenuObj.html()); 70 $('#'+maximenuObj.attr('id')+'tmp').css('visibility', 'hidden').height(maximenuObj.height()); 71 maximenuObj.addClass('maximenufixed'); 72// $(document.body).css('margin-top', parseInt(maximenuObj.menuHeight)); 73 } else { 74 maximenuObj.css('opacity', '0').css('margin-top', '-' + parseInt(maximenuObj.height()) + 'px').animate({'opacity': '1', 'margin-top': '0'}, 500).addClass('maximenufixed'); 75 $(document.body).css('margin-top', parseInt(maximenuObj.menuHeight)); 76 } 77 } else if ($(window).scrollTop() <= menuy) { 78 $(document.body).css('margin-top', $(document.body).attr('data-margintop')); 79 maximenuObj.removeClass('maximenufixed'); 80 $('#'+maximenuObj.attr('id')+'tmp').remove(); 81 } 82 }); 83 } else if (defaults.menuposition == 'bottomfixed') { 84 $(this).addClass('maximenufixed').find('ul.maximenuck').css('position', 'static'); 85 } 86 87 function openMaximenuck(el) { 88 if ((el.data('status') == 'opened' ) 89 || (status[el.data('level') - 1] == 'showing' && opentype == 'drop') 90 ) 91 return; 92 // if (el.hasClass('fullwidth') && maximenuObj.hasClass('maximenuckh') ) { 93 // el.submenu.css('display', 'block').css('left', '0'); 94 // } else { 95 el.submenu.css('display', 'block'); 96 // } 97 // el.submenuHeight = el.submenu.height(); 98 if (effecttype == 'pushdown') { 99 el.submenu.css('position','relative'); 100 } 101 if (opentype != 'noeffect') 102 status[el.data('level')] = 'showing'; 103 104 switch (opentype) { 105 case 'noeffect': 106 status[el.data('level')] = ''; 107 el.data('status', 'opened'); 108 break; 109 case 'slide': 110 if (el.data('status') == 'opening') 111 break; 112 el.data('status', 'opening'); 113 el.submenu.css('overflow', 'hidden'); 114 el.submenu.stop(true, true); 115 slideconteneur = $('.maximenuck2', el); 116 if (el.hasClass('level1') && orientation == 'horizontal') { 117 slideconteneur.css('marginTop', -el.submenuHeight); 118 slideconteneur.animate({ 119 marginTop: 0 120 }, {
121 duration: fxduration, 122 queue: false, 123 easing: fxtransition, 124 complete: function() { 125 status[el.data('level')] = ''; 126 el.submenu.css('overflow', 'visible'); 127 el.data('status', 'opened'); 128 } 129 }); 130 el.submenu.animate({ 131 'max-height': el.submenuHeight 132 }, { 133 duration: fxduration, 134 queue: false, 135 easing: fxtransition, 136 complete: function() { 137 $(this).css('max-height', ''); 138 status[el.data('level')] = ''; 139 el.submenu.css('overflow', 'visible'); 140 el.data('status', 'opened'); 141 } 142 }); 143 } else { 144 slideconteneur.css('marginLeft', -el.submenu.width()); 145 slideconteneur.animate({ 146 marginLeft: 0 147 }, { 148 duration: fxduration, 149 queue: false, 150 easing: fxtransition, 151 complete: function() { 152 status[el.data('level')] = ''; 153 el.submenu.css('overflow', 'visible'); 154 el.data('status', 'opened'); 155 } 156 }); 157 el.submenu.animate({ 158 'max-width': el.submenu.width() 159 }, { 160 duration: fxduration, 161 queue: false, 162 easing: fxtransition, 163 complete: function() { 164 status[el.data('level')] = ''; 165 el.submenu.css('overflow', 'visible'); 166 el.data('status', 'opened'); 167 } 168 }); 169 } 170 break; 171 case 'show': 172 el.data('status', 'opening'); 173 el.submenu.hide(); 174 el.submenu.stop(true, true); 175 el.submenu.show(fxduration, fxtransition, { 176 complete: function() { 177 status[el.data('level')] = ''; 178 el.data('status', 'opened'); 179 } 180 }); 181 el.data('status', 'opened'); 182 break; 183 case 'fade': 184 el.data('status', 'opening'); 185 el.submenu.hide(); 186 el.submenu.stop(true, true); 187 el.submenu.fadeIn(fxduration, fxtransition, { 188 complete: function() { 189 status[el.data('level')] = ''; 190 el.data('status', 'opened'); 191 } 192 }); 193 el.data('status', 'opened'); 194 break; 195 case 'scale': 196 el.data('status', 'opening'); 197 if (!el.hasClass('level1') || orientation == 'vertical') { 198 el.submenu.css('margin-left',el.submenu.width()); 199 } 200 el.submenu.hide(); 201 el.submenu.stop(true, true); 202 el.submenu.show("scale", { 203 duration: fxduration, 204 easing: fxtransition, 205 complete: function() { 206 status[el.data('level')] = ''; 207 el.data('status', 'opened'); 208 } 209 }); 210 el.data('status', 'opened'); 211 break; 212 case 'puff': 213 el.data('status', 'opening'); 214 if (!el.hasClass('level1') || orientation == 'vertical') { 215 el.submenu.css('margin-left',el.submenu.width()); 216 } 217 el.submenu.stop(true, true); 218 el.submenu.show("puff", { 219 duration: fxduration, 220 easing: fxtransition, 221 complete: function() { 222 status[el.data('level')] = ''; 223 // el.data('status','opened'); 224 } 225 }); 226 el.data('status', 'opened'); 227 break; 228 case 'drop': 229 el.data('status', 'opening'); 230 if (!el.hasClass('level1') || orientation == 'vertical') { 231 el.submenu.css('margin-left',el.submenu.width()); 232 } 233 el.submenu.stop(true, true); 234 if (el.hasClass('level1') && orientation == 'horizontal') { 235 if (fxdirection == 'inverse') { 236 dropdirection = 'down'; 237 el.submenu.css('bottom', directionoffset1 + 'px'); 238 } else { 239 dropdirection = 'up'; 240 } 241 } else { 242 if (fxdirection == 'inverse') { 243 dropdirection = 'right'; 244 el.submenu.css('right', directionoffset2 + 'px'); 245 } else { 246 el.submenu.css('margin-left',el.submenu.width()); 247 dropdirection = 'left'; 248 } 249 } 250 el.submenu.show("drop", { 251 direction: dropdirection, 252 duration: fxduration, 253 easing: fxtransition, 254 complete: function() { 255 status[el.data('level')] = ''; 256 // el.data('status','opened'); 257 } 258 }); 259 el.data('status', 'opened'); 260 break; 261 case 'open': 262 default: 263 el.data('status', 'opening'); 264 el.submenu.stop(); 265 el.submenu.css('overflow', 'hidden'); 266 if (el.hasClass('level1') && orientation == 'horizontal') { 267 el.submenu.animate({ 268 'max-height': el.submenuHeight 269 }, {
270 duration: fxduration, 271 queue: false, 272 easing: fxtransition, 273 complete: function() { 274 $(this).css('max-height', ''); 275 status[el.data('level')] = ''; 276 if (effecttype == 'dropdown') el.submenu.css('overflow', 'visible'); 277 el.data('status', 'opened'); 278 } 279 }); 280 } else { 281 el.submenu.animate({ 282 'max-width': el.submenu.width() 283 }, { 284 duration: fxduration, 285 queue: false, 286 easing: fxtransition, 287 complete: function() { 288 $(this).css('max-width', ''); 289 status[el.data('level')] = ''; 290 if (effecttype == 'dropdown') el.submenu.css('overflow', 'visible'); 291 el.data('status', 'opened'); 292 } 293 }); 294 } 295 break; 296 } 297 } 298 299 function closeMaximenuck(el) { 300 el.submenu.stop(true, true); 301 status[el.data('level')] = ''; 302 el.data('status', 'closing'); 303 switch (opentype) { 304 case 'noeffect': 305 el.submenu.css('display', 'none'); 306 // el.submenu.css('position','absolute'); 307 status[el.data('level')] = ''; 308 el.data('status', 'closed'); 309 break; 310 case 'fade': 311 el.submenu.fadeOut(fxduration, fxtransition, { 312 complete: function() { 313 status[el.data('level')] = ''; 314 el.data('status', 'closed'); 315 } 316 }); 317 el.data('status', 'closed'); 318 break; 319 case 'slide': 320 if (el.hasClass('level1') && orientation == 'horizontal') { 321 el.submenu.css('max-height', ''); 322 } else { 323 el.submenu.css('max-width', ''); 324 } 325 el.submenu.css('display', 'none'); 326 el.submenu.css('position','absolute'); 327 status[el.data('level')] = ''; 328 el.data('status', 'closed'); 329 break; 330 case 'open': 331 el.submenu.stop(); 332 el.submenuHeight = el.submenu.height(); 333 status[el.data('level')] = ''; 334 el.submenu.css('overflow', 'hidden'); 335 el.data('status','closing'); 336 if (el.hasClass('level1') && orientation == 'horizontal') { 337 el.submenu.css('overflow', 'hidden').css('max-height', el.submenu.height()).animate({ 338 'max-height': 0 339 }, { 340 duration: fxduration, 341 queue: false, 342 easing: fxtransition, 343 complete: function() { 344 el.submenu.css('max-height', ''); 345 el.submenu.css('display', 'none'); 346 el.submenu.css('position','absolute'); 347 status[el.data('level')] = ''; 348 el.data('status', 'closed'); 349 } 350 }); 351 } else { 352 el.submenu.css('max-width', ''); 353 el.submenu.css('display', 'none'); 354 el.submenu.css('position','absolute'); 355 status[el.data('level')] = ''; 356 el.data('status', 'closed'); 357 } 358 break; 359 default: 360 case 'drop': 361 el.submenu.hide(0, { 362 complete: function() { 363 status[el.data('level')] = ''; 364 el.data('status', 'closed'); 365 } 366 }); 367 el.data('status', 'closed'); 368 break; 369 } 370 } 371 372 function showSubmenuck(el) { 373 el.css('z-index', 15000); 374 el.submenu.css('z-index', 15000); 375 clearTimeout(el.timeout); 376 el.timeout = setTimeout(function() { 377 openMaximenuck(el); 378 }, dureeIn); 379 } 380 381 function hideSubmenuck(el) { 382 if (effecttype == 'pushdown' && el.data('status') != 'closing') { 383 closeMaximenuck(el); 384 } else if (effecttype != 'pushdown') { 385 el.css('z-index', 12001); 386 el.submenu.css('z-index', 12001); 387 clearTimeout(el.timeout); 388 el.timeout = setTimeout(function() { 389 closeMaximenuck(el); 390 }, dureeOut); 391 } 392 } 393 394 function testOverflowmenuck(el) { 395 if (el.hasClass('fullwidth')) return; 396 var pageWidth = $(window).outerWidth(); 397 el.submenu.removeClass('fixRight').css('right', ''); 398 var elOffset = el.submenu.attr('data-display', el.submenu.css('display')).css({'opacity':'0','display':'block'}).offset(); 399 el.submenu.css({'opacity':'1', 'display': el.submenu.attr('data-display')}); 400 el.submenu.removeAttr('data-display'); 401 402 var elementPositionX = elOffset.left + el.submenu.width(); 403 if (elementPositionX > pageWidth) { 404 if ((el.data('level')) == 1) { 405 el.submenu.css('right', '0px'); 406 } else { 407 el.submenu.css('right', el.outerWidth()); 408 } 409 el.submenu.css('marginRight', '0px'); 410 el.submenu.addClass('fixRight'); 411 } else { 412 el.submenu.removeClass('fixRight'); 413 el.submenu.css('right', ''); 414 } 415 416 if (orientation != 'vertical') return; 417 var boundTop = $(document).scrollTop(); 418 var boundBottom = boundTop + $(window).height(); 419 420 var elementPositionY = elOffset.top + el.submenu.height(); 421 elDataMarginTop = el.submenu.attr('data-margin-top') ? parseInt(el.submenu.attr('data-margin-top')) : parseInt(el.submenu.css('margin-top')); 422 if (elementPositionY >
422 boundBottom) { 423 el.submenu.attr('data-margin-top', el.submenu.css('margin-top')).css('margin-top', '-=' + (elementPositionY - boundBottom + 10) + 'px'); 424 } else if (elOffset.top + el.submenu.height() - (parseInt(el.submenu.css('margin-top')) - elDataMarginTop) < boundBottom) { 425 if (el.submenu.attr('data-margin-top')) el.submenu.css('margin-top', elDataMarginTop + 'px').removeAttr('data-margin-top'); 426 } 427 } 428 429 function maximenuInit() { 430 if (effecttype == 'pushdown') { 431 $('li.maximenuck.level1', maximenuObj).each(function(i, el) { 432 if (!$(el).hasClass('parent')) { 433 $(el).mouseenter(function() { 434 $('li.maximenuck.level1.parent', maximenuObj).each(function(j, el2) { 435 el2 = $(el2); 436 if ($(el).prop('class') != el2.prop('class')) { 437 el2.submenu = $('> .maxipushdownck > .floatck',maximenuObj).eq(j); 438 hideSubmenuck(el2); 439 } 440 }); 441 }); 442 } 443 }); 444 els = $('li.maximenuck.level1.parent', maximenuObj); 445 } else { 446 els = $('li.maximenuck.parent', maximenuObj); 447 } 448 els.each(function(i, el) { 449 el = $(el); 450 // test if dropdown is required 451 if (el.hasClass('nodropdown')) { 452 return true; 453 } 454 // manage item level 455 if (el.hasClass('level1')) 456 el.data('level', 1); 457 $('li.maximenuck.parent', el).each(function(j, child) { 458 $(child).data('level', el.data('level') + 1); 459 }); 460 // manage submenus 461 if (effecttype == 'pushdown') { 462 el.submenu = $('> .maxipushdownck > .floatck',maximenuObj).eq(i); 463 el.submenu.find('> .maxidrop-main') 464 .css('width','inherit') 465 .css('overflow','hidden'); 466 el.submenu.hover(function() {el.addClass('hover');}, function() {el.removeClass('hover');}); 467 } else { 468 el.submenu = $('> .floatck', el); 469 el.submenu.css('position', 'absolute'); 470 el.addClass('maximenuckanimation'); 471 } 472 el.submenuHeight = el.submenu.height(); 473 el.submenuWidth = el.submenu.width(); 474 475 if (opentype == 'noeffect' || opentype == 'open' || opentype == 'slide') { 476 el.submenu.css('display', 'none'); 477 } else { 478 el.submenu.css('display', 'block'); 479 el.submenu.hide(); 480 } 481 482 // if (opentype == 'open' || opentype == 'slide') { 483 // if (el.hasClass('level1') && orientation == 'horizontal') { 484 // el.submenu.css('max-height', '0'); 485 // } else { 486 // el.submenu.css('max-width', '0'); 487 // } 488 // } 489 //manage active submenus 490 if ( (showactivesubitems == '1' && el.hasClass('active')) || el.hasClass('openck')) { 491 if (el.hasClass('fullwidth')) { 492 el.submenu.css('display', 'block'); 493 if (orientation == 'horizontal') el.submenu.css('left', '0'); 494 } else { 495 el.submenu.css('display', 'block'); 496 } 497 el.submenu.css('max-height', ''); 498 el.submenu.show(); 499 } 500 // manage inverse direction 501 if (fxdirection == 'inverse' && el.hasClass('level1') && orientation == 'horizontal') 502 el.submenu.css('bottom', directionoffset1 + 'px'); 503 if (fxdirection == 'inverse' && el.hasClass('level1') && orientation == 'vertical') 504 el.submenu.css('right', directionoffset1 + 'px'); 505 if (fxdirection == 'inverse' && !el.hasClass('level1') && orientation == 'vertical') 506 el.submenu.css('right', directionoffset2 + 'px'); 507 508 var itembehavior = el.hasClass('showonclick') ? (el.hasClass('clickclose') ? 'showonclickclose' : 'click') : (el.hasClass('clickclose') ? 'clickclose' : behavior); 509 if (itembehavior == 'showonclickclose') { 510 $('> a.maximenuck,> span.separator,> span.nav-header', el).click(function(e) { 511 e.preventDefault(); 512 if (testoverflow == '1') 513 testOverflowmenuck(el); 514 // $('li.maximenuck.parent.level' + el.data('level'), maximenuObj).each(function(j, el2) { 515 // el2 = $(el2); 516 // if (el.prop('class') != el2.prop('class')) { 517 // if (effecttype == 'pushdown') { 518 // el2.submenu = $('> .maxipushdownck > .floatck',maximenuObj).eq(j); 519 // } else { 520 // el2.submenu = $('> .floatck', el2); 521 // } 522 // hideSubmenuck(el2); 523 // } 524 // }); 525 $('li.maximenuck', $(el)).removeClass('clickedck').removeClass('openck'); 526 $(el).removeClass('clickedck').removeClass('openck'); 527 hideSubmenuck(el); 528 $('li.maximenuck.parent:not(.nodropdown)', el).each(function(j, el2) { 529 el2 = $(el2); 530 if (el.prop('class') != el2.prop('class')) { 531 if (effecttype == 'pushdown') { 532 el2.submenu = $('> .maxipushdownck > .floatck',maximenuObj).eq(j); 533 } else { 534 el2.submenu = $('> .floatck', el2); 535 } 536 hideSubmenuck(el2); 537 } 538 }); 539 showSubmenuck(el); 540 }); 541 542 $('> div > .maxiclose', el).click(function() { 543 hideSubmenuck(el); 544 }); 545 } else if (itembehavior == 'clickclose') { 546 el.mouseenter(function() { 547 if (testoverflow == '1') 548 testOverflowmenuck(el); 549 $('li.maximenuck.parent.level' + el.data('level'), maximenuObj).each(function(j, el2) { 550 el2 = $(el2); 551 if (el.prop('class') != el2.prop('class')) { 552 if (effecttype == 'pushdown') { 553 el2.submenu = $('> .maxipushdownck > .floatck',maximenuObj).eq(j); 554 } else { 555 el2.submenu = $('> .floatck', el2); 556 } 557 // el2.data('status','closed'); 558 // status[el2.data('level')] = ''; 559 hideSubmenuck(el2); 560 } 561 }); 562 showSubmenuck(el); 563 }); 564 565 $('> div > .maxiclose', el).click(function() { 566 hideSubmenuck(el); 567 }); 568 } else if (itembehavior == 'click') { 569 if (el.hasClass('parent') && $('> a.maximenuck', el).length) { 570 el.redirection = $('> a.maximenuck', el).prop('href'); 571 $('> a.maximenuck', el).prop('href', 'javascript:void(0)'); 572 el.hasBeenClicked = false;
573 } 574 575 $('> a.maximenuck,> span.separator,> span.nav-header', el).click(function() { 576 // event.stopPropagation(); 577 // set the redirection again for mobile 578 // if (el.hasBeenClicked == true && ismobile) { 579 // el.getFirst('a.maximenuck').setProperty('href',el.redirection); 580 // } 581 // el.hasBeenClicked = true; 582 $('li.maximenuck.level' + $(el).attr('data-level'), maximenuObj).removeClass('clickedck').removeClass('openck'); 583 el.addClass('clickedck'); 584 if (testoverflow == '1') 585 testOverflowmenuck(el); 586 if (el.data('status') == 'opened') { 587 $('li.maximenuck', $(el)).removeClass('clickedck').removeClass('openck'); 588 $(el).removeClass('clickedck').removeClass('openck'); 589 hideSubmenuck(el); 590 $('li.maximenuck.parent:not(.nodropdown)', el).each(function(j, el2) { 591 el2 = $(el2); 592 if (el.prop('class') != el2.prop('class')) { 593 if (effecttype == 'pushdown') { 594 el2.submenu = $('> .maxipushdownck > .floatck',maximenuObj).eq(j); 595 } else { 596 el2.submenu = $('> .floatck', el2); 597 } 598 hideSubmenuck(el2); 599 } 600 }); 601 } else { 602 $('li.maximenuck.parent.level' + el.data('level'), maximenuObj).each(function(j, el2) { 603 el2 = $(el2); 604 if (el.prop('class') != el2.prop('class')) { 605 if (effecttype == 'pushdown') { 606 el2.submenu = $('> .maxipushdownck > .floatck',maximenuObj).eq(j); 607 } else { 608 el2.submenu = $('> .floatck', el2); 609 } 610 hideSubmenuck(el2); 611 } 612 }); 613 showSubmenuck(el); 614 } 615 }); 616 617 } else { 618 el.mouseenter(function() { 619 if (effecttype == 'pushdown') { 620 $('li.maximenuck.level1.parent', maximenuObj).each(function(j, el2) { 621 el2 = $(el2); 622 if (el.prop('class') != el2.prop('class')) { 623 el2.submenu = $('> .maxipushdownck > .floatck',maximenuObj).eq(j); 624 hideSubmenuck(el2); 625 } 626 }); 627 } else { 628 if (testoverflow == '1') 629 testOverflowmenuck(el); 630 } 631 showSubmenuck(el); 632 }); 633 if (effecttype == 'pushdown') { 634 maximenuObj.mouseleave(function() { 635 hideSubmenuck(el); 636 }); 637 } else { 638 el.mouseleave(function() { 639 hideSubmenuck(el); 640 el.find('li.maximenuck.parent.level'+el.attr('data-level')+':not(.nodropdown)').each(function(j, el2) { 641 el2 = $(el2); 642 if (effecttype == 'pushdown') { 643 el2.submenu = $('> .maxipushdownck > .floatck',maximenuObj).eq(j); 644 } else { 645 el2.submenu = $('> .floatck', el2); 646 } 647 hideSubmenuck(el2); 648 }); 649 }); 650 } 651 } 652 }); 653 654 } 655 }); 656 }; 657})(jQuery); 658 659// jQuery(document).ready(function($){ 660// $('#maximenuck').DropdownMaxiMenu({ 661// }); 662// });
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.