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
Ti.include("/struct/struct.js"); | |
S.app.mainWindow = S.ui.createApplicationWindow(); | |
S.app.mainWindow.open(); | |
S.app.mood = "RADIANT!"; | |
Ti.App.fireEvent("app:mood.update"); | |
setTimeout(function(){Ti.App.fireEvent("app:msg",{msg:"Welcome!"});},1000); |
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
/** | |
* Appcelerator Titanium Platform | |
* Copyright (c) 2009-2011 by Appcelerator, Inc. All Rights Reserved. | |
* Licensed under the terms of the Apache Public License | |
* Please see the LICENSE included with this distribution for details. | |
**/ | |
// Code is stripped-down version of Tweetanium, to expose new structure paradigm | |
(function(){ | |
S.ui.createFooWin = function(){ |
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
demos = [{ | |
description: "A parent with the layout property set to 'vertical' uses a vertical layout mechanism instead. Here, a child is placed in relation to the bottom of the previous child.", | |
children: [{height:80,width:100,left:30},{top:5,left:20,height:80,width:60}] | |
},{ | |
iphone: "Everything works as normal, even negative offsets (not on Android though!) and zIndexes. Except...", | |
android: "Negative top offsets have weird behaviour in a vertical layout on Android. Here, the second child ends up before the first!", | |
children: [{height:80,width:100,left:30,zIndex:1},{top:-5,left:20,height:80,width:60}] | |
},{ | |
iphone: "...the top and bottom properties are both used as margins (on Android only top!). So the height difference between two siblings is the sum of the bottom of the first and the top of the second.", | |
android: "The height difference between two siblings is controlled by the top property of the second sibling. On iPhone, the bottom prop of the first is added to the difference as well.", |
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
if typeof exports is "undefined" | |
exportTo = @parser = {} | |
else | |
exportTo = exports |
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
tests.addBatch "the implicit operation function": | |
"is defined": -> assert.isFunction iO | |
"returns product for": pairs "1x", "2y", "3z", "5(", "0x", ")(", "xy", "5\"", "x\"", "\"y","\"\"", "5|", "||", "!x" | |
"returns power for": pairs "x2", "y3", "z4", ")6", "\"2", "\"8", "|2", "x0", "!2" | |
"returns sum for": pairs "3-", "z-", ")-", "\"-" | |
"returns nothing for": wrongpairs "3+", "x*" |
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
tests.addBatch "the calc function": | |
"is defined": -> assert.isFunction calc | |
"when relating": | |
topic: -> (arg)-> calc "relation", start, arg, "eq" | |
"a blob": | |
topic: (relate)-> relate blob | |
"we get a": type "relation" | |
"containing": objs [start, blob] | |
"with a value": val "eq" | |
"a relation": (relate)-> assert.throws -> relate relation |
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
calc = (tool,a1,a2,toolarg)-> | |
if tool is "relation" | |
throw "Only one relation allowed!" if a2.type is "relation" | |
type:"relation",objs:[a1,a2],val:toolarg | |
else if a2.type is "relation" | |
type: "relation",val:a2.val, objs:[calc(tool,a1,a2.objs[0]),a2.objs[1]] | |
else if a2.isblock | |
o tool,[a1,a2] | |
else if tool in ["sum","product"] and tool is a2.type | |
o tool, [a1].concat a2.objs |
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
# ----------------------------- jquerified DOM references --------------------------- | |
ui = {} | |
ui[id] = $("##{id}") for id in ["input","output","response","history","current","savebtn","examples","clearhistorybtn","clearbtn"] | |
ui.currentstring = $ "#current .string" | |
ui.currentobjprint = $ "#current .objprint" | |
# -------------------------- variables/constans ----------------------------------- |
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
// Compare classic insert, insert using Begin/Commit and Union insert described slightly down on this page: http://stackoverflow.com/questions/1609637/is-it-possible-to-insert-multiple-rows-at-a-time-in-an-sqlite-database | |
// Create some values | |
var values = []; | |
for(var i = 0; i < 500; i++){ | |
values.push(i); | |
values.push(String.fromCharCode(65 + i % 25)); | |
} | |
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
/* | |
S A N I T A R Y V I E W P U B L I C A T I O N P A T T E R N | |
This pattern adresses three issues; memory leaks, involuntarily allowing unwanted event listeners to live | |
on, and the cumbersome process of publishing a view to the page. The first two issues are dealt with through | |
making sure that previously published views are removed properly, and not merely have their html | |
overwritten. And, as will see, the solution to fixing the removal process will also mean a streamlining | |
of the publication process! | |
We do this through the use of two mixin modules; one for our views, and one for our router. |