diff --git a/app/assets/javascripts/app/controllers/_application_controller.js.coffee b/app/assets/javascripts/app/controllers/_application_controller.js.coffee index 315e5a8b7..eb17c5946 100644 --- a/app/assets/javascripts/app/controllers/_application_controller.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller.js.coffee @@ -79,7 +79,7 @@ class App.Controller extends Spine.Controller @userPopupsDestroy() @organizationPopupsDestroy() - release: => + release: -> # release custom bindings after it got removed from dom # add @title methode to set title @@ -138,7 +138,7 @@ class App.Controller extends Spine.Controller element.css( 'left', positionStart + 'px' ) if position.length > 0 setTimeout( -> - shakeMe( element, position, positionEnd ) + shakeMe( element, position, positionEnd ) , positionEnd) else try @@ -174,14 +174,14 @@ class App.Controller extends Spine.Controller # # human readable file size - humanFileSize: (size) => + humanFileSize: (size) -> App.Utils.humanFileSize(size) # human readable time - humanTime: ( time, escalation, long = true ) => + humanTime: ( time, escalation, long = true ) -> App.PrettyDate.humanTime( time, escalation, long ) - userInfo: (data) => + userInfo: (data) -> el = data.el || $('[data-id="customer_info"]') el.unbind() @@ -242,7 +242,7 @@ class App.Controller extends Spine.Controller if id ticket = App.Ticket.find(id) @navigate ticket.uiUrl() - ); + ) @ticketPopupsDestroy() @@ -287,7 +287,7 @@ class App.Controller extends Spine.Controller if id user = App.User.find(id) @navigate user.uiUrl() - ); + ) @userPopupsDestroy() @@ -345,7 +345,7 @@ class App.Controller extends Spine.Controller if id organization = App.Organization.find(id) @navigate organization.uiUrl() - ); + ) @organizationPopupsDestroy() @@ -441,7 +441,7 @@ class App.Controller extends Spine.Controller customer_id: params.user_id, } processData: true, - success: (data, status, xhr) => + success: (data, status, xhr) -> App.Store.write( "user-ticket-popover::#{params.user_id}", data ) # load assets @@ -455,7 +455,7 @@ class App.Controller extends Spine.Controller if data show( params, { open: data.ticket_ids_open, closed: data.ticket_ids_closed } ) @delay( - => + -> fetch(params) 1000 'fetch' @@ -530,14 +530,14 @@ class App.Controller extends Spine.Controller class App.ControllerPermanent extends App.Controller constructor: -> super - $('.content').addClass('hide'); + $('.content').addClass('hide') @navShow() class App.ControllerContent extends App.Controller constructor: -> super - $('.content').addClass('hide'); - $('#content').removeClass('hide'); + $('.content').addClass('hide') + $('#content').removeClass('hide') @navShow() class App.ControllerModal extends App.Controller @@ -611,7 +611,7 @@ class App.ControllerModal extends App.Controller e.preventDefault() @el.modal('hide') - onShown: => + onShown: -> console.log('modal shown: do nothing') # do nothing @@ -685,7 +685,7 @@ class App.UpdateTastbar extends App.Controller release: => App[ @genericObject.constructor.className ].unsubscribe(@subscribeId) - update: (genericObject) => + update: (genericObject) -> # update taskbar with new meta data App.Event.trigger 'task:render' diff --git a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee index 51da9b8fc..41636071f 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee @@ -81,7 +81,7 @@ class App.ControllerForm extends App.Controller # rename display and name to _confirm if !attribute.single attribute.display = attribute.display + ' (confirm)' - attribute.name = attribute.name + '_confirm'; + attribute.name = attribute.name + '_confirm' item = @formGenItem( attribute, className, fieldset, attribute_count ) item.appendTo(fieldset) @@ -93,9 +93,9 @@ class App.ControllerForm extends App.Controller # bind form events if @events for eventSelector, callback of @events - do (eventSelector, callback) => + do (eventSelector, callback) -> evs = eventSelector.split(' ') - fieldset.find( evs[1] ).bind( evs[0], (e) => callback(e) ) + fieldset.find( evs[1] ).bind( evs[0], (e) -> callback(e) ) # return form return fieldset @@ -383,7 +383,7 @@ class App.ControllerForm extends App.Controller el.find('[name="' + key + '"]').attr('required', false) el.find('[name="' + key + '"]').parents('.form-group').find('label span').html('') - showHideToggle: (params, changedAttribute, attributes, classname, form, ui) => + showHideToggle: (params, changedAttribute, attributes, classname, form, ui) -> for attribute in attributes if attribute.shown_if hit = false @@ -400,7 +400,7 @@ class App.ControllerForm extends App.Controller else ui.hide(attribute.name) - requiredMandantoryToggle: (params, changedAttribute, attributes, classname, form, ui) => + requiredMandantoryToggle: (params, changedAttribute, attributes, classname, form, ui) -> for attribute in attributes if attribute.required_if hit = false diff --git a/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee index 6fd2f6b22..a23456dfc 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee @@ -91,7 +91,7 @@ class App.ControllerGenericEdit extends App.ControllerModal ui.callback( item ) ui.hide() - fail: => + fail: -> ui.log 'errors' ui.hide() ) @@ -569,7 +569,7 @@ class App.ActionRow extends App.Controller do (item) => @el.find('[data-type="' + item.name + '"]').on( 'click', - (e) => + (e) -> e.preventDefault() item.callback() ) @@ -620,7 +620,7 @@ class App.Sidebar extends App.Controller type: 'small' ) - toggleDropdown: (e) => + toggleDropdown: (e) -> e.stopPropagation() $(e.currentTarget).next('.js-actions').find('.dropdown-toggle').dropdown('toggle') diff --git a/app/assets/javascripts/app/controllers/_application_controller_table.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_table.js.coffee index 1acd639d6..608bb7bc7 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_table.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_table.js.coffee @@ -115,7 +115,7 @@ class App.ControllerTable extends App.Controller # remove group by attribute from header overview = _.filter( overview - (item) => + (item) -> return item if item isnt data.groupBy return ) @@ -123,7 +123,7 @@ class App.ControllerTable extends App.Controller # get new order groupObjects = _.groupBy( data.objects - (item) => + (item) -> return '' if !item[data.groupBy] return item[data.groupBy].displayName() if item[data.groupBy].displayName item[data.groupBy] @@ -135,7 +135,7 @@ class App.ControllerTable extends App.Controller # sort new groups groupOrder = _.sortBy( groupOrder - (item) => + (item) -> item ) @@ -201,11 +201,11 @@ class App.ControllerTable extends App.Controller if hit for event, callback of item.events - do (table, event, callback) => + do (table, event, callback) -> if cursorMap[event] table.find("tbody > tr > td:nth-child(#{position}) span").css( 'cursor', cursorMap[event] ) table.on( event, "tbody > tr > td:nth-child(#{position}) span", - (e) => + (e) -> e.stopPropagation() id = $(e.target).parents('tr').data('id') callback(id, e) @@ -215,11 +215,11 @@ class App.ControllerTable extends App.Controller if data.bindRow if data.bindRow.events for event, callback of data.bindRow.events - do (table, event, callback) => + do (table, event, callback) -> if cursorMap[event] table.find('tbody > tr').css( 'cursor', cursorMap[event] ) table.on( event, 'tbody > tr', - (e) => + (e) -> id = $(e.target).parents('tr').data('id') callback(id, e) ) @@ -228,7 +228,7 @@ class App.ControllerTable extends App.Controller if data.bindCheckbox if data.bindCheckbox.events for event, callback of data.bindCheckbox.events - do (table, event, callback) => + do (table, event, callback) -> table.delegate('input[name="bulk"]', event, (e) -> e.stopPropagation() id = $(e.target).parents('tr').data('id') diff --git a/app/assets/javascripts/app/index.js.coffee b/app/assets/javascripts/app/index.js.coffee index 11f9c2732..71c4b0940 100644 --- a/app/assets/javascripts/app/index.js.coffee +++ b/app/assets/javascripts/app/index.js.coffee @@ -121,7 +121,12 @@ class App extends Spine.Controller result @view: (name) -> - template = ( params = {} ) => + template = ( params = {} ) -> + + s = ( num, digits ) -> + while num.toString().length < digits + num = '0' + num + num # define print name helper params.P = ( object, attribute_name ) -> @@ -130,10 +135,6 @@ class App extends Spine.Controller # define date format helper params.date = ( time ) -> return '' if !time - s = ( num, digits ) -> - while num.toString().length < digits - num = "0" + num - num timeObject = new Date(time) d = s( timeObject.getDate(), 2 ) @@ -144,10 +145,6 @@ class App extends Spine.Controller # define datetime format helper params.datetime = ( time ) -> return '' if !time - s = ( num, digits ) -> - while num.toString().length < digits - num = "0" + num - num timeObject = new Date(time) d = s( timeObject.getDate(), 2 ) @@ -161,10 +158,7 @@ class App extends Spine.Controller # define decimal format helper params.decimal = ( data, positions = 2 ) -> return '' if !data - s = ( num, digits ) -> - while num.toString().length < digits - num = num + "0" - num + result = data.toString().match(/^(.+?)\.(.+?)$/) if !result || !result[2] return "#{data}." + s( 0, positions ).toString()