Skip to content

Instantly share code, notes, and snippets.

View krawaller's full-sized avatar

David Waller krawaller

View GitHub Profile
@krawaller
krawaller / gist:1125138
Created August 4, 2011 13:26
Demo object literals
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.",
@krawaller
krawaller / foowin.js
Created July 15, 2011 04:50 — forked from levi730/foowin.js
how to do subwindow with nav using struct
/**
* 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(){
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);
@krawaller
krawaller / community.js
Created October 21, 2010 10:05
CouchOne Tristania example
function map(doc){
if(doc.username && doc.presentation){
emit(doc._id, doc);
}
}
win.add(createKraWebView({template: "templateexamaple.html",data:{name:"ole",role:"bass",presentation:"<p>Nice guy!</p>"}}));
K.createKraWebView = function(o){
var webview = K.create(K.merge({url: "../views/"+ (o.masterPageFile || "_masterpage.html")} o),
template = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory+"/views/"+o.templateFile).read().text,
opts = { template: template, data: {data: o.data} };
webview.addEventListener("load",function(){ webview.evalJS("render("+JSON.stringify(opts)+")"); });
return webview;
},
@krawaller
krawaller / css_anchors.js
Created July 5, 2010 12:17
CSS Anchors Shim
(function(){
var hash = decodeURIComponent((location.href.match(/#(.*)$/) || [])[1]);
if(hash){
var el = document.querySelector(hash), t = 0;
do { t += el.offsetTop; }
while (el.offsetParent && (el = el.offsetParent));
window.scrollTo(0, t);
}
"plr-gate":{
conds: [{ // array of condition objects
'if': { // all properties here are conditions to be evaluated
"hasflag": "haskey" // tests for global flag of the given name
},
then: { // effects to take place if all conditions were true
on: true, // collision takes place on the square
stop: "b", // stops the marble motion, with animation "b" (bounce)
setwalltype: "none" // makes the gate disappear
},
// CSS-like styling
// test.css
tableView {
background-color: #f00;
color: #fff;
}
row { background-color: #0f0; }
.info { right: 0; }
// HTML-like templates combined with micro-templates or mustasche
Ti.include('../js/go.view.pre.js');
currentWin.add(Go.table([{
titleKey: 'play',
url: 'play_menu.js'
},
{
titleKey: 'options',
url: 'options.js'
},