From c542f0ec0c4bcf7cb7168af7a6a47fc880e9bc7e Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 9 Jul 2014 17:56:21 +0600 Subject: [PATCH] [#369] add flashes --- app/assets/javascripts/new_application.js | 7 ++++++- app/helpers/application_helper.rb | 4 ++++ app/models/flash_notify.rb | 4 ---- app/views/layouts/_flashes.html.haml | 7 ++++--- app/views/layouts/bootstrap.html.haml | 5 ++++- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/new_application.js b/app/assets/javascripts/new_application.js index e16aa45ec..656517dd8 100644 --- a/app/assets/javascripts/new_application.js +++ b/app/assets/javascripts/new_application.js @@ -42,7 +42,7 @@ function setCookie (name, value, expires, path, domain, secure) { } $(document).ready(function() { - $('.alert button.close').click(function () { + $('.notify.alert button.close').click(function () { var exdate=new Date(); exdate.setDate(exdate.getDate() + 365); var expires="expires="+exdate.toUTCString(); @@ -71,4 +71,9 @@ $(document).ready(function() { form.attr('action', $(this).val()); form.submit(); }); + + $('#create_fork').click(function () { + $(this).button('loading'); + }); + }); diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5c126a374..a6ec53d7f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -54,4 +54,8 @@ module ApplicationHelper klass = "datetime_moment #{options[:class]}" content_tag(tag, nil, class: klass, title: title, origin_datetime: date.to_i) end + + def alert_class(type) + "alert-#{type.to_s == 'error' ? 'danger' : type}" + end end diff --git a/app/models/flash_notify.rb b/app/models/flash_notify.rb index 5ed26b8b9..cfb569297 100644 --- a/app/models/flash_notify.rb +++ b/app/models/flash_notify.rb @@ -23,8 +23,4 @@ class FlashNotify < ActiveRecord::Base def should_show?(cookie_hash_id) cookie_hash_id != hash_id && published end - - def alert_class - "alert-#{status == 'error' ? 'danger' : status}" - end end diff --git a/app/views/layouts/_flashes.html.haml b/app/views/layouts/_flashes.html.haml index a3afb495a..855cfc11d 100644 --- a/app/views/layouts/_flashes.html.haml +++ b/app/views/layouts/_flashes.html.haml @@ -1,3 +1,4 @@ -.flash - - flash.each do |type, message| - .message{class: type}= message \ No newline at end of file +- flash.each do |type, message| + .alert.text-center{ class: alert_class(type) } + %button.close{ type: 'button', 'data-dismiss' => 'alert', 'aria-hidden' => true } × + = message diff --git a/app/views/layouts/bootstrap.html.haml b/app/views/layouts/bootstrap.html.haml index ec7601938..ffb78387c 100644 --- a/app/views/layouts/bootstrap.html.haml +++ b/app/views/layouts/bootstrap.html.haml @@ -16,10 +16,13 @@ - if (flash_notify = FlashNotify.published.first) && flash_notify.should_show?(cookies[:flash_notify_hash]) :javascript var FLASH_HASH_ID = "#{flash_notify.hash_id}"; - .alert.alert-dismissable.text-center{ class: flash_notify.alert_class } + .alert.alert-dismissable.text-center{ class: alert_class(flash_notify.status) } %button.close{ type: 'button', 'data-dismiss' => 'alert', 'aria-hidden' => true } × = flash_notify.body(I18n.locale).html_safe + = render 'layouts/noscript' + = render "layouts/flashes" + %article.container-fluid.offset20 = yield = render 'layouts/menu/new_bottom'