Created
February 23, 2012 20:25
-
-
Save Mode54/1894879 to your computer and use it in GitHub Desktop.
Titanium Mobile indicator module (iOS only so far)
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 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