/app/themes/myTheme/assets/alloy/CFG.js • The SQLite sync adapter is not compatible with Backbone.js 1.x • Make sure you sync config.json changes to your CFG.js files Alloy.isTablet = function() { return (Ti.Platform.displayCaps.platformWidth > 800); } app/alloy.js .. or go wild and overwrite Extend via app.js
var index = s.lastIndexOf("/"); var path = -1 === index ? "myWidget/" + s : s.substring(0, index) + "/myWidget/" + s.substring(index + 1); return path; } app/widgets/myWidget/assets/foo.png Resources/myWidget/foo.png app/widgets/myWidget/assets/one/two/three.png Resources/one/two/MyWidget/three.png Examples • Assets and libs the same • Place stuff in platform specific iphone, android folders • Place stuff in the images folder
sync adapter in: exports.definition = { config: { adapter: { type: 'my.widget/myAdapter' } } }; Use in widget models: /Resources/alloy/sync/my.widget/myAdapter.js It will end up in: /app/widgets/my.widget/models/myModel.js
ID and class of view components to same, globally unique value <Alloy> ! <Label id="myWidgetLabel" class="myWidgetLabel" /> </Alloy> Apply defaults styles using classes ".myWidgetLabel": { ! color: 'red' } "#myWidgetLabel": { ! color: 'blue' } Instruct developers using your widget to override using IDs More: http://go.fokkezb.nl/alloytssprio (widgets missing)
(typeof ENV_TEST === 'boolean'); • Alloy constants like OS_IOS don't exist at run-time • They are replaced by TRUE|FALSE during compile • Code blocks that will never execute are removed • In Vanilla Titanium they will be undefined var Alloy = require('alloy'); Alloy.infect && Alloy.infect(this); myLib.js or app.js (3.1+) Source: http://go.fokkezb.nl/alloydetect