Elgg  Version 2.3
Functions
date.js File Reference

Go to the source code of this file.

Functions

 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;})
 

Function Documentation

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;}  )
Parameters
function(require){varelgg=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(!.length){return;}var defaults={dateFormat: 'yy-mm-dd', nextText: '»', prevText: '«', changeMonth:true, changeYear:true};.each(function(){var $elem=;var opts=$elem.data('datepickerOpts')||{};opts=$.extend({}, defaults, opts);opts.onSelect=function(dateText, instance){if(.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;} Initialize the date picker on elements defined by the selector

If the class .elgg-input-timestamp is set on the element, the onSelect method converts the date text to a UNIX timestamp in seconds. That value is stored in a hidden element and submitted with the form. Note that the UNIX timestamp is normalized to start of the day at UTC, so you may need to use timezone offsets if you expect a different timezone. Timestamp is determined by the selected values of the datepicker instance, and is therefore agnostic to the dateFormat option.

Parameters
{string}selector Element selector
Returns
void jqueryui.datepicker