Elgg  Version 2.3
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  timestamp = '';
56  if (dateText.length) {
57  // convert to unix timestamp
58  var timestamp = Date.UTC(instance.selectedYear, instance.selectedMonth, instance.selectedDay);
59  timestamp = timestamp / 1000;
60  }
61  $('input[rel="' + this.id + '"]').val(timestamp);
62  }
63  };
64 
65  // defer until language loaded
66  i18n_ready.then(function () {
67  $elem.datepicker(opts);
68  $elem.on('keyup', function(event) {
69  switch (event.keyCode) {
70  case $.ui.keyCode.DELETE:
71  case $.ui.keyCode.BACKSPACE:
72  $.datepicker._clearDate(event.target);
73  break;
74  }
75  });
76  });
77  });
78  }
79  };
80 
81  return datepicker;
82 });
elgg
Definition: install.js:23
elgg comments init
Initialize comment inline editing.
Definition: comments.js:122
fn editable defaults
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;})
ui datepicker
Definition: admin.css.php:639
elgg require
Throw an error if the required package isn't present.
Definition: elgglib.js:164