Changeset 28500 for trunk/admin/themes
- Timestamp:
- May 18, 2014, 12:58:53 PM (10 years ago)
- Location:
- trunk/admin/themes/default
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/themes/default/js/datepicker.js
r28497 r28500 1 jQuery.timepicker.log = jQuery.noop; // that's ugly, but the timepicker is acting weird and throws parsing errors 2 1 3 jQuery.fn.pwgDatepicker = function(options) { 2 4 options = options || {}; … … 5 7 var $this = jQuery(this), 6 8 $target = jQuery('[name="'+ jQuery(this).data('datepicker') +'"]'), 7 value = $target.val().split('-');9 linked = !!$target.length; 8 10 9 function set(date) { 10 $this.datepicker('setDate', date); 11 if (linked) { // get value before init 12 var value = $target.val().split(' '); 13 } 14 15 // custom setter 16 function set(date, init) { 17 $this.datetimepicker('setDate', date); 11 18 12 19 if ($this.data('datepicker-start')) { 13 $start.date picker('option', 'maxDate', date);20 $start.datetimepicker('option', 'maxDate', date); 14 21 } 15 22 else if ($this.data('datepicker-end')) { 16 $end.datepicker('option', 'minDate', date); 23 if (!init) { // on init, "end" is not initialized yet (assuming "start" is before "end" in the DOM) 24 $end.datetimepicker('option', 'minDate', date); 25 } 26 } 27 28 if (!date && linked) { 29 $target.val(''); 17 30 } 18 31 } 19 32 20 33 // init picker 21 $this.datepicker(jQuery.extend({ 22 dateFormat: 'DD d MM yy', 23 altField: $target, 34 $this.datetimepicker(jQuery.extend({ 35 dateFormat: linked ? 'DD d MM yy' : 'yy-mm-dd', 36 timeFormat: 'HH:mm', 37 38 altField: linked ? $target : null, 24 39 altFormat: 'yy-mm-dd', 40 altTimeFormat: options.showTimepicker ? 'HH:mm:ss' : '', 41 25 42 autoSize: true, 26 43 changeMonth : true, 27 changeYear: true 44 changeYear: true, 45 showTimepicker: false, 46 altFieldTimeOnly: false, 47 showSecond: false, 48 alwaysSetTime: false, 49 stepMinute: 5 28 50 }, options)); 29 51 30 // attach linked picker (for ranges)52 // attach range pickers 31 53 if ($this.data('datepicker-start')) { 32 54 var $start = jQuery('[data-datepicker="'+ jQuery(this).data('datepicker-start') +'"]'); 33 55 34 $this.date picker('option', 'onClose', function(date) {35 $start.date picker('option', 'maxDate', date);56 $this.datetimepicker('option', 'onClose', function(date) { 57 $start.datetimepicker('option', 'maxDate', date); 36 58 }); 59 60 $this.datetimepicker('option', 'minDate', $start.datetimepicker('getDate')); 37 61 } 38 62 else if ($this.data('datepicker-end')) { 39 63 var $end = jQuery('[data-datepicker="'+ jQuery(this).data('datepicker-end') +'"]'); 40 64 41 $this.date picker('option', 'onClose', function(date) {42 $end.date picker('option', 'minDate', date);65 $this.datetimepicker('option', 'onClose', function(date) { 66 $end.datetimepicker('option', 'minDate', date); 43 67 }); 44 68 } … … 48 72 jQuery('#'+ $this.data('datepicker-unset')).on('click', function(e) { 49 73 e.preventDefault(); 50 51 $target.val(''); 52 set(null); 74 set(null, false); 53 75 }); 54 76 } 55 77 56 78 // set value from linked input 57 if (value.length == 3) { 58 set(new Date(value[0], value[1]-1, value[2])); 79 if (linked) { 80 if (value[0].length == 10 && !options.showTimepicker) { 81 set(jQuery.datepicker.parseDate('yy-mm-dd', value[0]), true); 82 } 83 else if (value.length == 2 && options.showTimepicker) { 84 set(jQuery.datepicker.parseDateTime('yy-mm-dd', 'HH:mm:ss', value.join(' ')), true); 85 } 86 else { 87 set(null, true); 88 } 89 } 90 91 // autoSize not handled by timepicker 92 if (options.showTimepicker) { 93 $this.attr('size', parseInt($this.attr('size'))+6); 59 94 } 60 95 }); -
trunk/admin/themes/default/template/batch_manager_global.tpl
r28497 r28500 61 61 {footer_script require='jquery.tokeninput'} 62 62 jQuery(document).ready(function() {ldelim} 63 jQuery('[data-datepicker]').pwgDatepicker( );63 jQuery('[data-datepicker]').pwgDatepicker({ showTimepicker: true }); 64 64 65 65 jQuery("a.preview-box").colorbox(); -
trunk/admin/themes/default/template/batch_manager_unit.tpl
r28497 r28500 52 52 {* <!-- DATEPICKER --> *} 53 53 jQuery(function(){ {* <!-- onLoad needed to wait localization loads --> *} 54 jQuery('[data-datepicker]').pwgDatepicker( );54 jQuery('[data-datepicker]').pwgDatepicker({ showTimepicker: true }); 55 55 }); 56 56 -
trunk/admin/themes/default/template/include/datepicker.inc.tpl
r28497 r28500 1 {combine_script id='datepicker.js' load='footer' require='jquery.ui.datepicker' path='admin/themes/default/js/datepicker.js'} 1 {combine_script id='jquery.ui.timepicker-addon' load='footer' require='jquery.ui.datepicker,jquery.ui.slider' path="themes/default/js/ui/jquery.ui.timepicker-addon.js"} 2 {combine_script id='datepicker.js' load='footer' require='jquery.ui.timepicker-addon' path='admin/themes/default/js/datepicker.js'} 2 3 3 4 {assign var="datepicker_language" value="themes/default/js/ui/i18n/jquery.ui.datepicker-`$lang_info.code`.js"} 4 5 5 {if "PHPWG_ROOT_PATH"|@constant|@cat:$datepicker_language|@file_exists} 6 {combine_script id="jquery.ui.datepicker-$lang_info.code" load='footer' path=$datepicker_language}6 {combine_script id="jquery.ui.datepicker-$lang_info.code" load='footer' require='jquery.ui.datepicker' path=$datepicker_language} 7 7 {/if} 8 8 9 {assign var="timepicker_language" value="themes/default/js/ui/i18n/jquery.ui.timepicker-`$lang_info.code`.js"} 10 {if "PHPWG_ROOT_PATH"|@constant|@cat:$datepicker_language|@file_exists} 11 {combine_script id="jquery.ui.timepicker-$lang_info.code" load='footer' require='jquery.ui.timepicker-addon' path=$timepicker_language} 12 {/if} 13 14 {combine_css path="themes/default/js/ui/theme/jquery.ui.slider.css"} 9 15 {combine_css path="themes/default/js/ui/theme/jquery.ui.datepicker.css"} 16 {combine_css path="themes/default/js/ui/theme/jquery.ui.timepicker-addon.css"} -
trunk/admin/themes/default/template/picture_modify.tpl
r28497 r28500 78 78 {* <!-- DATEPICKER --> *} 79 79 jQuery(function(){ {* <!-- onLoad needed to wait localization loads --> *} 80 jQuery('[data-datepicker]').pwgDatepicker( );80 jQuery('[data-datepicker]').pwgDatepicker({ showTimepicker: true }); 81 81 }); 82 82 }()); … … 141 141 <strong>{'Creation date'|@translate}</strong> 142 142 <br> 143 <input type="hidden" name="date_creation_time" value="{$DATE_CREATION_TIME}">144 143 <input type="hidden" name="date_creation" value="{$DATE_CREATION}"> 145 144 <label>
Note: See TracChangeset
for help on using the changeset viewer.