github.com/apremalal/vamps-core@v1.0.1-0.20161221121535-d430b56ec174/server/webapps/app/base/plugins/bootstrap-datetimepicker/README.md (about)

     1  # Project : bootstrap-datetimepicker
     2  ======================================
     3  
     4  [![Build Status](https://travis-ci.org/smalot/bootstrap-datetimepicker.png?branch=master)](https://travis-ci.org/smalot/bootstrap-datetimepicker)
     5  
     6  [Homepage](http://www.malot.fr/bootstrap-datetimepicker/)
     7  
     8  [Demo page](http://www.malot.fr/bootstrap-datetimepicker/demo.php)
     9  
    10  # Project forked
    11  
    12  This project is a fork of [bootstrap-datepicker project](https://github.com/eternicode/bootstrap-datepicker).
    13  
    14  
    15  # Home
    16  
    17  As 'bootstrap-datetimepicker' is restricted to the date scope (day, month, year), this project aims to support too the time picking (hour, minutes).
    18  
    19  
    20  # Screenshots
    21  
    22  ## Decade year view
    23  
    24  ![Datetimepicker decade year view](https://raw.github.com/smalot/bootstrap-datetimepicker/master/screenshot/standard_decade.png)
    25  
    26  This view allows to select the day in the selected month.
    27  
    28  ## Year view
    29  
    30  ![Datetimepicker year view](https://raw.github.com/smalot/bootstrap-datetimepicker/master/screenshot/standard_year.png)
    31  
    32  This view allows to select the month in the selected year.
    33  
    34  ## Month view
    35  
    36  ![Datetimepicker month view](https://raw.github.com/smalot/bootstrap-datetimepicker/master/screenshot/standard_month.png)
    37  
    38  This view allows to select the year in a range of 10 years.
    39  
    40  ## Day view
    41  
    42  ![Datetimepicker day view](https://raw.github.com/smalot/bootstrap-datetimepicker/master/screenshot/standard_day.png)
    43  
    44  This view allows to select the hour in the selected day.
    45  
    46  ## Hour view
    47  
    48  ![Datetimepicker hour view](https://raw.github.com/smalot/bootstrap-datetimepicker/master/screenshot/standard_hour.png)
    49  
    50  This view allows to select the preset of minutes in the selected hour.
    51  The range of 5 minutes (by default) has been selected to restrict buttons quantity to an acceptable value, but it can be overrided by the <code>minuteStep</code> property.
    52  
    53  ## Day view - meridian
    54  
    55  ![Datetimepicker day view meridian](https://raw.github.com/smalot/bootstrap-datetimepicker/master/screenshot/standard_day_meridian.png)
    56  
    57  Meridian is supported in both the day and hour views.
    58  To use it, just enable the <code>showMeridian</code> property.
    59  
    60  ## Hour view - meridian
    61  
    62  ![Datetimepicker hour view meridian](https://raw.github.com/smalot/bootstrap-datetimepicker/master/screenshot/standard_hour_meridian.png)
    63  
    64  # Example
    65  
    66  Attached to a field with the format specified via options:
    67  
    68  ```html
    69  <input type="text" value="2012-05-15 21:05" id="datetimepicker">
    70  ```
    71  ```javascript
    72  $('#datetimepicker').datetimepicker({
    73      format: 'yyyy-mm-dd hh:ii'
    74  });
    75  ```
    76  
    77  Attached to a field with the format specified via markup:
    78  
    79  ```html
    80  <input type="text" value="2012-05-15 21:05" id="datetimepicker" data-date-format="yyyy-mm-dd hh:ii">
    81  ```
    82  ```javascript
    83  $('#datetimepicker').datetimepicker();
    84  ```
    85  
    86  As component:
    87  
    88  ```html
    89  <div class="input-append date" id="datetimepicker" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
    90      <input size="16" type="text" value="12-02-2012" readonly>
    91      <span class="add-on"><i class="icon-th"></i></span>
    92  </div>
    93  ```
    94  ```javascript
    95  $('#datetimepicker').datetimepicker();
    96  ```
    97  
    98  As inline datetimepicker:
    99  
   100  ```html
   101  <div id="datetimepicker"></div>
   102  ```
   103  ```javascript
   104  $('#datetimepicker').datetimepicker();
   105  ```
   106  
   107  # Using bootstrap-datetimepicker.js
   108  
   109  Call the datetimepicker via javascript:
   110  
   111  ```javascript
   112  $('.datetimepicker').datetimepicker()
   113  ```
   114  
   115  ## Dependencies
   116  
   117  Requires bootstrap's dropdown component (`dropdowns.less`) for some styles, and bootstrap's sprites (`sprites.less` and associated images) for arrows.
   118  
   119  A standalone .css file (including necessary dropdown styles and alternative, text-based arrows) can be generated by running `build/build_standalone.less` through the `lessc` compiler:
   120  
   121  ```bash
   122  $ lessc build/build_standalone.less datetimepicker.css
   123  ```
   124  
   125  ## Options
   126  
   127  All options that take a "Date" can handle a `Date` object; a String formatted according to the given `format`; or a timedelta relative to today, eg '-1d', '+6m +1y', etc, where valid units are 'd' (day), 'w' (week), 'm' (month), and 'y' (year).
   128  
   129  You can also specify an ISO-8601 valid datetime, despite of the given `format` :
   130   * yyyy-mm-dd
   131   * yyyy-mm-dd hh:ii
   132   * yyyy-mm-ddThh:ii
   133   * yyyy-mm-dd hh:ii:ss
   134   * yyyy-mm-ddThh:ii:ssZ
   135  
   136  ### format
   137  
   138  String.  Default: 'mm/dd/yyyy'
   139  
   140  The date format, combination of p, P, h, hh, i, ii, s, ss, d, dd, m, mm, M, MM, yy, yyyy.
   141  
   142   * p : meridian in lower case ('am' or 'pm') - according to locale file
   143   * P : meridian in upper case ('AM' or 'PM') - according to locale file
   144   * s : seconds without leading zeros
   145   * ss : seconds, 2 digits with leading zeros
   146   * i : minutes without leading zeros
   147   * ii : minutes, 2 digits with leading zeros
   148   * h : hour without leading zeros - 24-hour format
   149   * hh : hour, 2 digits with leading zeros - 24-hour format
   150   * H : hour without leading zeros - 12-hour format
   151   * HH : hour, 2 digits with leading zeros - 12-hour format
   152   * d : day of the month without leading zeros
   153   * dd : day of the month, 2 digits with leading zeros
   154   * m : numeric representation of month without leading zeros
   155   * mm : numeric representation of the month, 2 digits with leading zeros
   156   * M : short textual representation of a month, three letters
   157   * MM : full textual representation of a month, such as January or March
   158   * yy : two digit representation of a year
   159   * yyyy : full numeric representation of a year, 4 digits
   160  
   161  ### weekStart
   162  
   163  Integer.  Default: 0
   164  
   165  Day of the week start. 0 (Sunday) to 6 (Saturday)
   166  
   167  ### startDate
   168  
   169  Date.  Default: Beginning of time
   170  
   171  The earliest date that may be selected; all earlier dates will be disabled.
   172  
   173  ### endDate
   174  
   175  Date.  Default: End of time
   176  
   177  The latest date that may be selected; all later dates will be disabled.
   178  
   179  ### daysOfWeekDisabled
   180  
   181  String, Array.  Default: '', []
   182  
   183  Days of the week that should be disabled. Values are 0 (Sunday) to 6 (Saturday). Multiple values should be comma-separated. Example: disable weekends: `'0,6'` or `[0,6]`.
   184  
   185  ### autoclose
   186  
   187  Boolean.  Default: false
   188  
   189  Whether or not to close the datetimepicker immediately when a date is selected.
   190  
   191  ### startView
   192  
   193  Number, String.  Default: 2, 'month'
   194  
   195  The view that the datetimepicker should show when it is opened.
   196  Accepts values of :
   197   * 0 or 'hour' for the hour view
   198   * 1 or 'day' for the day view
   199   * 2 or 'month' for month view (the default)
   200   * 3 or 'year' for the 12-month overview
   201   * 4 or 'decade' for the 10-year overview. Useful for date-of-birth datetimepickers.
   202  
   203  ### minView
   204  
   205  Number, String. Default: 0, 'hour'
   206  
   207  The lowest view that the datetimepicker should show.
   208  
   209  ### maxView
   210  
   211  Number, String. Default: 4, 'decade'
   212  
   213  The highest view that the datetimepicker should show.
   214  
   215  ### todayBtn
   216  
   217  Boolean, "linked".  Default: false
   218  
   219  If true or "linked", displays a "Today" button at the bottom of the datetimepicker to select the current date.  If true, the "Today" button will only move the current date into view; if "linked", the current date will also be selected.
   220  
   221  ### todayHighlight
   222  
   223  Boolean.  Default: false
   224  
   225  If true, highlights the current date.
   226  
   227  ### keyboardNavigation
   228  
   229  Boolean.  Default: true
   230  
   231  Whether or not to allow date navigation by arrow keys.
   232  
   233  ### language
   234  
   235  String.  Default: 'en'
   236  
   237  The two-letter code of the language to use for month and day names.  These will also be used as the input's value (and subsequently sent to the server in the case of form submissions).  Currently ships with English ('en'), German ('de'), Brazilian ('br'), and Spanish ('es') translations, but others can be added (see I18N below).  If an unknown language code is given, English will be used.
   238  
   239  ### forceParse
   240  
   241  Boolean.  Default: true
   242  
   243  Whether or not to force parsing of the input value when the picker is closed.  That is, when an invalid date is left in the input field by the user, the picker will forcibly parse that value, and set the input's value to the new, valid date, conforming to the given `format`.
   244  
   245  ### minuteStep
   246  
   247  Number.  Default: 5
   248  
   249  The increment used to build the hour view. A button is created for each <code>minuteStep</code> minutes.
   250  
   251  ### pickerReferer : deprecated
   252  
   253  String.  Default: 'default'
   254  
   255  The referer element to place the picker for the component implementation. If you want to place the picker just under the input field, just specify <code>input</code>.
   256  
   257  ### pickerPosition
   258  
   259  String. Default: 'bottom-right' (supported values are: 'bottom-right', 'bottom-left', 'top-right', 'top-left')
   260  
   261  This option allows to place the picker just under the input field for the component implementation instead of the default position which is at the bottom right of the button.
   262  
   263  ### viewSelect
   264  
   265  Number or String. Default: <code>same as minView</code> (supported values are: 'decade', 'year', 'month', 'day', 'hour')
   266  
   267  With this option you can select the view from which the date will be selected. By default it's the last one, however you can choose the first one, so at each click the date will be updated.
   268  
   269  ### showMeridian
   270  
   271  Boolean. Default: false
   272  
   273  This option will enable meridian views for day and hour views.
   274  
   275  ### initialDate
   276  
   277  Date or String. Default: new Date()
   278  
   279  You can initialize the viewer with a date. By default it's now, so you can specify yesterday or today at midnight ...
   280  
   281  ## Markup
   282  
   283  Format as component.
   284  
   285  ```html
   286  <div class="input-append date" id="datetimepicker" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
   287      <input class="span2" size="16" type="text" value="12-02-2012">
   288      <span class="add-on"><i class="icon-th"></i></span>
   289  </div>
   290  ```
   291  
   292  Format as component with reset button to clear the input field.
   293  
   294  ```html
   295  <div class="input-append date" id="datetimepicker" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
   296      <input class="span2" size="16" type="text" value="12-02-2012">
   297      <span class="add-on"><i class="icon-remove"></i></span>
   298      <span class="add-on"><i class="icon-th"></i></span>
   299  </div>
   300  ```
   301  
   302  ## Methods
   303  
   304  ### .datetimepicker(options)
   305  
   306  Initializes an datetimepicker.
   307  
   308  ### remove
   309  
   310  Arguments: None
   311  
   312  Remove the datetimepicker.  Removes attached events, internal attached objects, and
   313  added HTML elements.
   314  
   315      $('#datetimepicker').datetimepicker('remove');
   316  
   317  ### show
   318  
   319  Arguments: None
   320  
   321  Show the datetimepicker.
   322  
   323  ```javascript
   324  $('#datetimepicker').datetimepicker('show');
   325  ```
   326  
   327  ### hide
   328  
   329  Arguments: None
   330  
   331  Hide the datetimepicker.
   332  
   333  ```javascript
   334  $('#datetimepicker').datetimepicker('hide');
   335  ```
   336  
   337  ### update
   338  
   339  Arguments: 
   340  
   341  * currentDate (Date).
   342  
   343  Update the datetimepicker with the specified date.
   344  
   345  ```javascript
   346  $('#datetimepicker').datetimepicker('update', new Date());
   347  ```
   348  
   349  Omit currentDate to update the datetimepicker with the current input value.
   350  
   351  ```javascript
   352  $('#datetimepicker').datetimepicker('update');
   353  ```
   354  
   355  ### setStartDate
   356  
   357  Arguments:
   358  
   359  * startDate (String)
   360  
   361  Sets a new lower date limit on the datetimepicker.
   362  
   363  ```javascript
   364  $('#datetimepicker').datetimepicker('setStartDate', '2012-01-01');
   365  ```
   366  
   367  Omit startDate (or provide an otherwise falsey value) to unset the limit.
   368  
   369  ```javascript
   370  $('#datetimepicker').datetimepicker('setStartDate');
   371  $('#datetimepicker').datetimepicker('setStartDate', null);
   372  ```
   373  
   374  ### setEndDate
   375  
   376  Arguments:
   377  
   378  * endDate (String)
   379  
   380  Sets a new upper date limit on the datetimepicker.
   381  
   382  ```javascript
   383  $('#datetimepicker').datetimepicker('setEndDate', '2012-12-31');
   384  ```
   385  
   386  Omit endDate (or provide an otherwise falsey value) to unset the limit.
   387  
   388  ```javascript
   389  $('#datetimepicker').datetimepicker('setEndDate');
   390  $('#datetimepicker').datetimepicker('setEndDate', null);
   391  ```
   392  
   393  ### setDaysOfWeekDisabled
   394  
   395  Arguments:
   396  
   397  * daysOfWeekDisabled (String|Array)
   398  
   399  Sets the days of week that should be disabled.
   400  
   401  ```javascript
   402  $('#datetimepicker').datetimepicker('setDaysOfWeekDisabled', [0,6]);
   403  ```
   404  
   405  Omit daysOfWeekDisabled (or provide an otherwise falsey value) to unset the disabled days.
   406  
   407  ```javascript
   408  $('#datetimepicker').datetimepicker('setDaysOfWeekDisabled');
   409  $('#datetimepicker').datetimepicker('setDaysOfWeekDisabled', null);
   410  ```
   411  
   412  ## Events
   413  
   414  Datetimepicker class exposes a few events for manipulating the dates.
   415  
   416  ### show
   417  
   418  Fired when the date picker is displayed.
   419  
   420  ### hide
   421  
   422  Fired when the date picker is hidden.
   423  
   424  ### changeDate
   425  
   426  Fired when the date is changed.
   427  
   428  ```javascript
   429  $('#date-end')
   430      .datetimepicker()
   431      .on('changeDate', function(ev){
   432          if (ev.date.valueOf() < date-start-display.valueOf()){
   433              ....
   434          }
   435      });
   436  ```
   437  
   438  ### changeYear
   439  
   440  Fired when the *view* year is changed from decade view.
   441  
   442  ### changeMonth
   443  
   444  Fired when the *view* month is changed from year view.
   445  
   446  ### outOfRange
   447  
   448  Fired when you pick a date before the *startDate* or after the *endDate* or when you specify a date via the method *setDate* or *setUTCDate*..
   449  
   450  ## Keyboard support
   451  
   452  The datetimepicker includes some keyboard navigation:
   453  
   454  
   455  
   456  ### up, down, left, right arrow keys
   457  
   458  By themselves, left/right will move backward/forward one day, up/down will move back/forward one week.
   459  
   460  With the shift key, up/left will move backward one month, down/right will move forward one month.
   461  
   462  With the ctrl key, up/left will move backward one year, down/right will move forward oone year.
   463  
   464  Shift+ctrl behaves the same as ctrl -- that is, it does not change both month and year simultaneously, only the year.
   465  
   466  ### escape
   467  
   468  The escape key can be used to hide and re-show the datetimepicker; this is necessary if the user wants to manually edit the value.
   469  
   470  ### enter
   471  
   472  When the picker is visible, enter will simply hide it.  When the picker is not visible, enter will have normal effects -- submitting the current form, etc.
   473  
   474  ## Mouse Wheel View Navigation
   475  
   476  In order to make this plugin easier to set different part of date time, mouse wheel has been used to navigate through different views. Scroll up your mouse wheel to navigate to the decade year view. Scroll down will lead to the minute view. 
   477  
   478  ### Dependency
   479  
   480  To enalbe this feature. [jQuery Mouse Wheel Plugin](https://github.com/brandonaaron/jquery-mousewheel) must be included before using this feature. 
   481  
   482  ### Options
   483  
   484  #### wheelViewModeNavigation
   485  
   486  Boolean.  Default: false
   487  
   488  Whether or not to enable navigating through different view mode using mouse wheel.
   489  
   490  #### wheelViewModeNavigationInverseDirection
   491  
   492  Boolean.  Default: false
   493  
   494  Whether or not to reverse the direction of scrolling. Default is scroll up to the decade view.
   495  
   496  #### wheelViewModeNavigationDelay
   497  
   498  Integer.  Default: 100
   499  
   500  Time delays between the next respond to the wheel command, it controls the speed between switching in different views. Unit is in million seconds.
   501  
   502  #### About viewSelect option
   503  
   504  The recommended value for viewSelect option is 4 when this feature is enable. That means you can easily update any the value in every view. This option value is applied in the demo page.
   505  
   506  ### Feature Demo
   507  
   508  A simple [Demo](http://lyonlai.github.io/bootstrap-datetimepicker/demo.html) page is given to show it's simple idea. 
   509  
   510  ## I18N
   511  
   512  The plugin supports i18n for the month and weekday names and the `weekStart` option.  The default is English ('en'); other available translations are avilable in the `js/locales/` directory, simply include your desired locale after the plugin.  To add more languages, simply add a key to `$.fn.datetimepicker.dates`, before calling `.datetimepicker()`.  Example:
   513  
   514  ```javascript
   515  $.fn.datetimepicker.dates['en'] = {
   516      days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
   517      daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
   518      daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
   519      months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
   520      monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
   521      today: "Today"
   522  };
   523  ```
   524  
   525  You can override the default date format in the language configuration with `format` attribute.
   526  Example:
   527  
   528  ```javascript
   529  $.fn.datetimepicker.dates['pt-BR'] = {
   530      format: 'dd/mm/yyyy'
   531  };
   532  ```
   533  
   534  Right-to-left languages may also include `rtl: true` to make the calendar display appropriately.
   535  
   536  If your browser (or those of your users) is displaying characters wrong, chances are the browser is loading the javascript file with a non-unicode encoding.  Simply add `charset="UTF-8"` to your `script` tag:
   537  
   538  ```html
   539  <script type="text/javascript" src="bootstrap-datetimepicker.de.js" charset="UTF-8"></script>
   540  ```