From c1c0cecf3a1fffafc4b9eb1884d96bb8dc4f40e7 Mon Sep 17 00:00:00 2001 From: nicolasconnault <nicolasconnault> Date: Fri, 28 Aug 2009 10:28:16 +0000 Subject: [PATCH] MDL-14632 Improved the output code of the settings block and fixed typo of toogle to toggle. --- .../block_global_navigation_tree.php | 20 +++---- .../block_settings_navigation_tree.php | 56 ++++++++++++------- lang/en_utf8/block_global_navigation_tree.php | 4 +- .../block_settings_navigation_tree.php | 4 +- lib/editor/tinymce/tiny_mce_src.js | 6 +- lib/javascript-navigation.js | 25 +++++---- webservice/rest/testclient/lib.php | 8 +-- 7 files changed, 71 insertions(+), 52 deletions(-) diff --git a/blocks/global_navigation_tree/block_global_navigation_tree.php b/blocks/global_navigation_tree/block_global_navigation_tree.php index 4ab412c66fb..327d0ab574d 100644 --- a/blocks/global_navigation_tree/block_global_navigation_tree.php +++ b/blocks/global_navigation_tree/block_global_navigation_tree.php @@ -88,9 +88,9 @@ class block_global_navigation_tree extends block_tree { $this->page->requires->js('lib/javascript-navigation.js'); // Navcount is used to allow us to have multiple trees although I dont' know why // you would want to trees the same - + block_global_navigation_tree::$navcount++; - + // Set the expansionlimit if one has been set in block config if (!empty($this->config->expansionlimit) && $this->config->expansionlimit!='0') { $this->page->navigation->expansionlimit = $this->config->expansionlimit; @@ -100,7 +100,7 @@ class block_global_navigation_tree extends block_tree { $this->page->navigation->initialise(); // Remove empty branches if the user has selected to - + if (empty($this->config->showemptybranches) || $this->config->showemptybranches=='no') { $this->remove_empty_section_branches(); } @@ -114,16 +114,16 @@ class block_global_navigation_tree extends block_tree { $this->showmyhistory(); } - $tooglesidetabdisplay = get_string('tooglesidetabdisplay', $this->blockname); - $toogleblockdisplay = get_string('toogleblockdisplay', $this->blockname); + $togglesidetabdisplay = get_string('togglesidetabdisplay', $this->blockname); + $toggleblockdisplay = get_string('toggleblockdisplay', $this->blockname); // Get the expandable items so we can pass them to JS $expandable = array(); $this->page->navigation->find_expandable($expandable); $args = array('expansions'=>$expandable,'instance'=>$this->instance->id); - $args['tooglesidetabdisplay'] = $tooglesidetabdisplay; - $args['toogleblockdisplay'] = $toogleblockdisplay; + $args['togglesidetabdisplay'] = $togglesidetabdisplay; + $args['toggleblockdisplay'] = $toggleblockdisplay; // Give JS some information we will use within the JS tree object $this->page->requires->data_for_js('globalnav'.block_global_navigation_tree::$navcount, $args); // Initialise the JS tree object @@ -140,10 +140,10 @@ class block_global_navigation_tree extends block_tree { user_preference_allow_ajax_update('nav_in_tab_panel_globalnav'.block_global_navigation_tree::$navcount, PARAM_INT); if (get_user_preferences('nav_in_tab_panel_globalnav'.block_global_navigation_tree::$navcount, 0)) { $icon = $OUTPUT->old_icon_url('t/movetoblock'); - $string = $toogleblockdisplay; + $string = $toggleblockdisplay; } else { $icon = $OUTPUT->old_icon_url('t/movetosidetab'); - $string = $tooglesidetabdisplay; + $string = $togglesidetabdisplay; } $this->content->footer .= '<a class="moveto customcommand requiresjs"><img src="'.$icon.'" alt="'.$string.'" title="'.$string.'"></a>'; } @@ -351,4 +351,4 @@ class block_global_navigation_tree extends block_tree { } } } -} \ No newline at end of file +} diff --git a/blocks/settings_navigation_tree/block_settings_navigation_tree.php b/blocks/settings_navigation_tree/block_settings_navigation_tree.php index e574be7d56d..2a18e7e3d2d 100644 --- a/blocks/settings_navigation_tree/block_settings_navigation_tree.php +++ b/blocks/settings_navigation_tree/block_settings_navigation_tree.php @@ -87,11 +87,11 @@ class block_settings_navigation_tree extends block_tree { $this->page->requires->js('lib/javascript-navigation.js'); block_settings_navigation_tree::$navcount++; - $tooglesidetabdisplay = get_string('tooglesidetabdisplay', $this->blockname); - $toogleblockdisplay = get_string('toogleblockdisplay', $this->blockname); + $togglesidetabdisplay = get_string('togglesidetabdisplay', $this->blockname); + $toggleblockdisplay = get_string('toggleblockdisplay', $this->blockname); $args = array('instance'=>$this->instance->id); - $args['tooglesidetabdisplay'] = $tooglesidetabdisplay; - $args['toogleblockdisplay'] = $toogleblockdisplay; + $args['togglesidetabdisplay'] = $togglesidetabdisplay; + $args['toggleblockdisplay'] = $toggleblockdisplay; // Give JS some information we will use within the JS tree object $this->page->requires->data_for_js('settingsnav'.block_settings_navigation_tree::$navcount, $args); @@ -104,31 +104,49 @@ class block_settings_navigation_tree extends block_tree { // only do search if you have moodle/site:config if (count($this->content->items)>0) { if (has_capability('moodle/site:config',get_context_instance(CONTEXT_SYSTEM)) ) { - $this->content->footer = - '<div class="adminsearchform">'. - '<form action="'.$CFG->wwwroot.'/'.$CFG->admin.'/search.php" method="get"><div>'. - '<label for="query" class="accesshide">'.get_string('searchinsettings', 'admin').'</label>'. - '<input type="text" name="query" id="query" size="8" value="'.s(optional_param('query', '')).'" />'. - '<input type="submit" value="'.get_string('search').'" /></div>'. - '</form></div>'; + $searchform = new html_form(); + $searchform->url = new moodle_url("$CFG->wwwroot/$CFG->admin/search.php"); + $searchform->method = 'get'; + $searchform->button->text = get_string('search'); + + $searchfield = html_field::make_text('query', optional_param('query', '', PARAM_RAW)); + $searchfield->id = 'query'; + $searchfield->style .= 'width: 7em;'; + $searchfield->set_label(get_string('searchinsettings', 'admin'), 'query'); + $searchfield->label->add_class('accesshide'); + $this->content->footer = $OUTPUT->container($OUTPUT->form($searchform, $OUTPUT->field($searchfield)), 'adminsearchform'); } else { $this->content->footer = ''; } + $reloadicon = new moodle_action_icon(); $url = $this->page->url; $url->param('regenerate','navigation'); - $reloadstr = get_string('reload'); - $this->content->footer .= '<a href="'.$url->out().'" class="customcommand"><img src="'.$OUTPUT->old_icon_url('t/reload').'" alt="'.$reloadstr.'" title="'.$reloadstr.'" /></a>'; + $reloadicon->link->url = $url; + $reloadicon->link->add_class('customcommand'); + $reloadicon->image->src = $OUTPUT->old_icon_url('t/reload'); + $reloadicon->alt = get_string('reload'); + $reloadicon->title = get_string('reload'); + + $this->content->footer .= $OUTPUT->action_icon($reloadicon); + if (!empty($this->config->enablesidebarpopout) && $this->config->enablesidebarpopout == 'yes') { + $moveicon = new moodle_action_icon(); + $moveicon->link->add_classes('moveto customcommand requiresjs'); + $moveicon->link->url = ' '; + user_preference_allow_ajax_update('nav_in_tab_panel_settingsnav'.block_settings_navigation_tree::$navcount, PARAM_INT); if (get_user_preferences('nav_in_tab_panel_settingsnav'.block_settings_navigation_tree::$navcount, 0)) { - $icon = $OUTPUT->old_icon_url('t/movetoblock'); - $string = $toogleblockdisplay; + $moveicon->image->src = $OUTPUT->old_icon_url('t/movetoblock'); + $string = $toggleblockdisplay; + $moveicon->image->alt = $toggleblockdisplay; + $moveicon->image->title = $toggleblockdisplay; } else { - $icon = $OUTPUT->old_icon_url('t/movetosidetab'); - $string = $tooglesidetabdisplay; + $moveicon->image->src = $OUTPUT->old_icon_url('t/movetosidetab'); + $moveicon->image->alt = $togglesidetabdisplay; + $moveicon->image->title = $togglesidetabdisplay; } - $this->content->footer .= '<a class="moveto customcommand requiresjs"><img src="'.$icon.'" alt="'.$string.'" title="'.$string.'"></a>'; + $this->content->footer .= $OUTPUT->action_icon($moveicon); } } @@ -146,4 +164,4 @@ class block_settings_navigation_tree extends block_tree { } return $attributes; } -} \ No newline at end of file +} diff --git a/lang/en_utf8/block_global_navigation_tree.php b/lang/en_utf8/block_global_navigation_tree.php index 25caf1a6e0a..4de60759195 100644 --- a/lang/en_utf8/block_global_navigation_tree.php +++ b/lang/en_utf8/block_global_navigation_tree.php @@ -36,5 +36,5 @@ $string['enablehoverexpansiondesc'] = 'Enable mouseover expansion of this block' $string['enablesidebarpopoutdesc'] = 'Allow the user to switch the block to a sidbar popout'; $string['showmyhistorydesc'] = 'Show my history as a branch in the navigation'; $string['showmyhistorytitle'] = 'My history'; -$string['toogleblockdisplay'] = 'Move to block position'; -$string['tooglesidetabdisplay'] = 'Move to side panel tab'; +$string['toggleblockdisplay'] = 'Move to block position'; +$string['togglesidetabdisplay'] = 'Move to side panel tab'; diff --git a/lang/en_utf8/block_settings_navigation_tree.php b/lang/en_utf8/block_settings_navigation_tree.php index 27d67904231..813815f0d5e 100644 --- a/lang/en_utf8/block_settings_navigation_tree.php +++ b/lang/en_utf8/block_settings_navigation_tree.php @@ -27,5 +27,5 @@ $string['blockname'] = 'Settings'; $string['enablehoverexpansion'] = 'Enable mouseover expansion of this block'; $string['enablesidebarpopout'] = 'Allow the user to switch the block to a sidbar popout'; -$string['toogleblockdisplay'] = 'Move to block position'; -$string['tooglesidetabdisplay'] = 'Move to side panel tab'; \ No newline at end of file +$string['toggleblockdisplay'] = 'Move to block position'; +$string['togglesidetabdisplay'] = 'Move to side panel tab'; diff --git a/lib/editor/tinymce/tiny_mce_src.js b/lib/editor/tinymce/tiny_mce_src.js index de6f0e6f613..c412aa1a0b3 100644 --- a/lib/editor/tinymce/tiny_mce_src.js +++ b/lib/editor/tinymce/tiny_mce_src.js @@ -7534,7 +7534,7 @@ tinymce.create('tinymce.ui.Separator:tinymce.ui.Control', { hideMenu : function(e) { var t = this; - // Prevent double toogles by canceling the mouse click event to the button + // Prevent double toggles by canceling the mouse click event to the button if (e && e.type == "mousedown" && (e.target.id == t.id + '_text' || e.target.id == t.id + '_open')) return; @@ -7833,7 +7833,7 @@ tinymce.create('tinymce.ui.Separator:tinymce.ui.Control', { hideMenu : function(e) { var t = this; - // Prevent double toogles by canceling the mouse click event to the button + // Prevent double toggles by canceling the mouse click event to the button if (e && e.type == "mousedown" && DOM.getParent(e.target, function(e) {return e.id === t.id || e.id === t.id + '_open';})) return; @@ -7992,7 +7992,7 @@ tinymce.create('tinymce.ui.Separator:tinymce.ui.Control', { hideMenu : function(e) { var t = this; - // Prevent double toogles by canceling the mouse click event to the button + // Prevent double toggles by canceling the mouse click event to the button if (e && e.type == "mousedown" && DOM.getParent(e.target, function(e) {return e.id === t.id + '_open';})) return; diff --git a/lib/javascript-navigation.js b/lib/javascript-navigation.js index d41f6e20276..6fe7d9c8d8f 100644 --- a/lib/javascript-navigation.js +++ b/lib/javascript-navigation.js @@ -66,8 +66,8 @@ function navigation_tree (treename, key) { this.cachedcontent = null; this.cachedfooter = null; this.position = 'block'; - this.tooglesidetabdisplay = '[[tooglesidetabdisplay]]'; - this.toogleblockdisplay = '[[toogleblockdisplay]]'; + this.togglesidetabdisplay = '[[togglesidetabdisplay]]'; + this.toggleblockdisplay = '[[toggleblockdisplay]]'; this.sideblockwidth = null; if (window[this.name]) { if (window[this.name].expansions) { @@ -76,17 +76,17 @@ function navigation_tree (treename, key) { if (window[this.name].instance) { this.instance = window[this.name].instance; } - if (window[this.name].tooglesidetabdisplay) { - this.tooglesidetabdisplay = window[this.name].tooglesidetabdisplay; + if (window[this.name].togglesidetabdisplay) { + this.togglesidetabdisplay = window[this.name].togglesidetabdisplay; } - if (window[this.name].toogleblockdisplay) { - this.toogleblockdisplay = window[this.name].toogleblockdisplay; + if (window[this.name].toggleblockdisplay) { + this.toggleblockdisplay = window[this.name].toggleblockdisplay; } } } /** * Initialise function used to attach the initial events to the navigation tree - * This function attachs toogles and ajax calls + * This function attachs toggles and ajax calls */ navigation_tree.prototype.initialise = function() { if (!document.getElementById(this.name)) { @@ -272,6 +272,7 @@ navigation_tree.prototype.add_branch = function(branchxml, target, depth) { * @param {element} e Event object */ navigation_tree.prototype.toggle_block_display = function(e) { + YAHOO.util.Event.preventDefault(e); if (e !== null) { YAHOO.util.Event.stopPropagation(e); } @@ -311,8 +312,8 @@ navigation_tree.prototype.move_to_sidebar_popout = function(e) { if (moveicon.length>0) { for (var j=0;j<moveicon.length;j++) { moveicon[j].src = moveicon[j].src.replace(/movetosidetab/, 'movetoblock'); - moveicon[j].setAttribute('alt', this.toogleblockdisplay); - moveicon[j].setAttribute('title', this.toogleblockdisplay); + moveicon[j].setAttribute('alt', this.toggleblockdisplay); + moveicon[j].setAttribute('title', this.toggleblockdisplay); } } } @@ -389,8 +390,8 @@ navigation_tree.prototype.move_to_block_position = function(e) { if (moveicon.length>0) { for (var j=0;j<moveicon.length;j++) { moveicon[j].src = moveicon[j].src.replace(/movetoblock/, 'movetosidetab'); - moveicon[j].setAttribute('alt', this.tooglesidetabdisplay); - moveicon[j].setAttribute('title', this.tooglesidetabdisplay); + moveicon[j].setAttribute('alt', this.togglesidetabdisplay); + moveicon[j].setAttribute('title', this.togglesidetabdisplay); } } } @@ -833,4 +834,4 @@ function remove_shadow(el) { shadows[i].parentNode.removeChild(shadows[i]); } return true; -} \ No newline at end of file +} diff --git a/webservice/rest/testclient/lib.php b/webservice/rest/testclient/lib.php index 47f5a883e88..ebac6cd2dc3 100644 --- a/webservice/rest/testclient/lib.php +++ b/webservice/rest/testclient/lib.php @@ -46,9 +46,9 @@ function end_interface ($ret = true) { */ function show_xml ($xml) { echo '<div class="xmlshow">'; - echo '<a onClick="document.getElementById(\'toogleme\').style.display = ' . - '(document.getElementById(\'toogleme\').style.display!=\'none\')?\'none\':\'\';">Hide/Show XML</a>'; - echo "<div style=\"display:none;\" id=\"toogleme\">"; + echo '<a onClick="document.getElementById(\'toggleme\').style.display = ' . + '(document.getElementById(\'toggleme\').style.display!=\'none\')?\'none\':\'\';">Hide/Show XML</a>'; + echo "<div style=\"display:none;\" id=\"toggleme\">"; echo '<pre>';echo htmlentities($xml);echo '</pre>'; echo "</div>"; echo "</div>"; @@ -223,4 +223,4 @@ function basicxml_xml_to_object_aux ($values) { } return $res; } -?> \ No newline at end of file +?>