forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-35819 AJAX Rewrite Moodle popup help to be more friendly and more…
… efficient
- Loading branch information
Andrew Robert Nicols
committed
Feb 10, 2013
1 parent
6319737
commit 238b8bc
Showing
11 changed files
with
598 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
YUI.add('moodle-core-popuphelp', function(Y) { | ||
function POPUPHELP() { | ||
POPUPHELP.superclass.constructor.apply(this, arguments); | ||
} | ||
|
||
var SELECTORS = { | ||
CLICKABLELINKS: 'span.helptooltip > a', | ||
FOOTER: 'div.moodle-dialogue-ft' | ||
}, | ||
|
||
CSS = { | ||
ICON: 'icon', | ||
ICONPRE: 'icon-pre' | ||
}, | ||
ATTRS = {}; | ||
|
||
// Set the modules base properties. | ||
POPUPHELP.NAME = 'moodle-core-popuphelp'; | ||
POPUPHELP.ATTRS = ATTRS; | ||
|
||
Y.extend(POPUPHELP, Y.Base, { | ||
panel: null, | ||
|
||
initializer: function() { | ||
Y.one('body').delegate('click', this.display_panel, SELECTORS.CLICKABLELINKS, this); | ||
}, | ||
|
||
display_panel: function(e) { | ||
if (!this.panel) { | ||
this.panel = new M.core.tooltip({ | ||
bodyhandler: this.set_body_content, | ||
footerhandler: this.set_footer, | ||
initialheadertext: M.util.get_string('loadinghelp', 'moodle'), | ||
initialfootertext: '' | ||
}); | ||
} | ||
|
||
// Call the tooltip setup. | ||
this.panel.display_panel(e); | ||
}, | ||
|
||
/** | ||
* Override the footer handler to add a 'More help' link where relevant. | ||
* | ||
* @param {Object} helpobject The object returned from the AJAX call. | ||
*/ | ||
set_footer: function(helpobject) { | ||
// Check for an optional link to documentation on moodle.org. | ||
if (helpobject.doclink) { | ||
// Wrap a help icon and the morehelp text in an anchor. The class of the anchor should | ||
// determine whether it's opened in a new window or not. | ||
doclink = Y.Node.create('<a />') | ||
.setAttrs({ | ||
'href': helpobject.doclink.link | ||
}) | ||
.addClass(helpobject.doclink['class']); | ||
helpicon = Y.Node.create('<img />') | ||
.setAttrs({ | ||
'src': M.util.image_url('docs', 'core') | ||
}) | ||
.addClass(CSS.ICON) | ||
.addClass(CSS.ICONPRE); | ||
doclink.appendChild(helpicon); | ||
doclink.appendChild(helpobject.doclink.linktext); | ||
|
||
// Set the footerContent to the contents of the doclink. | ||
this.set('footerContent', doclink); | ||
this.bb.one(SELECTORS.FOOTER).show(); | ||
} else { | ||
this.bb.one(SELECTORS.FOOTER).hide(); | ||
} | ||
} | ||
}); | ||
M.core = M.core || {}; | ||
M.core.popuphelp = M.core.popuphelp || null; | ||
M.core.init_popuphelp = M.core.init_popuphelp || function(config) { | ||
// Only set up a single instance of the popuphelp. | ||
if (!M.core.popuphelp) { | ||
M.core.popuphelp = new POPUPHELP(config); | ||
} | ||
return M.core.popuphelp; | ||
}; | ||
}, | ||
'@VERSION@', { | ||
requires: ['moodle-core-tooltip'] | ||
}); |
Oops, something went wrong.