So I'm playing around with SC now and I like what I see. As my first contribution to the community, here's a statusBar widget. I haven't see one in the normal widget set, so I made one as a intro to the framework.
Also, I'm sorry if this is the wrong place in the forums. I couldn't really find a better place.
Configuration Properties (Inherits from ToolStrip):
width, height: (self-explanatory)
animateMembers: (boolean default - true) set to False if you wish for status changes to happen immediately without the pretty fading
defaultText: (string default - "Ready") The text displayed when calling the clearStatus method
defaultIcon: (string default - "") The URL of an icon to display along with the default text.
members: An array of members of the StatusBar. By default it includes a label that is used for the statusText and Icon.
Instance Properties:
lbl - a label widget used to display the statusText and statusIcon
Instance Methods:
setStatus: Take parameters:
clearStatus: Takes no parameters, sets the statusBar to display the defaultText and defaultIcon if supplied.
Also, I'm sorry if this is the wrong place in the forums. I couldn't really find a better place.
Code:
isc.defineClass("StatusBar", ToolStrip); isc.StatusBar.addProperties({ width: "100%", height:24, animateMembers: true, defaultText: "Ready", defaultIcon: "", currentTimeout: null // Internal use only }); isc.StatusBar.addMethods({ initWidget: function() { this.lbl = isc.Label.create({ width: "*", wrap: false, baseStyle: "statusBarText normal", icon: "", contents: "", animateTime:300 }); this.addMember(this.lbl); }, setStatus: function(status, icon, timeout) { if (this.currentTimeout) { clearTimeout(this.currentTimeout); this.currentTimeout = null; } status = typeof(status) == 'string' ? status : this.defaultText; icon = icon ? icon : this.defaultIcon; if (this.animateMembers && this.getContents !== "") { this.lbl.animateFade(0); } var setMsg = function(self, status, icon, timeout) { return function inside() { self.currentTimeout = null; self.lbl.setIcon(icon); self.lbl.setContents(status); if (self.animateMembers) { self.lbl.animateFade(100); } if (typeof(timeout) == 'number') { var f = function() {self.clearStatus.apply(self, []);}; self.currentTimeout = setTimeout(f, self.lbl.animateTime+timeout); } }; }(this, status, icon, timeout); this.currentTimeout = setTimeout(setMsg, this.lbl.animateTime); }, clearStatus: function() { this.setStatus(); } });
width, height: (self-explanatory)
animateMembers: (boolean default - true) set to False if you wish for status changes to happen immediately without the pretty fading
defaultText: (string default - "Ready") The text displayed when calling the clearStatus method
defaultIcon: (string default - "") The URL of an icon to display along with the default text.
members: An array of members of the StatusBar. By default it includes a label that is used for the statusText and Icon.
Instance Properties:
lbl - a label widget used to display the statusText and statusIcon
Instance Methods:
setStatus: Take parameters:
- statusText - string to display on the statusBar
- statusIcon - (optional) url of an icon to display along with the statusText
- timeout - (optional) integer value of milliseconds before the status reverts to the defaultText.
clearStatus: Takes no parameters, sets the statusBar to display the defaultText and defaultIcon if supplied.