=========
MonthYear
=========

All necessary components are set up in the testclass to make sure that
we test the real configuration. Let's test the Widget:

  >>> import datetime
  >>> import z3c.form
  >>> import zope.schema
  >>> from plone.formwidget.datetime.z3cform import MonthYearFieldWidget

  >>> request = self.testrequest()
  >>> field = zope.schema.Date(default=datetime.date(2007, 4, 1))
  >>> widget = MonthYearFieldWidget(field, request)
  >>> widget.id = 'foo'
  >>> widget.name = 'bar'
  >>> widget.update()
  >>> widget.extract() is z3c.form.interfaces.NOVALUE
  True


INPUT_MODE
----------

  >>> print widget.render()
  <BLANKLINE>
  <BLANKLINE>
  <input type="hidden" id="foo-day" name="bar-day" class="monthyear-widget required date-field" size="2" maxlength="2" onchange="updateCalendar('#foo');" value="1" />
  <select id="foo-month" name="bar-month" class="monthyear-widget required date-field" onchange="updateCalendar('#foo');">
      <option value="1">January</option>
      <option value="2">February</option>
      <option value="3">March</option>
      <option value="4" selected="selected">April</option>
      <option value="5">May</option>
      <option value="6">June</option>
      <option value="7">July</option>
      <option value="8">August</option>
      <option value="9">September</option>
      <option value="10">October</option>
      <option value="11">November</option>
      <option value="12">December</option>
  </select> /
  <input type="text" id="foo-year" name="bar-year" class="monthyear-widget required date-field" alt="" accesskey="" size="4" maxlength="4" onchange="updateCalendar('#foo');" value="2007" />
  <input name="bar-empty-marker" type="hidden" value="1" />
  <BLANKLINE>
  <BLANKLINE>
              <input type="hidden"
                  id="foo-calendar"
                  name="bar-calendar"
                  class="bar-calendar" />
              <script type="text/javascript">
                  if (jQuery().dateinput) {
                      jQuery.tools.dateinput.localize("en", {months: "January,February,March,April,May,June,July,August,September,October,November,December",shortMonths: "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec",days: "Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday",shortDays: "Mon,Tue,Wed,Thu,Fri,Sat,Sun"});
                      jQuery("#foo-calendar").dateinput({lang: "en", value: new Date(2007, 4, 1), change: function() {
    var value = this.getValue("yyyy-m-d").split("-");
    jQuery("#foo-year").val(value[0]);
    jQuery("#foo-month").val(value[1]);
    jQuery("#foo-day").val(value[2]);
  }, selectors: true, trigger: true, yearRange: [-10, 10]}).unbind('change')
                          .bind('onShow', function (event) {
                              var trigger_offset = jQuery(this).next().offset();
                              jQuery(this).data('dateinput').getCalendar().offset(
                                  {top: trigger_offset.top+20, left: trigger_offset.left}
                              );
                          });
                      jQuery("#foo-calendar").next().css({'width': '16px', 'vertical-align': 'middle', 'display': 'inline-block', 'background': 'url(popup_calendar.gif)', 'height': '16px'});
                  }
  <BLANKLINE>
                  function updateCalendar(widgetId) {
                      var y = jQuery(widgetId + '-year').val();
                      var m = jQuery(widgetId + '-month').val();
                      var d = jQuery(widgetId + '-day').val();
                      jQuery(widgetId + '-calendar').val(m + '/' + d + '/' + y);
                      jQuery(widgetId + '-calendar').data()['dateinput'].setValue(new Date(m + '/' + d + '/' + y));
                  }
                 </script>


  >>> widget.request = self.testrequest(
  ...     form={'bar-day': '1',
  ...           'bar-month': '4',
  ...           'bar-year': '2007',
  ...           'bar-empty-marker': '1',
  ...           }
  ...     )
  >>> widget.extract()
  ('2007', '4', '1')


DISPLAY_MODE
------------

  >>> widget.mode = z3c.form.interfaces.DISPLAY_MODE
  >>> print widget.render()
  <span id="foo" class="monthyear-widget required date-field">4/1/07</span>


HIDDEN_MODE
-----------

  >>> widget.mode = z3c.form.interfaces.HIDDEN_MODE
  >>> print widget.render()
  <input type="hidden" id="foo" name="bar"
           class="hidden-widget" value="4/1/07" />
  >>> widget.request = self.testrequest(
  ...     form={'bar': '4/1/07'}
  ...     )
  >>> widget.extract()
  ('2007', '4', '1')
