forked from maccman/holla
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspine.controller.manager.js
More file actions
49 lines (39 loc) · 1.03 KB
/
spine.controller.manager.js
File metadata and controls
49 lines (39 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
(function(Spine, $){
var Manager = Spine.Controller.Manager = Spine.Class.create();
Manager.include(Spine.Events);
Manager.include({
addAll: function(){
var args = Spine.makeArray(arguments);
for (var i=0; i < args.length; i++) this.add(args[i]);
},
add: function(controller){
if ( !controller ) throw("Controller required");
this.bind("change", function(current){
if (controller == current)
controller.activate();
else
controller.deactivate();
});
controller.active(this.proxy(function(){
this.trigger("change", controller);
}));
}
});
Spine.Controller.include({
active: function(callback){
(typeof callback == "function") ? this.bind("active", callback) : this.trigger("active");
return this;
},
isActive: function(){
return this.el.hasClass("active");
},
activate: function(){
this.el.addClass("active");
return this;
},
deactivate: function(){
this.el.removeClass("active");
return this;
}
});
})(Spine, Spine.$);