Code Monkey home page Code Monkey logo

growlyflash's Introduction

Growlyflash

The growlyflash gem turns boring ActionDispatch::Flash messages in your Rails app to asynchronous Growl-like notifications with Bootstrap Alert markup.

With XHR requests it places flash hash to the X-Messages HTTP header or inline in javascript.

Based on rewritten in coffeescript Bootstrap Growl plugin and inspired by Bootstrap Flash Messages

Update from versions below 0.5.0

Warning! Current version breaks integration from older releases, so, if you want to update, you should check installation and customization steps again.

Installation

Add this line to your application's Gemfile:

gem 'growlyflash'

Require one of the following Growlyflash javascripts depending on your Bootstrap version in app/assets/javascripts/application.js:

For Bootstrap 3

//= require growlyflash

For Bootstrap 2

//= require growlyflash.bs2

Import Growlyflash style in app/assets/stylesheets/application.css.scss after importing Bootstrap styles:

@import "growlyflash";

To use text flash messages as growl notifications with XHR request, add use_growlyflash to your controllers (usually application_controller.rb). This is a shorthand for append_after_action :flash_to_header, if: "request.xhr?" and takes callback parameters like only, except, if or unless:

use_growlyflash # except: %i[actions without growlyflash]

# Also there is another shorthand, to skip callbacks:
# skip_growlyflash only: %i[actions without growlyflash]

To make notifications also available with non-XHR requests, insert the following line into your layout template inside <head> tag before any other javascript:

<%= growlyflash_static_notices %>

If you want your website to be compliant with Content-Security-Policy, and especially avoid script-src: 'unsafe-inline', you can use another helper to render an html tag with data attributes instead of injecting javascript code into your page:

<%= growlyflash_tag %>

Customize

If you want to change default options, you can override them somewhere in your coffee/js:

Growlyflash.defaults = $.extend on, Growlyflash.defaults,
  align:   'right'  # horizontal aligning (left, right or center)
  delay:   4000     # auto-dismiss timeout (0 to disable auto-dismiss)
  dismiss: yes      # allow to show close button
  spacing: 10       # spacing between alerts
  target:  'body'   # selector to target element where to place alerts
  title:   no       # switch for adding a title
  type:    null     # bootstrap alert class by default
  class:   ['alert', 'growlyflash', 'fade']

