garlicjs-rails 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -31,7 +31,7 @@ And add the following line to your application layout (must be before garlicjs i
31
31
 
32
32
  ## Versioning
33
33
 
34
- garlicjs-rails 1.2.0 == Garlic.js 1.2.0
34
+ garlicjs-rails 1.2.1 == Garlic.js 1.2.1
35
35
 
36
36
  ## Contributing
37
37
 
@@ -1,5 +1,5 @@
1
1
  module Garlicjs
2
2
  module Rails
3
- VERSION = "1.2.0"
3
+ VERSION = "1.2.1"
4
4
  end
5
5
  end
@@ -106,23 +106,22 @@
106
106
  , persist: function () {
107
107
 
108
108
  // some binded events are redundant (change & paste for example), persist only once by field val
109
- if ( this.val === this.$element.val() ) {
109
+ if ( this.val === this.getVal() ) {
110
110
  return;
111
111
  }
112
112
 
113
- this.val = this.$element.val();
113
+ this.val = this.getVal();
114
114
 
115
115
  // if auto-expires is enabled, set the expiration date for future auto-deletion
116
116
  if ( this.options.expires ) {
117
117
  this.storage.set( this.expiresFlag , ( new Date().getTime() + this.options.expires * 1000 ).toString() );
118
118
  }
119
119
 
120
- // for checkboxes, we need to implement an unchecked / checked behavior
121
- if ( this.$element.is( 'input[type=checkbox]' ) ) {
122
- return this.storage.set( this.path , this.$element.attr( 'checked' ) ? 'checked' : 'unchecked' );
123
- }
120
+ this.storage.set( this.path , this.getVal() );
121
+ }
124
122
 
125
- this.storage.set( this.path , this.$element.val() );
123
+ , getVal: function () {
124
+ return !this.$element.is( 'input[type=checkbox]' ) ? this.$element.val() : ( this.$element.attr( 'checked' ) ? 'checked' : 'unchecked' );
126
125
  }
127
126
 
128
127
  /* retrieve localStorage data / state and update elem accordingly */
@@ -398,20 +397,20 @@
398
397
  $.fn.garlic.Constructor = Garlic;
399
398
 
400
399
  $.fn.garlic.defaults = {
401
- destroy: true // Remove or not localstorage on submit & clear
402
- , inputs: 'input, textarea, select' // Default supported inputs.
403
- , events: [ 'DOMAttrModified', 'textInput', 'input', 'change', 'keypress', 'paste', 'focus' ] // Events list that trigger a localStorage
404
- , domain: false // Store et retrieve forms data accross all domain, not just on
405
- , expires: false // false for no expiration, otherwise (int) in seconds for auto-expiration
400
+ destroy: true // Remove or not localstorage on submit & clear
401
+ , inputs: 'input, textarea, select' // Default supported inputs.
402
+ , events: [ 'DOMAttrModified', 'textInput', 'input', 'change', 'click', 'keypress', 'paste', 'focus' ] // Events list that trigger a localStorage
403
+ , domain: false // Store et retrieve forms data accross all domain, not just on
404
+ , expires: false // false for no expiration, otherwise (int) in seconds for auto-expiration
406
405
  , conflictManager: {
407
- enabled: true // Manage default data and persisted data. If false, persisted data will always replace default ones
408
- , garlicPriority: true // If form have default data, garlic persisted data will be shown first
409
- , template: '<span class="garlic-swap"></span>' // Template used to swap between values if conflict detected
410
- , message: 'This is your saved data. Click here to see default one' // Default message for swapping data / state
411
- , onConflictDetected: function ( $item, storedVal ) { return true; } // This function will be triggered if a conflict is detected on an item. Return true if you want Garlic behavior, return false if you want to override it
406
+ enabled: false // Manage default data and persisted data. If false, persisted data will always replace default ones
407
+ , garlicPriority: true // If form have default data, garlic persisted data will be shown first
408
+ , template: '<span class="garlic-swap"></span>' // Template used to swap between values if conflict detected
409
+ , message: 'This is your saved data. Click here to see default one' // Default message for swapping data / state
410
+ , onConflictDetected: function ( $item, storedVal ) { return true; } // This function will be triggered if a conflict is detected on an item. Return true if you want Garlic behavior, return false if you want to override it
412
411
  }
413
- , getPath: function ( $item ) {} // Set your own key-storing strategy per field
414
- , onRetrieve: function ( $item, storedVal ) {} // This function will be triggered each time Garlic find an retrieve a local stored data for a field
412
+ , getPath: function ( $item ) {} // Set your own key-storing strategy per field
413
+ , onRetrieve: function ( $item, storedVal ) {} // This function will be triggered each time Garlic find an retrieve a local stored data for a field
415
414
  }
416
415
 
417
416
  /* GARLIC DATA-API
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: garlicjs-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
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-02-02 00:00:00.000000000 Z
12
+ date: 2013-04-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -58,7 +58,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
58
58
  version: '0'
59
59
  segments:
60
60
  - 0
61
- hash: -1326770196954254873
61
+ hash: -3826722763077447348
62
62
  required_rubygems_version: !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
@@ -67,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
67
  version: '0'
68
68
  segments:
69
69
  - 0
70
- hash: -1326770196954254873
70
+ hash: -3826722763077447348
71
71
  requirements: []
72
72
  rubyforge_project:
73
73
  rubygems_version: 1.8.24