constructor-pages 0.2.3 → 0.2.4

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.
@@ -0,0 +1,59 @@
1
+ $(document).ready(function() {
2
+ $page = {};
3
+ update_pages();
4
+ });
5
+
6
+ function update_pages(){
7
+ $('.b-page-json').each(function(index, el){
8
+ var _href = $(el).attr('href');
9
+
10
+ $(el).unbind('click');
11
+
12
+ $(el).click(function(event){
13
+ event.preventDefault();
14
+ history.pushState(null, null, _href);
15
+
16
+ window.onpopstate = function(){
17
+ update_page(window.location.href.toString().split(window.location.host)[1]);
18
+ };
19
+
20
+ update_page(_href);
21
+ });
22
+ });
23
+ }
24
+
25
+ function update_page(href) {
26
+ var _b_page_json = $('.b-page-json');
27
+
28
+ close_blocks();
29
+
30
+ $.get(href+'.json', function(page){
31
+ $page = page;
32
+
33
+ $('title').html(page.title || page.name);
34
+
35
+ var partials = JSON.parse(page.template);
36
+ var names = Object.keys(partials);
37
+
38
+ for (i in names) {
39
+ var name = names[i];
40
+
41
+ $('.b-page-part__'+name).html(partials[name]);
42
+ }
43
+
44
+ _b_page_json.parent().removeClass('active');
45
+
46
+ for (var i in $page.ancestors) {
47
+ var ancestor = $page.ancestors[i];
48
+ $('.b-page-json__id-'+ancestor).addClass('active');
49
+ }
50
+
51
+ el.parent().addClass('active');
52
+
53
+ update_pages();
54
+
55
+ eval(page.js);
56
+ });
57
+
58
+ var el = $('a[href="'+ href +'"]');
59
+ }
@@ -3,7 +3,7 @@
3
3
  Gem::Specification.new do |s|
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.name = %q{constructor-pages}
6
- s.version = '0.2.3'
6
+ s.version = '0.2.4'
7
7
  s.summary = %q{Pages for ConstructorCms}
8
8
  s.authors = ['Ivan Zotov']
9
9
  s.require_paths = %w(lib)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: constructor-pages
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -134,6 +134,7 @@ files:
134
134
  - app/assets/images/constructor_pages/information.png
135
135
  - app/assets/images/constructor_pages/page_white_edit.png
136
136
  - app/assets/images/constructor_pages/photos.png
137
+ - app/assets/javascripts/ajax_pages.js
137
138
  - app/controllers/constructor_pages/fields_controller.rb
138
139
  - app/controllers/constructor_pages/pages_controller.rb
139
140
  - app/controllers/constructor_pages/templates_controller.rb