Files
CHOMPStation2/nano/js/nano_state.js
Mark Aherne 34516bded4 Layout update for NanoUI.
The layout HTML (which was mainly used for the title bar) is no longer hard coded in nanoui.dm.
Layouts are now dynamic and each consists of a template and stylesheet (CSS) file.
Multiple layouts can exist, they can be switched to using the set_layout_key proc. See the proc comments for more info.
Added "default" and "basic" layouts, "basic" has no title bar.
Moved image source assets (GIMP and Flash files) into a separate source folder so that they are not sent to the client.
2014-07-15 01:08:06 +01:00

71 lines
2.4 KiB
JavaScript

// This is the base state class, it is not to be used directly
function NanoStateClass() {
/*if (typeof this.key != 'string' || !this.key.length)
{
alert('ERROR: Tried to create a state with an invalid state key: ' + this.key);
return;
}
this.key = this.key.toLowerCase();
NanoStateManager.addState(this);*/
}
NanoStateClass.prototype.key = null;
NanoStateClass.prototype.isCurrent = function () {
return NanoStateManager.getCurrentState() == this;
};
NanoStateClass.prototype.onAdd = function (previousState) {
// Do not add code here, add it to the 'default' state (nano_state_defaut.js) or create a new state and override this function
NanoBaseCallbacks.addCallbacks();
NanoBaseHelpers.addHelpers();
};
NanoStateClass.prototype.onRemove = function (nextState) {
// Do not add code here, add it to the 'default' state (nano_state_defaut.js) or create a new state and override this function
NanoBaseCallbacks.removeCallbacks();
NanoBaseHelpers.removeHelpers();
};
NanoStateClass.prototype.onBeforeUpdate = function (data) {
// Do not add code here, add it to the 'default' state (nano_state_defaut.js) or create a new state and override this function
data = NanoStateManager.executeBeforeUpdateCallbacks(data);
return data; // Return data to continue, return false to prevent onUpdate and onAfterUpdate
};
NanoStateClass.prototype.onUpdate = function (data) {
// Do not add code here, add it to the 'default' state (nano_state_defaut.js) or create a new state and override this function
try
{
$("#uiLayout").html(NanoTemplate.parse('layout', data)); // render the 'mail' template to the #mainTemplate div
$("#uiContent").html(NanoTemplate.parse('main', data)); // render the 'mail' template to the #mainTemplate div
}
catch(error)
{
alert('ERROR: An error occurred while rendering the UI: ' + error.message);
return;
}
};
NanoStateClass.prototype.onAfterUpdate = function (data) {
// Do not add code here, add it to the 'default' state (nano_state_defaut.js) or create a new state and override this function
NanoStateManager.executeAfterUpdateCallbacks(data);
};
NanoStateClass.prototype.alertText = function (text) {
// Do not add code here, add it to the 'default' state (nano_state_defaut.js) or create a new state and override this function
alert(text);
};