garlicjs-rails 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/garlicjs-rails/version.rb +1 -1
- data/vendor/assets/javascripts/garlic.js +18 -19
- metadata +4 -4
data/README.md
CHANGED
@@ -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
|
109
|
+
if ( this.val === this.getVal() ) {
|
110
110
|
return;
|
111
111
|
}
|
112
112
|
|
113
|
-
this.val = this
|
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
|
-
|
121
|
-
|
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
|
-
|
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
|
402
|
-
, inputs: 'input, textarea, select'
|
403
|
-
, events: [ 'DOMAttrModified', 'textInput', 'input', 'change', 'keypress', 'paste', 'focus' ]
|
404
|
-
, domain: false
|
405
|
-
, expires: false
|
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:
|
408
|
-
, garlicPriority: true
|
409
|
-
, template: '<span class="garlic-swap"></span>'
|
410
|
-
, message: 'This is your saved data. Click here to see default one'
|
411
|
-
, onConflictDetected: function ( $item, storedVal ) { return true; }
|
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 ) {}
|
414
|
-
, onRetrieve: function ( $item, storedVal ) {}
|
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.
|
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-
|
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: -
|
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: -
|
70
|
+
hash: -3826722763077447348
|
71
71
|
requirements: []
|
72
72
|
rubyforge_project:
|
73
73
|
rubygems_version: 1.8.24
|