jsb-rails 0.2.0 → 1.0.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b21b5b5961649d9ed0c9d11eb01cc9403fe4351e
4
- data.tar.gz: 2d9550a0f4eaa59a3b854bc5a98096c439b8540a
3
+ metadata.gz: c32a2dcaa69f191fd655263efe511f12487137ed
4
+ data.tar.gz: 735f68a353b576fc0f7947146d151b0408d25d5e
5
5
  SHA512:
6
- metadata.gz: ec73f5f2c5e4767ee66b12bbd1a4c9117dd5a8398beebb9ec4fcc0da472582b241c7554dc9ec4cb309b7b860fb2aede8783b881f30695d87de7ae45daf575142
7
- data.tar.gz: 33647250ee88fffab9042b78a72abad19f9c688cd613fe7600ef99d89609f1732b2ceac8c778b7f5084648bda1d3f3dcc9eb231e1685d4dbb756d6e83b962146
6
+ metadata.gz: 852800ca2ce00b98aead0759452c99585ffb5cde7440505e9971aa4dd44b1d6444444853d78ec957efe831c7b72bed9b86bf1b77b5f9dfb2cf0bc64e1c843de5
7
+ data.tar.gz: 2603c8ef5335c7fc905ed711981757464331b44ba5ad04e83d4565653ad6269d024793c8988ae8ea2a7f9b6f32db375339b668a115989f6c89411bf0f60e5e57
data/README.md CHANGED
@@ -1,8 +1,14 @@
1
- # Jsb::Rails
1
+ # jsb-rails
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/jsb/rails`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ This gem integrates JsBehaviour Toolkit with Rails asset pipeline for ease of use.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ ## What is Jsb and how does it work?
6
+
7
+ https://github.com/DracoBlue/jsb
8
+
9
+ ## What version of jsb?
10
+
11
+ the latest and greatest 2.0.0
6
12
 
7
13
  ## Installation
8
14
 
@@ -22,13 +28,9 @@ Or install it yourself as:
22
28
 
23
29
  ## Usage
24
30
 
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
31
+ After bundle the jsb will be added to the asset pipeline. Add the following line to your `app/assets/javascripts/application.js` and you're done.
30
32
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
33
+ //= require jsb
32
34
 
33
35
  ## Contributing
34
36
 
data/jsb-rails.gemspec CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["René Kersten"]
10
10
  spec.email = ["rene.kersten@gmail.com"]
11
11
 
12
- spec.summary = "This gem integrates JsBehaviourToolkit with Rails asset pipeline for easy of use."
13
- spec.description = "This gem integrates JsBehaviourToolkit with Rails asset pipeline for easy of use. "
12
+ spec.summary = "This gem integrates JsBehaviourToolkit with Rails asset pipeline for ease of use."
13
+ spec.description = "This gem integrates JsBehaviourToolkit with Rails asset pipeline for ease of use."
14
14
  spec.homepage = "https://github.com/endorfin/jsb-rails"
15
15
  spec.license = "MIT"
16
16
 
@@ -1,6 +1,6 @@
1
1
  module Jsb
2
2
  module Rails
3
- VERSION = "0.2.0"
4
- JSB_VERSION = "2.0.0"
3
+ VERSION = "1.0.0"
4
+ JSB_VERSION = "2.3.0"
5
5
  end
6
6
  end
@@ -1,8 +1,8 @@
1
1
  /*
2
- * jsb 2.0.0
2
+ * jsb
3
3
  *
4
4
  * This file is part of jsb (Javascript Behaviour Toolkit).
5
- * Copyright (c) 2010-2014 DracoBlue, http://dracoblue.net/
5
+ * Copyright (c) 2010-2015 DracoBlue, http://dracoblue.net/
6
6
  *
7
7
  * Licensed under the terms of MIT License. For the full copyright and license
8
8
  * information, please see the LICENSE file in the root folder.
@@ -15,6 +15,7 @@ jsb = {
15
15
  handlers: {},
16
16
  listeners: [],
17
17
  last_event_values: {},
18
+ sticky_event_values: {},
18
19
 
19
20
  /**
20
21
  * Set the prefix for the jsb toolkit.
@@ -71,13 +72,19 @@ jsb = {
71
72
  * @param {String} name
72
73
  * @param {Object} [values={}]
73
74
  */
74
- fireEvent: function(name, values) {
75
+ fireEvent: function(name, values, sticky) {
75
76
  values = values || {};
77
+ sticky = sticky || false;
76
78
 
77
79
  /*
78
- * Remember the last value for calls to `jsb.whenFired`
80
+ * Remember the last values for calls to `jsb.whenFired`
79
81
  */
80
- this.last_event_values[name] = values;
82
+ if (sticky) {
83
+ this.sticky_event_values[name] = this.sticky_event_values[name] || [];
84
+ this.sticky_event_values[name].push(values);
85
+ } else {
86
+ this.last_event_values[name] = values;
87
+ }
81
88
 
82
89
  var listeners = this.listeners;
83
90
  var listeners_length = listeners.length;
@@ -91,6 +98,10 @@ jsb = {
91
98
  }
92
99
  },
93
100
 
101
+ fireStickyEvent: function(name, values) {
102
+ this.fireEvent(name, values, true);
103
+ },
104
+
94
105
  /**
95
106
  * Adds an event listener for a given name or regular expression.
96
107
  *
@@ -196,20 +207,51 @@ jsb = {
196
207
  if (this.last_event_values.hasOwnProperty(key) && key.match(name_or_regexp)) {
197
208
  (function(key)
198
209
  {
210
+ var last_value = that.last_event_values[key];
199
211
  setTimeout(function()
200
212
  {
201
- that.rawFireEventToListener([cb, name_or_regexp, filter], key, that.last_event_values[key]);
213
+ that.rawFireEventToListener([cb, name_or_regexp, filter], key, last_value);
202
214
  }, 0);
203
215
  })(key);
204
216
  }
205
217
  }
218
+ for (var key in this.sticky_event_values) {
219
+ if (this.sticky_event_values.hasOwnProperty(key) && key.match(name_or_regexp)) {
220
+ (function(key)
221
+ {
222
+ var last_values = that.sticky_event_values[key];
223
+ var last_values_length = last_values.length;
224
+ for (var i = 0; i < last_values_length; i++) {
225
+ (function(last_value) {
226
+ setTimeout(function()
227
+ {
228
+ that.rawFireEventToListener([cb, name_or_regexp, filter], key, last_value);
229
+ }, 0);
230
+ })(last_values[i]);
231
+ }
232
+ })(key);
233
+ }
234
+ }
206
235
  } else {
207
236
  if (typeof this.last_event_values[name_or_regexp] !== 'undefined') {
237
+ var last_value = that.last_event_values[name_or_regexp];
208
238
  setTimeout(function()
209
239
  {
210
- that.rawFireEventToListener([cb, name_or_regexp, filter], name_or_regexp, that.last_event_values[name_or_regexp]);
240
+ that.rawFireEventToListener([cb, name_or_regexp, filter], name_or_regexp, last_value);
211
241
  }, 0);
212
242
  }
243
+ if (typeof this.sticky_event_values[name_or_regexp] !== 'undefined') {
244
+ var last_values = that.sticky_event_values[name_or_regexp];
245
+ var last_values_length = last_values.length;
246
+ for (var i = 0; i < last_values_length; i++) {
247
+ (function(last_value) {
248
+ setTimeout(function()
249
+ {
250
+ that.rawFireEventToListener([cb, name_or_regexp, filter], name_or_regexp, last_value);
251
+ }, 0);
252
+ })(last_values[i]);
253
+ }
254
+ }
213
255
  }
214
256
 
215
257
  return off_handler;
@@ -382,14 +424,15 @@ if (typeof jQuery !== 'undefined') {
382
424
  }
383
425
  };
384
426
 
385
- /*
386
- * Fire domready in a jQuery way!
387
- */
388
-
389
- jQuery(window.document).ready(function() {
390
- jsb.applyBehaviour(window.document);
391
- });
427
+ if (typeof window !== "undefined") {
428
+ /*
429
+ * Fire domready in a jQuery way!
430
+ */
392
431
 
432
+ jQuery(window.document).ready(function () {
433
+ jsb.applyBehaviour(window.document);
434
+ });
435
+ }
393
436
  } else if (typeof MooTools !== 'undefined') {
394
437
  /*
395
438
  * If we have MooTools available, we can use the MooTools methods instead
@@ -420,31 +463,37 @@ if (typeof jQuery !== 'undefined') {
420
463
  }
421
464
  };
422
465
 
423
- /*
424
- * Fire domready in a mootools way!
425
- */
426
-
427
- $(window).addEvent('domready', function() {
428
- jsb.applyBehaviour(window.document);
429
- });
430
- } else {
466
+ if (typeof window !== "undefined") {
467
+ /*
468
+ * Fire domready in a mootools way!
469
+ */
431
470
 
432
- /*
433
- * Fire domready in a native way!
434
- */
435
- if (window.addEventListener) {
436
- window.addEventListener("DOMContentLoaded", function() {
437
- jsb.applyBehaviour(window.document);
438
- }, true);
439
- } else if(window.attachEvent) {
440
- window.attachEvent("onLoad",function() {
471
+ $(window).addEvent('domready', function () {
441
472
  jsb.applyBehaviour(window.document);
442
473
  });
443
474
  }
475
+ } else {
476
+
477
+ if (typeof window !== "undefined") {
478
+ /*
479
+ * Fire domready in a native way!
480
+ */
481
+ if (window.addEventListener) {
482
+ window.addEventListener("DOMContentLoaded", function() {
483
+ jsb.applyBehaviour(window.document);
484
+ }, true);
485
+ } else if(window.attachEvent) {
486
+ window.attachEvent("onLoad",function() {
487
+ jsb.applyBehaviour(window.document);
488
+ });
489
+ }
490
+ }
444
491
  }
445
492
 
446
- if (typeof define !== "undefined") {
493
+ if (typeof define !== "undefined" && define.amd) {
447
494
  define('jsb', function() {
448
495
  return jsb;
449
496
  });
497
+ } else if (typeof module === 'object' && module.exports) {
498
+ module.exports = jsb;
450
499
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsb-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - René Kersten
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-23 00:00:00.000000000 Z
11
+ date: 2015-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,8 +38,8 @@ dependencies:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
- description: 'This gem integrates JsBehaviourToolkit with Rails asset pipeline for
42
- easy of use. '
41
+ description: This gem integrates JsBehaviourToolkit with Rails asset pipeline for
42
+ ease of use.
43
43
  email:
44
44
  - rene.kersten@gmail.com
45
45
  executables: []
@@ -79,10 +79,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  version: '0'
80
80
  requirements: []
81
81
  rubyforge_project:
82
- rubygems_version: 2.0.14
82
+ rubygems_version: 2.4.7
83
83
  signing_key:
84
84
  specification_version: 4
85
- summary: This gem integrates JsBehaviourToolkit with Rails asset pipeline for easy
85
+ summary: This gem integrates JsBehaviourToolkit with Rails asset pipeline for ease
86
86
  of use.
87
87
  test_files: []
88
88
  has_rdoc: