Save note on F5/quit
This commit is contained in:
@@ -5,6 +5,7 @@ function CATC(asGlobals)
|
||||
this.consts.hash_sep = '-';
|
||||
this.consts.default_page = 'workshops';
|
||||
this.consts.title = 'CATC';
|
||||
this.consts.exitmodes = {same_page:'SP', new_page:'NP', closing:'LE'};
|
||||
this.consts.root = location.protocol+'//'+location.host+location.pathname;
|
||||
|
||||
this.init = function()
|
||||
@@ -22,6 +23,9 @@ function CATC(asGlobals)
|
||||
//on window resize
|
||||
$(window).resize(self.onResize).resize();
|
||||
|
||||
//on Quit / F5
|
||||
$(window).on('unload', function(){self.onQuitPage(self.consts.exitmodes.closing);});
|
||||
|
||||
//Hash management
|
||||
self.resetTmpFunctions();
|
||||
$(window)
|
||||
@@ -34,23 +38,6 @@ function CATC(asGlobals)
|
||||
$.each(asVars, function(sKey, oValue){self.vars(sKey, oValue)});
|
||||
};
|
||||
|
||||
/* Scrollbar */
|
||||
|
||||
/*this.scrollbar = function(sPos)
|
||||
{
|
||||
var $Cv = $('#main');
|
||||
if(!self.vars('mobile'))
|
||||
{
|
||||
if(typeof self.vars('scrollbar') === 'undefined')
|
||||
{
|
||||
$Cv.tinyscrollbar({axis:'y', thumbSizeMin:'20', thumbSize:'20'});
|
||||
self.vars('scrollbar', $Cv.data("plugin_tinyscrollbar"));
|
||||
}
|
||||
else self.vars('scrollbar').update(sPos);
|
||||
}
|
||||
else $Cv.unbind("tinyscrollbar");
|
||||
}*/
|
||||
|
||||
/* Menu */
|
||||
|
||||
this.initMenu = function()
|
||||
@@ -181,24 +168,11 @@ function CATC(asGlobals)
|
||||
);
|
||||
};
|
||||
|
||||
this.setSideElemVisibility = function() {
|
||||
if(self.elem.$Side) {
|
||||
var iHeight = 0;
|
||||
var iMaxHeight = self.elem.$Side.height();
|
||||
self.elem.$Side.children().each(function(){
|
||||
$(this).toggle(iMaxHeight - iHeight > 0);
|
||||
iHeight += $(this).outerHeight(true);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/* Events */
|
||||
|
||||
this.onResize = function()
|
||||
{
|
||||
self.vars('mobile', $('body').css('min-width')=='120px');
|
||||
self.setSideElemVisibility();
|
||||
//self.scrollbar();
|
||||
};
|
||||
|
||||
this.onHashChange = function()
|
||||
@@ -211,7 +185,7 @@ function CATC(asGlobals)
|
||||
{
|
||||
self.pageInit = function(asHash, bFirstPage){console.log('no init for the page: '+asHash.page)};
|
||||
self.onSamePageMove = function(asHash){return false};
|
||||
self.onQuitPage = function(){return true};
|
||||
self.onQuitPage = function(sExitMode){return true};
|
||||
self.onFeedback = function(sType, sMsg){Tools.feedback(sType, sMsg);};
|
||||
};
|
||||
|
||||
@@ -251,21 +225,6 @@ function CATC(asGlobals)
|
||||
if(bReboot) location.reload();
|
||||
};
|
||||
|
||||
this.getVars = function(fOnSuccess)
|
||||
{
|
||||
fOnSuccess = fOnSuccess || function(){};
|
||||
getInfo
|
||||
(
|
||||
'vars',
|
||||
function(asData)
|
||||
{
|
||||
self.updateVars(asData.vars);
|
||||
fOnSuccess();
|
||||
},
|
||||
{}
|
||||
);
|
||||
};
|
||||
|
||||
/* Page Switching */
|
||||
|
||||
this.loadHome = function(asData) {
|
||||
@@ -316,7 +275,7 @@ function CATC(asGlobals)
|
||||
else
|
||||
{
|
||||
var bSamePage = (sCurrPage == sNextPage);
|
||||
if(self.onQuitPage(bSamePage) && !bSamePage || self.onSamePageMove(asHash))
|
||||
if(self.onQuitPage(self.consts.exitmodes[bSamePage?'same_page':'new_page']) && !bSamePage || self.onSamePageMove(asHash))
|
||||
{
|
||||
//Delete tmp variables
|
||||
self.vars('tmp', {});
|
||||
@@ -340,7 +299,6 @@ function CATC(asGlobals)
|
||||
self.elem.$Main = self.elem.$Container.find('#main');
|
||||
|
||||
self.elem.$Menu = self.elem.$Container.find('#menu');
|
||||
self.elem.$Side = self.elem.$Container.find('#side');
|
||||
if(self.vars.log_in) self.initMenu();
|
||||
|
||||
self.splash(self.elem.$Main, $Dom, asHash, bFirstPage); //first page
|
||||
|
||||
Reference in New Issue
Block a user