*** kronolith/js/kronolith.js.orig 2014-03-17 10:05:14.304289035 +0100 --- kronolith/js/kronolith.js 2014-03-17 13:37:53.280316374 +0100 *************** *** 5518,5523 **** --- 5518,5532 ---- $('kronolithEventId').setValue(ev.id); $('kronolithEventCalendar').setValue(ev.ty + '|' + ev.c); $('kronolithEventTarget').setValue(ev.ty + '|' + ev.c); + + try { // inject "source calendar"-information into dropdown menu + var theOption = $$('option[value="' + ev.ty + '|' + ev.c + '"]'); + theOption[0].id = "optionSourceCalendar"; + } catch(e) { // source calendar is not writable + } + + + $('kronolithEventTargetRO').update(Kronolith.conf.calendars[ev.ty][ev.c].name.escapeHTML()); $('kronolithEventTitle').setValue(ev.t); $('kronolithEventLocation').setValue(ev.l); *************** *** 5667,5674 **** } if (!ev.pd) { $('kronolithEventDelete').hide(); - $('kronolithEventTarget').hide(); - $('kronolithEventTargetRO').show(); } this.setTitle(ev.t); --- 5676,5681 ---- *************** *** 6338,6343 **** --- 6345,6371 ---- RedBox.close(); }, + + targetCalendarChangeHandler: function() { + if(! $('kronolithEventSave').visible()) { // user can not save, no need to disable save button + return; + } + if( $('kronolithEventDelete').visible()) { // user can delete, so no need to disable save button when saving in different calendar + return; + } + + var newVal = $('kronolithEventTarget').getValue(); + var sourceVal = $('optionSourceCalendar').value; + + if(newVal == sourceVal) { + $('kronolithEventSave').enable(); + console.log("changed to orig"); + } else { + $('kronolithEventSave').disable(); + console.log("changed from orig"); + } + }, + // By default, no context onShow action contextOnShow: Prototype.emptyFunction, *************** *** 6583,6588 **** --- 6611,6618 ---- $('kronolithEventStartDate').observe('change', this.attendeeStartDateHandler.bind(this)); + $('kronolithEventTarget').observe('change', this.targetCalendarChangeHandler.bind(this)); + this.updateMinical(this.date); },