Use ECMAScript 5 array and string methods

These methods were added in 2009 and are supported by 98.5% of the
browsers, including Internet Explorer 9, 10 and 11. We were already
using them in some places.
This commit is contained in:
Javi Martín
2019-06-30 04:37:52 +02:00
parent 49b4a0c71d
commit 3120e0aa41
6 changed files with 13 additions and 18 deletions

View File

@@ -17,7 +17,7 @@ App.ColumnsSelector =
initChecks: () ->
$(".column-selecteable th[data-field]").each ->
field = $(this).data("field")
text = $.trim($(this).text())
text = $(this).text().trim()
item = $("#column_selector_item_template").clone()
item.prop("id", "column_selector_item_" + field)
input = item.find("input")

View File

@@ -44,15 +44,12 @@
};
ProposalGraph.prototype.parseGoals = function(data) {
var i, l;
this.goals = [];
for (i = 0, l = data.length; i < l; i += 1) {
this.goals.push({
value: data[i].required_supports,
text: data[i].title
});
}
this.goals = data.map(function(item) {
return {
value: item.required_supports,
text: item.title
};
});
};
ProposalGraph.prototype.refreshData = function () {

View File

@@ -34,7 +34,7 @@ App.Documentable =
data.submit()
change: (e, data) ->
$.each data.files, (index, file) ->
data.files.forEach (file) ->
App.Documentable.setFilename(inputData, file.name)
fail: (e, data) ->

View File

@@ -97,7 +97,5 @@ App.Globalize =
App.Globalize.remove_language(locale)
$(".js-add-fields-container").on "cocoon:after-insert", ->
$.each(
App.Globalize.enabled_locales(),
(index, locale) -> App.Globalize.enable_locale(locale)
)
App.Globalize.enabled_locales().forEach (locale) ->
App.Globalize.enable_locale(locale)

View File

@@ -36,7 +36,7 @@ App.Imageable =
data.submit()
change: (e, data) ->
$.each data.files, (index, file) ->
data.files.forEach (file) ->
App.Imageable.setFilename(inputData, file.name)
fail: (e, data) ->

View File

@@ -11,8 +11,8 @@ App.Tags =
name = "\"#{$(this).text()}\""
current_tags = $tag_input.val().split(",").filter(Boolean)
if $.inArray(name, current_tags) >= 0
current_tags.splice($.inArray(name, current_tags), 1)
if current_tags.indexOf(name) >= 0
current_tags.splice(current_tags.indexOf(name), 1)
else
current_tags.push name