add bootstrap
This commit is contained in:
@@ -5,6 +5,7 @@ function MyThoughts(asGlobals)
|
||||
this.consts.hash_sep = '-';
|
||||
this.consts.default_page = 'home';
|
||||
this.consts.title = 'My Thoughts';
|
||||
this.consts.root = location.protocol+'//'+location.host+location.pathname;
|
||||
|
||||
this.init = function()
|
||||
{
|
||||
@@ -16,14 +17,11 @@ function MyThoughts(asGlobals)
|
||||
|
||||
//page elem
|
||||
self.elem = {};
|
||||
self.elem.container = $('#container');
|
||||
self.elem.$Container = $('#container');
|
||||
|
||||
//on window resize
|
||||
$(window).resize(self.onResize).resize();
|
||||
|
||||
//Setup menu
|
||||
//self.initMenu();
|
||||
|
||||
//Hash management
|
||||
self.resetTmpFunctions();
|
||||
$(window)
|
||||
@@ -57,7 +55,7 @@ function MyThoughts(asGlobals)
|
||||
|
||||
this.initMenu = function()
|
||||
{
|
||||
|
||||
self.elem.$Menu.show('fast');
|
||||
};
|
||||
|
||||
/* Events */
|
||||
@@ -76,10 +74,10 @@ function MyThoughts(asGlobals)
|
||||
|
||||
this.resetTmpFunctions = function()
|
||||
{
|
||||
self.pageInit = function(asHash){console.log('no init for the page: '+asHash.page)};
|
||||
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.onFeedback = function(sType, sMsg){feedback(sType, sMsg, self.elem.container);};
|
||||
self.onFeedback = function(sType, sMsg){Tools.feedback(sType, sMsg, self.elem.$Container);};
|
||||
};
|
||||
|
||||
/* Hash Handling */
|
||||
@@ -131,6 +129,22 @@ function MyThoughts(asGlobals)
|
||||
|
||||
/* Page Switching */
|
||||
|
||||
this.loadHome = function(asData) {
|
||||
|
||||
console.log(asData);
|
||||
|
||||
self.vars('log_in', asData.log_in);
|
||||
self.vars('id', asData.id);
|
||||
|
||||
if(self.vars('log_in')) {
|
||||
//Setup menu
|
||||
self.initMenu();
|
||||
|
||||
//Swap to default page
|
||||
self.setHash('write');
|
||||
}
|
||||
};
|
||||
|
||||
this.getActionLink = function(sAction, oVars)
|
||||
{
|
||||
if(!oVars) oVars = {};
|
||||
@@ -149,7 +163,15 @@ function MyThoughts(asGlobals)
|
||||
var bLoggedIn = self.vars('log_in');
|
||||
var sDefaultPage = bLoggedIn?'write':'logon';
|
||||
|
||||
if(asHash.hash !='' && sNextPage != '' && (bLoggedIn || sNextPage==sDefaultPage))
|
||||
if( asHash.hash == '' ||
|
||||
sNextPage == '' ||
|
||||
!bLoggedIn && sNextPage != sDefaultPage ||
|
||||
bLoggedIn && sNextPage == 'logon'
|
||||
)
|
||||
{
|
||||
self.setHash(sDefaultPage); //force first page
|
||||
}
|
||||
else
|
||||
{
|
||||
var bSamePage = (sCurrPage==sNextPage);
|
||||
if(self.onQuitPage(bSamePage) && !bSamePage || self.onSamePageMove(asHash))
|
||||
@@ -172,17 +194,20 @@ function MyThoughts(asGlobals)
|
||||
var $Dom = $(self.consts.pages[sNextPage]);
|
||||
if(bFirstPage)
|
||||
{
|
||||
self.elem.container.html($(self.consts.pages['template']));
|
||||
self.elem.main = self.elem.container.find('#main');
|
||||
self.splash(self.elem.main, $Dom, asHash, bFirstPage); //first page
|
||||
self.elem.$Container.html($(self.consts.pages['template']));
|
||||
self.elem.$Main = self.elem.$Container.find('#main');
|
||||
|
||||
self.elem.$Menu = self.elem.$Container.find('#menu');
|
||||
if(self.vars.log_in) self.initMenu();
|
||||
|
||||
self.splash(self.elem.$Main, $Dom, asHash, bFirstPage); //first page
|
||||
}
|
||||
else
|
||||
{
|
||||
self.elem.main.stop().fadeTo('fast', 0, function(){self.splash(self.elem.main, $Dom, asHash, bFirstPage);}); //Switching page
|
||||
self.elem.$Main.stop().fadeTo('fast', 0, function(){self.splash(self.elem.$Main, $Dom, asHash, bFirstPage);}); //Switching page
|
||||
}
|
||||
}
|
||||
}
|
||||
else self.setHash(sDefaultPage); //force first page
|
||||
};
|
||||
|
||||
this.splash = function($FadeInElem, $Dom, asHash, bFirstPage)
|
||||
@@ -192,6 +217,7 @@ function MyThoughts(asGlobals)
|
||||
$FadeInElem.html($Dom);
|
||||
|
||||
//Page Bootstrap
|
||||
self.elem.$Main.removeClass('no_frame');
|
||||
self.pageInit(asHash, bFirstPage);
|
||||
|
||||
//Show main
|
||||
|
||||
Reference in New Issue
Block a user