Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix revert draft; accommodate true/false radio buttons from template …

…extension
  • Loading branch information...
commit 7dbec69411d42a9ce215c26263eb434222f2a181 1 parent 0ae9f64
@avonderluft authored
View
4 app/views/admin/page_parts/_page_part.html.haml
@@ -12,6 +12,6 @@
= link_to_function 'Available Tags', "load_tag_reference('#{page_part.name.to_slug}');"
= render_region :part_controls, :locals => {:page_part => page_part}
%div
- ~ text_area_tag 'page[parts][][draft_content]', h(page_part.draft_content), :class => "textarea", :style => "width: 100%", :id => "part_#{page_part.name.to_slug}_draft_content"
+ ~ text_area_tag "page[parts][][draft_content]", h(page_part.draft_content), :class => "textarea", :style => "width: 100%", :id => "page_parts_#{page_part.name.to_slug}_draft_content"
= preserve do
- = hidden_field_tag "page[parts][][content]", page_part.content
+ = hidden_field_tag "page[parts][][content]", page_part.content, :id => "page_parts_#{page_part.name.to_slug}_content"
View
18 public/javascripts/admin/concurrent_draft.js
@@ -22,10 +22,11 @@ Draft.RevertLink = Behavior.create({
this.popup.show();
},
copyData: function(input){
- var draft_id = input.name.gsub(/content/, 'draft_content').gsub(/[\[\]]+/, '_').sub(/\_*$/, '');
+ // var draft_id = input.name.gsub(/content/, 'draft_content').gsub(/[\[\]]+/, '_').sub(/\_*$/, '');
+ var draft_id = input.id.gsub(/content/, 'draft_content');
var draft = $(draft_id);
- // The following was modified to accommodate templates
- if(draft){
+ // The following was modified to accommodate templates extension
+ if (draft) {
switch(draft.type){
case 'checkbox':
draft.checked = (input.value == draft.value);
@@ -35,6 +36,17 @@ Draft.RevertLink = Behavior.create({
break;
}
draft.fire('draft:reverted');
+ } else {
+ // for true/false radio buttons in templates extension
+ var draft_true = document.getElementById(draft_id + '_true');
+ var draft_false = document.getElementById(draft_id + '_false');
+ if (draft_true && draft_false && draft_true.type == 'radio' && draft_false.type == 'radio') {
+ if (input.value == 'true') {
+ draft_true.checked = true;
+ } else if (input.value == 'false') {
+ draft_false.checked = true;
+ }
+ }
}
}
});
Please sign in to comment.
Something went wrong with that request. Please try again.