cirandas.net

ref: master

plugins/organization_ratings/public/organization_rating_management.js


 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
(function($) {
  "use strict";

  var VoteOnce = {
    init: function() {
      this.cacheDom();
      this.setEvents();
    },


    cacheDom: function() {
      this.$vote_once_checkbox = $("#organization_ratings_config_vote_once");
      this.$hours_timer_input = $("#organization_ratings_config_cooldown");
    },


    setEvents: function() {
      this.$vote_once_checkbox.on("click", this.verifyHoursTimerDisable.bind(this));
    },


    verifyHoursTimerDisable: function() {
      if (this.$vote_once_checkbox.is(":checked")) {
        //this.$hours_timer_input.attr("disabled", "disabled");
        this.disableVoteOnce();
      } else {
        //this.$hours_timer_input.removeAttr("disabled");
        this.enableVoteOnce();
      }
    },


    enableVoteOnce: function() {
      this.$hours_timer_input.removeAttr("disabled");
    },


    disableVoteOnce: function() {
      this.$hours_timer_input.attr("disabled", "disabled");
    }
  }


  $(document).ready(function() {
    VoteOnce.init();
  });
}) (jQuery);