Elgg  Version 2.2
date.js
Go to the documentation of this file.
1 define(function (require) {
2 
3  var elgg = require('elgg');
4  var $ = require('jquery');
5  require('jquery-ui');
6 
7  // the language module may need loading
8  var i18n_ready = $.Deferred();
9  if (elgg.get_language() === 'en') {
10  i18n_ready.resolve();
11  } else {
12  require(['jquery-ui/i18n/datepicker-' + elgg.get_language() + '.min'], function () {
13  i18n_ready.resolve();
14  }, function () {
15  // if load fails (e.g. lang code mismatch), carry on with English
16  i18n_ready.resolve();
17  });
18  }
19 
20  var datepicker = {
36  init: function (selector) {
37  if (!$(selector).length) {
38  return;
39  }
40  var defaults = {
41  dateFormat: 'yy-mm-dd',
42  nextText: '»',
43  prevText: '«',
44  changeMonth: true,
45  changeYear: true
46  };
47 
48  $(selector).each(function () {
49  var $elem = $(this);
50  var opts = $elem.data('datepickerOpts') || {};
51  opts = $.extend({}, defaults, opts);
52 
53  opts.onSelect = function (dateText, instance) {
54  if ($(this).is('.elgg-input-timestamp')) {
55  // convert to unix timestamp
56  var timestamp = Date.UTC(instance.selectedYear, instance.selectedMonth, instance.selectedDay);
57  timestamp = timestamp / 1000;
58  $('input[rel="' + this.id + '"]').val(timestamp);
59  }
60  };
61 
62  // defer until language loaded
63  i18n_ready.then(function () {
64  $elem.datepicker(opts);
65  });
66  });
67  }
68  };
69 
70  return datepicker;
71 });
elgg
Definition: install.js:23
elgg comments init
Initialize comment inline editing.
Definition: comments.js:118
fn editable defaults
ui datepicker
Definition: admin.css.php:608
elgg require
Throw an error if the required package isn't present.
Definition: elgglib.js:164
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')){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);});});}};return datepicker;})