observejs 0.0.5

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.
Files changed (62) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +65 -0
  6. data/Rakefile +3 -0
  7. data/jointjs.gemspec +23 -0
  8. data/lib/jointjs/app/assets/javascripts/joint/base.js.coffee +18 -0
  9. data/lib/jointjs/app/assets/javascripts/joint/creator.js.coffee +41 -0
  10. data/lib/jointjs/app/assets/javascripts/joint/ext.js.coffee +7 -0
  11. data/lib/jointjs/app/assets/javascripts/joint/watcher.js.coffee +49 -0
  12. data/lib/jointjs/app/assets/javascripts/joint/xhr.js.coffee +110 -0
  13. data/lib/jointjs/app/assets/javascripts/joint.js.coffee +12 -0
  14. data/lib/jointjs/app/views/layouts/application.js.erb +6 -0
  15. data/lib/jointjs/railtie.rb +8 -0
  16. data/lib/jointjs/version.rb +3 -0
  17. data/lib/jointjs.rb +5 -0
  18. data/test/Gemfile +27 -0
  19. data/test/Gemfile.lock +164 -0
  20. data/test/README.rdoc +28 -0
  21. data/test/Rakefile +6 -0
  22. data/test/app/assets/javascripts/application.js +4 -0
  23. data/test/app/assets/javascripts/item.js.coffee +2 -0
  24. data/test/app/assets/javascripts/list.js.coffee +6 -0
  25. data/test/app/assets/javascripts/tests/instances.js.coffee +17 -0
  26. data/test/app/assets/javascripts/tests/xhr.js.coffee +20 -0
  27. data/test/app/controllers/todos_controller.rb +18 -0
  28. data/test/app/models/todo.rb +2 -0
  29. data/test/app/views/layouts/application.html.erb +16 -0
  30. data/test/app/views/todos/_todo.html.erb +1 -0
  31. data/test/app/views/todos/create.js.erb +1 -0
  32. data/test/app/views/todos/index.html.erb +11 -0
  33. data/test/bin/bundle +3 -0
  34. data/test/bin/rails +8 -0
  35. data/test/bin/rake +8 -0
  36. data/test/bin/setup +29 -0
  37. data/test/bin/spring +18 -0
  38. data/test/config/application.rb +26 -0
  39. data/test/config/boot.rb +3 -0
  40. data/test/config/database.yml +11 -0
  41. data/test/config/environment.rb +5 -0
  42. data/test/config/environments/development.rb +41 -0
  43. data/test/config/environments/production.rb +79 -0
  44. data/test/config/environments/test.rb +42 -0
  45. data/test/config/initializers/assets.rb +11 -0
  46. data/test/config/initializers/backtrace_silencers.rb +7 -0
  47. data/test/config/initializers/cookies_serializer.rb +3 -0
  48. data/test/config/initializers/filter_parameter_logging.rb +4 -0
  49. data/test/config/initializers/inflections.rb +16 -0
  50. data/test/config/initializers/mime_types.rb +4 -0
  51. data/test/config/initializers/session_store.rb +3 -0
  52. data/test/config/initializers/wrap_parameters.rb +14 -0
  53. data/test/config/locales/en.yml +23 -0
  54. data/test/config/routes.rb +4 -0
  55. data/test/config/secrets.yml +2 -0
  56. data/test/config.ru +4 -0
  57. data/test/db/joint_test +0 -0
  58. data/test/db/migrate/20150106151240_create_todos.rb +9 -0
  59. data/test/db/schema.rb +22 -0
  60. data/test/db/seeds.rb +1 -0
  61. data/test/integration/load_test.rb +24 -0
  62. metadata +204 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bd073a5b83f32fad3ad67963494c19805dd4c864
