volt 0.5.10 → 0.5.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Readme.md +4 -0
- data/VERSION +1 -1
- data/lib/volt/models/url.rb +45 -14
- data/lib/volt/page/bindings/template_binding.rb +25 -2
- data/lib/volt/page/page.rb +2 -4
- data/lib/volt/page/template_renderer.rb +0 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1b91323e2f7568714d8806c4a6a19ca652bcd42
|
4
|
+
data.tar.gz: 7b101bb67b83e2bd1e17e51deaba445c6e1b71d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79cd2a471f41f67827221272bba712810fe0e2f3451407c62bff270e35cc1ce21618bc1411614537e5a90c9636cdcfcc99c093d5ef76204b5f87efc4996fcfe1
|
7
|
+
data.tar.gz: df8606499fcdfc4aebfcf7e7ee1d49efd15f4a45b2e7def66a822f31ff035addd62a63f60f07ba40111d17705a07c37ba0a54554aa55edfa34031537f287b7f1
|
data/Readme.md
CHANGED
@@ -616,6 +616,10 @@ The above would search the following:
|
|
616
616
|
| blog | comments | index.html | :body |
|
617
617
|
| gems/blog | comments | index.html | :body |
|
618
618
|
|
619
|
+
# Context in Controls
|
620
|
+
|
621
|
+
Controls that render without a provided controller can access the context they were inserted in with the ```.parent``` method. Most of the time you want to pass in any data that will be used. But for things like calling methods on the parent controller, using ```.parent.some_method``` can be useful.
|
622
|
+
|
619
623
|
|
620
624
|
# Routes
|
621
625
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.11
|
data/lib/volt/models/url.rb
CHANGED
@@ -17,17 +17,29 @@ class URL
|
|
17
17
|
destructive!
|
18
18
|
end
|
19
19
|
def parse(url)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
if url[0] == '#'
|
21
|
+
# url only updates fragment
|
22
|
+
@fragment = url[1..-1]
|
23
|
+
else
|
24
|
+
# Add the host for localized names
|
25
|
+
if url[0..3] != 'http'
|
26
|
+
host = `document.location.host`
|
27
|
+
url = "http://#{host}" + url
|
28
|
+
end
|
29
|
+
|
30
|
+
matcher = url.match(/^(https?)[:]\/\/([^\/]+)(.*)$/)
|
31
|
+
@scheme = matcher[1]
|
32
|
+
@host, @port = matcher[2].split(':')
|
33
|
+
@port ||= 80
|
25
34
|
|
26
|
-
|
27
|
-
|
28
|
-
|
35
|
+
@path = matcher[3]
|
36
|
+
@path, @fragment = @path.split('#', 2)
|
37
|
+
@path, @query = @path.split('?', 2)
|
29
38
|
|
30
|
-
|
39
|
+
assign_query_hash_to_params
|
40
|
+
end
|
41
|
+
|
42
|
+
scroll
|
31
43
|
end
|
32
44
|
|
33
45
|
# Full url rebuilds the url from it's constituent parts
|
@@ -55,6 +67,8 @@ class URL
|
|
55
67
|
new_url += query_parts.join('&')
|
56
68
|
end
|
57
69
|
|
70
|
+
new_url += '#' + @fragment if @fragment
|
71
|
+
|
58
72
|
return new_url
|
59
73
|
end
|
60
74
|
|
@@ -62,10 +76,29 @@ class URL
|
|
62
76
|
# browser should be updated
|
63
77
|
# Called when an attribute changes to update the url
|
64
78
|
def update!
|
65
|
-
|
79
|
+
if Volt.client?
|
80
|
+
new_url = full_url()
|
66
81
|
|
67
|
-
|
68
|
-
|
82
|
+
if `(document.location.href != new_url)`
|
83
|
+
`history.pushState(null, null, new_url)`
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def scroll
|
89
|
+
if Volt.client?
|
90
|
+
if @fragment
|
91
|
+
# Scroll to anchor
|
92
|
+
%x{
|
93
|
+
var anchor = $('a[name="' + this.fragment + '"]');
|
94
|
+
if (anchor) {
|
95
|
+
$(document.body).scrollTop(anchor.offset().top);
|
96
|
+
}
|
97
|
+
}
|
98
|
+
else
|
99
|
+
# Scroll to the top by default
|
100
|
+
`$(document.body).scrollTop(0);`
|
101
|
+
end
|
69
102
|
end
|
70
103
|
end
|
71
104
|
|
@@ -85,8 +118,6 @@ class URL
|
|
85
118
|
# Loop through the .params we already have assigned.
|
86
119
|
assign_from_old(@params, query_hash)
|
87
120
|
assign_new(@params, query_hash)
|
88
|
-
|
89
|
-
puts @params.inspect + '---'
|
90
121
|
end
|
91
122
|
|
92
123
|
# Loop through the old params, and overwrite any existing values,
|
@@ -3,7 +3,7 @@ require 'volt/page/template_renderer'
|
|
3
3
|
|
4
4
|
class TemplateBinding < BaseBinding
|
5
5
|
def initialize(target, context, binding_name, binding_in_path, getter)
|
6
|
-
# puts "New template binding: #{context.inspect} - #{binding_name.inspect}
|
6
|
+
# puts "New template binding: #{context.inspect} - #{binding_name.inspect}"
|
7
7
|
super(target, context, binding_name)
|
8
8
|
|
9
9
|
# Binding in path is the path for the template this binding is in
|
@@ -108,6 +108,7 @@ class TemplateBinding < BaseBinding
|
|
108
108
|
|
109
109
|
def update
|
110
110
|
full_path, controller_name = path_for_template(@path.cur, @section.cur)
|
111
|
+
puts "Update: #{full_path} - #{controller_name.inspect}"
|
111
112
|
|
112
113
|
@current_template.remove if @current_template
|
113
114
|
|
@@ -140,7 +141,20 @@ class TemplateBinding < BaseBinding
|
|
140
141
|
current_context = @context
|
141
142
|
end
|
142
143
|
|
143
|
-
@current_template = TemplateRenderer.new(@target, current_context, @binding_name, full_path)
|
144
|
+
@current_template = TemplateRenderer.new(@target, current_context, @binding_name, full_path)
|
145
|
+
|
146
|
+
if controller
|
147
|
+
if current_context.respond_to?(:section=)
|
148
|
+
current_context.section = @current_template.section
|
149
|
+
end
|
150
|
+
|
151
|
+
if current_context.respond_to?(:dom_ready)
|
152
|
+
current_context.dom_ready
|
153
|
+
end
|
154
|
+
|
155
|
+
@controller = controller
|
156
|
+
end
|
157
|
+
|
144
158
|
end
|
145
159
|
|
146
160
|
def remove
|
@@ -161,6 +175,15 @@ class TemplateBinding < BaseBinding
|
|
161
175
|
end
|
162
176
|
|
163
177
|
super
|
178
|
+
|
179
|
+
if @controller
|
180
|
+
# Let the controller know we removed
|
181
|
+
if @controller.respond_to?(:dom_removed)
|
182
|
+
@controller.dom_removed
|
183
|
+
end
|
184
|
+
|
185
|
+
@controller = nil
|
186
|
+
end
|
164
187
|
end
|
165
188
|
|
166
189
|
private
|
data/lib/volt/page/page.rb
CHANGED
@@ -75,14 +75,13 @@ class Page
|
|
75
75
|
@tasks ||= Tasks.new(self)
|
76
76
|
end
|
77
77
|
|
78
|
-
def link_clicked(url)
|
78
|
+
def link_clicked(url='')
|
79
79
|
# Skip when href == ''
|
80
80
|
return if url.blank?
|
81
81
|
|
82
82
|
# Normalize url
|
83
83
|
# Benchmark.bm(1) do
|
84
|
-
|
85
|
-
@url.parse("http://#{host}" + url)
|
84
|
+
@url.parse(url)
|
86
85
|
# end
|
87
86
|
|
88
87
|
# Clear the flash
|
@@ -161,7 +160,6 @@ class Page
|
|
161
160
|
page_obj_str = nil
|
162
161
|
|
163
162
|
`page_obj_str = sessionStorage.getItem('___page');`
|
164
|
-
`console.log(page_obj_str);`
|
165
163
|
`if (page_obj_str) {`
|
166
164
|
`sessionStorage.removeItem('___page');`
|
167
165
|
|
@@ -25,15 +25,6 @@ class TemplateRenderer < BaseBinding
|
|
25
25
|
@sub_bindings << binding.call(target, context, id)
|
26
26
|
end
|
27
27
|
end
|
28
|
-
|
29
|
-
if @context.respond_to?(:section=)
|
30
|
-
@context.section = self.section
|
31
|
-
end
|
32
|
-
|
33
|
-
if @context.respond_to?(:dom_ready)
|
34
|
-
@context.dom_ready
|
35
|
-
end
|
36
|
-
|
37
28
|
end
|
38
29
|
|
39
30
|
def remove
|
@@ -51,12 +42,6 @@ class TemplateRenderer < BaseBinding
|
|
51
42
|
@sub_bindings = []
|
52
43
|
|
53
44
|
super
|
54
|
-
|
55
|
-
# Let the controller know we removed
|
56
|
-
if @context.respond_to?(:dom_removed)
|
57
|
-
@context.dom_removed
|
58
|
-
end
|
59
|
-
|
60
45
|
end
|
61
46
|
|
62
47
|
def remove_anchors
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: volt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Stout
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|