From d1fba0f4f509661c4a461ecff7f0cf5e5c8c23c6 Mon Sep 17 00:00:00 2001 From: David Monllao Date: Tue, 2 Feb 2016 12:34:59 +0800 Subject: [PATCH] MDL-51075 filter_glossary: Fix popup position when no popups Thanks to Andrew Nicols for cleaning my eyes. --- .../moodle-filter_glossary-autolinker-debug.js | 7 +++---- .../moodle-filter_glossary-autolinker-min.js | 2 +- .../moodle-filter_glossary-autolinker.js | 7 +++---- filter/glossary/yui/src/autolinker/js/autolinker.js | 7 +++---- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/filter/glossary/yui/build/moodle-filter_glossary-autolinker/moodle-filter_glossary-autolinker-debug.js b/filter/glossary/yui/build/moodle-filter_glossary-autolinker/moodle-filter_glossary-autolinker-debug.js index ecffc3ca735..58f6b4c265a 100644 --- a/filter/glossary/yui/build/moodle-filter_glossary-autolinker/moodle-filter_glossary-autolinker-debug.js +++ b/filter/glossary/yui/build/moodle-filter_glossary-autolinker/moodle-filter_glossary-autolinker-debug.js @@ -75,7 +75,6 @@ Y.extend(AUTOLINKER, Y.Base, { alertpanelid, definition, position; - var self = this; try { data = Y.JSON.parse(content); if (data.success){ @@ -91,7 +90,7 @@ Y.extend(AUTOLINKER, Y.Base, { // Register alertpanel for stacking. alertpanelid = '#moodle-dialogue-' + alertpanel.get('COUNT'); - alertpanel.on('complete', this._deletealertpanel(self.alertpanels, alertpanelid)); + alertpanel.on('complete', this._deletealertpanel, this, alertpanelid); // We already have some windows opened, so set the right position... if (!Y.Object.isEmpty(this.alertpanels)){ @@ -120,8 +119,8 @@ Y.extend(AUTOLINKER, Y.Base, { }); return lastPosition; }, - _deletealertpanel : function(alertpanels, alertpanelid) { - delete alertpanels[alertpanelid]; + _deletealertpanel : function(ev, alertpanelid) { + delete this.alertpanels[alertpanelid]; } }, { NAME : AUTOLINKERNAME, diff --git a/filter/glossary/yui/build/moodle-filter_glossary-autolinker/moodle-filter_glossary-autolinker-min.js b/filter/glossary/yui/build/moodle-filter_glossary-autolinker/moodle-filter_glossary-autolinker-min.js index 46b748d1a20..c2fdc14318e 100644 --- a/filter/glossary/yui/build/moodle-filter_glossary-autolinker/moodle-filter_glossary-autolinker-min.js +++ b/filter/glossary/yui/build/moodle-filter_glossary-autolinker/moodle-filter_glossary-autolinker-min.js @@ -1 +1 @@ -YUI.add("moodle-filter_glossary-autolinker",function(e,t){var n="Glossary filter autolinker",r="width",i="height",s="menubar",o="location",u="scrollbars",a="resizable",f="toolbar",l="status",c="directories",h="fullscreen",p="dependent",d;d=function(){d.superclass.constructor.apply(this,arguments)},e.extend(d,e.Base,{overlay:null,alertpanels:{},initializer:function(){var t=this;require(["core/event"],function(n){e.delegate("click",function(r){r.preventDefault();var i="",s=e.Node.create('
'+"
"),o=new e.Overlay({headerContent:i,bodyContent:s}),u,a;t.overlay=o,o.render(e.one(document.body)),u=this.getAttribute("href").replace("showentry.php","showentry_ajax.php"),a={method:"get",context:t,on:{success:function(e,t){this.display_callback(t.responseText,n)},failure:function(e,t){var n=t.statusText;M.cfg.developerdebug&&(t.statusText+=" ("+u+")"),new M.core.exception({message:n})}}},e.io(u,a)},e.one(document.body),"a.glossary.autolink.concept")})},display_callback:function(t,n){var r,i,s,o,u,a,f=this;try{r=e.JSON.parse(t);if(r.success){this.overlay.hide();for(i in r.entries)u=r.entries[i].definition+r.entries[i].attachments,s=new M.core.alert({title:r.entries[i].concept,draggable:!0,message:u,modal:!1,yesLabel:M.util.get_string("ok","moodle")}),n.notifyFilterContentUpdated(s.get("boundingBox").getDOMNode()),e.Node.one("#id_yuialertconfirm-"+s.get("COUNT")).focus(),o="#moodle-dialogue-"+s.get("COUNT"),s.on("complete",this._deletealertpanel(f.alertpanels,o)),e.Object.isEmpty(this.alertpanels)||(a=this._getLatestWindowPosition(),e.Node.one(o).setXY([a[0]+10,a[1]+10])),this.alertpanels[o]=e.Node.one(o).getXY();return!0}r.error&&new M.core.ajaxException(r)}catch(l){new M.core.exception(l)}return!1},_getLatestWindowPosition:function(){var t=[0,0];return e.Object.each(this.alertpanels,function(e){e[0]>t[0]&&(t=e)}),t},_deletealertpanel:function(e,t){delete e[t]}},{NAME:n,ATTRS:{url:{validator:e.Lang.isString,value:M.cfg.wwwroot+"/mod/glossary/showentry.php"},name:{validator:e.Lang.isString,value:"glossaryconcept"},options:{getter:function(){return{width:this.get(r),height:this.get(i),menubar:this.get(s),location:this.get(o),scrollbars:this.get(u),resizable:this.get(a),toolbar:this.get(f),status:this.get(l),directories:this.get(c),fullscreen:this.get(h),dependent:this.get(p)}},readOnly:!0},width:{value:600},height:{value:450},menubar:{value:!1},location:{value:!1},scrollbars:{value:!0},resizable:{value:!0},toolbar:{value:!0},status:{value:!0},directories:{value:!1},fullscreen:{value:!1},dependent:{value:!0}}}),M.filter_glossary=M.filter_glossary||{},M.filter_glossary.init_filter_autolinking=function(e){return new d(e)}},"@VERSION@",{requires:["base","node","io-base","json-parse","event-delegate","overlay","moodle-core-event","moodle-core-notification-alert","moodle-core-notification-exception","moodle-core-notification-ajaxexception"]}); +YUI.add("moodle-filter_glossary-autolinker",function(e,t){var n="Glossary filter autolinker",r="width",i="height",s="menubar",o="location",u="scrollbars",a="resizable",f="toolbar",l="status",c="directories",h="fullscreen",p="dependent",d;d=function(){d.superclass.constructor.apply(this,arguments)},e.extend(d,e.Base,{overlay:null,alertpanels:{},initializer:function(){var t=this;require(["core/event"],function(n){e.delegate("click",function(r){r.preventDefault();var i="",s=e.Node.create('
'+"
"),o=new e.Overlay({headerContent:i,bodyContent:s}),u,a;t.overlay=o,o.render(e.one(document.body)),u=this.getAttribute("href").replace("showentry.php","showentry_ajax.php"),a={method:"get",context:t,on:{success:function(e,t){this.display_callback(t.responseText,n)},failure:function(e,t){var n=t.statusText;M.cfg.developerdebug&&(t.statusText+=" ("+u+")"),new M.core.exception({message:n})}}},e.io(u,a)},e.one(document.body),"a.glossary.autolink.concept")})},display_callback:function(t,n){var r,i,s,o,u,a;try{r=e.JSON.parse(t);if(r.success){this.overlay.hide();for(i in r.entries)u=r.entries[i].definition+r.entries[i].attachments,s=new M.core.alert({title:r.entries[i].concept,draggable:!0,message:u,modal:!1,yesLabel:M.util.get_string("ok","moodle")}),n.notifyFilterContentUpdated(s.get("boundingBox").getDOMNode()),e.Node.one("#id_yuialertconfirm-"+s.get("COUNT")).focus(),o="#moodle-dialogue-"+s.get("COUNT"),s.on("complete",this._deletealertpanel,this,o),e.Object.isEmpty(this.alertpanels)||(a=this._getLatestWindowPosition(),e.Node.one(o).setXY([a[0]+10,a[1]+10])),this.alertpanels[o]=e.Node.one(o).getXY();return!0}r.error&&new M.core.ajaxException(r)}catch(f){new M.core.exception(f)}return!1},_getLatestWindowPosition:function(){var t=[0,0];return e.Object.each(this.alertpanels,function(e){e[0]>t[0]&&(t=e)}),t},_deletealertpanel:function(e,t){delete this.alertpanels[t]}},{NAME:n,ATTRS:{url:{validator:e.Lang.isString,value:M.cfg.wwwroot+"/mod/glossary/showentry.php"},name:{validator:e.Lang.isString,value:"glossaryconcept"},options:{getter:function(){return{width:this.get(r),height:this.get(i),menubar:this.get(s),location:this.get(o),scrollbars:this.get(u),resizable:this.get(a),toolbar:this.get(f),status:this.get(l),directories:this.get(c),fullscreen:this.get(h),dependent:this.get(p)}},readOnly:!0},width:{value:600},height:{value:450},menubar:{value:!1},location:{value:!1},scrollbars:{value:!0},resizable:{value:!0},toolbar:{value:!0},status:{value:!0},directories:{value:!1},fullscreen:{value:!1},dependent:{value:!0}}}),M.filter_glossary=M.filter_glossary||{},M.filter_glossary.init_filter_autolinking=function(e){return new d(e)}},"@VERSION@",{requires:["base","node","io-base","json-parse","event-delegate","overlay","moodle-core-event","moodle-core-notification-alert","moodle-core-notification-exception","moodle-core-notification-ajaxexception"]}); diff --git a/filter/glossary/yui/build/moodle-filter_glossary-autolinker/moodle-filter_glossary-autolinker.js b/filter/glossary/yui/build/moodle-filter_glossary-autolinker/moodle-filter_glossary-autolinker.js index ecffc3ca735..58f6b4c265a 100644 --- a/filter/glossary/yui/build/moodle-filter_glossary-autolinker/moodle-filter_glossary-autolinker.js +++ b/filter/glossary/yui/build/moodle-filter_glossary-autolinker/moodle-filter_glossary-autolinker.js @@ -75,7 +75,6 @@ Y.extend(AUTOLINKER, Y.Base, { alertpanelid, definition, position; - var self = this; try { data = Y.JSON.parse(content); if (data.success){ @@ -91,7 +90,7 @@ Y.extend(AUTOLINKER, Y.Base, { // Register alertpanel for stacking. alertpanelid = '#moodle-dialogue-' + alertpanel.get('COUNT'); - alertpanel.on('complete', this._deletealertpanel(self.alertpanels, alertpanelid)); + alertpanel.on('complete', this._deletealertpanel, this, alertpanelid); // We already have some windows opened, so set the right position... if (!Y.Object.isEmpty(this.alertpanels)){ @@ -120,8 +119,8 @@ Y.extend(AUTOLINKER, Y.Base, { }); return lastPosition; }, - _deletealertpanel : function(alertpanels, alertpanelid) { - delete alertpanels[alertpanelid]; + _deletealertpanel : function(ev, alertpanelid) { + delete this.alertpanels[alertpanelid]; } }, { NAME : AUTOLINKERNAME, diff --git a/filter/glossary/yui/src/autolinker/js/autolinker.js b/filter/glossary/yui/src/autolinker/js/autolinker.js index 3689b4a3d05..2d0471ecff4 100644 --- a/filter/glossary/yui/src/autolinker/js/autolinker.js +++ b/filter/glossary/yui/src/autolinker/js/autolinker.js @@ -73,7 +73,6 @@ Y.extend(AUTOLINKER, Y.Base, { alertpanelid, definition, position; - var self = this; try { data = Y.JSON.parse(content); if (data.success){ @@ -89,7 +88,7 @@ Y.extend(AUTOLINKER, Y.Base, { // Register alertpanel for stacking. alertpanelid = '#moodle-dialogue-' + alertpanel.get('COUNT'); - alertpanel.on('complete', this._deletealertpanel(self.alertpanels, alertpanelid)); + alertpanel.on('complete', this._deletealertpanel, this, alertpanelid); // We already have some windows opened, so set the right position... if (!Y.Object.isEmpty(this.alertpanels)){ @@ -118,8 +117,8 @@ Y.extend(AUTOLINKER, Y.Base, { }); return lastPosition; }, - _deletealertpanel : function(alertpanels, alertpanelid) { - delete alertpanels[alertpanelid]; + _deletealertpanel : function(ev, alertpanelid) { + delete this.alertpanels[alertpanelid]; } }, { NAME : AUTOLINKERNAME,