Files
grecia/app/assets/javascripts/votations.js
Javi Martín d93a029ce5 Convert CofeeScript to JavaScript
Compiled using `coffee -c` with CoffeeScript 1.12.6.
2019-09-11 14:03:24 +02:00

71 lines
2.0 KiB
JavaScript

// Generated by CoffeeScript 1.12.6
(function() {
"use strict";
App.Votations = {
checkMaxVotes: function() {
if ($("#votation_type_enum_type").val() === "0") {
$(".js-max_votes").hide();
return $("#max_votes").attr({
disabled: true
});
} else {
$(".js-max_votes").show();
return $("#max_votes").attr({
disabled: false
});
}
},
checkPrioritization: function() {
if ($("#votation_type_enum_type").val() === "2") {
$(".js-prioritization_type").show();
return $("#prioritization_type").attr({
disabled: false
});
} else {
$(".js-prioritization_type").hide();
return $("#prioritization_type").attr({
disabled: true
});
}
},
checkMaxGroups: function() {
if ($("#votation_type_enum_type").val() === "7" || $("#votation_type_enum_type").val() === "8") {
$(".js-max_group_votes").show();
return $("#max_groups_answers").attr({
disabled: false
});
} else {
$(".js-max_group_votes").hide();
return $("#max_groups_answers").attr({
disabled: true
});
}
},
setTraduction: function(response) {
return $(".js-description_text").text(response["traduction"]);
},
updateChecks: function() {
App.Votations.checkMaxVotes();
App.Votations.checkPrioritization();
return App.Votations.checkMaxGroups();
},
initialize: function() {
App.Votations.updateChecks();
return $("#votation_type_enum_type").on({
change: function() {
var params, url;
App.Votations.updateChecks();
url = "/admin/get_options_traductions.json";
params = {
enum_type: $("#votation_type_enum_type").val()
};
return $.get(url, params, function(response) {
return App.Votations.setTraduction(response, "json");
});
}
});
}
};
}).call(this);