summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/broadcast_message.js
blob: 576f4c76c1eacefafe7a529f9be973afda85a566 (plain)
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
/* eslint-disable */
(function() {
  $(function() {
    var previewPath;
    $('input#broadcast_message_color').on('input', function() {
      var previewColor;
      previewColor = $(this).val();
      return $('div.broadcast-message-preview').css('background-color', previewColor);
    });
    $('input#broadcast_message_font').on('input', function() {
      var previewColor;
      previewColor = $(this).val();
      return $('div.broadcast-message-preview').css('color', previewColor);
    });
    previewPath = $('textarea#broadcast_message_message').data('preview-path');
    return $('textarea#broadcast_message_message').on('input', function() {
      var message;
      message = $(this).val();
      if (message === '') {
        return $('.js-broadcast-message-preview').text("Your message here");
      } else {
        return $.ajax({
          url: previewPath,
          type: "POST",
          data: {
            broadcast_message: {
              message: message
            }
          }
        });
      }
    });
  });

}).call(this);