Remove unnecessary conditions
The code won't do anything if there are no elements, so there's no need to check that condition.
This commit is contained in:
@@ -9,8 +9,7 @@ App.Imageable =
|
||||
$("#new_image_link").removeClass("hide")
|
||||
|
||||
$("#nested-image").on "cocoon:before-insert", ->
|
||||
if $(".js-image-attachment").length > 0
|
||||
$(".js-image-attachment").closest(".image").remove()
|
||||
$(".js-image-attachment").closest(".image").remove()
|
||||
|
||||
$("#nested-image").on "cocoon:after-insert", (e, nested_image) ->
|
||||
$("#new_image_link").addClass("hide")
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
App.RegistrationForm =
|
||||
|
||||
initialize: ->
|
||||
|
||||
registrationForm = $("form#new_user[action=\"/users\"]")
|
||||
usernameInput = $("input#user_username")
|
||||
usernameInput = $("form#new_user[action=\"/users\"] input#user_username")
|
||||
|
||||
clearUsernameMessage = ->
|
||||
$("small").remove()
|
||||
@@ -18,8 +16,7 @@ App.RegistrationForm =
|
||||
showUsernameMessage(response)
|
||||
|
||||
|
||||
if registrationForm.length > 0
|
||||
usernameInput.on "focusout", ->
|
||||
clearUsernameMessage()
|
||||
username = usernameInput.val()
|
||||
validateUsername(username) if username != ""
|
||||
usernameInput.on "focusout", ->
|
||||
clearUsernameMessage()
|
||||
username = usernameInput.val()
|
||||
validateUsername(username) if username != ""
|
||||
|
||||
@@ -2,9 +2,6 @@ App.TreeNavigator =
|
||||
setNodes: (nodes) ->
|
||||
children = nodes.children("ul")
|
||||
|
||||
if(children.length == 0)
|
||||
return
|
||||
|
||||
children.each ->
|
||||
link = $(this).prev("a")
|
||||
$('<span class="open"></span>').insertBefore(link)
|
||||
@@ -30,7 +27,6 @@ App.TreeNavigator =
|
||||
elem.siblings("ul").show()
|
||||
|
||||
if anchor = $(location).attr("hash")
|
||||
if link = elem.find("a[href='#{anchor}']")
|
||||
link.parents("ul").each ->
|
||||
$(this).show()
|
||||
$(this).siblings("span").removeClass("closed").addClass("open")
|
||||
elem.find("a[href='#{anchor}']").parents("ul").each ->
|
||||
$(this).show()
|
||||
$(this).siblings("span").removeClass("closed").addClass("open")
|
||||
|
||||
@@ -3,8 +3,7 @@ App.WatchFormChanges =
|
||||
return $("form[data-watch-changes]")
|
||||
|
||||
msg: ->
|
||||
if($("[data-watch-form-message]").length)
|
||||
return $("[data-watch-form-message]").data("watch-form-message")
|
||||
return $("[data-watch-form-message]").data("watch-form-message")
|
||||
|
||||
hasChanged: ->
|
||||
App.WatchFormChanges.forms().is ->
|
||||
|
||||
Reference in New Issue
Block a user