garlicjs-rails 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
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.1.2 == Garlic.js 1.1.2
34
+ garlicjs-rails 1.2.0 == Garlic.js 1.2.0
35
35
 
36
36
  ## Contributing
37
37
 
@@ -1,5 +1,5 @@
1
1
  module Garlicjs
2
2
  module Rails
3
- VERSION = "1.1.2"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
@@ -82,7 +82,7 @@
82
82
  this.$element = $( element );
83
83
  this.options = this.getOptions( options );
84
84
  this.storage = storage;
85
- this.path = this.getPath();
85
+ this.path = this.options.getPath( this.$element ) || this.getPath();
86
86
  this.parentForm = this.$element.closest( 'form' );
87
87
  this.$element.addClass('garlic-auto-save');
88
88
  this.expiresFlag = !this.options.expires ? false : ( this.$element.data( 'expires' ) ? this.path : this.getPath( this.parentForm ) ) + '_flag' ;
@@ -276,6 +276,10 @@
276
276
  elem = this.$element;
277
277
  }
278
278
 
279
+ if ( this.options.getPath( elem ) ) {
280
+ return this.options.getPath( elem );
281
+ }
282
+
279
283
  // Requires one element.
280
284
  if ( elem.length != 1 ) {
281
285
  return false;
@@ -404,9 +408,10 @@
404
408
  , garlicPriority: true // If form have default data, garlic persisted data will be shown first
405
409
  , template: '<span class="garlic-swap"></span>' // Template used to swap between values if conflict detected
406
410
  , message: 'This is your saved data. Click here to see default one' // Default message for swapping data / state
407
- , 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
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
408
412
  }
409
- , onRetrieve: function ( item, storedVal ) {} // This function will be triggered each time Garlic find an retrieve a local stored data for a field
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
410
415
  }
411
416
 
412
417
  /* 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.1.2
4
+ version: 1.2.0
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-01-02 00:00:00.000000000 Z
12
+ date: 2013-02-02 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: -2766940448262897459
61
+ hash: -1326770196954254873
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: -2766940448262897459
70
+ hash: -1326770196954254873
71
71
  requirements: []
72
72
  rubyforge_project:
73
73
  rubygems_version: 1.8.24