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
// my little html string builder | |
buildHTML = function(tag, html, attrs) { | |
// you can skip html param | |
if (typeof(html) != 'string') { | |
attrs = html; | |
html = null; | |
} | |
var h = '<' + tag; | |
for (attr in attrs) { | |
if(attrs[attr] === false) continue; |
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
// relevant dropbox threads: | |
// - http://forums.dropbox.com/topic.php?id=28728&replies=12#post- | |
// - http://forums.dropbox.com/topic.php?id=31832 | |
// code depends on spazcore.titanium.js (found in Tweetanium) | |
// SIMPLE WORKING EXAMPLE | |
var oa = new SpazOAuth("https://api.dropbox.com/", {"consumerKey": DROPBOX_KEY, "consumerSecret": DROPBOX_SECRET}); | |
oa.setAccessToken(ACCESS_TOKEN, ACCESS_SECRET); |
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 uploadFile = Titanium.Filesystem.getFile(filepath, filename); | |
var uploadStream = Titanium.Filesystem.getFileStream(uploadFile); | |
uploadStream.open(Titanium.Filesystem.MODE_READ, true); | |
content = uploadStream.read(); | |
uploadStream.close(); | |
// content = Titanium.Codec.encodeBase64(content); | |
// content = Titanium.Codec.encodeHexBinary(content); | |
var name = "file"; |
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
// arrEach and objEach plugins | |
// code under MIT license by Marc Grabanski http://marcgrabanski.com | |
// jsperf tests: http://jsperf.com/each-vs-fn-arreach-and-objeach/2 | |
$.arrEach = function(arr, cb){ | |
for (var i = 0, item; item = arr[i]; ++i) { | |
cb.apply(item, [i, item]); | |
} | |
return arr; | |
} |
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
.bind('xgcolor:hsbmove' + ns, $.proxy(function(e) { | |
var pos = $(this).offset(), | |
hsbcolor = $.xgcolor.options.hsbcolor; | |
hsbcolor.b = parseInt(100*(126 - Math.max(0,Math.min(126,(e.pageY - pos.top))))/126, 10); | |
hsbcolor.s = parseInt(100*(Math.max(0,Math.min(130,(e.pageX - pos.left))))/130, 10); | |
$.xgcolor._setColor(hsbcolor); | |
}, this.get('hsbselector'))) |
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
Add this to your backbone view: | |
selectors: { | |
form: '.ui-page-active form', | |
backbutton: '.ui-page-active .back', | |
...all your selectors... | |
}, | |
$find: function(key) { | |
if (this.selectors.hasOwnProperty(key)) { |
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
// Add this to your backbone view: | |
selectors: { | |
form: '.ui-page-active form', | |
backbutton: '.ui-page-active .back', | |
...all your selectors... | |
}, | |
$find: function(key) { | |
if (this.selectors.hasOwnProperty(key)) { |
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
// Pseudocode demonstrating inefficient rendering | |
var $list = $('#list'); | |
var dataset = data; // array of 1000 objects | |
for (var i = 0; i < dataset.length; i++) { | |
var view = new ItemView({model: dataset[i]}); | |
$list.append(view.render().el); | |
} |
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
// Pseudocode demonstrating pre-rendering HTML | |
// Binding views to HTML rather than the views generating HTML | |
var $listItems = $('#list').find('li'); | |
var dataset = data; // array of 1000 objects | |
for (var i = 0; i < dataset.length; i++) { | |
var view = new ItemView({model: dataset[i]}); | |
view.setElement($listItems.eq(i)); | |
} |
OlderNewer