MDL-14632 Improved the output code of the settings block and fixed typo of toogle to toggle.

This commit is contained in:
nicolasconnault 2009-08-28 10:28:16 +00:00
parent 5000d34e8e
commit c1c0cecf3a
7 changed files with 71 additions and 52 deletions

View File

@ -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 {
}
}
}
}
}

View File

@ -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;
}
}
}

View File

@ -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';

View File

@ -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';
$string['toggleblockdisplay'] = 'Move to block position';
$string['togglesidetabdisplay'] = 'Move to side panel tab';

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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;
}
?>
?>