window.eGovUtilities = setup: ()-> # select2 defaults $.fn.select2.defaults.set( "theme", "bootstrap" ) # datepicker defaults $.extend $.fn.datetimepicker.defaults.icons, { time: 'fa fa-clock-o', date: 'fa fa-calendar', up: 'fa fa-chevron-up', down: 'fa fa-chevron-down', previous: 'fa fa-chevron-left', next: 'fa fa-chevron-right', today: 'fa fa-calendar-check-o', clear: 'fa fa-trash-o', close: 'fa fa-close' } initPage: ($container)-> $container ||= $(document) eGovUtilities.initDatepickers($container) eGovUtilities.initSelect2($container) initDatepickers: ($container)-> $container ||= $(document) if !Modernizr.inputtypes.date pickers = $('[type="date"][data-provide="datepicker"]', $container) pickers.parent().datetimepicker() if !Modernizr.inputtypes.datetime pickers = $('[type="datetime"][data-provide="datepicker"]', $container) pickers.parent().datetimepicker() if !Modernizr.inputtypes['datetime-local'] pickers = $('[type="datetime-local"][data-provide="datepicker"]', $container) pickers.parent().datetimepicker() initSelect2: ($container)-> $container ||= $(document) $('[data-provide="select2"]', $container).each (i, el)-> $(el).select2() initModal: (modalId, options)-> options = options || {} modalId = modalId || 'modal' $modal = $('#'+modalId) if $modal.length != 1 $modal = $('