Socket
Socket
Sign inDemoInstall

alloy

Package Overview
Dependencies
Maintainers
4
Versions
269
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alloy - npm Package Compare versions

Comparing version 0.2.0 to 0.2.2

docs/Alloy-bootstrap/assets/img/grid-18px.png

61

Alloy/builtins/animation.js

@@ -0,5 +1,20 @@

/**
* @class Alloy.builtins.animation
* A collection of useful animation utilities. To use the animation builtin library,
* all you need to do is require it with the `alloy` root directory in your
* `require` call. For example:
*
* var animation = require('alloy/animation');
* animation.crossFade(view1, view2, 500, callback);
*/
/**
* A collection of useful Animation utilities
* @method crossFade
* Transitions from one view to another using a cross-fade animation.
* @param {Titanium.UI.View} from View to fade out.
* @param {Titanium.UI.View} to View to fade in.
* @param {Number} duration Fade duration in milliseconds.
* @param {function()} callback Callback function, invoked after the fade completes.
*/
exports.crossFade = function (from, to, duration, callback) {

@@ -20,2 +35,9 @@ if (from)

/**
* @method fadeAndRemove
* Fades out a view then removes it from its parent view.
* @param {Titanium.UI.View} from View to remove.
* @param {Number} duration Fade duration in milliseconds.
* @param {Titanium.UI.View} container Parent container view.
*/
exports.fadeAndRemove = function (from, duration, container) {

@@ -33,2 +55,8 @@ if (from && container) {

/**
* @method fadeIn
* Fades in the specified view.
* @param {Titanium.UI.View} to View to fade in.
* @param {Number} duration Fade duration in milliseconds.
*/
exports.fadeIn = function (to, duration) {

@@ -43,2 +71,9 @@ if (to) {

/**
* @method popIn
* Makes the specified view appear using a "pop-in" animation, which combines a fade-in
* with a slight expanding and contracting animation, to call attention to the new view.
*
* @param {Titanium.UI.View} view View to animate.
*/
exports.popIn = function (view) {

@@ -66,2 +101,9 @@ if (!OS_IOS)

/**
* @method shake
* Creates a shake animation, moving the target view back and forth rapidly several times.
*
* @param {Titanium.UI.View} view View to animate.
* @param {Number} [delay] If specified, animation starts after `delay` milliseconds.
*/
exports.shake = function (view, delay) {

@@ -99,2 +141,10 @@ var shake1 = Ti.UI.createAnimation({

/**
* @method flash
* Flashes the target view twice, fading to partially transparent then back to
* fully-opaque.
*
* @param {Titanium.UI.View} view View to animate.
* @param {Number} [delay] If specified, animation starts after `delay` milliseconds.
*/
exports.flash = function (view, delay) {

@@ -128,2 +178,9 @@ var flash1 = Ti.UI.createAnimation({

/**
* @method chainAnimate
* Executes a series of animations on the target view.
*
* @param {Titanium.UI.View} view View to animate.
* @param {Titanium.UI.Animation[]} animations A set of animations to execute on `view` in sequence.
*/
exports.chainAnimate = function (view, animations) {

@@ -130,0 +187,0 @@ function step() {

@@ -88,3 +88,3 @@ var U = require('../../utils'),

exports.generateVarName = function(id) {
return '$.' + id;
return '$.__views.' + id;
}

@@ -188,3 +188,3 @@

code.content += state.code;
if (isTopLevel) { code.content += '$.addRoot(' + args.symbol + ');\n'; }
if (isTopLevel) { code.content += '$.addTopLevelView(' + args.symbol + ');\n'; }
if (args.events && args.events.length > 0) {

@@ -302,7 +302,44 @@ _.each(args.events, function(ev) {

exports.loadController = function(file) {
if (path.existsSync(file)) {
return fs.readFileSync(file,'utf8');
} else {
return '';
var code = {
parentControllerName: '',
controller: '',
exports: ''
};
if (!path.existsSync(file)) {
return code;
}
var contents = fs.readFileSync(file,'utf8');
function checkAssigment() {
var target = this[2];
var value = this[3];
var match = pro.gen_code(target).match(/^exports\.(.+)/);
if (match !== null) {
if (match[1] === 'baseController') {
code.parentControllerName = pro.gen_code(value);
}
code.exports += pro.gen_code(this) + ';\n';
return ['block'];
}
}
function do_stat() {
if (this[1][0] === 'assign') {
return checkAssigment.call(this[1]);
}
}
var ast = jsp.parse(contents);
var walker = pro.ast_walker();
var new_ast = walker.with_walkers({
"stat": do_stat
}, function(){
return walker.walk(ast);
});
code.controller = pro.gen_code(new_ast);
return code;
};

@@ -451,3 +488,3 @@

if (styleCollection.length === 0) {
// do nothing
code += '{}';
} else if (styleCollection.length === 1) {

@@ -454,0 +491,0 @@ if (styleCollection[0].condition) {

51

Alloy/commands/compile/index.js

@@ -170,3 +170,4 @@ var path = require('path'),

viewCode: '',
controllerCode: ''
controllerCode: '',
exportsCode: ''
},

@@ -214,44 +215,5 @@ state = { parent: {} },

}
// Process all <Include> tags
function processInclude(node) {
var ns = node.getAttribute('ns');
if (node.nodeName === 'Include' && (!ns || ns === 'Alloy')) {
if (U.XML.getElementsFromNodes(node.childNodes).length !== 0) {
U.die('<Include> elements may not have child elements.');
}
var src = node.getAttribute('src');
if (!src) {
U.die('<Include> element must have a "src" attribute');
} else if (node.attributes.length !== 1) {
U.die('<Include> must have only one attribute, and it must be "src"');
}
var fullpath = path.join(dir,CONST.DIR.VIEW,src) + '.' + CONST.FILE_EXT.VIEW;
if (!path.existsSync(fullpath)) {
U.die('<Include> "src" attribute path "' + src + '" does not exist');
}
var xml = fs.readFileSync(fullpath,'utf8');
var doc = new DOMParser().parseFromString(xml);
_.each(U.XML.getElementsFromNodes(doc.documentElement.childNodes), function(n) {
node.parentNode.appendChild(n);
});
node.parentNode.removeChild(node);
}
}
// need to loop in case <Include> tag contains other <Include> tags
var includeElems;
while ((includeElems = docRoot.getElementsByTagName('Include')).length > 0) {
_.each(includeElems, processInclude);
}
// make sure we have a Window, TabGroup, or SplitWindow
var rootChildren = U.XML.getElementsFromNodes(docRoot.childNodes);
// Don't process any further if "controller" is set to false. This view
// does not need a runtime controller.
if (docRoot.getAttribute('controller') === 'false') { return; }
// make sure we have a Window, TabGroup, or SplitWindow
if (viewName === 'index') {

@@ -277,3 +239,6 @@ var found = _.find(rootChildren, function(node) {

});
template.controllerCode += CU.loadController(files.CONTROLLER);
var cCode = CU.loadController(files.CONTROLLER);
template.parentController = (cCode.parentControllerName != '') ? cCode.parentControllerName : "'BaseController'";
template.controllerCode += cCode.controller;
template.exportsCode += cCode.exports;

@@ -280,0 +245,0 @@ // create generated controller module code for this view/controller or widget

@@ -259,3 +259,3 @@ /**

var newArgs = '(function(t) {' +
'return (_.isObject(t) && t.__iamalloy ? t.getRoot() : t) || t;' +
'return (_.isObject(t) && t.__iamalloy ? t.getView() : t) || t;' +
'})(' + argsStr + ')';

@@ -281,44 +281,2 @@ ast[2][0] = jsp.parse(newArgs)[1][0][1];

exports.dissectController = function(code) {
var ast;
try {
ast = jsp.parse(code);
} catch(e) {
U.die([
code,
e.stack,
'Failed to parse controller file'
]);
}
var w = pro.ast_walker();
var initFunction = 'function init(){}';
var postLayoutCode = '';
var new_ast = w.with_walkers({
"toplevel": function() {
for (var i = 0, l = this[1].length; i < l; i++) {
if (this[1][i][0] === 'defun' && this[1][i][1] === 'init') {
//delete this[1][i][1];
initFunction = pro.gen_code(this[1][i]);
delete this[1][i];
}
}
return this;
}
}, function() {
return w.walk(ast);
});
postLayoutCode = pro.gen_code(new_ast);
return {
init: initFunction,
post: postLayoutCode
}
// console.log('----------------------------------------');
// console.log(require('util').inspect(ast, false, null));
// console.log('-');
// console.log(require('util').inspect(new_ast, false, null));
}
function optimize(ast, defines, fn)

@@ -335,3 +293,2 @@ {

"var" :processVar
//"call": processCall
}

@@ -338,0 +295,0 @@ , function()

@@ -25,2 +25,3 @@ var path = require('path'),

// determine which Alloy method to use
var extraArgs = '';
switch(type) {

@@ -32,2 +33,3 @@ case 'view':

method = 'getWidget';
extraArgs = "'widget',";
break;

@@ -41,4 +43,9 @@ default:

// Remove <Require>-specific attributes from createArgs
args.createArgs = _.reject(args.createArgs, function(v,k) {
return _.contains(['type','src'], k);
});
// Generate runtime code
code += args.symbol + " = new (Alloy." + method + "('" + src + "'))(" + CU.generateStyleParams(
code += args.symbol + " = Alloy." + method + "('" + src + "'," + extraArgs + CU.generateStyleParams(
state.styles,

@@ -57,3 +64,3 @@ args.classes,

node: node,
symbol: args.symbol + '.getRoots()'
symbol: args.symbol + '.getView()'
},

@@ -60,0 +67,0 @@ styles: state.styles,

@@ -98,3 +98,3 @@ var path = require('path'),

README = fs.readFileSync(path.join(templateDir, 'README'),'utf8'),
projectPath, appPath, tmpPath, alloyJmkTemplate, cfg;
projectPath, appPath, resourcesPath, tmpPath, alloyJmkTemplate, cfg;

@@ -109,2 +109,3 @@ // validate args

appPath = path.join(projectPath,'app');
resourcesPath = path.join(projectPath,'Resources');
if (path.existsSync(appPath)) {

@@ -136,3 +137,3 @@ if (!program.force) {

// TODO: remove this once the this is merged: https://github.com/appcelerator/titanium_mobile/pull/2610
// TODO: remove this once this is merged: https://github.com/appcelerator/titanium_mobile/pull/2610
U.installModule(projectPath, {

@@ -154,2 +155,14 @@ id: 'ti.physicalSizeCategory',

installPlugin(projectPath);
// copy original android, iphone, and mobileweb directories to assets
_.each(['android','iphone','mobileweb'], function(dir) {
var rDir = path.join(resourcesPath,dir);
if (!path.existsSync(rDir)) {
return;
}
var p = path.join(appPath,'assets',dir);
wrench.mkdirSyncRecursive(p, 0777);
wrench.copyDirSyncRecursive(path.join(resourcesPath,dir), p);
});

@@ -156,0 +169,0 @@ logger.info('Generated new project at: ' + appPath);

@@ -0,1 +1,2 @@

var _ = require('alloy/underscore')._,

@@ -105,16 +106,16 @@ Backbone = require('alloy/backbone'),

exports.getWidget = function(id, name) {
return require('alloy/widgets/' + id + '/controllers/' + (name || 'widget'));
exports.getWidget = function(id, name, args) {
return new (require('alloy/widgets/' + id + '/controllers/' + (name || 'widget')))(args);
}
exports.getController = function(name) {
return require('alloy/controllers/' + name);
exports.getController = function(name, args) {
return new (require('alloy/controllers/' + name))(args);
}
exports.getModel = function(name) {
return require('alloy/models/' + STR.ucfirst(name)).Model;
exports.getModel = function(name, args) {
return new (require('alloy/models/' + STR.ucfirst(name)).Model)(args);
}
exports.getCollection = function(name) {
return require('alloy/models/' + STR.ucfirst(name)).Collection;
exports.getCollection = function(name, args) {
return new (require('alloy/models/' + STR.ucfirst(name)).Collection)(args);
}

@@ -121,0 +122,0 @@

@@ -5,56 +5,9 @@ var Alloy = require('alloy'),

var Controller = function(args, thisRef) {
// collection of top-level elements
this.__roots = [];
var Controller = function() {
var roots = [];
// If this instance has a parent, use an instance of the parent
// as the base for this instance. This allows us to execute the
// lifecycle functions of the parent then those of the current
// instance, rather than just overwriting the parent's lifecycle.
if (this.__parent) {
var instance = new this.__parent.prototype.constructor(args, this);
_.defaults(this, instance);
}
// Execute the sequence of lifecycle functions
if (this.__init) { this.__init(); }
if (this.onInit) { this.onInit.call(this, args); }
if (this.__layout) { this.__layout(this); }
if (this.onReady) { this.onReady.call(this, args); }
// If a reference to a subclass has been passed in, pass it to
// __final() so that the $ variable will reference the subclass,
// not the parent.
if (thisRef) {
if (this.__final) { this.__final(thisRef); }
}
}
// Controller.extend = Backbone.Model.extend;
Controller.extend = function(protoOpts, classOpts, skipParent) {
// don't change the reference to the parent "class". This is
// done in the component.js. It allows extension of a class
// definition without changing the inheritance chain.
if (!skipParent) {
protoOpts.__parent = this;
}
// Levergae Backbone's extend() method to give Alloy controllers
// inheritance.
return Backbone.Model.extend.call(this, protoOpts, classOpts);
}
_.extend(
Controller.prototype,
// Give Alloy controllers Backbone eventing (on, off, trigger)
Backbone.Events,
// Set other properties commons to all controllers.
{
// Identifies Alloy controllers
__iamalloy: true,
// Establishing this controllers position in a view hierarchy
this.__iamalloy = true;
_.extend(this, Backbone.Events, {
__views: {},
setParent: function(parent) {
// If it's an Alloy controller, use its parent. Otherwise,
// use the given parent.
if (parent.__iamalloy) {

@@ -66,30 +19,27 @@ this.parent = parent.parent;

// Iterate through all top-level elements. If one of these
// elements is an Alloy component itself, call setParent
// again recursively. If not, add the element to the parent.
for (var i = 0, l = this.__roots.length; i < l; i++) {
if (this.__roots[i].__iamalloy) {
this.__roots[i].setParent(this.parent);
for (var i = 0, l = roots.length; i < l; i++) {
if (roots[i].__iamalloy) {
roots[i].setParent(this.parent);
} else {
this.parent.add(this.__roots[i]);
this.parent.add(roots[i]);
}
}
},
// Add a top-level element to the controller
addRoot: function(view) {
this.__roots.push(view);
addTopLevelView: function(view) {
roots.push(view);
},
// Return an array of all top-level controllers
getRoots: function() {
return this.__roots;
getTopLevelViews: function() {
return roots;
},
// Return the first top-level element
getRoot: function(index) {
return this.__roots[index || 0];
getView: function(id) {
if (typeof id === 'undefined' || id === null) {
return roots[0];
}
return this.__views[id];
},
getViews: function() {
return this.__views;
}
}
);
});
}
module.exports = Controller;

@@ -135,2 +135,11 @@ /**

var sql = 'SELECT * FROM '+table;
if(opts.byId) {
sql = sql+" WHERE id = '"+opts.byId.id+"'";
} else if(opts.filter) {
var filter = model.filterquery(opts, '');
sql = sql+" WHERE " + filter;
}
var rs = db.execute(sql);

@@ -144,3 +153,2 @@ while(rs.isValidRow())

});
var m = new model.config.Model(o);

@@ -242,4 +250,38 @@ model.models.push(m);

Model = Model || {};
Model.prototype.config.Model = Model; // needed for fetch operations to initialize the collection from persistent store
//inspired by postegresql adapter backbonejs
Model.prototype.filterquery = function(options, prefix, cb){
var self = this;
var conds = [];
if (!prefix) prefix = '';
// Process the filter parameter to further filter the select
if('filter' in options){
if(options.filter.conditions instanceof Array){
conds = options.filter.conditions;
}else if(options.filter.conditions instanceof Object){
conds = _.keys(options.filter.conditions).map(function(i){ return i + ' = ' + self.quote(i, options.filter.conditions[i]) });
}
}
if(conds.length == 0) return '';
return prefix + conds.join(' '+options.filter.operator+' ');
};
Model.prototype.quote = function(column_name, value){
var self = this;
var col_type = null;
_.map(self.config.columns, function(type,col){
if(col === column_name) { col_type = type; }
});
if(col_type === 'text' || col_type === 'string') return "'" + value + "'";
return value;
};
Alloy.Backbone.Collection.prototype.config = Model.prototype.config;
Alloy.Backbone.Collection.prototype.quote = Model.prototype.quote;
Alloy.Backbone.Collection.prototype.filterquery = Model.prototype.filterquery;

@@ -250,1 +292,4 @@ Migrate(Model.migrations);

};

@@ -10,2 +10,2 @@ /**

Alloy.CFG = require('alloy/CFG');
new (Alloy.getController('index'))();
Alloy.getController('index');
var Alloy = require('alloy'),
Backbone = Alloy.Backbone,
_ = Alloy._,
A$ = Alloy.A,
$ = {};
A$ = Alloy.A;
<%= controllerCode %>
function Controller() {
require('alloy/controllers/' + <%= parentController %>).call(this);
var $ = this;
var exports = {};
<%= exportsCode %>
var __obj = _.isFunction(module.exports.extend) ? module.exports : Alloy.getController('BaseController');
module.exports = __obj.extend({
__init: function() {
$ = this;
},
__layout: function($) {
<%= viewCode %>
},
__final: function(thisRef) {
$ = thisRef || $;
}
}, {}, true);
<%= viewCode %>
// make all IDed elements in $.__views available right on the $ in a
// controller's internal code. Externally the IDed elements will
// be accessed with getView().
_.extend($, $.__views);
<%= controllerCode %>
// Extend the $ instance with all functions and properties
// defined on the exports object.
_.extend($, exports);
}
module.exports = Controller;

@@ -1,5 +0,1 @@

function onReady(args) {
$.index.open();
}
function doClick(e) {

@@ -9,4 +5,2 @@ alert($.label.text);

module.exports = Alloy.getController('BaseController').extend({
onReady: onReady
});
$.index.open();

@@ -80,3 +80,3 @@ // The island of misfit toys... for functions

node.setAttribute('version',opts.version || '1.0');
var text = doc.createTextNode(opts.id);
var text = doc.createTextNode(opts.id.toLowerCase());
node.appendChild(text);

@@ -127,16 +127,22 @@

var dirs = [];
var widgetPath = path.join(outputPath,'app','widgets');
if (path.existsSync(widgetPath)) {
var wFiles = fs.readdirSync(widgetPath);
for (var i = 0; i < wFiles.length; i++) {
var wDir = path.join(widgetPath,wFiles[i]);
if (fs.statSync(wDir).isDirectory() &&
_.indexOf(fs.readdirSync(wDir), 'widget.json') !== -1) {
dirs.push({
dir: wDir,
manifest: JSON.parse(fs.readFileSync(path.join(wDir,'widget.json'),'utf8'))
});
}
var widgetPaths = [];
widgetPaths.push(path.join(outputPath,'app','widgets'));
widgetPaths.push(path.join(__dirname,'..','widgets'));
_.each(widgetPaths, function(widgetPath) {
if (path.existsSync(widgetPath)) {
var wFiles = fs.readdirSync(widgetPath);
for (var i = 0; i < wFiles.length; i++) {
var wDir = path.join(widgetPath,wFiles[i]);
if (fs.statSync(wDir).isDirectory() &&
_.indexOf(fs.readdirSync(wDir), 'widget.json') !== -1) {
dirs.push({
dir: wDir,
manifest: JSON.parse(fs.readFileSync(path.join(wDir,'widget.json'),'utf8'))
});
}
}
}
}
});
return dirs;

@@ -143,0 +149,0 @@ };

@@ -16,3 +16,3 @@ {

],
"version": "0.2.0",
"version": "0.2.2",
"author": "Appcelerator, Inc. <info@appcelerator.com>",

@@ -19,0 +19,0 @@ "maintainers": [

@@ -9,14 +9,9 @@ // These "builtin" requires will be detected by the alloy compile process.

function onReady(args) {
$.shake.on('click', function(e) {
animation.shake($.mover);
});
$.trim.on('click', function(e) {
$.label.text = string.trim($.label.text);
});
$.index.open();
}
$.shake.on('click', function(e) {
animation.shake($.mover);
});
$.trim.on('click', function(e) {
$.label.text = string.trim($.label.text);
});
module.exports = Alloy.getController('BaseController').extend({
onReady: onReady
});
$.index.open();

@@ -1,7 +0,1 @@

function onReady(args) {
Ti.API.info('bottom controller is executing');
}
module.exports = Alloy.getController('BaseController').extend({
onReady: onReady
});
Ti.API.info('bottom controller is executing');

@@ -1,7 +0,1 @@

function onReady(args) {
$.index.open();
}
module.exports = Alloy.getController('BaseController').extend({
onReady: onReady
});
$.index.open();

@@ -1,9 +0,3 @@

function onReady(args) {
$.bottom.b.addEventListener('click',function(){
$.middle.t.text = "You clicked me";
});
}
module.exports = Alloy.getController('BaseController').extend({
onReady: onReady
$.bottom.getView('b').addEventListener('click',function(){
$.middle.getView('t').text = "You clicked me";
});

@@ -1,7 +0,1 @@

function onReady(args) {
$.win.open();
}
module.exports = Alloy.getController('BaseController').extend({
onReady: onReady
});
$.win.open();

@@ -1,56 +0,50 @@

function onReady(args) {
// Function to keep a Ti.TableView in sync with Backbone Model.
$.table.updateContent = function(collection) {
var rows = [];
for (var i = 0; i < collection.length; i++) {
var model = collection.at(i).attributes, title = "";
for (var key in model) { if (key !== "id") { title += model[key] + " " }}
rows.push(Ti.UI.createTableViewRow({"title":title}));
}
this.setData(rows);
};
// Function to keep a Ti.TableView in sync with Backbone Model.
$.table.updateContent = function(collection) {
var rows = [];
for (var i = 0; i < collection.length; i++) {
var model = collection.at(i).attributes, title = "";
for (var key in model) { if (key !== "id") { title += model[key] + " " }}
rows.push(Ti.UI.createTableViewRow({"title":title}));
}
this.setData(rows);
};
// Now let's create a Backbone collection that will hold our models,
// the classes that represent our model have been generated automatically
// as Alloy components. Use new on the component to create the model or
// collection.
var books = new (Alloy.getCollection('Book'));
// Now let's create a Backbone collection that will hold our models,
// the classes that represent our model have been generated automatically
// as Alloy components. Use new on the component to create the model or
// collection.
var books = Alloy.getCollection('Book');
// You can bind any Backbone event to models or collections but fetch is convenient because
// fetch occurs when the persistent store is sync'd to the local Backbone server.
books.bind("fetch", function() { $.table.updateContent(books); });
// You can bind any Backbone event to models or collections but fetch is convenient because
// fetch occurs when the persistent store is sync'd to the local Backbone server.
books.bind("fetch", function() { $.table.updateContent(books); });
// Fetch will load models from persistent starage, sync'ing Backbone and persistent store.
books.fetch();
// Fetch will load models from persistent starage, sync'ing Backbone and persistent store.
books.fetch();
// Now we can add items to the model.
var book = new (Alloy.getModel('Book'))({book:"Jungle Book", author:"Kipling"});
books.add(book);
// Now we can add items to the model.
var book = Alloy.getModel('Book', {book:"Jungle Book", author:"Kipling"});
books.add(book);
// Use Backbone shortcut to create a model and add to collection in single step. Does the same
// thing as the creating a new model and then adding it to the collection.
books.add({book:"War and Peace", author:"Tolstoy"});
// Use Backbone shortcut to create a model and add to collection in single step. Does the same
// thing as the creating a new model and then adding it to the collection.
books.add({book:"War and Peace", author:"Tolstoy"});
// Add will add models to local Backbone server but save triggers the CRUD create opperation
// causing the model to get added to the persistent store. During create an id is added to the
// model signaling that the model has been persisted and no longer in the new state.
books.forEach(function(model){ model.save();});
// Add will add models to local Backbone server but save triggers the CRUD create opperation
// causing the model to get added to the persistent store. During create an id is added to the
// model signaling that the model has been persisted and no longer in the new state.
books.forEach(function(model){ model.save();});
// UPDATE - update the model save here triggers the CRUD update opperation
book.save({author:"R Kipling"});
// UPDATE - update the model save here triggers the CRUD update opperation
book.save({author:"R Kipling"});
// Okay time to show the results. Remember this sync's local Backbone server with persitent store.
books.fetch();
// Okay time to show the results. Remember this sync's local Backbone server with persitent store.
books.fetch();
// DELETE - destroy triggers the CRUD delete opperation
for(i=books.length-1; i>=0; i--) {
var model = books.at(i);
model.destroy();
};
// DELETE - destroy triggers the CRUD delete opperation
for(i=books.length-1; i>=0; i--) {
var model = books.at(i);
model.destroy();
};
$.index.open();
}
module.exports = Alloy.getController('BaseController').extend({
onReady: onReady
});
$.index.open();

@@ -1,4 +0,2 @@

function onReady(args) {
$.index.open();
}
$.index.open();

@@ -8,5 +6,1 @@ function doClick(e) {

}
module.exports = Alloy.getController('BaseController').extend({
onReady: onReady
});

@@ -1,12 +0,6 @@

function onReady(args) {
var foo = require("foo"),
bar = require("vendor/bar");
var foo = require("foo"),
bar = require("vendor/bar");
Ti.API.info(bar.helloize(foo.generate()));
Ti.API.info(bar.helloize(foo.generate()));
$.index.open();
}
module.exports = Alloy.getController('BaseController').extend({
onReady: onReady
});
$.index.open();

@@ -1,7 +0,1 @@

function onReady(args) {
$.index.open();
}
module.exports = Alloy.getController('BaseController').extend({
onReady: onReady
});
$.index.open();

@@ -1,34 +0,28 @@

var items = new (Alloy.getCollection('collectionTab')),
var items = Alloy.getCollection('collectionTab'),
rowControllers = [];
function onReady(args) {
// update the row and save the model when the score changes
items.on('change:score', function(model) {
if (model) {
var row = _.find(rowControllers, function(r) {
return r.id === model.id;
});
if (row) {
row.score.text = model.get('score');
model.save();
}
// update the row and save the model when the score changes
items.on('change:score', function(model) {
if (model) {
var row = _.find(rowControllers, function(r) {
return r.id === model.id;
});
if (row) {
row.score.text = model.get('score');
model.save();
}
});
}
});
// reset the table whenever a model is added or destroyed
// completely. Also reset whenever the collection is reset.
// Save the model changes if necessary.
items.on('add destroy reset', function(model) {
resetTableData();
if (model && model.save) { model.save(); }
});
// reset the table whenever a model is added or destroyed
// completely. Also reset whenever the collection is reset.
// Save the model changes if necessary.
items.on('add destroy reset', function(model) {
resetTableData();
if (model && model.save) { model.save(); }
});
// fetch collection from Ti.App.Properties adapter
items.fetch();
}
// fetch collection from Ti.App.Properties adapter
items.fetch();
module.exports = Alloy.getController('BaseController').extend({
onReady: onReady
});
//////////////////////////////////////

@@ -42,3 +36,3 @@ ////////// private function //////////

_.each(items.toJSON(), function(i) {
rowControllers.push(new (Alloy.getController('collection/row'))({
rowControllers.push(Alloy.getController('collection/row', {
id: i.id,

@@ -53,3 +47,3 @@ name: i.name,

$.table.setData(_.sortBy(
_.map(rowControllers, function(r) { return r.getRoot(); }),
_.map(rowControllers, function(r) { return r.getView(); }),
function(r) { return r.id; }

@@ -56,0 +50,0 @@ ));

@@ -1,10 +0,4 @@

function onReady(args) {
args || (args = {});
$.id = $.row.id = args.id;
$.name.text = args.name || '<no name>';
$.score.text = args.score || 0;
}
module.exports = Alloy.getController('BaseController').extend({
onReady: onReady
});
var args = arguments[0] || {};
$.id = $.row.id = args.id;
$.name.text = args.name || '<no name>';
$.score.text = args.score || 0;

@@ -1,7 +0,1 @@

function onReady(args) {
$.index.open();
}
module.exports = Alloy.getController('BaseController').extend({
onReady: onReady
});
$.index.open();

@@ -1,23 +0,19 @@

var app = new (Alloy.getModel('modelTab'));
var app = Alloy.getModel('modelTab');
function onReady(args) {
// persist all changes
app.on('change', function() { app.save(); });
// persist all changes
app.on('change', function() { app.save(); });
// Change label when 'count' changes on model
app.on('change:count', function(model) {
$.label.text = 'model: ' + JSON.stringify(model.attributes);
});
// Change label when 'count' changes on model
app.on('change:count', function(model) {
$.label.text = 'model: ' + JSON.stringify(model.attributes);
});
// fetch model from Ti.App.Properties adapter
app.fetch();
}
// fetch model from Ti.App.Properties adapter
app.fetch();
////////////////////////////////////
////////// event handlers //////////
////////////////////////////////////
function create(e) { app.save(app.defaults); }
function destroy(e) { app.destroy(); }
function increment(e) { app.set({'count':app.get('count')+1}); }
module.exports = Alloy.getController('BaseController').extend({
onReady: onReady
});
function increment(e) { app.set({'count':app.get('count')+1}); }

@@ -1,13 +0,6 @@

function onReady() {
function showAlert() {
alert("Click! Shouldn't do it again though");
$.b.off("click",showAlert);
}
$.b.on("click",showAlert);
$.index.open();
function showAlert() {
alert("Click! Shouldn't do it again though");
$.b.off("click",showAlert);
}
module.exports = Alloy.getController('BaseController').extend({
onReady: onReady
});
$.b.on("click",showAlert);
$.index.open();

@@ -1,7 +0,1 @@

function onReady(args) {
$.index.open();
}
module.exports = Alloy.getController('BaseController').extend({
onReady: onReady
});
$.index.open();

@@ -1,56 +0,50 @@

function onReady(args) {
// Function to keep a Ti.TableView in sync with Backbone Model.
$.table.updateContent = function(collection) {
var rows = [];
for (var i = 0; i < collection.length; i++) {
var model = collection.at(i).attributes, title = "";
for (var key in model) { if (key !== "id") { title += model[key] + " " }}
rows.push(Ti.UI.createTableViewRow({"title":title}));
}
this.setData(rows);
};
// Function to keep a Ti.TableView in sync with Backbone Model.
$.table.updateContent = function(collection) {
var rows = [];
for (var i = 0; i < collection.length; i++) {
var model = collection.at(i).attributes, title = "";
for (var key in model) { if (key !== "id") { title += model[key] + " " }}
rows.push(Ti.UI.createTableViewRow({"title":title}));
}
this.setData(rows);
};
// Now let's create a Backbone collection that will hold our models,
// the classes that represent our model have been generated automatically
// as Alloy components. Use new on the component to create the model or
// collection.
var books = new (Alloy.getCollection('Book'));
// Now let's create a Backbone collection that will hold our models,
// the classes that represent our model have been generated automatically
// as Alloy components. Use new on the component to create the model or
// collection.
var books = Alloy.getCollection('Book');
// You can bind any Backbone event to models or collections but fetch is convenient because
// fetch occurs when the persistent store is sync'd to the local Backbone server.
books.bind("fetch", function() { $.table.updateContent(books); });
// You can bind any Backbone event to models or collections but fetch is convenient because
// fetch occurs when the persistent store is sync'd to the local Backbone server.
books.bind("fetch", function() { $.table.updateContent(books); });
// Fetch will load models from persistent starage, sync'ing Backbone and persistent store.
books.fetch();
// Fetch will load models from persistent starage, sync'ing Backbone and persistent store.
books.fetch();
// Now we can add items to the model.
var book = new (Alloy.getModel('Book'))({book:"Jungle Book", author:"Kipling"});
books.add(book);
// Now we can add items to the model.
var book = Alloy.getModel('Book', {book:"Jungle Book", author:"Kipling"});
books.add(book);
// Use Backbone shortcut to create a model and add to collection in single step. Does the same
// thing as the creating a new model and then adding it to the collection.
books.add({book:"War and Peace", author:"Tolstoy"});
// Use Backbone shortcut to create a model and add to collection in single step. Does the same
// thing as the creating a new model and then adding it to the collection.
books.add({book:"War and Peace", author:"Tolstoy"});
// Add will add models to local Backbone server but save triggers the CRUD create opperation
// causing the model to get added to the persistent store. During create an id is added to the
// model signaling that the model has been persisted and no longer in the new state.
books.forEach(function(model){ model.save();});
// Add will add models to local Backbone server but save triggers the CRUD create opperation
// causing the model to get added to the persistent store. During create an id is added to the
// model signaling that the model has been persisted and no longer in the new state.
books.forEach(function(model){ model.save();});
// UPDATE - update the model save here triggers the CRUD update opperation
book.save({author:"R Kipling"});
// UPDATE - update the model save here triggers the CRUD update opperation
book.save({author:"R Kipling"});
// Okay time to show the results. Remember this sync's local Backbone server with persitent store.
books.fetch();
// Okay time to show the results. Remember this sync's local Backbone server with persitent store.
books.fetch();
// DELETE - destroy triggers the CRUD delete opperation
for(i=books.length-1; i>=0; i--) {
var model = books.at(i);
model.destroy();
};
// DELETE - destroy triggers the CRUD delete opperation
for(i=books.length-1; i>=0; i--) {
var model = books.at(i);
model.destroy();
};
$.index.open();
}
module.exports = Alloy.getController('BaseController').extend({
onReady: onReady
});
$.index.open();

@@ -1,7 +0,1 @@

function onReady(args) {
$.index.open();
}
module.exports = Alloy.getController('BaseController').extend({
onReady: onReady
});
$.index.open();

@@ -1,25 +0,19 @@

function onReady(args) {
$.sfb.setHandlers({
success: function(books) {
var data = [];
_.each(books, function(book) {
var row = new (Alloy.getController('row'))({
title: book.title,
authors: book.authors,
image: book.image
}).getRoot();
data.push(row);
});
$.table.setData(data);
}
// You can override error handling with the 'error' property
// error: function(e) {
// alert('ERROR: ' + e.error);
// }
});
$.win.open();
}
module.exports = Alloy.getController('BaseController').extend({
onReady: onReady
$.sfb.setHandlers({
success: function(books) {
var data = [];
_.each(books, function(book) {
var row = Alloy.getController('row', {
title: book.title,
authors: book.authors,
image: book.image
}).getView();
data.push(row);
});
$.table.setData(data);
}
// You can override error handling with the 'error' property
// error: function(e) {
// alert('ERROR: ' + e.error);
// }
});
$.win.open();

@@ -1,10 +0,4 @@

function onReady(args) {
args || (args = {});
$.thumbnail.image = args.image;
$.title.text = args.title || '';
$.authors.text = args.authors || '';
}
module.exports = Alloy.getController('BaseController').extend({
onReady: onReady
});
var args = arguments[0] || {};
$.thumbnail.image = args.image;
$.title.text = args.title || '';
$.authors.text = args.authors || '';

@@ -1,19 +0,14 @@

function onReady(args) {
args || (args = {});
var args = arguments[0] || {};
for (var k in args) {
$.loading[k] = args[k];
}
if (Ti.Platform.osname === 'mobileweb') {
$.loading.duration = 100;
}
$.loading.start();
for (var k in args) {
$.loading[k] = args[k];
}
module.exports = Alloy.getController('BaseController').extend({
onReady: onReady,
setOpacity: function(opacity) {
$.loading.opacity = opacity;
}
});
if (Ti.Platform.osname === 'mobileweb') {
$.loading.duration = 100;
}
$.loading.start();
exports.setOpacity = function(opacity) {
$.loading.opacity = opacity;
};

@@ -9,18 +9,19 @@ var API_URL = 'https://www.googleapis.com/books/v1/volumes?q=';

function onReady(args) {
// react to changes in the model state
model.on('change:loading', function(m) {
if (m.get('loading')) {
$.searchView.touchEnabled = false;
$.search.opacity = 0;
$.loading.setOpacity(1.0);
} else {
$.loading.setOpacity(0);
$.search.opacity = 1;
$.searchView.touchEnabled = true;
}
});
}
// react to changes in the model state
model.on('change:loading', function(m) {
if (m.get('loading')) {
$.searchView.touchEnabled = false;
$.search.opacity = 0;
$.loading.setOpacity(1.0);
} else {
$.loading.setOpacity(0);
$.search.opacity = 1;
$.searchView.touchEnabled = true;
}
});
function setHandlers(args) {
////////////////////////////////////
///////// public functions /////////
////////////////////////////////////
exports.setHandlers = function(args) {
_.each(HANDLERS, function(h) {

@@ -31,9 +32,4 @@ if (args[h]) {

});
}
}
module.exports = Alloy.getController('BaseController').extend({
onReady: onReady,
setHandlers: setHandlers
});
///////////////////////////////////////

@@ -40,0 +36,0 @@ ////////// private functions //////////

@@ -1,8 +0,2 @@

function onReady(args) {
$.w.setText("Press a button to see something happen");
$.index.open();
}
module.exports = Alloy.getController('BaseController').extend({
onReady: onReady
});
$.w.setText("Press a button to see something happen");
$.index.open();

@@ -1,26 +0,22 @@

function onReady(args) {
// add listeners for widget buttons
$.a.addEventListener('click',function(){
$.t.text = "You clicked A";
});
// add listeners for widget buttons
$.a.addEventListener('click',function(){
$.t.text = "You clicked A";
});
$.b.addEventListener('click',function(){
$.t.text = "You clicked B";
});
$.b.addEventListener('click',function(){
$.t.text = "You clicked B";
});
$.c.addEventListener('click',function(){
$.t.text = "You clicked C";
});
}
$.c.addEventListener('click',function(){
$.t.text = "You clicked C";
});
module.exports = Alloy.getController('BaseController').extend({
onReady: onReady,
// anything defined against exports will be exposed as methods/properties
// on any instance of the widget
exports.setText = function(text){
$.t.text = text;
};
// custom functions for public interface
setText: function(text) {
$.t.text = text;
},
getText: function() {
return $.t.text;
}
});
exports.getText = function() {
return $.t.text;
}
{
"name": "Ti",
"description": "The mobile web platform for rapidly developing applications",
"version": "2.1.0",
"version": "2.1.1",
"keywords": ["Titanium", "Ti", "mobile", "JavaScript"],

@@ -25,6 +25,6 @@ "licenses": [

"titanium": {
"timestamp": "06/28/12 12:16",
"githash": "6e3cab6",
"version": "2.1.0"
"timestamp": "07/27/12 14:01",
"githash": "0fd84a2",
"version": "2.1.1"
}
}

@@ -69,3 +69,3 @@ define(["Ti/_", "Ti/_/dom", "Ti/_/has", "Ti/_/lang", "Ti/App", "Ti/Platform"],

ts: evt.ts,
data: /(Array|Object)/.test(is(evt.data)) ? JSON.stringify(evt.data) : evt.data
data: evt.data
}));

@@ -72,0 +72,0 @@

@@ -228,3 +228,3 @@ define(

_insertAt: function(view,index, hidden) {
_insertAt: function(view, index, hidden) {
var children = this._children;

@@ -634,4 +634,4 @@ if (index > children.length || index < 0) {

nodeStyle.backgroundRepeat !== tmp && (nodeStyle.backgroundRepeat = tmp);
tmp = repeat ? "auto" : "100% 100%";
nodeStyle.backgroundSize !== tmp && (nodeStyle.backgroundSize = tmp);
tmp = repeat ? "auto" : "100%";
nodeStyle.backgroundSize.replace(/(100%) 100%/, "$1") !== tmp && (nodeStyle.backgroundSize = tmp);
}

@@ -638,0 +638,0 @@ }

@@ -37,4 +37,5 @@ define(["Ti/_/browser", "Ti/_/declare", "Ti/UI/View", "Ti/_/lang", "Ti/_/dom", "Ti/_/style", "Ti/UI", "Ti/_/event"],

// Controls the friction curve for elastic dragging. The higher the value, the sooner drag starts to kick in.
elasticityDrag = 30;
// Controls the friction curve for elastic dragging. The higher the value, the sooner drag starts to kick in.
// Must be greater than or equal to elasticityLimit otherwise the curve has a slope greater than 1, which is bad.
elasticityDrag = 100;

@@ -90,99 +91,103 @@ return declare("Ti._.UI.KineticScrollView", View, {

// Listen for postlayouts and update the translation
on(self, "postlayout", function() {
minTranslationX = self._minTranslationX = Math.min(0, self._measuredWidth - self._borderLeftWidth - self._borderRightWidth - self._contentContainer._measuredWidth);
minTranslationY = self._minTranslationY = Math.min(0, self._measuredHeight - self._borderTopWidth - self._borderBottomWidth - self._contentContainer._measuredHeight);
});
on(self, "draggingstart", function(e) {
if (this.scrollingEnabled) {
// Initialize the velocity calculations
velocityX = void 0;
velocityY = void 0;
startTranslationX = self._currentTranslationX;
startTranslationY = self._currentTranslationY;
numSamples = 0;
previousTime = (new Date).getTime();
// Initialize the velocity calculations
velocityX = void 0;
velocityY = void 0;
startTranslationX = self._currentTranslationX;
startTranslationY = self._currentTranslationY;
numSamples = 0;
previousTime = (new Date).getTime();
// Start the scroll bars
var width = self._measuredWidth,
height = self._measuredHeight,
contentWidth = contentContainer._measuredWidth,
contentHeight = contentContainer._measuredHeight;
self._startScrollBars({
x: -self._currentTranslationX / (contentWidth - width),
y: -self._currentTranslationY / (contentHeight - height)
},
{
x: width / contentWidth,
y: height / contentHeight
});
minTranslationX = self._minTranslationX = Math.min(0, self._measuredWidth - self._borderLeftWidth - self._borderRightWidth - self._contentContainer._measuredWidth);
minTranslationY = self._minTranslationY = Math.min(0, self._measuredHeight - self._borderTopWidth - self._borderBottomWidth - self._contentContainer._measuredHeight);
// Call the callback
self._handleDragStart && self._handleDragStart(e);
// Start the scroll bars
var width = self._measuredWidth,
height = self._measuredHeight,
contentWidth = contentContainer._measuredWidth,
contentHeight = contentContainer._measuredHeight;
self._startScrollBars({
x: -self._currentTranslationX / (contentWidth - width),
y: -self._currentTranslationY / (contentHeight - height)
},
{
x: width / contentWidth,
y: height / contentHeight
});
// Call the callback
self._handleDragStart && self._handleDragStart(e);
}
});
on(self, "dragging", function(e) {
if (self.scrollingEnabled) {
// Update the velocity calculations
translationX = startTranslationX + e.distanceX;
translationY = startTranslationY + e.distanceY;
calculateVelocity();
// Update the velocity calculations
translationX = startTranslationX + e.distanceX;
translationY = startTranslationY + e.distanceY;
calculateVelocity();
// Update the translation
self._setTranslation(previousTranslationX = translationX, previousTranslationY = translationY);
// Update the translation
self._setTranslation(previousTranslationX = translationX, previousTranslationY = translationY);
// Update the scroll bars
var width = self._measuredWidth,
height = self._measuredHeight,
contentWidth = contentContainer._measuredWidth,
contentHeight = contentContainer._measuredHeight;
this._updateScrollBars({
x: -self._currentTranslationX / (contentWidth - width),
y: -self._currentTranslationY / (contentHeight - height)
});
self._handleDrag && self._handleDrag(e);
// Update the scroll bars
var width = self._measuredWidth,
height = self._measuredHeight,
contentWidth = contentContainer._measuredWidth,
contentHeight = contentContainer._measuredHeight;
self._updateScrollBars({
x: -self._currentTranslationX / (contentWidth - width),
y: -self._currentTranslationY / (contentHeight - height)
});
self._handleDrag && self._handleDrag(e);
}
});
on(self, "draggingcancel", function(e) {
self._animateToPosition(startTranslationX, startTranslationY, 400 + 0.3 * calculateDistance(
startTranslationX, startTranslationY, self._currentTranslationX, self._currentTranslationY),
"ease-in-out", function(){
self._handleDragCancel && self._handleDragCancel(e);
});
self._endScrollBars();
self._handleDragCancel && self._handleDragCancel(e);
if (self.scrollingEnabled) {
self._animateToPosition(startTranslationX, startTranslationY, 400 + 0.3 * calculateDistance(
startTranslationX, startTranslationY, self._currentTranslationX, self._currentTranslationY),
"ease-in-out", function(){
self._handleDragCancel && self._handleDragCancel(e);
});
self._endScrollBars();
self._handleDragCancel && self._handleDragCancel(e);
}
});
on(self, "draggingend", function(e) {
translationX = startTranslationX + e.distanceX;
translationY = startTranslationY + e.distanceY;
calculateVelocity();
var x = self._currentTranslationX,
y = self._currentTranslationY,
springBack;
if (self.scrollingEnabled) {
translationX = startTranslationX + e.distanceX;
translationY = startTranslationY + e.distanceY;
calculateVelocity();
var x = self._currentTranslationX,
y = self._currentTranslationY,
springBack;
// Spring back if need be
if (x > 0) {
x = 0;
springBack = 1;
} else if(x < minTranslationX) {
x = minTranslationX;
springBack = 1;
}
if (y > 0) {
y = 0;
springBack = 1;
} else if(y < minTranslationY) {
y = minTranslationY;
springBack = 1;
}
// Spring back if need be
if (x > 0) {
x = 0;
springBack = 1;
} else if(x < minTranslationX) {
x = minTranslationX;
springBack = 1;
}
if (y > 0) {
y = 0;
springBack = 1;
} else if(y < minTranslationY) {
y = minTranslationY;
springBack = 1;
}
if (springBack) {
self._animateToPosition(x, y, 200, "ease-out", function(){
self._handleDragEnd && self._handleDragEnd(e);
});
} else {
self._handleDragEnd && self._handleDragEnd(e, velocityX, velocityY);
if (springBack) {
self._animateToPosition(x, y, 200, "ease-out", function(){
self._handleDragEnd && self._handleDragEnd(e);
});
} else {
self._handleDragEnd && self._handleDragEnd(e, velocityX, velocityY);
}
}

@@ -193,32 +198,37 @@ });

enableMouseWheel && (this._disconnectMouseWheelEvent = on(self.domNode, "mousewheel",function(e) {
var distanceX = contentContainer._measuredWidth - self._measuredWidth,
distanceY = contentContainer._measuredHeight - self._measuredHeight,
currentPositionX = -self._currentTranslationX,
currentPositionY = -self._currentTranslationY;
if (self.scrollingEnabled) {
var distanceX = contentContainer._measuredWidth - self._measuredWidth,
distanceY = contentContainer._measuredHeight - self._measuredHeight,
currentPositionX = -self._currentTranslationX,
currentPositionY = -self._currentTranslationY;
// Start the scrollbar
self._startScrollBars({
x: currentPositionX / distanceX,
y: currentPositionY / distanceY
},
{
x: self._measuredWidth / contentContainer._measuredWidth,
y: self._measuredHeight / contentContainer._measuredHeight
});
minTranslationX = self._minTranslationX = Math.min(0, self._measuredWidth - self._borderLeftWidth - self._borderRightWidth - self._contentContainer._measuredWidth);
minTranslationY = self._minTranslationY = Math.min(0, self._measuredHeight - self._borderTopWidth - self._borderBottomWidth - self._contentContainer._measuredHeight);
// Set the scroll position
self._setTranslation(Math.min(0, Math.max(self._minTranslationX,-currentPositionX + e.wheelDeltaX)),
Math.min(0, Math.max(self._minTranslationY,-currentPositionY + e.wheelDeltaY)));
// Start the scrollbar
self._startScrollBars({
x: currentPositionX / distanceX,
y: currentPositionY / distanceY
},
{
x: self._measuredWidth / contentContainer._measuredWidth,
y: self._measuredHeight / contentContainer._measuredHeight
});
// Create the scroll event and immediately update the position
self._updateScrollBars({
x: currentPositionX / distanceX,
y: currentPositionY / distanceY
});
clearTimeout(scrollbarTimeout);
scrollbarTimeout = setTimeout(function(){
self._endScrollBars();
},500);
// Set the scroll position
self._setTranslation(Math.min(0, Math.max(self._minTranslationX,-currentPositionX + e.wheelDeltaX)),
Math.min(0, Math.max(self._minTranslationY,-currentPositionY + e.wheelDeltaY)));
self._handleMouseWheel && self._handleMouseWheel();
// Create the scroll event and immediately update the position
self._updateScrollBars({
x: currentPositionX / distanceX,
y: currentPositionY / distanceY
});
clearTimeout(scrollbarTimeout);
scrollbarTimeout = setTimeout(function(){
self._endScrollBars();
},500);
self._handleMouseWheel && self._handleMouseWheel();
}
}));

@@ -433,4 +443,8 @@ },

}, 10);
},
properties: {
scrollingEnabled: true
}
});
});

@@ -1,5 +0,12 @@

define(["Ti/_/Evented", "Ti/_/lang"], function(Evented, lang) {
define(["Ti/_", "Ti/_/Evented", "Ti/_/lang"], function(_, Evented, lang) {
return lang.mixProps(lang.setObject("Ti.App", Evented), {
constants: require.config.app,
constants: require.mix({
sessionId: function() {
var ss = sessionStorage,
sid = ss.getItem("ti:sessionId");
sid || ss.setItem("ti:sessionId", sid = _.uuid());
return sid;
}
}, require.config.app),

@@ -6,0 +13,0 @@ getID: function() {

define(["Ti/_/declare", "Ti/_/UI/Widget", "Ti/_/dom", "Ti/_/css", "Ti/_/style", "Ti/_/lang", "Ti/Locale", "Ti/UI"],
function(declare, Widget, dom, css, style, lang, Locale, UI) {
var setStyle = style.set,
var on = require.on,
setStyle = style.set,
postDoBackground = {

@@ -27,8 +28,11 @@ post: function() {

var contentContainer = this._contentContainer = UI.createView({
width: UI.INHERIT,
height: UI.INHERIT,
layout: UI._LAYOUT_CONSTRAINING_HORIZONTAL,
borderColor: "transparent"
});
width: UI.INHERIT,
height: UI.INHERIT,
layout: UI._LAYOUT_CONSTRAINING_HORIZONTAL,
borderColor: "transparent"
}),
node = this.domNode;
this._add(contentContainer);
contentContainer._add(this._buttonImage = UI.createImageView());

@@ -41,14 +45,18 @@ contentContainer._add(this._buttonTitle = UI.createLabel({

}));
this._setDefaultLook();
this.addEventListener("touchstart",function(){
on(this, "touchstart", this, function() {
css.remove(node, "TiUIElementGradient");
css.add(node, "TiUIElementGradientActive");
this.selectedColor && (this._buttonTitle.color = this.selectedColor);
});
this.addEventListener("touchend",function(){
this.selectedColor && (this._buttonTitle.color = this.color || "black");
on(this, "touchend", this, function() {
css.remove(node, "TiUIElementGradientActive");
css.add(node, "TiUIElementGradient");
this.selectedColor && (this._buttonTitle.color = this.color || "#000");
});
this.domNode.addEventListener("mouseout",lang.hitch(this,function(){
this.selectedColor && (this._buttonTitle.color = this.color || "black");
}));
on(node, "mouseout", this, function() {
this.selectedColor && (this._buttonTitle.color = this.color || "#000");
});
},

@@ -55,0 +63,0 @@

@@ -156,3 +156,3 @@ define(["Ti/_/declare", "Ti/_/event", "Ti/_/lang", "Ti/_/style", "Ti/_/UI/Widget", "Ti/UI", "Ti/Filesystem"],

if (this._images) {
this._setState(1, 0);
this._setState(0, 1);
this._slideshowCount = 0;

@@ -159,0 +159,0 @@ this._setSlideshowInterval();

@@ -14,40 +14,42 @@ define(["Ti/_/css", "Ti/_/declare", "Ti/UI/View", "Ti/UI", "Ti/_/lang"],

tab = args && args._tab,
navBar = self._navBarContainer = UI.createView({
width: UI_FILL,
height: 50
navBarContainer = self._navBarContainer = UI.createView({
height: 50,
width: UI.FILL,
layout: UI._LAYOUT_CONSTRAINING_HORIZONTAL
});
css.add(navBarContainer.domNode, navGroupCss);
self.layout = UI._LAYOUT_CONSTRAINING_VERTICAL;
css.add(navBar.domNode, navGroupCss);
self._navBarContainer._add(self._backButton = UI.createButton({
title: "Back",
// Create the nav bar content
navBarContainer.add(self._leftContainer = Ti.UI.createView({
width: UI.SIZE,
height: "100%",
left: 5,
opacity: 0,
enabled: true
right: 5
}));
self._backButton.addEventListener("singletap", function() {
self.close(self._windows[self._windows.length-1]);
});
self._navBarContainer._add(self._title = UI.createLabel({
width: UI_FILL,
textAlign: UI.TEXT_ALIGNMENT_CENTER,
touchEnabled: false
navBarContainer.add(self._centerContainer = Ti.UI.createView({
width: UI.FILL,
height: "100%"
}));
navBarContainer.add(self._rightContainer = Ti.UI.createView({
width: UI.SIZE,
height: "100%",
left: 5,
right: 5
}));
self._add(navBarContainer);
// Create the content container
self._contentContainer = UI.createView({
self._add(self._contentContainer = UI.createView({
width: UI_FILL,
height: UI_FILL
});
// init window stack and add window
}));
// Stylize the top
this.navBarAtTop = true;
navBarContainer._getBorderFromCSS();
// Initialize the window stack and add the root window
self._windows = [];
win && this._addWindow(win);
// invoke the navBarAtTop setter
self.navBarAtTop = true;
win && self.open(win);
},

@@ -58,15 +60,66 @@

_defaultHeight: UI_FILL,
_updateTitle: function() {
var len = this._windows.length;
this._title.text = (len && this._windows[len - 1]._getTitle()) || (this._tab && this._tab._getTitle()) || "";
_updateNavBar: function() {
var _self = this,
windows = _self._windows,
len = windows.length,
activeWin = windows[len - 1],
navBarContainer = this._navBarContainer,
leftContainer = _self._leftContainer,
centerContainer = _self._centerContainer,
rightContainer = _self._rightContainer,
leftView,
centerView,
rightView = activeWin.rightNavButton;
if (activeWin.leftNavButton) {
leftView = activeWin.leftNavButton;
} else {
if (!_self._backButton) {
_self._backButton = Ti.UI.createButton({
title: "Back"
});
require.on(_self._backButton, "singletap", function() {
// Note: we can reuse activeWin or length because they may have changed by the time this event
// listener is called due to reuse of the back button across windows.
_self.close(windows[windows.length - 1]);
});
};
len > 1 && (leftView = _self._backButton);
}
if (leftContainer._children[0] !== leftView) {
leftContainer._removeAllChildren();
leftView && leftContainer._add(leftView);
}
if (rightContainer._children[0] !== rightView) {
rightContainer._removeAllChildren();
rightView && rightContainer._add(rightView);
}
navBarContainer.backgroundColor = activeWin.barColor;
navBarContainer.backgroundImage = activeWin.barImage;
navBarContainer.opacity = activeWin.translucent ? 0.5 : 1;
navBarContainer.height = activeWin.navBarHidden && activeWin.modal ? 0 : 50;
if (activeWin.titleControl) {
centerView = activeWin.titleControl;
} else if (activeWin.titleImage) {
centerView = activeWin._titleImageView || (activeWin._titleImageView = Ti.UI.createImageView({
image: activeWin.titleImage
}));
} else {
centerView = activeWin._titleControl || (activeWin._titleControl = Ti.UI.createLabel({
text: activeWin._getTitle() || (this._tab && this._tab._getTitle()) || "",
width: "100%",
height: "100%",
textAlign: UI.TEXT_ALIGNMENT_CENTER
}));
}
if (centerContainer._children[0] !== centerView) {
centerContainer._removeAllChildren();
centerView && centerContainer._add(centerView);
}
},
_addWindow: function(win) {
var tab = this._tab;
tab && (win.tabGroup = (win.tab = tab)._tabGroup);
this._windows.push(win);
this._contentContainer._add(win);
},
_getTopWindow: function() {

@@ -78,36 +131,21 @@ var windows = this._windows,

add: function(view) {
this._navBarContainer._add(view);
this._publish(view);
},
remove: function(view) {
this._navBarContainer._remove(view);
this._unpublish(view);
},
open: function(win) {
if (!win._opened) {
var backButton = this._backButton;
var backButton = this._backButton,
windows = this._windows,
tab = this._tab;
win._navGroup = this;
// Publish the window
this._publish(win);
// Show the back button, if need be
if (!this._backButtonVisible) {
this._backButtonVisible = 1;
backButton.animate({opacity: 1, duration: 250}, function() {
backButton.opacity = 1;
backButton.enabled = true;
});
}
// Set a default background
!isDef(win.backgroundColor) && !isDef(win.backgroundImage) && (win.backgroundColor = "#fff");
this._windows[this._windows.length - 1].fireEvent("blur");
this._title.text = win._getTitle();
~(windows.length - 1) && windows[windows.length - 1].fireEvent("blur");
// Show the window
this._addWindow(win);
tab && (win.tabGroup = (win.tab = tab)._tabGroup);
windows.push(win);
this._contentContainer._add(win);
this._updateNavBar();
win._opened || win.fireEvent("open");

@@ -124,6 +162,5 @@ win._opened = 1;

backButton = self._backButton;
win._navGroup = void 0;
// Unpublish the window
self._unpublish(win);
// make sure the window exists and it's not the root

@@ -137,14 +174,4 @@ if (windowIdx > 0) {

if (windowIdx > 0) {
// hide the back button if we're back at the root
windows.length <= 1 && backButton.animate({ opacity: 0, duration: 250 }, function() {
self._backButtonVisible = 0;
backButton.opacity = 0;
backButton.enabled = false;
});
win = windows[windows.length - 1];
self._title.text = win._getTitle();
win.fireEvent("focus");
}
this._updateNavBar();
windows[windows.length - 1].fireEvent("focus");
}

@@ -176,3 +203,3 @@ },

windows.splice(1);
this._title.text = win._getTitle();
this._updateNavBar();
win.fireEvent("focus");

@@ -189,11 +216,10 @@ },

if (value !== oldValue) {
var containers = [this._contentContainer, this._navBarContainer],
node = this._navBarContainer.domNode;
containers.forEach(this._remove, this);
value && containers.reverse();
containers.forEach(this._add, this);
css.remove(node, navGroupCss + (value ? "Top" : "Bottom"));
css.add(node, navGroupCss + (value ? "Bottom" : "Top"));
var navBarContainer = this._navBarContainer,
navBarContainerDomNode = navBarContainer.domNode;
this._remove(navBarContainer);
this._insertAt(navBarContainer, value ? 0 : 1);
css.remove(navBarContainerDomNode, navGroupCss + (value ? "Top" : "Bottom"));
css.add(navBarContainerDomNode, navGroupCss + (value ? "Bottom" : "Top"));
}

@@ -200,0 +226,0 @@

@@ -62,2 +62,3 @@ define(["Ti/_/declare", "Ti/_/UI/FontWidget", "Ti/_/css", "Ti/_/style", "Ti/UI"],

this._contentContainer.borderWidth = 6;
this._getBorderFromCSS();
}

@@ -64,0 +65,0 @@ },

@@ -103,3 +103,3 @@ define(["Ti/_/declare", "Ti/UI/View", "Ti/_/dom", "Ti/Locale", "Ti/UI", "Ti/UI/MobileWeb"],

navGroup.navBarAtTop = tabGroup.tabsAtBottom;
navGroup._updateTitle();
navGroup._updateNavBar();
tabGroup._addTabContents(navGroup);

@@ -106,0 +106,0 @@ doEvents && this._focus();

@@ -6,4 +6,2 @@ define(["Ti/_/declare", "Ti/_/dom", "Ti/_/UI/Element", "Ti/_/lang", "Ti/_/string", "Ti/_/Layouts", "Ti/_/style", "Ti/UI"],

_parent: null,
constructor: function() {

@@ -10,0 +8,0 @@ this.constants.__values__.children = [];

@@ -5,3 +5,8 @@ define(["Ti/_/declare", "Ti/Gesture", "Ti/Locale", "Ti/_/UI/SuperView", "Ti/UI"],

var UI_FILL = UI.FILL,
UI_SIZE = UI.SIZE;
UI_SIZE = UI.SIZE,
postNavGroup = {
post: function () {
this._navGroup && this._navGroup._updateNavBar();
}
};

@@ -32,2 +37,3 @@ return declare("Ti.UI.Window", SuperView, {

properties: {
modal: {

@@ -66,6 +72,24 @@ set: function(value, oldValue) {

},
/** Nav group properties **/
barColor: postNavGroup,
barImage: postNavGroup,
leftNavButton: postNavGroup,
navBarHidden: postNavGroup,
rightNavButton: postNavGroup,
titleControl: postNavGroup,
titleImage: postNavGroup,
title: void 0,
title: postNavGroup,
titleid: void 0
titleid: postNavGroup,
translucent: postNavGroup
}

@@ -72,0 +96,0 @@

@@ -1,18 +0,14 @@

function onReady(args) {
args || (args = {});
for (var k in args) {
$.loading[k] = args[k];
}
var args = arguments[0] || {};
if (Ti.Platform.osname === 'mobileweb') {
$.loading.duration = 100;
}
$.loading.start();
for (var k in args) {
$.loading[k] = args[k];
}
module.exports = Alloy.getController('BaseController').extend({
onReady: onReady,
setOpacity: function(opacity) {
$.loading.opacity = opacity;
}
});
if (Ti.Platform.osname === 'mobileweb') {
$.loading.duration = 100;
}
$.loading.start();
exports.setOpacity = function(opacity) {
$.loading.opacity = opacity;
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc