annotate sites/all/modules/ctools/js/dropbutton.js @ 9:830c812b520f

added smtp module
author root <root@paio.local>
date Mon, 28 Oct 2013 15:34:27 +0000
parents ff03f76ab3fe
children
rev   line source
danielebarchiesi@0 1 /**
danielebarchiesi@0 2 * @file
danielebarchiesi@0 3 * Implement a simple, clickable dropbutton menu.
danielebarchiesi@0 4 *
danielebarchiesi@0 5 * See dropbutton.theme.inc for primary documentation.
danielebarchiesi@0 6 *
danielebarchiesi@0 7 * The javascript relies on four classes:
danielebarchiesi@0 8 * - The dropbutton must be fully contained in a div with the class
danielebarchiesi@0 9 * ctools-dropbutton. It must also contain the class ctools-no-js
danielebarchiesi@0 10 * which will be immediately removed by the javascript; this allows for
danielebarchiesi@0 11 * graceful degradation.
danielebarchiesi@0 12 * - The trigger that opens the dropbutton must be an a tag wit hthe class
danielebarchiesi@0 13 * ctools-dropbutton-link. The href should just be '#' as this will never
danielebarchiesi@0 14 * be allowed to complete.
danielebarchiesi@0 15 * - The part of the dropbutton that will appear when the link is clicked must
danielebarchiesi@0 16 * be a div with class ctools-dropbutton-container.
danielebarchiesi@0 17 * - Finally, ctools-dropbutton-hover will be placed on any link that is being
danielebarchiesi@0 18 * hovered over, so that the browser can restyle the links.
danielebarchiesi@0 19 *
danielebarchiesi@0 20 * This tool isn't meant to replace click-tips or anything, it is specifically
danielebarchiesi@0 21 * meant to work well presenting menus.
danielebarchiesi@0 22 */
danielebarchiesi@0 23
danielebarchiesi@0 24 (function ($) {
danielebarchiesi@0 25 Drupal.behaviors.CToolsDropbutton = {
danielebarchiesi@0 26 attach: function() {
danielebarchiesi@0 27 // Process buttons. All dropbuttons are buttons.
danielebarchiesi@0 28 $('.ctools-button')
danielebarchiesi@0 29 .once('ctools-button')
danielebarchiesi@0 30 .removeClass('ctools-no-js');
danielebarchiesi@0 31
danielebarchiesi@0 32 // Process dropbuttons. Not all buttons are dropbuttons.
danielebarchiesi@0 33 $('.ctools-dropbutton').once('ctools-dropbutton', function() {
danielebarchiesi@0 34 var $dropbutton = $(this);
danielebarchiesi@0 35 var $button = $('.ctools-content', $dropbutton);
danielebarchiesi@0 36 var $secondaryActions = $('li', $button).not(':first');
danielebarchiesi@0 37 var $twisty = $(".ctools-link", $dropbutton);
danielebarchiesi@0 38 var open = false;
danielebarchiesi@0 39 var hovering = false;
danielebarchiesi@0 40 var timerID = 0;
danielebarchiesi@0 41
danielebarchiesi@0 42 var toggle = function(close) {
danielebarchiesi@0 43 // if it's open or we're told to close it, close it.
danielebarchiesi@0 44 if (open || close) {
danielebarchiesi@0 45 // If we're just toggling it, close it immediately.
danielebarchiesi@0 46 if (!close) {
danielebarchiesi@0 47 open = false;
danielebarchiesi@0 48 $secondaryActions.slideUp(100);
danielebarchiesi@0 49 $dropbutton.removeClass('open');
danielebarchiesi@0 50 }
danielebarchiesi@0 51 else {
danielebarchiesi@0 52 // If we were told to close it, wait half a second to make
danielebarchiesi@0 53 // sure that's what the user wanted.
danielebarchiesi@0 54 // Clear any previous timer we were using.
danielebarchiesi@0 55 if (timerID) {
danielebarchiesi@0 56 clearTimeout(timerID);
danielebarchiesi@0 57 }
danielebarchiesi@0 58 timerID = setTimeout(function() {
danielebarchiesi@0 59 if (!hovering) {
danielebarchiesi@0 60 open = false;
danielebarchiesi@0 61 $secondaryActions.slideUp(100);
danielebarchiesi@0 62 $dropbutton.removeClass('open');
danielebarchiesi@0 63 }}, 500);
danielebarchiesi@0 64 }
danielebarchiesi@0 65 }
danielebarchiesi@0 66 else {
danielebarchiesi@0 67 // open it.
danielebarchiesi@0 68 open = true;
danielebarchiesi@0 69 $secondaryActions.animate({height: "show", opacity: "show"}, 100);
danielebarchiesi@0 70 $dropbutton.addClass('open');
danielebarchiesi@0 71 }
danielebarchiesi@0 72 }
danielebarchiesi@0 73 // Hide the secondary actions initially.
danielebarchiesi@0 74 $secondaryActions.hide();
danielebarchiesi@0 75
danielebarchiesi@0 76 $twisty.click(function() {
danielebarchiesi@0 77 toggle();
danielebarchiesi@0 78 return false;
danielebarchiesi@0 79 });
danielebarchiesi@0 80
danielebarchiesi@0 81 $dropbutton.hover(
danielebarchiesi@0 82 function() {
danielebarchiesi@0 83 hovering = true;
danielebarchiesi@0 84 }, // hover in
danielebarchiesi@0 85 function() { // hover out
danielebarchiesi@0 86 hovering = false;
danielebarchiesi@0 87 toggle(true);
danielebarchiesi@0 88 return false;
danielebarchiesi@0 89 }
danielebarchiesi@0 90 );
danielebarchiesi@0 91 });
danielebarchiesi@0 92 }
danielebarchiesi@0 93 }
danielebarchiesi@0 94 })(jQuery);