Moved to easier page header show/hide implementation of long pages.
This commit is contained in:
parent
6ce75e975e
commit
6491d18f34
4 changed files with 41 additions and 1816 deletions
|
@ -1,9 +1,11 @@
|
||||||
class App.TicketZoom extends App.Controller
|
class App.TicketZoom extends App.Controller
|
||||||
elements:
|
elements:
|
||||||
'.main': 'main'
|
'.main': 'main'
|
||||||
|
'.ticketZoom': 'ticketZoom'
|
||||||
|
'.scrollPageHeader': 'scrollPageHeader'
|
||||||
|
|
||||||
events:
|
events:
|
||||||
'click .js-submit': 'submit'
|
'click .js-submit': 'submit'
|
||||||
'click .js-bookmark': 'bookmark'
|
'click .js-bookmark': 'bookmark'
|
||||||
|
|
||||||
constructor: (params) ->
|
constructor: (params) ->
|
||||||
|
@ -59,24 +61,21 @@ class App.TicketZoom extends App.Controller
|
||||||
show: =>
|
show: =>
|
||||||
App.OnlineNotification.seen( 'Ticket', @ticket_id )
|
App.OnlineNotification.seen( 'Ticket', @ticket_id )
|
||||||
@navupdate '#'
|
@navupdate '#'
|
||||||
if @scrollHeader
|
@positionPageHeaderStart()
|
||||||
@scrollHeader.continue()
|
|
||||||
|
|
||||||
hide: =>
|
hide: =>
|
||||||
if @scrollHeader
|
@positionPageHeaderStop()
|
||||||
@scrollHeader.pause()
|
|
||||||
|
|
||||||
changed: =>
|
changed: =>
|
||||||
formCurrent = @formParam( @el.find('.edit') )
|
formCurrent = @formParam( @el.find('.edit') )
|
||||||
ticket = App.Ticket.find(@ticket_id).attributes()
|
ticket = App.Ticket.find(@ticket_id).attributes()
|
||||||
modelDiff = @getDiff( ticket, formCurrent )
|
modelDiff = @getDiff( ticket, formCurrent )
|
||||||
return false if !modelDiff || _.isEmpty( modelDiff )
|
return false if !modelDiff || _.isEmpty( modelDiff )
|
||||||
return true
|
return true
|
||||||
|
|
||||||
release: =>
|
release: =>
|
||||||
# nothing
|
|
||||||
@autosaveStop()
|
@autosaveStop()
|
||||||
@scrollHeader.destroy() if @scrollHeader
|
@positionPageHeaderStop()
|
||||||
|
|
||||||
fetch: (ticket_id, force) ->
|
fetch: (ticket_id, force) ->
|
||||||
|
|
||||||
|
@ -149,6 +148,36 @@ class App.TicketZoom extends App.Controller
|
||||||
# render page
|
# render page
|
||||||
@render(force)
|
@render(force)
|
||||||
|
|
||||||
|
positionPageHeaderStart: =>
|
||||||
|
|
||||||
|
# scroll is also fired on window resize, if element scroll is changed
|
||||||
|
@main.bind(
|
||||||
|
'scroll'
|
||||||
|
@positionPageHeaderUpdate
|
||||||
|
)
|
||||||
|
|
||||||
|
positionPageHeaderStop: =>
|
||||||
|
@main.unbind('scroll', @positionPageHeaderUpdate)
|
||||||
|
|
||||||
|
positionPageHeaderUpdate: =>
|
||||||
|
pageHeader = @scrollPageHeader.height()
|
||||||
|
mainScrollHeigth = @main.prop('scrollHeight')
|
||||||
|
mainHeigth = @main.height()
|
||||||
|
|
||||||
|
# if page header is possible to use, show page header
|
||||||
|
top = 0
|
||||||
|
if mainScrollHeigth > mainHeigth + pageHeader
|
||||||
|
offset = @ticketZoom.offset()
|
||||||
|
if offset.top >= 0
|
||||||
|
top = offset.top
|
||||||
|
|
||||||
|
# if page header is not possible to use - mainScrollHeigth to low - hide page header
|
||||||
|
else
|
||||||
|
top = pageHeader
|
||||||
|
|
||||||
|
#console.log('TOP', top, @ticket.id, new Date)
|
||||||
|
@scrollPageHeader.css('transform', "translateY(-#{top}px)")
|
||||||
|
|
||||||
render: (force) =>
|
render: (force) =>
|
||||||
|
|
||||||
# update taskbar with new meta data
|
# update taskbar with new meta data
|
||||||
|
@ -404,21 +433,11 @@ class App.TicketZoom extends App.Controller
|
||||||
|
|
||||||
@scrollToBottom()
|
@scrollToBottom()
|
||||||
|
|
||||||
@bindScrollPageHeader()
|
@positionPageHeaderStart()
|
||||||
|
|
||||||
scrollToBottom: =>
|
scrollToBottom: =>
|
||||||
@main.scrollTop( @main.prop('scrollHeight') )
|
@main.scrollTop( @main.prop('scrollHeight') )
|
||||||
|
|
||||||
bindScrollPageHeader: ->
|
|
||||||
pageHeader = @$('.page-header')
|
|
||||||
scrollBody = @main.prop('scrollHeight') - @main.height()
|
|
||||||
|
|
||||||
if scrollBody > pageHeader.height()
|
|
||||||
# TODO: recalculate the distance when adding a comment
|
|
||||||
@scrollHeader = skrollr.init
|
|
||||||
forceHeight: false
|
|
||||||
holder: @main.get(0)
|
|
||||||
|
|
||||||
autosaveStop: =>
|
autosaveStop: =>
|
||||||
@autosaveLast = {}
|
@autosaveLast = {}
|
||||||
@clearInterval( 'autosave' )
|
@clearInterval( 'autosave' )
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,11 +1,7 @@
|
||||||
<div class="tabsSidebar-holder">
|
<div class="tabsSidebar-holder">
|
||||||
<div class="main no-padding flex tabsSidebar-sidebarSpacer tabsSidebar-tabsSpacer">
|
<div class="main no-padding flex tabsSidebar-sidebarSpacer tabsSidebar-tabsSpacer">
|
||||||
<div class="ticketZoom">
|
<div class="ticketZoom">
|
||||||
<div class="scrollPageHeader tabsSidebar-sidebarSpacer zIndex-3 horizontal center"
|
<div class="scrollPageHeader tabsSidebar-sidebarSpacer zIndex-3 horizontal center">
|
||||||
data-anchor-target=".ticketZoom .page-header"
|
|
||||||
data-128-top-bottom="transform: translateY(-64px);"
|
|
||||||
data-64-top-bottom="transform: translateY(0px);"
|
|
||||||
>
|
|
||||||
<small><%- @C('ticket_hook') %> <span class="ticket-number"><%- @ticket.number %></span></small>
|
<small><%- @C('ticket_hook') %> <span class="ticket-number"><%- @ticket.number %></span></small>
|
||||||
<div class="ticket-title flex"></div>
|
<div class="ticket-title flex"></div>
|
||||||
<div class="pagination-counter">
|
<div class="pagination-counter">
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
|
|
||||||
//= require ./app/lib/animations/velocity.min.js
|
//= require ./app/lib/animations/velocity.min.js
|
||||||
//= require ./app/lib/animations/velocity.ui.js
|
//= require ./app/lib/animations/velocity.ui.js
|
||||||
//= require ./app/lib/animations/skrollr.js
|
|
||||||
|
|
||||||
//not_used= require_tree ./app/lib/spine
|
//not_used= require_tree ./app/lib/spine
|
||||||
//= require ./app/lib/spine/spine.coffee
|
//= require ./app/lib/spine/spine.coffee
|
||||||
|
|
Loading…
Reference in a new issue