/* * Kendo UI Beta v2013.2.716 (http://kendoui.com) * Copyright 2013 Telerik AD. All rights reserved. * * Kendo UI Beta license terms available at * http://www.kendoui.com/purchase/license-agreement/kendo-ui-beta.aspx */ ("function"==typeof define&&define.amd?define:function(e,t){return t()})(["./kendo.dropdownlist.min","./kendo.editable.min","./kendo.multiselect.min","./kendo.window.min","./kendo.datepicker.min","./kendo.scheduler.recurrence.min","./kendo.scheduler.view.min","./kendo.scheduler.dayview.min","./kendo.scheduler.agendaview.min","./kendo.scheduler.monthview.min"],function(){!function(e,t){function i(e,t){var i,n=t.model.fields[t.field].validation;n&&(i=n.dateCompare,i&&S(i)&&i.message&&(e[h.attr("dateCompare-msg")]=i.message))}function n(e,t){return function(i){return i=e(i),r(i,"apply",t),i||[]}}function a(e,t){return function(i){return i&&("[object Array]"===I.call(i)||i instanceof h.data.ObservableArray||(i=[i])),r(i,"remove",t,!0),i=e(i),i||[]}}function r(e,t,i,n){var a,r,o;for(e=e||[],r=0,o=e.length;o>r;r++)a=e[r],(a.startTimezone||a.endTimezone||i)&&(a.start=h.timezone[t](a.start,a.startTimezone||a.endTimezone||i),a.end=h.timezone[t](a.end,a.endTimezone||a.startTimezone||i)),n&&delete a.uid;return e}function o(e,t){for(var i,n=e.length,a=0;n>a;a++)if(i=e[a],i.uid===t)return i}function d(e){var t,i,n,a,r;return e.filter("[name=end]").length&&(t=e.closest(".k-scheduler-edit-form"),i=t.find("[name=start]:visible"),n=t.find("[name=end]:visible"),n.length&&i.length&&(a=h.widgetInstance(i,h.ui),r=h.widgetInstance(n,h.ui),a&&r))?a.value()<=r.value():!0}function s(e){return delete e.name,delete e.prefix,delete e.remove,delete e.edit,e}function l(e){var t,i,n=[];for(t=0,i=e.length;i>t;t++)n.push(e[t].toJSON());return n}function c(t){return function(i){e(h.format('',h.ns,t.field)).appendTo(i).kendoMultiSelect({dataTextField:t.dataTextField,dataValueField:t.dataValueField,dataSource:t.dataSource,valuePrimitive:t.valuePrimitive,itemTemplate:h.format('#={1}#',t.dataColorField,t.dataTextField),tagTemplate:h.format('#={1}#',t.dataColorField,t.dataTextField)})}}var v,p,f,m,h=window.kendo,g=h.date,w=g.getDate,_=h.recurrence,k=h.keys,y=h.ui,T=y.Widget,z="string",b=y.Popup,D=y.Calendar,S=e.isPlainObject,x=e.extend,E=e.proxy,I=Object.prototype.toString,C=e.isArray,H=".kendoScheduler",R="click",V="change",F="cancel",B="remove",P="save",A="add",M="edit",N=w(new Date),W="yyyyMMddTHHmmssZ",O="Are you sure you want to delete this event?",K="Do you want to delete only this event occurrence or the whole series?",j="Do you want to edit only this event occurrence or the whole series?",q='#=text#',L=h.template('
'),U=function(t,n){var a={name:n.field};i(a,n),e('').attr(a).appendTo(t),e('').attr(a).appendTo(t),e("').appendTo(t),"end"===n.field&&e("').appendTo(t),e("').hide().appendTo(t)},J=h.date.getMilliseconds,Q=function(t,i){e("
').attr({name:i.field}).appendTo(t).kendoRecurrenceEditor({start:i.model.start,timezone:i.timezone,messages:i.messages})},Y=function(t,i){e(''+i.messages.timezoneEditorButton+"").click(i.click).appendTo(t)},$=function(t,i){e("
').attr({name:i.field}).toggle(i.visible).appendTo(t).kendoTimezoneEditor()},Z=h.Class.extend({init:function(t,i){var r=t.timezone;this.reader=i,i.model&&(this.model=i.model),this.timezone=r,this.data=n(e.proxy(this.data,this),r),this.serialize=a(e.proxy(this.serialize,this),r)},errors:function(e){return this.reader.errors(e)},parse:function(e){return this.reader.parse(e)},data:function(e){return this.reader.data(e)},total:function(e){return this.reader.total(e)},groups:function(e){return this.reader.groups(e)},aggregates:function(e){return this.reader.aggregates(e)},serialize:function(e){return this.reader.serialize(e)}}),G=h.data.Model.define({init:function(e){var t=this;h.data.Model.fn.init.call(t,e)},toJSON:function(){var e=h.data.Model.fn.toJSON.call(this);return e.uid=this.uid,e},set:function(e,t){var i,n,a,r=this.isAllDay||!1;h.data.Model.fn.set.call(this,e,t),"isAllDay"==e&&t!=r&&(i=h.date.getDate(this.start),n=new Date(this.end),a=h.date.getMilliseconds(n),0===a&&t&&(a=h.date.MS_PER_DAY),this.set("start",i),t===!0?(h.date.setTime(n,-a),i>n&&(n=i)):h.date.setTime(n,h.date.MS_PER_DAY-a),this.set("end",n))},id:"id",fields:{id:{type:"number"},title:{defaultValue:"",type:"string"},start:{type:"date",validation:{required:!0}},startTimezone:{type:"string"},end:{type:"date",validation:{required:!0,dateCompare:{value:d,message:"End date should be greater than or equal to the start date"}}},endTimezone:{type:"string"},recurrenceRule:{defaultValue:"",type:"string"},recurrenceException:{defaultValue:"",type:"string"},isAllDay:{type:"boolean",defaultValue:!1},description:{type:"string"}}}),X=h.data.DataSource.extend({init:function(e){h.data.DataSource.fn.init.call(this,x(!0,{},{schema:{modelBase:G,model:G}},e)),this.reader=new Z(this.options.schema,this.reader)}});X.create=function(e){e=e&&e.push?{data:e}:e;var t=e||{},i=t.data;if(t.data=i,!(t instanceof X)&&t instanceof h.data.DataSource)throw Error("Incorrect DataSource type. Only SchedulerDataSource instances are supported");return t instanceof X?t:new X(t)},x(!0,h.data,{SchedulerDataSource:X,SchedulerDataReader:Z,SchedulerEvent:G}),v={update:{text:"Save",className:"k-scheduler-update"},canceledit:{text:"Cancel",className:"k-scheduler-cancel"},destroy:{text:"Delete",imageClass:"k-delete",className:"k-grid-delete",iconClass:"k-icon"}},p=T.extend({init:function(t,i){var n=this;T.fn.init.call(n,t,i),n.options.views&&n.options.views.length||(n.options.views=["day","week"]),n.resources=[],n._initModel(),n._wrapper(),n._views(),n._toolbar(),n._dataSource(),n._resources(),n._resizeHandler=E(n._resize,n),n.wrapper.on("mousedown"+H+" selectstart"+H,function(e){e.preventDefault()}),n.options.editable&&n.options.editable.resize!==!1&&n._resizable(),n.options.editable&&n.options.editable.move!==!1&&n._movable(),e(window).on("resize"+H,n._resizeHandler),n.options.messages&&n.options.messages.recurrence&&(_.options=n.options.messages.recurrence),n._selectable()},_selectable:function(){var t=this,i=h.support.mobileOS?"touchend":"mousedown";t.options.selectable&&(t._tabindex(),t.wrapper.on(i,".k-scheduler-header-all-day td, .k-scheduler-content td, .k-event",function(e){t._createSelection(e.currentTarget),t.wrapper.focus()}),t.wrapper.on("focus"+H,function(){t._selection||t._createSelection(e(".k-scheduler-content").find("td:first")),t.view().select(t._selection)}),t.wrapper.on("focusout"+H,function(){t.view().clearSelection(),t._ctrlKey=t._shiftKey=!1}),t.wrapper.on("keydown"+H,E(t._keydown,t)),t.wrapper.on("keyup"+H,function(e){t._ctrlKey=e.ctrlKey,t._shiftKey=e.shiftKey}))},_viewByIndex:function(e){var t,i=this.views;for(t in i){if(!e)return t;e--}},_keydown:function(e){var t,i=this,n=e.keyCode,a=i.view(),r=a.options.editable,o=i._selection,d=e.shiftKey;i._ctrlKey=e.ctrlKey,i._shiftKey=e.shiftKey,n===k.TAB?a.moveToEvent(o,d)&&(a.select(o),e.preventDefault()):r&&n===k.ENTER?o.events.length?r.update!==!1&&i.editEvent(o.events[0]):r.create!==!1&&i.addEvent(o):n===k.DELETE?i.removeEvent(o.events[0]):n>=49&&57>=n?i.view(i._viewByIndex(n-49)):a.move(o,n,d)&&(t=o.start,a.isInRange(t)?a.select(o):i.date(t),e.preventDefault()),i._adjustSelectedDate()},_createSelection:function(t){var i,n,a;this._selection&&(this._ctrlKey||this._shiftKey)||(this._selection={events:[],groupIndex:0}),t=e(t),a=this._selection,i=t.attr(h.attr("uid")),n=this.view().selectionByElement(t),n&&(a.groupIndex=n.groupIndex),i&&(n=o(this._data,i)),n&&n.uid&&(i=[n.uid]),this._updateSelection(n,i),this._adjustSelectedDate()},_updateSelection:function(e,t){var i,n,a=this._selection;e&&a&&(this._shiftKey&&a.start&&a.end?(i=e.end=c._timeSlotInterval()&&(n=u,d=!0):"north"==l?n.groupIndex==u.groupIndex&&a.end-u.start>=c._timeSlotInterval()&&(i=u,d=!0):"east"==l?i.groupIndex==u.groupIndex&&h.date.getDate(u.end).getTime()>=h.date.getDate(a.start).getTime()&&(n=u,d=!0):"west"==l&&n.groupIndex==u.groupIndex&&h.date.getDate(a.end).getTime()>=h.date.getDate(u.start).getTime()&&(i=u,d=!0),d&&c._updateResizeHint(l,i,n))},dragend:function(o){var d=e(o.currentTarget),s=new Date(a.start.getTime()),l=new Date(a.end.getTime()),c=t(d);r.view()._removeResizeHint(),"south"==c?l=n.end:"north"==c?s=i.start:"east"==c?(l=h.date.getDate(n.end),a.isAllDay||(l=h.date.addDays(l,1))):"west"==c&&(s=new Date(i.start.getTime()),s.setHours(0),s.setMinutes(0)),(a.start.getTime()!=s.getTime()||a.end.getTime()!=l.getTime())&&r._updateEvent(c,a,{start:s,end:l})},dragcancel:function(){r.view()._removeResizeHint()}})},_updateEvent:function(e,t,i){var n=this,a=function(e){e.recurrenceId&&n._removeExceptionDate(e);for(var t in i)e.set(t,i[t]);e.recurrenceId&&n._addExceptionDate(e),n.trigger(P,{model:e})||(n._updateSelection(e),n.dataSource.sync())},r=function(e){return e.recurrenceRule?n.dataSource.getByUid(e.uid):n.dataSource.get(e.recurrenceId)},o=function(){var n,o,d=r(t);("south"==e||"north"==e)&&(i.start&&(n=h.date.getDate(d.start),h.date.setTime(n,J(i.start)),i.start=n),i.end&&(o=h.date.getDate(d.end),h.date.setTime(o,J(i.end)),i.end=o)),a(d)},d=function(){var e,a=r(t),o=a.toJSON();delete o[a.idField],delete o.recurrenceRule,delete o.id,o.recurrenceId=a.id,o.start=t.start,o.end=t.end,o=n.dataSource.add(o),n._addExceptionDate(o);for(e in i)o.set(e,i[e]);n.trigger(P,{model:o})||(n._updateSelection(t),n.dataSource.sync())},s=n.options.messages.recurrenceMessages;t.recurrenceRule||t.recurrenceId&&!t.id?n.showDialog({title:s.editWindowTitle,text:s.editRecurring?s.editRecurring:j,buttons:[{text:s.editWindowOccurrence,click:d},{text:s.editWindowSeries,click:o}]}):a(n.dataSource.getByUid(t.uid))},_modelForContainer:function(t){t=e(t).closest("["+h.attr("uid")+"]");var i=t.attr(h.attr("uid"));return this.dataSource.getByUid(i)},showDialog:function(t){var i,n,a=h.format("

{0}

",t.text),r=this;for(a+='
',i=0;i
",n=e(a).appendTo(r.wrapper).eq(0).on("click",".k-button",function(i){i.preventDefault(),n.close();var a=e(i.currentTarget).index();t.buttons[a].click()}).kendoWindow({modal:!0,resizable:!1,draggable:!1,title:t.title,visible:!1,close:function(){this.destroy(),r.focus()}}).getKendoWindow(),n.center().open()},focus:function(){this.wrapper.focus()},_confirmation:function(e){var t,i,n=this.options.editable;n===!0||n.confirmation?(t=this.options.messages,i=typeof n.confirmation===z?n.confirmation:O,this.showDialog({text:i,title:"Delete Event",buttons:[{name:"destroy",text:t.destroy,click:function(){e()}},{name:"canceledit",text:t.cancel,click:function(){e(!0)}}]})):e()},addEvent:function(e){var t,i;(this.editable&&this.editable.end()||!this.editable)&&(this.cancelEvent(),t=this.dataSource,i=t._createNewModel(),i instanceof h.data.Model?i.accept(e):i=x({title:""},i,e),i=this.dataSource.add(i),i&&this.editEvent(i.uid))},saveEvent:function(){var e=this,t=e._editContainer,i=e._modelForContainer(t),n=e.editable;t&&n&&n.end()&&!e.trigger(P,{container:t,model:i})&&e.dataSource.sync()},cancelEvent:function(){var e,t=this,i=t._editContainer;i&&(e=t._modelForContainer(i),t._removeExceptionDate(e),t.dataSource.cancelChanges(e),t._destroyEditable())},editEvent:function(e){var t=this,i="string"==typeof e?t.dataSource.getByUid(e):e;t.cancelEvent(),!i||i.recurrenceRule||i.id&&i.recurrenceId?t._editRecurringDialog(i,e):t._editEvent(i)},_editEvent:function(e){var t,i=this;i._createPopupEditor(e),t=i._editContainer,t.on(R+H,"a.k-scheduler-cancel",function(n){n.preventDefault(),n.stopPropagation(),i.trigger(F,{container:t,event:e})||i.cancelEvent()}),t.on(R+H,"a.k-scheduler-update",function(e){e.preventDefault(),e.stopPropagation(),i.saveEvent()})},_createButton:function(e){var t=e.template||q,i=typeof e===z?e:e.name||e.text,n={className:"k-scheduler-"+(i||"").replace(/\s/g,""),text:i,attr:""};if(!(i||S(e)&&e.template))throw Error("Custom commands should have name specified");return S(e)?(e.className&&(e.className+=" "+n.className),"edit"===i&&S(e.text)&&(e=x(!0,{},e),e.text=e.text.edit),n=x(!0,n,v[i],e)):n=x(!0,n,v[i]),h.template(t)(n)},_revertTimezones:function(e){e.set("startTimezone",this._startTimezone),e.set("endTimezone",this._endTimezone)},_createTimezonePopup:function(t,i){var n,a=this,r=a._editContainer.find(".k-scheduler-timezones"),o=r.find(".k-timezone-toggle"),d=r.find(".k-edit-label:last").add(r.find(".k-edit-field:last")),s=r.find(".k-scheduler-savetimezone"),l=r.find(".k-scheduler-canceltimezone"),c=a._timezonePopup;a._startTimezone=t.startTimezone,a._endTimezone=t.endTimezone,c||(a._timezonePopup=c=r.kendoWindow({modal:!0,resizable:!1,draggable:!0,title:a.options.messages.editor.timezoneEditorTitle,visible:!1,close:function(e){e.userTriggered&&a._revertTimezones(t),i&&i.focus()}}),o.click(function(){d.toggle(e(this).prop("checked")),t.set("endTimezone","")}),s.click(function(e){e.preventDefault(),n.close()}),l.click(function(e){e.preventDefault(),a._revertTimezones(t),n.close()})),o.prop("checked",t.endTimezone),d.toggle(t.endTimezone),n=c.data("kendoWindow"),n.center().open()},_createPopupEditor:function(i){var n,a,r,o,d,s,l,v,p,f=this,m=f.options.editable,g="
',w=m.template,_=f.options.messages,k=_.save,y=_.cancel,T=function(e){e.preventDefault(),f._createTimezonePopup(i,this)},b=[{field:"title",title:_.editor.title},{field:"start",title:_.editor.start,editor:U},{field:"end",title:_.editor.end,editor:U},{field:"isAllDay",title:_.editor.allDayEvent}],D=S(m)?m.window:{},E=x({},h.Template,f.options.templateSettings),I=E.paramName,C=i.startTime,H=i.endTime,R=[];if(w)typeof w===z&&(w=window.unescape(w)),g+=h.template(w,E)(i);else{h.timezone.windows_zones&&(b.push({field:"timezone",title:_.editor.timezone,editor:Y,click:T,messages:_.editor}),b.push({field:"startTimezone",title:_.editor.startTimezone,editor:$}),b.push({field:"endTimezone",title:_.editor.endTimezone,editor:$})),i.recurrenceId||(a=i.startTimezone||i.endTimezone||this.dataSource.reader.timezone,b.push({field:"recurrenceRule",title:_.editor.repeat,editor:Q,timezone:a,messages:_.recurrenceEditor})),"description"in i&&b.push({field:"description",title:_.editor.description,editor:'