publication/app/views/admin/publications/_form_link.html.erb

37 lines
1.5 KiB
Plaintext
Raw Normal View History

2023-06-23 10:25:35 +00:00
<div class="input-prepend input-append start-line">
<% url_id = "#{f.object_name.gsub(/[\[\]]+/, '_')}url" %>
<span class="add-on icons-link" title="<%= t(:url) %>"></span>
<%= f.text_field :url, class: "input-large", placeholder: t(:url), id: url_id %>
<span class="add-on icons-pencil" title="<%= t(:url_alt) %>"></span>
<span class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
<%= f.fields_for :title_translations do |f| %>
<%= f.text_field locale, :class => "input-large", placeholder: t(:url_alt), :value => (form_link.title_translations[locale] rescue nil) %>
<% end %>
</span>
<% end %>
</span>
<% if form_link.new_record? %>
<span class="delete_link add-on btn" title="<%= t(:delete_) %>">
<a class="icon-trash"></a>
</span>
<% else %>
<span class="remove_existing_record add-on btn" title="<%= t(:remove) %>">
<%= f.hidden_field :id %>
<a class="icon-remove"></a>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
</span>
<% end %>
<script type="text/javascript">
$('#<%=url_id%>').on('paste', function(e){
var pastedData = e.originalEvent.clipboardData.getData('text');
var _this = $(this);
pastedData = pastedData.replace(new RegExp('^http(s|)://' + window.location.host), '');
window.setTimeout(function(){
_this.val(pastedData);
}, 0);
});
</script>
</div>