Auto convert title and note field to text when pasting from clipboard.
This commit is contained in:
parent
39be2dd0e9
commit
a956408459
|
|
@ -62,7 +62,7 @@
|
||||||
<%= f.fields_for :title_translations, f.object do |f| %>
|
<%= f.fields_for :title_translations, f.object do |f| %>
|
||||||
<div class="tab-pane fade <%= ( i == 0 ) ? "active in" : '' %>" id="title_translations_<%= locale %>">
|
<div class="tab-pane fade <%= ( i == 0 ) ? "active in" : '' %>" id="title_translations_<%= locale %>">
|
||||||
<% title = f.object.title(locale) %>
|
<% title = f.object.title(locale) %>
|
||||||
<div data-ph="<%= t('calendar.press_enter') %>" contenteditable="true" class="calendar-comment"><%= title.to_s.html_safe %></div>
|
<div data-ph="<%= t('calendar.press_enter') %>" contenteditable="true" class="calendar-comment preserve_input_text"><%= title.to_s.html_safe %></div>
|
||||||
<%= hidden_field_tag "#{f.object_name}[#{locale}]", title %>
|
<%= hidden_field_tag "#{f.object_name}[#{locale}]", title %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
@ -83,7 +83,7 @@
|
||||||
<%= f.fields_for :note_translations, f.object do |f| %>
|
<%= f.fields_for :note_translations, f.object do |f| %>
|
||||||
<div class="tab-pane fade <%= ( i == 0 ) ? "active in" : '' %>" id="note_translations_<%= locale %>">
|
<div class="tab-pane fade <%= ( i == 0 ) ? "active in" : '' %>" id="note_translations_<%= locale %>">
|
||||||
<% note = f.object.note(locale) %>
|
<% note = f.object.note(locale) %>
|
||||||
<div data-ph="<%= t('calendar.press_enter') %>" contenteditable="true" class="calendar-comment"><%= note.to_s.html_safe %></div>
|
<div data-ph="<%= t('calendar.press_enter') %>" contenteditable="true" class="calendar-comment preserve_input_text"><%= note.to_s.html_safe %></div>
|
||||||
<%= hidden_field_tag "#{f.object_name}[#{locale}]", note %>
|
<%= hidden_field_tag "#{f.object_name}[#{locale}]", note %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
@ -283,6 +283,10 @@
|
||||||
if (year != '' && month != '' && day != ''){
|
if (year != '' && month != '' && day != ''){
|
||||||
parent_div.find('input[type="hidden"]').eq(-1).val(year+'-'+month+'-'+day)
|
parent_div.find('input[type="hidden"]').eq(-1).val(year+'-'+month+'-'+day)
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
$('.preserve_input_text').off('paste').on('paste',function(e){
|
||||||
|
$(this).html(($('<div></div>').append(e.originalEvent.clipboardData.getData('text/plain')).text()));
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
Loading…
Reference in New Issue