ultimate-flash 0.8.3 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +1,13 @@
1
1
  ###*
2
- * Ultimate Flash 0.8.3 - Ruby on Rails oriented jQuery plugin for smart notifications
2
+ * Ultimate Flash 0.9.0 - Ruby on Rails oriented jQuery plugin for smart notifications
3
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
  ###
7
7
 
8
8
  ###*
9
+ * * * DEPRECATED syntax!
10
+ *
9
11
  * $.fn.ultimateFlash() invoke Ultimate Flash functionality at first call on jQuery object
10
12
  * for the first element in the set of matched elements.
11
13
  * Subsequent calls forwarding on view methods or return view property.
@@ -22,29 +24,25 @@
22
24
  * auto .ultimateFlash('auto', {ArrayOrObject} obj) : {Array} ajFlashes | {Boolean} false
23
25
  * ajaxSuccess .ultimateFlash('ajaxSuccess'[, Arguments successArgs = []])
24
26
  * ajaxError .ultimateFlash('ajaxError'[, String text = translations.defaultErrorText][, Arguments errorArgs = []])
27
+ *
28
+ * * * USE INSTEAD
29
+ * @usage
30
+ * window.flash = new Ultimate.Plugin.Flash[(Object options = {})]
31
+ * flash.notice String text
25
32
  ###
26
33
 
27
34
  # TODO improve English
28
35
  # TODO jGrowl features
29
36
 
30
- #= require ultimate/jquery-plugin-class
31
37
  #= require ultimate/jquery-plugin-adapter
32
38
 
33
39
  Ultimate.Plugins ||= {}
34
40
 
35
- class Ultimate.Plugins.Flash extends Ultimate.Plugin
41
+ Ultimate.__FlashClass ||= Ultimate.Plugin
36
42
 
37
- el: '.l-page__flashes'
43
+ class Ultimate.Plugins.Flash extends Ultimate.__FlashClass
38
44
 
39
- @defaultLocales =
40
- en:
41
- defaultErrorText: 'Error'
42
- defaultThrownError: 'server connection error'
43
- formFieldsError: 'Form filled with errors'
44
- ru:
45
- defaultErrorText: 'Ошибка'
46
- defaultThrownError: 'ошибка соединения с сервером'
47
- formFieldsError: 'Форма заполнена с ошибками'
45
+ el: '.l-page__flashes'
48
46
 
49
47
  flashClass: 'flash' # css-class of message container
50
48
  showAjaxErrors: true # catch global jQuery.ajaxErrors(), try detect message and show it
@@ -88,6 +86,34 @@ class Ultimate.Plugins.Flash extends Ultimate.Plugin
88
86
  a = @_ajaxParseArguments(arguments)
89
87
  @ajaxSuccess a.data, a.jqXHR
90
88
 
89
+
90
+ _configure: (options) ->
91
+ super
92
+ @_initTranslations()
93
+
94
+ locale: 'en'
95
+ translations: null
96
+
97
+ @defaultLocales =
98
+ en:
99
+ defaultErrorText: 'Error'
100
+ defaultThrownError: 'server connection error'
101
+ formFieldsError: 'Form filled with errors'
102
+ ru:
103
+ defaultErrorText: 'Ошибка'
104
+ defaultThrownError: 'ошибка соединения с сервером'
105
+ formFieldsError: 'Форма заполнена с ошибками'
106
+
107
+ # use I18n, and modify locale and translations
108
+ _initTranslations: ->
109
+ @translations ||= {}
110
+ if not @options['locale'] and I18n?.locale of @constructor.defaultLocales
111
+ @locale = I18n.locale
112
+ _.defaults @translations, @constructor.defaultLocales[@locale]
113
+
114
+ t: (key) ->
115
+ @translations[key] or _.string.humanize(key)
116
+
91
117
  # delegate event for hide on click
92
118
  closeFlashClick: (event) ->
93
119
  jFlash = $(event.currentTarget)
@@ -95,6 +121,8 @@ class Ultimate.Plugins.Flash extends Ultimate.Plugin
95
121
  @hide jFlash
96
122
  false
97
123
 
124
+
125
+
98
126
  jFlashes: (filterSelector) ->
99
127
  _jFlashes = @$(".#{@flashClass}")
100
128
  if filterSelector then _jFlashes.filter(filterSelector) else _jFlashes
@@ -1,5 +1,5 @@
1
1
  module Ultimate
2
2
  module Flash
3
- VERSION = '0.8.3'
3
+ VERSION = '0.9.0'
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.3
4
+ version: 0.9.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: