Merge pull request #3652 from consul/remove_unused_javascript

Remove unused JavaScript code
This commit is contained in:
Javier Martín
2019-09-11 02:40:54 +02:00
committed by GitHub
28 changed files with 20 additions and 134 deletions

View File

@@ -9,4 +9,3 @@ App.AllowParticipation =
$(this).find(".js-participation-not-allowed").hide()
$(this).find(".js-participation-allowed").show()
}, ".js-participation"
false

View File

@@ -1,38 +0,0 @@
_t = (key) -> new Gettext().gettext(key)
App.Annotatable =
initialize: ->
current_user_id = $("html").data("current-user-id")
if current_user_id == ""
annotator.ui.editor.Editor.template = [
'<div class="annotator-outer annotator-editor annotator-hide">',
' <form class="annotator-widget">',
" #{_t("Unregistered")}",
' <div class="annotator-controls">',
" <a href='#cancel' class='annotator-cancel'>#{_t("Cancel")}</a>",
" </div>",
" </form>",
"</div>"
].join("\n")
$("[data-annotatable-type]").each ->
$this = $(this)
ann_type = $this.data("annotatable-type")
ann_id = $this.data("annotatable-id")
app = new annotator.App()
.include ->
beforeAnnotationCreated: (ann) ->
ann["#{ann_type}_id"] = ann_id
ann.permissions = ann.permissions || {}
ann.permissions.admin = []
.include(annotator.ui.main, { element: this })
.include(annotator.storage.http, { prefix: "", urls: { search: "/annotations/search" } })
app.start().then ->
app.ident.identity = current_user_id
options = {}
options["#{ann_type}_id"] = ann_id
app.annotations.load(options)

View File

