/**
* @module common/view
* @description This is handles page transitions
* @requires common/model
* @requires common/services
*/
define([
"common/model",
"common/services"
],
function (model, services)
{
// ---------------------------------------------------------------
//
// GLOBAL VIEW
//
// ---------------------------------------------------------------
var View = function()
{
console.log(" * <view>");
var self = this;
// core objects
this.oModel = model;
this.oServices = services;
this.tweenPageTransition = -1;
this.ui = {
$main: $("main"),
fullContent: ".js-constrain"
};
this.init();
};
View.prototype =
{
// ______________________________________________________________
// init
/**
* init
* @description Initializes class
* @fires assignListeners()
* @memberOf module:common/view
* @instance
*/
init: function()
{
// init modal
window.oModal.init();
this.assignListeners();
},
// ______________________________________________________________
// assignListeners
/**
* assignListeners
* @description Assigns listeners to events used in this class.
* @memberOf module:common/view
* @instance
*/
assignListeners: function()
{
var self = this;
},
// --------------------------------------------------------------
// HELPERS
// --------------------------------------------------------------
// --------------------------------------------------------------
// EVENTS
// --------------------------------------------------------------
// ______________________________________________________________
// registerPage
/*
registerData = {
events: [
"MY_EVENT_STRING_1",
"MY_EVENT_STRING_2",
"MY_EVENT_STRING_3"
],
routes: {
index:
{
hashString : "default",
loadEvent : window.tEvent.eventStr.EVENT_LOAD_INDEX
},
testimonials:
{
hashString : "testimonials",
loadEvent : window.tEvent.eventStr.EVENT_LOAD_TESTIMONIALS
}
}
}
*/
/**
* registerPage
* @description Registers and manages pages through events
* @param {Object} registerData - Page event data
* @memberOf module:common/view
* @instance
*/
registerPage: function(registerData)
{
//debugger;
// register events
if (registerData.events){
for (var i = 0; i < registerData.events.length; i++){
window.tEvent.eventStr[registerData.events[i]] = registerData.events[i];
}
}
},
// ______________________________________________________________
// loadPageFrameTemplate
/**
* loadPageTemplate
* @description Loads and transitions to new page template
* @param {HTML} template - Page html to render
* @param {Object} pageData - Page data (more specifically pageData.event)
* @fires pageLoaded(pageData)
* @memberOf module:common/view
* @instance
*/
loadPageTemplate: function(template, pageData)
{
var fadeEle = this.ui.fullContent;
if ($("#configuration").attr("data-mode") === "iha"){
fadeEle = "main";
}
$(fadeEle).css("opacity", "0");
this.ui.$main.html(template);
$("body").attr("data-module-id", pageData.moduleId);
if (typeof this.tweenPageTransition === "object"){
this.tweenPageTransition.kill();
}
this.tweenPageTransition = TweenLite.to($(fadeEle), 1, {opacity: 1});
this.pageLoaded(pageData);
},
// ______________________________________________________________
// pageLoaded
/**
* pageLoaded
* @description Fires event to declare a new page is loaded
* @param {Object} pageData - Page data (more specifically pageData.event)
* @fires EVENT_PAGE_LOADED w/ pageData.event to id which event was called
* @memberOf module:common/view
* @instance
*/
pageLoaded: function(pageData)
{
window.tEvent.fire(window.tEvent.eventStr.EVENT_PAGE_LOADED, pageData.event);
}
};
var oView = new View();
return (oView);
});