Commit 2af94793 authored by Arinde Eniola's avatar Arinde Eniola

increase the speed of the labels animation ans aslo refactor some part fo issue.js

parent 259970ca
......@@ -3,6 +3,7 @@
Issues.initTemplates()
Issues.initSearch()
Issues.initChecks()
Issues.toggleLabelFilters()
$("body").on "ajax:success", ".close_issue, .reopen_issue", ->
t = $(this)
......@@ -20,11 +21,20 @@
Issue.labelRow = _.template(
'<% _.each(labels, function(label){ %>
<span class="label-row">
<a href="#"><span class="label color-label" style="background-color: <%= label.color %>; color: #FFFFFF" title="<%= label.description %>" data-container="body"><%= label.title %></span></a>
<a href="#"><span class="label color-label has-tooltip" style="background-color: <%= label.color %>; color: #FFFFFF" title="<%= label.description %>" data-container="body"><%= label.title %></span></a>
</span>
<% }); %>'
)
toggleLabelFilters: ()->
$filteredLabels = $('.filtered-labels')
if $filteredLabels.find('.label-row').length > 0
#$filteredLabels.show()
$filteredLabels.slideDown().css({'overflow':'visible'})
else
#$filteredLabels.hide()
$filteredLabels.slideUp().css({'overflow':'visible'})
reload: ->
Issues.initChecks()
$('#filter_issue_search').val($('#issue_search').val())
......@@ -43,13 +53,15 @@
paramKeys = ['author_id', 'milestone_title', 'assignee_id', 'issue_search']
for paramKey in paramKeys
newParams[paramKey] = gl.utils.getUrlParameter(paramKey) or ''
newParams[paramKey] = gl.utils.getParameterValues(paramKey)[0] or ''
if stateFilters.length
stateFilters.find('a').each ->
initialUrl = gl.utils.removeParamQueryString($(this).attr('href'), 'label_name[]')
if gl.utils.getParamQueryString('label_name[]')
newUrl = "#{gl.utils.mergeUrlParams(newParams, initialUrl)}&#{gl.utils.getParamQueryString('label_name[]')}"
labelNameValues = gl.utils.getParameterValues('label_name[]')
if labelNameValues
labelNameQueryString = ("label_name[]=#{value}" for value in labelNameValues).join('&')
newUrl = "#{gl.utils.mergeUrlParams(newParams, initialUrl)}&#{labelNameQueryString}"
else
newUrl = gl.utils.mergeUrlParams(newParams, initialUrl)
$(this).attr 'href', newUrl
......@@ -84,29 +96,24 @@
Issues.reload()
Issues.updateStateFilters()
$filteredLabels = $('.filtered-labels')
$filteredLabelsSpans = $filteredLabels.find('span')
$filteredLabelsSpans = $filteredLabels.find('.label-row')
gl.animate.animateEach(
$filteredLabelsSpans,
'fadeOutDown', 20, {
cssStart: {
$filteredLabelsSpans, 'fadeOutDown', 5,
cssStart:
opacity: 1
},
cssEnd: {
cssEnd:
opacity: 0
}
}).then( ->
).then( ->
if typeof Issue.labelRow is 'function'
$filteredLabels.html(Issue.labelRow(data))
$spans = $filteredLabels.find('span')
$spans.css('opacity',0)
return gl.animate.animateEach($spans, 'fadeInUp', 20, {
cssStart: {
Issues.toggleLabelFilters()
$spans = $filteredLabels.find('.label-row')
$spans.css('opacity', 0)
return gl.animate.animateEach $spans, 'fadeInUp', 5,
cssStart:
opacity: 0
},
cssEnd: {
cssEnd:
opacity: 1
}
})
)
dataType: "json"
......
......@@ -224,7 +224,7 @@ class @LabelsSelect
selected_labels = $('.js-label-select').siblings('.dropdown-menu-labels').find('.is-active')
if selected and selected.title?
if selected_labels and selected_labels.length > 1
if selected_labels.length > 1
"#{selected.title} +#{selected_labels.length - 1} more"
else
selected.title
......@@ -247,7 +247,7 @@ class @LabelsSelect
hidden: ->
page = $('body').data 'page'
isIssueIndex = page is 'projects:issues:index'
isMRIndex = page is page is 'projects:merge_requests:index'
isMRIndex = page is 'projects:merge_requests:index'
$selectbox.hide()
# display:block overrides the hide-collapse rule
......@@ -256,11 +256,8 @@ class @LabelsSelect
if $dropdown.hasClass('js-filter-submit') and (isIssueIndex or isMRIndex)
selectedLabels = $dropdown
.closest('form')
.find("input[type='hidden'][name='#{$dropdown.data('fieldName')}']")
Issues.filterResults(
$dropdown.closest('form'),
$dropdown.data('fieldName')
)
.find("input:hidden[name='#{$dropdown.data('fieldName')}']")
Issues.filterResults $dropdown.closest('form')
else if $dropdown.hasClass('js-filter-submit')
$dropdown.closest('form').submit()
else
......@@ -270,7 +267,7 @@ class @LabelsSelect
clicked: (label) ->
page = $('body').data 'page'
isIssueIndex = page is 'projects:issues:index'
isMRIndex = page is page is 'projects:merge_requests:index'
isMRIndex = page is 'projects:merge_requests:index'
if $dropdown.hasClass('js-filter-submit') and (isIssueIndex or isMRIndex)
if not $dropdown.hasClass 'js-multiselect'
selectedLabel = label.title
......
......@@ -3,16 +3,20 @@
w.gl ?= {}
w.gl.utils ?= {}
w.gl.utils.getUrlParameter = (sParam) ->
# Returns an array containing the value(s) of the
# of the key passed as an argument
w.gl.utils.getParameterValues = (sParam) ->
sPageURL = decodeURIComponent(window.location.search.substring(1))
sURLVariables = sPageURL.split('&')
sParameterName = undefined
values = []
i = 0
while i < sURLVariables.length
sParameterName = sURLVariables[i].split('=')
if sParameterName[0] is sParam
return if sParameterName[1] is undefined then true else sParameterName[1]
values.push(sParameterName[1])
i++
values
# #
# @param {Object} params - url keys and value to merge
......@@ -28,14 +32,6 @@
newUrl = "#{newUrl}#{(if newUrl.indexOf('?') > 0 then '&' else '?')}#{paramName}=#{paramValue}"
newUrl
# get parameter query string from url.
w.gl.utils.getParamQueryString = (param) ->
pageURL = decodeURIComponent(window.location.search.substring(1))
urlVariables = pageURL.split('&')
(
variables for variables in urlVariables when variables.indexOf(param) > -1
).join('&')
# removes parameter query string from url. returns the modified url
w.gl.utils.removeParamQueryString = (url, param) ->
url = decodeURIComponent(url)
......
......@@ -3,6 +3,7 @@
#
@MergeRequests =
init: ->
$('.filtered-labels').hide()
MergeRequests.initSearch()
# Make sure we trigger ajax request only after user stop typing
......
......@@ -18,22 +18,20 @@ module IssuablesHelper
def multi_label_name(current_labels, default_label)
# current_labels may be a string from before
if current_labels.respond_to?('any?')
if current_labels.any?
if current_labels.is_a?(Array)
if current_labels.count > 1
"#{current_labels[0]} +#{current_labels.count - 1} more"
else
current_labels[0]
end
else
default_label
end
else
elsif current_labels.is_a?(String)
if current_labels.nil? || current_labels.empty?
default_label
else
current_labels
end
else
default_label
end
end
......
- labels.each do |l|
- labels.each do |label|
%span.label-row
= link_to_label(l, tooltip: false)
\ No newline at end of file
= link_to_label(label, tooltip: false)
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment