// Get the height of the div at this point before we shrink it if required
var height = this.div.get('offsetHeight');
var collapsedimage = 't/collapsed'; // ltr mode
- if ( Y.one(document.body).hasClass('dir-rtl') ) {
+ if (right_to_left()) {
collapsedimage = 't/collapsed_rtl';
} else {
collapsedimage = 't/collapsed';
animation.on('end', function() {
this.div.toggleClass('collapsed');
var collapsedimage = 't/collapsed'; // ltr mode
- if ( Y.one(document.body).hasClass('dir-rtl') ) {
+ if (right_to_left()) {
collapsedimage = 't/collapsed_rtl';
} else {
collapsedimage = 't/collapsed';
if (Y.Lang.isString(el)) {
el = Y.one('#' + el);
}
- var val = el.getStyle(prop);
- if (val == 'auto') {
- val = el.getComputedStyle(prop);
+ // Ensure element exists.
+ if (el) {
+ var val = el.getStyle(prop);
+ if (val == 'auto') {
+ val = el.getComputedStyle(prop);
+ }
+ return parseInt(val);
+ } else {
+ return 0;
}
- return parseInt(val);
};
var resize_object = function() {
/**
* Attach handler to single_select
+ *
+ * This code was deprecated in Moodle 2.4 and will be removed in Moodle 2.6
+ *
+ * Please see lib/yui/formautosubmit/formautosubmit.js for its replacement
*/
M.util.init_select_autosubmit = function(Y, formid, selectid, nothing) {
+ if (M.cfg.developerdebug) {
+ Y.log("You are using a deprecated function call (M.util.init_select_autosubmit). Please look at rewriting your call to use moodle-core-formautosubmit");
+ }
Y.use('event-key', function() {
var select = Y.one('#'+selectid);
if (select) {
* This function has accessability issues and also does not use the formid passed through as a parameter.
*/
M.util.init_url_select = function(Y, formid, selectid, nothing) {
+ if (M.cfg.developerdebug) {
+ Y.log("You are using a deprecated function call (M.util.init_url_select). Please look at rewriting your call to use moodle-core-formautosubmit");
+ }
YUI().use('node', function(Y) {
Y.on('change', function() {
if ((nothing == false && Y.Lang.isBoolean(nothing)) || Y.one('#'+selectid).get('value') != nothing) {
return (arrReturnElements)
}
+/**
+ * Return whether we are in right to left mode or not.
+ *
+ * @return boolean
+ */
+function right_to_left() {
+ var body = Y.one('body');
+ var rtl = false;
+ if (body && body.hasClass('dir-rtl')) {
+ rtl = true;
+ }
+ return rtl;
+}
+
function openpopup(event, args) {
if (event) {
M.util.help_icon = {
Y : null,
instance : null,
- add : function(Y, properties) {
- this.Y = Y;
- properties.node = Y.one('#'+properties.id);
- if (properties.node) {
- properties.node.on('click', this.display, this, properties);
+ initialised : false,
+ setup : function(Y) {
+ if (this.initialised) {
+ // Exit early if we have already completed setup
+ return;
}
+ this.Y = Y;
+ Y.one('body').delegate('click', this.display, 'span.helplink a.tooltip', this);
+ this.initialised = true;
},
- display : function(event, args) {
+ add : function(Y, properties) {
+ this.setup(Y);
+ },
+ display : function(event) {
event.preventDefault();
if (M.util.help_icon.instance === null) {
var Y = M.util.help_icon.Y;
// Hide the menu if the user clicks outside of its content
boundingBox.get("ownerDocument").on("mousedown", function (event) {
var oTarget = event.target;
- var menuButton = Y.one("#"+args.id);
+ var menuButton = this.helplink;
if (!oTarget.compareTo(menuButton) &&
!menuButton.contains(oTarget) &&
this.overlay.hide();
},
- display : function(event, args) {
- if (Y.one('html').get('dir') == 'rtl') {
- var overlayPosition = [Y.WidgetPositionAlign.TR, Y.WidgetPositionAlign.LC];
+ display : function(event) {
+ var overlayPosition;
+ this.helplink = event.target.ancestor('span.helplink a', true);
+ if (Y.one('html').get('dir') === 'rtl') {
+ overlayPosition = [Y.WidgetPositionAlign.TR, Y.WidgetPositionAlign.LC];
} else {
- var overlayPosition = [Y.WidgetPositionAlign.TL, Y.WidgetPositionAlign.RC];
+ overlayPosition = [Y.WidgetPositionAlign.TL, Y.WidgetPositionAlign.RC];
}
- this.helplink = args.node;
-
this.overlay.set('bodyContent', Y.Node.create('<img src="'+M.cfg.loadingicon+'" class="spinner" />'));
- this.overlay.set("align", {node:args.node, points: overlayPosition});
-
- var fullurl = args.url;
- if (!args.url.match(/https?:\/\//)) {
- fullurl = M.cfg.wwwroot + args.url;
- }
-
- var ajaxurl = fullurl + '&ajax=1';
+ this.overlay.set("align", {node:this.helplink, points: overlayPosition});
var cfg = {
method: 'get',
context : this,
+ data : {
+ ajax : 1
+ },
on: {
success: function(id, o, node) {
this.display_callback(o.responseText);
}
};
- Y.io(ajaxurl, cfg);
+ Y.io(this.helplink.get('href'), cfg);
this.overlay.show();
},
};
help_content_overlay.init();
M.util.help_icon.instance = help_content_overlay;
- M.util.help_icon.instance.display(event, args);
+ M.util.help_icon.instance.display(event);
});
} else {
- M.util.help_icon.instance.display(event, args);
+ M.util.help_icon.instance.display(event);
}
},
init : function(Y) {
object.width = width;
object.height = height;
}
- }
+ }
}
});
}