1bez.ctl.task = function() { 2 var $task_form = jQuery('.bez_task_form'); 3 4 if ($task_form.length > 0) { 5 //date picker 6 jQuery("input[name=plan_date]").datepicker({ 7 dateFormat: "yy-mm-dd" 8 }); 9 if (jQuery("input[name=all_day_event]").is(":checked")) { 10 jQuery('#task_datapair').hide(); 11 } 12 jQuery("input[name=all_day_event]").on('change', function() { 13 if (jQuery(this).is(":checked")) { 14 jQuery('#task_datapair').hide(); 15 } else { 16 jQuery('#task_datapair').show(); 17 } 18 }); 19 20 //time picker 21 jQuery('#task_datapair .time').timepicker({ 22 'showDuration': true, 23 'timeFormat': 'H:i' 24 }); 25 var timeDatepair = new Datepair(jQuery('#task_datapair').get(0)); 26 bez.rich_text_editor($task_form.find('textarea'), $task_form.find('.bez_toolbar')); 27 } 28 29 if (jQuery('#reason').length > 0) { 30 jQuery('#no_evaluation').on('change', function() { 31 if (jQuery(this).prop('checked') === true) { 32 jQuery('#reason').prop('disabled', true).hide(); 33 jQuery('.bez_reason_toolbar').hide(); 34 } else { 35 jQuery('#reason').prop('disabled', false).show(); 36 jQuery('.bez_reason_toolbar').show(); 37 } 38 39 }); 40 bez.rich_text_editor(jQuery('#reason'), jQuery('.bez_reason_toolbar')); 41 } 42 43 jQuery('#bez_hidden_issue').hide(); 44 jQuery('#bez_show_issue').on('click', function (e) { 45 e.preventDefault(); 46 jQuery('#bez_hidden_issue').slideDown(); 47 jQuery(this).hide(); 48 }); 49 50 if (jQuery('.bez_task_metaform').length > 0) { 51 var tooltips = jQuery('.bez_task_metaform').find("input, select").tooltip({ 52 position: { 53 my: "left top", 54 at: "right+5 top-5", 55 collision: "none" 56 } 57 }); 58 jQuery.validate({ 59 form: '.bez_task_metaform', 60 inlineErrorMessageCallback: function($input, errorMessage, config) { 61 if ($input.tooltip("instance") === undefined) { 62 return false; 63 } 64 65 if (errorMessage) { 66 //customDisplayInlineErrorMessage($input, errorMessage); 67 $input.attr('title', errorMessage); 68 $input.tooltip("open"); 69 } else { 70 //customRemoveInlineError($input); 71 $input.tooltip("disable"); 72 } 73 return false; // prevent default behaviour 74 } 75 }); 76 77 jQuery("input[name=date], input[name=close_date]").datepicker({ 78 dateFormat: "yy-mm-dd" 79 }); 80 } 81}; 82