diff options
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r-- | app/assets/javascripts/issues.js.coffee | 36 | ||||
-rw-r--r-- | app/assets/javascripts/labels_select.js.coffee | 9 | ||||
-rw-r--r-- | app/assets/javascripts/lib/animate.js.coffee | 32 |
3 files changed, 67 insertions, 10 deletions
diff --git a/app/assets/javascripts/issues.js.coffee b/app/assets/javascripts/issues.js.coffee index fc9f6301bcc..320b92d2a60 100644 --- a/app/assets/javascripts/issues.js.coffee +++ b/app/assets/javascripts/issues.js.coffee @@ -1,5 +1,6 @@ @Issues = init: -> + Issues.initTemplates() Issues.initSearch() Issues.initChecks() @@ -15,6 +16,15 @@ else $(this).html totalIssues - 1 + initTemplates: -> + 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> + </span> + <% }); %>' + ) + reload: -> Issues.initChecks() $('#filter_issue_search').val($('#issue_search').val()) @@ -50,7 +60,6 @@ , 500) filterResults: (form) => - formData = form.serialize() $('.issues-holder, .merge-requests-holder').css("opacity", '0.5') @@ -70,6 +79,31 @@ history.replaceState {page: issuesUrl}, document.title, issuesUrl Issues.reload() Issues.updateStateFilters() + $filteredLabels = $('.filtered-labels') + $filteredLabelsSpans = $filteredLabels.find('span') + gl.animate.animateEach( + $filteredLabelsSpans, + 'fadeOutDown', 20, { + cssStart: { + opacity: 1 + }, + cssEnd: { + opacity: 0 + } + }).then( -> + $filteredLabels.html(Issue.labelRow(data)) + $spans = $filteredLabels.find('span') + $spans.css('opacity',0) + return gl.animate.animateEach($spans, 'fadeInUp', 20, { + cssStart: { + opacity: 0 + }, + cssEnd: { + opacity: 1 + } + }) + ) + dataType: "json" checkChanged: -> diff --git a/app/assets/javascripts/labels_select.js.coffee b/app/assets/javascripts/labels_select.js.coffee index 9cebc26e668..97a813577ed 100644 --- a/app/assets/javascripts/labels_select.js.coffee +++ b/app/assets/javascripts/labels_select.js.coffee @@ -16,6 +16,7 @@ class @LabelsSelect abilityName = $dropdown.data('ability-name') $selectbox = $dropdown.closest('.selectbox') $block = $selectbox.closest('.block') + $form = $dropdown.closest('form') $sidebarCollapsedValue = $block.find('.sidebar-collapsed-icon span') $value = $block.find('.value') $loading = $block.find('.block-loading').fadeOut() @@ -171,7 +172,7 @@ class @LabelsSelect .find('a') .each((i) -> setTimeout(=> - glAnimate($(@), 'pulse') + gl.animate.animate($(@), 'pulse') ,200 * i ) ) @@ -201,9 +202,9 @@ class @LabelsSelect renderRow: (label) -> selectedClass = '' - if $selectbox.find("input[type='hidden']\ + if $form.find("input[type='hidden']\ [name='#{$dropdown.data('field-name')}']\ - [value='#{label.id}']").length + [value='#{this.id(label)}']").length selectedClass = 'is-active' color = if label.color? then "<span class='dropdown-label-box' style='background-color: #{label.color}'></span>" else "" @@ -248,8 +249,6 @@ class @LabelsSelect .find("input[type='hidden'][name='#{$dropdown.data('field-name')}']") Issues.filterResults( $dropdown.closest('form'), - selectedLabels, - $dropdown.data('singularFieldName'), $dropdown.data('fieldName') ) else if $dropdown.hasClass('js-filter-submit') diff --git a/app/assets/javascripts/lib/animate.js.coffee b/app/assets/javascripts/lib/animate.js.coffee index 8f892b5a2b9..64aef4c6d43 100644 --- a/app/assets/javascripts/lib/animate.js.coffee +++ b/app/assets/javascripts/lib/animate.js.coffee @@ -1,13 +1,37 @@ ((w) -> + if not w.gl? then w.gl = {} + if not gl.animate? then gl.animate = {} - w.glAnimate = ($el, animation, done) -> + gl.animate.animate = ($el, animation, options, done) -> + if options?.cssStart? + $el.css(options.cssStart) $el - .removeClass() + .removeClass(animation + ' animated') .addClass(animation + ' animated') .one 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', -> - $(this).removeClass() + $(this).removeClass(animation + ' animated') + if done? + done() + if options?.cssEnd? + $el.css(options.cssEnd) return return - return + gl.animate.animateEach = ($els, animation, time, options, done) -> + dfd = $.Deferred() + $els.each((i) -> + setTimeout(=> + $this = $(@) + gl.animate.animate($this, animation, options, => + if i is $els.length - 1 + dfd.resolve() + if done? + done() + ) + ,time * i + ) + return + ) + return dfd.promise() + return ) window
\ No newline at end of file |