ultimate-flash 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  ###*
2
- * Ultimate Flash 0.7.1 - Ruby on Rails oriented jQuery plugin for smart notifications
3
- * Copyright 2011-2012 Karpunin Dmitry (KODer) / Evrone.com
2
+ * Ultimate Flash 0.8.2 - Ruby on Rails oriented jQuery plugin for smart notifications
3
+ * Copyright 2011-2013 Karpunin Dmitry (KODer) / Evrone.com
4
4
  * Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
5
5
  *
6
6
  ###
@@ -54,6 +54,7 @@ class Ultimate.Plugins.Flash extends Ultimate.Plugin
54
54
  detectPlainTextMaxLength: 200 # if response has plain text and its length fits, show it (-1 for disable)
55
55
  productionMode: true
56
56
 
57
+ maxFlashes: 0 # maximum flash messages in one time
57
58
  slideTime: 200 # show and hide animate duration
58
59
  showTime: 3600 # base time for show flash message
59
60
  showTimePerChar: 30 # show time per char of flash message
@@ -123,14 +124,22 @@ class Ultimate.Plugins.Flash extends Ultimate.Plugin
123
124
  jFlashes.each (index, element) =>
124
125
  jFlash = $(element)
125
126
  clearTimeout jFlash.data('timeoutId')
126
- jFlash.slideUp @_getOptionOverFlash('slideTime', jFlash), =>
127
+ jFlash.addClass('hide').slideUp @_getOptionOverFlash('slideTime', jFlash), =>
127
128
  jFlash.remove() if @_getOptionOverFlash('removeOnHide', jFlash)
128
129
 
130
+ _append: (jFlash) ->
131
+ jFlash.appendTo @$el
132
+
129
133
  show: (type, text, timeout = null, perFlashOptions = null) ->
130
134
  text = @_prepareText(text, perFlashOptions)
131
135
  return false if not _.isString(text) or _.string.isBlank(text)
136
+ if @maxFlashes
137
+ jActiveFlashes = @jFlashes(':not(.hide)')
138
+ excessFlashes = jActiveFlashes.length - (@maxFlashes - 1)
139
+ if excessFlashes > 0
140
+ @hide jActiveFlashes.slice(0, excessFlashes)
132
141
  jFlash = $("<div class=\"#{@flashClass} #{type}\" style=\"display: none;\">#{text}</div>")
133
- jFlash.appendTo(@$el).slideDown @_getOptionOverFlash('slideTime', perFlashOptions)
142
+ @_append(jFlash).slideDown @_getOptionOverFlash('slideTime', perFlashOptions)
134
143
  if perFlashOptions
135
144
  jFlash.data(key, value) for key, value of perFlashOptions
136
145
  @_setTimeout jFlash, timeout
@@ -1,5 +1,5 @@
1
1
  module Ultimate
2
2
  module Flash
3
- VERSION = '0.8.1'
3
+ VERSION = '0.8.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ultimate-flash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-31 00:00:00.000000000 Z
12
+ date: 2013-04-01 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Ruby on Rails oriented jQuery plugin for smart notifications
15
15
  email: