[eGroupWare-svn] r55915 - in /trunk: egroupware/api/js/jsapi/app_base.js jdots/js/fw_mobile.js

[email protected] Thu, 28 Apr 2016 13:53:44 -0000
Newsgroups gmane.comp.web.egroupware.cvs
Message-ID <[email protected]>
Author: hnategh
Date: Thu Apr 28 15:53:44 2016
New Revision: 55915

URL: http://svn.stylite.de/viewvc/egroupware?rev=55915&view=rev
Log:
Mobile theme:
- Fix back button state and a confirmation to logout action

Modified:
    trunk/egroupware/api/js/jsapi/app_base.js
    trunk/jdots/js/fw_mobile.js

Modified: trunk/egroupware/api/js/jsapi/app_base.js
URL: http://svn.stylite.de/viewvc/egroupware/trunk/egroupware/api/js/jsapi/app_base.js?rev=55915&r1=55914&r2=55915&view=diff
==============================================================================
--- trunk/egroupware/api/js/jsapi/app_base.js (original)
+++ trunk/egroupware/api/js/jsapi/app_base.js Thu Apr 28 15:53:44 2016
@@ -472,7 +472,7 @@
 
 		// etemplate2 object for view
 		this.et2_view = new etemplate2 (this.viewTemplate[0], false);
-
+		framework.pushState('view');
 		if(templateName)
 		{
 			this.et2_view.load(this.appname+'.'+templateName,templateURL, data, typeof et2_callback == 'function'?et2_callback:function(){}, app);

Modified: trunk/jdots/js/fw_mobile.js
URL: http://svn.stylite.de/viewvc/egroupware/trunk/jdots/js/fw_mobile.js?rev=55915&r1=55914&r2=55915&view=diff
==============================================================================
--- trunk/jdots/js/fw_mobile.js (original)
+++ trunk/jdots/js/fw_mobile.js Thu Apr 28 15:53:44 2016
@@ -243,7 +243,6 @@
 			this.$container.detach();
 			//Remove the closed popup from popups array
 			window.framework.popups.splice(_idx,1);
-			history.back();
 		},
 
 		/**
@@ -754,7 +753,7 @@
 				window.framework.popups.push(popup);
 
 			popup.open(_url,_width,_height,positionLeft,positionTop);
-			history.pushState({current:_url, index:this.popup_idx(popup.$iFrame[0].contentWindow)},"popup", _url);
+			framework.pushState('popup',this.popup_idx(popup.$iFrame[0].contentWindow));
 			var windowID = popup.$iFrame[0].contentWindow;
 
 			// inject framework and egw object, because opener might not yet be loaded and therefore has no egw object!
@@ -923,6 +922,18 @@
 				// vibration API supported
 				navigator.vibrate(_duration);
 			}
+		},
+		/**
+		 * Push state history, set a state as hashed url param
+		 *
+		 * @param {type} _type type of state
+		 * @param {type} _index index of state
+		 */
+		pushState: function (_type, _index)
+		{
+			var index = _index || 1;
+			history.pushState({type:_type, index:_index}, _type, '#'+ egw.app_name()+"."+_type);
+			history.pushState({type:_type, index:_index}, _type, '#'+ egw.app_name()+"."+_type + '#' + index);
 		}
 	});
 
@@ -955,20 +966,29 @@
 			jQuery('#topmenu_logout').click(function(){ window.framework.redirect(this.getAttribute('href')); return false;});
 			jQuery('form[name^="tz_selection"]').children().on('change', function(){framework.tzSelection(this.value);	return false;});
 			window.egw.link_quick_add('quick_add');
-			history.pushState({current:window.location.href,index:-1},"init");
+			history.pushState({type:'main'}, 'main', '#main');
 			jQuery(window).on('popstate', function(e){
-				var index = 0;
-				if (e.originalEvent.state === null || typeof e.originalEvent.state =='undefined')
-				{
-					history.forward();
-					return false;
-				}
-				else if (e.originalEvent.state && e.originalEvent.state.index >= 0)
-				{
-					index = e.originalEvent.state.index+1;
-				}
-
-				window.framework.popups[index].close(index);
+				// Check if user wants to logout and ask a confirmation
+				if (e.originalEvent.state == null || typeof e.originalEvent.state == 'undefined') {
+					et2_dialog.show_dialog(function(button){
+						if (button === 3){
+							history.forward();
+							return;
+						}
+						history.back();
+					}, 'Are you sure you want to logout?', 'Logout');
+				}
+				// Execute action based on
+				switch (e.originalEvent.state.type)
+				{
+					case 'popup':
+						window.framework.popups[e.originalEvent.state.index].close(e.originalEvent.state.index);
+						break;
+					case 'view':
+						jQuery('.egw_fw_mobile_popup_close').click();
+						break;
+				}
+
 				e.preventDefault();
 			});
 			// allowing javascript urls in topmenu and sidebox only under CSP by binding click handlers to them


------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z