Hello,

I am wondering if it is possible to implement the "multiple" dates feature in JSCalendar library in the JSCalendar module.

Right now the code is available in the library, however is not currently implemented. Perhaps, when returning the dates from the JSCalendar module, separating the individual dates returned by an semicolon. (Example: 03/12/2007; 03/13/2007; 03/14/2007 etc.). Is this at all possible?

Thanks in advance.

Jeremy

Comments

nicolash’s picture

Ok, this the the POC...I haven't figured out how to feed the dates back to the calendar from a textfield when the node gets edited...it expects the date in some object form, I think. Anybody more familiar with this?


if (Drupal.jsEnabled) {
  $(document).ready(function() {
    $("textarea.jscalendar").each(function (){
      var id = $(this).id();
      var form = this.form;
      var button = document.createElement('button');
      $(button)
        .html(' ... ')
        .id(id + '-button')
        .addClass('jscalendar-icon');
      $(this)
        .after(button)
        .parent().addClass('jscalendar');

      // ADD: An empty array
      MA = [];
	  
      // ADD: A function to be fired when closing the calendar
      var closed = function() {
			//var el = document.getElementById("output");
			//el.innerHTML = "";
            var str = new String;
			for (var i in this.multiple) {
		        var d = this.multiple[i];
		        // sometimes the date is not actually selected, that's why we need to check.
		        if (d) {
                  str += d.print("%Y-%m-%d") + '\n';
		
		          // and push it in the "MA", in case one triggers the calendar again.
		          MA[MA.length] = d;
		        }
		    }
          // ADD: This is particular to my date field...would need to be generalized
          $('#edit-field-dates-0-value').val(str);
	      this.hide();
	      return true;
		}
      var settings = [];
      settings['ifFormat'] = $('#' + id + '-jscalendar-ifFormat', form).size() > 0 ? $('#' + this.id + '-jscalendar-ifFormat', form).val() : '%Y-%m-%d';
      // We use eval() because the result is a boolean while our input is a string.
      settings['showsTime'] = $('#' + id + '-jscalendar-showsTime', form).size() > 0 ? eval($('#' + this.id + '-jscalendar-showsTime', form).val()) : true;
      settings['timeFormat'] = $('#' + id + '-jscalendar-timeFormat', form).size() > 0 ? $('#' + this.id + '-jscalendar-timeFormat', form).val() : '12';
      Calendar.setup({
        inputField  : id,
        ifFormat    : settings['ifFormat'],
        button      : id + '-button',
        // ADD: The multiple option and the close function
        multiple    : MA,
        onClose     : closed,
      });
    });
  });
}

oliver soell’s picture

I definitely second this.. it would be super useful.
-o

nedjo’s picture

I'd definitely like to see this supported and welcome a patch.