From 796012fcc574215cf95e4fb631501d2b198c70e9 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Wed, 6 Jun 2012 12:42:39 +0100 Subject: [PATCH] Completely drop footnotes and use tooltips instead --- js/db_structure.js | 2 +- js/functions.js | 63 +++------- js/server_privileges.js | 4 +- js/server_status.js | 2 +- js/tbl_structure.js | 6 +- libraries/Footer.class.php | 31 +---- libraries/Footnotes.class.php | 153 ----------------------- libraries/Message.class.php | 8 +- libraries/common.inc.php | 6 - libraries/common.lib.php | 18 +-- setup/styles.css | 12 +- test/PMA_showHint_test.php | 189 ----------------------------- themes/original/css/common.css.php | 14 +-- themes/pmahomme/css/common.css.php | 17 +-- themes/sprites.css.php | 2 +- 15 files changed, 51 insertions(+), 476 deletions(-) delete mode 100644 libraries/Footnotes.class.php delete mode 100644 test/PMA_showHint_test.php diff --git a/js/db_structure.js b/js/db_structure.js index f5d4db94bb..5305431334 100644 --- a/js/db_structure.js +++ b/js/db_structure.js @@ -194,7 +194,7 @@ $(function() { $("table.insertRowTable").addClass("ajax"); $("#buttonYes").addClass("ajax"); $div = $("#insert_table_dialog"); - PMA_convertFootnotesToTooltips($div); + PMA_showHints($div); } PMA_ajaxRemoveMessage($msgbox); }); // end $.get() diff --git a/js/functions.js b/js/functions.js index 5dd7c8d65b..7dbb67110c 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1673,7 +1673,7 @@ function PMA_createTableDialog( $div, url , target) buttons: button_options }); // end dialog options } - PMA_convertFootnotesToTooltips($div); + PMA_showHints($div); PMA_ajaxRemoveMessage($msgbox); }); // end $.get() @@ -2922,10 +2922,6 @@ $(function() { }); }); -$(function() { - PMA_convertFootnotesToTooltips(); -}); - /** * Ensures indexes names are valid according to their type and, for a primary * key, lock index name to 'PRIMARY' @@ -2961,55 +2957,22 @@ function checkIndexName(form_id) } // end of the 'checkIndexName()' function /** - * function to convert the footnotes to tooltips + * Function to display tooltips that were + * generated on the PHP side by PMA_showHint() * - * @param jquery-Object $div a div jquery object which specifies the - * domain for searching footnootes. If we - * ommit this parameter the function searches - * the footnotes in the whole body + * @param object $div a div jquery object which specifies the + * domain for searching for tooltips. If we + * omit this parameter the function searches + * in the whole body **/ -function PMA_convertFootnotesToTooltips($div) +function PMA_showHints($div) { - // Hide the footnotes from the footer (which are displayed for - // JavaScript-disabled browsers) since the tooltip is sufficient - if ($div == undefined || ! $div instanceof jQuery || $div.length == 0) { $div = $("body"); } - - $footnotes = $div.find(".footnotes"); - - $footnotes.hide(); - $footnotes.find('span').each(function() { - $(this).children("sup").remove(); - }); - // The border and padding must be removed otherwise a thin yellow box remains visible - $footnotes.css("border", "none"); - $footnotes.css("padding", "0px"); - - // Replace the superscripts with the help icon - $div.find("sup.footnotemarker").hide(); - $div.find("img.footnotemarker").show(); - - $div.find("img.footnotemarker").each(function() { - var img_class = $(this).attr("class"); - /** img contains two classes, as example "footnotemarker footnote_1". - * We split it by second class and take it for the id of span - */ - img_class = img_class.split(" "); - for (i = 0; i < img_class.length; i++) { - if (img_class[i].split("_")[0] == "footnote") { - var span_id = img_class[i].split("_")[1]; - } - } - /** - * Now we get the #id of the span with span_id variable. As an example if we - * initially get the img class as "footnotemarker footnote_2", now we get - * #2 as the span_id. Using that we can find footnote_2 in footnotes. - * */ - var tooltip_text = $footnotes.find("span#footnote_" + span_id).html(); - $(this).qtip({ - content: tooltip_text, + $div.find('.pma_hint').each(function () { + $(this).children('img').qtip({ + content: $(this).children('span').html(), show: { delay: 0 }, hide: { delay: 1000 }, style: { background: '#ffffcc' } @@ -3017,6 +2980,10 @@ function PMA_convertFootnotesToTooltips($div) }); } +$(function() { + PMA_showHints(); +}); + /** * This function handles the resizing of the content frame * and adjusts the top menu according to the new size of the frame diff --git a/js/server_privileges.js b/js/server_privileges.js index 5394f594dd..d4c8d8d37b 100644 --- a/js/server_privileges.js +++ b/js/server_privileges.js @@ -218,7 +218,7 @@ $(function() { } }); //dialog options end displayPasswordGenerateButton(); - PMA_convertFootnotesToTooltips($div); + PMA_showHints($div); PMA_ajaxRemoveMessage($msgbox); $div.find("input[autofocus]").focus(); @@ -354,7 +354,7 @@ $(function() { }); //dialog options end displayPasswordGenerateButton(); PMA_ajaxRemoveMessage($msgbox); - PMA_convertFootnotesToTooltips($div); + PMA_showHints($div); }); // end $.get() }); diff --git a/js/server_status.js b/js/server_status.js index edd0c54658..243cbe84d3 100644 --- a/js/server_status.js +++ b/js/server_status.js @@ -437,7 +437,7 @@ $(function() { if (data != null) { tab.find('.tabInnerContent').html(data); } - PMA_convertFootnotesToTooltips(); + PMA_showHints(); break; case 'statustabs_queries': if (data != null) { diff --git a/js/tbl_structure.js b/js/tbl_structure.js index 2a931d206a..c93826504f 100644 --- a/js/tbl_structure.js +++ b/js/tbl_structure.js @@ -301,7 +301,7 @@ $(function() { }); checkIndexType(); checkIndexName("index_frm"); - PMA_convertFootnotesToTooltips($div); + PMA_showHints($div); // Add a slider for selecting how many columns to add to the index $div.find('.slider').slider({ animate: true, @@ -542,7 +542,7 @@ $(function() { $div = $("#add_columns"); /*changed the z-index of the enum editor to allow the edit*/ $("#enum_editor").css("z-index", "1100"); - PMA_convertFootnotesToTooltips($div); + PMA_showHints($div); // set focus on first column name input $div.find("input.textfield").eq(0).focus(); } @@ -620,7 +620,7 @@ function changeColumns(action,url) /*changed the z-index of the enum editor to allow the edit*/ $("#enum_editor").css("z-index", "1100"); $div = $("#change_column_dialog"); - PMA_convertFootnotesToTooltips($div); + PMA_showHints($div); } PMA_ajaxRemoveMessage($msgbox); }); // end $.get() diff --git a/libraries/Footer.class.php b/libraries/Footer.class.php index 21bf6a734e..5be2168c8d 100644 --- a/libraries/Footer.class.php +++ b/libraries/Footer.class.php @@ -10,7 +10,6 @@ if (! defined('PHPMYADMIN')) { } require_once 'libraries/Scripts.class.php'; -require_once 'libraries/Footnotes.class.php'; /** * Class used to output the footer @@ -19,13 +18,6 @@ require_once 'libraries/Footnotes.class.php'; */ class PMA_Footer { - /** - * PMA_Footnotes instance - * - * @access private - * @var object - */ - private $_footnotes; /** * PMA_Scripts instance * @@ -44,7 +36,7 @@ class PMA_Footer private $_isAjax; /** * Whether to only close the BODY and HTML tags - * or also include scripts, footnotes, errors and links + * or also include scripts, errors and links * * @access private * @var bool @@ -66,7 +58,6 @@ class PMA_Footer public function __construct() { $this->_isEnabled = true; - $this->_footnotes = new PMA_Footnotes(); $this->_scripts = new PMA_Scripts(); $this->_isMinimal = false; $this->_addDefaultScripts(); @@ -282,16 +273,6 @@ class PMA_Footer $this->_isMinimal = true; } - /** - * Returns the PMA_Footnotes object - * - * @return PMA_Footnotes object - */ - public function getFootnotes() - { - return $this->_footnotes; - } - /** * Renders the footer * @@ -322,13 +303,6 @@ class PMA_Footer $retval .= $this->_getSelfLink($url_params); } $retval .= $this->_getDebugMessage(); - } - if (! $this->_isMinimal) { - // display Footnotes and error messages even in ajax reqests - // FIXME: nootnotes should be sent as JSON - $retval .= $this->_footnotes->getDisplay(); - } - if (! $this->_isAjax && ! $this->_isMinimal) { $retval .= $this->_getErrorMessages(); $retval .= $this->_scripts->getDisplay(); // Include possible custom footers @@ -337,8 +311,7 @@ class PMA_Footer include CUSTOM_FOOTER_FILE; $retval .= ob_end_clean(); } - } - if (! $this->_isAjax) { + } else if (! $this->_isAjax) { $retval .= ""; } } diff --git a/libraries/Footnotes.class.php b/libraries/Footnotes.class.php deleted file mode 100644 index eb6ee41339..0000000000 --- a/libraries/Footnotes.class.php +++ /dev/null @@ -1,153 +0,0 @@ -_footnotes = array(); - } - - /** - * Setter for the ID attribute in the BODY tag - * - * @param mixed $message The message to be used for the footnote. - * Can be a string or a PMA_Message object. - * - * @return string The marker to be displayed near the element - * that is being referenced by the footnote - */ - public function add($message) - { - if ($message instanceof PMA_Message) { - $key = $message->getHash(); - $message = $message->getDisplay(); - } else { - $key = md5($message); - } - - if (! isset($this->_footnotes[$key])) { - $id = count($this->_footnotes) + 1; - $this->_footnotes[$key] = new PMA_Footnote( - $id, - $message - ); - } - return $this->_footnotes[$key]->getMarker(); - } - - /** - * Renders the footnotes - * - * @return string - */ - public function getDisplay() - { - $retval = ''; - if (count($this->_footnotes)) { - $retval .= '
'; - foreach ($this->_footnotes as $footnote) { - $retval .= $footnote->getDisplay(); - } - $retval .= '
'; - } - return $retval; - } -} - -/** - * Each object of this class represents a footnote - * Used by PMA_Footnotes - * - * @package PhpMyAdmin - */ -class PMA_Footnote -{ - /** - * Footnote identifier - * - * @var int - * @access private - */ - private $_id; - /** - * The message to be used for the footnote - * - * @var string - * @access private - */ - private $_message; - - /** - * Generates new PMA_Footnotes objects - * - * @param int $id Footnote identifier - * @param string $message The message to be used for the footnote - * - * @return PMA_Footnote object - */ - public function __construct($id, $message) - { - $this->_id = $id; - $this->_message = $message; - } - - /** - * Returns the marker to be displayed near the element - * that is being referenced by this footnote - * - * @return string - */ - public function getMarker() - { - $retval = '' . $this->_id . ''; - $retval .= PMA_getImage( - 'b_help.png', - '', - array('class' => 'footnotemarker footnote_' . $this->_id) - ); - return $retval; - } - - /** - * Renders the footnote - * - * @return string - */ - public function getDisplay() - { - $retval = ''; - $retval .= '' . $this->_id . ' '; - $retval .= $this->_message; - $retval .= '
'; - return $retval; - } -} - -?> diff --git a/libraries/Message.class.php b/libraries/Message.class.php index 61e7cda64b..de7cfe9fba 100644 --- a/libraries/Message.class.php +++ b/libraries/Message.class.php @@ -27,15 +27,15 @@ * $message = PMA_Message::success('strSomeLocaleMessage'); * * // create another message, a hint, with a localized string which expects - * // two parameters: $strSomeFootnote = 'Read the %smanual%s' - * $hint = PMA_Message::notice('strSomeFootnote'); + * // two parameters: $strSomeTooltip = 'Read the %smanual%s' + * $hint = PMA_Message::notice('strSomeTooltip'); * // replace %d with the following params * $hint->addParam('[a@./Documentation.html#cfg_Example@_blank]'); * $hint->addParam('[/a]'); - * // add this hint as a footnote + * // add this hint as a tooltip * $hint = PMA_showHint($hint); * - * // add the retrieved footnote reference to the original message + * // add the retrieved tooltip reference to the original message * $message->addMessage($hint); * * // create another message ... diff --git a/libraries/common.inc.php b/libraries/common.inc.php index d3dfffe78d..d0a84f92eb 100644 --- a/libraries/common.inc.php +++ b/libraries/common.inc.php @@ -545,12 +545,6 @@ if (PMA_isValid($_REQUEST['sql_query'])) { //$_REQUEST['server']; // checked later in this file //$_REQUEST['lang']; // checked by LABEL_loading_language_file -/** - * footnotes to be displayed ot the page bottom - * @global array $footnotes - */ -$GLOBALS['footnotes'] = array(); - /******************************************************************************/ /* loading language file LABEL_loading_language_file */ diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 41634c20d3..22bf6e6b50 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -528,21 +528,23 @@ function PMA_showPHPDocu($target) } // end of the 'PMA_showPHPDocu()' function /** - * returns HTML for a footnote marker and add the messsage to the footnotes + * Returns HTML code for a tooltip * - * @param string $message the error message - * @param bool $bbcode whether to interpret BB code - * @param string $type message types + * @param string $message the message for the tooltip * - * @return string html code for a footnote marker + * @return string * * @access public */ function PMA_showHint($message) { - $response = PMA_Response::getInstance(); - $footnotes = $response->getFooter()->getFootnotes(); - return $footnotes->add($message); + $retval = ''; + $retval .= PMA_getImage('b_help.png'); + $retval .= ''; + $retval .= $message; + $retval .= ''; + $retval .= ''; + return $retval; } /** diff --git a/setup/styles.css b/setup/styles.css index e7e955c275..c6798c74e2 100644 --- a/setup/styles.css +++ b/setup/styles.css @@ -118,8 +118,7 @@ div.error h4 { div.success, div.notice, -div.error, -div.footnotes { +div.error { margin: .5em 0 1.3em 0; border: 1px solid; background-repeat: no-repeat; @@ -137,8 +136,7 @@ div.footnotes { .success a, .notice a, -.error a, -.footnotes a { +.error a { text-decoration: underline; } @@ -158,15 +156,13 @@ div.success { border-color: #00FF00; } -.notice, -.footnotes { +.notice { color: #000; background-color: #e8eef1; } h1.notice, -div.notice, -div.footnotes { +div.notice { border-color: #3a6c7e; background-image: url(../themes/pmahomme/img/s_notice.png); background-repeat: no-repeat; diff --git a/test/PMA_showHint_test.php b/test/PMA_showHint_test.php deleted file mode 100644 index e99114cb48..0000000000 --- a/test/PMA_showHint_test.php +++ /dev/null @@ -1,189 +0,0 @@ -tmpGlobals = $GLOBALS; - $this->tmpSession = $_SESSION; - } - - /** - * recovering globals and session - */ - public function tearDown() - { - $GLOBALS = $this->tmpGlobals; - $_SESSION = $this->tmpSession; - } - - /** - * PMA_showHint with defined GLOBALS - */ - public function testShowHintReturnValue() - { - $key = md5('test'); - $nr = 1234; - $instance = 1; - - $GLOBALS['footnotes'][$key]['nr'] = $nr; - $GLOBALS['footnotes'][$key]['instance'] = $instance; - $this->assertEquals( - sprintf( - '%d', - $nr, $instance + 1, $nr - ), - PMA_showHint('test') - ); - } - - /** - * PMA_showHint with defined GLOBALS formatted as BB - */ - public function testShowHintReturnValueBbFormat() - { - $key = md5('test'); - $nr = 1234; - $instance = 1; - - $GLOBALS['footnotes'][$key]['nr'] = $nr; - $GLOBALS['footnotes'][$key]['instance'] = $instance; - $this->assertEquals( - sprintf('[sup]%d[/sup]', $nr), - PMA_showHint('test', true) - ); - } - - /** - * PMA_showHint with not defined GLOBALS - */ - public function testShowHintSetting() - { - $key = md5('test'); - $nr = 1; - $instance = 1; - - $this->assertEquals(sprintf('%d', $nr, $instance, $nr), PMA_showHint('test', false, 'notice')); - - $expArray = array( - 'note' => 'test', - 'type' => 'notice', - 'nr' => count($GLOBALS['footnotes']), - 'instance' => 1, - ); - - $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]); - } - - /** - * PMA_showHint with not defined GLOBALS formatted as BB - * @depends testShowHintSetting - */ - public function testShowHintSettingBbFormat() - { - $key = md5('test'); - $nr = 1; - $instance = 1; - - $this->assertEquals(sprintf('[sup]%d[/sup]', $nr), PMA_showHint('test', true, 'notice')); - - $expArray = array( - 'note' => 'test', - 'type' => 'notice', - 'nr' => count($GLOBALS['footnotes']), - 'instance' => 1, - ); - - $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]); - } - - /** - * PMA_showHint with defined GLOBALS using PMA_Message object - */ - public function testShowHintPmaMessageReturnValue() - { - $nr = 1; - $instance = 1; - - $oMock = $this->getMock( - 'PMA_Message', - array('setMessage', 'setNumber', 'getHash', 'getLevel') - ); - $oMock->setMessage('test'); - $oMock->setNumber($nr); - - $key = $oMock->getHash(); - - $GLOBALS['footnotes'][$key]['nr'] = $nr; - $GLOBALS['footnotes'][$key]['instance'] = $instance; - - $this->assertEquals( - sprintf( - '%d', - $nr, $instance + 1, $nr - ), - PMA_showHint($oMock) - ); - } - - /** - * PMA_showHint with not defined GLOBALS using PMA_Message object - */ - public function testShowHintPmaMessageSetting() - { - $nr = 1; - $instance = 1; - - $oMock = $this->getMock( - 'PMA_Message', - array('setMessage', 'setNumber', 'getHash', 'getLevel', 'getNumber') - ); - $oMock->setMessage('test'); - $oMock->setNumber($nr); - - $this->assertEquals( - sprintf( - '%d', - $nr, $instance, $nr - ), - PMA_showHint($oMock, false) - ); - - $key = $oMock->getHash(); - - $expArray = array( - 'note' => $oMock, - 'type' => $oMock->getLevel(), - 'nr' => count($GLOBALS['footnotes']), - 'instance' => 1, - ); - - $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]); - } -} -?> diff --git a/themes/original/css/common.css.php b/themes/original/css/common.css.php index 91c3a65d45..dfbb8882ac 100644 --- a/themes/original/css/common.css.php +++ b/themes/original/css/common.css.php @@ -427,16 +427,12 @@ img.lightbulb { } /* leave some space between icons and text */ -.icon, img.footnotemarker { +.icon { vertical-align: middle; margin-right: 0.3em; margin-left: 0.3em; } -img.footnotemarker { - display: none; -} - /* no extra space in table cells */ td .icon { margin: 0; @@ -459,8 +455,7 @@ div.error h1 { div.success, div.notice, -div.error, -div.footnotes { +div.error { margin: 0.3em 0 0 0; border: 2px solid; background-repeat: no-repeat; @@ -494,13 +489,12 @@ div.success { border-color: #00FF00; } -.notice, .footnotes { +.notice { color: #000000; background-color: #FFFFDD; } h1.notice, -div.notice, -div.footnotes { +div.notice { border-color: #FFD700; background-image: url(getImgPath(); ?>s_notice.png); background-repeat: no-repeat; diff --git a/themes/pmahomme/css/common.css.php b/themes/pmahomme/css/common.css.php index ef19d2dd33..5379c5bc6e 100644 --- a/themes/pmahomme/css/common.css.php +++ b/themes/pmahomme/css/common.css.php @@ -652,11 +652,6 @@ img.lightbulb { .syntax_quote_backtick { } -/* leave some space between icons and text */ -img.footnotemarker { - display: none; -} - /* no extra space in table cells */ td .icon { margin: 0; @@ -679,8 +674,7 @@ div.error h1 { div.success, div.notice, -div.error, -div.footnotes { +div.error { margin: .5em 0 1.3em 0; border: 1px solid; background-repeat: no-repeat; @@ -703,8 +697,7 @@ div.footnotes { .success a, .notice a, -.error a, -.footnotes a { +.error a { text-decoration: underline; } @@ -728,15 +721,13 @@ div.success { border-color: #00FF00; } -.notice, -.footnotes { +.notice { color: #000; background-color: #e8eef1; } h1.notice, -div.notice, -div.footnotes { +div.notice { border-color: #3a6c7e; background-image: url(getImgPath(); ?>s_notice.png); background-repeat: no-repeat; diff --git a/themes/sprites.css.php b/themes/sprites.css.php index e51e1a557a..2c12589a41 100644 --- a/themes/sprites.css.php +++ b/themes/sprites.css.php @@ -17,7 +17,7 @@ if (is_readable($_SESSION['PMA_Theme']->getPath() . '/sprites.lib.php')) { ?> /* Icon sprites */ -.icon, .footnotemarker { +.icon { margin: 0 .3em; padding: 0 !important; width: 16px;