Also you can override few style variables before the @import directive (or just manually override styles (look at _growlyflash.scss):

$growlyflash-top:     20px !default;
$growlyflash-side:    20px !default;
$growlyflash-width:   auto !default;
$growlyflash-zindex:  9999 !default;

@import "growlyflash";

Insert the following if you want to close alert boxes by clicking on themselves. Also it doesn't steel focus from toggled elements like dropdowns and works fine with touch devices, so I advise to use it:

jQuery ->
  $(document).on "touchstart.alert click.alert", ".growlyflash", (e) ->
    e.stopPropagation()
    ($ @).alert 'close'
    off

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

growlyflash's People

Contributors

ben-gy avatar coxy avatar dinuz avatar estum avatar grosser avatar klacointe avatar serggl avatar simmerer avatar vortizhe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

growlyflash's Issues

Turbolinks - click twice to close

The title almost says it all. I'm having to click the close button twice in order to get it to close. Tried various ways and nothing is getting it to close on the first click. Using the coffeescript code in README. Is this a known issue or am I just blanking on the solution. Cheers for the great gem!

Breaks in Ruby 3.x due to deprecation of URI.escape

Due to the deprecation of URI.escape (see ruby/uri@61c6a47 and ruby/uri#14), this gem will no longer work in Ruby 3.x based Rails projects.

Fix might be straightforward to replace with CGI.escape instead.

Specific error from a project using growlyflash 0.10.1:

NoMethodError (undefined method `escape' for URI:Module

        response.headers['X-Message'] = URI.escape(growlyhash.to_json)
                                           ^^^^^^^):

Support for triggering client side Flashes via JS

This would be pretty easy to implement as the code is really already there. You just need to expose an interface like this (this code worked for me - btw great gem, super helpful!)

Flash = new function() {
var self = this;

self.warning = function(msg) {
    flashMessage(msg, 'alert');
}

self.error = function(msg) {
    flashMessage(msg, 'error');
};

self.notice = function(msg) {
    flashMessage(msg, 'info');
}

self.success = function(msg) {
    flashMessage(msg, 'success');
}

function flashMessage(msg, type) {
    $.growlyflash(new Growlyflash.FlashStruct(msg, type))
}

}

deprecation warning is occurred when I add 'use_growlyflash'

I got this log when I add 'use_growlyflash' to application_controller.rb.

DEPRECATION WARNING: Passing string to be evaluated in :if and :unless conditional options is deprecated and will be removed in Rails 5.2 without replacement

Can you suggest any solution for this?
I am on 'Using growlyflash 0.10.0'

Thanks.

Remotipart - upload files with ajax

@estum I changed this issue completely, after further investigations and I am updating it now:

In the case I have an upload file that use remotipart https://github.com/JangoSteve/remotipart.git (this is the classic solution to upload files in rails using remote: true), due to the behaviour of the gem, my request will not be xhr type.
Under this circumstance, unfortunatelly the growlyflash gem cannot properly work (the gem checks for an xhr request only).

If you look in the remotipart gem they have an helper that return true if the request or the submit happened due to remotipart https://github.com/JangoSteve/remotipart/blob/master/lib/remotipart/request_helper.rb

What do you think if we include remotipart helper and modify the growly flash gem in order to keep using growlyflash also after this type of request?

I mean:

included do
  helper_method :growlyflash_static_notices, :growlyhash , "the remotipart helper" if remotipart exist
end

and

  def use_growlyflash(options = {})
    append_after_filter :flash_to_headers, options.reverse_merge(if: :is_xhr_request? || "the remotipart helper")
  end

or just modify the is_xhr_request? method in order to include there a check on the remotipart submission?

This will allow us to use the growlyflash gem also under a fake xhr request as the one made by remotipart (it use Iframe).

Or maybe you have some other alternatives and I would love to hear.

Please let me know what do you think?
I don't think is smart adding a dependence on the gem, but maybe adding a check could help.

Best
Dinuz

Remove :timedout not working in Rails 4.1

Flash messages:

Under Rails 4.0, the key is a Symbol.
Under Rails 4.1, the key is a String.

So, we need to do something like this .except!(:timedout, 'timedout')

SyntaxError: [stdin]:42:42: unexpected :

I'm running Rails 4 with Bootstrap 3. I have followed the instructions and installed the gem, added proper includes in applicaion js and css files.

However, adding the require in the application.js file and reloading the app page, I get:

SyntaxError: [stdin]:42:42: unexpected :

Stack:

apply.bare (<anonymous>:6:21)
eval (<anonymous>:16:2)
(execjs):13:8
(execjs):19:14
require./helpers.e ((execjs):1:102)
Object.<anonymous> ((execjs):1:120)
Module._compile (module.js:460:26)
Object.Module._extensions..js (module.js:478:10)
Module.load (module.js:355:32)
Function.Module._load (module.js:310:12)
Function.Module.runMain (module.js:501:10)
startup (node.js:129:16)
node.js:814:3
execjs (2.6.0) lib/execjs/external_runtime.rb:39:in `exec'
execjs (2.6.0) lib/execjs/external_runtime.rb:21:in `eval'
execjs (2.6.0) lib/execjs/external_runtime.rb:46:in `call'
coffee-script (2.3.0) lib/coffee_script.rb:76:in `compile'
sprockets (3.4.0) lib/sprockets/coffee_script_processor.rb:21:in `block in call'
sprockets (3.4.0) lib/sprockets/cache.rb:85:in `fetch'
sprockets (3.4.0) lib/sprockets/coffee_script_processor.rb:20:in `call'
sprockets (3.4.0) lib/sprockets/processor_utils.rb:75:in `call_processor'
sprockets (3.4.0) lib/sprockets/processor_utils.rb:57:in `block in call_processors'
sprockets (3.4.0) lib/sprockets/processor_utils.rb:56:in `reverse_each'
sprockets (3.4.0) lib/sprockets/processor_utils.rb:56:in `call_processors'
sprockets (3.4.0) lib/sprockets/loader.rb:134:in `load_from_unloaded'
sprockets (3.4.0) lib/sprockets/loader.rb:60:in `block in load'
sprockets (3.4.0) lib/sprockets/loader.rb:318:in `fetch_asset_from_dependency_cache'
sprockets (3.4.0) lib/sprockets/loader.rb:44:in `load'
sprockets (3.4.0) lib/sprockets/cached_environment.rb:20:in `block in initialize'
sprockets (3.4.0) lib/sprockets/cached_environment.rb:47:in `yield'
sprockets (3.4.0) lib/sprockets/cached_environment.rb:47:in `load'
sprockets (3.4.0) lib/sprockets/bundle.rb:23:in `block in call'
sprockets (3.4.0) lib/sprockets/utils.rb:183:in `dfs'
sprockets (3.4.0) lib/sprockets/bundle.rb:24:in `call'
sprockets (3.4.0) lib/sprockets/processor_utils.rb:75:in `call_processor'
sprockets (3.4.0) lib/sprockets/processor_utils.rb:57:in `block in call_processors'
sprockets (3.4.0) lib/sprockets/processor_utils.rb:56:in `reverse_each'
sprockets (3.4.0) lib/sprockets/processor_utils.rb:56:in `call_processors'
sprockets (3.4.0) lib/sprockets/loader.rb:134:in `load_from_unloaded'
sprockets (3.4.0) lib/sprockets/loader.rb:60:in `block in load'
sprockets (3.4.0) lib/sprockets/loader.rb:318:in `fetch_asset_from_dependency_cache'
sprockets (3.4.0) lib/sprockets/loader.rb:44:in `load'
sprockets (3.4.0) lib/sprockets/cached_environment.rb:20:in `block in initialize'
sprockets (3.4.0) lib/sprockets/cached_environment.rb:47:in `yield'
sprockets (3.4.0) lib/sprockets/cached_environment.rb:47:in `load'
sprockets (3.4.0) lib/sprockets/base.rb:66:in `find_asset'
sprockets (3.4.0) lib/sprockets/environment.rb:30:in `find_asset'
sprockets (3.4.0) lib/sprockets/base.rb:92:in `[]'
sprockets-rails (2.3.3) lib/sprockets/rails/helper.rb:230:in `lookup_asset_for_path'
sprockets-rails (2.3.3) lib/sprockets/rails/helper.rb:190:in `check_errors_for'
sprockets-rails (2.3.3) lib/sprockets/rails/helper.rb:137:in `block in javascript_include_tag'
sprockets-rails (2.3.3) lib/sprockets/rails/helper.rb:136:in `map'
sprockets-rails (2.3.3) lib/sprockets/rails/helper.rb:136:in `javascript_include_tag'
app/views/layouts/mobile.html.erb:10:in `_app_views_layouts_mobile_html_erb___4357399633193654801_70119466606260'
actionview (4.2.4) lib/action_view/template.rb:145:in `block in render'
activesupport (4.2.4) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.4) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.4) lib/active_support/notifications.rb:164:in `instrument'
actionview (4.2.4) lib/action_view/template.rb:333:in `instrument'
actionview (4.2.4) lib/action_view/template.rb:143:in `render'
actionview (4.2.4) lib/action_view/renderer/template_renderer.rb:66:in `render_with_layout'
actionview (4.2.4) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
actionview (4.2.4) lib/action_view/renderer/template_renderer.rb:14:in `render'
actionview (4.2.4) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionview (4.2.4) lib/action_view/renderer/renderer.rb:23:in `render'
actionview (4.2.4) lib/action_view/rendering.rb:100:in `_render_template'
actionpack (4.2.4) lib/action_controller/metal/streaming.rb:217:in `_render_template'
actionview (4.2.4) lib/action_view/rendering.rb:83:in `render_to_body'
actionpack (4.2.4) lib/action_controller/metal/rendering.rb:32:in `render_to_body'
actionpack (4.2.4) lib/action_controller/metal/renderers.rb:37:in `render_to_body'
actionpack (4.2.4) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (4.2.4) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (4.2.4) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
activesupport (4.2.4) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/Users/yuri/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/benchmark.rb:303:in `realtime'
activesupport (4.2.4) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (4.2.4) lib/action_controller/metal/instrumentation.rb:44:in `block in render'
actionpack (4.2.4) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
activerecord (4.2.4) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (4.2.4) lib/action_controller/metal/instrumentation.rb:43:in `render'
wicked_pdf (0.11.0) lib/wicked_pdf/pdf_helper.rb:23:in `render_with_wicked_pdf'
actionpack (4.2.4) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (4.2.4) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (4.2.4) lib/abstract_controller/base.rb:198:in `process_action'
actionpack (4.2.4) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.2.4) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.2.4) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.4) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.4) lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
activesupport (4.2.4) lib/active_support/callbacks.rb:505:in `call'
activesupport (4.2.4) lib/active_support/callbacks.rb:505:in `call'
activesupport (4.2.4) lib/active_support/callbacks.rb:498:in `block (2 levels) in around'
activesupport (4.2.4) lib/active_support/callbacks.rb:313:in `call'
activesupport (4.2.4) lib/active_support/callbacks.rb:313:in `block (2 levels) in halting'
app/controllers/application_controller.rb:53:in `set_locale'
activesupport (4.2.4) lib/active_support/callbacks.rb:432:in `block in make_lambda'
activesupport (4.2.4) lib/active_support/callbacks.rb:312:in `call'
activesupport (4.2.4) lib/active_support/callbacks.rb:312:in `block in halting'
activesupport (4.2.4) lib/active_support/callbacks.rb:497:in `call'
activesupport (4.2.4) lib/active_support/callbacks.rb:497:in `block in around'
activesupport (4.2.4) lib/active_support/callbacks.rb:505:in `call'
activesupport (4.2.4) lib/active_support/callbacks.rb:505:in `call'
activesupport (4.2.4) lib/active_support/callbacks.rb:498:in `block (2 levels) in around'
activesupport (4.2.4) lib/active_support/callbacks.rb:313:in `call'
activesupport (4.2.4) lib/active_support/callbacks.rb:313:in `block (2 levels) in halting'
app/controllers/application_controller.rb:46:in `set_time_zone'
activesupport (4.2.4) lib/active_support/callbacks.rb:432:in `block in make_lambda'
activesupport (4.2.4) lib/active_support/callbacks.rb:312:in `call'
activesupport (4.2.4) lib/active_support/callbacks.rb:312:in `block in halting'
activesupport (4.2.4) lib/active_support/callbacks.rb:497:in `call'
activesupport (4.2.4) lib/active_support/callbacks.rb:497:in `block in around'
activesupport (4.2.4) lib/active_support/callbacks.rb:505:in `call'
activesupport (4.2.4) lib/active_support/callbacks.rb:505:in `call'
activesupport (4.2.4) lib/active_support/callbacks.rb:92:in `__run_callbacks__'
activesupport (4.2.4) lib/active_support/callbacks.rb:778:in `_run_process_action_callbacks'
activesupport (4.2.4) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.4) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.2.4) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.2.4) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (4.2.4) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.4) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.4) lib/active_support/notifications.rb:164:in `instrument'
actionpack (4.2.4) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.2.4) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.2.4) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.2.4) lib/abstract_controller/base.rb:137:in `process'
actionview (4.2.4) lib/action_view/rendering.rb:30:in `process'
actionpack (4.2.4) lib/action_controller/metal.rb:196:in `dispatch'
actionpack (4.2.4) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.2.4) lib/action_controller/metal.rb:237:in `block in action'
actionpack (4.2.4) lib/action_dispatch/routing/route_set.rb:76:in `call'
actionpack (4.2.4) lib/action_dispatch/routing/route_set.rb:76:in `dispatch'
actionpack (4.2.4) lib/action_dispatch/routing/route_set.rb:45:in `serve'
actionpack (4.2.4) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.4) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.4) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.4) lib/action_dispatch/routing/route_set.rb:821:in `call'
message_bus (1.0.9) lib/message_bus/rack/middleware.rb:55:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `catch'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
rack (1.6.4) lib/rack/etag.rb:24:in `call'
rack (1.6.4) lib/rack/conditionalget.rb:25:in `call'
rack (1.6.4) lib/rack/head.rb:13:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.4) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
activerecord (4.2.4) lib/active_record/migration.rb:377:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.4) lib/active_support/callbacks.rb:88:in `__run_callbacks__'
activesupport (4.2.4) lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
activesupport (4.2.4) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.4) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
web-console (2.2.1) lib/web_console/middleware.rb:39:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
lograge (0.3.4) lib/lograge/rails_ext/rack/logger.rb:15:in `call_app'
railties (4.2.4) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.4) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.4) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.4) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.4) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.4) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.4) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/static.rb:116:in `call'
rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
rack-cors (0.4.0) lib/rack/cors.rb:80:in `call'
sentry-raven (0.15.2) lib/raven/integrations/rack.rb:54:in `call'
railties (4.2.4) lib/rails/engine.rb:518:in `call'
railties (4.2.4) lib/rails/application.rb:165:in `call'
puma (2.11.3) lib/puma/rack_patch.rb:13:in `call'
puma (2.11.3) lib/puma/configuration.rb:51:in `call'
puma (2.11.3) lib/puma/server.rb:507:in `handle_request'
puma (2.11.3) lib/puma/server.rb:375:in `process_client'
puma (2.11.3) lib/puma/server.rb:262:in `block in run'
puma (2.11.3) lib/puma/thread_pool.rb:104:in `call'
puma (2.11.3) lib/puma/thread_pool.rb:104:in `block in spawn_thread'

Webpacker

Hi, is there a way I can import the assets from this gem into webpacker managed assets so I don't have to use the asset pipeline as well? Thanks in advance

Regression? Title appeared after upgrading to 0.8.5

After upgrading to 0.8.5 I now see all alerts have the title showing (the "Info!" part). When I revert back to 0.8.4.1 the title went away.

alert_with_title

My setting has title turned off:

Growlyflash.defaults = $.extend on, Growlyflash.defaults,
  align:   'right'  # horizontal aligning (left, right or center)
  delay:   4000     # auto-dismiss timeout (0 to disable auto-dismiss)
  dismiss: yes      # allow to show close button
  spacing: 10       # spacing between alerts
  target:  'body'   # selector to target element where to place alerts
  title:   no       # switch for adding a title

Is this a regression/bug?

Turbolinks?

It looks like turbolinks interferes with the operation of this gem. I haven't dug in yet. Is there a fix for Rails5/Turbolinks3?

$.growlyflash is not a function

I followed the instructions and am using Rails 4.2.5 but getting the error

$.growlyflash is not a function

image

Following is my application.js.coffee

#= require jquery2
#= require jquery_ujs
#= require bootstrap-sprockets
#= require cocoon
#= require knockoutjs/build/output/knockout-latest.js
#= require growlyflash
#= require_tree
#= require_self

Style CSS conflict Rails 4.1

Hello, i'm using this gorgeous gem but i'm finding some issues with the "flash[:alert]" messages, because when the message displays it is doing it without a text bubble, it only displays the text with the delete button, but the "flash[:notice]" is displaying it ok.

What do you recommend me something to avoid this issues please?

Thanks

Alert gets not removed after fade out

The alert message gets not removed after it was faded out. That means that the position of a new alert is wrong because the html tag of the old one still exists. Have a look at my pull request and merge it if you agree.

Error on auto dismiss

Hi, on new version 0.8.0, I've getting an error TypeError: this.el.alert is not a function on auto dismiss.

XHR notices don't work where as non XHR does

I have installed and setup the gem as shown in readme.
Normal notices or shown but when something done with ajax, no notice is shown.
I added use_growlyflash in application controller.
Am i missing any configuration ?

Issue with the version 0.6.0: couldn't find file 'growlyflash' (js)

Hi @estum,

I tried out the new version of growlyflash, and I get a weird message:

couldn't find file 'growlyflash' in app/assets/javascripts/application.js

I thought at the beginning that it was related with me updating my ruby version, but after I immediately realized it was related with the new growlyflash version.

I kept everything the same (with my upgrade ruby version, and rails 4.2), and I just downgraded growlyflash to the 0.5.0 version, and everything was working well.

I didn't look into the new addition in the code, but I cannot load the growlyflash.js for the life of me using the 0.6.0 version.

Do you have any idea?

Quick question.

I just installed the gem. Love the easy integration, however I found some trouble.

There are no documents on how to test this.

I am using rspec and capybara. It totally works out side of testing, but when I look for the css selectors, they are not there when I go to test.

Any help would be great.

Issue in centering the alert

@estum

First of all thanks so much for this great gem.

I noticed that the plugin works fine with different screen size, using the bootstrap responsive functionalities.

Unfortunately the only issue that I have found is related with the horizontal centering of the alert when the width of the screen size become smaller (in my case happen around 400px). In that condition, the calculation for the left-margin are wrong, and always kind of short (the alert instead of been centered is just displaced on the right side of the screen).

I have a proposal to avoid this type of issue (ant it can work for the horizontal and eventually the vertical centering of the alert in the screen). To me this make kind of sense, in this way the user always have centered the message (anyway, either in fixed or in absolute position, it is out of the flow of the page and not breaks the layout - it works a bit as a modal).

Using the following library: https://github.com/tysonmatanich/viewportSize

we can easily integrate a viewportsize functionality in the code, and doing something like I do with modal object:

function modal_on_show(modal_element) {
    modal_element.on('show', function(event) {
        if(event.target === this){
            $('body').css({'overflow-y' : 'hidden'});
            var modal = $(this);

            var width = viewportSize.getWidth();
            var height = viewportSize.getHeight();

            modal.css('margin-top', ((height - modal.outerHeight()) / 2))
           .css('margin-left', ((width - modal.outerWidth()) / 2))
           .css('left', 0+'px')
           .css('top', 0+'px');

          return this;
        }
    });
}

What do you think? we can just translate this idea in coffee if you prefer.

Best
Dinuz

Customize. Deploy fails

Hello,

I must be doing something wrong. I paste the custom styles on application.js and when I deploy I get error.

$.bootstrapGrowl.defaults = $.extend on, $.bootstrapGrowl.defaults, width: 250 delay: 4000 spacing: 10 target: 'body' dismiss: true type: success align: 'center' alignAmount: 20 offset: from: 'top' amount: 20

Where should I insert the customizing code and how?

Thankyou!

[Question] How to configure it?

Hi! This gem is awesome!

One question... On Rails 4.1, let's say I want to change:

Growlyflash.defaults = $.extend on, Growlyflash.defaults,
  align:   'center'  # horizontal aligning (left, right or center)
  delay:   4000     # auto-dismiss timeout (0 to disable auto-dismiss)
  dismiss: yes      # allow to show close button
  spacing: 10       # spacing between alerts
  target:  'body'   # selector to target element where to place alerts
  type:    null     # bootstrap alert class by default
  class:   ['alert', 'growlyflash', 'fade']

Just as documented so I can center the notification. How/Where do I put this script?

Thanks!

Not getting AJAX flashes

Thanks for fixing the earlier issue. Static flashes are working now.

I am not seeing AJAX flashes in spite of getting the X-Message: Header in the response. I am using data-remote on a form POST submit link. Maybe the event names have changed. I tried some breakpoints in the listener, but it does not get triggered. I am using Rails 4.2.5 without turbolinks.

image

image

I have use_growlyflash in my application_controller and am getting the X-Message:
X-Message:%7B%22notice%22:%22Succesfully%20saved%20Field%20Values%22%7D

Flash messages with xhr break in Rails 5.1.5

Hi,

Flash messages with xhr no longer works in Rails 5.1.5 because of the following:

Like this page said:
As of Rails 5.1 and the new rails-ujs, the parameters data, status, xhr have been bundled into event.detail. For information about the previously used jquery-ujs in Rails 5 and earlier, read the jquery-ujs wiki.

I think the reason is that the following code no longer works (in Listener class):

 constructor: (context) ->
    @stack ?= new Stack()
    @process_static(context)
    ($ context).on Growlyflash.Listener.EVENTS, (event, xhr) =>
      if xhr ?= event.data?.xhr # now returns false 
        source = process_from_header(xhr.getResponseHeader(Growlyflash.Listener.HEADER))
        @stack.push_only_fresh source
      return

As a quick fix, I patch that method removing the test but I don't know if it could produce any side effect...

title: true override setting results in error: TypeError: s.replace is not a function

Without any other configuration, changing the hash option title: true in javascript results in an error message in the console pointing to s.replace in line 36.

    Growlyflash.DISMISS = "<button type=\"close\" class=\"close\" data-dismiss=\"alert\" aria-label=\"Close\"><span aria-hidden=\"true\">&times;</span></button>";

    _titleize = function(s) {
      return s.replace(/^./, function(m) {
        return m.toUpperCase();
      });
    };

Rails 4 support

It doesn't work with latest Rails version 4.0.

Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Bundler could not find compatible versions for gem "railties":
  In Gemfile:
    growlyflash (>= 0) java depends on
      railties (~> 3.1) java

    rails (= 4.0.1) java depends on
      railties (4.0.1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.