44 $ lang = (isset ($ _SESSION ['s ' ]['language ' ]) && $ _SESSION ['s ' ]['language ' ] != '' )?$ _SESSION ['s ' ]['language ' ]:'en ' ;
55 include_once (ISPC_ROOT_PATH .'/web/strengthmeter/lib/lang/ ' .$ lang .'_strengthmeter.lng ' );
66?>
7-
7+ var pageFormChanged = false;
8+ var tabChangeWarningTxt = '';
9+ var tabChangeDiscardTxt = '';
10+ var tabChangeWarning = false;
11+ var tabChangeDiscard = false;
812redirect = '';
913
1014function reportError(request) {
@@ -24,6 +28,7 @@ function loadContentRefresh(pagename) {
2428 dataType: "html",
2529 success: function(data, textStatus, jqXHR) {
2630 jQuery('#pageContent').html(jqXHR.responseText);
31+ pageFormChanged = false;
2732 },
2833 error: function() {
2934 reportError('Ajax Request was not successful.'+pagename);
@@ -87,6 +92,7 @@ function submitLoginForm(formname) {
8792 document.location.href = 'index.php';
8893 } else {
8994 jQuery('#pageContent').html(jqXHR.responseText);
95+ pageFormChanged = false;
9096 }
9197 loadMenus();
9298 },
@@ -118,6 +124,7 @@ function submitForm(formname,target) {
118124 //window.setTimeout('loadContent(redirect)', 1000);
119125 } else {
120126 jQuery('#pageContent').html(jqXHR.responseText);
127+ pageFormChanged = false;
121128 }
122129 },
123130 error: function(jqXHR, textStatus, errorThrown) {
@@ -150,6 +157,7 @@ function submitFormConfirm(formname,target,confirmation) {
150157 //window.setTimeout('loadContent(redirect)', 1000);
151158 } else {
152159 jQuery('#pageContent').html(jqXHR.responseText);
160+ pageFormChanged = false;
153161 }
154162 },
155163 error: function(jqXHR, textStatus, errorThrown) {
@@ -202,8 +210,10 @@ function submitUploadForm(formname,target) {
202210}
203211
204212function loadContent(pagename) {
213+ var params = arguments[1];
205214 var pageContentObject2 = jQuery.ajax({ type: "GET",
206215 url: pagename,
216+ data: (params ? params : null),
207217 dataType: "html",
208218 beforeSend: function() {
209219 jQuery('#pageContent').html('<div id="ajaxloader"><img src="themes/default/images/ajax-loader.gif" /></div>');
@@ -222,6 +232,7 @@ function loadContent(pagename) {
222232 //jQuery.each(reponseScript, function(idx, val) { eval(val.text); } );
223233
224234 jQuery('#pageContent').html(jqXHR.responseText);
235+ pageFormChanged = false;
225236 }
226237 },
227238 error: function() {
@@ -242,6 +253,7 @@ function loadInitContent() {
242253 loadContent(parts[1]);
243254 } else {
244255 jQuery('#pageContent').html(jqXHR.responseText);
256+ pageFormChanged = false;
245257 }
246258 },
247259 error: function() {
@@ -293,7 +305,28 @@ function loadMenus() {
293305function changeTab(tab,target) {
294306 //document.forms[0].next_tab.value = tab;
295307 document.pageForm.next_tab.value = tab;
296- submitForm('pageForm',target);
308+
309+ var id = document.pageForm.id.value;
310+ if(tabChangeDiscard == 'y') {
311+ if(id && (pageFormChanged == false || window.confirm(tabChangeDiscardTxt))) {
312+ var next_tab = tab;
313+ loadContent(target, {'next_tab': next_tab, 'id': id});
314+ } else {
315+ return false;
316+ }
317+ } else {
318+ if(id && tabChangeWarning == 'y' && pageFormChanged == true) {
319+ if(window.confirm(tabChangeWarningTxt)) {
320+ submitForm('pageForm', target);
321+ } else {
322+ var next_tab = tab;
323+ var id = document.pageForm.id.value;
324+ loadContent(target, {'next_tab': next_tab, 'id': id});
325+ }
326+ } else {
327+ submitForm('pageForm',target);
328+ }
329+ }
297330}
298331
299332function del_record(link,confirmation) {
0 commit comments