From 67b48d11c3bfb1357690a5a62e39a85db82c1699 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 2 Nov 2015 23:21:59 +0000 Subject: [PATCH] Calendar sidebox: - Move today button to sidebox calendar header - Resources now add & remove from current owner, not replace it --- calendar/js/app.js | 50 +++++++++++++++++++++++++++--- calendar/templates/default/app.css | 4 +++ 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/calendar/js/app.js b/calendar/js/app.js index 7b982efc96..4a3c08cb00 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -2539,11 +2539,30 @@ app.classes.calendar = AppJS.extend( .find('.egw_fw_ui_category_content').not(sidebox.parent()) .on('change.sidebox', 'select:not(.et2_selectbox),input', this, function(event) { var state = {}; + var name = this.name.replace('[]',''); + var value = $j(this).val(); + // Handle special value like r0, which removes all r + if(typeof value == 'string' && parseInt(value.substring(1)==0) || + value[0] && typeof value[0] == 'string' && parseInt(value[0].substring(1))==0) + { + value = typeof value == 'string' ? value : value[0]; + var type = value.substring(0,1); + state[name] = []; + for(var key in app.calendar.state[name]) + { + var cur_item = app.calendar.state[name][key]; + if(cur_item && (cur_item+'').substring(0,1) != type) + { + state[name].push(cur_item); + } + } + $j('option', this).removeAttr('selected'); + return app.calendar.update_state(state); + } // Here we look for things like owner: ['r1,r2'] and change them // to owner: ['r1','r2'] - state[this.name.replace('[]','')] = $j(this).val(); - $j('option', this).removeAttr('selected'); + state[name] = value; for(var key in state) { if(state[key] && typeof state[key].length !== 'undefined') @@ -2557,6 +2576,11 @@ app.classes.calendar = AppJS.extend( jQuery.extend(state[key], explode_me.split(',')); } } + // Add to, not replace, current value + if(typeof state[key] == 'object' && typeof app.calendar.state[key]) + { + jQuery.extend(state[key],app.calendar.state[key]); + } } } app.calendar.update_state(state); @@ -2575,8 +2599,8 @@ app.classes.calendar = AppJS.extend( var date = this.sidebox_et2.getWidgetById('date'); if(date) { - date.input_date.datepicker("option", { - showButtonPanel: true, + var datepicker = date.input_date.datepicker("option", { + showButtonPanel: false, onChangeMonthYear: function(year, month, inst) { // Switch to month view for that month @@ -2662,6 +2686,24 @@ app.classes.calendar = AppJS.extend( }); } }); + + // Today + var today = et2_createWidget('buttononly', {image: 'calendar/today', label: 'Today', id: 'today'},date); + today.set_image('calendar/today'); + var today_button = $j(today.getDOMNode()); + today_button + .prependTo(date.getDOMNode()) + .on('click', function() { + var inst = $j.datepicker._getInst(datepicker[0]); + inst.drawMonth = new Date().getUTCMonth(); + inst.drawYear = new Date().getFullYear(); + jQuery.datepicker._updateDatepicker(inst); + }); + var position_today = function() { + var week_col = $j('#calendar-sidebox_date th.ui-datepicker-week-col'); + today_button.position({my: 'left top', at: 'left top', of: week_col,collision:'none'}); + }; + window.setTimeout(position_today,0); } }, diff --git a/calendar/templates/default/app.css b/calendar/templates/default/app.css index 03c41739d9..33e7f1d89d 100644 --- a/calendar/templates/default/app.css +++ b/calendar/templates/default/app.css @@ -28,6 +28,10 @@ #calendar-sidebox_date td.ui-datepicker-week-col { cursor: pointer; } +#calendar-sidebox_date img.et2_button { + position: absolute; + padding: 4px; +} #calendar-sidebox_date .calendar_calHoliday { background: inherit; }