kit_cms 2.3.16 → 2.3.17
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/images/kit/toolbar/bold.png +0 -0
- data/app/assets/images/kit/toolbar/formatted.png +0 -0
- data/app/assets/images/kit/toolbar/image.png +0 -0
- data/app/assets/images/kit/toolbar/link.png +0 -0
- data/app/assets/images/kit/toolbar/list.png +0 -0
- data/app/assets/images/kit/toolbar/numbered_list.png +0 -0
- data/app/assets/images/kit/toolbar/preview.png +0 -0
- data/app/assets/images/kit/toolbar/quote.png +0 -0
- data/app/assets/images/kit/toolbar/redo.png +0 -0
- data/app/assets/images/kit/toolbar/underline.png +0 -0
- data/app/assets/images/kit/toolbar/undo.png +0 -0
- data/app/assets/images/kit/toolbar/video.png +0 -0
- data/app/assets/javascripts/codemirror/editor.js +183 -0
- data/app/assets/javascripts/codemirror/markdown.js +475 -0
- data/app/assets/javascripts/jquery.contextmenu.js +7 -7
- data/app/assets/javascripts/kit/kit.js +0 -1
- data/app/assets/javascripts/kit/markdown.js +1 -37
- data/app/assets/javascripts/kit/tree.js +18 -10
- data/app/assets/javascripts/kit/utilities.js +1 -1
- data/app/assets/stylesheets/codemirror/editor.css +3 -3
- data/app/assets/stylesheets/codemirror/theme.css +76 -1
- data/app/assets/stylesheets/kit/calendar.css +58 -97
- data/app/assets/stylesheets/kit/cms/cms.css +19 -0
- data/app/assets/stylesheets/kit/cms/dsc_tree.css +4 -0
- data/app/assets/stylesheets/kit/forums.css +30 -0
- data/app/assets/stylesheets/kit/kit.css +0 -1
- data/app/controllers/admin/dashboard_controller.rb +11 -2
- data/app/controllers/admin/page_templates_controller.rb +14 -1
- data/app/controllers/admin/user_controller.rb +2 -3
- data/app/controllers/category_controller.rb +5 -6
- data/app/controllers/form_controller.rb +1 -1
- data/app/controllers/forum_controller.rb +2 -2
- data/app/controllers/kit_controller.rb +2 -2
- data/app/controllers/pages_controller.rb +24 -0
- data/app/controllers/user/passwords_controller.rb +2 -0
- data/app/controllers/user/registrations_controller.rb +1 -4
- data/app/controllers/user/sessions_controller.rb +2 -0
- data/app/controllers/user/unlocks_controller.rb +2 -0
- data/app/controllers/user_controller.rb +1 -1
- data/app/helpers/calendar_helper.rb +4 -1
- data/app/helpers/kit_helper.rb +3 -3
- data/app/mailers/notification.rb +3 -3
- data/app/models/activity.rb +5 -2
- data/app/models/calendar.rb +1 -1
- data/app/models/category.rb +18 -4
- data/app/models/experiment.rb +2 -0
- data/app/models/form_submission.rb +2 -2
- data/app/models/html_asset.rb +3 -0
- data/app/models/mapping.rb +1 -0
- data/app/models/user.rb +1 -1
- data/app/views/admin/blocks/_form.html.haml +1 -1
- data/app/views/admin/dashboard/user_comments.html.haml +19 -8
- data/app/views/admin/experiments/show.html.haml +1 -1
- data/app/views/admin/form/_form.html.haml +8 -0
- data/app/views/admin/page_templates/_form.html.haml +1 -1
- data/app/views/admin/views/_form.html.haml +4 -4
- data/app/views/calendar/_calendar_scripts.js.erb +2 -2
- data/app/views/calendar/_month.html.haml +58 -27
- data/app/views/category/_select_options.html.erb +1 -1
- data/app/views/form/_show.html.haml +9 -1
- data/app/views/forum/_add_post.html.haml +3 -2
- data/app/views/forum/_mod_thread.js.erb +2 -2
- data/app/views/forum/_post_scripts.js.erb +1 -2
- data/app/views/forum/thread.html.haml +4 -0
- data/app/views/layouts/_application.html.erb +1 -0
- data/app/views/layouts/minimal.html.erb +2 -2
- data/app/views/notification/form_submission.text.erb +2 -0
- data/app/views/pages/_form.html.haml +7 -8
- data/app/views/pages/_page_scripts.js.erb +1 -3
- data/app/views/pages/_page_template_script.js.erb +28 -0
- data/app/views/pages/cookie_text.html.haml +1 -1
- data/app/views/pages/info.html.erb +2 -2
- data/app/views/pages/page_template.html.haml +40 -0
- data/app/views/utility/_cm_editor.html.erb +34 -5
- data/app/views/utility/_cm_toolbar_markdown.html.haml +49 -0
- data/config/initializers/devise_extender.rb +9 -0
- data/config/initializers/html_assets.rb +4 -0
- data/config/initializers/quiet_asserts.rb +1 -1
- data/config/routes.rb +2 -0
- metadata +21 -3
data/app/models/html_asset.rb
CHANGED
@@ -35,6 +35,9 @@ class HtmlAsset < ActiveRecord::Base
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def write_to_file
|
38
|
+
parent = File.join(Rails.root, "public", "kit", self.file_type)
|
39
|
+
FileUtils.mkdir_p(parent) unless File.exists?(parent)
|
40
|
+
|
38
41
|
path = File.join(Rails.root, "public", "kit", self.file_type, self.kit_name)
|
39
42
|
dir = File.join(Rails.root, "public", "kit", self.file_type)
|
40
43
|
found = false
|
data/app/models/mapping.rb
CHANGED
data/app/models/user.rb
CHANGED
@@ -117,7 +117,7 @@ class User < KitIndexed
|
|
117
117
|
|
118
118
|
after_create :welcome_message
|
119
119
|
|
120
|
-
validates :display_name, :uniqueness=>{:scope=>:system_id}
|
120
|
+
validates :display_name, :uniqueness=>{:scope=>:system_id}, :allow_blank => true
|
121
121
|
validates :email, :presence=>true, :uniqueness=>{:scope=>:system_id}
|
122
122
|
validates :password, :presence=>true, :confirmation=>true, :on=>:create
|
123
123
|
validates_confirmation_of :password, :on=>:create
|
@@ -1,7 +1,6 @@
|
|
1
1
|
- content_for :page_scripts do
|
2
2
|
|
3
3
|
function updated(id, moderated, visible) {
|
4
|
-
console.debug(moderated + " " + visible);
|
5
4
|
var mod;
|
6
5
|
var nmod;
|
7
6
|
var vis;
|
@@ -25,8 +24,6 @@
|
|
25
24
|
vnmod = 0;
|
26
25
|
}
|
27
26
|
|
28
|
-
console.debug(id + ", " + moderated + ", " + visible + ", " + mod + ", " + nmod + "," + vis + ", " + vnmod);
|
29
|
-
|
30
27
|
$('#mod_link_' + id + ' a').text(mod).attr('href', '/admin/dashboard/user_comment/' + id + '?comment[is_moderated]='+nmod);
|
31
28
|
|
32
29
|
$('#vis_link_' + id + ' a').text(vis).attr('href', '/admin/dashboard/user_comment/' + id + '?comment[is_visible]='+vnmod);
|
@@ -57,18 +54,32 @@
|
|
57
54
|
%th(width='200') User
|
58
55
|
%th Moderated
|
59
56
|
%th Visible
|
57
|
+
%th Delete
|
60
58
|
- @comments.each do |comment|
|
61
|
-
%tr
|
59
|
+
%tr(class="comment_#{comment.id}")
|
62
60
|
%td
|
63
61
|
= link_to comment.url, comment.url
|
64
62
|
%td
|
65
63
|
= link_to_if comment.user_id!=0, comment.user_email, "/admin/user/#{comment.user_id}"
|
66
64
|
%td(id="mod_link_#{comment.id}")
|
67
|
-
=
|
65
|
+
= icon_to comment.is_moderated? ? 'Yes' : 'No', "/admin/dashboard/user_comment/#{comment.id}?comment[is_moderated]=#{comment.is_moderated? ? 0 : 1}", false, :method=>:post, :remote=>true
|
68
66
|
%td(id="vis_link_#{comment.id}")
|
69
|
-
=
|
70
|
-
|
71
|
-
|
67
|
+
= icon_to comment.is_visible? ? 'Yes' : 'No', "/admin/dashboard/user_comment/#{comment.id}?comment[is_visible]=#{comment.is_visible? ? 0 : 1}", false, :method=>:post, :remote=>true
|
68
|
+
%td(id="delete_link_#{comment.id}")
|
69
|
+
= icon_to "Delete", "/admin/dashboard/user_comment/#{comment.id}?delete=1", false, :method=>:post, :remote=>true, :confirm=>"Are you sure?"
|
70
|
+
%tr(class="comment_#{comment.id}")
|
71
|
+
%td(colspan="5")
|
72
|
+
.info
|
73
|
+
Name:
|
74
|
+
= comment.user_name
|
75
|
+
.info
|
76
|
+
Email:
|
77
|
+
= comment.user_email
|
78
|
+
.info
|
79
|
+
URL:
|
80
|
+
= link_to comment.user_url, comment.user_url
|
81
|
+
%br
|
72
82
|
= field_reveal(comment.body, 200)
|
83
|
+
%hr
|
73
84
|
|
74
85
|
|
@@ -52,6 +52,14 @@
|
|
52
52
|
.field_help
|
53
53
|
Include new and updated entries in system activity log
|
54
54
|
|
55
|
+
- if @form.respond_to?(:layout)
|
56
|
+
%li.advanced
|
57
|
+
= f.label "Layout"
|
58
|
+
= f.select :layout, options_from_collection_for_select(Layout.sys(_sid).order(:name).all, 'name', 'name')
|
59
|
+
|
60
|
+
.field_help
|
61
|
+
The layout to use for this form when rendering it as a page.
|
62
|
+
|
55
63
|
%li.advanced
|
56
64
|
= f.label "Stylesheets"
|
57
65
|
= f.text_field :stylesheets
|
@@ -43,7 +43,7 @@
|
|
43
43
|
If this template has an equivalent version for mobile devices, select it here. As such, practically this is mutually exclusive with the "For mobile devices" option above.
|
44
44
|
%p
|
45
45
|
= f.label :body
|
46
|
-
= cm_editor('
|
46
|
+
= cm_editor('xml', :page_template, :body, f)
|
47
47
|
.field_help
|
48
48
|
The content of the template.
|
49
49
|
%p
|
@@ -11,17 +11,17 @@
|
|
11
11
|
|
12
12
|
%p
|
13
13
|
= f.label :body
|
14
|
-
= f
|
14
|
+
= cm_editor("html", :view, :body, f, nil, :height=>"400px")
|
15
15
|
|
16
16
|
%p
|
17
17
|
= f.label :header
|
18
|
-
= f
|
18
|
+
= cm_editor("html", :view, :header, f, nil, :height=>"120px")
|
19
19
|
.field_help
|
20
20
|
Optional
|
21
21
|
|
22
22
|
%p
|
23
23
|
= f.label :footer
|
24
|
-
= f
|
24
|
+
= cm_editor("html", :view, :footer, f, nil, :height=>"120px")
|
25
25
|
.field_help
|
26
26
|
Optional
|
27
27
|
|
@@ -50,7 +50,7 @@
|
|
50
50
|
|
51
51
|
%p
|
52
52
|
= f.label :layout_id
|
53
|
-
= f.select :layout_id, options_from_collection_for_select(Layout.order(:name).all, :id, :name, @view.layout_id)
|
53
|
+
= f.select :layout_id, options_from_collection_for_select(Layout.sys(_sid).order(:name).all, :id, :name, @view.layout_id)
|
54
54
|
.field_help
|
55
55
|
Only used if rendering this view as a whole page. Not used if rendering the view in another page
|
56
56
|
|
@@ -4,7 +4,7 @@ function month_show_day(day) {
|
|
4
4
|
$('#day_' + i).hide();
|
5
5
|
}
|
6
6
|
$('#day_' + day).show().find('li').show();
|
7
|
-
$('
|
7
|
+
$('table td.selected').removeClass('selected');
|
8
8
|
$('#box_' + day).addClass('selected');
|
9
9
|
}
|
10
10
|
|
@@ -12,7 +12,7 @@ function month_show_entry(day, entry) {
|
|
12
12
|
month_show_day(day);
|
13
13
|
$('#day_' + day + " li").hide();
|
14
14
|
$('.entry_' + entry).show();
|
15
|
-
$('
|
15
|
+
$('table td.selected').removeClass('selected');
|
16
16
|
$('#box_' + day).addClass('selected');
|
17
17
|
}
|
18
18
|
|
@@ -75,18 +75,32 @@
|
|
75
75
|
.next
|
76
76
|
= link_to ">".html_safe, current_path_with_new_params("month=#{next_month}&year=#{next_year}&srid=#{params[:srid]}&etid=#{params[:etid]}")
|
77
77
|
|
78
|
-
|
79
|
-
|
80
|
-
%
|
81
|
-
-
|
82
|
-
%
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
78
|
+
|
79
|
+
%table(class="#{mini ? 'mini' : 'full'}")
|
80
|
+
%tr.titles
|
81
|
+
- if options[:show_days]
|
82
|
+
%th.monday Monday
|
83
|
+
%th.tuesday Tuesday
|
84
|
+
%th.wednesday Wednesday
|
85
|
+
%th.thursday Thursday
|
86
|
+
%th.friday Friday
|
87
|
+
%th.saturday Saturday
|
88
|
+
%th.sunday Sunday
|
89
|
+
|
90
|
+
- row = 1
|
91
|
+
- col = 0
|
92
|
+
|
87
93
|
- entries.keys.sort.each do |key|
|
88
94
|
- days = entries[key]
|
89
|
-
|
95
|
+
- col += 1
|
96
|
+
= "<tr>".html_safe if col==1
|
97
|
+
|
98
|
+
- if col==1 && row==1
|
99
|
+
- while col < Date.new(date.year, date.month, 1).wday
|
100
|
+
= "<td class='pad'> </td>".html_safe
|
101
|
+
- col += 1
|
102
|
+
|
103
|
+
%td(id="box_#{key}" rel="#{key}" class="date_box #{date.strftime("%A").downcase if key==1} #{'today' if (date+(key-1).days).to_date==Date.today}")
|
90
104
|
- if mini
|
91
105
|
= key
|
92
106
|
- else
|
@@ -94,23 +108,40 @@
|
|
94
108
|
- if days.size==0 || mini
|
95
109
|
|
96
110
|
- else
|
97
|
-
|
98
|
-
|
99
|
-
-
|
100
|
-
|
101
|
-
|
102
|
-
- if
|
103
|
-
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
111
|
+
- cnt = 0
|
112
|
+
- days.each do |entry|
|
113
|
+
- cnt += 1
|
114
|
+
%p
|
115
|
+
- if cnt>3
|
116
|
+
- if Preference.get_cached(_sid, 'calendar_show_event_count')=='true'
|
117
|
+
- cnt = days.size
|
118
|
+
.event_count
|
119
|
+
= "#{cnt}"
|
120
|
+
|
121
|
+
= link_to_function "more...", "month_show_day(#{key})"
|
122
|
+
- break
|
123
|
+
- else
|
124
|
+
= "*" unless entry.approved_at
|
125
|
+
= link_to_function truncate(entry.name, :length=>20), "month_show_entry(#{key}, #{entry.id})"
|
126
|
+
|
127
|
+
|
128
|
+
- if col==7
|
129
|
+
= "</tr>".html_safe
|
130
|
+
- col = 0
|
131
|
+
- row += 1
|
132
|
+
- need_close = false
|
133
|
+
- if col > 0
|
134
|
+
- while col < 7
|
135
|
+
= "<td class='pad'> </td>".html_safe
|
136
|
+
- col += 1
|
137
|
+
- need_close = true
|
138
|
+
|
139
|
+
= "</tr>".html_safe if need_close
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
.clear
|
114
145
|
|
115
146
|
- unless mini
|
116
147
|
.details
|
@@ -1 +1 @@
|
|
1
|
-
<% @categories.each do |cat| -%><option value="<%= cat.id %>"><%= cat.path %></option><% end -%>
|
1
|
+
<% @categories.each do |cat| -%><option value="<%= cat.id %>"><%= cat.path.strip %></option><% end -%>
|
@@ -1,12 +1,15 @@
|
|
1
|
+
- first_field = nil
|
1
2
|
- content_for :page_scripts do
|
2
3
|
$(document).ready(function() {
|
3
4
|
|
4
5
|
- form.form_fields.each do |field|
|
6
|
+
- first_field = field
|
5
7
|
- next unless field.form_field_type.html_options.not_blank?
|
6
8
|
- field.form_field_type.html_options.split('|').each do |hh|
|
7
9
|
$('#field_#{field.id}').attr('#{hh.split('=')[0]}', #{hh.split('=')[1]});
|
8
10
|
$('#form_#{form.id}').validate();
|
9
|
-
|
11
|
+
- if first_field
|
12
|
+
$('#field_#{first_field.id}').focus();
|
10
13
|
});
|
11
14
|
|
12
15
|
%div(class="#{form.klass}")
|
@@ -14,6 +17,11 @@
|
|
14
17
|
.form-title
|
15
18
|
= form.title
|
16
19
|
|
20
|
+
- if first_field == nil && (is_admin? || (current_user && form.user_id==current_user.id) )
|
21
|
+
This form has no fields. Go to the
|
22
|
+
= link_to "form in the dashboard", "/admin/form/#{form.id}/fields"
|
23
|
+
to add some. Normal users will not see this message.
|
24
|
+
|
17
25
|
- if show_body
|
18
26
|
.body
|
19
27
|
= form.body.html_safe
|
@@ -34,7 +34,9 @@
|
|
34
34
|
#body
|
35
35
|
%label(label_for='post_body')
|
36
36
|
= t "forum.post_body"
|
37
|
-
=
|
37
|
+
.post_box(style="border: thin #AAA solid; margin-bottom: 10px;")
|
38
|
+
= f.text_area :body
|
39
|
+
= cm_editor('markdown', :topic_post, :body, form, nil, {:theme=>"neat", :dont_show_mode=>true, :dont_show_line_numbers=>true, :height=>300, :show_toolbar=>true}) if Preference.get_cached(_sid, "use_markdown_editor")=="true"
|
38
40
|
|
39
41
|
- formatting = kit_snippet('Forum Post Formatting Help')
|
40
42
|
- if formatting.not_blank?
|
@@ -43,7 +45,6 @@
|
|
43
45
|
|
44
46
|
#submit
|
45
47
|
= link_to_function t("forum.submit_post"), "send_this_form();", :class=>"action"
|
46
|
-
= link_to_function t("forum.preview_post"), "$('#body .markItUpButton9').mouseup();", :class=>"action"
|
47
48
|
.display_name
|
48
49
|
Posting as "
|
49
50
|
= current_user.display_name if current_user && current_user.display_name
|
@@ -43,8 +43,8 @@ function edit_post(thread_id, post_id) {
|
|
43
43
|
body.append('<div id="popup_form"></div>');
|
44
44
|
div = $('#popup_form');
|
45
45
|
|
46
|
-
|
47
|
-
|
46
|
+
div.append('Post: <textarea style="width:95%;" rows="18" id="topic_post_body_mod"></textarea>');
|
47
|
+
// TODO: Markdown editor
|
48
48
|
div.append('Comment: <textarea style="width:95%;" rows="6" id="comment"></textarea>');
|
49
49
|
div.append('<br/><input type="button" onClick="save_edit();" value="Save"/>');
|
50
50
|
$('#topic_post_body_mod').load("/forums/post/"+post_id);
|
@@ -14,7 +14,6 @@ $(document).ready(function() {
|
|
14
14
|
show_post();
|
15
15
|
<% end %>
|
16
16
|
|
17
|
-
markdown_editor('#topic_post_body');
|
18
17
|
});
|
19
18
|
|
20
19
|
var editing_id = null;
|
@@ -28,9 +27,9 @@ function user_edit_post(post_id) {
|
|
28
27
|
div = $('#popup_form');
|
29
28
|
|
30
29
|
div.append('Post: <textarea style="width:95%;" rows="18" id="topic_post_body_edit"></textarea>');
|
30
|
+
// TODO Markdown editor
|
31
31
|
div.append('<br/><input type="button" onClick="user_save_edit();" value="Save"/>');
|
32
32
|
$('#topic_post_body_edit').load("/forums/post/"+post_id);
|
33
|
-
markdown_editor('#topic_post_body_edit');
|
34
33
|
editing_id = post_id;
|
35
34
|
}
|
36
35
|
|
@@ -2,6 +2,10 @@
|
|
2
2
|
- content_for :page_scripts do
|
3
3
|
= render :partial=>"mod_thread", :formats=>[:js]
|
4
4
|
|
5
|
+
- content_for :head do
|
6
|
+
= javascript_include_tag "codemirror/editor"
|
7
|
+
= stylesheet_link_tag "codemirror/editor"
|
8
|
+
|
5
9
|
#forums
|
6
10
|
= render(:partial=>"introduction")
|
7
11
|
.titles(class='clearfix')
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= yield %>
|
@@ -3,9 +3,9 @@
|
|
3
3
|
<head>
|
4
4
|
<title><%= yield :title %></title>
|
5
5
|
<!-- layout: minimal -->
|
6
|
-
|
6
|
+
|
7
|
+
<%= stylesheet_link_tag "kit/cms" %>
|
7
8
|
<%= render :partial=>'/layouts/cms-common', :locals=>{:include_menu=>true} %>
|
8
|
-
<%= stylesheet_link_tag "kit_admin" %>
|
9
9
|
|
10
10
|
<%= csrf_meta_tag %>
|
11
11
|
|
@@ -19,7 +19,7 @@
|
|
19
19
|
= render :partial=>"google_preview"
|
20
20
|
|
21
21
|
- simple_mode = pref('advanced_mode')!='advanced'
|
22
|
-
|
22
|
+
- advanced_mode = !simple_mode
|
23
23
|
|
24
24
|
#pageinfo.cms_form(style="margin-bottom: 10px;")
|
25
25
|
= form_for @page do |f|
|
@@ -32,15 +32,14 @@
|
|
32
32
|
= f.hidden_field :copy_of
|
33
33
|
|
34
34
|
- if @page.new_record?
|
35
|
-
- category_visible =
|
35
|
+
- category_visible = advanced_mode || params[:cat_id]==nil || @page.errors[:name].size>0
|
36
36
|
%li(class='select optional more_options' id='article_category_input' style="#{'display: none;' unless category_visible}")
|
37
37
|
%label(for='article_category_id') Category
|
38
|
-
=
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
Enter any part of the name of the desired category
|
38
|
+
- cat_options = options_from_collection_for_select(Category.order('path').sys(_sid).all, :id, :path, @page.category_id || params[:cat_id])
|
39
|
+
= select_tag "page[category_id]", cat_options.html_safe, :style=>"width: 542px;"
|
40
|
+
%span.category_filter
|
41
|
+
= icon_to_function "Filter Categories", "$('.category_filter input').show().focus(); $('.category_filter a').hide();", false
|
42
|
+
= text_field_tag "category_filter", '', {"data-focus"=>has_cat ? '':'special', :style=>"width: 100px; display: none;"}
|
44
43
|
#category_warning
|
45
44
|
- else
|
46
45
|
%script(type='text/javascript')
|
@@ -29,8 +29,7 @@ $('input#page_title').change(function() {
|
|
29
29
|
}
|
30
30
|
});
|
31
31
|
|
32
|
-
$('#category_filter').bind('
|
33
|
-
if ($(this).val().length>0) {
|
32
|
+
$('#category_filter').bind('keyup', function () {
|
34
33
|
$('#wait').show();
|
35
34
|
$.ajax({type:"POST",
|
36
35
|
url:"/category/select_options",
|
@@ -39,7 +38,6 @@ $('#category_filter').bind('keydown', function () {
|
|
39
38
|
$('#wait').hide();
|
40
39
|
},
|
41
40
|
data:"type=page&search="+$(this).val()});
|
42
|
-
}
|
43
41
|
});
|
44
42
|
|
45
43
|
$('#category_filter').focus();
|
@@ -0,0 +1,28 @@
|
|
1
|
+
var current_page_template_id = <%= current %>;
|
2
|
+
|
3
|
+
$(document).ready(function() {
|
4
|
+
$('#page_page_template_id').on('change', function() {
|
5
|
+
$('#error_explanation').hide();
|
6
|
+
var template_id = $('#page_page_template_id').val();
|
7
|
+
if (template_id == current_page_template_id) {
|
8
|
+
return;
|
9
|
+
}
|
10
|
+
$.get('/admin/page_templates/' + template_id + "/mapping", null, function(data) {
|
11
|
+
var options = '<option></option>';
|
12
|
+
$.each(data, function(index, value) {
|
13
|
+
options = options + "<option value='" + value + "'>";
|
14
|
+
options = options + value + "</option>";
|
15
|
+
});
|
16
|
+
|
17
|
+
$('.field_select').html($(options));
|
18
|
+
$('.field_select').each(function () {
|
19
|
+
var select = $(this);
|
20
|
+
var data_name = select.attr('data-name');
|
21
|
+
select.find('option').each(function() {
|
22
|
+
this.selected = (this.value == data_name);
|
23
|
+
});
|
24
|
+
});
|
25
|
+
$('ul#mapping').show();
|
26
|
+
});
|
27
|
+
});
|
28
|
+
});
|