Skip to content

Instantly share code, notes, and snippets.

@Mode54
Created February 23, 2012 20:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Mode54/1894879 to your computer and use it in GitHub Desktop.
Save Mode54/1894879 to your computer and use it in GitHub Desktop.
Titanium Mobile indicator module (iOS only so far)
var isIndicatorOpen = false,
view = Ti.UI.createView({
backgroundColor : "#000",
borderRadius : 10,
opacity : 0.8
}),
// message
message = Ti.UI.createLabel({
color : "#fff",
width : "auto",
height : "auto",
font : { fontSize : 14, fontWeight : "bold" },
bottom : 20
}),
// window container
indicatorWin = Ti.UI.createWindow({
top : 0,
left : 0,
right : 0,
bottom : 0
}),
// loading indicator
activityIndicator = Ti.UI.createActivityIndicator({
style : Ti.UI.iPhone.ActivityIndicatorStyle.BIG,
height : 30,
width : 30
});
view.add(activityIndicator);
view.add(message);
indicatorWin.add(view);
exports.show = function(settings){
settings = settings || {};
isIndicatorOpen = true;
message.text = settings.message || "Loading";
view.width = settings.width || 150;
view.height = settings.height || 150;
view.top = settings.top || null;
view.bottom = settings.bottom || null;
view.left = settings.left || null;
view.right = settings.right || null;
indicatorWin.open();
activityIndicator.show();
};
exports.hide = function(){
isIndicatorOpen = false;
activityIndicator.hide();
indicatorWin.close({ opacity : 0, duration : 500 });
};
exports.isOpen = function(){
return isIndicatorOpen;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment