Commit 025e0130 authored by Martin Mastny's avatar Martin Mastny Committed by Mark Nelson
Browse files

MDL-33765 filter_glossary: Stacking JS windows with offset

parent 5a0a0a4d
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
...@@ -17,6 +17,7 @@ AUTOLINKER = function() { ...@@ -17,6 +17,7 @@ AUTOLINKER = function() {
}; };
Y.extend(AUTOLINKER, Y.Base, { Y.extend(AUTOLINKER, Y.Base, {
overlay : null, overlay : null,
alertpanels: {},
initializer : function() { initializer : function() {
var self = this; var self = this;
Y.delegate('click', function(e){ Y.delegate('click', function(e){
...@@ -59,7 +60,11 @@ Y.extend(AUTOLINKER, Y.Base, { ...@@ -59,7 +60,11 @@ Y.extend(AUTOLINKER, Y.Base, {
display_callback : function(content) { display_callback : function(content) {
var data, var data,
key, key,
alertpanel; alertpanel,
alertpanelid,
definition,
position;
var self = this;
try { try {
data = Y.JSON.parse(content); data = Y.JSON.parse(content);
if (data.success){ if (data.success){
...@@ -71,6 +76,20 @@ Y.extend(AUTOLINKER, Y.Base, { ...@@ -71,6 +76,20 @@ Y.extend(AUTOLINKER, Y.Base, {
message:definition, modal:false, yesLabel: M.util.get_string('ok', 'moodle')}); message:definition, modal:false, yesLabel: M.util.get_string('ok', 'moodle')});
Y.fire(M.core.event.FILTER_CONTENT_UPDATED, {nodes: (new Y.NodeList(alertpanel.get('boundingBox')))}); Y.fire(M.core.event.FILTER_CONTENT_UPDATED, {nodes: (new Y.NodeList(alertpanel.get('boundingBox')))});
Y.Node.one('#id_yuialertconfirm-' + alertpanel.get('COUNT')).focus(); Y.Node.one('#id_yuialertconfirm-' + alertpanel.get('COUNT')).focus();
// Register alertpanel for stacking.
alertpanelid = '#moodle-dialogue-' + alertpanel.get('COUNT');
alertpanel.on('complete', function(){
delete self.alertpanels[alertpanelid];
});
// We already have some windows opened, so set the right position...
if (!Y.Object.isEmpty(this.alertpanels)){
position = this._getLatestWindowPosition();
Y.Node.one(alertpanelid).setXY([position[0] + 10, position[1] + 10]);
}
this.alertpanels[alertpanelid] = Y.Node.one(alertpanelid).getXY();
} }
return true; return true;
...@@ -81,6 +100,15 @@ Y.extend(AUTOLINKER, Y.Base, { ...@@ -81,6 +100,15 @@ Y.extend(AUTOLINKER, Y.Base, {
new M.core.exception(e); new M.core.exception(e);
} }
return false; return false;
},
_getLatestWindowPosition : function() {
var lastPosition = [0, 0];
Y.Object.each(this.alertpanels, function(position) {
if (position[0] > lastPosition[0]){
lastPosition = position;
}
});
return lastPosition;
} }
}, { }, {
NAME : AUTOLINKERNAME, NAME : AUTOLINKERNAME,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment