mirror of
https://github.com/github/choosealicense.com
synced 2025-01-21 10:57:47 +01:00
#1140, update hint.css for repository url input field errors
This commit is contained in:
parent
176a622db0
commit
5fcdf233f5
@ -76,23 +76,10 @@ class Choosealicense
|
|||||||
|
|
||||||
class LicenseSuggestion
|
class LicenseSuggestion
|
||||||
constructor: (@inputEl, @licenseId, @statusIndicator) ->
|
constructor: (@inputEl, @licenseId, @statusIndicator) ->
|
||||||
@setupTooltips()
|
|
||||||
@bindEventHandlers()
|
@bindEventHandlers()
|
||||||
|
|
||||||
# Initializes tooltips on the input element
|
inputWraper: $('.input-wrapper')
|
||||||
setupTooltips: =>
|
tooltipErrorClasses: 'hint--bottom hint--error hint--always'
|
||||||
@inputEl.qtip
|
|
||||||
content:
|
|
||||||
text: false
|
|
||||||
title:
|
|
||||||
text: "message"
|
|
||||||
show: false
|
|
||||||
hide: false
|
|
||||||
position:
|
|
||||||
my: "top center"
|
|
||||||
at: "bottom center"
|
|
||||||
style:
|
|
||||||
classes: "qtip-shadow"
|
|
||||||
|
|
||||||
# Main event handlers for user input
|
# Main event handlers for user input
|
||||||
bindEventHandlers: =>
|
bindEventHandlers: =>
|
||||||
@ -136,22 +123,19 @@ class LicenseSuggestion
|
|||||||
# Displays an indicator and tooltips to the user about the current status
|
# Displays an indicator and tooltips to the user about the current status
|
||||||
setStatus: (status="", message="") =>
|
setStatus: (status="", message="") =>
|
||||||
statusClass = status.toLowerCase()
|
statusClass = status.toLowerCase()
|
||||||
displayQtip = (status, message) =>
|
displayTooltip = (status, message) =>
|
||||||
@inputEl.qtip("api")
|
@inputWraper.attr('aria-label', "#{status}: #{message}")
|
||||||
.set("content.text", message)
|
@inputWraper.addClass(@tooltipErrorClasses)
|
||||||
.set("content.title", status)
|
|
||||||
.set("style.classes", "qtip-shadow qtip-#{statusClass}")
|
|
||||||
.show()
|
|
||||||
|
|
||||||
switch status
|
switch status
|
||||||
when "Fetching"
|
when "Fetching"
|
||||||
@statusIndicator.removeClass('error').addClass(statusClass)
|
@statusIndicator.removeClass("error #{@tooltipErrorClasses}").addClass(statusClass)
|
||||||
when "Error"
|
when "Error"
|
||||||
@statusIndicator.removeClass('fetching').addClass(statusClass)
|
@statusIndicator.removeClass('fetching').addClass(statusClass)
|
||||||
displayQtip status, message
|
displayTooltip status, message
|
||||||
else
|
else
|
||||||
@inputEl.qtip("api").hide()
|
|
||||||
@statusIndicator.removeClass('fetching error')
|
@statusIndicator.removeClass('fetching error')
|
||||||
|
@inputWraper.removeClass(@tooltipErrorClasses)
|
||||||
|
|
||||||
# Fetches information about a repository from the Github API
|
# Fetches information about a repository from the Github API
|
||||||
fetchInfoFromGithubAPI: (repositoryFullName, callback) ->
|
fetchInfoFromGithubAPI: (repositoryFullName, callback) ->
|
||||||
@ -167,10 +151,9 @@ class LicenseSuggestion
|
|||||||
repositoryLicense: (repositoryFullName, license) ->
|
repositoryLicense: (repositoryFullName, license) ->
|
||||||
foundLicense = window.licenses.find (lic) -> lic.spdx_id == license.spdx_id
|
foundLicense = window.licenses.find (lic) -> lic.spdx_id == license.spdx_id
|
||||||
if foundLicense # Links the license to its page on this site
|
if foundLicense # Links the license to its page on this site
|
||||||
"The repository <b> #{repositoryFullName}</b> is already licensed under the
|
"The repository #{repositoryFullName} is already licensed under the #{foundLicense.title}."
|
||||||
<a href='/licenses/#{foundLicense.spdx_id.toLowerCase()}'><b>#{foundLicense.title}</b></a>."
|
|
||||||
else
|
else
|
||||||
"The repository <b> #{repositoryFullName}</b> is already licensed."
|
"The repository #{repositoryFullName} is already licensed."
|
||||||
|
|
||||||
$ ->
|
$ ->
|
||||||
new Choosealicense()
|
new Choosealicense()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user