foreign_office 0.13.0 → 0.14.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: 21cc8423d3c2968af39056f4d38ab4fe9b6f1595
4
- data.tar.gz: ce68f970618fdf2942424c28ff59785a69d9880b
3
+ metadata.gz: d52a84688cf5ff06aa54de9bc51be17de548a743
4
+ data.tar.gz: 94dd508cdaa0210dd6d794b2620501b70c8076a8
5
5
  SHA512:
6
- metadata.gz: 2b5253d0ecbcae1e0dbfcf455a57f5e1015d634426dbb0b29defe8c0712a0e41a5b224d729eddea74be2e7a05f24e4927116c338838acf355a2725eb7f7098f4
7
- data.tar.gz: 08d8f94809996bea13066400747bc241c7fc26b809d9869230b76b2e6dabad8145f526c15471adfed6af19a9fe0f6247217c283d27ae51edcc9c4095fe3c913b
6
+ metadata.gz: 42bcdc01c9a2fbd8580a4500816702f3e4efe4f2ff626fa95a11d34cf72de5ae667fc4af80cbd33c5e282dd0d22bf6e48eb677515344b05fc4e410d5614c8c2f
7
+ data.tar.gz: 561668e5074b7d894afd866790e215049da54966a76ebcc43d7d70505b78414eacfb191e8e44668b1c0acfae932af1809347d0c4c14e1f1997da1b6d3cb76def
@@ -101,6 +101,21 @@ var ForeignOfficeChannel = Class.extend({
101
101
  },
102
102
  addListener: function(listener){
103
103
  this.listeners.push(listener);
104
+ //need to ensure forms are last in the list, so that inputs
105
+ //will be updated before forms are submitted
106
+ //NB. this will only work if the form and its inputs share the same channel
107
+ //since we can't control the order of channel messages coming across the wire
108
+ this.listeners.sort(function(a,b){
109
+ var a_kind = a.$listener.get(0).nodeName.toLowerCase()
110
+ var b_kind = b.$listener.get(0).nodeName.toLowerCase()
111
+ if(('form' != a_kind) && ('form' == b_kind)){
112
+ return -1
113
+ }
114
+ if(('form' == a_kind) && ('form' != b_kind)){
115
+ return 1
116
+ }
117
+ return 0 //('form' == a_kind) && ('form' == b_kind)
118
+ })
104
119
  }
105
120
  });
106
121
 
@@ -119,6 +134,9 @@ var ForeignOfficeListener = Class.extend({
119
134
  },
120
135
  handleMessage: function(m){
121
136
  var $listener = this.$listener;
137
+ if(!m.object.hasOwnProperty(this.object_key) && !m.object.hasOwnProperty(this.delete_key)){
138
+ return true
139
+ }
122
140
  if(this.endpoint){
123
141
  if (m.object[this.object_key] == true) {
124
142
  $.get(this.endpoint, function(data){
@@ -155,7 +173,9 @@ var ForeignOfficeListener = Class.extend({
155
173
  }
156
174
  break;
157
175
  case 'select':
158
- this.$listener.find('option[value="' + new_value + '"]').attr('selected','selected')
176
+ if(this.$listener.val() != ('' + new_value)){
177
+ this.$listener.val('' + new_value).change()
178
+ }
159
179
  this.$listener.trigger("chosen:updated")
160
180
  break;
161
181
 
@@ -178,6 +198,8 @@ var ForeignOfficeListener = Class.extend({
178
198
  }
179
199
  if(this.$listener.data('ajax-link')){
180
200
  this.$listener.trigger('apiclick');
201
+ }else if(this.$listener.data('ajax-form')){
202
+ this.$listener.trigger('apisubmit');
181
203
  }else{
182
204
  window.location = new_value;
183
205
  }
@@ -1,3 +1,3 @@
1
1
  module ForeignOffice
2
- VERSION = "0.13.0"
2
+ VERSION = "0.14.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreign_office
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Draut
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-01-27 00:00:00.000000000 Z
12
+ date: 2017-01-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails