From d9706ac37449d61c2c5a657f6fa5a15d78a30b6c Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sun, 6 Jan 2013 13:28:35 -0500 Subject: [PATCH] Convert draggable headers and sort links to jQuery UI tooltip --- js/functions.js | 8 +++--- js/makegrid.js | 73 ++++++++++++++++++++----------------------------- 2 files changed, 34 insertions(+), 47 deletions(-) diff --git a/js/functions.js b/js/functions.js index 0987c43e5fcf..787b29ec178d 100644 --- a/js/functions.js +++ b/js/functions.js @@ -3506,16 +3506,16 @@ function PMA_createqTip($elements, content, options) * @param item the item * (see http://api.jqueryui.com/tooltip/#option-items) * @param myContent content of the tooltip - * @param additional_options to override the default options + * @param additionalOptions to override the default options * */ -function PMA_tooltip($elements, item, myContent, additional_options) +function PMA_tooltip($elements, item, myContent, additionalOptions) { if ($('#no_hint').length > 0) { return; } - var default_options = { + var defaultOptions = { content: myContent, items: item, //@todo: when PMA_createqTip() is gone, rename this class @@ -3525,7 +3525,7 @@ function PMA_tooltip($elements, item, myContent, additional_options) hide: {effect: "slideUp", duration: 250} } - $elements.tooltip($.extend(true, default_options, additional_options)); + $elements.tooltip($.extend(true, defaultOptions, additionalOptions)); } /** diff --git a/js/makegrid.js b/js/makegrid.js index e1f2dc47bc0c..a5e427340f58 100644 --- a/js/makegrid.js +++ b/js/makegrid.js @@ -127,7 +127,8 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi objTop: objPos.top, objLeft: objPos.left }; - g.hideHint(); + $(t).find('th.draggable').tooltip('disable'); + $('body').css('cursor', 'move'); $('body').noSelect(); if (g.isCellEditActive) { @@ -226,6 +227,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi } $('body').css('cursor', 'inherit'); $('body').noSelect(false); + $(t).find('th.draggable').tooltip('enable'); }, /** @@ -417,13 +419,18 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi /** * Update current hint using the boolean values (showReorderHint, showSortHint, etc.). - * It will hide the hint if all the boolean values is false. * - * @param e event */ - updateHint: function(e) { + updateHint: function() { + var text = ''; if (!g.colRsz && !g.colReorder) { // if not resizing or dragging - var text = ''; + if (g.visibleHeadersCount > 1) { + g.showReorderHint = true; + } + if ($(t).find('th.marker').length > 0) { + g.showMarkHint = true; + } + if (g.showReorderHint && g.reorderHint) { text += g.reorderHint; } @@ -439,21 +446,8 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi text += text.length > 0 ? '
' : ''; text += g.copyHint; } - // hide the hint if no text and the event is mouseenter - if (g.qtip) { - g.qtip.disable(!text && e.type == 'mouseenter'); - g.qtip.updateContent(text, false); - } - } else { - g.hideHint(); - } - }, - - hideHint: function() { - if (g.qtip) { - g.qtip.hide(); - g.qtip.disable(true); } + return text; }, /** @@ -1467,7 +1461,6 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi }) .mouseenter(function(e) { if (g.visibleHeadersCount > 1) { - g.showReorderHint = true; $(this).css('cursor', 'move'); } else { $(this).css('cursor', 'inherit'); @@ -1475,6 +1468,9 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi }) .mouseleave(function(e) { g.showReorderHint = false; + $(t).find("th.draggable").tooltip("option", { + content: g.updateHint() + }) ; }) .dblclick(function(e) { e.preventDefault(); @@ -1826,27 +1822,28 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi g.initGridEdit(); } - // create qtip for each with draggable class - PMA_createqTip($(t).find('th.draggable')); + // create tooltip for each with draggable class + PMA_tooltip( + $(t).find("th.draggable"), + 'th', + g.updateHint() + ); - // register events for hint tooltip + // register events for hint tooltip (anchors inside draggable th) $(t).find('th.draggable a') - .attr('title', '') // hide default tooltip for sorting .mouseenter(function(e) { g.showSortHint = true; - g.updateHint(e); + $(t).find("th.draggable").tooltip("option", { + content: g.updateHint() + }); }) .mouseleave(function(e) { g.showSortHint = false; - g.updateHint(e); - }); - $(t).find('th.marker') - .mouseenter(function(e) { - g.showMarkHint = true; - }) - .mouseleave(function(e) { - g.showMarkHint = false; + $(t).find("th.draggable").tooltip("option", { + content: g.updateHint() + }); }); + // register events for dragging-related feature if (enableResize || enableReorder) { $(document).mousemove(function(e) { @@ -1857,16 +1854,6 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi }); } - // bind event to update currently hovered qtip API - $(t).find('th.draggable') - .mouseenter(function(e) { - g.qtip = $(this).qtip('api'); - g.updateHint(e); - }) - .mouseleave(function(e) { - g.updateHint(e); - }); - // some adjustment $(t).removeClass('data'); $(g.gDiv).addClass('data');