From 4d016169e701e63522175e899ecd7353f688276e Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 29 Apr 2014 16:51:57 +0000 Subject: [PATCH] Precautions for iframes + sidebox - Unbind any existing events on existing sidebox, if _init_sidebox() is called again - Only call _init_sidebox() on top-level window's app.js, fixes some iframe issues with admin --- phpgwapi/js/jsapi/app_base.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/phpgwapi/js/jsapi/app_base.js b/phpgwapi/js/jsapi/app_base.js index 41b83837e0..f9f4ce1eb3 100644 --- a/phpgwapi/js/jsapi/app_base.js +++ b/phpgwapi/js/jsapi/app_base.js @@ -99,7 +99,15 @@ var AppJS = Class.extend( var egw_fw = egw_getFramework(); sidebox= $j('#favorite_sidebox_'+this.appname,egw_fw.sidemenuDiv); } - this._init_sidebox(sidebox); + // Make sure we're running in the top window when we init sidebox + if(window.top.app[this.appname] !== this) + { + window.top.app[this.appname]._init_sidebox(sidebox); + } + else + { + this._init_sidebox(sidebox); + } }, /** @@ -302,6 +310,7 @@ var AppJS = Class.extend( if(sidebox.length) { var self = this; + if(this.sidebox) this.sidebox.off(); this.sidebox = sidebox; sidebox .off() @@ -319,7 +328,7 @@ var AppJS = Class.extend( } }) .addClass("ui-helper-clearfix"); - + //Add Sortable handler to sideBox fav. menu jQuery('ul','#favorite_sidebox_'+this.appname).sortable({ @@ -330,10 +339,10 @@ var AppJS = Class.extend( var favSortedList = jQuery(this).sortable('toArray', {attribute:'data-id'}); self.egw.set_preference(self.appname,'fav_sort_pref',favSortedList); - + self._refresh_fav_nm(); } - }); + }); return true; } return false;