2012-04-10 14:06:46 +00:00
// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
2012-04-10 13:31:21 +00:00
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
2012-04-10 14:06:46 +00:00
2016-02-28 01:19:35 +00:00
//= require ./app/lib/core/jquery-2.2.1.js
2016-03-12 00:00:05 +00:00
//= require ./app/lib/core/jquery-ui-1.11.4.js
2015-04-13 12:44:36 +00:00
//= require ./app/lib/core/underscore-1.8.3.js
2014-09-02 14:35:50 +00:00
2014-09-04 00:54:33 +00:00
//= require ./app/lib/animations/velocity.min.js
2014-09-02 14:35:50 +00:00
//= require ./app/lib/animations/velocity.ui.js
2012-11-05 14:37:59 +00:00
//not_used= require_tree ./app/lib/spine
2014-04-06 11:32:20 +00:00
//= require ./app/lib/spine/spine.coffee
//= require ./app/lib/spine/ajax.coffee
//= require ./app/lib/spine/local.coffee
//= require ./app/lib/spine/route.coffee
2012-11-05 14:37:59 +00:00
2012-12-18 02:00:31 +00:00
//= require ./app/lib/flot/jquery.flot.js
//= require ./app/lib/flot/jquery.flot.selection.js
2012-11-05 14:37:59 +00:00
//not_used= require_tree ./app/lib/bootstrap
2013-08-19 21:03:03 +00:00
//= require ./app/lib/bootstrap/dropdown.js
//= require ./app/lib/bootstrap/tooltip.js
//= require ./app/lib/bootstrap/popover.js
2015-01-14 21:59:56 +00:00
//= require ./app/lib/bootstrap/popover-enhance.js
2015-01-15 09:07:06 +00:00
// modified by Felix Jan-2014
2013-08-19 21:03:03 +00:00
//= require ./app/lib/bootstrap/modal.js
2015-01-15 09:07:06 +00:00
2013-08-19 21:03:03 +00:00
//= require ./app/lib/bootstrap/tab.js
//= require ./app/lib/bootstrap/transition.js
//= require ./app/lib/bootstrap/button.js
//= require ./app/lib/bootstrap/collapse.js
2015-06-29 15:04:09 +00:00
//= require ./app/lib/bootstrap/bootstrap-timepicker.js
2015-09-25 15:15:57 +00:00
//= require ./app/lib/bootstrap/bootstrap-datepicker.js
2012-11-05 14:37:59 +00:00
2015-03-10 20:11:36 +00:00
//= require ./app/lib/rangy/rangy-core.js
//= require ./app/lib/rangy/rangy-classapplier.js
//= require ./app/lib/rangy/rangy-textrange.js
//= require ./app/lib/rangy/rangy-highlighter.js
2012-11-05 14:37:59 +00:00
//= require_tree ./app/lib/base
2015-09-28 17:52:27 +00:00
//= require ./app/index.coffee
2012-12-20 09:16:02 +00:00
// IE8 workaround for missing console.log
if ( ! window . console ) {
window . console = { }
}
if ( ! console . log ) {
console . log = function ( ) { }
}
2013-01-25 09:15:41 +00:00
2013-03-07 22:42:37 +00:00
function escapeRegExp ( str ) {
return str . replace ( /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g , "\\$&" ) ;
}
2013-01-25 09:15:41 +00:00
Date . prototype . getWeek = function ( ) {
var onejan = new Date ( this . getFullYear ( ) , 0 , 1 ) ;
return Math . ceil ( ( ( ( this - onejan ) / 86400000 ) + onejan . getDay ( ) + 1 ) / 7 ) ;
2013-03-08 07:27:25 +00:00
}
function difference ( object1 , object2 ) {
var changes = { } ;
2022-02-17 07:35:55 +00:00
_ . uniq ( Object . keys ( object1 ) . concat ( Object . keys ( object2 ) ) ) . forEach ( function ( name ) {
if ( name in object1 && name in object2 ) {
if ( _ . isObject ( object1 [ name ] ) && ! _ . isArray ( object1 [ name ] ) && _ . isObject ( object2 [ name ] ) && ! _ . isArray ( object2 [ name ] ) ) {
2016-03-04 08:28:16 +00:00
var diff = difference ( object1 [ name ] , object2 [ name ] ) ;
if ( ! _ . isEmpty ( diff ) ) {
2013-03-08 07:27:25 +00:00
changes [ name ] = diff ;
}
2016-03-04 08:28:16 +00:00
} else if ( ! _ . isEqual ( object1 [ name ] , object2 [ name ] ) ) {
2013-03-08 07:27:25 +00:00
changes [ name ] = object2 [ name ] ;
}
2022-02-17 07:35:55 +00:00
} else {
changes [ name ] = object2 [ name ]
2013-03-08 07:27:25 +00:00
}
2022-02-17 07:35:55 +00:00
} )
2013-03-08 07:27:25 +00:00
return changes ;
2013-07-22 22:41:13 +00:00
}
2016-06-27 18:04:18 +00:00
// returns the byte length of an utf8 string
// taken from http://stackoverflow.com/questions/5515869/string-length-in-bytes-in-javascript
function byteLength ( str ) {
var s = str . length
for ( var i = str . length - 1 ; i >= 0 ; i -- ) {
var code = str . charCodeAt ( i )
if ( code > 0x7f && code <= 0x7ff ) s ++
else if ( code > 0x7ff && code <= 0xffff ) s += 2
if ( code >= 0xDC00 && code <= 0xDFFF ) i -- //trail surrogate
}
return s
}
2015-01-29 13:19:11 +00:00
// clone, just data, no instances of objects
2015-02-06 21:51:52 +00:00
function clone ( item , full ) {
2015-06-03 05:53:28 +00:00
// just return/clone false conditions
2015-02-06 21:51:52 +00:00
if ( ! item ) { return item }
2015-01-29 13:19:11 +00:00
2015-06-03 05:53:28 +00:00
var itemType = item . constructor . name
// IE behavior // doesn't know item.constructor.name, detect it by underscore
if ( itemType === undefined ) {
if ( _ . isArray ( item ) ) {
itemType = 'Array'
}
else if ( _ . isNumber ( item ) ) {
itemType = 'Number'
}
else if ( _ . isString ( item ) ) {
itemType = 'String'
}
else if ( _ . isBoolean ( item ) ) {
itemType = 'Boolean'
}
else if ( _ . isFunction ( item ) ) {
itemType = 'Function'
}
else if ( _ . isObject ( item ) ) {
itemType = 'Object'
}
}
2015-01-29 13:19:11 +00:00
// ignore certain objects
2015-02-06 21:51:52 +00:00
var acceptedInstances = [ 'Object' , 'Number' , 'String' , 'Boolean' , 'Array' ]
if ( full ) {
2016-03-04 08:28:16 +00:00
acceptedInstances . push ( 'Function' )
2015-02-06 21:51:52 +00:00
}
2015-06-03 05:53:28 +00:00
// check if item is accepted to get cloned
if ( itemType && ! _ . contains ( acceptedInstances , itemType ) ) {
2015-06-17 18:07:51 +00:00
console . log ( 'no acceptedInstances' , itemType , item )
2016-05-17 14:28:08 +00:00
console . trace ( )
2015-06-03 05:53:28 +00:00
return
2015-01-29 13:19:11 +00:00
}
// copy array
2015-02-06 21:51:52 +00:00
var result ;
2015-06-03 05:53:28 +00:00
if ( itemType == 'Array' ) {
2015-02-06 21:51:52 +00:00
result = [ ]
2015-01-29 13:19:11 +00:00
item . forEach ( function ( child , index , array ) {
2015-02-06 21:51:52 +00:00
result [ index ] = clone ( child , full )
2015-01-29 13:19:11 +00:00
} ) ;
}
2015-02-06 21:51:52 +00:00
// copy function
2015-06-03 05:53:28 +00:00
else if ( itemType == 'Function' ) {
2015-02-06 21:51:52 +00:00
result = item . bind ( { } )
}
2015-01-29 13:19:11 +00:00
// copy object
2015-06-03 05:53:28 +00:00
else if ( itemType == 'Object' ) {
2015-02-06 21:51:52 +00:00
result = { }
2015-01-29 13:19:11 +00:00
for ( var key in item ) {
if ( item . hasOwnProperty ( key ) ) {
2016-03-04 08:28:16 +00:00
result [ key ] = clone ( item [ key ] , full )
2015-01-29 13:19:11 +00:00
}
}
}
// copy others
else {
2015-02-06 21:51:52 +00:00
result = item
2015-01-29 13:19:11 +00:00
}
2015-02-06 21:51:52 +00:00
return result
2015-01-29 13:19:11 +00:00
}
2015-08-05 07:28:47 +00:00
// taken from https://github.com/epeli/underscore.string/blob/master/underscored.js
2016-05-17 17:02:40 +00:00
function underscored ( str ) {
2015-08-05 07:28:47 +00:00
return str . trim ( ) . replace ( /([a-z\d])([A-Z]+)/g , '$1_$2' ) . replace ( /[-\s]+/g , '_' ) . toLowerCase ( ) ;
}
2016-05-17 17:02:40 +00:00
function toCamelCase ( str ) {
2015-09-17 18:39:51 +00:00
return str
. replace ( /\s(.)/g , function ( $1 ) { return $1 . toUpperCase ( ) ; } )
. replace ( /\s/g , '' )
. replace ( /^(.)/ , function ( $1 ) { return $1 . toUpperCase ( ) ; } ) ;
} ;
2016-05-27 13:30:36 +00:00
function isRetina ( ) {
if ( window . matchMedia ) {
var mq = window . matchMedia ( "only screen and (min--moz-device-pixel-ratio: 1.3), only screen and (-o-min-device-pixel-ratio: 2.6/2), only screen and (-webkit-min-device-pixel-ratio: 1.3), only screen and (min-device-pixel-ratio: 1.3), only screen and (min-resolution: 1.3dppx)" ) ;
return ( mq && mq . matches || ( window . devicePixelRatio > 1 ) ) ;
}
}
2013-07-22 22:41:13 +00:00
jQuery . event . special . remove = {
remove : function ( e ) {
if ( e . handler ) e . handler ( ) ;
}
} ;
2013-08-14 08:05:23 +00:00
2016-03-03 11:16:19 +00:00
// checkbox-replacement helper
// native checkbox focus behaviour is the following:
// tab to checkbox: :focus state and focus outline
// click on checkbox: :focus state but no focus outline
2016-05-12 13:22:34 +00:00
$ ( 'body' ) . on ( 'click' , '.checkbox-replacement, .radio-replacement' , function ( event ) {
2016-03-03 11:16:19 +00:00
$ ( event . currentTarget ) . find ( 'input' ) . addClass ( 'is-active' )
} ) ;
2016-05-12 13:22:34 +00:00
$ ( 'body' ) . on ( 'blur' , '.checkbox-replacement input, .radio-replacement input' , function ( ) {
2016-03-03 11:16:19 +00:00
$ ( this ) . removeClass ( 'is-active' )
} ) ;
2016-05-12 13:22:34 +00:00
// remove attributes by regex
// http://stackoverflow.com/questions/8968767/remove-multiple-html5-data-attributes-with-jquery
jQuery . fn . removeAttrs = function ( regex ) {
return this . each ( function ( ) {
var $this = $ ( this ) ,
names = [ ] ;
$ . each ( this . attributes , function ( i , attr ) {
if ( attr && attr . specified && regex . test ( attr . name ) ) {
$this . removeAttr ( attr . name ) ;
}
} ) ;
} ) ;
} ;
2016-05-28 21:17:59 +00:00
// based on jquery serializeArray
// changes
// - set type based on data('field-type')
// - also catch [disabled] params
jQuery . fn . extend ( {
serializeArrayWithType : function ( ) {
var r20 = /%20/g ,
rbracket = /\[\]$/ ,
rCRLF = /\r?\n/g ,
rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i ,
rsubmittable = /^(?:input|select|textarea|keygen)/i ;
var rcheckableType = ( /^(?:checkbox|radio)$/i ) ;
return this . map ( function ( ) {
2020-08-04 09:48:25 +00:00
// We dont use jQuery.prop( this, "elements" ); here anymore
// because it did not work out for IE 11
var elements = $ ( this ) . find ( '*' ) . filter ( ':input' ) ;
2016-05-28 21:17:59 +00:00
return elements ? jQuery . makeArray ( elements ) : this ;
} )
. filter ( function ( ) {
var type = this . type ;
return this . name &&
rsubmittable . test ( this . nodeName ) && ! rsubmitterTypes . test ( type ) &&
( this . checked || ! rcheckableType . test ( type ) ) ;
} )
. map ( function ( i , elem ) {
var $elem = jQuery ( this ) ;
var val = $elem . val ( ) ;
var type = $elem . data ( 'field-type' ) ;
2017-05-29 11:49:17 +00:00
var result ;
if ( val == null ) {
// be sure that also null values are transfered
// https://github.com/zammad/zammad/issues/944
if ( $elem . prop ( 'multiple' ) ) {
result = { name : elem . name , value : null , type : type } ;
}
else {
result = null
}
}
else if ( jQuery . isArray ( val ) ) {
result = jQuery . map ( val , function ( val ) {
return { name : elem . name , value : val . replace ( rCRLF , "\r\n" ) , type : type } ;
} ) ;
}
else {
result = { name : elem . name , value : val . replace ( rCRLF , "\r\n" ) , type : type } ;
}
return result ;
2016-05-28 21:17:59 +00:00
} ) . get ( ) ;
}
} ) ;
2013-08-14 08:05:23 +00:00
// start application
jQuery ( function ( ) {
new App . Run ( ) ;
2015-09-28 17:52:27 +00:00
} ) ;