thin_man 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7505c23309e907eb80f25e8efb2dbbce0c0b6e84
4
- data.tar.gz: ae498426ab48b3cee758a0998b7dc4004b99f0e9
3
+ metadata.gz: c78fa7fda7cd7c1a392af814feb0302669c812b0
4
+ data.tar.gz: b945bb9dc6bd45f6baf3930efff768c09638dee7
5
5
  SHA512:
6
- metadata.gz: 77f3cdb8f2e7dcfcc56a77dcc03de079e78a4b24f32024eb661ed84b8888b397e1c10267209e2fc51f20a2574f45bcb3585b8e4f1a7978e178c9baf2fea973aa
7
- data.tar.gz: a7875b7830ade5ff848936c2bf2f1eca0cd375256f17570364c75bc3a06c65a209b7ebb5691103eeca540d0382839562fa5834e6067bcb0186ba64fbd709d4d8
6
+ metadata.gz: ab36ac0ec87222b67cf959fe9a4efc2a0a2384f85182e4b9a08030a0b68a24c5561012e75bdffbaf13dfc7fd7e990990d09694c11aa50897d453d47826c9e6c9
7
+ data.tar.gz: 55deb2c24be04ab2eb04739ec43616edbf4cf515efa03cec9a86bb65c21d6ce6fb4e9001b16ca69700cdcb4a29fef4b6da8be83624286a42469581e68ba1a7e8
@@ -142,11 +142,19 @@ var AjaxSubmission = Class.extend({
142
142
  // hmmm, the response is not JSON, so there's no flash.
143
143
  }
144
144
  if(typeof response_data.flash_message != 'undefined'){
145
- flash_style = this.httpResponseToFlashStyle(jqXHR.status)
145
+ var flash_style = this.httpResponseToFlashStyle(jqXHR.status);
146
+ var flash_duration = null;
147
+ if(typeof response_data.flash_persist != 'undefined'){
148
+ if(response_data.flash_persist){
149
+ flash_duration = 'persist'
150
+ } else {
151
+ flash_duration = 'fade'
152
+ }
153
+ }
146
154
  if(this.target){
147
- new AjaxFlash(flash_style, response_data.flash_message,this.target);
155
+ new AjaxFlash(flash_style, response_data.flash_message,this.target, flash_duration);
148
156
  }else{
149
- new AjaxFlash(flash_style, response_data.flash_message,this.jq_obj);
157
+ new AjaxFlash(flash_style, response_data.flash_message,this.jq_obj, flash_duration);
150
158
  }
151
159
  }
152
160
  if('function' == typeof this.params.on_complete){
@@ -241,16 +249,34 @@ var AjaxProgress = Class.extend({
241
249
  }
242
250
  });
243
251
  var AjaxFlash = Class.extend({
244
- init: function(type,message,elem){
252
+ init: function(type,message,elem,duration){
245
253
  this.flash_container = $('#thin-man-flash-container').clone();
246
254
  $('body').append(this.flash_container);
247
255
  this.flash_container.css({position:'absolute',visibility: 'hidden'});
256
+ this.alert_type = type;
257
+ this.elem = elem;
248
258
  var alert_class = 'alert-' + type;
249
259
  this.flash_container.addClass(alert_class);
250
260
  $('#thin-man-flash-content', this.flash_container).html(message);
251
261
  this.flash_container.show();
262
+ this.setFadeBehavior(duration);
252
263
  this.reposition(elem);
253
264
  },
265
+ setFadeBehavior: function(duration){
266
+ if(duration){
267
+ if('persist' == duration){
268
+ this.fade = false
269
+ } else {
270
+ this.fade = true
271
+ }
272
+ }else{ //default behavior if persist duration is not sent back with message
273
+ if('error' == this.alert_type || 'warning' == this.alert_type || 'info' == this.alert_type){
274
+ this.fade = false;
275
+ } else {
276
+ this.fade = true;
277
+ }
278
+ }
279
+ },
254
280
  reposition: function(elem){
255
281
  var this_window = {
256
282
  top: $(window).scrollTop(),
@@ -270,8 +296,8 @@ var AjaxFlash = Class.extend({
270
296
  var new_left = this_window.horiz_middle - this_flash.half_width;
271
297
  this.flash_container.css({left: new_left, top: new_top, visibility: 'visible'});
272
298
  var ajax_flash = this;
273
- if (! $('form', elem).data('ajax-flash-persist')) {
274
- setTimeout(function(){ajax_flash.fadeOut()},1000);
299
+ if (this.fade) {
300
+ setTimeout(function(){ajax_flash.fadeOut()},1618);
275
301
  }
276
302
  },
277
303
  fadeOut: function(){
@@ -1,3 +1,3 @@
1
1
  module ThinMan
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thin_man
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Draut, Adam Bialek