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 +4 -4
- data/README.md +11 -9
- data/jsb-rails.gemspec +2 -2
- data/lib/jsb/rails/version.rb +2 -2
- data/vendor/assets/javascripts/jsb.js +81 -32
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c32a2dcaa69f191fd655263efe511f12487137ed
|
4
|
+
data.tar.gz: 735f68a353b576fc0f7947146d151b0408d25d5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 852800ca2ce00b98aead0759452c99585ffb5cde7440505e9971aa4dd44b1d6444444853d78ec957efe831c7b72bed9b86bf1b77b5f9dfb2cf0bc64e1c843de5
|
7
|
+
data.tar.gz: 2603c8ef5335c7fc905ed711981757464331b44ba5ad04e83d4565653ad6269d024793c8988ae8ea2a7f9b6f32db375339b668a115989f6c89411bf0f60e5e57
|
data/README.md
CHANGED
@@ -1,8 +1,14 @@
|
|
1
|
-
#
|
1
|
+
# jsb-rails
|
2
2
|
|
3
|
-
|
3
|
+
This gem integrates JsBehaviour Toolkit with Rails asset pipeline for ease of use.
|
4
4
|
|
5
|
-
|
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
|
-
|
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
|
-
|
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
|
13
|
-
spec.description = "This gem integrates JsBehaviourToolkit with Rails asset pipeline for
|
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
|
|
data/lib/jsb/rails/version.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
/*
|
2
|
-
* jsb
|
2
|
+
* jsb
|
3
3
|
*
|
4
4
|
* This file is part of jsb (Javascript Behaviour Toolkit).
|
5
|
-
* Copyright (c) 2010-
|
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
|
80
|
+
* Remember the last values for calls to `jsb.whenFired`
|
79
81
|
*/
|
80
|
-
|
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,
|
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,
|
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
|
-
|
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
|
-
|
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.
|
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-
|
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:
|
42
|
-
|
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.
|
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
|
85
|
+
summary: This gem integrates JsBehaviourToolkit with Rails asset pipeline for ease
|
86
86
|
of use.
|
87
87
|
test_files: []
|
88
88
|
has_rdoc:
|