observejs 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +7 -7
- data/Rakefile +1 -1
- data/lib/observejs/app/assets/javascripts/observejs/base.js.coffee +28 -0
- data/lib/{jointjs/app/assets/javascripts/joint → observejs/app/assets/javascripts/observejs}/creator.js.coffee +7 -6
- data/lib/observejs/app/assets/javascripts/observejs/watcher.js.coffee +49 -0
- data/lib/{jointjs/app/assets/javascripts/joint → observejs/app/assets/javascripts/observejs}/xhr.js.coffee +24 -7
- data/lib/observejs/app/assets/javascripts/observejs.js.coffee +11 -0
- data/lib/{jointjs → observejs}/railtie.rb +2 -2
- data/lib/observejs/version.rb +3 -0
- data/lib/observejs.rb +5 -0
- data/{jointjs.gemspec → observejs.gemspec} +2 -2
- data/test/Gemfile +1 -2
- data/test/Gemfile.lock +3 -3
- data/test/app/assets/javascripts/application.js +1 -1
- data/test/app/assets/javascripts/item.js.coffee +1 -1
- data/test/app/assets/javascripts/list.js.coffee +1 -1
- data/test/app/assets/javascripts/tests/instances.js.coffee +2 -3
- data/test/app/assets/javascripts/tests/template.js.coffee +11 -0
- data/test/app/assets/javascripts/tests/xhr.js.coffee +13 -2
- data/test/app/assets/stylesheets/application.css.scss +3 -0
- data/test/app/views/layouts/application.html.erb +1 -0
- data/test/app/views/todos/index.html.erb +3 -0
- data/test/config/application.rb +1 -1
- data/test/config/routes.rb +1 -1
- metadata +18 -16
- data/lib/jointjs/app/assets/javascripts/joint/base.js.coffee +0 -18
- data/lib/jointjs/app/assets/javascripts/joint/watcher.js.coffee +0 -49
- data/lib/jointjs/app/assets/javascripts/joint.js.coffee +0 -12
- data/lib/jointjs/version.rb +0 -3
- data/lib/jointjs.rb +0 -5
- data/test/db/joint_test +0 -0
- /data/lib/{jointjs/app/assets/javascripts/joint → observejs/app/assets/javascripts/observejs}/ext.js.coffee +0 -0
- /data/lib/{jointjs → observejs}/app/views/layouts/application.js.erb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34f7e2b0d3b0c92e4a99b441e4e47ef15ad3744c
|
4
|
+
data.tar.gz: 0b4ca8788f5915d2b925d68a1131560315195865
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f74f38db3a194c310dc5dcfa10996fbf2d68691ee288ff62b1247508fecd2a2e261d74ae8d803e7a3645a4973f55899249d1baa61b4508bca4b72bcd090b982
|
7
|
+
data.tar.gz: c2eb85285421fdf3ef7e5b24c559e4967a5e090ee93d1f1a5a53890237f14c54ae1091ac63ae83c28bae6ec8205f451cabf8398f5a0da44860aaa1beff9ea815
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# ObserveJS
|
2
2
|
|
3
3
|
Event based JavaScript framework tailored made for Ruby on rails.
|
4
4
|
|
@@ -7,17 +7,17 @@ Event based JavaScript framework tailored made for Ruby on rails.
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
9
|
```ruby
|
10
|
-
gem '
|
10
|
+
gem 'observejs'
|
11
11
|
```
|
12
12
|
|
13
13
|
Then add this line to application.js
|
14
14
|
|
15
15
|
```js
|
16
|
-
//= require '
|
16
|
+
//= require 'observejs'
|
17
17
|
```
|
18
18
|
## Usage
|
19
19
|
|
20
|
-
|
20
|
+
ObserveJS is an event based framework that manages the life cycle of JavaScript objects. Here's a simple Todo where you can dynamically add/remove items on the list.
|
21
21
|
|
22
22
|
```erb
|
23
23
|
<!-- views/todos/index.html.erb -->
|
@@ -28,7 +28,7 @@ JointJSe is an event based framework that manages the life cycle of JavaScript o
|
|
28
28
|
|
29
29
|
```coffee
|
30
30
|
# assets/javascripts/todos/list.js.coffee
|
31
|
-
|
31
|
+
ObserveJS.bind 'Todo.List', class
|
32
32
|
# @element() always return the element to which your object is bound.
|
33
33
|
|
34
34
|
loaded: =>
|
@@ -57,9 +57,9 @@ Some notes:
|
|
57
57
|
|
58
58
|
- Automatic instantiation. No need to wrap things in DOMContentReady anymore.
|
59
59
|
- Events are built following the "controller:action" pattern.
|
60
|
-
- A callback (@loaded) is called right after
|
60
|
+
- A callback (@loaded) is called right after ObserveJS has instantiated an object.
|
61
61
|
- In *.js.erb, an event is created. You can set HTML to the event object.
|
62
62
|
- To ease the process, a toHTML() method has been added to the String object (JS).
|
63
|
-
- You need to register any class you create through the ```
|
63
|
+
- You need to register any class you create through the ```ObserveJS.bind 'name', Class```. The name is the attribute you set in your DOM.
|
64
64
|
|
65
65
|
|
data/Rakefile
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
class ObserveJS
|
2
|
+
attributeName: 'as'
|
3
|
+
|
4
|
+
constructor: ->
|
5
|
+
@cache = {}
|
6
|
+
|
7
|
+
initialize: =>
|
8
|
+
event = new CustomEvent('observejs:loaded')
|
9
|
+
document.dispatchEvent(event)
|
10
|
+
|
11
|
+
isDOM: (el) ->
|
12
|
+
el instanceof HTMLDocument ||
|
13
|
+
el instanceof HTMLElement
|
14
|
+
|
15
|
+
bind: (name, kls) =>
|
16
|
+
@cache[name] = kls
|
17
|
+
|
18
|
+
kls.prototype.template = () ->
|
19
|
+
tmpl = @element().querySelector("template[for='#{name}']")
|
20
|
+
unless tmpl?
|
21
|
+
throw "Template Error: Couldn't find a template matching #{name}"
|
22
|
+
return
|
23
|
+
tmpl
|
24
|
+
|
25
|
+
kls.prototype.retrieve = (selector) ->
|
26
|
+
@element().querySelector(selector) || @template().content.querySelector(selector).cloneNode(true)
|
27
|
+
|
28
|
+
window.ObserveJS = new ObserveJS()
|
@@ -1,19 +1,20 @@
|
|
1
1
|
class Creator
|
2
2
|
|
3
3
|
update: (el) =>
|
4
|
-
model = el.getAttribute(
|
4
|
+
model = el.getAttribute(ObserveJS.attributeName)
|
5
5
|
if model?
|
6
6
|
@create(el, model)
|
7
7
|
else
|
8
8
|
@destroy(el)
|
9
9
|
|
10
10
|
create: (el) =>
|
11
|
-
model = el.getAttribute(
|
12
|
-
if
|
11
|
+
model = el.getAttribute(ObserveJS.attributeName)
|
12
|
+
if ObserveJS.cache[model]?
|
13
13
|
if el.instance?
|
14
|
+
el.loaded()
|
14
15
|
return
|
15
16
|
|
16
|
-
el.instance = new
|
17
|
+
el.instance = new ObserveJS.cache[model](el)
|
17
18
|
|
18
19
|
el.instance.element = ->
|
19
20
|
el
|
@@ -32,10 +33,10 @@ class Creator
|
|
32
33
|
el.instance.loaded()
|
33
34
|
|
34
35
|
else
|
35
|
-
throw "error: #{model} is not registered. Add your model with
|
36
|
+
throw "error: #{model} is not registered. Add your model with ObserveJS.Models.add(#{model})"
|
36
37
|
|
37
38
|
destroy: (el) =>
|
38
39
|
el.instance.on.events?.forEach (event) ->
|
39
40
|
event[1].removeEventListener(event[0], event[2])
|
40
41
|
|
41
|
-
@
|
42
|
+
@ObserveJS.Creator = new Creator()
|
@@ -0,0 +1,49 @@
|
|
1
|
+
class Watcher
|
2
|
+
constructor: ->
|
3
|
+
document.addEventListener('observejs:loaded', @start)
|
4
|
+
|
5
|
+
start: =>
|
6
|
+
@observer = new MutationObserver(@observed)
|
7
|
+
@observer.observe(document, {
|
8
|
+
attributes: true,
|
9
|
+
subtree: true,
|
10
|
+
childList: true,
|
11
|
+
attributeFilter: [ObserveJS.attributeName],
|
12
|
+
characterData: true
|
13
|
+
})
|
14
|
+
|
15
|
+
@inspect(document)
|
16
|
+
|
17
|
+
observed: (mutations) =>
|
18
|
+
mutations.forEach (mutation) =>
|
19
|
+
if mutation.type == 'attributes'
|
20
|
+
ObserveJS.Creator.update(mutation.target)
|
21
|
+
else
|
22
|
+
@add(mutation.addedNodes)
|
23
|
+
@destroy(mutation.removedNodes)
|
24
|
+
|
25
|
+
|
26
|
+
add: (nodes) =>
|
27
|
+
for node in nodes
|
28
|
+
continue unless ObserveJS.isDOM(node)
|
29
|
+
if node.hasAttribute(ObserveJS.attributeName)
|
30
|
+
ObserveJS.Creator.create(node, node.getAttribute(ObserveJS.attributeName))
|
31
|
+
|
32
|
+
for child in node.querySelectorAll("[#{ObserveJS.attributeName}]")
|
33
|
+
ObserveJS.Creator.create(child, child.getAttribute(ObserveJS.attributeName))
|
34
|
+
|
35
|
+
destroy: (nodes) =>
|
36
|
+
for node in nodes
|
37
|
+
continue unless ObserveJS.isDOM(node)
|
38
|
+
if node.hasAttribute(ObserveJS.attributeName)
|
39
|
+
ObserveJS.Creator.destroy(node)
|
40
|
+
|
41
|
+
for child in node.querySelectorAll("[#{ObserveJS.attributeName}]")
|
42
|
+
ObserveJS.Creator.destroy(child)
|
43
|
+
|
44
|
+
inspect: (node) ->
|
45
|
+
if ObserveJS.isDOM(node)
|
46
|
+
found = node.querySelectorAll("[#{ObserveJS.attributeName}]")
|
47
|
+
ObserveJS.Creator.create(el) for el in found
|
48
|
+
|
49
|
+
@ObserveJS.Watcher = new Watcher()
|
@@ -31,13 +31,31 @@ class XHRData
|
|
31
31
|
|
32
32
|
formData
|
33
33
|
|
34
|
-
class
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
class Response
|
35
|
+
constructor: (@xhr) ->
|
36
|
+
@xhr.request.addEventListener 'load', @process
|
37
|
+
@xhr.request.addEventListener 'error', @failure
|
38
|
+
@xhr.request.addEventListener 'abort', @failure
|
39
|
+
|
40
|
+
process: (e) =>
|
41
|
+
if e.target.status >= 200 && e.target.status < 300
|
42
|
+
@success(e)
|
43
|
+
else
|
44
|
+
@failure(e)
|
45
|
+
|
46
|
+
success: (e) =>
|
38
47
|
if e.target.responseText.length > 1
|
39
48
|
eval(e.target.responseText)(e.target.element)
|
40
49
|
|
50
|
+
failure: (e) =>
|
51
|
+
event = new CustomEvent("ObserveJS:XHR:Failed", {bubbles: true})
|
52
|
+
event.response = e
|
53
|
+
@xhr.request.element.dispatchEvent(event)
|
54
|
+
|
55
|
+
|
56
|
+
class XHR
|
57
|
+
script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
|
58
|
+
|
41
59
|
@send: (el) ->
|
42
60
|
|
43
61
|
xhr = new XHR(el)
|
@@ -48,7 +66,7 @@ class XHR
|
|
48
66
|
@data = new XHRData(el)
|
49
67
|
@request = new XMLHttpRequest()
|
50
68
|
@request.element = el
|
51
|
-
@
|
69
|
+
@response = new Response(this)
|
52
70
|
|
53
71
|
@method = el.getAttribute('method') || 'GET'
|
54
72
|
|
@@ -82,7 +100,7 @@ class XHR
|
|
82
100
|
@request.send(@data.serialize())
|
83
101
|
|
84
102
|
|
85
|
-
|
103
|
+
ObserveJS.XHR = XHR
|
86
104
|
|
87
105
|
document.addEventListener 'submit', (e) =>
|
88
106
|
if e.target.getAttribute('disabled')? || e.target.dataset['remote'] != 'true'
|
@@ -107,4 +125,3 @@ document.addEventListener 'click', (e) =>
|
|
107
125
|
|
108
126
|
e.preventDefault()
|
109
127
|
return false
|
110
|
-
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#= require 'observejs/ext'
|
2
|
+
#= require 'observejs/base'
|
3
|
+
#= require 'observejs/watcher'
|
4
|
+
#= require 'observejs/creator'
|
5
|
+
#= require 'observejs/xhr'
|
6
|
+
|
7
|
+
if document.readyState == 'complete'
|
8
|
+
window.ObserveJS.initialize()
|
9
|
+
else
|
10
|
+
document.addEventListener 'DOMContentLoaded', ->
|
11
|
+
window.ObserveJS.initialize()
|
@@ -1,6 +1,6 @@
|
|
1
|
-
module
|
1
|
+
module ObserveJS
|
2
2
|
class Railtie < Rails::Railtie
|
3
|
-
initializer '
|
3
|
+
initializer 'observejs.assets.paths', before: :add_view_paths do |app|
|
4
4
|
app.paths['vendor/assets'] << File.dirname(__FILE__) + '/app/assets/'
|
5
5
|
app.paths['app/views'] << File.dirname(__FILE__) + '/app/views/'
|
6
6
|
end
|
data/lib/observejs.rb
ADDED
@@ -1,11 +1,11 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require '
|
4
|
+
require 'observejs/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "observejs"
|
8
|
-
spec.version =
|
8
|
+
spec.version = ObserveJS::VERSION
|
9
9
|
spec.authors = ["Pier-Olivier Thibault"]
|
10
10
|
spec.email = ["pothibo@gmail.com"]
|
11
11
|
spec.summary = %q{Event based JavaScript framework tailored for Ruby on rails.}
|
data/test/Gemfile
CHANGED
@@ -12,7 +12,7 @@ gem 'jbuilder', '~> 2.0'
|
|
12
12
|
|
13
13
|
path = Pathname.new(__FILE__) + '..'
|
14
14
|
|
15
|
-
gem '
|
15
|
+
gem 'observejs', path: path.dirname
|
16
16
|
|
17
17
|
group :development, :test do
|
18
18
|
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
@@ -24,4 +24,3 @@ group :development, :test do
|
|
24
24
|
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
25
25
|
gem 'spring'
|
26
26
|
end
|
27
|
-
|
data/test/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
|
-
remote: /Users/pothibo/Develop/
|
2
|
+
remote: /Users/pothibo/Develop/observejs
|
3
3
|
specs:
|
4
|
-
|
4
|
+
observejs (0.0.6)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -153,8 +153,8 @@ DEPENDENCIES
|
|
153
153
|
byebug
|
154
154
|
coffee-rails (~> 4.1.0)
|
155
155
|
jbuilder (~> 2.0)
|
156
|
-
jointjs!
|
157
156
|
jquery-rails
|
157
|
+
observejs!
|
158
158
|
rails (= 4.2.0)
|
159
159
|
sass-rails (~> 5.0)
|
160
160
|
spring
|
@@ -1,2 +1,2 @@
|
|
1
|
-
|
1
|
+
ObserveJS.bind 'List.Item', class
|
2
2
|
loaded: ->
|
@@ -11,7 +11,6 @@ document.addEventListener 'readystatechange', (e) ->
|
|
11
11
|
document.querySelector('ol.test.items').appendChild(li)
|
12
12
|
assert.ok count + 1 == document.querySelectorAll("li[as='List.Item']").length, "Should instantiate a new instance for the new item"
|
13
13
|
li.remove()
|
14
|
-
|
15
|
-
event = new CustomEvent('QUnit:Joint:Initialized')
|
16
|
-
document.dispatchEvent(event)
|
17
14
|
|
15
|
+
event = new CustomEvent('QUnit:ObserveJS:Initialized')
|
16
|
+
document.dispatchEvent(event)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
document.addEventListener 'readystatechange', (e) ->
|
2
|
+
return unless document.readyState == 'complete'
|
3
|
+
QUnit.test 'Should return a template bound to the class', (assert) ->
|
4
|
+
elements = document.querySelectorAll("li[as='List.Item']")
|
5
|
+
|
6
|
+
list = document.querySelector("[as='List']")
|
7
|
+
assert.ok list.instance.template() instanceof HTMLTemplateElement, "Should have a template associated with the List"
|
8
|
+
|
9
|
+
for li in elements
|
10
|
+
assert.throws li.instance.template, "No template should be found for those list element."
|
11
|
+
|
@@ -1,4 +1,4 @@
|
|
1
|
-
document.addEventListener 'QUnit:
|
1
|
+
document.addEventListener 'QUnit:ObserveJS:Initialized', ->
|
2
2
|
QUnit.test 'Send an AJAX for any element that has a href attribute', (assert) ->
|
3
3
|
el = document.querySelector("li[as='List.Item']")
|
4
4
|
assert.ok(true)
|
@@ -9,11 +9,22 @@ document.addEventListener 'QUnit:Joint:Initialized', ->
|
|
9
9
|
form = NewTodo
|
10
10
|
form.querySelector('#todo_title').value = "Creating a new todo"
|
11
11
|
|
12
|
-
xhr =
|
12
|
+
xhr = ObserveJS.XHR.send(form)
|
13
13
|
xhr.request.addEventListener 'load', (r) ->
|
14
14
|
assert.equal(r.target.status, 200)
|
15
15
|
passed()
|
16
16
|
|
17
|
+
QUnit.test 'Failed AJAX will emit and event', (assert) ->
|
18
|
+
passed = assert.async()
|
19
|
+
|
20
|
+
form = NewTodo.cloneNode(true)
|
21
|
+
|
22
|
+
form.addEventListener 'ObserveJS:XHR:Failed', (e) ->
|
23
|
+
assert.equal(form, e.response.target.element)
|
24
|
+
passed()
|
25
|
+
|
26
|
+
form.setAttribute('action', 'http://error.domain.cyz')
|
27
|
+
ObserveJS.XHR.send(form)
|
17
28
|
|
18
29
|
|
19
30
|
QUnit.test 'If a form data is passed and the request is GET, hardcode the params in the URL', (assert) ->
|
@@ -3,6 +3,7 @@
|
|
3
3
|
<head>
|
4
4
|
<title>JointJS Test Suite</title>
|
5
5
|
<link rel="stylesheet" href="//code.jquery.com/qunit/qunit-1.16.0.css">
|
6
|
+
<%= stylesheet_link_tag "application", "data-turbolinks-track" => true %>
|
6
7
|
<%= javascript_include_tag "application", 'http://code.jquery.com/qunit/qunit-1.16.0.js', "data-turbolinks-track" => true %>
|
7
8
|
<%= csrf_meta_tags %>
|
8
9
|
</head>
|
data/test/config/application.rb
CHANGED
@@ -6,7 +6,7 @@ require 'rails/all'
|
|
6
6
|
# you've limited to :test, :development, or :production.
|
7
7
|
Bundler.require(*Rails.groups)
|
8
8
|
|
9
|
-
module
|
9
|
+
module ObserveJSTest
|
10
10
|
class Application < Rails::Application
|
11
11
|
# Settings in config/environments/* take precedence over those specified here.
|
12
12
|
# Application configuration should go into files in config/initializers
|
data/test/config/routes.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: observejs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pier-Olivier Thibault
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -78,17 +78,17 @@ files:
|
|
78
78
|
- LICENSE.txt
|
79
79
|
- README.md
|
80
80
|
- Rakefile
|
81
|
-
-
|
82
|
-
- lib/
|
83
|
-
- lib/
|
84
|
-
- lib/
|
85
|
-
- lib/
|
86
|
-
- lib/
|
87
|
-
- lib/
|
88
|
-
- lib/
|
89
|
-
- lib/
|
90
|
-
- lib/
|
91
|
-
-
|
81
|
+
- lib/observejs.rb
|
82
|
+
- lib/observejs/app/assets/javascripts/observejs.js.coffee
|
83
|
+
- lib/observejs/app/assets/javascripts/observejs/base.js.coffee
|
84
|
+
- lib/observejs/app/assets/javascripts/observejs/creator.js.coffee
|
85
|
+
- lib/observejs/app/assets/javascripts/observejs/ext.js.coffee
|
86
|
+
- lib/observejs/app/assets/javascripts/observejs/watcher.js.coffee
|
87
|
+
- lib/observejs/app/assets/javascripts/observejs/xhr.js.coffee
|
88
|
+
- lib/observejs/app/views/layouts/application.js.erb
|
89
|
+
- lib/observejs/railtie.rb
|
90
|
+
- lib/observejs/version.rb
|
91
|
+
- observejs.gemspec
|
92
92
|
- test/Gemfile
|
93
93
|
- test/Gemfile.lock
|
94
94
|
- test/README.rdoc
|
@@ -97,7 +97,9 @@ files:
|
|
97
97
|
- test/app/assets/javascripts/item.js.coffee
|
98
98
|
- test/app/assets/javascripts/list.js.coffee
|
99
99
|
- test/app/assets/javascripts/tests/instances.js.coffee
|
100
|
+
- test/app/assets/javascripts/tests/template.js.coffee
|
100
101
|
- test/app/assets/javascripts/tests/xhr.js.coffee
|
102
|
+
- test/app/assets/stylesheets/application.css.scss
|
101
103
|
- test/app/controllers/todos_controller.rb
|
102
104
|
- test/app/models/todo.rb
|
103
105
|
- test/app/views/layouts/application.html.erb
|
@@ -128,7 +130,6 @@ files:
|
|
128
130
|
- test/config/locales/en.yml
|
129
131
|
- test/config/routes.rb
|
130
132
|
- test/config/secrets.yml
|
131
|
-
- test/db/joint_test
|
132
133
|
- test/db/migrate/20150106151240_create_todos.rb
|
133
134
|
- test/db/schema.rb
|
134
135
|
- test/db/seeds.rb
|
@@ -153,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
154
|
version: '0'
|
154
155
|
requirements: []
|
155
156
|
rubyforge_project:
|
156
|
-
rubygems_version: 2.
|
157
|
+
rubygems_version: 2.4.5
|
157
158
|
signing_key:
|
158
159
|
specification_version: 4
|
159
160
|
summary: Event based JavaScript framework tailored for Ruby on rails.
|
@@ -166,7 +167,9 @@ test_files:
|
|
166
167
|
- test/app/assets/javascripts/item.js.coffee
|
167
168
|
- test/app/assets/javascripts/list.js.coffee
|
168
169
|
- test/app/assets/javascripts/tests/instances.js.coffee
|
170
|
+
- test/app/assets/javascripts/tests/template.js.coffee
|
169
171
|
- test/app/assets/javascripts/tests/xhr.js.coffee
|
172
|
+
- test/app/assets/stylesheets/application.css.scss
|
170
173
|
- test/app/controllers/todos_controller.rb
|
171
174
|
- test/app/models/todo.rb
|
172
175
|
- test/app/views/layouts/application.html.erb
|
@@ -197,7 +200,6 @@ test_files:
|
|
197
200
|
- test/config/locales/en.yml
|
198
201
|
- test/config/routes.rb
|
199
202
|
- test/config/secrets.yml
|
200
|
-
- test/db/joint_test
|
201
203
|
- test/db/migrate/20150106151240_create_todos.rb
|
202
204
|
- test/db/schema.rb
|
203
205
|
- test/db/seeds.rb
|
@@ -1,18 +0,0 @@
|
|
1
|
-
class Joint
|
2
|
-
attributeName: 'as'
|
3
|
-
|
4
|
-
constructor: ->
|
5
|
-
@cache = {}
|
6
|
-
|
7
|
-
initialize: =>
|
8
|
-
event = new CustomEvent('joint:loaded')
|
9
|
-
document.dispatchEvent(event)
|
10
|
-
|
11
|
-
isDOM: (el) ->
|
12
|
-
el instanceof HTMLDocument ||
|
13
|
-
el instanceof HTMLElement
|
14
|
-
|
15
|
-
bind: (name, kls) =>
|
16
|
-
@cache[name] = kls
|
17
|
-
|
18
|
-
window.Joint = new Joint()
|
@@ -1,49 +0,0 @@
|
|
1
|
-
class Watcher
|
2
|
-
constructor: ->
|
3
|
-
document.addEventListener('joint:loaded', @start)
|
4
|
-
|
5
|
-
start: =>
|
6
|
-
@observer = new MutationObserver(@observed)
|
7
|
-
@observer.observe(document, {
|
8
|
-
attributes: true,
|
9
|
-
subtree: true,
|
10
|
-
childList: true,
|
11
|
-
attributeFilter: [Joint.attributeName],
|
12
|
-
characterData: true
|
13
|
-
})
|
14
|
-
|
15
|
-
@inspect(document)
|
16
|
-
|
17
|
-
observed: (mutations) =>
|
18
|
-
mutations.forEach (mutation) =>
|
19
|
-
if mutation.type == 'attributes'
|
20
|
-
Joint.Creator.update(target)
|
21
|
-
else
|
22
|
-
@add(mutation.addedNodes)
|
23
|
-
@destroy(mutation.removedNodes)
|
24
|
-
|
25
|
-
|
26
|
-
add: (nodes) =>
|
27
|
-
for node in nodes
|
28
|
-
continue unless Joint.isDOM(node)
|
29
|
-
if node.hasAttribute(Joint.attributeName)
|
30
|
-
Joint.Creator.create(node, node.getAttribute(Joint.attributeName))
|
31
|
-
|
32
|
-
for child in node.querySelectorAll("[#{Joint.attributeName}]")
|
33
|
-
Joint.Creator.create(child, child.getAttribute(Joint.attributeName))
|
34
|
-
|
35
|
-
destroy: (nodes) =>
|
36
|
-
for node in nodes
|
37
|
-
continue unless Joint.isDOM(node)
|
38
|
-
if node.hasAttribute(Joint.attributeName)
|
39
|
-
Joint.Creator.destroy(node)
|
40
|
-
|
41
|
-
for child in node.querySelectorAll("[#{Joint.attributeName}]")
|
42
|
-
Joint.Creator.destroy(child)
|
43
|
-
|
44
|
-
inspect: (node) ->
|
45
|
-
if Joint.isDOM(node)
|
46
|
-
found = node.querySelectorAll("[#{Joint.attributeName}]")
|
47
|
-
Joint.Creator.create(el) for el in found
|
48
|
-
|
49
|
-
@Joint.Watcher = new Watcher()
|
@@ -1,12 +0,0 @@
|
|
1
|
-
#= require 'joint/ext'
|
2
|
-
#= require 'joint/base'
|
3
|
-
#= require 'joint/watcher'
|
4
|
-
#= require 'joint/creator'
|
5
|
-
#= require 'joint/xhr'
|
6
|
-
|
7
|
-
if document.readyState == 'complete'
|
8
|
-
window.Joint.initialize()
|
9
|
-
else
|
10
|
-
document.addEventListener 'DOMContentLoaded', ->
|
11
|
-
window.Joint.initialize()
|
12
|
-
|
data/lib/jointjs/version.rb
DELETED
data/lib/jointjs.rb
DELETED
data/test/db/joint_test
DELETED
Binary file
|
File without changes
|
File without changes
|