Files
nairobi/app/assets/javascripts/banners.js.coffee
iagirre 82cb8d4c52 Changes suggested in PR:
* Delete all things related to banner images and styles (in code)
* Add a new test to check that the banner is showing correctly
* Update the specs accordingly to match the changes

Update dev_seed to set a random background_color and a font_color for banners (and remove everything about image and style)
Add a rake task to migrate the banner style to backgroun_color and font_color (so that the banners have the same colors than before)
2018-07-12 10:17:24 -04:00

44 lines
1.6 KiB
CoffeeScript

App.Banners =
update_banner: (selector, text) ->
$(selector).html(text)
update_style: (selector, style) ->
$(selector).removeClass($(selector).attr("class"), true)
.addClass(style, true)
update_background_color: (selector, text_selector, background_color) ->
$(selector).css('background-color', background_color);
$(text_selector).val(background_color);
update_font_color: (selector, text_selector, font_color) ->
$(selector).css('color', font_color);
$(text_selector).val(font_color);
initialize: ->
$('[data-js-banner-title]').on
change: ->
App.Banners.update_banner("#js-banner-title", $(this).val())
$('[data-js-banner-description]').on
change: ->
App.Banners.update_banner("#js-banner-description", $(this).val())
$("#banner_background_color_picker").on
change: ->
App.Banners.update_background_color("#js-banner-background", "#banner_background_color", $(this).val());
$("#banner_background_color").on
change: ->
App.Banners.update_background_color("#js-banner-background", "#banner_background_color_picker", $(this).val());
$("#banner_font_color_picker").on
change: ->
App.Banners.update_font_color("#js-banner-title", "#banner_font_color", $(this).val());
App.Banners.update_font_color("#js-banner-description", "#banner_font_color", $(this).val());
$("#banner_font_color").on
change: ->
App.Banners.update_font_color("#js-banner-title", "#banner_font_color_picker", $(this).val());
App.Banners.update_font_color("#js-banner-description", "#banner_font_color_picker", $(this).val());