Use string interpolation in CoffeeScript
We use it in Ruby, and it will make it easier to change all quotes to double quotes in CoffeeScript files.
This commit is contained in:
@@ -7,9 +7,9 @@ App.Annotatable =
|
||||
annotator.ui.editor.Editor.template = [
|
||||
'<div class="annotator-outer annotator-editor annotator-hide">',
|
||||
' <form class="annotator-widget">',
|
||||
' ' + _t('Unregistered'),
|
||||
" #{_t('Unregistered')}",
|
||||
' <div class="annotator-controls">',
|
||||
' <a href="#cancel" class="annotator-cancel">' + _t('Cancel') + '</a>',
|
||||
" <a href='#cancel' class='annotator-cancel'>#{_t('Cancel')}</a>",
|
||||
' </div>',
|
||||
' </form>',
|
||||
'</div>'
|
||||
@@ -23,7 +23,7 @@ App.Annotatable =
|
||||
app = new annotator.App()
|
||||
.include ->
|
||||
beforeAnnotationCreated: (ann) ->
|
||||
ann[ann_type + "_id"] = ann_id
|
||||
ann["#{ann_type}_id"] = ann_id
|
||||
ann.permissions = ann.permissions || {}
|
||||
ann.permissions.admin = []
|
||||
.include(annotator.ui.main, { element: this })
|
||||
@@ -34,5 +34,5 @@ App.Annotatable =
|
||||
app.ident.identity = current_user_id
|
||||
|
||||
options = {}
|
||||
options[ann_type + "_id"] = ann_id
|
||||
options["#{ann_type}_id"] = ann_id
|
||||
app.annotations.load(options)
|
||||
|
||||
@@ -3,8 +3,8 @@ App.CheckAllNone =
|
||||
initialize: ->
|
||||
$('[data-check-all]').on 'click', ->
|
||||
target_name = $(this).data('check-all')
|
||||
$("[name='" + target_name + "']").prop('checked', true)
|
||||
$("[name='#{target_name}']").prop('checked', true)
|
||||
|
||||
$('[data-check-none]').on 'click', ->
|
||||
target_name = $(this).data('check-none')
|
||||
$("[name='" + target_name + "']").prop('checked', false)
|
||||
$("[name='#{target_name}']").prop('checked', false)
|
||||
|
||||
@@ -69,7 +69,7 @@ App.Documentable =
|
||||
|
||||
progress: (e, data) ->
|
||||
progress = parseInt(data.loaded / data.total * 100, 10)
|
||||
$(data.progressBar).find('.loading-bar').css 'width', progress + '%'
|
||||
$(data.progressBar).find('.loading-bar').css 'width', "#{progress}%"
|
||||
return
|
||||
|
||||
buildFileUploadData: (e, data) ->
|
||||
@@ -112,7 +112,7 @@ App.Documentable =
|
||||
$(data.titleField).val(title)
|
||||
|
||||
setInputErrors: (data) ->
|
||||
errors = '<small class="error">' + data.jqXHR.responseJSON.errors + '</small>'
|
||||
errors = "<small class='error'>#{data.jqXHR.responseJSON.errors}</small>"
|
||||
$(data.errorContainer).append(errors)
|
||||
|
||||
lockUploads: ->
|
||||
@@ -157,4 +157,4 @@ App.Documentable =
|
||||
App.Documentable.doDeleteCachedAttachmentRequest(this.href, data)
|
||||
|
||||
removeDocument: (id) ->
|
||||
$('#' + id).remove()
|
||||
$("##{id}").remove()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
App.Flaggable =
|
||||
|
||||
update: (resource_id, button) ->
|
||||
$("#" + resource_id + " .js-flag-actions").html(button).foundation()
|
||||
$("##{resource_id} .js-flag-actions").html(button).foundation()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
App.Followable =
|
||||
|
||||
update: (followable_id, button, notice) ->
|
||||
$("#" + followable_id + " .js-follow").html(button)
|
||||
$("##{followable_id} .js-follow").html(button)
|
||||
if ($('[data-alert]').length > 0)
|
||||
$('[data-alert]').replaceWith(notice)
|
||||
else
|
||||
|
||||
@@ -16,18 +16,18 @@ App.Globalize =
|
||||
else
|
||||
$(this).hide()
|
||||
$('.js-delete-language').hide()
|
||||
$('#js_delete_' + locale).show()
|
||||
$("#js_delete_#{locale}").show()
|
||||
|
||||
highlight_locale: (element) ->
|
||||
$('.js-globalize-locale-link').removeClass('is-active')
|
||||
element.addClass('is-active')
|
||||
|
||||
remove_language: (locale) ->
|
||||
$(".js-globalize-attribute[data-locale=" + locale + "]").each ->
|
||||
$(".js-globalize-attribute[data-locale=#{locale}]").each ->
|
||||
$(this).val('').hide()
|
||||
if CKEDITOR.instances[$(this).attr('id')]
|
||||
CKEDITOR.instances[$(this).attr('id')].setData('')
|
||||
$(".js-globalize-locale-link[data-locale=" + locale + "]").hide()
|
||||
$(".js-globalize-locale-link[data-locale=#{locale}]").hide()
|
||||
next = $(".js-globalize-locale-link:visible").first()
|
||||
App.Globalize.highlight_locale(next)
|
||||
App.Globalize.display_translations(next.data("locale"))
|
||||
@@ -48,10 +48,10 @@ App.Globalize =
|
||||
)
|
||||
|
||||
destroy_locale_field: (locale) ->
|
||||
$("input[id$=_destroy][data-locale=" + locale + "]")
|
||||
$("input[id$=_destroy][data-locale=#{locale}]")
|
||||
|
||||
site_customization_enable_locale_field: (locale) ->
|
||||
$("#enabled_translations_" + locale)
|
||||
$("#enabled_translations_#{locale}")
|
||||
|
||||
refresh_visible_translations: ->
|
||||
locale = $('.js-globalize-locale-link.is-active').data("locale")
|
||||
|
||||
@@ -70,7 +70,7 @@ App.Imageable =
|
||||
|
||||
progress: (e, data) ->
|
||||
progress = parseInt(data.loaded / data.total * 100, 10)
|
||||
$(data.progressBar).find('.loading-bar').css 'width', progress + '%'
|
||||
$(data.progressBar).find('.loading-bar').css 'width', "#{progress}%"
|
||||
return
|
||||
|
||||
buildFileUploadData: (e, data) ->
|
||||
@@ -117,11 +117,11 @@ App.Imageable =
|
||||
$(data.titleField).val(title)
|
||||
|
||||
setInputErrors: (data) ->
|
||||
errors = '<small class="error">' + data.jqXHR.responseJSON.errors + '</small>'
|
||||
errors = "<small class='error'>#{data.jqXHR.responseJSON.errors}</small>"
|
||||
$(data.errorContainer).append(errors)
|
||||
|
||||
setPreview: (data) ->
|
||||
image_preview = '<div class="small-12 column text-center image-preview"><figure><img src="' + data.result.attachment_url + '" class="cached-image"/></figure></div>'
|
||||
image_preview = "<div class='small-12 column text-center image-preview'><figure><img src='#{data.result.attachment_url}' class='cached-image'></figure></div>"
|
||||
if $(data.preview).length > 0
|
||||
$(data.preview).replaceWith(image_preview)
|
||||
else
|
||||
@@ -162,5 +162,5 @@ App.Imageable =
|
||||
App.Imageable.doDeleteCachedAttachmentRequest(this.href, data)
|
||||
|
||||
removeImage: (id) ->
|
||||
$('#' + id).remove()
|
||||
$("##{id}").remove()
|
||||
$("#new_image_link").removeClass('hide')
|
||||
|
||||
@@ -2,6 +2,6 @@ App.InvestmentReportAlert =
|
||||
initialize: ->
|
||||
$('#js-investment-report-alert').on 'click', ->
|
||||
if this.checked && $('#budget_investment_feasibility_unfeasible').is(':checked')
|
||||
confirm(this.dataset.alert + "\n" + this.dataset.notFeasibleAlert)
|
||||
confirm("#{this.dataset.alert}\n#{this.dataset.notFeasibleAlert}")
|
||||
else if this.checked
|
||||
confirm(this.dataset.alert)
|
||||
|
||||
@@ -6,7 +6,7 @@ App.LegislationAdmin =
|
||||
checkbox = $(this)
|
||||
parent = $(this).parents('.row:eq(0)')
|
||||
date_selector = $(this).data('disable-date')
|
||||
parent.find("input[type='text'][id^='" + date_selector + "']").each ->
|
||||
parent.find("input[type='text'][id^='#{date_selector}']").each ->
|
||||
if checkbox.is(':checked')
|
||||
$(this).removeAttr("disabled")
|
||||
else
|
||||
|
||||
@@ -45,7 +45,7 @@ App.LegislationAnnotatable =
|
||||
|
||||
$.ajax
|
||||
method: "GET"
|
||||
url: event.annotation_url + "/annotations/" + event.annotation_id + "/comments"
|
||||
url: "#{event.annotation_url}/annotations/#{event.annotation_id}/comments"
|
||||
dataType: 'script'
|
||||
|
||||
onClick: (event) ->
|
||||
@@ -54,7 +54,7 @@ App.LegislationAnnotatable =
|
||||
|
||||
if App.LegislationAnnotatable.isMobile()
|
||||
annotation_url = $(event.target).closest(".legislation-annotatable").data("legislation-annotatable-base-url")
|
||||
window.location.href = annotation_url + "/annotations/" + $(this).data('annotation-id')
|
||||
window.location.href = "#{annotation_url}/annotations/#{$(this).data('annotation-id')}"
|
||||
return
|
||||
|
||||
$('[data-annotation-id]').removeClass('current-annotation')
|
||||
@@ -66,7 +66,7 @@ App.LegislationAnnotatable =
|
||||
$(elem).data("annotation-id")
|
||||
|
||||
annotation_id = target.data('annotation-id')
|
||||
$('[data-annotation-id="' + annotation_id + '"]').addClass('current-annotation')
|
||||
$("[data-annotation-id='#{annotation_id}']").addClass('current-annotation')
|
||||
|
||||
$('#comments-box').html('')
|
||||
App.LegislationAllegations.show_comments()
|
||||
@@ -101,7 +101,7 @@ App.LegislationAnnotatable =
|
||||
annotation_url = $('[data-legislation-annotatable-base-url]').data('legislation-annotatable-base-url')
|
||||
$.ajax(
|
||||
method: 'GET'
|
||||
url: annotation_url + '/annotations/new'
|
||||
url: "#{annotation_url}/annotations/new"
|
||||
dataType: 'script').done (->
|
||||
$('#new_legislation_annotation #legislation_annotation_quote').val(@annotation.quote)
|
||||
$('#new_legislation_annotation #legislation_annotation_ranges').val(JSON.stringify(@annotation.ranges))
|
||||
@@ -118,11 +118,11 @@ App.LegislationAnnotatable =
|
||||
$("#comments-box").html("").hide()
|
||||
$.ajax
|
||||
method: "GET"
|
||||
url: annotation_url + "/annotations/" + data.responseJSON.id + "/comments"
|
||||
url: "#{annotation_url}/annotations/#{data.responseJSON.id}/comments"
|
||||
dataType: 'script'
|
||||
else
|
||||
$(e.target).find('label').addClass('error')
|
||||
$('<small class="error">' + data.responseJSON[0] + '</small>').insertAfter($(e.target).find('textarea'))
|
||||
$("<small class='error'>#{data.responseJSON[0]}</small>").insertAfter($(e.target).find('textarea'))
|
||||
return true
|
||||
)
|
||||
return
|
||||
@@ -138,8 +138,8 @@ App.LegislationAnnotatable =
|
||||
ann_id = anchor.split("-")[-1..]
|
||||
|
||||
checkExist = setInterval((->
|
||||
if $("span[data-annotation-id='" + ann_id + "']").length
|
||||
el = $("span[data-annotation-id='" + ann_id + "']")
|
||||
if $("span[data-annotation-id='#{ann_id}']").length
|
||||
el = $("span[data-annotation-id='#{ann_id}']")
|
||||
el.addClass('current-annotation')
|
||||
$('#comments-box').html('')
|
||||
App.LegislationAllegations.show_comments()
|
||||
@@ -164,11 +164,11 @@ App.LegislationAnnotatable =
|
||||
last_annotation = annotations[annotations.length - 1]
|
||||
|
||||
checkExist = setInterval((->
|
||||
if $("span[data-annotation-id='" + last_annotation.id + "']").length
|
||||
if $("span[data-annotation-id='#{last_annotation.id}']").length
|
||||
for annotation in annotations
|
||||
ann_weight = App.LegislationAnnotatable.propotionalWeight(annotation.weight, max_weight)
|
||||
el = $("span[data-annotation-id='" + annotation.id + "']")
|
||||
el.addClass('weight-' + ann_weight)
|
||||
el = $("span[data-annotation-id='#{annotation.id}']")
|
||||
el.addClass("weight-#{ann_weight}")
|
||||
clearInterval checkExist
|
||||
return
|
||||
), 100)
|
||||
|
||||
@@ -75,7 +75,7 @@ App.Map =
|
||||
openMarkerPopup = (e) ->
|
||||
marker = e.target
|
||||
|
||||
$.ajax '/investments/' + marker.options['id'] + '/json_data',
|
||||
$.ajax "/investments/#{marker.options['id']}/json_data",
|
||||
type: 'GET'
|
||||
dataType: 'json'
|
||||
success: (data) ->
|
||||
|
||||
@@ -23,7 +23,7 @@ App.Polls =
|
||||
click: =>
|
||||
token_message = $(".js-token-message")
|
||||
if !token_message.is(':visible')
|
||||
token_message.html(token_message.html() + "<br><strong>" + @token + "</strong>")
|
||||
token_message.html("#{token_message.html()}<br><strong>#{@token}</strong>")
|
||||
token_message.show()
|
||||
false
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ App.Tags =
|
||||
|
||||
unless $this.data('initialized') is 'yes'
|
||||
$this.on('click', ->
|
||||
name = '"' + $(this).text() + '"'
|
||||
name = "\"#{$(this).text()}\""
|
||||
current_tags = $tag_input.val().split(',').filter(Boolean)
|
||||
|
||||
if $.inArray(name, current_tags) >= 0
|
||||
|
||||
@@ -30,7 +30,7 @@ App.TreeNavigator =
|
||||
elem.siblings('ul').show()
|
||||
|
||||
if anchor = $(location).attr('hash')
|
||||
if link = elem.find('a[href="' + anchor + '"]')
|
||||
if link = elem.find("a[href='#{anchor}']")
|
||||
link.parents('ul').each ->
|
||||
$(this).show()
|
||||
$(this).siblings('span').removeClass('closed').addClass('open')
|
||||
|
||||
Reference in New Issue
Block a user