journalduhacker/app/views/stories/_form.html.erb

52 lines
1.8 KiB
Plaintext
Raw Normal View History

<%= error_messages_for f.object %>
<div class="box">
<div class="boxline">
<% if f.object.url_is_editable_by_user?(@user) %>
<%= f.label :url, "URL:", :class => "required" %>
<%= f.text_field :url, :autocomplete => "off" %>
2012-09-19 19:37:42 +02:00
<%= button_tag "Fetch Title", :id => "story_fetch_title",
:type => "button" %>
<% elsif !f.object.new_record? && !f.object.url.blank? %>
<%= f.label :url, "URL:", :class => "required" %>
<div class="d">
<a href="<%= f.object.url %>"><%= f.object.url %></a>
</div>
<% end %>
</div>
<div class="boxline">
<%= f.label :title, "Title:", :class => "required" %>
2012-07-05 01:58:58 +02:00
<%= f.text_field :title, :maxlength => 100, :autocomplete => "off" %>
</div>
<div class="boxline" style="margin-bottom: 2px;">
<%= f.label :tags_a, "Tags:", :class => "required",
:style => "line-height: 2.3em;" %>
<%= f.select "tags_a", options_for_select(
Tag.all_with_filtered_counts_for(@user).map{|t|
[ "#{t.tag} - #{t.description}", t.tag, { "data-html" => raw("<strong>") +
t.tag + raw("</strong> - ") + t.description.to_s +
(t.filtered_count == 0 ? "" :
raw(" <em>") + "#{t.filtered_count} user" +
(t.filtered_count == 1 ? "" : "s") + " filtering" +
raw("</em>")) } ]}, f.object.tags_a), {}, { :multiple => true } %>
</div>
<div class="boxline">
<%= f.label :description, "Text:", :class => "required" %>
<%= f.text_area :description, :rows => 15,
2012-08-17 21:15:04 +02:00
:placeholder => "Optional when submitting a URL; please see guidelines",
2012-07-05 01:58:58 +02:00
:autocomplete => "off" %>
</div>
</div>
2012-09-19 19:37:42 +02:00
<script>
$(document).ready(function() {
$("#story_fetch_title").click(function() {
Lobsters.fetchURLTitle($(this), $("#story_url"), $("#story_title"));
return false;
});
});
</script>