MDL-19756 Migrated the following functions from weblib to outputlib:

1. button_to_popup_window
2. link_to_popup_window
3. print_single_button
4. print_spacer
5. print_file_picture (deprecated)
6. print_user_picture
7. print_png (deprecated)
8. helpbutton
9. doclink
10. print_paging_bar
11. notice_yesno
This commit is contained in:
nicolasconnault
2009-07-27 10:33:00 +00:00
parent 9482c0fff6
commit f8065dd287
18 changed files with 2481 additions and 861 deletions
+122 -9
View File
@@ -560,7 +560,7 @@ date_selector_calendar.document_click = function(event) {
date_selector_calendar.currentowner.release_calendar();
}
}
}
}
date_selector_calendar.prototype.claim_calendar = function() {
date_selector_calendar.cancel_any_timeout();
@@ -733,12 +733,15 @@ function getElementsByClassName(oElm, strTagName, oClassNames) {
return (arrReturnElements)
}
function openpopup(url, name, options, fullscreen) {
var fullurl = url;
if (!url.match(/https?:\/\//)) {
fullurl = moodle_cfg.wwwroot + url;
function openpopup(event, args) {
YAHOO.util.Event.preventDefault(event);
var fullurl = args.url;
if (!args.url.match(/https?:\/\//)) {
fullurl = moodle_cfg.wwwroot + args.url;
}
var windowobj = window.open(fullurl,name,options);
var windowobj = window.open(fullurl,args.name,args.options);
if (!windowobj) {
return true;
}
@@ -812,7 +815,7 @@ function set_user_preference(name, value) {
}
// Make the request.
YAHOO.util.Connect.asyncRequest('GET', url, callback);
YAHOO.util.Connect.asyncRequest('GET', url, callback);
}
}
@@ -886,7 +889,7 @@ function collapsible_region(id, userpref, strtooltip, collapsedicon, expandedico
collapsible_region.prototype.userpref = null;
/**
* The key divs that make up this
* The key divs that make up this
* @property div, innerdiv, captiondiv
* @type HTMLDivElement
*/
@@ -895,7 +898,7 @@ collapsible_region.prototype.innerdiv = null;
collapsible_region.prototype.captiondiv = null;
/**
* The key divs that make up this
* The key divs that make up this
* @property icon
* @type HTMLImageElement
*/
@@ -1102,3 +1105,113 @@ function build_querystring(obj) {
}
return list.join('&');
}
/**
* Finds all help icons on the page and initiates YUI tooltips for
* each of them, which load a truncated version of the help's content
* on-the-fly asynchronously
*/
function init_help_icons() {
// var logger = new YAHOO.widget.LogReader(document.body, {draggable: true});
var iconspans = YAHOO.util.Dom.getElementsByClassName('helplink', 'span');
var tooltip = new YAHOO.widget.Tooltip('help_icon_tooltip', {
context: iconspans,
showdelay: 100,
hidedelay: 150,
autodismissdelay: 50000,
underlay: 'none'
});
tooltip.contextTriggerEvent.subscribe(
function(type, args) {
// Fetch help page contents asynchronously
// Load spinner icon while content is loading
var spinner = document.createElement('img');
spinner.src = moodle_cfg.loadingicon;
this.cfg.setProperty('text', spinner);
var context = args[0];
context.title = '';
var link = context.getElementsByTagName('a')[0];
link.title = '';
YAHOO.util.Dom.getElementsByClassName('iconhelp', 'img', link)[0].title = '';
var thistooltip = this;
var ajaxurl = link.href + '&fortooltip=1';
var callback = {
success: function(o) {
thistooltip.cfg.setProperty('text', o.responseText);
},
failure: function(o) {
var debuginfo = o.statusText;
if (moodle_cfg.developerdebug) {
o.statusText += ' (' + ajaxurl + ')';
}
thistooltip.cfg.setProperty('text', debuginfo);
}
};
var conn = YAHOO.util.Connect.asyncRequest("get", ajaxurl, callback);
}
);
}
/**
* Prints a confirmation dialog in the style of DOM.confirm().
* @param object event A DOM event
* @param string message The message to show in the dialog
* @param string url The URL to forward to if YES is clicked. Disabled if fn is given
* @param function fn A JS function to run if YES is clicked.
*/
function confirm_dialog(event, message) {
YAHOO.util.Event.preventDefault(event);
var simpledialog = new YAHOO.widget.SimpleDialog('confirmdialog',
{ width: '300px',
fixedcenter: true,
modal: true,
visible: false,
draggable: false
}
);
simpledialog.setHeader(mstr.moodle.confirmation);
simpledialog.setBody(message);
simpledialog.cfg.setProperty('icon', YAHOO.widget.SimpleDialog.ICON_WARN);
var handle_cancel = function() {
this.hide();
};
var handle_yes = function() {
this.hide();
var target = event.target;
if (target.tagName.toLowerCase() == 'a') {
window.location = target.href;
} else if (target.tagName.toLowerCase() == 'input') {
var parentelement = target.parentNode;
while (parentelement.tagName.toLowerCase() != 'form' && parentelement.tagName.toLowerCase() != 'body') {
parentelement = parentelement.parentNode;
}
if (parentelement.tagName.toLowerCase() == 'form') {
parentelement.submit();
}
} else if(moodle_cfg.developerdebug) {
alert("Element of type " + target.tagName + " is not supported by the confirm_dialog function. Use A or INPUT");
}
};
var buttons = [ { text: mstr.moodle.cancel, handler: handle_cancel, isDefault: true },
{ text: mstr.moodle.yes, handler: handle_yes } ];
simpledialog.cfg.queueProperty('buttons', buttons);
simpledialog.render(document.body);
simpledialog.show();
}