4
+ data.tar.gz: 5a806556aa26a32d44702cce679be4cf4ef58851
5
+ SHA512:
6
+ metadata.gz: 3fa57f1031876da0bad348dcb068992fdfb9b5fc51fb990356134356d787456b8abbfb14467e2f39ad83b140cc6e6954f6ffdb238e831080ad521068c5fc53f6
7
+ data.tar.gz: 3712714f8ef1bb3279e1cf00aa2d3ce9ae2c9b41b95c89bf31d2d72b27cff251faafa97ca01b0e1ac41ea8c22181c814563ed196c5b445b320ed22c577ee0f59
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ tmp
10
+ *.gem
11
+ *.bundle
12
+ *.so
13
+ *.o
14
+ *.a
15
+ *.log
16
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ethereal.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Pier-Olivier Thibault
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # JointJS
2
+
3
+ Event based JavaScript framework tailored made for Ruby on rails.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'jointjs'
11
+ ```
12
+
13
+ Then add this line to application.js
14
+
15
+ ```js
16
+ //= require 'joint'
17
+ ```
18
+ ## Usage
19
+
20
+ JointJSe 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
+
22
+ ```erb
23
+ <!-- views/todos/index.html.erb -->
24
+ <%= content_tag :ol, as: 'Todo.List', do %>
25
+ <%= render @todos %>
26
+ <% end %>
27
+ ```
28
+
29
+ ```coffee
30
+ # assets/javascripts/todos/list.js.coffee
31
+ Joint.bind 'Todo.List', class
32
+ # @element() always return the element to which your object is bound.
33
+
34
+ loaded: =>
35
+ @element().on 'todos:create', @add
36
+ @element().on 'todos:destroy', @delete
37
+
38
+ add: (e) =>
39
+ @element().appendChild(e.html)
40
+
41
+ delete: (e) =>
42
+ @element().querySelector("[tid=#{e.todoId}]")?.remove()
43
+
44
+ ```
45
+
46
+ ```ruby
47
+ #views/todos/create.js.erb
48
+ e.html = "<%= j render(@todo) %>".toHTML()
49
+ ```
50
+
51
+ ```ruby
52
+ #views/todos/destroy.js.erb
53
+ e.todoId = <%= @todo.id %>
54
+ ```
55
+
56
+ Some notes:
57
+
58
+ - Automatic instantiation. No need to wrap things in DOMContentReady anymore.
59
+ - Events are built following the "controller:action" pattern.
60
+ - A callback (@loaded) is called right after JointJS has instantiated an object.
61
+ - In *.js.erb, an event is created. You can set HTML to the event object.
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 ```Joint.bind 'name', Class```. The name is the attribute you set in your DOM.
64
+
65
+
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require File.expand_path('../test/application', __FILE__)
2
+
3
+ JointTest::Application.load_tasks
data/jointjs.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jointjs/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "observejs"
8
+ spec.version = JointJS::VERSION
9
+ spec.authors = ["Pier-Olivier Thibault"]
10
+ spec.email = ["pothibo@gmail.com"]
11
+ spec.summary = %q{Event based JavaScript framework tailored for Ruby on rails.}
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files -z`.split("\x0")
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_development_dependency "bundler", "~> 1.7"
20
+ spec.add_development_dependency "rake", "~> 10.0"
21
+ spec.add_development_dependency "rails", "~> 4.1"
22
+ spec.add_development_dependency "sqlite3"
23
+ end
@@ -0,0 +1,18 @@
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()
@@ -0,0 +1,41 @@
1
+ class Creator
2
+
3
+ update: (el) =>
4
+ model = el.getAttribute(Joint.attributeName)
5
+ if model?
6
+ @create(el, model)
7
+ else
8
+ @destroy(el)
9
+
10
+ create: (el) =>
11
+ model = el.getAttribute(Joint.attributeName)
12
+ if Joint.cache[model]?
13
+ if el.instance?
14
+ return
15
+
16
+ el.instance = new Joint.cache[model](el)
17
+
18
+ el.instance.element = ->
19
+ el
20
+
21
+ el.instance.on = (event, target, callback) ->
22
+ if callback?
23
+ el.instance.on.events.push([event, target, callback])
24
+ else
25
+ callback = target
26
+ target = el
27
+ target.addEventListener(event, callback)
28
+
29
+ el.instance.on.events = []
30
+
31
+ if el.instance.loaded?
32
+ el.instance.loaded()
33
+
34
+ else
35
+ throw "error: #{model} is not registered. Add your model with Joint.Models.add(#{model})"
36
+
37
+ destroy: (el) =>
38
+ el.instance.on.events?.forEach (event) ->
39
+ event[1].removeEventListener(event[0], event[2])
40
+
41
+ @Joint.Creator = new Creator()
@@ -0,0 +1,7 @@
1
+ String::toHTML = ->
2
+ el = document.createElement('div')
3
+ el.innerHTML = this
4
+ if el.children.length > 1
5
+ el.children
6
+ else
7
+ el.children[0]
@@ -0,0 +1,49 @@
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()
@@ -0,0 +1,110 @@
1
+ class XHRData
2
+ constructor: (el) ->
3
+ @backend = {}
4
+ if el instanceof HTMLFormElement
5
+ @form = el
6
+
7
+ set: (k, v) =>
8
+ @backend[k] = v
9
+ @keys().push(k)
10
+
11
+ value: (k) =>
12
+ @backend[k]
13
+
14
+ has: (k) =>
15
+ @backend[k]?
16
+
17
+ keys: =>
18
+ store = []
19
+ fn = ->
20
+ store
21
+ @keys = fn
22
+ fn()
23
+
24
+ any: =>
25
+ @keys().length > 0
26
+
27
+ serialize: =>
28
+ formData = new FormData(@form)
29
+ for key in @keys()
30
+ formData.append key, @value(key)
31
+
32
+ formData
33
+
34
+ class XHR
35
+ script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
36
+
37
+ @completed: (e) ->
38
+ if e.target.responseText.length > 1
39
+ eval(e.target.responseText)(e.target.element)
40
+
41
+ @send: (el) ->
42
+
43
+ xhr = new XHR(el)
44
+ xhr.send()
45
+ xhr
46
+
47
+ constructor: (el) ->
48
+ @data = new XHRData(el)
49
+ @request = new XMLHttpRequest()
50
+ @request.element = el
51
+ @request.addEventListener 'load', XHR.completed
52
+
53
+ @method = el.getAttribute('method') || 'GET'
54
+
55
+ send: =>
56
+ action = @request.element.getAttribute('action') || @request.element.getAttribute('href')
57
+
58
+ unless action?
59
+ throw "Cannot send a request to the server if the element isn't a Form or if the element doesn't have the HREF attributes: <div href>"
60
+ return
61
+
62
+ if @method == 'GET' && @data.any()
63
+ parser = document.createElement('a')
64
+ parser.href = action
65
+ params = parser.search.substring(1).split('&')
66
+
67
+ for key in @data.keys()
68
+ params.push "#{key}=#{@data.value(key)}"
69
+
70
+ parser.search = "?#{params.join("&")}"
71
+
72
+ action = parser.href
73
+
74
+ @request.open @method, action
75
+ @request.setRequestHeader 'accept', "*/*;q=0.5, #{@script}"
76
+ @request.setRequestHeader 'X-Requested-With', "XMLHttpRequest"
77
+
78
+ if @method != 'GET'
79
+ token = document.querySelector('meta[name=csrf-token]').getAttribute('content')
80
+ @request.setRequestHeader 'X-CSRF-Token', token
81
+
82
+ @request.send(@data.serialize())
83
+
84
+
85
+ Joint.XHR = XHR
86
+
87
+ document.addEventListener 'submit', (e) =>
88
+ if e.target.getAttribute('disabled')? || e.target.dataset['remote'] != 'true'
89
+ return
90
+
91
+ XHR.send(e.target)
92
+
93
+ e.preventDefault()
94
+ return false
95
+
96
+ document.addEventListener 'click', (e) =>
97
+ el = e.target
98
+ while el? && !(el instanceof HTMLAnchorElement)
99
+ el = el.parentElement
100
+
101
+ return unless el?
102
+
103
+ if el.getAttribute('disabled')? || el.dataset['remote'] != 'true'
104
+ return
105
+
106
+ XHR.send(el)
107
+
108
+ e.preventDefault()
109
+ return false
110
+
@@ -0,0 +1,12 @@
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
+
@@ -0,0 +1,6 @@
1
+ (function(target) {
2
+ var e = new CustomEvent("<%= j "#{controller_name}:#{action_name}" %>", {bubbles: true})
3
+ <%= yield %>
4
+ target.dispatchEvent(e)
5
+ })
6
+
@@ -0,0 +1,8 @@
1
+ module JointJS
2
+ class Railtie < Rails::Railtie
3
+ initializer 'joint.assets.paths', before: :add_view_paths do |app|
4
+ app.paths['vendor/assets'] << File.dirname(__FILE__) + '/app/assets/'
5
+ app.paths['app/views'] << File.dirname(__FILE__) + '/app/views/'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module JointJS
2
+ VERSION = "0.0.5"
3
+ end
data/lib/jointjs.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "jointjs/version"
2
+
3
+ module JointJS
4
+ require 'jointjs/railtie'
5
+ end
data/test/Gemfile ADDED
@@ -0,0 +1,27 @@
1
+ source 'https://rubygems.org'
2
+
3
+
4
+ gem 'rails', '4.2.0'
5
+ gem 'sqlite3'
6
+ gem 'sass-rails', '~> 5.0'
7
+ gem 'uglifier', '>= 1.3.0'
8
+ gem 'coffee-rails', '~> 4.1.0'
9
+ gem 'jquery-rails'
10
+ gem 'turbolinks'
11
+ gem 'jbuilder', '~> 2.0'
12
+
13
+ path = Pathname.new(__FILE__) + '..'
14
+
15
+ gem 'jointjs', path: path.dirname
16
+
17
+ group :development, :test do
18
+ # Call 'byebug' anywhere in the code to stop execution and get a debugger console
19
+ gem 'byebug'
20
+
21
+ # Access an IRB console on exception pages or by using <%= console %> in views
22
+ gem 'web-console', '~> 2.0'
23
+
24
+ # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
25
+ gem 'spring'
26
+ end
27
+
data/test/Gemfile.lock ADDED
@@ -0,0 +1,164 @@
1
+ PATH
2
+ remote: /Users/pothibo/Develop/jointjs
3
+ specs:
4
+ jointjs (0.0.4)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actionmailer (4.2.0)
10
+ actionpack (= 4.2.0)
11
+ actionview (= 4.2.0)
12
+ activejob (= 4.2.0)
13
+ mail (~> 2.5, >= 2.5.4)
14
+ rails-dom-testing (~> 1.0, >= 1.0.5)
15
+ actionpack (4.2.0)
16
+ actionview (= 4.2.0)
17
+ activesupport (= 4.2.0)
18
+ rack (~> 1.6.0)
19
+ rack-test (~> 0.6.2)
20
+ rails-dom-testing (~> 1.0, >= 1.0.5)
21
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
22
+ actionview (4.2.0)
23
+ activesupport (= 4.2.0)
24
+ builder (~> 3.1)
25
+ erubis (~> 2.7.0)
26
+ rails-dom-testing (~> 1.0, >= 1.0.5)
27
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
28
+ activejob (4.2.0)
29
+ activesupport (= 4.2.0)
30
+ globalid (>= 0.3.0)
31
+ activemodel (4.2.0)
32
+ activesupport (= 4.2.0)
33
+ builder (~> 3.1)
34
+ activerecord (4.2.0)
35
+ activemodel (= 4.2.0)
36
+ activesupport (= 4.2.0)
37
+ arel (~> 6.0)
38
+ activesupport (4.2.0)
39
+ i18n (~> 0.7)
40
+ json (~> 1.7, >= 1.7.7)
41
+ minitest (~> 5.1)
42
+ thread_safe (~> 0.3, >= 0.3.4)
43
+ tzinfo (~> 1.1)
44
+ arel (6.0.0)
45
+ binding_of_caller (0.7.2)
46
+ debug_inspector (>= 0.0.1)
47
+ builder (3.2.2)
48
+ byebug (3.5.1)
49
+ columnize (~> 0.8)
50
+ debugger-linecache (~> 1.2)
51
+ slop (~> 3.6)
52
+ coffee-rails (4.1.0)
53
+ coffee-script (>= 2.2.0)
54
+ railties (>= 4.0.0, < 5.0)
55
+ coffee-script (2.3.0)
56
+ coffee-script-source
57
+ execjs
58
+ coffee-script-source (1.8.0)
59
+ columnize (0.9.0)
60
+ debug_inspector (0.0.2)
61
+ debugger-linecache (1.2.0)
62
+ erubis (2.7.0)
63
+ execjs (2.2.2)
64
+ globalid (0.3.0)
65
+ activesupport (>= 4.1.0)
66
+ hike (1.2.3)
67
+ i18n (0.7.0)
68
+ jbuilder (2.2.6)
69
+ activesupport (>= 3.0.0, < 5)
70
+ multi_json (~> 1.2)
71
+ jquery-rails (4.0.3)
72
+ rails-dom-testing (~> 1.0)
73
+ railties (>= 4.2.0)
74
+ thor (>= 0.14, < 2.0)
75
+ json (1.8.1)
76
+ loofah (2.0.1)
77
+ nokogiri (>= 1.5.9)
78
+ mail (2.6.3)
79
+ mime-types (>= 1.16, < 3)
80
+ mime-types (2.4.3)
81
+ mini_portile (0.6.2)
82
+ minitest (5.5.0)
83
+ multi_json (1.10.1)
84
+ nokogiri (1.6.5)
85
+ mini_portile (~> 0.6.0)
86
+ rack (1.6.0)
87
+ rack-test (0.6.2)
88
+ rack (>= 1.0)
89
+ rails (4.2.0)
90
+ actionmailer (= 4.2.0)
91
+ actionpack (= 4.2.0)
92
+ actionview (= 4.2.0)
93
+ activejob (= 4.2.0)
94
+ activemodel (= 4.2.0)
95
+ activerecord (= 4.2.0)
96
+ activesupport (= 4.2.0)
97
+ bundler (>= 1.3.0, < 2.0)
98
+ railties (= 4.2.0)
99
+ sprockets-rails
100
+ rails-deprecated_sanitizer (1.0.3)
101
+ activesupport (>= 4.2.0.alpha)
102
+ rails-dom-testing (1.0.5)
103
+ activesupport (>= 4.2.0.beta, < 5.0)
104
+ nokogiri (~> 1.6.0)
105
+ rails-deprecated_sanitizer (>= 1.0.1)
106
+ rails-html-sanitizer (1.0.1)
107
+ loofah (~> 2.0)
108
+ railties (4.2.0)
109
+ actionpack (= 4.2.0)
110
+ activesupport (= 4.2.0)
111
+ rake (>= 0.8.7)
112
+ thor (>= 0.18.1, < 2.0)
113
+ rake (10.4.2)
114
+ sass (3.4.9)
115
+ sass-rails (5.0.1)
116
+ railties (>= 4.0.0, < 5.0)
117
+ sass (~> 3.1)
118
+ sprockets (>= 2.8, < 4.0)
119
+ sprockets-rails (>= 2.0, < 4.0)
120
+ tilt (~> 1.1)
121
+ slop (3.6.0)
122
+ spring (1.2.0)
123
+ sprockets (2.12.3)
124
+ hike (~> 1.2)
125
+ multi_json (~> 1.0)
126
+ rack (~> 1.0)
127
+ tilt (~> 1.1, != 1.3.0)
128
+ sprockets-rails (2.2.2)
129
+ actionpack (>= 3.0)
130
+ activesupport (>= 3.0)
131
+ sprockets (>= 2.8, < 4.0)
132
+ sqlite3 (1.3.10)
133
+ thor (0.19.1)
134
+ thread_safe (0.3.4)
135
+ tilt (1.4.1)
136
+ turbolinks (2.5.3)
137
+ coffee-rails
138
+ tzinfo (1.2.2)
139
+ thread_safe (~> 0.1)
140
+ uglifier (2.6.1)
141
+ execjs (>= 0.3.0)
142
+ json (>= 1.8.0)
143
+ web-console (2.0.0)
144
+ activemodel (~> 4.0)
145
+ binding_of_caller (>= 0.7.2)
146
+ railties (~> 4.0)
147
+ sprockets-rails (>= 2.0, < 4.0)
148
+
149
+ PLATFORMS
150
+ ruby
151
+
152
+ DEPENDENCIES
153
+ byebug
154
+ coffee-rails (~> 4.1.0)
155
+ jbuilder (~> 2.0)
156
+ jointjs!
157
+ jquery-rails
158
+ rails (= 4.2.0)
159
+ sass-rails (~> 5.0)
160
+ spring
161
+ sqlite3
162
+ turbolinks
163
+ uglifier (>= 1.3.0)
164
+ web-console (~> 2.0)
data/test/README.rdoc ADDED
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
data/test/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,4 @@
1
+ //= require joint
2
+ //= require list
3
+ //= require item
4
+ //= require_tree ./tests
@@ -0,0 +1,2 @@
1
+ Joint.bind 'List.Item', ->
2
+ loaded: ->
@@ -0,0 +1,6 @@
1
+ Joint.bind 'List', class
2
+ loaded: ->
3
+ @on 'todos:create', document, @append
4
+
5
+ append: (e) =>
6
+ @element().insertBefore(e.HTML, @element().firstChild)
@@ -0,0 +1,17 @@
1
+ document.addEventListener 'readystatechange', (e) ->
2
+ return unless document.readyState == 'complete'
3
+ QUnit.test 'All declared HTML element should have an instance', (assert) ->
4
+ elements = document.querySelectorAll("li[as='List.Item']")
5
+ for li in elements
6
+ assert.ok li.instance, "No instance bound to the element"
7
+
8
+ QUnit.test 'If an element is inserted in the DOM, load its instance', (assert) ->
9
+ count = document.querySelectorAll("li[as='List.Item']").length
10
+ li = "<li as='List.Item'>Item ##{count + 1}</li>".toHTML()
11
+ document.querySelector('ol.test.items').appendChild(li)
12
+ assert.ok count + 1 == document.querySelectorAll("li[as='List.Item']").length, "Should instantiate a new instance for the new item"
13
+ li.remove()
14
+
15
+ event = new CustomEvent('QUnit:Joint:Initialized')
16
+ document.dispatchEvent(event)
17
+