Created
August 16, 2012 16:33
-
-
Save tonylukasavage/3371493 to your computer and use it in GitHub Desktop.
revised Alloy controller format
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
"Window": { | |
backgroundColor: '#fff' | |
}, | |
"Label": { | |
width: Ti.UI.SIZE, | |
height: Ti.UI.SIZE, | |
color: "#000", | |
font: { | |
fontSize: '32dp' | |
} | |
}, | |
"#ad": { | |
buttonNames: ['OK'], | |
title: 'Label Text' | |
} |
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 args = arguments[0] || {}; | |
$.ad.message = args.message; | |
// "exported" functions attached to each dialog controller instance | |
exports.showDialog = function() { | |
$.ad.show(); | |
} | |
exports.hideDialog = function() { | |
$.ad.hide(); | |
} |
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
<Alloy> | |
<AlertDialog id="ad"/> | |
</Alloy> |
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
$.index.open(); | |
/* | |
* "exported" functions are attached to each instance and are made | |
* available inside the controller code as well. | |
* - "exports" can call and access other "exports" | |
* - "exports" also have full access to the $ variable | |
*/ | |
exports.showAlert = function(text) { | |
var dialogController = Alloy.getController('dialog', { message:text }); | |
dialogController.showDialog(); | |
// or you can access the AlertDialog directly with getView(id) | |
// | |
// dialogController.getView('ad').show(); | |
// | |
// getView() called with no id will get the first top-level view | |
// | |
// dialogController.getView().show(); | |
// hide the dialog after 3 seconds using the exposed "hideDialog" function | |
setTimeout(function() { | |
dialogController.hideDialog(); | |
}, 3000); | |
} | |
/* | |
* markup event handler | |
*/ | |
function doClick(e) { | |
exports.showAlert($.label.text); | |
} | |
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
<Alloy> | |
<Window> | |
<Label id="label" onClick="doClick">Hello, World</Label> | |
</Window> | |
</Alloy> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment