This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Helper for opening / animating sidebar | |
*/ | |
$.openSidebar = function() { | |
if(isOpen) { | |
var animateRight = Ti.UI.createAnimation({ | |
left : 0, | |
curve : Ti.UI.ANIMATION_CURVE_EASE_OUT, | |
duration : 200 | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Override createWidget until widget styling is possible in Alloy | |
*/ | |
Alloy.createWidget = function(id, name, args) { | |
if ("undefined" != typeof name && null !== name && _.isObject(name) && !_.isString(name)) { | |
args = name; | |
name = DEFAULT_WIDGET; | |
} | |
var widget = new (require("alloy/widgets/" + id + "/controllers/" + (name || DEFAULT_WIDGET)))(args); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Custom swipe detection for table rows (since technically the "swipe" | |
// event doesn't apply to individual rows but rather the table. This way we | |
// don't have to assign a swipe event for each row. One event to manage | |
// them all is more performant. | |
var TOUCH_X = 0; | |
$.list.addEventListener("touchstart", function(e) { | |
TOUCH_X = e.x; | |
}); | |
$.list.addEventListener("touchend", function(e) { | |
if(e.x > (TOUCH_X + 44)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Handle Item Swipe | |
* @param {Object} _event | |
*/ | |
$.handleItemSwipe = function(_event) { | |
var row = _event.source; | |
var id = row.id; | |
var controls = Alloy.createController("rowControls"); | |
row.add(controls.wrapper); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Alloy.createWidget = function(id, name, args) { | |
Ti.Analytics.featureEvent("widget." + id, args); | |
return new (require("alloy/widgets/" + id + "/controllers/" + (name || "widget")))(args); | |
}; | |
Alloy.createController = function(name, args) { | |
Ti.Analytics.featureEvent("controller." + name, args); | |
return new (require("alloy/controllers/" + name))(args); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function MyModule() {} | |
module.exports = function(_params) { | |
// Could even do things in here for pre-init | |
return new MyModule(_params); | |
} | |
// Implementation: | |
var module = require("mymodule")(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function MyObject() { | |
var self = this; | |
self.someProperty = "test"; | |
self.table = Ti.UI.createTableView(); | |
self.someMethod = function() {}; | |
self.table.addEventListner("click", self.someMethod); | |
// etc. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function NavButton() { | |
var self = this; | |
self.button = Ti.UI.createButton(); | |
self.select = function() {}; | |
self.unselect = function() {}; | |
//etc. | |
} | |
module.exports = NavButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Javascript example patterns | |
*/ | |
/** | |
* Singleton Object | |
* Should be used for global, static objects. You should not place memory | |
* intensive items in here unless they are meant to be used throughout the application | |
* at anytime. If the item is meant to be reused or instantiated multiple times | |
* a singleton should not be used. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Alloy = require('alloy'), | |
Backbone = Alloy.Backbone, | |
_ = Alloy._, | |
A$ = Alloy.A; | |
function Controller() { | |
require('alloy/controllers/' + <%= parentController %>).apply(this, Array.prototype.slice.call(arguments)); | |
var $ = this; | |
var exports = {}; |