Created
September 9, 2012 11:08
-
-
Save raulriera/3683830 to your computer and use it in GitHub Desktop.
CustomAlertDialog commonJS module for Titanium Appcelerator. Similar to the "Tweetbot" (but will need more makeup of course) where the information is displayed below the title bar instead of an intrusive popup
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
// Include the module | |
require("DialogWindow"); | |
// Show the alert wherever (this is of course the one liner approach) | |
new DialogWindow("Oh oh, super error detected").open(); |
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
DialogWindow = function(message, type){ | |
// Default params | |
var message = message || "How about you add some message to this? :)"; | |
var type = type || "error"; | |
var window = Titanium.UI.createWindow({ | |
width: 320, | |
height: 44, | |
top: 44, | |
opacity: 0 | |
}); | |
var container = Titanium.UI.createView({ | |
opacity: 0.8, | |
backgroundColor: type == "error" ? "#cc0000" : "#333333", | |
borderWidth: 2, | |
borderColor: type == "error" ? "#ff0000" : "#111111" | |
}); | |
var message = Titanium.UI.createLabel({ | |
text: message, | |
font: { fontSize: 11, fontWeight: "bold"}, | |
color: "#ffffff", | |
shadowColor: "#111111", | |
shadowOffset: {x:0,y:1}, | |
left: 12, | |
right: 12 | |
}); | |
// When the window opens | |
window.addEventListener("open", function(e){ | |
window.animate({ opacity: 1, duration: 500 }); | |
setTimeout(function(){ | |
window.animate({ opacity: 0, duration: 500 }); | |
}, 5500); | |
}); | |
window.add(container); | |
window.add(message); | |
return window; | |
}; | |
module.exports = DialogWindow; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For usage
require("/DialogWindow");
new DialogWindow("Hello there champ").open();