Avoid conflicts between lightboxes on keypress ESC
parent
2fe857a970
commit
362ff5f37d
|
@ -39,7 +39,7 @@ normalizeString = @.taiga.normalizeString
|
||||||
class LightboxService extends taiga.Service
|
class LightboxService extends taiga.Service
|
||||||
constructor: (@animationFrame, @q, @rootScope) ->
|
constructor: (@animationFrame, @q, @rootScope) ->
|
||||||
|
|
||||||
open: ($el, onClose, onEsc) ->
|
open: ($el, onClose, onEsc, ignoreEsc) ->
|
||||||
@.onClose = onClose
|
@.onClose = onClose
|
||||||
|
|
||||||
if _.isString($el)
|
if _.isString($el)
|
||||||
|
@ -66,14 +66,15 @@ class LightboxService extends taiga.Service
|
||||||
lightboxContent.show()
|
lightboxContent.show()
|
||||||
defered.resolve()
|
defered.resolve()
|
||||||
|
|
||||||
docEl = angular.element(document)
|
if !ignoreEsc
|
||||||
docEl.on "keydown.lightbox", (e) =>
|
docEl = angular.element(document)
|
||||||
code = if e.keyCode then e.keyCode else e.which
|
docEl.on "keydown.lightbox", (e) =>
|
||||||
if code == 27
|
code = if e.keyCode then e.keyCode else e.which
|
||||||
if onEsc
|
if code == 27
|
||||||
@rootScope.$applyAsync(onEsc)
|
if onEsc
|
||||||
else
|
@rootScope.$applyAsync(onEsc)
|
||||||
@.close($el)
|
else
|
||||||
|
@.close($el)
|
||||||
|
|
||||||
|
|
||||||
return defered.promise
|
return defered.promise
|
||||||
|
@ -892,7 +893,7 @@ $confirm, $q, attachmentsService, $template, $compile) ->
|
||||||
setStatus($scope.obj.status)
|
setStatus($scope.obj.status)
|
||||||
render()
|
render()
|
||||||
$scope.lightboxOpen = true
|
$scope.lightboxOpen = true
|
||||||
lightboxService.open($el)
|
lightboxService.open($el, null, null, true)
|
||||||
|
|
||||||
resetAttachments = () ->
|
resetAttachments = () ->
|
||||||
attachmentsToAdd = Immutable.List()
|
attachmentsToAdd = Immutable.List()
|
||||||
|
@ -1020,7 +1021,7 @@ $confirm, $q, attachmentsService, $template, $compile) ->
|
||||||
deleteAttachments(data).then () ->
|
deleteAttachments(data).then () ->
|
||||||
createAttachments(data).then () ->
|
createAttachments(data).then () ->
|
||||||
currentLoading.finish()
|
currentLoading.finish()
|
||||||
lightboxService.close($el)
|
close()
|
||||||
$rs[schema.model].getByRef(data.project, data.ref, schema.params).then (obj) ->
|
$rs[schema.model].getByRef(data.project, data.ref, schema.params).then (obj) ->
|
||||||
$rootScope.$broadcast(broadcastEvent, obj)
|
$rootScope.$broadcast(broadcastEvent, obj)
|
||||||
promise.then null, (data) ->
|
promise.then null, (data) ->
|
||||||
|
@ -1031,14 +1032,27 @@ $confirm, $q, attachmentsService, $template, $compile) ->
|
||||||
|
|
||||||
checkClose = () ->
|
checkClose = () ->
|
||||||
if !$scope.obj.isModified()
|
if !$scope.obj.isModified()
|
||||||
lightboxService.close($el)
|
close()
|
||||||
$scope.$apply ->
|
$scope.$apply ->
|
||||||
$scope.obj.revert()
|
$scope.obj.revert()
|
||||||
else
|
else
|
||||||
$confirm.ask(
|
$confirm.ask(
|
||||||
$translate.instant("LIGHTBOX.CREATE_EDIT.CONFIRM_CLOSE")).then (result) ->
|
$translate.instant("LIGHTBOX.CREATE_EDIT.CONFIRM_CLOSE"))
|
||||||
|
.then (result) ->
|
||||||
result.finish()
|
result.finish()
|
||||||
lightboxService.close($el)
|
close()
|
||||||
|
|
||||||
|
close = () ->
|
||||||
|
lightboxService.close($el)
|
||||||
|
$scope.lightboxOpen = false
|
||||||
|
|
||||||
|
docEl = angular.element(document)
|
||||||
|
docEl.on "keydown.lightbox-create-edit", (event) ->
|
||||||
|
if $scope.lightboxOpen
|
||||||
|
event.stopPropagation()
|
||||||
|
code = if event.keyCode then event.keyCode else event.which
|
||||||
|
if code == 27
|
||||||
|
checkClose()
|
||||||
|
|
||||||
$el.on "submit", "form", submit
|
$el.on "submit", "form", submit
|
||||||
|
|
||||||
|
@ -1047,12 +1061,6 @@ $confirm, $q, attachmentsService, $template, $compile) ->
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
checkClose()
|
checkClose()
|
||||||
|
|
||||||
$el.keydown (event) ->
|
|
||||||
event.stopPropagation()
|
|
||||||
code = if event.keyCode then event.keyCode else event.which
|
|
||||||
if code == 27
|
|
||||||
checkClose()
|
|
||||||
|
|
||||||
$el.on "click", ".status-dropdown", (event) ->
|
$el.on "click", ".status-dropdown", (event) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
|
|
Loading…
Reference in New Issue