Reduced dom operations at loading time.

This commit is contained in:
Martin Edenhofer 2015-12-02 10:18:02 +01:00
parent 1439588581
commit b102e75aaa
3 changed files with 44 additions and 39 deletions

View file

@ -4,24 +4,24 @@ class App.OrganizationProfile extends App.Controller
# check authentication
if !@authenticate()
App.TaskManager.remove( @task_key )
App.TaskManager.remove(@task_key)
return
# fetch new data if needed
App.Organization.full( @organization_id, @render )
App.Organization.full(@organization_id, @render)
# rerender view, e. g. on langauge change
@bind 'ui:rerender', =>
return if !@authenticate(true)
@render( App.Organization.fullLocal( @organization_id ) )
@render(App.Organization.fullLocal(@organization_id))
meta: =>
meta =
url: @url()
id: @organization_id
if App.Organization.exists( @organization_id )
organization = App.Organization.find( @organization_id )
if App.Organization.exists(@organization_id)
organization = App.Organization.find(@organization_id)
meta.head = organization.displayName()
meta.title = organization.displayName()
@ -33,7 +33,7 @@ class App.OrganizationProfile extends App.Controller
'#organization/profile/' + @organization_id
show: =>
App.OnlineNotification.seen( 'Organization', @organization_id )
App.OnlineNotification.seen('Organization', @organization_id)
@navupdate '#'
changed: ->
@ -43,22 +43,24 @@ class App.OrganizationProfile extends App.Controller
if !@doNotLog
@doNotLog = 1
@recentView( 'Organization', @organization_id )
@recentView('Organization', @organization_id)
@html App.view('organization_profile/index')(
elLocal = $(App.view('organization_profile/index')(
organization: organization
)
))
new Object(
el: @$('.js-object-container')
el: elLocal.find('.js-object-container')
organization: organization
)
new App.TicketStats(
el: @$('.js-ticket-stats')
el: elLocal.find('.js-ticket-stats')
organization: organization
)
@html elLocal
new App.UpdateTastbar(
genericObject: organization
)
@ -71,7 +73,7 @@ class Object extends App.Controller
super
# subscribe and reload data / fetch new data if triggered
@subscribeId = App.Organization.full( @organization.id, @render, false, true )
@subscribeId = App.Organization.full(@organization.id, @render, false, true)
release: =>
App.Organization.unsubscribe(@subscribeId)
@ -87,12 +89,12 @@ class Object extends App.Controller
# check if value for _id exists
name = attributeName
nameNew = name.substr( 0, name.length - 3 )
nameNew = name.substr(0, name.length - 3)
if nameNew of organization
name = nameNew
# add to show if value exists
if ( organization[name] || attributeConfig.tag is 'richtext' ) && attributeConfig.shown
if (organization[name] || attributeConfig.tag is 'richtext') && attributeConfig.shown
# do not show firstname and lastname / already show via diplayName()
if name isnt 'name'
@ -148,11 +150,11 @@ class Object extends App.Controller
update: (e) =>
name = $(e.target).attr('data-name')
value = $(e.target).html()
org = App.Organization.find( @organization.id )
org = App.Organization.find(@organization.id)
if org[name] isnt value
data = {}
data[name] = value
org.updateAttributes( data )
org.updateAttributes(data)
@log 'notice', 'update', name, value, org
@ -171,4 +173,4 @@ class Router extends App.ControllerPermanent
show: true
)
App.Config.set( 'organization/profile/:organization_id', Router, 'Routes' )
App.Config.set('organization/profile/:organization_id', Router, 'Routes')

View file

@ -6,21 +6,23 @@ class App.TicketOverview extends App.Controller
@render()
render: ->
@html App.view('ticket_overview')()
elLocal = $(App.view('ticket_overview')())
@navBarControllerVertical = new Navbar
el: @$('.overview-header')
el: elLocal.find('.overview-header')
view: @view
vertical: true
@navBarController = new Navbar
el: @$('.sidebar')
el: elLocal.first()
view: @view
@contentController = new Table
el: @$('.overview-table')
el: elLocal.find('.overview-table')
view: @view
@html elLocal
active: (state) =>
@activeState = state

View file

@ -4,16 +4,16 @@ class App.UserProfile extends App.Controller
# check authentication
if !@authenticate()
App.TaskManager.remove( @task_key )
App.TaskManager.remove(@task_key)
return
# fetch new data if needed
@subscribeId = App.User.full( @user_id, @render )
@subscribeId = App.User.full(@user_id, @render)
# rerender view, e. g. on langauge change
@bind 'ui:rerender', =>
return if !@authenticate(true)
@render( App.User.fullLocal( @user_id ) )
@render(App.User.fullLocal(@user_id))
release: =>
App.User.unsubscribe(@subscribeId)
@ -23,8 +23,8 @@ class App.UserProfile extends App.Controller
url: @url()
id: @user_id
if App.User.exists( @user_id )
user = App.User.find( @user_id )
if App.User.exists(@user_id)
user = App.User.find(@user_id)
meta.head = user.displayName()
meta.title = user.displayName()
@ -35,7 +35,7 @@ class App.UserProfile extends App.Controller
'#user/profile/' + @user_id
show: =>
App.OnlineNotification.seen( 'User', @user_id )
App.OnlineNotification.seen('User', @user_id)
@navupdate '#'
changed: ->
@ -45,22 +45,24 @@ class App.UserProfile extends App.Controller
if !@doNotLog
@doNotLog = 1
@recentView( 'User', @user_id )
@recentView('User', @user_id)
@html App.view('user_profile/index')(
elLocal = $(App.view('user_profile/index')(
user: user
)
))
new Object(
el: @$('.js-object-container')
el: elLocal.find('.js-object-container')
user: user
)
new App.TicketStats(
el: @$('.js-ticket-stats')
el: elLocal.find('.js-ticket-stats')
user: user
)
@html elLocal
new App.UpdateTastbar(
genericObject: user
)
@ -74,7 +76,7 @@ class Object extends App.Controller
super
# subscribe and reload data / fetch new data if triggered
@subscribeId = App.User.full( @user.id, @render, false, true )
@subscribeId = App.User.full(@user.id, @render, false, true)
release: =>
App.User.unsubscribe(@subscribeId)
@ -90,12 +92,12 @@ class Object extends App.Controller
# check if value for _id exists
name = attributeName
nameNew = name.substr( 0, name.length - 3 )
nameNew = name.substr(0, name.length - 3)
if nameNew of user
name = nameNew
# add to show if value exists
if ( user[name] || attributeConfig.tag is 'richtext' ) && attributeConfig.shown
if (user[name] || attributeConfig.tag is 'richtext') && attributeConfig.shown
# do not show firstname and lastname / already show via diplayName()
if name isnt 'firstname' && name isnt 'lastname' && name isnt 'organization'
@ -152,11 +154,11 @@ class Object extends App.Controller
update: (e) =>
name = $(e.target).attr('data-name')
value = $(e.target).html()
user = App.User.find( @user.id )
user = App.User.find(@user.id)
if user[name] isnt value
data = {}
data[name] = value
user.updateAttributes( data )
user.updateAttributes(data)
@log 'notice', 'update', name, value, user
class Router extends App.ControllerPermanent
@ -174,5 +176,4 @@ class Router extends App.ControllerPermanent
show: true
)
App.Config.set( 'user/profile/:user_id', Router, 'Routes' )
App.Config.set('user/profile/:user_id', Router, 'Routes')