Skip to content

Instantly share code, notes, and snippets.

@bradenpowers
Forked from raulriera/DialogWindow.js
Created November 15, 2012 20:42
Show Gist options
  • Save bradenpowers/4081119 to your computer and use it in GitHub Desktop.
Save bradenpowers/4081119 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
// 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();
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