MDL-21170 migrated code to new M.util.image_url() function that returns correct theme images

This commit is contained in:
Petr Skoda
2010-01-22 10:34:09 +00:00
parent ef502357f4
commit bca0975478
4 changed files with 31 additions and 25 deletions
+4 -4
View File
@@ -131,7 +131,7 @@ M.blocks.dock = {
}
var dockcontrol = Y.Node.create('<div class="'+M.blocks.dock.cfg.css.controls+'"></div>');
var removeall = Y.Node.create('<img src="'+get_image_url('t/dock_to_block', 'moodle')+'" alt="'+mstr.block.undockall+'" title="'+mstr.block.undockall+'" />');
var removeall = Y.Node.create('<img src="'+M.util.image_url('t/dock_to_block', 'moodle')+'" alt="'+mstr.block.undockall+'" title="'+mstr.block.undockall+'" />');
removeall.on('removeall|click', this.remove_all, this);
dockcontrol.appendChild(removeall);
this.node.appendChild(dockcontrol);
@@ -309,7 +309,7 @@ M.blocks.dock = {
}
var moveto = Y.Node.create('<a class="moveto customcommand requiresjs"></a>');
moveto.append(Y.Node.create('<img src="'+get_image_url('t/dock_to_block', 'moodle')+'" alt="'+mstr.block.undockitem+'" title="'+mstr.block.undockitem+'" />'));
moveto.append(Y.Node.create('<img src="'+M.util.image_url('t/dock_to_block', 'moodle')+'" alt="'+mstr.block.undockitem+'" title="'+mstr.block.undockitem+'" />'));
if (location.href.match(/\?/)) {
moveto.set('href', location.href+'&dock='+this.id);
} else {
@@ -353,7 +353,7 @@ M.blocks.dock = {
Y.Event.purgeElement(Y.Node.getDOMNode(moveto), false, 'click');
if (moveto.hasClass('customcommand')) {
moveto.all('img').each(function(movetoimg){
movetoimg.setAttribute('src', get_image_url('t/dock_to_block', 'moodle'));
movetoimg.setAttribute('src', M.util.image_url('t/dock_to_block', 'moodle'));
movetoimg.setAttribute('alt', mstr.block.undockitem);
movetoimg.setAttribute('title', mstr.block.undockitem);
}, this);
@@ -448,7 +448,7 @@ M.blocks.dock = {
moveto.on('movetodock|click', this.move_to_dock, this);
if (moveto.hasClass('customcommand')) {
moveto.all('img').each(function(movetoimg){
movetoimg.setAttribute('src', get_image_url('t/block_to_dock', 'moodle'));
movetoimg.setAttribute('src', M.util.image_url('t/block_to_dock', 'moodle'));
movetoimg.setAttribute('alt', mstr.block.addtodock);
movetoimg.setAttribute('title', mstr.block.addtodock);
}, this);
+4 -4
View File
@@ -158,7 +158,7 @@ M.core_comment = {
var val = template.get('innerHTML');
val = val.replace('___name___', list[i].username);
if (list[i]['delete']||newcmt) {
list[i].content = '<div class="comment-delete"><a href="###" id ="comment-delete-'+this.client_id+'-'+list[i].id+'" title="'+mstr.moodle.deletecomment+'"><img src="'+M.cfg.wwwroot+'/pix/t/delete.gif" /></a></div>' + list[i].content;
list[i].content = '<div class="comment-delete"><a href="###" id ="comment-delete-'+this.client_id+'-'+list[i].id+'" title="'+mstr.moodle.deletecomment+'"><img src="'+M.util.image_url('t/delete', 'core')+'" /></a></div>' + list[i].content;
}
val = val.replace('___time___', list[i].time);
val = val.replace('___picture___', list[i].avatar);
@@ -279,11 +279,11 @@ M.core_comment = {
// show
this.load(page);
container.setStyle('display', 'block');
img.src=M.cfg.wwwroot+'/pix/t/expanded.png';
img.src=M.util.image_url('t/expanded', 'core');
} else {
// hide
container.setStyle('display', 'none');
img.src=M.cfg.wwwroot+'/pix/t/collapsed.png';
img.src=M.util.image_url('t/collapsed', 'core');
ta.set('value','');
}
//toggle_textarea.apply(ta, [false]);
@@ -318,7 +318,7 @@ M.core_comment = {
},
wait: function() {
var container = Y.one('#comment-list-'+this.client_id);
container.set('innerHTML', '<div style="text-align:center"><img src="'+M.cfg.wwwroot+'/pix/i/loading.gif'+'" /></div>');
container.set('innerHTML', '<div style="text-align:center"><img src="'+M.util.image_url('i/loading', 'core')+'" /></div>');
}
});
-2
View File
@@ -215,8 +215,6 @@ class page_requirements_manager {
// Otherwise, in some situations, users will get warnings about insecure content
// on sercure pages from their web browser.
//TODO: problem here is we may need this in some included JS - move this somehow to the very beginning
// right after the YUI loading
$this->M_cfg = array(
'wwwroot' => $CFG->httpswwwroot, // Yes, really. See above.
'sesskey' => sesskey(),
+23 -15
View File
@@ -14,6 +14,29 @@ M.yui.add_module = function(modules) {
}
};
/**
* Various utility functions
*/
M.util = {
/**
* Returns url for images.
*/
image_url: function(imagename, component) {
var url = M.cfg.wwwroot + '/theme/image.php?theme=' + M.cfg.theme + '&image=' + imagename;
if (M.cfg.themerev > 0) {
url = url + '&rev=' + M.cfg.themerev;
}
if (component != '' && component != 'moodle' && component != 'core') {
url = url + '&component=' + component;
}
return url;
}
}
function launch_filemanager(options) {
Y.use('core_filemanager', function() {
var client_id = options.client_id;
@@ -1398,21 +1421,6 @@ function frame_breakout(e, properties) {
this.setAttribute('target', properties.framename);
}
function get_image_url(imagename, component) {
var url = M.cfg.wwwroot + '/theme/image.php?theme=' + M.cfg.theme + '&image=' + imagename;
if (M.cfg.themerev > 0) {
url = url + '&rev=' + M.cfg.themerev;
}
if (component != '' && component != 'moodle' && component != 'core') {
url = url + '&component=' + component;
}
return url;
}
// ===== Deprecated core Javascript functions for Moodle ====
// DO NOT USE!!!!!!!