-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Unique HTML IDs to .dropzones, #fileinputs #8927
Changes from 4 commits
bc302a0
37e4ed2
9a71180
43a66f4
12726f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,18 @@ def feature_node(title) | |
end | ||
end | ||
|
||
# used in views/comments/_form.html.erb | ||
def get_large_dropzone_id(location, reply_to) | ||
case location | ||
when :main | ||
'-main' | ||
when :reply | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indent |
||
'-reply-' + reply_to.to_s | ||
when :responses | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indent |
||
'-responses' | ||
end | ||
end | ||
|
||
def locale_name_pairs | ||
I18n.available_locales.map do |locale| | ||
[I18n.t('language', locale: locale), locale] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,16 +19,24 @@ | |
padding-top: 10px; | ||
} | ||
</style> | ||
|
||
|
||
<%= render :partial => "editor/toolbar" %> | ||
<!-- location: for creating unique .dropzone IDs --> | ||
<!-- this view is used for: main comment form, replies to comments, and 'responses' --> | ||
<!-- if location == reply, toolbar needs reply_to for dropzone IDs --> | ||
<% locals = (location == :reply) ? | ||
{ :location => location, :reply_to => reply_to } : | ||
{ :location => location } | ||
%> | ||
<%= render :partial => "editor/toolbar", :locals => locals %> | ||
|
||
<% if local_assigns[:reply_to].present? %> | ||
<%= hidden_field_tag :reply_to, local_assigns[:reply_to] %> | ||
<% end %> | ||
|
||
<div class="form-group dropzone"> | ||
|
||
<!-- most comment forms have two dropzones: 1) small button, 2) large form that covers textarea --> | ||
<!-- this is the large dropzone --> | ||
<!-- get_large_dropzone_id defined in application_helper.rb --> | ||
<% dropzone_large_id = get_large_dropzone_id(location,local_assigns[:reply_to]) %> | ||
<div id="dropzone-large<%= dropzone_large_id %>" class="form-group dropzone"> | ||
<% | ||
body = body || params[:body] | ||
# Look for comment templates | ||
|
@@ -45,24 +53,20 @@ | |
<% end %> | ||
<textarea aria-label="Comment Text" style="border: 1px solid #bbb;border-bottom-left-radius: 0;border-bottom-right-radius: 0;border-bottom: 0;padding: 10px;" onFocus="editing=true" name="body" class="form-control" id="text-input" rows="6" cols="40" placeholder="<%= placeholder %>"><%= body %></textarea> | ||
<div id="imagebar"> | ||
|
||
<div id="create_progress" style="display:none;" class="progress float-right"> | ||
<div id="create_progress-bar" class="progress-bar progress-bar-striped progress-bar-animated" style="width: 0%;"></div> | ||
</div> | ||
|
||
<p> | ||
<span id="create_uploading" class="uploading" style="display:none;"> | ||
<%= translation('comments._form.uploading') %> | ||
</span> | ||
<span id="create_prompt" class="prompt"> | ||
|
||
<span style="padding-right:4px;float:left;" class="d-none d-md-inline"> | ||
<%= raw translation('comments._form.drag_and_drop') %> | ||
</span> | ||
|
||
<!-- http://stackoverflow.com/questions/11235206/twitter-bootstrap-form-file-element-upload-button --> | ||
<label for="fileinput"> | ||
<input id="fileinput" type="file" name="image[photo]" style="display:none;" /> | ||
<label for="fileinput-choose-one<%= dropzone_large_id %>"> | ||
<input id="fileinput-choose-one<%= dropzone_large_id %>" type="file" name="image[photo]" style="display:none;" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this change styling at all? Noting that sometimes adding unique classnames instead of ids can be better since elements are allowed to have more than one class but only one ID. I tend to use classes instead of IDs for that reason, but it's just a convention or habit, so no big deal here, just curious! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, that's a really good point about styling. I did a simple search in VSCode for That's also a good point about classes vs. IDs. Since my ultimate goal is to be able to use I was aware of the one ID per page rule. |
||
<a onClick="handleClick()" style="cursor: pointer;" class="d-none d-md-inline text-underline">choose one</a> | ||
<span class="d-md-none"> | ||
<i class="fa fa-upload"></i> | ||
|
@@ -71,61 +75,60 @@ | |
</label> | ||
</span> | ||
</p> | ||
</div> | ||
</div> | ||
|
||
<div id="preview" style="background: white; display: none;"> | ||
</div> | ||
<script> | ||
jQuery(document).ready(function() { | ||
$E.initialize(); | ||
}); | ||
$D = { | ||
uid: <%= current_user.uid if current_user %>, | ||
type: 'comment' | ||
}; | ||
|
||
function handleClick() { | ||
$D.selected = $(event.target.closest('div.comment-form-wrapper')); | ||
console.log($D.selected); | ||
$E.refresh(); | ||
} | ||
|
||
</div> | ||
</div> | ||
|
||
<div id="preview" style="background: white; display: none;"> | ||
</div> | ||
<script> | ||
jQuery(document).ready(function() { | ||
$E.initialize(); | ||
}); | ||
$D = { | ||
uid: <%= current_user.uid if current_user %>, | ||
type: 'comment' | ||
}; | ||
|
||
function handleClick() { | ||
$D.selected = $(event.target.closest('div.comment-form-wrapper')); | ||
console.log($D.selected); | ||
$E.refresh(); | ||
} | ||
|
||
$('#input_label').click(function(e){ | ||
$E.initialize({}); | ||
}); | ||
</script> | ||
|
||
<%= javascript_include_tag "dragdrop" %> | ||
<script src="/emoji.js" type="text/javascript"></script> | ||
<script src="/assets/atwho_autocomplete.js" type="text/javascript"></script> | ||
<%= javascript_include_tag "comment.js" %> | ||
|
||
<div class="control-group"> | ||
<button type="submit" class="btn btn-primary"><%= translation('comments._form.publish') %></button> | ||
<% if local_assigns[:comment] %> | ||
<a class="btn btn-outline-secondary preview-btn" onClick="$('#c<%= comment.cid %>preview').toggle(); | ||
$('#c<%= comment.cid %>text-input').toggle(); | ||
$('#c<%= comment.cid %>edit .preview-btn').button('toggle'); | ||
$E.generate_preview('c<%= comment.cid %>preview',$('#c<%= comment.cid %>text-input').val())"> | ||
<%= translation('comments._form.preview') %> | ||
</a> | ||
<a class="btn btn-outline-secondary" onClick="$('#c<%= comment.cid %>show').toggle();$('#c<%= comment.cid %>edit').toggle()"><%= translation('comments._form.cancel') %></a> | ||
<% else %> | ||
<a class="btn btn-outline-secondary preview-btn>" id="post_comment" data-previewing-text="Hide Preview" onClick="handleClick();$E.toggle_preview()"><%= translation('comments._form.preview') %></a> | ||
<% end %> | ||
$('#input_label').click(function(e){ | ||
$E.initialize({}); | ||
}); | ||
</script> | ||
|
||
<%= javascript_include_tag "dragdrop" %> | ||
<script src="/emoji.js" type="text/javascript"></script> | ||
<script src="/assets/atwho_autocomplete.js" type="text/javascript"></script> | ||
<%= javascript_include_tag "comment.js" %> | ||
|
||
<div class="control-group"> | ||
<button type="submit" class="btn btn-primary"><%= translation('comments._form.publish') %></button> | ||
<% if local_assigns[:comment] %> | ||
<a class="btn btn-outline-secondary preview-btn" onClick="$('#c<%= comment.cid %>preview').toggle(); | ||
$('#c<%= comment.cid %>text-input').toggle(); | ||
$('#c<%= comment.cid %>edit .preview-btn').button('toggle'); | ||
$E.generate_preview('c<%= comment.cid %>preview',$('#c<%= comment.cid %>text-input').val())"> | ||
<%= translation('comments._form.preview') %> | ||
</a> | ||
<a class="btn btn-outline-secondary" onClick="$('#c<%= comment.cid %>show').toggle();$('#c<%= comment.cid %>edit').toggle()"><%= translation('comments._form.cancel') %></a> | ||
<% else %> | ||
<a class="btn btn-outline-secondary preview-btn>" id="post_comment" data-previewing-text="Hide Preview" onClick="handleClick();$E.toggle_preview()"><%= translation('comments._form.preview') %></a> | ||
<% end %> | ||
|
||
<span style="color:#888;"> | ||
<br class="d-md-none" /><%= raw translation('comments._form.logged_in', :username => current_user.username) %> | ||
<a aria-label="Authoring Help" target="_blank" href="/wiki/authoring-help#Formatting"><i class="fa fa-question-circle"></i></a> | ||
<a onClick="changeNotificationIcon('#who-is-notified-form', '#bell')"><i id="bell" class="fa fa-bell-o"></i></a> | ||
</span> | ||
</div> | ||
<span style="color:#888;"> | ||
<br class="d-md-none" /><%= raw translation('comments._form.logged_in', :username => current_user.username) %> | ||
<a aria-label="Authoring Help" target="_blank" href="/wiki/authoring-help#Formatting"><i class="fa fa-question-circle"></i></a> | ||
<a onClick="changeNotificationIcon('#who-is-notified-form', '#bell')"><i id="bell" class="fa fa-bell-o"></i></a> | ||
</span> | ||
</div> | ||
|
||
<p id="who-is-notified-form" style="display:none;color:#888;"> | ||
<%= translation('comments._form.email_notifications') %> | ||
</p> | ||
<p id="who-is-notified-form" style="display:none;color:#888;"> | ||
<%= translation('comments._form.email_notifications') %> | ||
</p> | ||
</form> | ||
</div> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,7 +166,16 @@ | |
<div id="comment-<%= comment.cid %>-reply-section"> | ||
<% if current_user %> | ||
<div class="inline" id="question-comment-form"> | ||
<%= render :partial => "comments/form", :locals => { title: "Reply to this comment", reply_to: comment.cid, comment: false, placeholder: "Help the author refine their post, or point them at other helpful information on the site. Mention users by @username to notify them of this thread by email", url1: '/conduct', author: current_user.title, is_new_contributor:current_user.is_new_contributor? } %> | ||
<%= render :partial => "comments/form", :locals => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so much more readable, thank you! |
||
title: "Reply to this comment", | ||
reply_to: comment.cid, | ||
comment: false, | ||
placeholder: "Help the author refine their post, or point them at other helpful information on the site. Mention users by @username to notify them of this thread by email", | ||
url1: '/conduct', | ||
author: current_user.title, | ||
is_new_contributor:current_user.is_new_contributor?, | ||
location: :reply # toolbar needs this to create dropzone ID | ||
} %> | ||
</div> | ||
<% else %> | ||
<p><%= link_to "Log in", "/login?return_to=#{request.path}" %> to comment</p> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent
when
as deep asend
.