Skip to content

Software architecture design: classes

emi420 edited this page Feb 8, 2014 · 42 revisions

This document is a draft

Index

Public objects

window.m object

app function (options array)

data object

models array

bind function

context

window.Mootor object

ns function

addModule function

Public prototypes

App

getView function (id string)

addView function (id string, callback function)

removeView function (id string, callback function)

go function (string id)

history function

router function

settings object

getVersion string

setVersion string

View

setTitle function (title string)

getTitle function

onInit function (callback function)

onLoad function (callback function)

onBeforeLoad function (callback function)

onUnload function (callback function)

onBeforeUnload function (callback function)

ui function

UI

show function

Returns UI instance

hide function

Returns UI instance

UIView

view View

Type View instance

UIViewPanel

getLeft function

getTop function

getHeight function

getWidth function

setLeft function

setTop function

block function

getTransition function

setTransition function (transition string)

el HTMLElement

script string

css string

UIHeader

backButton object

title object

navigation object

UIFooter

navigation object

UILoading

style function (options object)

Router

create function (options array)

get function (url string)

getViewByUrl function (url string)

Route

url string

params array

view View


Description

Public objects

window.m object

app function (options array)

Create a new app.

Return App instance

data object

models array

Type array

bind function

Return DataBind object

context

 // Detect it is running in a browser
 app.context.browser
 // Detect it is running in on Cordova/PhoneGap
 app.context.cordova
 app.context.phonegap
 // detect device vendor
 app.context.device.vendor
 // define a method callback run on back button event
 app.context.device.onBackButton(function() {
 	app.go("index");
 });
 // define a method callback run on home button event
 app.context.device.onHomeButton(function() {
 	app.go("home");
 });
 // define a method callback run on menu button event
 app.context.device.onHomeButton(function() {
 	app.footer.show();
 });
 // get viewport's height
 app.context.viewport.height
 // get viewport's width
 app.context.viewport.width
 // get viewport's width
 app.context.device.onRotate(function() {
 	console.log(app.contect.device.orientation)
 });

window.Mootor object

ns function

Return object

addModule function

Return object

Public prototypes

App

getView function (id string)

Returns View instance

addView function (id string, callback function)

Returns View instance

// Define a method callback run after add a new view 
app.addView({
	id: "index",
	success: function(self) {
		console.log(self.title);
	}
});

removeView function (id string, callback function)

Returns Boolean

go function (string id)

Returns undefined

// Go to another view
$("#myLink").onTapEnd(function() {
	app.go("myView");
});
// Go to another view with parameters
$("#myLink").onTapEnd(function() {
	app.go("store", {
		storeid: 20
	});
});

history function

Returns array

router function

Returns Router instance

settings object

Type object

// Set a setting (debug mode) value for the App instance
app.settings.debug = true;
// Get a setting (debug mode) value for the App instance
if (app.settings.debug === true) {
	console.log("Debug mode.");
};

getVersion string

Return string

if (app.getVersion() === "1.0.0") {
	console.log("This is version 1.0.0")
};

setVersion string

Define a version number for the App instance Return string

app.setVersion("2");

View

setTitle function (title string)

Define a view's title Returns undefined

getTitle function

Returns string title

onInit function (callback function)

Returns undefined

onLoad function (callback function)

define a method callback run after load

 app.getView("index").onLoad(function() {
 	console.log("index view is load").
 });

Returns undefined

onBeforeLoad function (callback function)

define a method callback run before load

Returns undefined

onUnload function (callback function)

define a method callback unload

Returns undefined

onBeforeUnload function (callback function)

define a method callback run before unload

Returns undefined

ui function

Returns UIView instance

UI

All UI objects inherits this prototype

Show

Return boolean

Hide

Return boolean

UIView

All UIView objects inherits this prototype

view

Returns View instance

UIViewPanel

getLeft function

Get panel's horizontal scroll position

Returns int

getTop function

Get panel's vertical scroll position

Returns int

getHeight function

Get panel's height

Returns int

getWidth function

Get panel's width

Returns int

setLeft function

Returns ViewPanel instance

setTop function

Returns ViewPanel instance

block function

Returns ViewPanel instance

getTransition function

Returns string

setTransition function (transition string)

Define panel's transition

Returns ViewPanel instance

// app.getView("index").ui.setTransition("slide-left");

el HTMLElement

Type HTMLElement instance

// Get view's HTML
var html = app.getView("index").el.innerHTML;

script string

Type string

 // Load view's JavaScript from the view
 var script = app.getView("index").script;

css string

Type string

 // Load view's CSS from the view
 var css = app.getView("index").css;

UIHeader

backButton object

Returns object

title object

Returns object

navigation object

Returns object

UIFooter

navigation object

Returns object

UILoading

style function (options object)

Returns UILoading instance

Router

create function (options array)

return Route instance

// Define a regular expressio for route the URL to a view
app.router.create({
	url: "product/(.*)",
	view: "product"
});

get function (url string)

return Route instance

getViewByUrl function (url string)

return Route instance

// Load a view from an URL
var categoryView = app.router.getViewByUrl("/category");

Route

url string

params array

view View

Clone this wiki locally