|
14 | 14 | var uniqueId = 0; // used for unique ID generation within multiple plugin instances |
15 | 15 |
|
16 | 16 | $.widget('comiseo.daterangepicker', { |
17 | | -version: '0.3.5', |
| 17 | +version: '0.4.0', |
18 | 18 |
|
19 | 19 | options: { |
20 | 20 | // presetRanges: array of objects; each object describes an item in the presets menu |
|
33 | 33 | initialText: 'Select date range...', // placeholder text - shown when nothing is selected |
34 | 34 | icon: 'ui-icon-triangle-1-s', |
35 | 35 | applyButtonText: 'Apply', |
| 36 | +clearButtonText: 'Clear', |
36 | 37 | cancelButtonText: 'Cancel', |
37 | 38 | rangeSplitter: ' - ', // string to use between dates |
38 | 39 | dateFormat: 'M d, yy', // displayed date format. Available formats: http://api.jqueryui.com/datepicker/#utility-formatDate |
|
268 | 269 | function buildButtonPanel(classnameContext, options, handlers) { |
269 | 270 | var $self, |
270 | 271 | applyButton, |
| 272 | +clearButton, |
271 | 273 | cancelButton; |
272 | 274 |
|
273 | 275 | function init() { |
274 | 276 | applyButton = $('<button type="button" class="ui-priority-primary"></button>') |
275 | 277 | .text(options.applyButtonText) |
276 | 278 | .button(); |
| 279 | +clearButton = $('<button type="button" class="ui-priority-secondary"></button>') |
| 280 | +.text(options.clearButtonText) |
| 281 | +.button(); |
277 | 282 | cancelButton = $('<button type="button" class="ui-priority-secondary"></button>') |
278 | 283 | .text(options.cancelButtonText) |
279 | 284 | .button(); |
280 | 285 |
|
281 | 286 | $self = $('<div></div>') |
282 | 287 | .addClass(classnameContext + '-buttonpanel') |
283 | 288 | .append(applyButton) |
| 289 | +.append(clearButton) |
284 | 290 | .append(cancelButton); |
285 | 291 |
|
286 | 292 | bindEvents(); |
|
289 | 295 | function bindEvents() { |
290 | 296 | if (handlers) { |
291 | 297 | applyButton.click(handlers.onApply); |
| 298 | +clearButton.click(handlers.onClear); |
292 | 299 | cancelButton.click(handlers.onCancel); |
293 | 300 | } |
294 | 301 | } |
|
336 | 343 | close(); |
337 | 344 | setRange(); |
338 | 345 | }, |
| 346 | +onClear: function() { |
| 347 | +close(); |
| 348 | +clearRange(); |
| 349 | +}, |
339 | 350 | onCancel: function() { |
340 | 351 | close(); |
341 | 352 | reset(); |
|
461 | 472 | function clearRange() { |
462 | 473 | triggerButton.reset(); |
463 | 474 | calendar.reset(); |
| 475 | +$originalElement.val(''); |
464 | 476 | } |
465 | 477 |
|
466 | 478 | // callback - used when the user clicks a preset range |
|
0 commit comments