mirror of
https://github.com/pierre42100/ComunicWeb
synced 2025-06-19 04:15:17 +00:00
Add page URL auto change
This commit is contained in:
@ -88,6 +88,11 @@ var ComunicWeb = {
|
||||
* Return current URL opened on the website
|
||||
*/
|
||||
getCurrentWebsiteURL: function(){},
|
||||
|
||||
/**
|
||||
* Change the current website URI
|
||||
*/
|
||||
changeURI: function(newTitle, newURI){},
|
||||
},
|
||||
|
||||
/**
|
||||
@ -104,6 +109,11 @@ var ComunicWeb = {
|
||||
*/
|
||||
showWaitSplashScreen: function(){},
|
||||
|
||||
/**
|
||||
* Show a transparent wait splash screen
|
||||
*/
|
||||
showTransparentWaitSplashScreen: function(){},
|
||||
|
||||
/**
|
||||
* Open a page
|
||||
*/
|
||||
@ -301,6 +311,11 @@ var ComunicWeb = {
|
||||
* Open login page
|
||||
*/
|
||||
openLoginPage: function(additionnalData, targetElement){},
|
||||
|
||||
/**
|
||||
* Perform user login
|
||||
*/
|
||||
loginSubmit: function(){},
|
||||
}
|
||||
|
||||
},
|
||||
|
@ -57,6 +57,28 @@ ComunicWeb.common.page = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Show a transparent wait splash screen
|
||||
*
|
||||
* @returns {elem} The splash screen element to let it being deleted
|
||||
*/
|
||||
showTransparentWaitSplashScreen: function(){
|
||||
//Create the element
|
||||
var waitSplashScreen = document.createElement("div");
|
||||
waitSplashScreen.className = "transparentWaitSplashScreen";
|
||||
|
||||
//Populate it
|
||||
var imgElem = document.createElement("img");
|
||||
imgElem.src = ComunicWeb.__config.assetsURL+"img/barProgress.gif";
|
||||
waitSplashScreen.appendChild(imgElem);
|
||||
|
||||
//Apply splash screen
|
||||
document.body.appendChild(waitSplashScreen);
|
||||
|
||||
//Return wait splash screen element
|
||||
return waitSplashScreen;
|
||||
},
|
||||
|
||||
/**
|
||||
* Open a page
|
||||
*
|
||||
@ -68,7 +90,7 @@ ComunicWeb.common.page = {
|
||||
ComunicWeb.debug.logMessage("Open the following page: " + pageURI);
|
||||
|
||||
//Extract the first part of the URL
|
||||
var firstPartURI = pageURI;
|
||||
var firstPartURI = pageURI.toString();
|
||||
|
||||
//Check if pageURI is empty
|
||||
if(firstPartURI == ""){
|
||||
@ -93,6 +115,9 @@ ComunicWeb.common.page = {
|
||||
//Change page title
|
||||
document.title = pageInfos.pageTitle;
|
||||
|
||||
//Change page URL
|
||||
ComunicWeb.common.url.changeURI(document.title, pageURI);
|
||||
|
||||
//Get the main contener of the page
|
||||
//var mainContenerElem = document.getElementById("wrapper");
|
||||
|
||||
@ -160,6 +185,26 @@ ComunicWeb.common.page = {
|
||||
//Apply template source
|
||||
targetElem.innerHTML = templateContent;
|
||||
|
||||
//Make a link live
|
||||
var aElems = targetElem.getElementsByTagName("a");
|
||||
for(num in aElems){
|
||||
|
||||
//Export current element
|
||||
var currentElement = aElems[num];
|
||||
|
||||
//Check if it is a real html elements and if it contains a "target" attribute
|
||||
if(currentElement.attributes){
|
||||
if(currentElement.attributes.target){
|
||||
|
||||
//Change the onclick behavior of the elements
|
||||
currentElement.onclick = (function() {
|
||||
ComunicWeb.common.page.openPage(this.getAttribute("target"));
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Perform next action (if there is)
|
||||
if(afterParsingHTMLtemplate)
|
||||
afterParsingHTMLtemplate();
|
||||
|
@ -20,4 +20,23 @@ ComunicWeb.common.url = {
|
||||
//Return result
|
||||
return uripage;
|
||||
},
|
||||
|
||||
/**
|
||||
* Change the current website URI
|
||||
*
|
||||
* @param {String} newTitle New title for the page
|
||||
* @param {String} newURI The new URI
|
||||
* @return {Boolean} False if it fails
|
||||
*/
|
||||
changeURI: function(newTitle, newURI){
|
||||
|
||||
//Determine the new URL
|
||||
var newURL = ComunicWeb.__config.siteURL + newURI;
|
||||
|
||||
//Apply it
|
||||
window.history.pushState("object or string", newTitle, newURI);
|
||||
|
||||
//Everything is OK
|
||||
return true;
|
||||
},
|
||||
};
|
@ -41,9 +41,28 @@ ComunicWeb.pages.login = {
|
||||
increaseArea: '20%' // optional
|
||||
});
|
||||
});
|
||||
|
||||
//Get login form element
|
||||
var loginBody = document.getElementById("loginForm");
|
||||
|
||||
//Get login button
|
||||
var loginButton = loginBody.getElementsByClassName("btn-login")[0];
|
||||
|
||||
loginButton.onclick=ComunicWeb.pages.login.loginSubmit;
|
||||
};
|
||||
|
||||
//Apply template
|
||||
ComunicWeb.common.page.getAndShowTemplate(targetElement, additionalData, "pages/login/loginPage.tpl", afterParsingTemplate, true);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Perform user login
|
||||
*
|
||||
* @return {Boolean} False if it fails
|
||||
*/
|
||||
loginSubmit: function(){
|
||||
alert("Login");
|
||||
|
||||
//var overlay = ComunicWeb.common.page.showTransparentWaitSplashScreen();
|
||||
},
|
||||
};
|
Reference in New Issue
Block a user