foreign_office 0.15.12 → 0.16.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: 325ba8a4518dc69892add11cc324fa8572ea799a
4
- data.tar.gz: 4a22aa76e8461d2bf2d318c29614da1db1f271a1
3
+ metadata.gz: c2de91fc96446054ec1140b1abe152bc1776e9cf
4
+ data.tar.gz: 1b99de5a4721b53894230d6cd47046894c1203ad
5
5
  SHA512:
6
- metadata.gz: 909917d0c42580d95388e0caa10659c09100742833435f2ed569a4fadc97f3457b98058984be25da118397608f46cc0cfc4311406f260415046832d52d73bb0b
7
- data.tar.gz: f0b30d0f5750b1f348bc977b611e8de527c5dbc5cc5625df5df8594553b846f172fb2d19ad160c37ff1aa2684f00663777a559ed9ae9e6ca53bca913470ac945
6
+ metadata.gz: af62c31292bca5b0f6c2054cee6a5bddf9f12b022987efe8feb533cccd5836c3ea90c8caec051c8c3e7d80200dd5f0bfabbd1f9c86ae9b14d77e9ff2e52502c6
7
+ data.tar.gz: f4c4a53a322aa615716d86c8ddbc8705d176b109a6ef187bcdedab3af05bb74bd0ae22026c34b1c95b7bda5397f81e7bea003552ee06c1bb85c7b83856ba1cb0
@@ -136,6 +136,7 @@ var ForeignOfficeListener = Class.extend({
136
136
  init: function($listener){
137
137
  this.$listener = $listener;
138
138
  $listener.data('foreign_office.ForeignOfficeListener',this)
139
+ this.exclude_value = $listener.data('exclude-value');
139
140
  this.endpoint = $listener.data('endpoint');
140
141
  this.reveal_hide = $listener.data('reveal-hide');
141
142
  this.object_key = $listener.data('key');
@@ -161,11 +162,13 @@ var ForeignOfficeListener = Class.extend({
161
162
  handleMessage: function(m){
162
163
  var $listener = this.$listener;
163
164
  var listener = this
164
- if(!m.object.hasOwnProperty(this.object_key) && !m.object.hasOwnProperty(this.delete_key)){
165
+ var message_value = m.object[this.object_key]
166
+ if((!m.object.hasOwnProperty(this.object_key) && !m.object.hasOwnProperty(this.delete_key)) ||
167
+ (this.exclude_value && message_value == this.exclude_value)){
165
168
  return true
166
169
  }
167
170
  if(this.endpoint){
168
- if (m.object[this.object_key] == true) {
171
+ if (message_value == true) {
169
172
  listener.maskMe()
170
173
  $.get(this.endpoint, function(data){
171
174
  $listener.html(data);
@@ -174,29 +177,28 @@ var ForeignOfficeListener = Class.extend({
174
177
  })
175
178
  }else if(m.object[this.object_key] == false) {
176
179
  $listener.empty();
177
- }else if(typeof(m.object[this.object_key]) == 'string'){
180
+ }else if(typeof(message_value) == 'string'){
178
181
  listener.maskMe()
179
- $.get(m.object[this.object_key], function(data){
182
+ $.get(message_value, function(data){
180
183
  $listener.html(data);
181
184
  }).always(function(){
182
185
  listener.unMaskMe()
183
186
  })
184
187
  }
185
- if (m.object[this.delete_key] == true) {
188
+ if (message_value == true) {
186
189
  $listener.remove();
187
190
  }
188
191
  }else if(this.reveal_hide){
189
- var current_value = m.object[this.object_key];
190
- if(!current_value || current_value == 'false' || current_value == 'hide'){
192
+ if(!message_value || message_value == 'false' || message_value == 'hide'){
191
193
  this.$listener.hide();
192
194
  } else {
193
195
  this.$listener.removeClass('hidden');
194
196
  this.$listener.show();
195
197
  }
196
198
  }else if(this.href_target){
197
- this.$listener.attr('href',m.object[this.object_key])
199
+ this.$listener.attr('href',message_value)
198
200
  }else if(this.create_modal){
199
- if (m.object[this.object_key] == true) {
201
+ if (message_value && message_value != 'false') {
200
202
  var $modal_content = $('<div>').html($(this.create_modal).html());
201
203
  var modal = new hooch.Modal($modal_content);
202
204
  modal.$dismisser.remove();
@@ -204,35 +206,34 @@ var ForeignOfficeListener = Class.extend({
204
206
  delete modal.$dismisser;
205
207
  }
206
208
  }else{
207
- var new_value = m.object[this.object_key];
208
209
  switch(this.$listener.get(0).nodeName.toLowerCase()){
209
210
  case 'input':
210
211
  if(this.$listener.attr('type') == 'checkbox'){
211
- this.$listener.prop('checked', new_value);
212
+ this.$listener.prop('checked', message_value);
212
213
  } else {
213
- this.$listener.val(new_value);
214
+ this.$listener.val(message_value);
214
215
  }
215
216
  break;
216
217
  case 'select':
217
- if(this.$listener.val() != ('' + new_value)){
218
- this.$listener.val('' + new_value).change()
218
+ if(this.$listener.val() != ('' + message_value)){
219
+ this.$listener.val('' + message_value).change()
219
220
  }
220
221
  this.$listener.trigger("chosen:updated")
221
222
  break;
222
223
 
223
224
  case 'img':
224
- this.$listener.prop('src',new_value);
225
+ this.$listener.prop('src',message_value);
225
226
  break;
226
227
 
227
228
  case 'progress':
228
- this.$listener.attr('value',new_value)
229
+ this.$listener.attr('value',message_value)
229
230
  break;
230
231
 
231
232
  default:
232
233
  if(this.$listener.data('trigger-on-message') || this.$listener.data('download')){
233
- if(new_value && (new_value != 'false')){
234
- if((new_value != true) && (new_value != 'true')){
235
- this.$listener.attr('href',new_value);
234
+ if(message_value && (message_value != 'false')){
235
+ if((message_value != true) && (message_value != 'true')){
236
+ this.$listener.attr('href',message_value);
236
237
  }
237
238
  if(this.progress_indicator){
238
239
  this.progress_indicator.stop();
@@ -242,15 +243,15 @@ var ForeignOfficeListener = Class.extend({
242
243
  }else if(this.$listener.data('ajax-form')){
243
244
  this.$listener.trigger('apisubmit');
244
245
  }else if(this.$listener.data('download')){
245
- window.open(new_value);
246
+ window.open(message_value);
246
247
  }else{
247
- window.location = new_value;
248
+ window.location = message_value;
248
249
  }
249
250
  }
250
251
  }else if (m.object[this.delete_key] == true) {
251
252
  $listener.remove();
252
253
  }else{
253
- this.$listener.html(new_value);
254
+ this.$listener.html(message_value);
254
255
  }
255
256
  break;
256
257
  }
@@ -1,12 +1,15 @@
1
1
  module ForeignOffice
2
2
  module ForeignOfficeHelper
3
- def listener_attrs(resource, key, reveal_hide: false, endpoint: nil, download: nil, trigger: nil, delete: nil, href_target: nil, create_modal: nil, mask_me: nil)
3
+ def listener_attrs(resource, key, reveal_hide: false, endpoint: nil, download: nil,
4
+ trigger: nil, delete: nil, href_target: nil, create_modal: nil, mask_me: nil,
5
+ exclude_value: nil)
4
6
  data_attrs = "data-listener=true data-channel=#{resource.class.name}#{resource.id}"
5
7
  if delete
6
8
  data_attrs += " data-delete-key=#{key}"
7
9
  else
8
10
  data_attrs += " data-key=#{key}"
9
11
  end
12
+ data_attrs += " data-exclude-value=#{exclude_value}" if exclude_value
10
13
  data_attrs += " data-reveal-hide=true" if reveal_hide
11
14
  data_attrs += " data-endpoint=#{endpoint}" if endpoint
12
15
  data_attrs += " data-trigger-on-message=true" if trigger
@@ -22,7 +25,9 @@ module ForeignOffice
22
25
  data_attrs += " data-key=#{key}"
23
26
  end
24
27
 
25
- def listener_attrs_raw(channel, key, reveal_hide: false, endpoint: nil, download: nil, trigger: nil, delete: nil, href_target: nil, create_modal: nil, mask_me: nil)
28
+ def listener_attrs_raw(channel, key, reveal_hide: false, endpoint: nil, download: nil,
29
+ trigger: nil, delete: nil, href_target: nil, create_modal: nil, mask_me: nil,
30
+ exclude_value: nil)
26
31
  data_attrs = "data-listener=true data-channel=#{channel}"
27
32
  if delete
28
33
  data_attrs += " data-delete-key=#{key}"
@@ -30,6 +35,7 @@ module ForeignOffice
30
35
  data_attrs += " data-key=#{key}"
31
36
  end
32
37
  data_attrs += " data-reveal-hide=true" if reveal_hide
38
+ data_attrs += " data-endpoint=#{exclude_value}" if exclude_value
33
39
  data_attrs += " data-endpoint=#{endpoint}" if endpoint
34
40
  data_attrs += " data-download=true" if download
35
41
  data_attrs += " data-trigger-on-message=true" if trigger
@@ -39,7 +45,9 @@ module ForeignOffice
39
45
  data_attrs
40
46
  end
41
47
 
42
- def listener_hash(resource, key, reveal_hide: false, endpoint: nil, download: nil, trigger: nil, delete: nil, href_target: nil, create_modal: nil, mask_me: nil)
48
+ def listener_hash(resource, key, reveal_hide: false, endpoint: nil, download: nil,
49
+ trigger: nil, delete: nil, href_target: nil, create_modal: nil, mask_me: nil,
50
+ exclude_value: nil)
43
51
  hash = {listener: true, channel: resource.class.name + resource.id.to_s}
44
52
  if delete
45
53
  hash[:delete_key] = key
@@ -48,6 +56,7 @@ module ForeignOffice
48
56
  end
49
57
  hash[:reveal_hide] = true if reveal_hide
50
58
  hash[:endpoint] = endpoint if endpoint
59
+ hash[:exclude_value] = exclude_value if exclude_value
51
60
  hash[:download] = true if download
52
61
  hash[:trigger_on_message] = true if trigger
53
62
  hash[:href_target] = true if href_target
@@ -56,7 +65,9 @@ module ForeignOffice
56
65
  hash
57
66
  end
58
67
 
59
- def listener_hash_raw(channel, key, reveal_hide: false, endpoint: nil, download: nil, trigger: nil, delete: nil, href_target: nil, create_modal: nil, mask_me: nil)
68
+ def listener_hash_raw(channel, key, reveal_hide: false, endpoint: nil, download: nil,
69
+ trigger: nil, delete: nil, href_target: nil, create_modal: nil, mask_me: nil,
70
+ exclude_value: nil)
60
71
  hash = {listener: true, channel: channel}
61
72
  if delete
62
73
  hash[:delete_key] = key
@@ -65,6 +76,7 @@ module ForeignOffice
65
76
  end
66
77
  hash[:reveal_hide] = true if reveal_hide
67
78
  hash[:endpoint] = endpoint if endpoint
79
+ hash[:exclude_value] = exclude_value if exclude_value
68
80
  hash[:download] = true if download
69
81
  hash[:trigger_on_message] = true if trigger
70
82
  hash[:href_target] = true if href_target
@@ -1,3 +1,3 @@
1
1
  module ForeignOffice
2
- VERSION = "0.15.12"
2
+ VERSION = "0.16.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.15.12
4
+ version: 0.16.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: 2018-03-01 00:00:00.000000000 Z
12
+ date: 2018-04-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails