diff --git a/jquery.comiseo.daterangepicker.js b/jquery.comiseo.daterangepicker.js index e54a220d4c77df412aa7b3861807e8bd7e82053b..8e6cefc9ecbeb22dd5c6c5ac1215fb3bf93d31da 100644 --- a/jquery.comiseo.daterangepicker.js +++ b/jquery.comiseo.daterangepicker.js @@ -14,7 +14,7 @@ var uniqueId = 0; // used for unique ID generation within multiple plugin instances $.widget('comiseo.daterangepicker', { - version: '0.3.5', + version: '0.4.0', options: { // presetRanges: array of objects; each object describes an item in the presets menu @@ -33,6 +33,7 @@ initialText: 'Select date range...', // placeholder text - shown when nothing is selected icon: 'ui-icon-triangle-1-s', applyButtonText: 'Apply', + clearButtonText: 'Clear', cancelButtonText: 'Cancel', rangeSplitter: ' - ', // string to use between dates dateFormat: 'M d, yy', // displayed date format. Available formats: http://api.jqueryui.com/datepicker/#utility-formatDate @@ -268,12 +269,16 @@ function buildButtonPanel(classnameContext, options, handlers) { var $self, applyButton, + clearButton, cancelButton; function init() { applyButton = $('<button type="button" class="ui-priority-primary"></button>') .text(options.applyButtonText) .button(); + clearButton = $('<button type="button" class="ui-priority-secondary"></button>') + .text(options.clearButtonText) + .button(); cancelButton = $('<button type="button" class="ui-priority-secondary"></button>') .text(options.cancelButtonText) .button(); @@ -281,6 +286,7 @@ $self = $('<div></div>') .addClass(classnameContext + '-buttonpanel') .append(applyButton) + .append(clearButton) .append(cancelButton); bindEvents(); @@ -289,6 +295,7 @@ function bindEvents() { if (handlers) { applyButton.click(handlers.onApply); + clearButton.click(handlers.onClear); cancelButton.click(handlers.onCancel); } } @@ -336,6 +343,10 @@ close(); setRange(); }, + onClear: function() { + close(); + clearRange(); + }, onCancel: function() { close(); reset(); @@ -461,6 +472,7 @@ function clearRange() { triggerButton.reset(); calendar.reset(); + $originalElement.val(''); } // callback - used when the user clicks a preset range