@@ -42,12 +42,10 @@
//= require users
//= require votes
//= require allow_participation
//= require annotatable
//= require advanced_search
//= require registration_form
//= require suggest
//= require forms
//= require tracks
//= require valuation_budget_investment_form
//= require embed_video
//= require fixed_bar
@@ -102,12 +100,10 @@ var initialize_modules = function() {
App.CheckAllNone.initialize();
App.PreventDoubleSubmission.initialize();
App.IeAlert.initialize();
App.Annotatable.initialize();
App.AdvancedSearch.initialize();
App.RegistrationForm.initialize();
App.Suggest.initialize();
App.Forms.initialize();
App.Tracks.initialize();
App.ValuationBudgetInvestmentForm.initialize();
App.EmbedVideo.initialize();
App.FixedBar.initialize();
@@ -137,7 +133,6 @@ var initialize_modules = function() {
App.SendAdminNotificationAlert.initialize();
App.ModalDownload.initialize();
App.Settings.initialize();
App.Cookies.initialize();
if ( $('#js-columns-selector').length )
App.ColumnsSelector.initialize();
App.BudgetEditAssociations.initialize();

View File

@@ -3,10 +3,6 @@ App.Banners =
update_banner: (selector, text) ->
$(selector).html(text)
update_style: (selector, style) ->
$(selector).removeClass($(selector).attr("class"), true)
.addClass(style, true)
update_background_color: (selector, background_color) ->
$(selector).css("background-color", background_color)

View File

@@ -1,6 +1,6 @@
App.ColumnsSelector =
initColums: (name) ->
initColums: () ->
App.ColumnsSelector.hideAll()
c_value = App.ColumnsSelector.currentValue()
@@ -15,8 +15,6 @@ App.ColumnsSelector =
$("#column_selector_" + column).prop("checked", true)
initChecks: () ->
fields = $(".column-selecteable th[data-field]")
columns = []
$(".column-selecteable th[data-field]").each ->
field = $(this).data("field")
text = $.trim($(this).text())
@@ -70,7 +68,7 @@ App.ColumnsSelector =
initialize: ->
App.ColumnsSelector.initChecks()
columns = App.ColumnsSelector.initColums($("#js-columns-selector").data("cookie"))
App.ColumnsSelector.initColums()
$("#js-columns-selector").on
click: (event) ->

View File

@@ -10,7 +10,7 @@ App.Comments =
$("##{parent_id} .comment-children:first").prepend($(response_html))
this.update_comments_count()
update_comments_count: (parent_id) ->
update_comments_count: ->
$(".js-comments-count").each ->
new_val = $(this).text().trim().replace /\d+/, (match) -> parseInt(match, 10) + 1
$(this).text(new_val)

View File

@@ -1,8 +1,5 @@
App.Cookies =
removeCookie: (name) ->
document.cookie("name", null, { path: '/' })
saveCookie: (name, value, days) ->
expires = undefined
if days
@@ -24,6 +21,3 @@ App.Cookies =
c_end = document.cookie.length
return unescape(document.cookie.substring(c_start, c_end))
''
initialize: ->
''

View File

@@ -263,7 +263,7 @@
};
ProposalGraph.prototype.formatXColumnValues = function () {
var i, l, parts;
var i, l;
this.xColumnValues = this.xColumnValues.sort();

View File

@@ -6,7 +6,7 @@ App.Documentable =
$.each inputFiles, (index, input) ->
App.Documentable.initializeDirectUploadInput(input)
$("#nested-documents").on "cocoon:after-remove", (e, insertedItem) ->
$("#nested-documents").on "cocoon:after-remove", ->
App.Documentable.unlockUploads()
$("#nested-documents").on "cocoon:after-insert", (e, nested_document) ->

View File

@@ -58,4 +58,3 @@ App.Forms =
App.Forms.toggleLink()
App.Forms.synchronizeInputs()
App.Forms.hideOrShowFieldsAfterSelection()
false

View File

@@ -19,7 +19,7 @@ i18n = {
}
}
window.Gettext = (key) ->
window.Gettext = ->
gettext: (key) ->
locale_id = $("html").attr("lang")
locale = i18n[locale_id]

View File

@@ -5,10 +5,10 @@ App.Imageable =
$.each inputFiles, (index, input) ->
App.Imageable.initializeDirectUploadInput(input)
$("#nested-image").on "cocoon:after-remove", (e, item) ->
$("#nested-image").on "cocoon:after-remove", ->
$("#new_image_link").removeClass("hide")
$("#nested-image").on "cocoon:before-insert", (e, nested_image) ->
$("#nested-image").on "cocoon:before-insert", ->
if $(".js-image-attachment").length > 0
$(".js-image-attachment").closest(".image").remove()

View File

@@ -18,7 +18,7 @@ App.LegislationAllegations =
App.LegislationAllegations.toggle_comments()
$(".js-toggle-allegations").on
click: (e) ->
click: ->
# Toggle comments when the section title is visible
if !App.LegislationAnnotatable.isMobile()
if $(this).find(".draft-panel .panel-title:visible").length == 0

View File

@@ -1,5 +1,3 @@
_t = (key) -> new Gettext().gettext(key)
App.LegislationAnnotatable =
makeEditableAndHighlight: (colour) ->
@@ -83,7 +81,7 @@ App.LegislationAnnotatable =
return window.innerWidth <= 652
viewerExtension: (viewer) ->
viewer._onHighlightMouseover = (event) ->
viewer._onHighlightMouseover = ->
return
customShow: (position) ->
@@ -106,7 +104,7 @@ App.LegislationAnnotatable =
App.LegislationAnnotatable.highlight("#7fff9a")
$("#comments-box textarea").focus()
$("#new_legislation_annotation").on("ajax:complete", (e, data, status, xhr) ->
$("#new_legislation_annotation").on("ajax:complete", (e, data) ->
App.LegislationAnnotatable.app.destroy()
if data.status == 200
App.LegislationAnnotatable.remove_highlight()
@@ -127,7 +125,7 @@ App.LegislationAnnotatable =
editor.show = App.LegislationAnnotatable.customShow
scrollToAnchor: ->
annotationsLoaded: (annotations) ->
annotationsLoaded: ->
anchor = $(location).attr("hash")
if anchor && anchor.startsWith("#annotation")
ann_id = anchor.split("-")[-1..]
@@ -183,7 +181,6 @@ App.LegislationAnnotatable =
$(".legislation-annotatable").each ->
$this = $(this)
ann_type = "legislation_draft_version"
ann_id = $this.data("legislation-draft-version-id")
base_url = $this.data("legislation-annotatable-base-url")

View File

@@ -14,11 +14,11 @@ App.Managers =
$("#user_password").prop "type", type
initialize: ->
$(".generate-random-value").on "click", (event) ->
$(".generate-random-value").on "click", ->
password = App.Managers.generatePassword()
$("#user_password").val(password)
$(".show-password").on "click", (event) ->
$(".show-password").on "click", ->
if $("#user_password").is("input[type='password']")
App.Managers.togglePassword("text")
else

View File

@@ -19,14 +19,6 @@ App.Polls =
@token = App.Polls.generateToken()
App.Polls.replaceToken()
$(".js-question-answer").on
click: =>
token_message = $(".js-token-message")
if !token_message.is(":visible")
token_message.html("#{token_message.html()}<br><strong>#{@token}</strong>")
token_message.show()
false
$(".zoom-link").on "click", (event) ->
element = event.target
answer = $(element).closest("div.answer")

View File

@@ -34,5 +34,3 @@ App.PreventDoubleSubmission =
buttons = $(this).find(":button, :submit")
App.PreventDoubleSubmission.reset_buttons(buttons)
)
false

View File

@@ -1,7 +1,7 @@
App.Sortable =
initialize: ->
$(".sortable").sortable
update: (event, ui) ->
update: ->
new_order = $(this).sortable("toArray", { attribute: "data-answer-id" })
$.ajax
url: $(".sortable").data("js-url"),
@@ -9,7 +9,7 @@ App.Sortable =
type: "POST"
$(".sortable-priotirized-votation").sortable
update: (event, ui) ->
update: ->
new_order = $(this).sortable("toArray", { attribute: "data-answer-id" })
$.ajax
url: $(this).data("js-url"),

View File

@@ -4,7 +4,7 @@
buildGraph = (el) ->
url = $(el).data "graph"
conf = bindto: el, data: { x: "x", url: url, mimeType: "json" }, axis: { x: { type: "timeseries", tick: { format: "%Y-%m-%d" } } }
graph = c3.generate conf
c3.generate conf
App.Stats =
initialize: ->

View File

@@ -1,28 +0,0 @@
App.Tracks =
tracking_enabled: ->
_paq?
set_custom_var: (id, name, value, scope) ->
_paq.push(["setCustomVariable", id, name, value, scope])
_paq.push(["trackPageView"])
track_event: ($this) ->
category = $this.data("track-event-category")
action = $this.data("track-event-action")
_paq.push(["trackEvent", category, action])
initialize: ->
if App.Tracks.tracking_enabled()
$("[data-track-usertype]").each ->
$this = $(this)
usertype = $this.data("track-usertype")
App.Tracks.set_custom_var(1, "usertype", usertype, "visit")
$("[data-track-event-category]").each ->
$this = $(this)
App.Tracks.track_event($this)
$("[data-track-click]").on "click", ->
$this = $(this)
App.Tracks.track_event($this)

View File

@@ -20,7 +20,7 @@ App.TreeNavigator =
App.TreeNavigator.setNodes(ul.children())
$("[data-tree-navigator] span").on
click: (e) ->
click: ->
elem = $(this)
if(elem.hasClass("open"))
elem.removeClass("open").addClass("closed")

View File

@@ -2,4 +2,3 @@ App.Users =
initialize: ->
$(".initialjs-avatar").initial()
false

View File

@@ -29,4 +29,3 @@ App.ValuationBudgetInvestmentForm =
initialize: ->
App.ValuationBudgetInvestmentForm.showFeasibilityFields()
App.ValuationBudgetInvestmentForm.showFeasibilityFieldsOnChange()
false

View File

@@ -25,7 +25,6 @@ App.Votations =
$("#max_groups_answers").attr(disabled: true)
setTraduction: (response) ->
console.log response
$(".js-description_text").text(response["traduction"])
updateChecks: () ->
@@ -41,5 +40,3 @@ App.Votations =
url = "/admin/get_options_traductions.json"
params = { enum_type: $("#votation_type_enum_type").val() }
$.get(url, params, (response) -> App.Votations.setTraduction response, "json")
false

View File

@@ -15,4 +15,3 @@ App.Votes =
App.Votes.hoverize "div.supports"
App.Votes.hoverize "div.debate-questions"
App.Votes.hoverize "div.comment-footer"
false

View File

@@ -6,7 +6,7 @@ App.WatchFormChanges =
if($("[data-watch-form-message]").length)
return $("[data-watch-form-message]").data("watch-form-message")
checkChanges: (event) ->
checkChanges: ->
changes = false
App.WatchFormChanges.forms().each ->
form = $(this)
@@ -21,10 +21,8 @@ App.WatchFormChanges =
if App.WatchFormChanges.forms().length == 0 || App.WatchFormChanges.msg() == undefined
return
$(document).off("page:before-change").on("page:before-change", (e) -> App.WatchFormChanges.checkChanges(e))
$(document).off("page:before-change").on("page:before-change", -> App.WatchFormChanges.checkChanges())
App.WatchFormChanges.forms().each ->
form = $(this)
form.data("watchChanges", form.serialize())
false

View File

@@ -346,12 +346,6 @@
}
.callout {
&.token-message {
background-color: #fff;
border-color: $info-border;
color: $color-info;
}
&.proposal-retired {
font-size: $base-font-size;
}

View File

@@ -177,8 +177,6 @@ describe "Voter" do
visit poll_path(poll)
expect(page).not_to have_selector(".js-token-message")
expect(page).to have_content "You have already participated in this poll. If you vote again it will be overwritten."
within("#poll_question_#{question.id}_answers") do
expect(page).not_to have_link(answer_yes.title)