knockout-rails 0.0.2 → 0.0.3
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.
data/HISTORY.md
CHANGED
@@ -4,10 +4,10 @@
|
|
4
4
|
- Client side validation
|
5
5
|
- JST templating support
|
6
6
|
|
7
|
-
# 0.0.2 - 26 November 2011
|
7
|
+
# 0.0.2-3 - 26 November 2011
|
8
8
|
|
9
9
|
- do not require bindings automatically
|
10
|
-
- includes bindings: autosave, inplace, onoff, color
|
10
|
+
- includes bindings: autosave, inplace, onoff, color, animate
|
11
11
|
|
12
12
|
# 0.0.1 - 17 November 2011
|
13
13
|
Initial release. Bare bones moved over from other project. Includes:
|
data/README.md
CHANGED
@@ -78,8 +78,6 @@ For example, you can use `autosave` binding by requiring `knockout/bindings/auto
|
|
78
78
|
|
79
79
|
Or if you want to include all of the bindings available, then require `knockout/bindings/all`.
|
80
80
|
|
81
|
-
Please see the specs for more detailed instruction on how to use specific binding.
|
82
|
-
|
83
81
|
The list of currently available bindings:
|
84
82
|
|
85
83
|
- `autosave` - automatically persists the model whenever any of its attributes change.
|
@@ -87,6 +85,9 @@ The list of currently available bindings:
|
|
87
85
|
- `inplace` - converts the input elements into inplace editing with 'Edit'/'Done' buttons. Apply it on `input` elements similarly to the `value` binding.
|
88
86
|
- `color` - converts an element into a color picker. Apply it to a `div` element: `color: page.fontColor`. Depends on [pakunok](https://github.com/dnagir/pakunok) gem (specifically - its `colorpicker` asset).
|
89
87
|
- `onoff` - Converts checkboxes into iOS on/off buttons. Example: `onoff: page.isPublic`. It depends on [ios-chechboxes](https://github.com/dnagir/ios-checkboxes) gem.
|
88
|
+
- 'animate' - runs the animation. Example: `animate: {width: quotaUsed, height: quotaUsed(), duration: 2000}`.
|
89
|
+
|
90
|
+
Please see the specs for more detailed instruction on how to use the specific binding.
|
90
91
|
|
91
92
|
# Development
|
92
93
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
runAnimation = (element, valueAccessor) ->
|
2
|
+
flat = valueAccessor()
|
3
|
+
|
4
|
+
optionKeys = ['duration', 'easing', 'complete', 'step', 'queue', 'specialEasing']
|
5
|
+
|
6
|
+
properties = {}
|
7
|
+
Object.keys(flat).exclude(optionKeys).forEach (key) ->
|
8
|
+
properties[key] = ko.utils.unwrapObservable flat[key]
|
9
|
+
|
10
|
+
options = {}
|
11
|
+
optionKeys.forEach (key) ->
|
12
|
+
options[key] = flat[key] if flat[key]?
|
13
|
+
|
14
|
+
$(element).animate properties, options
|
15
|
+
|
16
|
+
ko.bindingHandlers.animate =
|
17
|
+
init: runAnimation
|
18
|
+
update: runAnimation
|
19
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#= require knockout/bindings/animate
|
2
|
+
|
3
|
+
describe "Animate binding", ->
|
4
|
+
beforeEach ->
|
5
|
+
@animate = spyOn jQuery.fn, 'animate'
|
6
|
+
binding = "width: dataUsed, height: dataUsed(), duration: 2000, easing: 'linear', complete: flash"
|
7
|
+
setFixtures "<div id='anim' data-bind=\"animate: {#{binding}}\" /> "
|
8
|
+
@el = $("#anim")
|
9
|
+
@targetSize = 600
|
10
|
+
ko.applyBindings {
|
11
|
+
dataUsed: ko.observable(@targetSize),
|
12
|
+
flash: ->{}
|
13
|
+
}, @el[0]
|
14
|
+
|
15
|
+
it "should call the jQuery animate", ->
|
16
|
+
expect(@animate).toHaveBeenCalled()
|
17
|
+
|
18
|
+
it "should have correct css properties to animate", ->
|
19
|
+
properties = @animate.mostRecentCall.args[0]
|
20
|
+
expect(properties.width).toBe @targetSize
|
21
|
+
expect(properties.height).toBe @targetSize
|
22
|
+
|
23
|
+
it "should have correct animation options", ->
|
24
|
+
options = @animate.mostRecentCall.args[1]
|
25
|
+
expect(options.duration).toBe 2000
|
26
|
+
expect(options.easing).toBe 'linear'
|
27
|
+
expect(typeof options.complete).toBe 'function'
|
28
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knockout-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-11-26 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sprockets
|
16
|
-
requirement: &
|
16
|
+
requirement: &70126369879100 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70126369879100
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: execjs
|
27
|
-
requirement: &
|
27
|
+
requirement: &70126369878560 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70126369878560
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: jquery-rails
|
38
|
-
requirement: &
|
38
|
+
requirement: &70126369878020 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70126369878020
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &70126369877580 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70126369877580
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rails
|
60
|
-
requirement: &
|
60
|
+
requirement: &70126369877040 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: 3.1.1
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70126369877040
|
69
69
|
description: Include the knockout.js and some of its extensions so you can pick what
|
70
70
|
you need. Adds the support for models and interation with the Rails backend.
|
71
71
|
email:
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- knockout-rails.gemspec
|
83
83
|
- lib/assets/javascripts/knockout.js
|
84
84
|
- lib/assets/javascripts/knockout/bindings/all.js
|
85
|
+
- lib/assets/javascripts/knockout/bindings/animate.js.coffee
|
85
86
|
- lib/assets/javascripts/knockout/bindings/autosave.js.coffee
|
86
87
|
- lib/assets/javascripts/knockout/bindings/color.js.coffee
|
87
88
|
- lib/assets/javascripts/knockout/bindings/inplace.js.coffee
|
@@ -121,6 +122,7 @@ files:
|
|
121
122
|
- spec/dummy/public/500.html
|
122
123
|
- spec/dummy/public/favicon.ico
|
123
124
|
- spec/dummy/script/rails
|
125
|
+
- spec/javascripts/knockout/bindings/animate_spec.js.coffee
|
124
126
|
- spec/javascripts/knockout/bindings/autosave_spec.js.coffee
|
125
127
|
- spec/javascripts/knockout/bindings/color_spec.js.coffee
|
126
128
|
- spec/javascripts/knockout/bindings/inplace_spec.js.coffee
|
@@ -150,7 +152,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
150
152
|
version: '0'
|
151
153
|
segments:
|
152
154
|
- 0
|
153
|
-
hash:
|
155
|
+
hash: 3220950392876216281
|
154
156
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
157
|
none: false
|
156
158
|
requirements:
|
@@ -159,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
161
|
version: '0'
|
160
162
|
segments:
|
161
163
|
- 0
|
162
|
-
hash:
|
164
|
+
hash: 3220950392876216281
|
163
165
|
requirements: []
|
164
166
|
rubyforge_project: knockout-rails
|
165
167
|
rubygems_version: 1.8.10
|
@@ -198,6 +200,7 @@ test_files:
|
|
198
200
|
- spec/dummy/public/500.html
|
199
201
|
- spec/dummy/public/favicon.ico
|
200
202
|
- spec/dummy/script/rails
|
203
|
+
- spec/javascripts/knockout/bindings/animate_spec.js.coffee
|
201
204
|
- spec/javascripts/knockout/bindings/autosave_spec.js.coffee
|
202
205
|
- spec/javascripts/knockout/bindings/color_spec.js.coffee
|
203
206
|
- spec/javascripts/knockout/bindings/inplace_spec.js.coffee
|