feat(kfet/open): small changes to allow registering callbacks
This commit is contained in:
parent
8d7ccccc9b
commit
983664d218
2 changed files with 13 additions and 6 deletions
|
@ -49,6 +49,8 @@ OpenKfet.prototype = {
|
||||||
deactivate: "Réouvrir la K-Fêt"
|
deactivate: "Réouvrir la K-Fêt"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
callbacks: [ ],
|
||||||
|
|
||||||
get is_recent() {
|
get is_recent() {
|
||||||
return this.last_update && moment().diff(this.last_update, 'minute') <= this.time_unknown;
|
return this.last_update && moment().diff(this.last_update, 'minute') <= this.time_unknown;
|
||||||
},
|
},
|
||||||
|
@ -69,6 +71,9 @@ OpenKfet.prototype = {
|
||||||
|
|
||||||
this.add_class(status);
|
this.add_class(status);
|
||||||
this.dom.status_text.html(this.status_text[status]);
|
this.dom.status_text.html(this.status_text[status]);
|
||||||
|
for (callback of this.callbacks) {
|
||||||
|
callback(status);
|
||||||
|
}
|
||||||
|
|
||||||
// admin specific
|
// admin specific
|
||||||
if (this.admin) {
|
if (this.admin) {
|
||||||
|
@ -109,5 +114,9 @@ OpenKfet.prototype = {
|
||||||
|
|
||||||
add_class: function (status) {
|
add_class: function (status) {
|
||||||
$(this.target).addClass(this.class_prefix + status);
|
$(this.target).addClass(this.class_prefix + status);
|
||||||
|
},
|
||||||
|
|
||||||
|
add_callback: function (callback) {
|
||||||
|
this.callbacks.push(callback);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,10 +4,8 @@
|
||||||
<script type="text/javascript" src="{% static "kfetopen/kfet-open.js" %}"></script>
|
<script type="text/javascript" src="{% static "kfetopen/kfet-open.js" %}"></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$( function() {
|
|
||||||
kfet_open = new OpenKfet(
|
kfet_open = new OpenKfet(
|
||||||
"{% url "kfet.open.edit_force_close" %}",
|
"{% url "kfet.open.edit_force_close" %}",
|
||||||
{{ perms.kfet.is_team|yesno:"true,false" }}
|
{{ perms.kfet.is_team|yesno:"true,false" }}
|
||||||
);
|
);
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Reference in a new issue