This repository has been archived on 2023-03-18. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
osr-discourse-src/app/assets/javascripts/discourse/models/selectable_array.js
T
Sam 5280b3a01b more group progress, UI getting there, controller mostly done
changed it so notify moderators goes to the moderators group
allow admins to grant self moderation and revoke self moderation
2013-05-09 17:37:34 +10:00

31 lines
733 B
JavaScript

// this allows you to track the selected item in an array, ghetto for now
Discourse.SelectableArray = Em.ArrayProxy.extend({
init: function() {
this.content = [];
this._super();
},
selectIndex: function(index){
this.select(this[index]);
},
select: function(selected){
this.content.each(function(item){
if(item === selected){
Em.set(item, "active", true)
} else {
if (item.get("active")) {
Em.set(item, "active", false)
}
}
});
this.set("active", selected);
},
removeObject: function(object) {
if(object === this.get("active")){
this.set("active", null);
Em.set(object, "active", false);
}
this._super(object);
}
});