summaryrefslogtreecommitdiff
path: root/app/assets/javascripts
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/application.js.coffee3
-rw-r--r--app/assets/javascripts/dispatcher.js.coffee2
-rw-r--r--app/assets/javascripts/flash.js.coffee12
-rw-r--r--app/assets/javascripts/gl_dropdown.js.coffee9
-rw-r--r--app/assets/javascripts/issuable.js.coffee3
-rw-r--r--app/assets/javascripts/lib/utils/text_utility.js.coffee45
-rw-r--r--app/assets/javascripts/search_autocomplete.js.coffee11
-rw-r--r--app/assets/javascripts/shortcuts.js.coffee6
-rw-r--r--app/assets/javascripts/tree.js.coffee12
9 files changed, 71 insertions, 32 deletions
diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee
index 5c5a4ca7670..b6dbf2d0cc1 100644
--- a/app/assets/javascripts/application.js.coffee
+++ b/app/assets/javascripts/application.js.coffee
@@ -199,7 +199,6 @@ $ ->
$('.header-content .header-logo').toggle()
$('.header-content .navbar-collapse').toggle()
$('.navbar-toggle').toggleClass('active')
- $('.navbar-toggle i').toggleClass("fa-angle-right fa-angle-left")
# Show/hide comments on diff
$body.on "click", ".js-toggle-diff-comments", (e) ->
@@ -261,7 +260,7 @@ $ ->
new Aside()
# Sidenav pinning
- if $window.width() < 1440 and $.cookie('pin_nav') is 'true'
+ if $window.width() < 1280 and $.cookie('pin_nav') is 'true'
$.cookie('pin_nav', 'false', { path: '/' })
$('.page-with-sidebar')
.toggleClass('page-sidebar-collapsed page-sidebar-expanded')
diff --git a/app/assets/javascripts/dispatcher.js.coffee b/app/assets/javascripts/dispatcher.js.coffee
index 7fbff9214cf..9493a575801 100644
--- a/app/assets/javascripts/dispatcher.js.coffee
+++ b/app/assets/javascripts/dispatcher.js.coffee
@@ -84,6 +84,8 @@ class Dispatcher
new Activities()
when 'groups:show'
shortcut_handler = new ShortcutsNavigation()
+ new NotificationsForm()
+ new NotificationsDropdown()
when 'groups:group_members:index'
new GroupMembers()
new UsersSelect()
diff --git a/app/assets/javascripts/flash.js.coffee b/app/assets/javascripts/flash.js.coffee
index 4f73d215b85..b76d214790a 100644
--- a/app/assets/javascripts/flash.js.coffee
+++ b/app/assets/javascripts/flash.js.coffee
@@ -4,11 +4,19 @@ class @Flash
@flash.html("")
innerDiv = $('<div/>',
- class: "flash-#{type}",
- text: message
+ class: "flash-#{type}"
)
innerDiv.appendTo(".flash-container")
+ textDiv = $("<div/>",
+ class: "flash-text",
+ text: message
+ )
+ textDiv.appendTo(innerDiv)
+
+ if @flash.parent().hasClass('content-wrapper')
+ textDiv.addClass('container-fluid container-limited')
+
@flash.click -> $(@).fadeOut()
@flash.show()
diff --git a/app/assets/javascripts/gl_dropdown.js.coffee b/app/assets/javascripts/gl_dropdown.js.coffee
index 703128fecb3..ed9dfcc917e 100644
--- a/app/assets/javascripts/gl_dropdown.js.coffee
+++ b/app/assets/javascripts/gl_dropdown.js.coffee
@@ -186,6 +186,8 @@ class GitLabDropdown
@fullData = data
@parseData @fullData
+
+ @filter.input.trigger('keyup') if @options.filterable and @filter and @filter.input
}
# Init filterable
@@ -218,6 +220,13 @@ class GitLabDropdown
@dropdown.on 'keyup', (e) =>
if e.which is 27 # Escape key
$('.dropdown-menu-close', @dropdown).trigger 'click'
+ @dropdown.on 'blur', 'a', (e) =>
+ if e.relatedTarget?
+ $relatedTarget = $(e.relatedTarget)
+ $dropdownMenu = $relatedTarget.closest('.dropdown-menu')
+
+ if $dropdownMenu.length is 0
+ @dropdown.removeClass('open')
if @dropdown.find(".dropdown-toggle-page").length
@dropdown.find(".dropdown-toggle-page, .dropdown-menu-back").on "click", (e) =>
diff --git a/app/assets/javascripts/issuable.js.coffee b/app/assets/javascripts/issuable.js.coffee
index 6a108c033ea..0527c66461c 100644
--- a/app/assets/javascripts/issuable.js.coffee
+++ b/app/assets/javascripts/issuable.js.coffee
@@ -59,13 +59,12 @@ issuable_created = false
filterResults: (form) =>
formData = form.serialize()
- $('.issues-holder, .merge-requests-holder').css('opacity', '0.5')
formAction = form.attr('action')
issuesUrl = formAction
issuesUrl += ("#{if formAction.indexOf('?') < 0 then '?' else '&'}")
issuesUrl += formData
- Turbolinks.visit(issuesUrl);
+ Turbolinks.visit(issuesUrl)
initChecks: ->
@issuableBulkActions = $('.bulk-update').data('bulkActions')
diff --git a/app/assets/javascripts/lib/utils/text_utility.js.coffee b/app/assets/javascripts/lib/utils/text_utility.js.coffee
index bb2772dfed2..7bcb876d056 100644
--- a/app/assets/javascripts/lib/utils/text_utility.js.coffee
+++ b/app/assets/javascripts/lib/utils/text_utility.js.coffee
@@ -10,17 +10,41 @@
gl.text.selectedText = (text, textarea) ->
text.substring(textarea.selectionStart, textarea.selectionEnd)
- gl.text.insertText = (textArea, text, tag, selected, wrap) ->
+ gl.text.lineBefore = (text, textarea) ->
+ split = text.substring(0, textarea.selectionStart).trim().split('\n')
+ split[split.length - 1]
+
+ gl.text.lineAfter = (text, textarea) ->
+ text.substring(textarea.selectionEnd).trim().split('\n')[0]
+
+ gl.text.blockTagText = (text, textArea, blockTag, selected) ->
+ lineBefore = @lineBefore(text, textArea)
+ lineAfter = @lineAfter(text, textArea)
+
+ if lineBefore is blockTag and lineAfter is blockTag
+ # To remove the block tag we have to select the line before & after
+ if blockTag?
+ textArea.selectionStart = textArea.selectionStart - (blockTag.length + 1)
+ textArea.selectionEnd = textArea.selectionEnd + (blockTag.length + 1)
+
+ selected
+ else
+ "#{blockTag}\n#{selected}\n#{blockTag}"
+
+ gl.text.insertText = (textArea, text, tag, blockTag, selected, wrap) ->
selectedSplit = selected.split('\n')
startChar = if not wrap and textArea.selectionStart > 0 then '\n' else ''
- if selectedSplit.length > 1 and not wrap
- insertText = selectedSplit.map((val) ->
- if val.indexOf(tag) is 0
- "#{val.replace(tag, '')}"
- else
- "#{tag}#{val}"
- ).join('\n')
+ if selectedSplit.length > 1 and (not wrap or blockTag?)
+ if blockTag?
+ insertText = @blockTagText(text, textArea, blockTag, selected)
+ else
+ insertText = selectedSplit.map((val) ->
+ if val.indexOf(tag) is 0
+ "#{val.replace(tag, '')}"
+ else
+ "#{tag}#{val}"
+ ).join('\n')
else
insertText = "#{startChar}#{tag}#{selected}#{if wrap then tag else ' '}"
@@ -51,7 +75,7 @@
textArea.setSelectionRange pos, pos
- gl.text.updateText = (textArea, tag, wrap) ->
+ gl.text.updateText = (textArea, tag, blockTag, wrap) ->
$textArea = $(textArea)
oldVal = $textArea.val()
textArea = $textArea.get(0)
@@ -59,7 +83,7 @@
selected = @selectedText(text, textArea)
$textArea.focus()
- @insertText(textArea, text, tag, selected, wrap)
+ @insertText(textArea, text, tag, blockTag, selected, wrap)
gl.text.init = (form) ->
self = @
@@ -70,6 +94,7 @@
self.updateText(
$this.closest('.md-area').find('textarea'),
$this.data('md-tag'),
+ $this.data('md-block'),
not $this.data('md-prepend')
)
diff --git a/app/assets/javascripts/search_autocomplete.js.coffee b/app/assets/javascripts/search_autocomplete.js.coffee
index 421328554b8..72b1d3dfb1e 100644
--- a/app/assets/javascripts/search_autocomplete.js.coffee
+++ b/app/assets/javascripts/search_autocomplete.js.coffee
@@ -171,22 +171,15 @@ class @SearchAutocomplete
}
bindEvents: ->
- $(document).on 'click', @onDocumentClick
@searchInput.on 'keydown', @onSearchInputKeyDown
@searchInput.on 'keyup', @onSearchInputKeyUp
@searchInput.on 'click', @onSearchInputClick
@searchInput.on 'focus', @onSearchInputFocus
+ @searchInput.on 'blur', @onSearchInputBlur
@clearInput.on 'click', @onClearInputClick
@locationBadgeEl.on 'click', =>
@searchInput.focus()
- onDocumentClick: (e) =>
- # If clicking outside the search box
- # And search input is not focused
- # And we are not clicking inside a suggestion
- if not $.contains(@dropdown[0], e.target) and @isFocused and not $(e.target).closest('.search-form').length
- @onSearchInputBlur()
-
enableAutocomplete: ->
# No need to enable anything if user is not logged in
return if !gon.current_user_id
@@ -287,8 +280,6 @@ class @SearchAutocomplete
value: @originalState._location
)
- @dropdown.removeClass 'open'
-
badgePresent: ->
@locationBadgeEl.length
diff --git a/app/assets/javascripts/shortcuts.js.coffee b/app/assets/javascripts/shortcuts.js.coffee
index c03877e9b06..3319a67a79d 100644
--- a/app/assets/javascripts/shortcuts.js.coffee
+++ b/app/assets/javascripts/shortcuts.js.coffee
@@ -9,12 +9,12 @@ class @Shortcuts
onToggleHelp: (e) =>
e.preventDefault()
- @toggleHelp(@enabledHelp)
+ Shortcuts.toggleHelp(@enabledHelp)
- toggleMarkdownPreview: (e) =>
+ toggleMarkdownPreview: (e) ->
$(document).triggerHandler('markdown-preview:toggle', [e])
- toggleHelp: (location) ->
+ @toggleHelp: (location) ->
$modal = $('#modal-shortcuts')
if $modal.length
diff --git a/app/assets/javascripts/tree.js.coffee b/app/assets/javascripts/tree.js.coffee
index de8eebcd0b2..83de584f2d9 100644
--- a/app/assets/javascripts/tree.js.coffee
+++ b/app/assets/javascripts/tree.js.coffee
@@ -5,9 +5,15 @@ class @TreeView
# Code browser tree slider
# Make the entire tree-item row clickable, but not if clicking another link (like a commit message)
$(".tree-content-holder .tree-item").on 'click', (e) ->
- if (e.target.nodeName != "A")
- path = $('.tree-item-file-name a', this).attr('href')
- Turbolinks.visit(path)
+ $clickedEl = $(e.target)
+ path = $('.tree-item-file-name a', this).attr('href')
+
+ if not $clickedEl.is('a') and not $clickedEl.is('.str-truncated')
+ if e.metaKey or e.which is 2
+ e.preventDefault()
+ window.open path, '_blank'
+ else
+ Turbolinks.visit path
# Show the "Loading commit data" for only the first element
$('span.log_loading:first').removeClass('hide')