This file contains hidden or 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 PX = require('com.pixate.framework'); | |
| PX.styleSheetFromFilePathWithOrigin({ | |
| monitor: true, | |
| origin: 0, | |
| filename: '/path/to/file.css' | |
| }); | |
| PX.styleSheetFromFilePathWithOrigin({ | |
| monitor: true, | |
| origin: 0, | |
| filename: '/path/to/second_file.css' |
This file contains hidden or 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 doClickMenu(evt){ | |
| alert(evt.source.title); | |
| } | |
| // we need to do some things to the Window once it is properly instanciated, so we add an event listener to its OPEN event | |
| $.win.addEventListener('open',function(){ | |
| var actionBar = $.win.activity.actionBar; // get a handle to the action bar | |
| actionBar.title='My App'; // change the App Title | |
| actionBar.displayHomeAsUp=true; // Show the "angle" pointing back | |
| actionBar.onHomeIconItemSelected = function() { // what to do when the "home" icon is pressed |
This file contains hidden or 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
| "#scrollView": { | |
| layout:"horizontal", | |
| contentWidth: Ti.UI.SIZE, //andoid important | |
| height:260, | |
| scrollType:"horizontal", | |
| horizontalWrap: false //andoid important | |
| }, | |
| ".view": { | |
| height:260, | |
| width:220, |
This file contains hidden or 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 CircleLoaderView = require("CircleLoaderView"); | |
| var myloader = new CircleLoaderView({ | |
| width : 200, | |
| centerWidth : 100, | |
| backgroundColor : "#fff", | |
| tintColor : "blue", | |
| textColor : "red", | |
| labelFontSize : 28 |
This file contains hidden or 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 viewWithTransparentBackground = Titanium.UI.createView({ | |
| backgroundColor: 'rgba(0,0,0,0.5)' // RGB way: Black background at 0.5 alpha | |
| }); | |
| //OR | |
| var viewWithTransparentBackground = Titanium.UI.createView({ | |
| backgroundColor: "#50ff0000" // hex way: red background at 0.5 alpha | |
| }); |
This file contains hidden or 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 Utils = { | |
| /* modified version of https://gist.github.com/1243697 | |
| * adds detection of file extension rather than hard-coding .jpg as in the original | |
| */ | |
| _getExtension: function(fn) { | |
| // from http://stackoverflow.com/a/680982/292947 | |
| var re = /(?:\.([^.]+))?$/; | |
| var tmpext = re.exec(fn)[1]; | |
| return (tmpext) ? tmpext : ''; | |
| }, |
This file contains hidden or 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 myFunction = function() { | |
| if(typeof arguments[0] == 'function') { | |
| arguments[0](); // throws error: [object Object] is not a function | |
| // but this works | |
| var cb = arguments[0]; | |
| cb(); | |
| } | |
| }; | |
| myFunction(function() { |
This file contains hidden or 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 xhr = Titanium.Network.createHTTPClient(); | |
| xhr.onload = function() | |
| { | |
| var results = this.responseText; | |
| Ti.API.info('Results from xhr Lookup = ' + results ); | |
| var supportDir = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,'my_support'); | |
| if(!supportDir.exists()){ | |
| supportDir.createDirectory(); | |
| } |
This file contains hidden or 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
| // I am pretty sure there is a sexier approach, but this works nicely | |
| var isPhone5 = Ti.Platform.displayCaps.platformHeight == 568; | |
| parse568hImages = function(imagePath) { | |
| if (isPhone5){ | |
| // Do this because the filename could contain dots | |
| imagePath = imagePath.replace(".png","[email protected]"); | |
| imagePath = imagePath.replace(".jpg","[email protected]"); | |
| imagePath = imagePath.replace(".jpeg","[email protected]"); | |
| } |
This file contains hidden or 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. |