define(function(require){var elgg=require('elgg');var $=require('jquery');require('jquery-ui');var i18n_ready=$.Deferred();if(elgg.get_language()=== 'en'){i18n_ready.resolve();}else{require(['jquery-ui/i18n/datepicker-'+elgg.get_language()+ '.min'], function(){i18n_ready.resolve();}, function(){i18n_ready.resolve();});}var datepicker={init:function(selector){if(!$(selector).length){return;}var defaults={dateFormat: 'yy-mm-dd', nextText: '»', prevText: '«', changeMonth:true, changeYear:true};$(selector).each(function(){var $elem=$(this);var opts=$elem.data('datepickerOpts')||{};opts=$.extend({}, defaults, opts);opts.onSelect=function(dateText, instance){if($(this).is('.elgg-input-timestamp')){timestamp= '';if(dateText.length){var timestamp=Date.UTC(instance.selectedYear, instance.selectedMonth, instance.selectedDay);timestamp=timestamp/1000;}$('input[rel="' + this.id + '"]').val(timestamp);}};i18n_ready.then(function(){$elem.datepicker(opts);$elem.on('keyup', function(event){switch(event.keyCode){case $.ui.keyCode.DELETE:case $.ui.keyCode.BACKSPACE:$.datepicker._clearDate(event.target);break;}});});});}};return datepicker;})