constructor-pages 0.7.7 → 0.7.8
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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/constructor_pages/.keep +0 -0
- data/app/assets/javascripts/constructor_pages/urlify.js +75 -0
- data/app/assets/stylesheets/constructor_pages/.keep +0 -0
- data/app/controllers/constructor_pages/fields_controller.rb +7 -5
- data/app/controllers/constructor_pages/pages_controller.rb +24 -31
- data/app/controllers/constructor_pages/templates_controller.rb +2 -2
- data/app/helpers/constructor_pages/treeview_helper.rb +14 -0
- data/app/models/constructor_pages/page.rb +9 -7
- data/app/models/constructor_pages/template.rb +10 -1
- data/app/views/constructor_pages/fields/_field.haml +11 -0
- data/app/views/constructor_pages/fields/_form.haml +4 -4
- data/app/views/constructor_pages/fields/types/_float.haml +1 -1
- data/app/views/constructor_pages/fields/types/_integer.haml +1 -1
- data/app/views/constructor_pages/pages/_field.haml +4 -0
- data/app/views/constructor_pages/pages/_form.haml +4 -9
- data/app/views/constructor_pages/pages/index.haml +8 -15
- data/app/views/constructor_pages/pages/new_child.haml +5 -0
- data/app/views/constructor_pages/templates/_form.haml +2 -13
- data/app/views/constructor_pages/templates/index.haml +3 -3
- data/config/locales/ru.yml +71 -1
- data/config/routes.rb +7 -10
- data/constructor-pages.gemspec +0 -1
- data/lib/constructor-pages.rb +1 -2
- data/spec/features/constructor_pages/fields_spec.rb +37 -26
- data/spec/features/constructor_pages/pages_spec.rb +7 -8
- data/spec/features/constructor_pages/templates_spec.rb +1 -1
- data/spec/models/constructor_pages/page_spec.rb +15 -0
- metadata +10 -25
- data/app/assets/javascripts/constructor_pages/ajax_pages.js +0 -61
- data/app/assets/javascripts/constructor_pages/jquery.history.js +0 -1
- data/app/views/constructor_pages/pages/_menu.haml +0 -8
- data/app/views/constructor_pages/pages/_submenu.haml +0 -6
- data/app/views/constructor_pages/pages/show.haml +0 -5
- data/app/views/constructor_pages/partials/_arrow_buttons.haml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a25115d3514e50b82a27b46727f053d4bbd3fe03
|
4
|
+
data.tar.gz: 32c4ed57db4bc38dfd1d32c52c8ce6d3d3a86e28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef760c7c1200443e416d15865ce4e14068e06bacda13d673b3df0845e8be194ca45bef89acce163b4ff66d3e69c92f6ca3f0fd6b1eb4930807373b161e98a38c
|
7
|
+
data.tar.gz: 27976bf54f5ee5887de59a6b557a71cac6024b78ebcc1c0360ff2ba202f4ff0f32f0764db79e3d1734c2f0acb595a7c95d370436733ca8cb1a7e0ee16baf9a7e
|
File without changes
|
@@ -0,0 +1,75 @@
|
|
1
|
+
var ru = {
|
2
|
+
'а':'a', 'б':'b', 'в':'v', 'г':'g', 'д':'d', 'е':'e', 'ё':'yo', 'ж':'zh',
|
3
|
+
'з':'z', 'и':'i', 'й':'y', 'к':'k', 'л':'l', 'м':'m', 'н':'n', 'о':'o',
|
4
|
+
'п':'p', 'р':'r', 'с':'s', 'т':'t', 'у':'u', 'ф':'f', 'х':'h', 'ц':'ts',
|
5
|
+
'ч':'ch', 'ш':'sh', 'щ':'sch', 'ъ':'', 'ы':'y', 'ь':'', 'э':'e', 'ю':'yu',
|
6
|
+
'я':'ya',
|
7
|
+
'А':'A', 'Б':'B', 'В':'V', 'Г':'G', 'Д':'D', 'Е':'E', 'Ё':'Yo', 'Ж':'Zh',
|
8
|
+
'З':'Z', 'И':'I', 'Й':'J', 'К':'K', 'Л':'L', 'М':'M', 'Н':'N', 'О':'O',
|
9
|
+
'П':'P', 'Р':'R', 'С':'S', 'Т':'T', 'У':'U', 'Ф':'F', 'Х':'H', 'Ц':'Ts',
|
10
|
+
'Ч':'Ch', 'Ш':'Sh', 'Щ':'Sch', 'Ъ':'', 'Ы':'Y', 'Ь':'', 'Э':'E', 'Ю':'Yu',
|
11
|
+
'Я':'Ya'
|
12
|
+
}
|
13
|
+
|
14
|
+
var ALL_DOWNCODE_MAPS=new Array()
|
15
|
+
|
16
|
+
ALL_DOWNCODE_MAPS[0] = ru
|
17
|
+
|
18
|
+
var Downcoder = new Object();
|
19
|
+
Downcoder.Initialize = function()
|
20
|
+
{
|
21
|
+
if (Downcoder.map) // already made
|
22
|
+
return ;
|
23
|
+
Downcoder.map ={}
|
24
|
+
Downcoder.chars = '' ;
|
25
|
+
for(var i in ALL_DOWNCODE_MAPS)
|
26
|
+
{
|
27
|
+
var lookup = ALL_DOWNCODE_MAPS[i]
|
28
|
+
for (var c in lookup)
|
29
|
+
{
|
30
|
+
Downcoder.map[c] = lookup[c] ;
|
31
|
+
Downcoder.chars += c ;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
Downcoder.regex = new RegExp('[' + Downcoder.chars + ']|[^' + Downcoder.chars + ']+','g') ;
|
35
|
+
}
|
36
|
+
|
37
|
+
downcode= function( slug )
|
38
|
+
{
|
39
|
+
Downcoder.Initialize() ;
|
40
|
+
var downcoded =""
|
41
|
+
var pieces = slug.match(Downcoder.regex);
|
42
|
+
if(pieces)
|
43
|
+
{
|
44
|
+
for (var i = 0 ; i < pieces.length ; i++)
|
45
|
+
{
|
46
|
+
if (pieces[i].length == 1)
|
47
|
+
{
|
48
|
+
var mapped = Downcoder.map[pieces[i]] ;
|
49
|
+
if (mapped != null)
|
50
|
+
{
|
51
|
+
downcoded+=mapped;
|
52
|
+
continue ;
|
53
|
+
}
|
54
|
+
}
|
55
|
+
downcoded+=pieces[i];
|
56
|
+
}
|
57
|
+
}
|
58
|
+
else
|
59
|
+
{
|
60
|
+
downcoded = slug;
|
61
|
+
}
|
62
|
+
return downcoded;
|
63
|
+
}
|
64
|
+
|
65
|
+
function URLify(s, num_chars) {
|
66
|
+
// changes, e.g., "Petty theft" to "petty_theft"
|
67
|
+
// remove all these words from the string before urlifying
|
68
|
+
s = downcode(s);
|
69
|
+
s = s.replace(/[^-\w\s]/g, '-'); // remove unneeded chars
|
70
|
+
s = s.replace(/^\s+|\s+$/g, ''); // trim leading/trailing spaces
|
71
|
+
s = s.replace(/[-\s]+/g, '-'); // convert spaces to hyphens
|
72
|
+
s = s.toLowerCase(); // convert to lowercase
|
73
|
+
return s.substring(0, num_chars);// trim to first num_chars chars
|
74
|
+
}
|
75
|
+
|
File without changes
|
@@ -3,25 +3,27 @@
|
|
3
3
|
module ConstructorPages
|
4
4
|
class FieldsController < ApplicationController
|
5
5
|
def new
|
6
|
-
@field = Field.new.tap {|f| f.template = Template.find(params[:template_id])}
|
6
|
+
@field = Field.new.tap {|f| @template = f.template = Template.find(params[:template_id])}
|
7
7
|
end
|
8
8
|
|
9
9
|
def edit
|
10
|
-
@field = Field.find(params[:id]).tap {|f| f.template = Template.find(params[:template_id])}
|
10
|
+
@field = Field.find(params[:id]).tap {|f| @template = f.template = Template.find(params[:template_id])}
|
11
11
|
end
|
12
12
|
|
13
13
|
def create
|
14
14
|
@field = Field.new field_params
|
15
|
+
@template = @field.template
|
15
16
|
|
16
17
|
if @field.save
|
17
|
-
redirect_to edit_template_path(@
|
18
|
+
redirect_to edit_template_path(@template), notice: t(:field_success_added, name: @field.name)
|
18
19
|
else
|
19
|
-
render action: :new
|
20
|
+
render action: :new
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
23
24
|
def update
|
24
25
|
@field = Field.find params[:id]
|
26
|
+
@template = @field.template
|
25
27
|
|
26
28
|
unless @field.type_value == params[:field][:type_value]
|
27
29
|
@field.type_class.where(field_id: @field.id).each do |field|
|
@@ -35,7 +37,7 @@ module ConstructorPages
|
|
35
37
|
end
|
36
38
|
|
37
39
|
if @field.update field_params
|
38
|
-
redirect_to
|
40
|
+
redirect_to edit_template_path(@template.id), notice: t(:field_success_updated, name: @field.name)
|
39
41
|
else
|
40
42
|
render action: :edit
|
41
43
|
end
|
@@ -6,32 +6,29 @@ module ConstructorPages
|
|
6
6
|
|
7
7
|
movable :page
|
8
8
|
|
9
|
-
before_filter {@roots
|
9
|
+
before_filter -> {@roots = Page.roots}, except: [:show, :create, :update, :destroy, :search]
|
10
10
|
|
11
11
|
def index
|
12
|
-
|
12
|
+
@template_exists = Template.count != 0
|
13
|
+
flash[:notice] = 'Create at least one template' unless @template_exists
|
13
14
|
end
|
14
15
|
|
15
16
|
def new
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
@page = Page.new
|
18
|
+
end
|
19
|
+
|
20
|
+
def new_child
|
21
|
+
@page, @parent_id = Page.new, params[:id]
|
22
|
+
@template_id = Page.find(@parent_id).try(:template).child.id
|
19
23
|
end
|
20
24
|
|
21
25
|
def show
|
22
26
|
@page = Page.find_by_request_or_first("/#{params[:all]}")
|
23
|
-
error_404 and return
|
27
|
+
error_404 and return unless @page.try(:published?)
|
24
28
|
redirect_to @page.link if @page.redirect?
|
25
|
-
_code_name = @page.template.code_name
|
29
|
+
_code_name = @page.template.code_name
|
26
30
|
instance_variable_set('@'+_code_name, @page)
|
27
|
-
|
28
|
-
format.html { render template: "html_templates/#{_code_name}" }
|
29
|
-
format.json {
|
30
|
-
_template = render_to_string partial: "json_templates/#{_code_name}.json.erb", layout: false, locals: {_code_name.to_sym => @page, page: @page}
|
31
|
-
_js = render_to_string partial: "js_partials/#{_code_name}.js"
|
32
|
-
render json: @page, self_and_ancestors: @page.self_and_ancestors.map(&:id), template: _template.gsub(/\n/, '\\\\n'), js: _js
|
33
|
-
}
|
34
|
-
end
|
31
|
+
render template: "templates/#{_code_name}"
|
35
32
|
end
|
36
33
|
|
37
34
|
def search
|
@@ -39,29 +36,27 @@ module ConstructorPages
|
|
39
36
|
|
40
37
|
_params = request.query_parameters
|
41
38
|
_params.each_pair {|k,v| v || (_params.delete(k); next)
|
42
|
-
_params[k] = v.numeric? ? v.to_f : (v.
|
39
|
+
_params[k] = v.numeric? ? v.to_f : (v.to_boolean if v.boolean?)}
|
43
40
|
|
44
41
|
@pages = Page.in(@page).by(_params).search(params[:what_search])
|
45
42
|
|
46
|
-
|
47
|
-
|
48
|
-
|
43
|
+
@page.template.code_name.tap {|c| [c.pluralize, c.singularize].each {|name|
|
44
|
+
instance_variable_set('@'+name, @pages)}
|
45
|
+
render template: "templates/#{c}_search"}
|
49
46
|
end
|
50
47
|
|
51
48
|
def edit
|
52
49
|
@page = Page.find(params[:id])
|
53
|
-
@page.
|
54
|
-
@template_id = @page.template.id
|
55
|
-
@multipart = @page.fields.map{|f| f.type_value == 'image'}.include?(true) ? true : false
|
50
|
+
@parent_id, @template_id = @page.parent.try(:id), @page.template.id
|
56
51
|
end
|
57
52
|
|
58
53
|
def create
|
59
54
|
@page = Page.new page_params
|
60
55
|
|
61
56
|
if @page.save
|
62
|
-
redirect_to
|
57
|
+
redirect_to pages_path, notice: t(:page_success_added, name: @page.name)
|
63
58
|
else
|
64
|
-
render
|
59
|
+
render :new
|
65
60
|
end
|
66
61
|
end
|
67
62
|
|
@@ -76,17 +71,15 @@ module ConstructorPages
|
|
76
71
|
@page.create_fields_values if _template_changed
|
77
72
|
@page.update_fields_values params[:fields]
|
78
73
|
|
79
|
-
redirect_to
|
74
|
+
redirect_to pages_path, notice: t(:page_success_updated, name: @page.name)
|
80
75
|
else
|
81
|
-
render
|
76
|
+
render :edit
|
82
77
|
end
|
83
78
|
end
|
84
79
|
|
85
80
|
def destroy
|
86
|
-
@page = Page.find(params[:id])
|
87
|
-
|
88
|
-
@page.destroy
|
89
|
-
redirect_to pages_url, notice: t(:page_success_removed, name: _name)
|
81
|
+
@page = Page.find(params[:id]).destroy
|
82
|
+
redirect_to pages_path, notice: t(:page_success_removed, name: @page.name)
|
90
83
|
end
|
91
84
|
|
92
85
|
private
|
@@ -110,7 +103,7 @@ module ConstructorPages
|
|
110
103
|
end
|
111
104
|
|
112
105
|
def error_404
|
113
|
-
render file: "#{Rails.root}/public/404", layout: false, status:
|
106
|
+
render file: "#{Rails.root}/public/404", layout: false, status: :not_found
|
114
107
|
end
|
115
108
|
end
|
116
109
|
end
|
@@ -22,7 +22,7 @@ module ConstructorPages
|
|
22
22
|
if @template.save
|
23
23
|
redirect_to templates_url, notice: t(:template_success_added, name: @template.name)
|
24
24
|
else
|
25
|
-
render
|
25
|
+
render :new
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -32,7 +32,7 @@ module ConstructorPages
|
|
32
32
|
if @template.update template_params
|
33
33
|
redirect_to templates_url, notice: t(:template_success_updated, name: @template.name)
|
34
34
|
else
|
35
|
-
render
|
35
|
+
render :edit
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -29,5 +29,19 @@ module ConstructorPages
|
|
29
29
|
|
30
30
|
output.html_safe
|
31
31
|
end
|
32
|
+
|
33
|
+
def arrow_buttons_for(item)
|
34
|
+
output = "<div class='btn-group'>"
|
35
|
+
|
36
|
+
{down: :right, up: :left}.each_pair do |a, b|
|
37
|
+
sibling = item.send(b.to_s+'_sibling')
|
38
|
+
if sibling and item.move_possible?(sibling)
|
39
|
+
output += link_to("<i class='icon-arrow-#{a}'></i>".html_safe, "/admin/#{item.class.to_s.demodulize.downcase.pluralize}/move/#{a}/#{item.id}", class: 'btn btn-mini')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
output += "</div>"
|
44
|
+
output.html_safe
|
45
|
+
end
|
32
46
|
end
|
33
47
|
end
|
@@ -3,6 +3,8 @@
|
|
3
3
|
module ConstructorPages
|
4
4
|
# Page model. Pages are core for company websites, blogs etc.
|
5
5
|
class Page < ActiveRecord::Base
|
6
|
+
include ActiveSupport::Inflector
|
7
|
+
|
6
8
|
# Adding has_many for all field types
|
7
9
|
Field::TYPES.each do |t|
|
8
10
|
class_eval %{has_many :#{t}_types, dependent: :destroy, class_name: 'Types::#{t.titleize}Type'}
|
@@ -114,9 +116,13 @@ module ConstructorPages
|
|
114
116
|
|
115
117
|
alias_method :find_pages_in_branch, :find_page_in_branch
|
116
118
|
|
117
|
-
def published?; active end
|
119
|
+
def published?; active? end
|
118
120
|
|
119
|
-
|
121
|
+
# Return true if there is a file upload field in page
|
122
|
+
def multipart?
|
123
|
+
fields.each {|f| return true if f.type_value == 'image'}
|
124
|
+
false
|
125
|
+
end
|
120
126
|
|
121
127
|
# Returns page hash attributes with fields.
|
122
128
|
#
|
@@ -147,13 +153,9 @@ module ConstructorPages
|
|
147
153
|
|
148
154
|
# if url has been changed by manually or url is empty
|
149
155
|
def friendly_url
|
150
|
-
self.url = ((auto_url || url.empty?) ?
|
156
|
+
self.url = ((auto_url || url.empty?) ? transliterate(name, '') : url).parameterize
|
151
157
|
end
|
152
158
|
|
153
|
-
# TODO: add more languages
|
154
|
-
# translit to english
|
155
|
-
def translit(str); Russian.translit(str) end
|
156
|
-
|
157
159
|
# Page is not valid if there is no template
|
158
160
|
def template_check; errors.add_on_empty(:template_id) if Template.count == 0 end
|
159
161
|
|
@@ -23,7 +23,16 @@ module ConstructorPages
|
|
23
23
|
|
24
24
|
# Return child corresponding child_id or children first
|
25
25
|
def child
|
26
|
-
|
26
|
+
if child_id
|
27
|
+
self.class.find(child_id)
|
28
|
+
else
|
29
|
+
children.first if !leaf?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Convert name to accusative
|
34
|
+
def to_accusative
|
35
|
+
self.name.mb_chars.downcase.to_s.accusative
|
27
36
|
end
|
28
37
|
|
29
38
|
private
|
@@ -0,0 +1,11 @@
|
|
1
|
+
.control-group
|
2
|
+
= label_tag '', field.name, class: 'control-label'
|
3
|
+
.controls
|
4
|
+
= link_to field_move_down_path(field), class: "btn btn-mini #{'disabled' if field.last?}" do
|
5
|
+
%i.icon-arrow-down
|
6
|
+
= link_to field_move_up_path(field), class: "btn btn-mini #{'disabled' if field.first?}" do
|
7
|
+
%i.icon-arrow-up
|
8
|
+
= link_to edit_template_field_path(field.template, field), class: 'btn btn-mini btn-primary' do
|
9
|
+
%i.icon-pencil
|
10
|
+
= link_to [field.template, field], method: :delete, data: {confirm: t(:are_you_sure?)}, class: 'btn btn-mini btn-danger' do
|
11
|
+
%i.icon-remove
|
@@ -1,4 +1,4 @@
|
|
1
|
-
= form_for @field do |f|
|
1
|
+
= form_for [@template, @field] do |f|
|
2
2
|
- if @field.errors.any?
|
3
3
|
.alert.alert-error.fade.in.span12
|
4
4
|
= link_to '×', '#', class: 'close', 'data-dismiss' => 'alert'
|
@@ -13,7 +13,7 @@
|
|
13
13
|
.control-group
|
14
14
|
= f.label :code_name, class: 'control-label'
|
15
15
|
.controls= f.text_field :code_name, class: 'span4'
|
16
|
-
= f.hidden_field :template_id, value: @
|
16
|
+
= f.hidden_field :template_id, value: @template.id, class: 'span4'
|
17
17
|
|
18
18
|
- unless @field.type_value == 'image'
|
19
19
|
.control-group
|
@@ -25,5 +25,5 @@
|
|
25
25
|
.span12
|
26
26
|
.form-actions
|
27
27
|
= f.submit class: 'btn btn-primary'
|
28
|
-
= link_to t(:cancel),
|
29
|
-
= link_to t(:delete_field), @field, method: :delete, data: {confirm: t(:are_you_sure?)}, class: 'btn btn-danger pull-right' unless @field.new_record?
|
28
|
+
= link_to t(:cancel), edit_template_path(@template), class: 'btn'
|
29
|
+
= link_to t(:delete_field), [@template, @field], method: :delete, data: {confirm: t(:are_you_sure?)}, class: 'btn btn-danger pull-right' unless @field.new_record?
|
@@ -1 +1 @@
|
|
1
|
-
=
|
1
|
+
= number_field_tag "fields[#{field.code_name}]", page.get_field_value(field.code_name), class: 'span2'
|
@@ -1 +1 @@
|
|
1
|
-
=
|
1
|
+
= number_field_tag "fields[#{field.code_name}]", page.get_field_value(field.code_name), class: 'span2'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
= form_for @page, html: {multipart: @multipart} do |f|
|
1
|
+
= form_for @page, html: {multipart: @page.multipart?} do |f|
|
2
2
|
- if @page.errors.any?
|
3
3
|
.row-fluid
|
4
4
|
.alert.alert-error.fade.in.span12
|
@@ -24,18 +24,13 @@
|
|
24
24
|
= f.label :url, class: 'control-label'
|
25
25
|
.controls
|
26
26
|
.full_url
|
27
|
-
%span.path>= @page.parent.full_url
|
27
|
+
%span.path>= @page.parent.full_url if @page.parent
|
28
28
|
\/
|
29
29
|
%span.address>= @page.url
|
30
30
|
= f.text_field :url, class: 'span3'
|
31
31
|
%i.address_icon.icon-pencil
|
32
32
|
|
33
|
-
|
34
|
-
- @page.template.fields.each do |field|
|
35
|
-
.control-group
|
36
|
-
= label_tag "fields[#{field.code_name}]", field.name, class: 'control-label'
|
37
|
-
.controls
|
38
|
-
= render :partial => "constructor_pages/fields/types/#{field.type_value}", locals: {field: field, page: @page}
|
33
|
+
= render partial: 'field', collection: @page.fields
|
39
34
|
|
40
35
|
.accordion
|
41
36
|
.accordion-group
|
@@ -46,7 +41,7 @@
|
|
46
41
|
.control-group
|
47
42
|
= f.label :parent_id, class: 'control-label'
|
48
43
|
.controls
|
49
|
-
= f.select :parent_id, options_for_select(for_select(@roots), selected: @
|
44
|
+
= f.select :parent_id, options_for_select(for_select(@roots), selected: @parent_id), disabled: @page.self_and_descendants.map(&:id), include_blank: t(:no)
|
50
45
|
|
51
46
|
.control-group
|
52
47
|
= f.label :template_id, :class => 'control-label'
|
@@ -17,26 +17,19 @@
|
|
17
17
|
%button.btn.disabled= page.name
|
18
18
|
|
19
19
|
.b-tree__buttons
|
20
|
-
=
|
20
|
+
= arrow_buttons_for(page)
|
21
21
|
|
22
22
|
= link_to edit_page_path(page), class: 'btn btn-primary btn-mini' do
|
23
23
|
%i.icon-pencil
|
24
24
|
=t :edit
|
25
|
-
= page.template.
|
25
|
+
= page.template.to_accusative
|
26
26
|
|
27
|
-
-
|
28
|
-
-
|
29
|
-
-
|
30
|
-
|
31
|
-
|
32
|
-
=t :add
|
33
|
-
= page.template.descendants.first.name.downcase
|
34
|
-
- else
|
35
|
-
= link_to new_child_page_path(page), class: 'btn btn-success btn-mini' do
|
36
|
-
%i.icon-chevron-down
|
37
|
-
=t :add
|
38
|
-
= ConstructorPages::Template.find(page.template.child_id).name.downcase
|
27
|
+
- if page.template.child
|
28
|
+
= link_to new_child_page_path(page), class: 'btn btn-success btn-mini' do
|
29
|
+
%i.icon-chevron-down
|
30
|
+
=t :add
|
31
|
+
= page.template.child.to_accusative
|
39
32
|
|
40
|
-
= link_to
|
33
|
+
= link_to page, method: :delete, class: 'btn btn-danger btn-mini pull-right', data: {confirm: t(:are_you_sure?)} do
|
41
34
|
%i.icon-remove
|
42
35
|
=t :delete
|
@@ -28,22 +28,11 @@
|
|
28
28
|
- unless @template.new_record?
|
29
29
|
.control-group
|
30
30
|
.controls
|
31
|
-
= link_to
|
31
|
+
= link_to new_template_field_path(@template), class: 'btn btn-mini btn-link' do
|
32
32
|
%i.icon-plus
|
33
33
|
=t :new_field
|
34
34
|
|
35
|
-
|
36
|
-
.control-group
|
37
|
-
= label_tag '', field.name, class: 'control-label'
|
38
|
-
.controls
|
39
|
-
= link_to field_move_down_path(field), class: "btn btn-mini #{'disabled' if field.last?}" do
|
40
|
-
%i.icon-arrow-down
|
41
|
-
= link_to field_move_up_path(field), class: "btn btn-mini #{'disabled' if field.first?}" do
|
42
|
-
%i.icon-arrow-up
|
43
|
-
= link_to edit_field_path(field, field.template), class: 'btn btn-mini btn-primary' do
|
44
|
-
%i.icon-pencil
|
45
|
-
= link_to field_path(field), method: :delete, data: {confirm: t(:are_you_sure?)}, class: 'btn btn-mini btn-danger' do
|
46
|
-
%i.icon-remove
|
35
|
+
= render @template.fields
|
47
36
|
|
48
37
|
.row-fluid
|
49
38
|
.span12
|
@@ -12,13 +12,13 @@
|
|
12
12
|
%button.btn.btn-link.disabled= template.name
|
13
13
|
|
14
14
|
.b-tree__buttons
|
15
|
-
=
|
15
|
+
= arrow_buttons_for(template)
|
16
16
|
|
17
17
|
= link_to edit_template_path(template), class: 'btn btn-primary btn-mini' do
|
18
18
|
%i.icon-pencil
|
19
19
|
=t :edit
|
20
|
-
= t(:template).downcase
|
20
|
+
= t(:template).mb_chars.downcase
|
21
21
|
|
22
|
-
= link_to
|
22
|
+
= link_to template, method: :delete, class: 'btn btn-danger btn-mini pull-right', data: {confirm: t(:are_you_sure?)} do
|
23
23
|
%i.icon-remove
|
24
24
|
=t :delete
|
data/config/locales/ru.yml
CHANGED
@@ -34,6 +34,7 @@ ru:
|
|
34
34
|
image: Изображение
|
35
35
|
help: Помощь
|
36
36
|
edit: Редактировать
|
37
|
+
add: Добавить
|
37
38
|
|
38
39
|
page_not_found: Страница не найдена
|
39
40
|
|
@@ -92,9 +93,78 @@ ru:
|
|
92
93
|
blank: "не может быть пустой"
|
93
94
|
constructor_pages/template:
|
94
95
|
attributes:
|
96
|
+
code_name:
|
97
|
+
taken: уже используется
|
95
98
|
base:
|
96
99
|
code_name_already_in_use: Такое кодовое имя уже используется
|
97
100
|
constructor_pages/field:
|
98
101
|
attributes:
|
102
|
+
code_name:
|
103
|
+
taken: уже используется
|
99
104
|
base:
|
100
|
-
code_name_already_in_use: Такое кодовое имя уже используется
|
105
|
+
code_name_already_in_use: Такое кодовое имя уже используется
|
106
|
+
i18n:
|
107
|
+
transliterate:
|
108
|
+
rule:
|
109
|
+
а: 'a'
|
110
|
+
б: 'b'
|
111
|
+
в: 'v'
|
112
|
+
г: 'g'
|
113
|
+
д: 'd'
|
114
|
+
е: 'e'
|
115
|
+
ё: 'yo'
|
116
|
+
ж: 'zh'
|
117
|
+
з: 'z'
|
118
|
+
и: 'i'
|
119
|
+
й: 'y'
|
120
|
+
к: 'k'
|
121
|
+
л: 'l'
|
122
|
+
м: 'm'
|
123
|
+
н: 'n'
|
124
|
+
о: 'o'
|
125
|
+
п: 'p'
|
126
|
+
р: 'r'
|
127
|
+
с: 's'
|
128
|
+
т: 't'
|
129
|
+
у: 'u'
|
130
|
+
ф: 'f'
|
131
|
+
х: 'h'
|
132
|
+
ц: 'ts'
|
133
|
+
ч: 'ch'
|
134
|
+
ш: 'sh'
|
135
|
+
щ: 'sch'
|
136
|
+
ы: 'y'
|
137
|
+
э: 'e'
|
138
|
+
ю: 'yu'
|
139
|
+
я: 'ya'
|
140
|
+
А: 'A'
|
141
|
+
Б: 'B'
|
142
|
+
В: 'V'
|
143
|
+
Г: 'G'
|
144
|
+
Д: 'D'
|
145
|
+
Е: 'E'
|
146
|
+
Ё: 'Yo'
|
147
|
+
Ж: 'Zh'
|
148
|
+
З: 'Z'
|
149
|
+
И: 'I'
|
150
|
+
Й: 'J'
|
151
|
+
К: 'K'
|
152
|
+
Л: 'L'
|
153
|
+
М: 'M'
|
154
|
+
Н: 'N'
|
155
|
+
О: 'O'
|
156
|
+
П: 'P'
|
157
|
+
Р: 'R'
|
158
|
+
С: 'S'
|
159
|
+
Т: 'T'
|
160
|
+
У: 'U'
|
161
|
+
Ф: 'F'
|
162
|
+
Х: 'H'
|
163
|
+
Ц: 'Ts'
|
164
|
+
Ч: 'Ch'
|
165
|
+
Ш: 'Sh'
|
166
|
+
Щ: 'Sch'
|
167
|
+
Ы: 'Y'
|
168
|
+
Э: 'E'
|
169
|
+
Ю: 'Yu'
|
170
|
+
Я: 'Ya'
|
data/config/routes.rb
CHANGED
@@ -1,21 +1,18 @@
|
|
1
1
|
ConstructorPages::Engine.routes.draw do
|
2
2
|
scope '/admin' do
|
3
|
-
resources :pages, except: [:show]
|
4
|
-
|
5
|
-
|
3
|
+
resources :pages, except: [:show] do
|
4
|
+
get :new_child, on: :member
|
5
|
+
end
|
6
|
+
|
7
|
+
resources :templates, except: [:show] do
|
8
|
+
resources :fields, except: [:show, :index]
|
9
|
+
end
|
6
10
|
|
7
11
|
%w{page template field}.each do |c|
|
8
12
|
%w{up down}.each do |d|
|
9
13
|
get "#{c.pluralize}/move/#{d}/:id" => "#{c.pluralize}#move_#{d}", as: "#{c}_move_#{d}"
|
10
14
|
end
|
11
15
|
end
|
12
|
-
|
13
|
-
scope '/fields' do
|
14
|
-
get ':template_id/new/' => 'fields#new', as: :new_field
|
15
|
-
get ':id/:template_id/edit/' => 'fields#edit', as: :edit_field
|
16
|
-
end
|
17
|
-
|
18
|
-
get '/pages/:page/new' => 'pages#new', as: :new_child_page
|
19
16
|
end
|
20
17
|
|
21
18
|
root :to => 'pages#show'
|
data/constructor-pages.gemspec
CHANGED
data/lib/constructor-pages.rb
CHANGED
@@ -38,14 +38,14 @@ module ConstructorPages
|
|
38
38
|
|
39
39
|
it 'should has edit field link' do
|
40
40
|
visit pages.edit_template_path(@template)
|
41
|
-
find("a[href='#{pages.
|
42
|
-
find("a[href='#{pages.
|
41
|
+
find("a[href='#{pages.edit_template_field_path(@template, @content_field)}']").should be_true
|
42
|
+
find("a[href='#{pages.edit_template_field_path(@template, @price_field)}']").should be_true
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'should has delete field link' do
|
46
46
|
visit pages.edit_template_path(@template)
|
47
|
-
find("a[href='#{pages.
|
48
|
-
find("a[href='#{pages.
|
47
|
+
find("a[href='#{pages.template_field_path(@template, @content_field)}']").should be_true
|
48
|
+
find("a[href='#{pages.template_field_path(@template, @price_field)}']").should be_true
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'should has move field link' do
|
@@ -62,14 +62,14 @@ module ConstructorPages
|
|
62
62
|
|
63
63
|
context 'Access' do
|
64
64
|
it 'should be accessed by new_field_path if loggen in' do
|
65
|
-
visit pages.
|
66
|
-
current_path.should == pages.
|
65
|
+
visit pages.new_template_field_path(@template)
|
66
|
+
current_path.should == pages.new_template_field_path(@template)
|
67
67
|
status_code.should == 200
|
68
68
|
end
|
69
69
|
|
70
70
|
it 'should not be accessed by new_field_path if not loggen in' do
|
71
71
|
logout
|
72
|
-
visit pages.
|
72
|
+
visit pages.new_template_field_path(@template)
|
73
73
|
current_path.should == '/'
|
74
74
|
end
|
75
75
|
end
|
@@ -81,33 +81,33 @@ module ConstructorPages
|
|
81
81
|
end
|
82
82
|
|
83
83
|
it 'should has name field' do
|
84
|
-
visit pages.
|
84
|
+
visit pages.new_template_field_path(@template)
|
85
85
|
page.should have_field 'Name'
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'should has code name field' do
|
89
|
-
visit pages.
|
89
|
+
visit pages.new_template_field_path(@template)
|
90
90
|
page.should have_field 'Code name'
|
91
91
|
end
|
92
92
|
|
93
93
|
it 'should has select type' do
|
94
|
-
visit pages.
|
94
|
+
visit pages.new_template_field_path(@template)
|
95
95
|
page.should have_select 'Type value'
|
96
96
|
end
|
97
97
|
|
98
98
|
it 'should has no delete link' do
|
99
|
-
visit pages.
|
99
|
+
visit pages.new_template_field_path(@template)
|
100
100
|
page.should_not have_link 'Delete'
|
101
101
|
end
|
102
102
|
|
103
103
|
it 'should has Create Field button' do
|
104
|
-
visit pages.
|
104
|
+
visit pages.new_template_field_path(@template)
|
105
105
|
page.should have_button 'Create Field'
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
109
|
it 'should create new field' do
|
110
|
-
visit pages.
|
110
|
+
visit pages.new_template_field_path(@template)
|
111
111
|
fill_in 'Name', with: 'Amount'
|
112
112
|
fill_in 'Code name', with: 'amount'
|
113
113
|
select 'Integer', from: 'Type value'
|
@@ -124,22 +124,33 @@ module ConstructorPages
|
|
124
124
|
end
|
125
125
|
|
126
126
|
it 'should validate uniqueness of code_name' do
|
127
|
-
visit pages.
|
127
|
+
visit pages.new_template_field_path(@template)
|
128
128
|
fill_in 'Name', with: 'Hello'
|
129
129
|
fill_in 'Code name', with: 'get_field_value'
|
130
130
|
Field.count.should == 0
|
131
131
|
click_button 'Create Field'
|
132
132
|
Field.count.should == 0
|
133
|
-
current_path.should == pages.
|
133
|
+
current_path.should == pages.template_fields_path(@template)
|
134
134
|
page.should have_text 'Code name has already been taken'
|
135
135
|
|
136
|
-
visit pages.
|
136
|
+
visit pages.new_template_field_path(@template)
|
137
137
|
fill_in 'Name', with: 'Hello'
|
138
138
|
fill_in 'Code name', with: 'brand'
|
139
139
|
Field.count.should == 0
|
140
140
|
click_button 'Create Field'
|
141
141
|
Field.count.should == 0
|
142
|
-
current_path.should == pages.
|
142
|
+
current_path.should == pages.template_fields_path(@template)
|
143
|
+
page.should have_text 'Code name has already been taken'
|
144
|
+
|
145
|
+
_field = Field.create name: 'Content', code_name: 'content', template: @template, type_value: 'text'
|
146
|
+
|
147
|
+
visit pages.edit_template_field_path(@template, _field)
|
148
|
+
fill_in 'Name', with: 'Hello'
|
149
|
+
fill_in 'Code name', with: 'brand'
|
150
|
+
Field.count.should == 1
|
151
|
+
click_button 'Update Field'
|
152
|
+
Field.count.should == 1
|
153
|
+
current_path.should == pages.template_field_path(@template, _field)
|
143
154
|
page.should have_text 'Code name has already been taken'
|
144
155
|
end
|
145
156
|
end
|
@@ -152,30 +163,30 @@ module ConstructorPages
|
|
152
163
|
|
153
164
|
context 'Access' do
|
154
165
|
it 'should be accessed by edit_field_path if loggen in' do
|
155
|
-
visit pages.
|
156
|
-
current_path.should == pages.
|
166
|
+
visit pages.edit_template_field_path(@template, @field_content)
|
167
|
+
current_path.should == pages.edit_template_field_path(@template, @field_content)
|
157
168
|
status_code.should == 200
|
158
169
|
end
|
159
170
|
|
160
171
|
it 'should not be accessed by new_field_path if not loggen in' do
|
161
172
|
logout
|
162
|
-
visit pages.
|
173
|
+
visit pages.edit_template_field_path(@template, @field_content)
|
163
174
|
current_path.should == '/'
|
164
175
|
end
|
165
176
|
end
|
166
177
|
|
167
178
|
it 'should has delete link' do
|
168
|
-
visit pages.
|
169
|
-
page.should have_link 'Delete', pages.
|
179
|
+
visit pages.edit_template_field_path(@template, @field_content)
|
180
|
+
page.should have_link 'Delete', pages.template_field_path(@template, @field_content)
|
170
181
|
end
|
171
182
|
|
172
183
|
it 'should has Update Field button' do
|
173
|
-
visit pages.
|
184
|
+
visit pages.edit_template_field_path(@template, @field_content)
|
174
185
|
page.should have_button 'Update Field'
|
175
186
|
end
|
176
187
|
|
177
188
|
it 'should edit field' do
|
178
|
-
visit pages.
|
189
|
+
visit pages.edit_template_field_path(@template, @field_content)
|
179
190
|
fill_in 'Name', with: 'Long content'
|
180
191
|
fill_in 'Code name', with: 'long_content'
|
181
192
|
select 'HTML', from: 'Type value'
|
@@ -198,14 +209,14 @@ module ConstructorPages
|
|
198
209
|
it 'should delete field from template edit' do
|
199
210
|
visit pages.edit_template_path(@template)
|
200
211
|
Field.count.should == 1
|
201
|
-
find("a[href='#{pages.
|
212
|
+
find("a[href='#{pages.template_field_path(@template, @field_content)}']").click
|
202
213
|
Field.count.should == 0
|
203
214
|
current_path.should == pages.edit_template_path(@template)
|
204
215
|
page.should have_text 'removed successfully'
|
205
216
|
end
|
206
217
|
|
207
218
|
it 'should delete from field edit' do
|
208
|
-
visit pages.
|
219
|
+
visit pages.edit_template_field_path(@template, @field_content)
|
209
220
|
Field.count.should == 1
|
210
221
|
click_link 'Delete'
|
211
222
|
Field.count.should == 0
|
@@ -79,7 +79,13 @@ module ConstructorPages
|
|
79
79
|
_template = Template.create name: 'Child', code_name: 'child_page', parent: @template
|
80
80
|
_page = Page.create name: 'Zanussi', template: @template
|
81
81
|
visit pages.pages_path
|
82
|
-
page.should have_link 'Add child', pages.
|
82
|
+
page.should have_link 'Add child', pages.new_page_path(_page)
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should not has if child not exists' do
|
86
|
+
_page = Page.create name: 'Zanussi', template: @template
|
87
|
+
visit pages.pages_path
|
88
|
+
page.should have_no_link 'Add'
|
83
89
|
end
|
84
90
|
end
|
85
91
|
|
@@ -185,13 +191,6 @@ module ConstructorPages
|
|
185
191
|
current_path.should == pages.pages_path
|
186
192
|
page.should have_text 'added successfully'
|
187
193
|
end
|
188
|
-
|
189
|
-
it 'should redirect to back if no template exists' do
|
190
|
-
Template.delete_all
|
191
|
-
visit pages.new_page_path
|
192
|
-
current_path.should == pages.pages_path
|
193
|
-
page.should have_text 'Create at least one template'
|
194
|
-
end
|
195
194
|
end
|
196
195
|
|
197
196
|
describe 'Edit page' do
|
@@ -214,7 +214,7 @@ module ConstructorPages
|
|
214
214
|
|
215
215
|
it 'should has new field link' do
|
216
216
|
visit pages.edit_template_path(@template)
|
217
|
-
page.should have_link 'New field', pages.
|
217
|
+
page.should have_link 'New field', pages.new_template_field_path(@template)
|
218
218
|
end
|
219
219
|
|
220
220
|
it 'should has update template button' do
|
@@ -239,6 +239,19 @@ module ConstructorPages
|
|
239
239
|
end
|
240
240
|
end
|
241
241
|
|
242
|
+
describe '#multipart?' do
|
243
|
+
it 'should return true if there is file upload in page fields' do
|
244
|
+
Field.create name: 'Photo', code_name: 'photo', template: @template, type_value: 'image'
|
245
|
+
_page = Page.create name: 'Product', template: @template
|
246
|
+
_page.multipart?.should be_true
|
247
|
+
end
|
248
|
+
|
249
|
+
it 'should return false if there is no file upload in page fields' do
|
250
|
+
_page = Page.create name: 'Product', template: @template
|
251
|
+
_page.multipart?.should be_false
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
242
255
|
describe '#as_json' do
|
243
256
|
context 'should return page hash attributes with fields' do
|
244
257
|
before :each do
|
@@ -312,11 +325,13 @@ module ConstructorPages
|
|
312
325
|
end
|
313
326
|
|
314
327
|
it 'should translit utf-8' do
|
328
|
+
I18n.locale = :ru
|
315
329
|
page = Page.create name: 'Проверка'
|
316
330
|
page.full_url.should == '/proverka'
|
317
331
|
|
318
332
|
page_two = Page.create name: 'Тест', parent: page
|
319
333
|
page_two.full_url.should == '/proverka/test'
|
334
|
+
I18n.locale = :en
|
320
335
|
end
|
321
336
|
end
|
322
337
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: constructor-pages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Zotov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: constructor-core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.7.
|
19
|
+
version: 0.7.8
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.7.
|
26
|
+
version: 0.7.8
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: dragonfly
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,20 +94,6 @@ dependencies:
|
|
94
94
|
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: russian
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - '>='
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :runtime
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - '>='
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
98
|
name: rspec-rails
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -147,8 +133,9 @@ files:
|
|
147
133
|
- app/assets/images/constructor_pages/information.png
|
148
134
|
- app/assets/images/constructor_pages/page_white_edit.png
|
149
135
|
- app/assets/images/constructor_pages/photos.png
|
150
|
-
- app/assets/javascripts/constructor_pages
|
151
|
-
- app/assets/javascripts/constructor_pages/
|
136
|
+
- app/assets/javascripts/constructor_pages/.keep
|
137
|
+
- app/assets/javascripts/constructor_pages/urlify.js
|
138
|
+
- app/assets/stylesheets/constructor_pages/.keep
|
152
139
|
- app/controllers/constructor_pages/application_controller.rb
|
153
140
|
- app/controllers/constructor_pages/fields_controller.rb
|
154
141
|
- app/controllers/constructor_pages/pages_controller.rb
|
@@ -169,6 +156,7 @@ files:
|
|
169
156
|
- app/models/constructor_pages/types/integer_type.rb
|
170
157
|
- app/models/constructor_pages/types/string_type.rb
|
171
158
|
- app/models/constructor_pages/types/text_type.rb
|
159
|
+
- app/views/constructor_pages/fields/_field.haml
|
172
160
|
- app/views/constructor_pages/fields/_form.haml
|
173
161
|
- app/views/constructor_pages/fields/edit.haml
|
174
162
|
- app/views/constructor_pages/fields/new.haml
|
@@ -181,14 +169,12 @@ files:
|
|
181
169
|
- app/views/constructor_pages/fields/types/_string.haml
|
182
170
|
- app/views/constructor_pages/fields/types/_text.haml
|
183
171
|
- app/views/constructor_pages/pages/_breadcrumbs.haml
|
172
|
+
- app/views/constructor_pages/pages/_field.haml
|
184
173
|
- app/views/constructor_pages/pages/_form.haml
|
185
|
-
- app/views/constructor_pages/pages/_menu.haml
|
186
|
-
- app/views/constructor_pages/pages/_submenu.haml
|
187
174
|
- app/views/constructor_pages/pages/edit.haml
|
188
175
|
- app/views/constructor_pages/pages/index.haml
|
189
176
|
- app/views/constructor_pages/pages/new.haml
|
190
|
-
- app/views/constructor_pages/pages/
|
191
|
-
- app/views/constructor_pages/partials/_arrow_buttons.haml
|
177
|
+
- app/views/constructor_pages/pages/new_child.haml
|
192
178
|
- app/views/constructor_pages/templates/_form.haml
|
193
179
|
- app/views/constructor_pages/templates/edit.haml
|
194
180
|
- app/views/constructor_pages/templates/index.haml
|
@@ -267,4 +253,3 @@ test_files:
|
|
267
253
|
- spec/models/constructor_pages/types/string_type_spec.rb
|
268
254
|
- spec/models/constructor_pages/types/text_type_spec.rb
|
269
255
|
- spec/routing/constructor_pages/.keep
|
270
|
-
has_rdoc:
|
@@ -1,61 +0,0 @@
|
|
1
|
-
//= require constructor_pages/jquery.history.js
|
2
|
-
|
3
|
-
$(document).ready(function() {
|
4
|
-
$page = {};
|
5
|
-
|
6
|
-
var History = window.History;
|
7
|
-
|
8
|
-
if ( !History.enabled ) { return false }
|
9
|
-
|
10
|
-
History.Adapter.bind(window,'statechange',function(){
|
11
|
-
update_page(History.getState().url);
|
12
|
-
});
|
13
|
-
|
14
|
-
|
15
|
-
update_pages();
|
16
|
-
});
|
17
|
-
|
18
|
-
function update_pages(){
|
19
|
-
$('.b-page-json').each(function(index, el){
|
20
|
-
var _href = $(el).attr('href');
|
21
|
-
|
22
|
-
$(el).unbind('click');
|
23
|
-
|
24
|
-
$(el).click(function(event){
|
25
|
-
event.preventDefault();
|
26
|
-
History.pushState(null, null, _href);
|
27
|
-
});
|
28
|
-
});
|
29
|
-
}
|
30
|
-
|
31
|
-
function update_page(href) {
|
32
|
-
|
33
|
-
$.get(href+'.json', function(page){
|
34
|
-
$page = page;
|
35
|
-
|
36
|
-
$('title').html(page.title || page.name);
|
37
|
-
|
38
|
-
var partials = JSON.parse(page.template);
|
39
|
-
var names = Object.keys(partials);
|
40
|
-
|
41
|
-
for (i in names) {
|
42
|
-
var name = names[i];
|
43
|
-
|
44
|
-
$('.b-page-part__'+name).html(partials[name]);
|
45
|
-
}
|
46
|
-
|
47
|
-
$("[class*='b-page-json__id-']").removeClass('active');
|
48
|
-
|
49
|
-
for (var i in $page.self_and_ancestors) {
|
50
|
-
$('.b-page-json__id-'+$page.self_and_ancestors[i]).addClass('active');
|
51
|
-
}
|
52
|
-
|
53
|
-
update_pages();
|
54
|
-
|
55
|
-
if (typeof Retina != 'undefined') {
|
56
|
-
Retina.update();
|
57
|
-
}
|
58
|
-
|
59
|
-
eval(page.js);
|
60
|
-
});
|
61
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
window.JSON||(window.JSON={}),function(){function f(a){return a<10?"0"+a:a}function quote(a){return escapable.lastIndex=0,escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return typeof b=="string"?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function str(a,b){var c,d,e,f,g=gap,h,i=b[a];i&&typeof i=="object"&&typeof i.toJSON=="function"&&(i=i.toJSON(a)),typeof rep=="function"&&(i=rep.call(b,a,i));switch(typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";gap+=indent,h=[];if(Object.prototype.toString.apply(i)==="[object Array]"){f=i.length;for(c=0;c<f;c+=1)h[c]=str(c,i)||"null";return e=h.length===0?"[]":gap?"[\n"+gap+h.join(",\n"+gap)+"\n"+g+"]":"["+h.join(",")+"]",gap=g,e}if(rep&&typeof rep=="object"){f=rep.length;for(c=0;c<f;c+=1)d=rep[c],typeof d=="string"&&(e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e))}else for(d in i)Object.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e));return e=h.length===0?"{}":gap?"{\n"+gap+h.join(",\n"+gap)+"\n"+g+"}":"{"+h.join(",")+"}",gap=g,e}}"use strict",typeof Date.prototype.toJSON!="function"&&(Date.prototype.toJSON=function(a){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(a){return this.valueOf()});var JSON=window.JSON,cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;typeof JSON.stringify!="function"&&(JSON.stringify=function(a,b,c){var d;gap="",indent="";if(typeof c=="number")for(d=0;d<c;d+=1)indent+=" ";else typeof c=="string"&&(indent=c);rep=b;if(!b||typeof b=="function"||typeof b=="object"&&typeof b.length=="number")return str("",{"":a});throw new Error("JSON.stringify")}),typeof JSON.parse!="function"&&(JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&typeof e=="object")for(c in e)Object.hasOwnProperty.call(e,c)&&(d=walk(e,c),d!==undefined?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),typeof reviver=="function"?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}(),function(a,b){"use strict";var c=a.History=a.History||{},d=a.jQuery;if(typeof c.Adapter!="undefined")throw new Error("History.js Adapter has already been loaded...");c.Adapter={bind:function(a,b,c){d(a).bind(b,c)},trigger:function(a,b,c){d(a).trigger(b,c)},extractEventData:function(a,c,d){var e=c&&c.originalEvent&&c.originalEvent[a]||d&&d[a]||b;return e},onDomLoad:function(a){d(a)}},typeof c.init!="undefined"&&c.init()}(window),function(a,b){"use strict";var c=a.document,d=a.setTimeout||d,e=a.clearTimeout||e,f=a.setInterval||f,g=a.History=a.History||{};if(typeof g.initHtml4!="undefined")throw new Error("History.js HTML4 Support has already been loaded...");g.initHtml4=function(){if(typeof g.initHtml4.initialized!="undefined")return!1;g.initHtml4.initialized=!0,g.enabled=!0,g.savedHashes=[],g.isLastHash=function(a){var b=g.getHashByIndex(),c;return c=a===b,c},g.saveHash=function(a){return g.isLastHash(a)?!1:(g.savedHashes.push(a),!0)},g.getHashByIndex=function(a){var b=null;return typeof a=="undefined"?b=g.savedHashes[g.savedHashes.length-1]:a<0?b=g.savedHashes[g.savedHashes.length+a]:b=g.savedHashes[a],b},g.discardedHashes={},g.discardedStates={},g.discardState=function(a,b,c){var d=g.getHashByState(a),e;return e={discardedState:a,backState:c,forwardState:b},g.discardedStates[d]=e,!0},g.discardHash=function(a,b,c){var d={discardedHash:a,backState:c,forwardState:b};return g.discardedHashes[a]=d,!0},g.discardedState=function(a){var b=g.getHashByState(a),c;return c=g.discardedStates[b]||!1,c},g.discardedHash=function(a){var b=g.discardedHashes[a]||!1;return b},g.recycleState=function(a){var b=g.getHashByState(a);return g.discardedState(a)&&delete g.discardedStates[b],!0},g.emulated.hashChange&&(g.hashChangeInit=function(){g.checkerFunction=null;var b="",d,e,h,i;return g.isInternetExplorer()?(d="historyjs-iframe",e=c.createElement("iframe"),e.setAttribute("id",d),e.style.display="none",c.body.appendChild(e),e.contentWindow.document.open(),e.contentWindow.document.close(),h="",i=!1,g.checkerFunction=function(){if(i)return!1;i=!0;var c=g.getHash()||"",d=g.unescapeHash(e.contentWindow.document.location.hash)||"";return c!==b?(b=c,d!==c&&(h=d=c,e.contentWindow.document.open(),e.contentWindow.document.close(),e.contentWindow.document.location.hash=g.escapeHash(c)),g.Adapter.trigger(a,"hashchange")):d!==h&&(h=d,g.setHash(d,!1)),i=!1,!0}):g.checkerFunction=function(){var c=g.getHash();return c!==b&&(b=c,g.Adapter.trigger(a,"hashchange")),!0},g.intervalList.push(f(g.checkerFunction,g.options.hashChangeInterval)),!0},g.Adapter.onDomLoad(g.hashChangeInit)),g.emulated.pushState&&(g.onHashChange=function(b){var d=b&&b.newURL||c.location.href,e=g.getHashByUrl(d),f=null,h=null,i=null,j;return g.isLastHash(e)?(g.busy(!1),!1):(g.doubleCheckComplete(),g.saveHash(e),e&&g.isTraditionalAnchor(e)?(g.Adapter.trigger(a,"anchorchange"),g.busy(!1),!1):(f=g.extractState(g.getFullUrl(e||c.location.href,!1),!0),g.isLastSavedState(f)?(g.busy(!1),!1):(h=g.getHashByState(f),j=g.discardedState(f),j?(g.getHashByIndex(-2)===g.getHashByState(j.forwardState)?g.back(!1):g.forward(!1),!1):(g.pushState(f.data,f.title,f.url,!1),!0))))},g.Adapter.bind(a,"hashchange",g.onHashChange),g.pushState=function(b,d,e,f){if(g.getHashByUrl(e))throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(f!==!1&&g.busy())return g.pushQueue({scope:g,callback:g.pushState,args:arguments,queue:f}),!1;g.busy(!0);var h=g.createStateObject(b,d,e),i=g.getHashByState(h),j=g.getState(!1),k=g.getHashByState(j),l=g.getHash();return g.storeState(h),g.expectedStateId=h.id,g.recycleState(h),g.setTitle(h),i===k?(g.busy(!1),!1):i!==l&&i!==g.getShortUrl(c.location.href)?(g.setHash(i,!1),!1):(g.saveState(h),g.Adapter.trigger(a,"statechange"),g.busy(!1),!0)},g.replaceState=function(a,b,c,d){if(g.getHashByUrl(c))throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(d!==!1&&g.busy())return g.pushQueue({scope:g,callback:g.replaceState,args:arguments,queue:d}),!1;g.busy(!0);var e=g.createStateObject(a,b,c),f=g.getState(!1),h=g.getStateByIndex(-2);return g.discardState(f,e,h),g.pushState(e.data,e.title,e.url,!1),!0}),g.emulated.pushState&&g.getHash()&&!g.emulated.hashChange&&g.Adapter.onDomLoad(function(){g.Adapter.trigger(a,"hashchange")})},typeof g.init!="undefined"&&g.init()}(window),function(a,b){"use strict";var c=a.console||b,d=a.document,e=a.navigator,f=a.sessionStorage||!1,g=a.setTimeout,h=a.clearTimeout,i=a.setInterval,j=a.clearInterval,k=a.JSON,l=a.alert,m=a.History=a.History||{},n=a.history;k.stringify=k.stringify||k.encode,k.parse=k.parse||k.decode;if(typeof m.init!="undefined")throw new Error("History.js Core has already been loaded...");m.init=function(){return typeof m.Adapter=="undefined"?!1:(typeof m.initCore!="undefined"&&m.initCore(),typeof m.initHtml4!="undefined"&&m.initHtml4(),!0)},m.initCore=function(){if(typeof m.initCore.initialized!="undefined")return!1;m.initCore.initialized=!0,m.options=m.options||{},m.options.hashChangeInterval=m.options.hashChangeInterval||100,m.options.safariPollInterval=m.options.safariPollInterval||500,m.options.doubleCheckInterval=m.options.doubleCheckInterval||500,m.options.storeInterval=m.options.storeInterval||1e3,m.options.busyDelay=m.options.busyDelay||250,m.options.debug=m.options.debug||!1,m.options.initialTitle=m.options.initialTitle||d.title,m.intervalList=[],m.clearAllIntervals=function(){var a,b=m.intervalList;if(typeof b!="undefined"&&b!==null){for(a=0;a<b.length;a++)j(b[a]);m.intervalList=null}},m.debug=function(){(m.options.debug||!1)&&m.log.apply(m,arguments)},m.log=function(){var a=typeof c!="undefined"&&typeof c.log!="undefined"&&typeof c.log.apply!="undefined",b=d.getElementById("log"),e,f,g,h,i;a?(h=Array.prototype.slice.call(arguments),e=h.shift(),typeof c.debug!="undefined"?c.debug.apply(c,[e,h]):c.log.apply(c,[e,h])):e="\n"+arguments[0]+"\n";for(f=1,g=arguments.length;f<g;++f){i=arguments[f];if(typeof i=="object"&&typeof k!="undefined")try{i=k.stringify(i)}catch(j){}e+="\n"+i+"\n"}return b?(b.value+=e+"\n-----\n",b.scrollTop=b.scrollHeight-b.clientHeight):a||l(e),!0},m.getInternetExplorerMajorVersion=function(){var a=m.getInternetExplorerMajorVersion.cached=typeof m.getInternetExplorerMajorVersion.cached!="undefined"?m.getInternetExplorerMajorVersion.cached:function(){var a=3,b=d.createElement("div"),c=b.getElementsByTagName("i");while((b.innerHTML="<!--[if gt IE "+ ++a+"]><i></i><![endif]-->")&&c[0]);return a>4?a:!1}();return a},m.isInternetExplorer=function(){var a=m.isInternetExplorer.cached=typeof m.isInternetExplorer.cached!="undefined"?m.isInternetExplorer.cached:Boolean(m.getInternetExplorerMajorVersion());return a},m.emulated={pushState:!Boolean(a.history&&a.history.pushState&&a.history.replaceState&&!/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(e.userAgent)&&!/AppleWebKit\/5([0-2]|3[0-2])/i.test(e.userAgent)),hashChange:Boolean(!("onhashchange"in a||"onhashchange"in d)||m.isInternetExplorer()&&m.getInternetExplorerMajorVersion()<8)},m.enabled=!m.emulated.pushState,m.bugs={setHash:Boolean(!m.emulated.pushState&&e.vendor==="Apple Computer, Inc."&&/AppleWebKit\/5([0-2]|3[0-3])/.test(e.userAgent)),safariPoll:Boolean(!m.emulated.pushState&&e.vendor==="Apple Computer, Inc."&&/AppleWebKit\/5([0-2]|3[0-3])/.test(e.userAgent)),ieDoubleCheck:Boolean(m.isInternetExplorer()&&m.getInternetExplorerMajorVersion()<8),hashEscape:Boolean(m.isInternetExplorer()&&m.getInternetExplorerMajorVersion()<7)},m.isEmptyObject=function(a){for(var b in a)return!1;return!0},m.cloneObject=function(a){var b,c;return a?(b=k.stringify(a),c=k.parse(b)):c={},c},m.getRootUrl=function(){var a=d.location.protocol+"//"+(d.location.hostname||d.location.host);if(d.location.port||!1)a+=":"+d.location.port;return a+="/",a},m.getBaseHref=function(){var a=d.getElementsByTagName("base"),b=null,c="";return a.length===1&&(b=a[0],c=b.href.replace(/[^\/]+$/,"")),c=c.replace(/\/+$/,""),c&&(c+="/"),c},m.getBaseUrl=function(){var a=m.getBaseHref()||m.getBasePageUrl()||m.getRootUrl();return a},m.getPageUrl=function(){var a=m.getState(!1,!1),b=(a||{}).url||d.location.href,c;return c=b.replace(/\/+$/,"").replace(/[^\/]+$/,function(a,b,c){return/\./.test(a)?a:a+"/"}),c},m.getBasePageUrl=function(){var a=d.location.href.replace(/[#\?].*/,"").replace(/[^\/]+$/,function(a,b,c){return/[^\/]$/.test(a)?"":a}).replace(/\/+$/,"")+"/";return a},m.getFullUrl=function(a,b){var c=a,d=a.substring(0,1);return b=typeof b=="undefined"?!0:b,/[a-z]+\:\/\//.test(a)||(d==="/"?c=m.getRootUrl()+a.replace(/^\/+/,""):d==="#"?c=m.getPageUrl().replace(/#.*/,"")+a:d==="?"?c=m.getPageUrl().replace(/[\?#].*/,"")+a:b?c=m.getBaseUrl()+a.replace(/^(\.\/)+/,""):c=m.getBasePageUrl()+a.replace(/^(\.\/)+/,"")),c.replace(/\#$/,"")},m.getShortUrl=function(a){var b=a,c=m.getBaseUrl(),d=m.getRootUrl();return m.emulated.pushState&&(b=b.replace(c,"")),b=b.replace(d,"/"),m.isTraditionalAnchor(b)&&(b="./"+b),b=b.replace(/^(\.\/)+/g,"./").replace(/\#$/,""),b},m.store={},m.idToState=m.idToState||{},m.stateToId=m.stateToId||{},m.urlToId=m.urlToId||{},m.storedStates=m.storedStates||[],m.savedStates=m.savedStates||[],m.normalizeStore=function(){m.store.idToState=m.store.idToState||{},m.store.urlToId=m.store.urlToId||{},m.store.stateToId=m.store.stateToId||{}},m.getState=function(a,b){typeof a=="undefined"&&(a=!0),typeof b=="undefined"&&(b=!0);var c=m.getLastSavedState();return!c&&b&&(c=m.createStateObject()),a&&(c=m.cloneObject(c),c.url=c.cleanUrl||c.url),c},m.getIdByState=function(a){var b=m.extractId(a.url),c;if(!b){c=m.getStateString(a);if(typeof m.stateToId[c]!="undefined")b=m.stateToId[c];else if(typeof m.store.stateToId[c]!="undefined")b=m.store.stateToId[c];else{for(;;){b=(new Date).getTime()+String(Math.random()).replace(/\D/g,"");if(typeof m.idToState[b]=="undefined"&&typeof m.store.idToState[b]=="undefined")break}m.stateToId[c]=b,m.idToState[b]=a}}return b},m.normalizeState=function(a){var b,c;if(!a||typeof a!="object")a={};if(typeof a.normalized!="undefined")return a;if(!a.data||typeof a.data!="object")a.data={};b={},b.normalized=!0,b.title=a.title||"",b.url=m.getFullUrl(m.unescapeString(a.url||d.location.href)),b.hash=m.getShortUrl(b.url),b.data=m.cloneObject(a.data),b.id=m.getIdByState(b),b.cleanUrl=b.url.replace(/\??\&_suid.*/,""),b.url=b.cleanUrl,c=!m.isEmptyObject(b.data);if(b.title||c)b.hash=m.getShortUrl(b.url).replace(/\??\&_suid.*/,""),/\?/.test(b.hash)||(b.hash+="?"),b.hash+="&_suid="+b.id;return b.hashedUrl=m.getFullUrl(b.hash),(m.emulated.pushState||m.bugs.safariPoll)&&m.hasUrlDuplicate(b)&&(b.url=b.hashedUrl),b},m.createStateObject=function(a,b,c){var d={data:a,title:b,url:c};return d=m.normalizeState(d),d},m.getStateById=function(a){a=String(a);var c=m.idToState[a]||m.store.idToState[a]||b;return c},m.getStateString=function(a){var b,c,d;return b=m.normalizeState(a),c={data:b.data,title:a.title,url:a.url},d=k.stringify(c),d},m.getStateId=function(a){var b,c;return b=m.normalizeState(a),c=b.id,c},m.getHashByState=function(a){var b,c;return b=m.normalizeState(a),c=b.hash,c},m.extractId=function(a){var b,c,d;return c=/(.*)\&_suid=([0-9]+)$/.exec(a),d=c?c[1]||a:a,b=c?String(c[2]||""):"",b||!1},m.isTraditionalAnchor=function(a){var b=!/[\/\?\.]/.test(a);return b},m.extractState=function(a,b){var c=null,d,e;return b=b||!1,d=m.extractId(a),d&&(c=m.getStateById(d)),c||(e=m.getFullUrl(a),d=m.getIdByUrl(e)||!1,d&&(c=m.getStateById(d)),!c&&b&&!m.isTraditionalAnchor(a)&&(c=m.createStateObject(null,null,e))),c},m.getIdByUrl=function(a){var c=m.urlToId[a]||m.store.urlToId[a]||b;return c},m.getLastSavedState=function(){return m.savedStates[m.savedStates.length-1]||b},m.getLastStoredState=function(){return m.storedStates[m.storedStates.length-1]||b},m.hasUrlDuplicate=function(a){var b=!1,c;return c=m.extractState(a.url),b=c&&c.id!==a.id,b},m.storeState=function(a){return m.urlToId[a.url]=a.id,m.storedStates.push(m.cloneObject(a)),a},m.isLastSavedState=function(a){var b=!1,c,d,e;return m.savedStates.length&&(c=a.id,d=m.getLastSavedState(),e=d.id,b=c===e),b},m.saveState=function(a){return m.isLastSavedState(a)?!1:(m.savedStates.push(m.cloneObject(a)),!0)},m.getStateByIndex=function(a){var b=null;return typeof a=="undefined"?b=m.savedStates[m.savedStates.length-1]:a<0?b=m.savedStates[m.savedStates.length+a]:b=m.savedStates[a],b},m.getHash=function(){var a=m.unescapeHash(d.location.hash);return a},m.unescapeString=function(b){var c=b,d;for(;;){d=a.unescape(c);if(d===c)break;c=d}return c},m.unescapeHash=function(a){var b=m.normalizeHash(a);return b=m.unescapeString(b),b},m.normalizeHash=function(a){var b=a.replace(/[^#]*#/,"").replace(/#.*/,"");return b},m.setHash=function(a,b){var c,e,f;return b!==!1&&m.busy()?(m.pushQueue({scope:m,callback:m.setHash,args:arguments,queue:b}),!1):(c=m.escapeHash(a),m.busy(!0),e=m.extractState(a,!0),e&&!m.emulated.pushState?m.pushState(e.data,e.title,e.url,!1):d.location.hash!==c&&(m.bugs.setHash?(f=m.getPageUrl(),m.pushState(null,null,f+"#"+c,!1)):d.location.hash=c),m)},m.escapeHash=function(b){var c=m.normalizeHash(b);return c=a.escape(c),m.bugs.hashEscape||(c=c.replace(/\%21/g,"!").replace(/\%26/g,"&").replace(/\%3D/g,"=").replace(/\%3F/g,"?")),c},m.getHashByUrl=function(a){var b=String(a).replace(/([^#]*)#?([^#]*)#?(.*)/,"$2");return b=m.unescapeHash(b),b},m.setTitle=function(a){var b=a.title,c;b||(c=m.getStateByIndex(0),c&&c.url===a.url&&(b=c.title||m.options.initialTitle));try{d.getElementsByTagName("title")[0].innerHTML=b.replace("<","<").replace(">",">").replace(" & "," & ")}catch(e){}return d.title=b,m},m.queues=[],m.busy=function(a){typeof a!="undefined"?m.busy.flag=a:typeof m.busy.flag=="undefined"&&(m.busy.flag=!1);if(!m.busy.flag){h(m.busy.timeout);var b=function(){var a,c,d;if(m.busy.flag)return;for(a=m.queues.length-1;a>=0;--a){c=m.queues[a];if(c.length===0)continue;d=c.shift(),m.fireQueueItem(d),m.busy.timeout=g(b,m.options.busyDelay)}};m.busy.timeout=g(b,m.options.busyDelay)}return m.busy.flag},m.busy.flag=!1,m.fireQueueItem=function(a){return a.callback.apply(a.scope||m,a.args||[])},m.pushQueue=function(a){return m.queues[a.queue||0]=m.queues[a.queue||0]||[],m.queues[a.queue||0].push(a),m},m.queue=function(a,b){return typeof a=="function"&&(a={callback:a}),typeof b!="undefined"&&(a.queue=b),m.busy()?m.pushQueue(a):m.fireQueueItem(a),m},m.clearQueue=function(){return m.busy.flag=!1,m.queues=[],m},m.stateChanged=!1,m.doubleChecker=!1,m.doubleCheckComplete=function(){return m.stateChanged=!0,m.doubleCheckClear(),m},m.doubleCheckClear=function(){return m.doubleChecker&&(h(m.doubleChecker),m.doubleChecker=!1),m},m.doubleCheck=function(a){return m.stateChanged=!1,m.doubleCheckClear(),m.bugs.ieDoubleCheck&&(m.doubleChecker=g(function(){return m.doubleCheckClear(),m.stateChanged||a(),!0},m.options.doubleCheckInterval)),m},m.safariStatePoll=function(){var b=m.extractState(d.location.href),c;if(!m.isLastSavedState(b))c=b;else return;return c||(c=m.createStateObject()),m.Adapter.trigger(a,"popstate"),m},m.back=function(a){return a!==!1&&m.busy()?(m.pushQueue({scope:m,callback:m.back,args:arguments,queue:a}),!1):(m.busy(!0),m.doubleCheck(function(){m.back(!1)}),n.go(-1),!0)},m.forward=function(a){return a!==!1&&m.busy()?(m.pushQueue({scope:m,callback:m.forward,args:arguments,queue:a}),!1):(m.busy(!0),m.doubleCheck(function(){m.forward(!1)}),n.go(1),!0)},m.go=function(a,b){var c;if(a>0)for(c=1;c<=a;++c)m.forward(b);else{if(!(a<0))throw new Error("History.go: History.go requires a positive or negative integer passed.");for(c=-1;c>=a;--c)m.back(b)}return m};if(m.emulated.pushState){var o=function(){};m.pushState=m.pushState||o,m.replaceState=m.replaceState||o}else m.onPopState=function(b,c){var e=!1,f=!1,g,h;return m.doubleCheckComplete(),g=m.getHash(),g?(h=m.extractState(g||d.location.href,!0),h?m.replaceState(h.data,h.title,h.url,!1):(m.Adapter.trigger(a,"anchorchange"),m.busy(!1)),m.expectedStateId=!1,!1):(e=m.Adapter.extractEventData("state",b,c)||!1,e?f=m.getStateById(e):m.expectedStateId?f=m.getStateById(m.expectedStateId):f=m.extractState(d.location.href),f||(f=m.createStateObject(null,null,d.location.href)),m.expectedStateId=!1,m.isLastSavedState(f)?(m.busy(!1),!1):(m.storeState(f),m.saveState(f),m.setTitle(f),m.Adapter.trigger(a,"statechange"),m.busy(!1),!0))},m.Adapter.bind(a,"popstate",m.onPopState),m.pushState=function(b,c,d,e){if(m.getHashByUrl(d)&&m.emulated.pushState)throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(e!==!1&&m.busy())return m.pushQueue({scope:m,callback:m.pushState,args:arguments,queue:e}),!1;m.busy(!0);var f=m.createStateObject(b,c,d);return m.isLastSavedState(f)?m.busy(!1):(m.storeState(f),m.expectedStateId=f.id,n.pushState(f.id,f.title,f.url),m.Adapter.trigger(a,"popstate")),!0},m.replaceState=function(b,c,d,e){if(m.getHashByUrl(d)&&m.emulated.pushState)throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(e!==!1&&m.busy())return m.pushQueue({scope:m,callback:m.replaceState,args:arguments,queue:e}),!1;m.busy(!0);var f=m.createStateObject(b,c,d);return m.isLastSavedState(f)?m.busy(!1):(m.storeState(f),m.expectedStateId=f.id,n.replaceState(f.id,f.title,f.url),m.Adapter.trigger(a,"popstate")),!0};if(f){try{m.store=k.parse(f.getItem("History.store"))||{}}catch(p){m.store={}}m.normalizeStore()}else m.store={},m.normalizeStore();m.Adapter.bind(a,"beforeunload",m.clearAllIntervals),m.Adapter.bind(a,"unload",m.clearAllIntervals),m.saveState(m.storeState(m.extractState(d.location.href,!0))),f&&(m.onUnload=function(){var a,b;try{a=k.parse(f.getItem("History.store"))||{}}catch(c){a={}}a.idToState=a.idToState||{},a.urlToId=a.urlToId||{},a.stateToId=a.stateToId||{};for(b in m.idToState){if(!m.idToState.hasOwnProperty(b))continue;a.idToState[b]=m.idToState[b]}for(b in m.urlToId){if(!m.urlToId.hasOwnProperty(b))continue;a.urlToId[b]=m.urlToId[b]}for(b in m.stateToId){if(!m.stateToId.hasOwnProperty(b))continue;a.stateToId[b]=m.stateToId[b]}m.store=a,m.normalizeStore(),f.setItem("History.store",k.stringify(a))},m.intervalList.push(i(m.onUnload,m.options.storeInterval)),m.Adapter.bind(a,"beforeunload",m.onUnload),m.Adapter.bind(a,"unload",m.onUnload));if(!m.emulated.pushState){m.bugs.safariPoll&&m.intervalList.push(i(m.safariStatePoll,m.options.safariPollInterval));if(e.vendor==="Apple Computer, Inc."||(e.appCodeName||"")==="Mozilla")m.Adapter.bind(a,"hashchange",function(){m.Adapter.trigger(a,"popstate")}),m.getHash()&&m.Adapter.onDomLoad(function(){m.Adapter.trigger(a,"hashchange")})}},m.init()}(window)
|
@@ -1,6 +0,0 @@
|
|
1
|
-
.btn-group
|
2
|
-
- {down: :right, up: :left}.each_pair do |a, b|
|
3
|
-
- sibling = item.send(b.to_s+'_sibling')
|
4
|
-
- if sibling and item.move_possible?(sibling)
|
5
|
-
= link_to "/admin/#{item.class.to_s.demodulize.downcase.pluralize}/move/#{a}/#{item.id}", class: 'btn btn-mini' do
|
6
|
-
%i{class: "icon-arrow-#{a}"}
|