Changeset 28765
- Timestamp:
- Jun 22, 2014, 2:44:43 PM (10 years ago)
- Location:
- trunk/admin/themes/default
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/themes/default/js/datepicker.js
r28578 r28765 1 1 jQuery.timepicker.log = jQuery.noop; // that's ugly, but the timepicker is acting weird and throws parsing errors 2 2 3 jQuery.fn.pwgDatepicker = function(options) { 4 options = options || {}; 5 3 jQuery.fn.pwgDatepicker = function(settings) { 4 var options = jQuery.extend(true, { 5 showTimepicker: false, 6 cancelButton: false, 7 }, settings || {}); 8 6 9 return this.each(function() { 7 10 var $this = jQuery(this), 8 $target = jQuery('[name="'+ jQuery(this).data('datepicker') +'"]'), 9 linked = !!$target.length; 11 originalValue = $this.val(), 12 originalDate, 13 $target = jQuery('[name="'+ $this.data('datepicker') +'"]'), 14 linked = !!$target.length, 15 $start, $end; 10 16 11 if (linked) { // get value before init12 var value = $target.val().split(' ');17 if (linked) { 18 originalValue = $target.val(); 13 19 } 14 20 15 21 // custom setter 16 22 function set(date, init) { 23 if (date === '') date = null; 17 24 $this.datetimepicker('setDate', date); 18 25 19 if ($this.data('datepicker-start') ) {26 if ($this.data('datepicker-start') && $start) { 20 27 $start.datetimepicker('option', 'maxDate', date); 21 28 } 22 else if ($this.data('datepicker-end') ) {29 else if ($this.data('datepicker-end') && $end) { 23 30 if (!init) { // on init, "end" is not initialized yet (assuming "start" is before "end" in the DOM) 24 31 $end.datetimepicker('option', 'minDate', date); … … 29 36 $target.val(''); 30 37 } 38 } 39 40 // and custom cancel button 41 if (options.cancelButton) { 42 options.beforeShow = options.onChangeMonthYear = function() { 43 setTimeout(function() { 44 var buttonPane = $this.datepicker('widget') 45 .find('.ui-datepicker-buttonpane'); 46 47 if (buttonPane.find('.pwg-datepicker-cancel').length == 0) { 48 $('<button type="button">'+ options.cancelButton +'</button>') 49 .on('click', function() { 50 set(originalDate, false); 51 $this.datepicker('hide').blur(); 52 }) 53 .addClass('pwg-datepicker-cancel ui-state-error ui-corner-all') 54 .appendTo(buttonPane); 55 } 56 }, 1); 57 }; 31 58 } 32 59 … … 43 70 changeMonth : true, 44 71 changeYear: true, 45 showTimepicker: false,46 72 altFieldTimeOnly: false, 47 73 showSecond: false, 48 alwaysSetTime: false, 49 stepMinute: 5 74 alwaysSetTime: false 50 75 }, options)); 51 76 52 77 // attach range pickers 53 78 if ($this.data('datepicker-start')) { 54 var $start = jQuery('[data-datepicker="'+ jQuery(this).data('datepicker-start') +'"]');79 $start = jQuery('[data-datepicker="'+ $this.data('datepicker-start') +'"]'); 55 80 56 81 $this.datetimepicker('option', 'onClose', function(date) { … … 61 86 } 62 87 else if ($this.data('datepicker-end')) { 63 var $end = jQuery('[data-datepicker="'+ jQuery(this).data('datepicker-end') +'"]');88 $end = jQuery('[data-datepicker="'+ $this.data('datepicker-end') +'"]'); 64 89 65 90 $this.datetimepicker('option', 'onClose', function(date) { … … 78 103 // set value from linked input 79 104 if (linked) { 80 if (value[0].length == 10 && (!options.showTimepicker || value.length==1)) { 81 set(jQuery.datepicker.parseDate('yy-mm-dd', value[0]), true); 105 var splitted = originalValue.split(' '); 106 if (splitted.length == 2 && options.showTimepicker) { 107 set(jQuery.datepicker.parseDateTime('yy-mm-dd', 'HH:mm:ss', originalValue), true); 82 108 } 83 else if ( value.length == 2 && options.showTimepicker) {84 set(jQuery.datepicker.parseDate Time('yy-mm-dd', 'HH:mm:ss', value.join(' ')), true);109 else if (splitted[0].length == 10) { 110 set(jQuery.datepicker.parseDate('yy-mm-dd', splitted[0]), true); 85 111 } 86 112 else { … … 88 114 } 89 115 } 116 117 originalDate = $this.datetimepicker('getDate'); 90 118 91 119 // autoSize not handled by timepicker -
trunk/admin/themes/default/template/batch_manager_global.tpl
r28703 r28765 65 65 66 66 jQuery(document).ready(function() {ldelim} 67 jQuery('[data-datepicker]').pwgDatepicker({ showTimepicker: true }); 67 jQuery('[data-datepicker]').pwgDatepicker({ 68 showTimepicker: true, 69 cancelButton: '{'Cancel'|translate}' 70 }); 68 71 69 72 jQuery("a.preview-box").colorbox(); -
trunk/admin/themes/default/template/batch_manager_unit.tpl
r28703 r28765 24 24 {* <!-- DATEPICKER --> *} 25 25 jQuery(function(){ {* <!-- onLoad needed to wait localization loads --> *} 26 jQuery('[data-datepicker]').pwgDatepicker({ showTimepicker: true }); 26 jQuery('[data-datepicker]').pwgDatepicker({ 27 showTimepicker: true, 28 cancelButton: '{'Cancel'|translate}' 29 }); 27 30 }); 28 31 -
trunk/admin/themes/default/template/include/datepicker.inc.tpl
r28500 r28765 12 12 {/if} 13 13 14 {combine_css path="themes/default/js/ui/theme/jquery.ui.theme.css"} 14 15 {combine_css path="themes/default/js/ui/theme/jquery.ui.slider.css"} 15 16 {combine_css path="themes/default/js/ui/theme/jquery.ui.datepicker.css"} -
trunk/admin/themes/default/template/picture_modify.tpl
r28703 r28765 33 33 {* <!-- DATEPICKER --> *} 34 34 jQuery(function(){ {* <!-- onLoad needed to wait localization loads --> *} 35 jQuery('[data-datepicker]').pwgDatepicker({ showTimepicker: true }); 35 jQuery('[data-datepicker]').pwgDatepicker({ 36 showTimepicker: true, 37 cancelButton: '{'Cancel'|translate}' 38 }); 36 39 }); 37 40 }());
Note: See TracChangeset
for help on using the changeset viewer.