Skip to content

Instantly share code, notes, and snippets.

@dizda
Forked from Seasons7/app.js
Last active December 14, 2015 05:49
Show Gist options
  • Save dizda/5038393 to your computer and use it in GitHub Desktop.
Save dizda/5038393 to your computer and use it in GitHub Desktop.
Growl-like notifications in Titanium (tested under iOS)
Growl = (function() {
// constructor
function Growl(message){
this.message = message;
}
Growl.prototype.show = function()
{
this.createWindow();
};
Growl.prototype.createWindow = function()
{
Ti.API.info('Growl :'+this.message);
var window = Ti.UI.createWindow({
title:this.message,
backgroundColor:'#000',
top:135, left:95,
width:145,height:145,
opacity:0,
borderRadius:16
});
var imgValid = Ti.UI.createImageView({
image:'/images/growl_check.png',
top:20, left:42,
width:64,
height:64
});
var label = Ti.UI.createLabel({
color:'#FFF',
font:{fontWeight:'bold'},
text:this.message,
textAlign:'center',
width:135,
left:6,
bottom:10,
height:'auto',
});
var animation = Ti.UI.createAnimation({
duration:250,
opacity:0.7
});
animation.addEventListener('complete',function(){
setTimeout( function(){
window.animate( {duration:1000, opacity:0}, function(){
window.close();
});
},1000 );
});
window.animate(animation);
window.add(imgValid);
window.add(label);
window.open();
};
return Growl;
})();
module.exports = Growl;
@dizda
Copy link
Author

dizda commented Feb 26, 2013

And call it with something like that :

var Growl = require('ui/models/Growl');
growl = new Growl('Saved successfully.');

growl.show();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment