/* * * 2.1.11 * */ Ext.define("Sch.util.Patch", { target : null, minVersion : null, maxVersion : null, reportUrl : null, description : null, applyFn : null, ieOnly : false, onClassExtended : function(a, b) { if (Sch.disableOverrides) { return } if (b.ieOnly && !Ext.isIE) { return } if ((!b.minVersion || Ext.versions.extjs.equals(b.minVersion) || Ext.versions.extjs .isGreaterThan(b.minVersion)) && (!b.maxVersion || Ext.versions.extjs.equals(b.maxVersion) || Ext.versions.extjs .isLessThan(b.maxVersion))) { if (b.applyFn) { b.applyFn() } else { b.requires[0].override(b.overrides) } } } }); Ext.define("Sch.patches.LoadMask", { extend : "Sch.util.Patch", requires : ["Ext.view.AbstractView"], minVersion : "4.1.0b3", reportURL : "http://www.sencha.com/forum/showthread.php?187700-4.1.0-B3-Ext.AbstractView-no-longer-binds-its-store-to-load-mask", description : "In Ext4.1 loadmask no longer bind the store", overrides : {} }); Ext.define("Sch.patches.Table", { extend : "Sch.util.Patch", requires : ["Ext.view.Table"], minVersion : "4.1.1", maxVersion : "4.1.1", reportURL : "http://www.sencha.com/forum/showthread.php?238026-4.1.1-Alt-row-styling-lost-after-record-update&p=874190#post874190", description : "In Ext4.1.1 when record is updated, the alternate row styling is lost", overrides : { onUpdate : function(c, a, b, e) { var d = this.store.indexOf(a); this.callParent(arguments); this.doStripeRows(d, d) } } }); Ext.define("Sch.patches.TreeView", { extend : "Sch.util.Patch", requires : ["Ext.tree.View"], maxVersion : "4.1.3", applyFn : function() { Ext.tree.View.addMembers({ providedStore : null, initComponent : function() { var a = this, b = a.panel.getStore(); if (a.initialConfig.animate === undefined) { a.animate = Ext.enableFx } a.store = a.providedStore || new Ext.data.NodeStore({ treeStore : b, recursive : true, rootVisible : a.rootVisible }); a.store.on({ beforeexpand : a.onBeforeExpand, expand : a.onExpand, beforecollapse : a.onBeforeCollapse, collapse : a.onCollapse, write : a.onStoreWrite, datachanged : a.onStoreDataChanged, collapsestart : a.beginBulkUpdate, collapsecomplete : a.endBulkUpdate, scope : a }); if (Ext.versions.extjs .isGreaterThanOrEqual("4.1.2")) { a.mon(b, { scope : a, beforefill : a.onBeforeFill, fillcomplete : a.onFillComplete, beforebulkremove : a.beginBulkUpdate, bulkremovecomplete : a.endBulkUpdate }); if (!b.remoteSort) { a.mon(b, { scope : a, beforesort : a.onBeforeSort, sort : a.onSort }) } } if (a.node && !a.store.node) { a.setRootNode(a.node) } a.animQueue = {}; a.animWraps = {}; a.addEvents("afteritemexpand", "afteritemcollapse"); a.callParent(arguments); a.on({ element : "el", scope : a, delegate : a.expanderSelector, mouseover : a.onExpanderMouseOver, mouseout : a.onExpanderMouseOut }); a.on({ element : "el", scope : a, delegate : a.checkboxSelector, click : a.onCheckboxChange }) } }) } }); Ext.define("Sch.patches.DataOperation", { extend : "Sch.util.Patch", requires : ["Ext.data.Operation"], reportURL : "http://www.sencha.com/forum/showthread.php?198894-4.1-Ext.data.TreeStore-CRUD-regression.", description : "In Ext 4.1.0 newly created records do not get the Id returned by server applied", maxVersion : "4.1.0", overrides : { commitRecords : function(j) { var g = this, h, f, a, c, b, d, e; if (!g.actionSkipSyncRe.test(g.action)) { a = g.records; if (a && a.length) { if (a.length > 1) { if (g.action == "update" || a[0].clientIdProperty) { h = new Ext.util.MixedCollection(); h.addAll(j); for (f = a.length; f--;) { b = a[f]; c = h.findBy(g.matchClientRec, b); b.copyFrom(c) } } else { for (d = 0, e = a.length; d < e; ++d) { b = a[d]; c = j[d]; if (b && c) { g.updateRecord(b, c) } } } } else { this.updateRecord(a[0], j[0]) } if (g.actionCommitRecordsRe.test(g.action)) { for (f = a.length; f--;) { a[f].commit() } } } } }, updateRecord : function(a, b) { if (b && (a.phantom || a.getId() === b.getId())) { a.copyFrom(b) } } } }); Ext.define("Sch.patches.TreeStore", { extend : "Sch.util.Patch", requires : ["Ext.data.TreeStore"], description : "http://www.sencha.com/forum/showthread.php?208602-Model-s-Id-field-not-defined-after-sync-in-TreeStore-%28CRUD%29", maxVersion : "4.1.0", overrides : { onCreateRecords : function(c) { this.callParent(arguments); var d = 0, b = c.length, a = this.tree, e; for (; d < b; ++d) { e = c[d]; a.onNodeIdChanged(e, null, e.getId()) } }, setRootNode : function(a, e) { var d = this, c = d.model, b = c.prototype.idProperty; a = a || {}; if (!a.isModel) { Ext.applyIf(a, { text : "Root", allowDrag : false }); if (a[b] === undefined) { a[b] = d.defaultRootId } Ext.data.NodeInterface.decorate(c); a = Ext.ModelManager.create(a, c) } else { if (a.isModel && !a.isNode) { Ext.data.NodeInterface.decorate(c) } } d.getProxy().getReader().buildExtractors(true); d.tree.setRootNode(a); if (e !== true && !a.isLoaded() && (d.autoLoad === true || a.isExpanded())) { d.load({ node : a }) } return a } } }); Ext.define("Sch.util.Date", { requires : "Ext.Date", singleton : true, unitHash : null, unitsByName : {}, unitNames : { YEAR : { single : "year", plural : "years", abbrev : "yr" }, QUARTER : { single : "quarter", plural : "quarters", abbrev : "q" }, MONTH : { single : "month", plural : "months", abbrev : "mon" }, WEEK : { single : "week", plural : "weeks", abbrev : "w" }, DAY : { single : "day", plural : "days", abbrev : "d" }, HOUR : { single : "hour", plural : "hours", abbrev : "h" }, MINUTE : { single : "minute", plural : "minutes", abbrev : "min" }, SECOND : { single : "second", plural : "seconds", abbrev : "s" }, MILLI : { single : "ms", plural : "ms", abbrev : "ms" } }, constructor : function() { var a = Ext.Date; var c = this.unitHash = { MILLI : a.MILLI, SECOND : a.SECOND, MINUTE : a.MINUTE, HOUR : a.HOUR, DAY : a.DAY, WEEK : "w", MONTH : a.MONTH, QUARTER : "q", YEAR : a.YEAR }; Ext.apply(this, c); var b = this; this.units = [b.MILLI, b.SECOND, b.MINUTE, b.HOUR, b.DAY, b.WEEK, b.MONTH, b.QUARTER, b.YEAR]; this.setUnitNames(this.unitNames) }, setUnitNames : function(e) { var d = this.unitsByName = {}; this.unitNames = e; var b = this.unitHash; for (var a in b) { if (b.hasOwnProperty(a)) { var c = b[a]; e[c] = e[a]; d[a] = c; d[c] = c } } }, betweenLesser : function(b, d, a) { var c = b.getTime(); return d.getTime() <= c && c < a.getTime() }, constrain : function(b, c, a) { return this.min(this.max(b, c), a) }, compareUnits : function(c, b) { var a = Ext.Array.indexOf(this.units, c), d = Ext.Array .indexOf(this.units, b); return a > d ? 1 : (a < d ? -1 : 0) }, isUnitGreater : function(b, a) { return this.compareUnits(b, a) > 0 }, copyTimeValues : function(b, a) { b.setHours(a.getHours()); b.setMinutes(a.getMinutes()); b.setSeconds(a.getSeconds()); b.setMilliseconds(a.getMilliseconds()) }, add : function(b, c, e) { var f = Ext.Date.clone(b); if (!c || e === 0) { return f } switch (c.toLowerCase()) { case this.MILLI : f = new Date(b.getTime() + e); break; case this.SECOND : f = new Date(b.getTime() + (e * 1000)); break; case this.MINUTE : f = new Date(b.getTime() + (e * 60000)); break; case this.HOUR : f = new Date(b.getTime() + (e * 3600000)); break; case this.DAY : f.setDate(b.getDate() + e); break; case this.WEEK : f.setDate(b.getDate() + e * 7); break; case this.MONTH : var a = b.getDate(); if (a > 28) { a = Math.min(a, Ext.Date.getLastDateOfMonth(this.add( Ext.Date.getFirstDateOfMonth(b), this.MONTH, e)).getDate()) } f.setDate(a); f.setMonth(f.getMonth() + e); break; case this.QUARTER : f = this.add(b, this.MONTH, e * 3); break; case this.YEAR : f.setFullYear(b.getFullYear() + e); break } return f }, getMeasuringUnit : function(a) { if (a === this.WEEK) { return this.DAY } return a }, getDurationInUnit : function(d, a, c) { var b; switch (c) { case this.YEAR : b = Math.round(this.getDurationInYears(d, a)); break; case this.QUARTER : b = Math.round(this.getDurationInMonths(d, a) / 3); break; case this.MONTH : b = Math.round(this.getDurationInMonths(d, a)); break; case this.WEEK : b = Math.round(this.getDurationInDays(d, a)) / 7; break; case this.DAY : b = Math.round(this.getDurationInDays(d, a)); break; case this.HOUR : b = Math.round(this.getDurationInHours(d, a)); break; case this.MINUTE : b = Math.round(this.getDurationInMinutes(d, a)); break; case this.SECOND : b = Math.round(this.getDurationInSeconds(d, a)); break; case this.MILLI : b = Math.round(this.getDurationInMilliseconds(d, a)); break } return b }, getUnitToBaseUnitRatio : function(b, a) { if (b === a) { return 1 } switch (b) { case this.YEAR : switch (a) { case this.QUARTER : return 1 / 4; case this.MONTH : return 1 / 12 } break; case this.QUARTER : switch (a) { case this.YEAR : return 4; case this.MONTH : return 1 / 3 } break; case this.MONTH : switch (a) { case this.YEAR : return 12; case this.QUARTER : return 3 } break; case this.WEEK : switch (a) { case this.DAY : return 1 / 7; case this.HOUR : return 1 / 168 } break; case this.DAY : switch (a) { case this.WEEK : return 7; case this.HOUR : return 1 / 24; case this.MINUTE : return 1 / 1440 } break; case this.HOUR : switch (a) { case this.DAY : return 24; case this.MINUTE : return 1 / 60 } break; case this.MINUTE : switch (a) { case this.HOUR : return 60; case this.SECOND : return 1 / 60; case this.MILLI : return 1 / 60000 } break; case this.SECOND : switch (a) { case this.MILLI : return 1 / 1000 } break; case this.MILLI : switch (a) { case this.SECOND : return 1000 } break } return -1 }, getDurationInMilliseconds : function(b, a) { return (a - b) }, getDurationInSeconds : function(b, a) { return (a - b) / 1000 }, getDurationInMinutes : function(b, a) { return (a - b) / 60000 }, getDurationInHours : function(b, a) { return (a - b) / 3600000 }, getDurationInDays : function(b, a) { return (a - b) / 86400000 }, getDurationInBusinessDays : function(g, b) { var c = Math.round((b - g) / 86400000), a = 0, f; for (var e = 0; e < c; e++) { f = this.add(g, this.DAY, e).getDay(); if (f !== 6 && f !== 0) { a++ } } return a }, getDurationInMonths : function(b, a) { return ((a.getFullYear() - b.getFullYear()) * 12) + (a.getMonth() - b.getMonth()) }, getDurationInYears : function(b, a) { return this.getDurationInMonths(b, a) / 12 }, min : function(b, a) { return b < a ? b : a }, max : function(b, a) { return b > a ? b : a }, intersectSpans : function(c, d, b, a) { return this.betweenLesser(c, b, a) || this.betweenLesser(b, c, d) }, getNameOfUnit : function(a) { a = this.getUnitByName(a); switch (a.toLowerCase()) { case this.YEAR : return "YEAR"; case this.QUARTER : return "QUARTER"; case this.MONTH : return "MONTH"; case this.WEEK : return "WEEK"; case this.DAY : return "DAY"; case this.HOUR : return "HOUR"; case this.MINUTE : return "MINUTE"; case this.SECOND : return "SECOND"; case this.MILLI : return "MILLI" } throw "Incorrect UnitName" }, getReadableNameOfUnit : function(b, a) { return this.unitNames[b][a ? "plural" : "single"] }, getShortNameOfUnit : function(a) { return this.unitNames[a].abbrev }, getUnitByName : function(a) { if (!this.unitsByName[a]) { Ext.Error.raise("Unknown unit name: " + a) } return this.unitsByName[a] }, getNext : function(c, g, a, f) { var e = Ext.Date.clone(c); f = arguments.length < 4 ? 1 : f; a = a || 1; switch (g) { case this.MILLI : e = this.add(c, g, a); break; case this.SECOND : e = this.add(c, g, a); e.setMilliseconds(0); break; case this.MINUTE : e = this.add(c, g, a); e.setSeconds(0); e.setMilliseconds(0); break; case this.HOUR : e = this.add(c, g, a); e.setMinutes(0); e.setSeconds(0); e.setMilliseconds(0); break; case this.DAY : var d = c.getHours() === 23 && this.add(e, this.HOUR, 1).getHours() === 1; if (d) { e = this.add(e, this.DAY, 2); Ext.Date.clearTime(e); return e } Ext.Date.clearTime(e); e = this.add(e, this.DAY, a); break; case this.WEEK : Ext.Date.clearTime(e); var b = e.getDay(); e = this.add(e, this.DAY, f - b + 7 * (a - (f <= b ? 0 : 1))); if (e.getDay() !== f) { e = this.add(e, this.HOUR, 1) } else { Ext.Date.clearTime(e) } break; case this.MONTH : e = this.add(e, this.MONTH, a); e.setDate(1); Ext.Date.clearTime(e); break; case this.QUARTER : e = this.add(e, this.MONTH, ((a - 1) * 3) + (3 - (e.getMonth() % 3))); Ext.Date.clearTime(e); e.setDate(1); break; case this.YEAR : e = new Date(e.getFullYear() + a, 0, 1); break; default : throw "Invalid date unit" } return e }, getNumberOfMsFromTheStartOfDay : function(a) { return a - Ext.Date.clearTime(a, true) || 86400000 }, getNumberOfMsTillTheEndOfDay : function(a) { return this.getStartOfNextDay(a, true) - a }, getStartOfNextDay : function(b, e) { var d = this.add(Ext.Date.clearTime(b, e), this.DAY, 1); if (d.getDate() == b.getDate()) { var c = this.add(Ext.Date.clearTime(b, e), this.DAY, 2) .getTimezoneOffset(); var a = b.getTimezoneOffset(); d = this.add(d, this.MINUTE, a - c) } return d }, getEndOfPreviousDay : function(b) { var a = Ext.Date.clearTime(b, true); if (a - b) { return a } else { return this.add(a, this.DAY, -1) } }, timeSpanContains : function(c, b, d, a) { return (d - c) >= 0 && (b - a) >= 0 } }); Ext.define("Sch.util.DragTracker", { extend : "Ext.dd.DragTracker", xStep : 1, yStep : 1, setXStep : function(a) { this.xStep = a }, setYStep : function(a) { this.yStep = a }, getRegion : function() { var e = this.startXY, d = this.getXY(), b = Math.min(e[0], d[0]), f = Math .min(e[1], d[1]), c = Math.abs(e[0] - d[0]), a = Math.abs(e[1] - d[1]); return new Ext.util.Region(f, b + c, f + a, b) }, onMouseDown : function(f, d) { if (this.disabled || f.dragTracked) { return } var c = f.getXY(), g, b, a = c[0], h = c[1]; if (this.xStep > 1) { g = this.el.getX(); a -= g; a = Math.round(a / this.xStep) * this.xStep; a += g } if (this.yStep > 1) { b = this.el.getY(); h -= b; h = Math.round(h / this.yStep) * this.yStep; h += b } this.dragTarget = this.delegate ? d : this.handle.dom; this.startXY = this.lastXY = [a, h]; this.startRegion = Ext.fly(this.dragTarget).getRegion(); if (this.fireEvent("mousedown", this, f) === false || this.fireEvent("beforedragstart", this, f) === false || this.onBeforeStart(f) === false) { return } this.mouseIsDown = true; f.dragTracked = true; if (this.preventDefault !== false) { f.preventDefault() } Ext.getDoc().on({ scope : this, mouseup : this.onMouseUp, mousemove : this.onMouseMove, selectstart : this.stopSelect }); if (this.autoStart) { this.timer = Ext.defer(this.triggerStart, this.autoStart === true ? 1000 : this.autoStart, this, [f]) } }, onMouseMove : function(g, f) { if (this.active && Ext.isIE && !g.browserEvent.button) { g.preventDefault(); this.onMouseUp(g); return } g.preventDefault(); var d = g.getXY(), b = this.startXY; if (!this.active) { if (Math.max(Math.abs(b[0] - d[0]), Math.abs(b[1] - d[1])) > this.tolerance) { this.triggerStart(g) } else { return } } var a = d[0], h = d[1]; if (this.xStep > 1) { a -= this.startXY[0]; a = Math.round(a / this.xStep) * this.xStep; a += this.startXY[0] } if (this.yStep > 1) { h -= this.startXY[1]; h = Math.round(h / this.yStep) * this.yStep; h += this.startXY[1] } var c = this.xStep > 1 || this.yStep > 1; if (!c || a !== d[0] || h !== d[1]) { this.lastXY = [a, h]; if (this.fireEvent("mousemove", this, g) === false) { this.onMouseUp(g) } else { this.onDrag(g); this.fireEvent("drag", this, g) } } } }); Ext.define("Sch.util.HeaderRenderers", { singleton : true, requires : ["Sch.util.Date", "Ext.XTemplate"], constructor : function() { var b = Ext .create( "Ext.XTemplate", '
{text}
') .compile(); var a = Ext .create( "Ext.XTemplate", '
{text}
') .compile(); return { quarterMinute : function(f, d, c, e) { c.headerCls = "sch-nested-hdr-pad"; return '
00153045
' }, dateCells : function(d, c, e) { return function(j, g, f) { f.headerCls = "sch-nested-hdr-nopad"; var i = [], h = Ext.Date.clone(j); while (h < g) { i.push({ text : Ext.Date.format(h, e) }); h = Sch.util.Date.add(h, d, c) } i[0].cls = "sch-nested-hdr-cell-first"; i[i.length - 1].cls = "sch-nested-hdr-cell-last"; return a.apply(i) } }, dateNumber : function(g, d, c) { c.headerCls = "sch-nested-hdr-nopad"; var f = [], e = Ext.Date.clone(g); while (e < d) { f.push({ dayOfWeek : e.getDay(), text : e.getDate() }); e = Sch.util.Date.add(e, Sch.util.Date.DAY, 1) } return b.apply(f) }, dayLetter : function(g, d, c) { c.headerCls = "sch-nested-hdr-nopad"; var f = [], e = g; while (e < d) { f.push({ dayOfWeek : e.getDay(), text : Ext.Date.dayNames[e.getDay()].substr(0, 1) }); e = Sch.util.Date.add(e, Sch.util.Date.DAY, 1) } f[0].cls = "sch-nested-hdr-cell-first"; f[f.length - 1].cls = "sch-nested-hdr-cell-last"; return b.apply(f) }, dayStartEndHours : function(e, d, c) { c.headerCls = "sch-hdr-startend"; return Ext.String .format( '{0}{1}', Ext.Date.format(e, "G"), Ext.Date .format(d, "G")) } } } }); Ext.define("Sch.model.Customizable", { extend : "Ext.data.Model", customizableFields : null, onClassExtended : function(b, d, a) { var c = a.onBeforeCreated; a.onBeforeCreated = function(f, k) { c.call(this, f, k); var j = f.prototype; if (!j.customizableFields) { return } j.customizableFields = (f.superclass.customizableFields || []) .concat(j.customizableFields); var g = j.customizableFields; var i = {}; Ext.Array.each(g, function(l) { if (typeof l == "string") { l = { name : l } } i[l.name] = l }); var e = j.fields; var h = []; e.each(function(l) { if (l.isCustomizableField) { h.push(l) } }); e.removeAll(h); Ext.Object.each(i, function(l, o) { o.isCustomizableField = true; var p = o.name; var t = p === "Id" ? "idProperty" : p.charAt(0).toLowerCase() + p.substr(1) + "Field"; var q = j[t]; var s = q || p; if (e.containsKey(s)) { e.getByKey(s).isCustomizableField = true; g.push(new Ext.data.Field(Ext.applyIf({ name : p, isCustomizableField : true }, e.getByKey(s)))) } else { e.add(new Ext.data.Field(Ext.applyIf({ name : s, isCustomizableField : true }, o))) } var n = Ext.String.capitalize(p); if (n != "Id") { var r = "get" + n; var m = "set" + n; if (!j[r] || j[r].__getterFor__ && j[r].__getterFor__ != s) { j[r] = function() { return this.data[s] }; j[r].__getterFor__ = s } if (!j[m] || j[m].__setterFor__ && j[m].__setterFor__ != s) { j[m] = function(u) { return this.set(s, u) }; j[m].__setterFor__ = s } } }) } }, set : function(c, b) { if (arguments.length === 2) { this.previous = this.previous || {}; var a = this.get(c); if (a !== b) { this.previous[c] = a } } this.callParent(arguments) }, afterEdit : function() { this.callParent(arguments); delete this.previous }, reject : function() { var b = this, a = b.modified, c; b.previous = b.previous || {}; for (c in a) { if (a.hasOwnProperty(c)) { if (typeof a[c] != "function") { b.previous[c] = b.get(c) } } } b.callParent(arguments); delete b.previous } }); Ext.define("Sch.patches.Model", { extend : "Sch.util.Patch", requires : "Sch.model.Customizable", reportURL : "http://www.sencha.com/forum/showthread.php?198250-4.1-Ext.data.Model-regression", description : "In Ext 4.1 Models cannot be subclassed", maxVersion : "4.1.0", applyFn : function() { try { Ext.define("Sch.foo", { extend : "Ext.data.Model", fields : ["a"] }); Ext.define("Sch.foo.Sub", { extend : "Sch.foo", fields : ["a"] }) } catch (a) { Ext.data.Types.AUTO.convert = function(b) { return b } } } }); Ext.define("Sch.data.mixin.EventStore", { model : "Sch.model.Event", requires : ["Sch.util.Date"], isEventStore : true, setResourceStore : function(a) { if (this.resourceStore) { this.resourceStore.un({ beforesync : this.onResourceStoreBeforeSync, write : this.onResourceStoreWrite, scope : this }) } this.resourceStore = a; if (a) { a.on({ beforesync : this.onResourceStoreBeforeSync, write : this.onResourceStoreWrite, scope : this }) } }, onResourceStoreBeforeSync : function(b, c) { var a = b.create; if (a) { for (var e, d = a.length - 1; d >= 0; d--) { e = a[d]; e._phantomId = e.internalId } } }, onResourceStoreWrite : function(c, b) { if (b.wasSuccessful()) { var d = this, a = b.getRecords(); Ext.each(a, function(e) { if (e._phantomId && !e.phantom) { d.each(function(f) { if (f.getResourceId() === e._phantomId) { f.assign(e) } }) } }) } }, isDateRangeAvailable : function(f, a, b, d) { var c = true, e = Sch.util.Date; this.each(function(g) { if (e .intersectSpans(f, a, g.getStartDate(), g .getEndDate()) && d === g.getResource() && (!b || b !== g)) { c = false; return false } }); return c }, getEventsInTimeSpan : function(d, b, a) { if (a !== false) { var c = Sch.util.Date; return this.queryBy(function(g) { var f = g.getStartDate(), e = g.getEndDate(); return f && e && c.intersectSpans(f, e, d, b) }) } else { return this.queryBy(function(g) { var f = g.getStartDate(), e = g.getEndDate(); return f && e && (f - d >= 0) && (b - e >= 0) }) } }, getTotalTimeSpan : function() { var a = new Date(9999, 0, 1), b = new Date(0), c = Sch.util.Date; this.each(function(d) { if (d.getStartDate()) { a = c.min(d.getStartDate(), a) } if (d.getEndDate()) { b = c.max(d.getEndDate(), b) } }); a = a < new Date(9999, 0, 1) ? a : null; b = b > new Date(0) ? b : null; return { start : a || null, end : b || a || null } }, getEventsForResource : function(e) { var c = [], d, f = e.getId() || e.internalId; for (var b = 0, a = this.getCount(); b < a; b++) { d = this.getAt(b); if (d.data[d.resourceIdField] === f) { c.push(d) } } return c }, getClosestSuccessor : function(g, e) { var c = Infinity, a = g.getEnd(), f, h; e = e || this.getRange(); for (var d = 0, b = e.length; d < b; d++) { h = e[d].getStart() - a; if (h >= 0 && h < c) { f = e[d]; c = h } } return f } }); Ext.define("Sch.model.Range", { extend : "Sch.model.Customizable", requires : ["Sch.util.Date", "Sch.patches.DataOperation"], startDateField : "StartDate", endDateField : "EndDate", nameField : "Name", clsField : "Cls", customizableFields : [{ name : "StartDate", type : "date", dateFormat : "c" }, { name : "EndDate", type : "date", dateFormat : "c" }, { name : "Cls", type : "string" }, { name : "Name", type : "string" }], setStartDate : function(a, d) { var c = this.getEndDate(); var b = this.getStartDate(); this.set(this.startDateField, a); if (d === true && c && b) { this.setEndDate(Sch.util.Date.add(a, Sch.util.Date.MILLI, c - b)) } }, setEndDate : function(b, d) { var a = this.getStartDate(); var c = this.getEndDate(); this.set(this.endDateField, b); if (d === true && a && c) { this.setStartDate(Sch.util.Date.add(b, Sch.util.Date.MILLI, -(c - a))) } }, setStartEndDate : function(b, a) { this.beginEdit(); this.set(this.startDateField, b); this.set(this.endDateField, a); this.endEdit() }, getDates : function() { var c = [], b = this.getEndDate(); for (var a = Ext.Date.clearTime(this.getStartDate(), true); a < b; a = Sch.util.Date .add(a, Sch.util.Date.DAY, 1)) { c.push(a) } return c }, forEachDate : function(b, a) { return Ext.each(this.getDates(), b, a) }, isValid : function() { var b = this.callParent(arguments); if (b) { var c = this.getStartDate(), a = this.getEndDate(); b = !c || !a || (a - c >= 0) } return b }, shift : function(b, a) { this.setStartEndDate(Sch.util.Date.add(this.getStartDate(), b, a), Sch.util.Date.add(this.getEndDate(), b, a)) } }); Ext.define("Sch.model.Resource", { extend : "Sch.model.Customizable", idProperty : "Id", nameField : "Name", customizableFields : ["Id", { name : "Name", type : "string" }], getEventStore : function() { return this.stores[0] && this.stores[0].eventStore || this.parentNode && this.parentNode.getEventStore() }, getEvents : function(d) { var c = [], e, f = this.getId() || this.internalId; d = d || this.getEventStore(); for (var b = 0, a = d.getCount(); b < a; b++) { e = d.getAt(b); if (e.data[e.resourceIdField] === f) { c.push(e) } } return c } }); Ext.define("Sch.data.mixin.ResourceStore", {}); Ext.define("Sch.data.FilterableNodeStore", { extend : "Ext.data.NodeStore", onNodeExpand : function(f, d, c) { var b = []; for (var e = 0; e < d.length; e++) { var a = d[e]; if (!(a.isHidden && a.isHidden() || a.hidden || a.data.hidden)) { b[b.length] = a } } return this.callParent([f, b, c]) } }); Ext.define("Sch.data.mixin.FilterableTreeStore", { requires : ["Sch.data.FilterableNodeStore"], nodeStoreClassName : "Sch.data.FilterableNodeStore", nodeStore : null, isFilteredFlag : false, initTreeFiltering : function() { if (!this.nodeStore) { this.nodeStore = this.createNodeStore(this) } this.addEvents("filter-set", "filter-clear", "nodestore-datachange-start", "nodestore-datachange-end") }, createNodeStore : function(a) { return Ext.create(this.nodeStoreClassName, { treeStore : a, recursive : true, rootVisible : this.rootVisible }) }, clearTreeFilter : function() { if (!this.isTreeFiltered()) { return } this.refreshNodeStoreContent(); this.isFilteredFlag = false; this.fireEvent("filter-clear", this) }, refreshNodeStoreContent : function(f) { var a = this.getRootNode(), d = []; var c = this.rootVisible; var b = function(i) { if (i.isHidden && i.isHidden() || i.hidden || i.data.hidden) { return } if (c || i != a) { d[d.length] = i } if (!i.data.leaf && i.isExpanded()) { var j = i.childNodes, h = j.length; for (var g = 0; g < h; g++) { b(j[g]) } } }; b(a); this.fireEvent("nodestore-datachange-start", this); var e = this.nodeStore; if (!this.loadDataInNodeStore || !this.loadDataInNodeStore(d)) { e.loadRecords(d) } if (!f) { e.fireEvent("clear", e) } this.fireEvent("nodestore-datachange-end", this) }, getIndexInTotalDataset : function(b) { var a = this.getRootNode(); index = -1; var d = this.rootVisible; if (!d && b == a) { return -1 } var c = function(g) { if (g.isHidden && g.isHidden() || g.hidden || g.data.hidden) { if (g == b) { return false } } if (d || g != a) { index++ } if (g == b) { return false } if (!g.data.leaf && g.isExpanded()) { var h = g.childNodes, f = h.length; for (var e = 0; e < f; e++) { if (c(h[e]) === false) { return false } } } }; c(a); return index }, isTreeFiltered : function() { return this.isFilteredFlag }, filterTreeBy : function(s, b) { var g; if (arguments.length == 1 && Ext.isObject(arguments[0])) { b = s.scope; g = s.filter } else { g = s; s = {} } this.fireEvent("nodestore-datachange-start", this); s = s || {}; var j = s.shallow; var r = s.checkParents || j; var h = s.fullMathchingParents; var c = s.onlyParents || h; var e = this.rootVisible; if (c && r) { throw new Error("Can't combine `onlyParents` and `checkParents` options") } var o = {}; var m = this.getRootNode(), d = []; var a = function(t) { var i = t.parentNode; while (i && !o[i.internalId]) { o[i.internalId] = true; i = i.parentNode } }; var k = function(v) { if (v.isHidden && v.isHidden() || v.hidden || v.data.hidden) { return } var t, w, u, i; if (v.data.leaf) { if (g.call(b, v, o)) { d[d.length] = v; a(v) } } else { if (e || v != m) { d[d.length] = v } if (c) { t = g.call(b, v); w = v.childNodes; u = w.length; if (t) { o[v.internalId] = true; a(v); if (h) { v.cascadeBy(function(x) { d[d.length] = x; if (!x.data.leaf) { o[x.internalId] = true } }); return } } for (i = 0; i < u; i++) { if (t && w[i].data.leaf) { d[d.length] = w[i] } else { if (!w[i].data.leaf) { k(w[i]) } } } } else { if (r) { t = g.call(b, v, o); if (t) { o[v.internalId] = true; a(v) } } if (!r || !j || j && (t || v == m && !e)) { w = v.childNodes; u = w.length; for (i = 0; i < u; i++) { k(w[i]) } } } } }; k(m); var f = []; for (var p = 0, q = d.length; p < q; p++) { var l = d[p]; if (l.data.leaf || o[l.internalId]) { f[f.length] = l } } var n = this.nodeStore; if (!this.loadDataInNodeStore || !this.loadDataInNodeStore(f)) { n.loadRecords(f, false); n.fireEvent("clear", n) } this.isFilteredFlag = true; this.fireEvent("nodestore-datachange-end", this); this.fireEvent("filter-set", this) }, hideNodesBy : function(b, a) { if (this.isFiltered()) { throw new Error("Can't hide nodes of the filtered tree store") } var c = this; a = a || this; this.getRootNode().cascadeBy(function(d) { d.hidden = b.call(a, d, c) }); this.refreshNodeStoreContent() }, showAllNodes : function() { this.getRootNode().cascadeBy(function(a) { a.hidden = a.data.hidden = false }); this.refreshNodeStoreContent() } }); Ext.define("Sch.data.mixin.BufferableTreeStore", { viewSize : 50, buffered : false, rangeStart : null, rangeEnd : null, initTreeBuffering : function() { if (!this.buffered) { return } var b = this; var a = { append : this.updateBufferedNodeStore, insert : this.updateBufferedNodeStore, remove : this.updateBufferedNodeStore, move : this.updateBufferedNodeStore, expand : this.updateBufferedNodeStore, collapse : this.updateBufferedNodeStore, sort : this.updateBufferedNodeStore, scope : this, buffer : 1 }; this.on(a); this.on("root-fill-start", function() { b.nodeStore.suspendEvents(); b.un(a); b.nodeStore.setNode() }); this.on("root-fill-end", function() { b.nodeStore.resumeEvents(); b.on(a); this.updateBufferedNodeStore() }) }, updateBufferedNodeStore : function() { this.refreshNodeStoreContent(true) }, loadDataInNodeStore : function(a) { if (!this.buffered) { return false } var b = this.nodeStore; b.totalCount = a.length; if (!a.length) { b.removeAll() } b.cachePage(a, 1); this.guaranteeRange(this.rangeStart || 0, this.rangeEnd || this.viewSize || 50); return true }, guaranteeRange : function(e, d) { var b = this.viewSize || 50; var f = this.nodeStore; var a = f.getTotalCount(); if (a) { var c = d - e + 1; if (c < b && a >= c) { d = e + b - 1 } if (d >= a) { e = a - (d - e); d = a - 1; e = Math.max(0, e) } f.guaranteeRange(e, d) } }, createNodeStore : function(a) { var b = Ext.create(this.nodeStoreClassName || "Ext.data.NodeStore", { treeStore : a, recursive : true, rootVisible : this.rootVisible, buffered : a.buffered, purgePageCount : 0, pageSize : 10000000000 }); if (a.buffered) { this.mon(b, "guaranteedrange", function(d, e, c) { this.rangeStart = e; this.rangeEnd = c }, this) } return b } }); Ext.define("Sch.data.ResourceStore", { extend : "Ext.data.Store", model : "Sch.model.Resource", mixins : ["Sch.data.mixin.ResourceStore"] }); Ext.define("Sch.data.TimeAxis", { extend : "Ext.util.Observable", requires : ["Ext.data.JsonStore", "Sch.util.Date"], continuous : true, autoAdjust : true, constructor : function(a) { Ext.apply(this, a); this.originalContinuous = this.continuous; this.addEvents("beforereconfigure", "reconfigure"); this.tickStore = new Ext.data.JsonStore({ fields : ["start", "end"] }); this.tickStore.on("datachanged", function() { this.fireEvent("reconfigure", this) }, this); this.callParent(arguments) }, reconfigure : function(a) { Ext.apply(this, a); var c = this.tickStore, b = this.generateTicks(this.start, this.end, this.unit, this.increment || 1, this.mainUnit); if (this.fireEvent("beforereconfigure", this, this.start, this.end) !== false) { c.suspendEvents(true); c.loadData(b); if (c.getCount() === 0) { Ext.Error .raise("Invalid time axis configuration or filter, please check your input data.") } c.resumeEvents() } }, setTimeSpan : function(b, a) { this.reconfigure({ start : b, end : a }) }, filterBy : function(b, a) { this.continuous = false; a = a || this; var c = this.tickStore; c.clearFilter(true); c.suspendEvents(true); c.filter([{ filterFn : function(e, d) { return b.call(a, e.data, d) } }]); if (c.getCount() === 0) { Ext.Error .raise("Invalid time axis filter - no columns passed through the filter. Please check your filter method."); this.clearFilter() } c.resumeEvents() }, isContinuous : function() { return this.continuous && !this.tickStore.isFiltered() }, clearFilter : function() { this.continuous = this.originalContinuous; this.tickStore.clearFilter() }, generateTicks : function(a, d, g, i) { var h = [], f, b = Sch.util.Date, e = 0; g = g || this.unit; i = i || this.increment; if (this.autoAdjust) { a = this.floorDate(a || this.getStart(), false); d = this.ceilDate(d || b.add(a, this.mainUnit, this.defaultSpan), false) } while (a < d) { f = this.getNext(a, g, i); if (g === b.HOUR && i > 1 && h.length > 0 && e === 0) { var c = h[h.length - 1]; e = ((c.start.getHours() + i) % 24) - c.end.getHours(); if (e !== 0) { f = b.add(f, b.HOUR, e) } } h.push({ start : a, end : f }); a = f } return h }, getTickFromDate : function(c) { if (this.getStart() > c || this.getEnd() < c) { return -1 } var f = this.tickStore.getRange(), e, a, d, b; for (d = 0, b = f.length; d < b; d++) { a = f[d].data.end; if (c <= a) { e = f[d].data.start; return d + (c > e ? (c - e) / (a - e) : 0) } } return -1 }, getDateFromTick : function(d, f) { var g = this.tickStore.getCount(); if (d === g) { return this.getEnd() } var a = Math.floor(d), e = d - a, c = this.getAt(a); var b = Sch.util.Date.add(c.start, Sch.util.Date.MILLI, e * (c.end - c.start)); if (f) { b = this[f + "Date"](b) } return b }, getAt : function(a) { return this.tickStore.getAt(a).data }, getCount : function() { return this.tickStore.getCount() }, getTicks : function() { var a = []; this.tickStore.each(function(b) { a.push(b.data) }); return a }, getStart : function() { var a = this.tickStore.first(); if (a) { return Ext.Date.clone(a.data.start) } return null }, getEnd : function() { var a = this.tickStore.last(); if (a) { return Ext.Date.clone(a.data.end) } return null }, roundDate : function(r) { var l = Ext.Date.clone(r), b = this.getStart(), s = this.resolutionIncrement; switch (this.resolutionUnit) { case Sch.util.Date.MILLI : var e = Sch.util.Date.getDurationInMilliseconds(b, l), d = Math .round(e / s) * s; l = Sch.util.Date.add(b, Sch.util.Date.MILLI, d); break; case Sch.util.Date.SECOND : var i = Sch.util.Date.getDurationInSeconds(b, l), q = Math .round(i / s) * s; l = Sch.util.Date.add(b, Sch.util.Date.MILLI, q * 1000); break; case Sch.util.Date.MINUTE : var n = Sch.util.Date.getDurationInMinutes(b, l), a = Math .round(n / s) * s; l = Sch.util.Date.add(b, Sch.util.Date.SECOND, a * 60); break; case Sch.util.Date.HOUR : var m = Sch.util.Date.getDurationInHours(this.getStart(), l), j = Math .round(m / s) * s; l = Sch.util.Date.add(b, Sch.util.Date.MINUTE, j * 60); break; case Sch.util.Date.DAY : var c = Sch.util.Date.getDurationInDays(b, l), f = Math.round(c / s) * s; l = Sch.util.Date.add(b, Sch.util.Date.DAY, f); break; case Sch.util.Date.WEEK : Ext.Date.clearTime(l); var o = l.getDay() - this.weekStartDay, t; if (o < 0) { o = 7 + o } if (Math.round(o / 7) === 1) { t = 7 - o } else { t = -o } l = Sch.util.Date.add(l, Sch.util.Date.DAY, t); break; case Sch.util.Date.MONTH : var p = Sch.util.Date.getDurationInMonths(b, l) + (l.getDate() / Ext.Date.getDaysInMonth(l)), h = Math .round(p / s) * s; l = Sch.util.Date.add(b, Sch.util.Date.MONTH, h); break; case Sch.util.Date.QUARTER : Ext.Date.clearTime(l); l.setDate(1); l = Sch.util.Date.add(l, Sch.util.Date.MONTH, 3 - (l.getMonth() % 3)); break; case Sch.util.Date.YEAR : var k = Sch.util.Date.getDurationInYears(b, l), g = Math .round(k / s) * s; l = Sch.util.Date.add(b, Sch.util.Date.YEAR, g); break } return l }, floorDate : function(t, d, v) { d = d !== false; var n = Ext.Date.clone(t), b = d ? this.getStart() : null, u = this.resolutionIncrement, k; if (v) { k = v } else { k = d ? this.resolutionUnit : this.mainUnit } switch (k) { case Sch.util.Date.MILLI : if (d) { var f = Sch.util.Date.getDurationInMilliseconds(b, n), e = Math .floor(f / u) * u; n = Sch.util.Date.add(b, Sch.util.Date.MILLI, e) } break; case Sch.util.Date.SECOND : if (d) { var j = Sch.util.Date.getDurationInSeconds(b, n), s = Math .floor(j / u) * u; n = Sch.util.Date.add(b, Sch.util.Date.MILLI, s * 1000) } else { n.setMilliseconds(0) } break; case Sch.util.Date.MINUTE : if (d) { var p = Sch.util.Date.getDurationInMinutes(b, n), a = Math .floor(p / u) * u; n = Sch.util.Date.add(b, Sch.util.Date.SECOND, a * 60) } else { n.setSeconds(0); n.setMilliseconds(0) } break; case Sch.util.Date.HOUR : if (d) { var o = Sch.util.Date .getDurationInHours(this.getStart(), n), l = Math .floor(o / u) * u; n = Sch.util.Date.add(b, Sch.util.Date.MINUTE, l * 60) } else { n.setMinutes(0); n.setSeconds(0); n.setMilliseconds(0) } break; case Sch.util.Date.DAY : if (d) { var c = Sch.util.Date.getDurationInDays(b, n), g = Math .floor(c / u) * u; n = Sch.util.Date.add(b, Sch.util.Date.DAY, g) } else { Ext.Date.clearTime(n) } break; case Sch.util.Date.WEEK : var r = n.getDay(); Ext.Date.clearTime(n); if (r !== this.weekStartDay) { n = Sch.util.Date.add(n, Sch.util.Date.DAY, -(r > this.weekStartDay ? (r - this.weekStartDay) : (7 - r - this.weekStartDay))) } break; case Sch.util.Date.MONTH : if (d) { var q = Sch.util.Date.getDurationInMonths(b, n), i = Math .floor(q / u) * u; n = Sch.util.Date.add(b, Sch.util.Date.MONTH, i) } else { Ext.Date.clearTime(n); n.setDate(1) } break; case Sch.util.Date.QUARTER : Ext.Date.clearTime(n); n.setDate(1); n = Sch.util.Date.add(n, Sch.util.Date.MONTH, -(n.getMonth() % 3)); break; case Sch.util.Date.YEAR : if (d) { var m = Sch.util.Date.getDurationInYears(b, n), h = Math .floor(m / u) * u; n = Sch.util.Date.add(b, Sch.util.Date.YEAR, h) } else { n = new Date(t.getFullYear(), 0, 1) } break } return n }, ceilDate : function(c, b, f) { var e = Ext.Date.clone(c); b = b !== false; var a = b ? this.resolutionIncrement : 1, g = false, d; if (f) { d = f } else { d = b ? this.resolutionUnit : this.mainUnit } switch (d) { case Sch.util.Date.DAY : if (e.getMinutes() > 0 || e.getSeconds() > 0 || e.getMilliseconds() > 0) { g = true } break; case Sch.util.Date.WEEK : Ext.Date.clearTime(e); if (e.getDay() !== this.weekStartDay) { g = true } break; case Sch.util.Date.MONTH : Ext.Date.clearTime(e); if (e.getDate() !== 1) { g = true } break; case Sch.util.Date.QUARTER : Ext.Date.clearTime(e); if (e.getMonth() % 3 !== 0) { g = true } break; case Sch.util.Date.YEAR : Ext.Date.clearTime(e); if (e.getMonth() !== 0 && e.getDate() !== 1) { g = true } break; default : break } if (g) { return this.getNext(e, d, a) } else { return e } }, getNext : function(b, c, a) { return Sch.util.Date.getNext(b, c, a, this.weekStartDay) }, getResolution : function() { return { unit : this.resolutionUnit, increment : this.resolutionIncrement } }, setResolution : function(b, a) { this.resolutionUnit = b; this.resolutionIncrement = a || 1 }, shiftNext : function(a) { a = a || this.getShiftIncrement(); var b = this.getShiftUnit(); this.setTimeSpan(Sch.util.Date.add(this.getStart(), b, a), Sch.util.Date.add(this.getEnd(), b, a)) }, shiftPrevious : function(a) { a = -(a || this.getShiftIncrement()); var b = this.getShiftUnit(); this.setTimeSpan(Sch.util.Date.add(this.getStart(), b, a), Sch.util.Date.add(this.getEnd(), b, a)) }, getShiftUnit : function() { return this.shiftUnit || this.getMainUnit() }, getShiftIncrement : function() { return this.shiftIncrement || 1 }, getUnit : function() { return this.unit }, getIncrement : function() { return this.increment }, timeSpanInAxis : function(b, a) { if (this.continuous) { return Sch.util.Date.intersectSpans(b, a, this.getStart(), this .getEnd()) } else { return (b < this.getStart() && a > this.getEnd()) || this.getTickFromDate(b) !== this.getTickFromDate(a) } }, forEachInterval : function(b, a, c) { c = c || this; if (b === "top" || (b === "middle" && this.headerConfig.bottom)) { this.forEachAuxInterval(b, a, c) } else { this.tickStore.each(function(e, d) { return a.call(c, e.data.start, e.data.end, d) }) } }, forEachMainInterval : function(a, b) { this.forEachInterval("middle", a, b) }, forEachAuxInterval : function(b, a, f) { f = f || this; var c = this.getEnd(), g = this.getStart(), e = 0, d; while (g < c) { d = Sch.util.Date.min(this.getNext(g, this.headerConfig[b].unit, this.headerConfig[b].increment || 1), c); a.call(f, g, d, e); g = d; e++ } } }); Ext.define("Sch.preset.Manager", { extend : "Ext.util.MixedCollection", requires : ["Sch.util.Date", "Sch.util.HeaderRenderers"], singleton : true, constructor : function() { this.callParent(arguments); this.registerDefaults() }, registerPreset : function(b, a) { if (a) { var c = a.headerConfig; var d = Sch.util.Date; for (var e in c) { if (c.hasOwnProperty(e)) { if (d[c[e].unit]) { c[e].unit = d[c[e].unit.toUpperCase()] } } } if (!a.timeColumnWidth) { a.timeColumnWidth = 50 } if (a.timeResolution && d[a.timeResolution.unit]) { a.timeResolution.unit = d[a.timeResolution.unit .toUpperCase()] } if (a.shiftUnit && d[a.shiftUnit]) { a.shiftUnit = d[a.shiftUnit.toUpperCase()] } } if (this.isValidPreset(a)) { if (this.containsKey(b)) { this.removeAtKey(b) } this.add(b, a) } else { throw "Invalid preset, please check your configuration" } }, isValidPreset : function(a) { var d = Sch.util.Date, b = true, c = Sch.util.Date.units; for (var e in a.headerConfig) { if (a.headerConfig.hasOwnProperty(e)) { b = b && Ext.Array.indexOf(c, a.headerConfig[e].unit) >= 0 } } if (a.timeResolution) { b = b && Ext.Array.indexOf(c, a.timeResolution.unit) >= 0 } if (a.shiftUnit) { b = b && Ext.Array.indexOf(c, a.shiftUnit) >= 0 } return b }, getPreset : function(a) { return this.get(a) }, deletePreset : function(a) { this.removeAtKey(a) }, registerDefaults : function() { var b = this, a = this.defaultPresets; for (var c in a) { b.registerPreset(c, a[c]) } }, defaultPresets : { minuteAndHour : { timeColumnWidth : 100, rowHeight : 24, resourceColumnWidth : 100, displayDateFormat : "G:i", shiftIncrement : 1, shiftUnit : "HOUR", defaultSpan : 24, timeResolution : { unit : "MINUTE", increment : 30 }, headerConfig : { middle : { unit : "MINUTE", increment : "30", dateFormat : "i" }, top : { unit : "HOUR", dateFormat : "D, GA/m" } } }, hourAndDay : { timeColumnWidth : 60, rowHeight : 24, resourceColumnWidth : 100, displayDateFormat : "G:i", shiftIncrement : 1, shiftUnit : "DAY", defaultSpan : 24, timeResolution : { unit : "MINUTE", increment : 30 }, headerConfig : { middle : { unit : "HOUR", dateFormat : "G:i" }, top : { unit : "DAY", dateFormat : "D d/m" } } }, dayAndWeek : { timeColumnWidth : 100, rowHeight : 24, resourceColumnWidth : 100, displayDateFormat : "Y-m-d G:i", shiftUnit : "DAY", shiftIncrement : 1, defaultSpan : 5, timeResolution : { unit : "HOUR", increment : 1 }, headerConfig : { middle : { unit : "DAY", dateFormat : "D d M" }, top : { unit : "WEEK", dateFormat : "W M Y", renderer : function(c, b, a) { return Sch.util.Date.getShortNameOfUnit("WEEK") + "." + Ext.Date.format(c, "W M Y") } } } }, weekAndDay : { timeColumnWidth : 100, rowHeight : 24, resourceColumnWidth : 100, displayDateFormat : "Y-m-d", shiftUnit : "WEEK", shiftIncrement : 1, defaultSpan : 1, timeResolution : { unit : "DAY", increment : 1 }, headerConfig : { bottom : { unit : "DAY", increment : 1, dateFormat : "d/m" }, middle : { unit : "WEEK", dateFormat : "D d M", align : "left" } } }, weekAndMonth : { timeColumnWidth : 100, rowHeight : 24, resourceColumnWidth : 100, displayDateFormat : "Y-m-d", shiftUnit : "WEEK", shiftIncrement : 5, defaultSpan : 6, timeResolution : { unit : "DAY", increment : 1 }, headerConfig : { middle : { unit : "WEEK", renderer : function(c, b, a) { a.align = "left"; return Ext.Date.format(c, "d M") } }, top : { unit : "MONTH", dateFormat : "M Y" } } }, monthAndYear : { timeColumnWidth : 110, rowHeight : 24, resourceColumnWidth : 100, displayDateFormat : "Y-m-d", shiftIncrement : 3, shiftUnit : "MONTH", defaultSpan : 12, timeResolution : { unit : "DAY", increment : 1 }, headerConfig : { middle : { unit : "MONTH", dateFormat : "M Y" }, top : { unit : "YEAR", dateFormat : "Y" } } }, year : { timeColumnWidth : 100, rowHeight : 24, resourceColumnWidth : 100, displayDateFormat : "Y-m-d", shiftUnit : "YEAR", shiftIncrement : 1, defaultSpan : 1, timeResolution : { unit : "MONTH", increment : 1 }, headerConfig : { bottom : { unit : "QUARTER", renderer : function(c, b, a) { return Ext.String.format(Sch.util.Date .getShortNameOfUnit("QUARTER") .toUpperCase() + "{0}", Math.floor(c .getMonth() / 3) + 1) } }, middle : { unit : "YEAR", dateFormat : "Y" } } }, weekAndDayLetter : { timeColumnWidth : 20, rowHeight : 24, resourceColumnWidth : 100, displayDateFormat : "Y-m-d", shiftUnit : "WEEK", shiftIncrement : 1, defaultSpan : 10, timeResolution : { unit : "DAY", increment : 1 }, headerConfig : { bottom : { unit : "DAY", increment : 1, renderer : function(a) { return Ext.Date.dayNames[a.getDay()].substring( 0, 1) } }, middle : { unit : "WEEK", dateFormat : "D d M Y", align : "left" } } }, weekDateAndMonth : { timeColumnWidth : 30, rowHeight : 24, resourceColumnWidth : 100, displayDateFormat : "Y-m-d", shiftUnit : "WEEK", shiftIncrement : 1, defaultSpan : 10, timeResolution : { unit : "DAY", increment : 1 }, headerConfig : { middle : { unit : "WEEK", dateFormat : "d" }, top : { unit : "MONTH", dateFormat : "Y F", align : "left" } } } } }); Ext.define("Sch.feature.AbstractTimeSpan", { extend : "Ext.AbstractPlugin", lockableScope : "normal", schedulerView : null, timeAxis : null, containerEl : null, expandToFitView : false, disabled : false, cls : null, template : null, store : null, renderElementsBuffered : false, renderDelay : 15, constructor : function(a) { this.uniqueCls = this.uniqueCls || ("sch-timespangroup-" + Ext.id()); Ext.apply(this, a) }, setDisabled : function(a) { if (a) { this.removeElements() } this.disabled = a }, getElements : function() { if (this.containerEl) { return this.containerEl.select("." + this.uniqueCls) } return null }, removeElements : function() { var a = this.getElements(); if (a) { a.remove() } }, init : function(a) { this.timeAxis = a.getTimeAxis(); this.schedulerView = a.getSchedulingView(); if (!this.store) { Ext.Error.raise("Error: You must define a store for this plugin") } this.schedulerView.on({ afterrender : this.onAfterRender, destroy : this.onDestroy, scope : this }) }, onAfterRender : function(b) { var a = this.schedulerView; this.containerEl = a.el; a.mon(this.store, { load : this.renderElements, datachanged : this.renderElements, clear : this.renderElements, add : this.renderElements, remove : this.renderElements, update : this.refreshSingle, scope : this }); if (Ext.data.NodeStore && a.store instanceof Ext.data.NodeStore) { if (a.animate) { } else { a.mon(a.store, { expand : this.renderElements, collapse : this.renderElements, scope : this }) } } a.on({ refresh : this.renderElements, itemadd : this.renderElements, itemremove : this.renderElements, itemupdate : this.renderElements, groupexpand : this.renderElements, groupcollapse : this.renderElements, columnwidthchange : this.renderElements, resize : this.renderElements, scope : this }); a.headerCt.on({ add : this.renderElements, remove : this.renderElements, scope : this }); a.ownerCt.up("panel").on({ viewchange : this.renderElements, orientationchange : this.renderElements, scope : this }); this.renderElements() }, renderElements : function() { if (this.renderElementsBuffered || this.disabled || this.schedulerView.headerCt.getColumnCount() === 0) { return } this.renderElementsBuffered = true; Ext.Function.defer(this.renderElementsInternal, this.renderDelay, this) }, renderElementsInternal : function() { this.renderElementsBuffered = false; if (this.disabled || this.schedulerView.isDestroyed || this.schedulerView.headerCt.getColumnCount() === 0) { return } this.removeElements(); Ext.core.DomHelper.insertHtml("afterBegin", this.containerEl.dom, this .generateMarkup()) }, generateMarkup : function(b) { var d = this.timeAxis.getStart(), a = this.timeAxis.getEnd(), c = this .getElementData(d, a, null, b); return this.template.apply(c) }, getElementData : function(b, a) { throw "Abstract method call" }, onDestroy : function() { if (this.store.autoDestroy) { this.store.destroy() } }, refreshSingle : function(c, b) { var e = Ext.get(this.uniqueCls + "-" + b.internalId); if (e) { var g = this.timeAxis.getStart(), a = this.timeAxis.getEnd(), f = this .getElementData(g, a, [b])[0], d = b.clsField || "Cls"; if (f) { e.dom.className = this.cls + " " + this.uniqueCls + " " + (f[d] || ""); e.setTop(f.top); e.setLeft(f.left); e.setSize(f.width, f.height) } else { Ext.destroy(e) } } else { this.renderElements() } } }); Ext.define("Sch.plugin.Lines", { extend : "Sch.feature.AbstractTimeSpan", cls : "sch-timeline", showTip : true, innerTpl : null, init : function(b) { this.callParent(arguments); var a = this.schedulerView; if (Ext.isString(this.innerTpl)) { this.innerTpl = new Ext.XTemplate(this.innerTpl) } var c = this.innerTpl; if (!this.template) { this.template = new Ext.XTemplate( '', '
' + (c ? "{[this.renderInner(values)]}" : "") + "
", "
", { getTipText : function(d) { return a.getFormattedDate(d.Date) + " " + (d.Text || "") }, renderInner : function(d) { return c.apply(d) } }) } }, getElementData : function(j, m, c) { var n = this.store, h = this.schedulerView, e = c || n.getRange(), g = [], a, b, k; for (var f = 0, d = e.length; f < d; f++) { a = e[f]; b = a.get("Date"); if (b && Sch.util.Date.betweenLesser(b, j, m)) { k = h.getTimeSpanRegion(b, null, this.expandToFitView); g[g.length] = Ext.apply({ id : a.internalId, left : k.left, top : k.top, width : 1, height : k.bottom - k.top }, a.data) } } return g } }); Ext.define("Sch.plugin.Zones", { extend : "Sch.feature.AbstractTimeSpan", innerTpl : null, requires : ["Sch.model.Range"], cls : "sch-zone", init : function(a) { if (Ext.isString(this.innerTpl)) { this.innerTpl = new Ext.XTemplate(this.innerTpl) } var b = this.innerTpl; if (!this.template) { this.template = new Ext.XTemplate( '
' + (b ? "{[this.renderInner(values)]}" : "") + "
", { renderInner : function(c) { return b.apply(c) } }) } this.callParent(arguments) }, getElementData : function(k, o, d, p) { var q = this.store, j = this.schedulerView, f = d || q.getRange(), h = [], a, n, c, m; for (var g = 0, e = f.length; g < e; g++) { a = f[g]; n = a.getStartDate(); c = a.getEndDate(); if (n && c && Sch.util.Date.intersectSpans(n, c, k, o)) { m = j.getTimeSpanRegion(Sch.util.Date.max(n, k), Sch.util.Date .min(c, o), this.expandToFitView); var b = m.right - m.left; h[h.length] = Ext.apply({ id : a.internalId, left : m.left, top : m.top, width : p ? 0 : b, height : m.bottom - m.top, style : p ? ("border-left-width:" + b + "px") : "", Cls : a.getCls() }, a.data) } } return h } }); Ext.define("Sch.plugin.Pan", { alias : "plugin.pan", extend : "Ext.AbstractPlugin", lockableScope : "normal", enableVerticalPan : true, panel : null, constructor : function(a) { Ext.apply(this, a) }, init : function(a) { this.panel = a.normalGrid || a; this.view = a.getSchedulingView(); this.view.on("afterrender", this.onRender, this) }, onRender : function(a) { this.view.el.on("mousedown", this.onMouseDown, this) }, onMouseDown : function(b, a) { if (b.getTarget("." + this.view.timeCellCls, 10) && !b.getTarget(this.view.eventSelector)) { this.mouseX = b.getPageX(); this.mouseY = b.getPageY(); Ext.getBody().on("mousemove", this.onMouseMove, this); Ext.getDoc().on("mouseup", this.onMouseUp, this); if (Ext.isIE || Ext.isGecko) { Ext.getBody().on("mouseenter", this.onMouseUp, this) } b.stopEvent() } }, onMouseMove : function(d) { d.stopEvent(); var a = d.getPageX(), f = d.getPageY(), c = a - this.mouseX, b = f - this.mouseY; this.panel.scrollByDeltaX(-c); this.mouseX = a; this.mouseY = f; if (this.enableVerticalPan) { this.panel.scrollByDeltaY(-b) } }, onMouseUp : function(a) { Ext.getBody().un("mousemove", this.onMouseMove, this); Ext.getDoc().un("mouseup", this.onMouseUp, this); if (Ext.isIE || Ext.isGecko) { Ext.getBody().un("mouseenter", this.onMouseUp, this) } } }); Ext.define("Sch.view.Locking", { extend : "Ext.grid.LockingView", scheduleEventRelayRe : /^(schedule|event|beforeevent|afterevent|dragcreate|beforedragcreate|afterdragcreate|beforetooltipshow)/, constructor : function(b) { this.callParent(arguments); var e = this, g = [], a = e.scheduleEventRelayRe, f = b.normal .getView(), c = f.events, d; for (d in c) { if (c.hasOwnProperty(d) && a.test(d)) { g.push(d) } } e.relayEvents(f, g) }, getElementFromEventRecord : function(a) { return this.normal.getView().getElementFromEventRecord(a) }, onClear : function() { this.relayFn("onClear", arguments) }, beginBulkUpdate : function() { this.relayFn("beginBulkUpdate", arguments) }, endBulkUpdate : function() { this.relayFn("endBulkUpdate", arguments) }, refreshKeepingScroll : function() { this.locked.getView().refresh(); this.normal.getView().refreshKeepingScroll() } }); Ext.define("Sch.column.Time", { extend : "Ext.grid.column.Column", alias : "timecolumn", draggable : false, groupable : false, hideable : false, sortable : false, fixed : true, align : "center", tdCls : "sch-timetd", menuDisabled : true, initComponent : function() { this.addEvents("timeheaderdblclick"); this.enableBubble("timeheaderdblclick"); this.callParent() }, initRenderData : function() { var a = this; a.renderData.headerCls = a.renderData.headerCls || a.headerCls; return a.callParent(arguments) }, onElDblClick : function(b, a) { this.callParent(arguments); this.fireEvent("timeheaderdblclick", this, this.startDate, this.endDate, b) } }, function() { Sch.column.Time.prototype.renderTpl = Sch.column.Time.prototype.renderTpl .replace("column-header-inner", "column-header-inner sch-timeheader {headerCls}") }); Ext.define("Sch.column.timeAxis.Horizontal", { extend : "Ext.grid.column.Column", alias : "widget.timeaxiscolumn", requires : ["Ext.Date", "Ext.XTemplate", "Sch.column.Time", "Sch.preset.Manager"], cls : "sch-timeaxiscolumn", timeAxis : null, renderTpl : '
{topHeaderCells}{middleHeaderCells}
{%this.renderContainer(out,values)%}', headerRowTpl : '{cells}
', headerCellTpl : '
{header}
', columnConfig : {}, timeCellRenderer : null, timeCellRendererScope : null, columnWidth : null, previousWidth : null, previousHeight : null, initComponent : function() { if (!(this.headerRowTpl instanceof Ext.Template)) { this.headerRowTpl = Ext.create("Ext.XTemplate", this.headerRowTpl) } if (!(this.headerCellTpl instanceof Ext.Template)) { this.headerCellTpl = Ext .create("Ext.XTemplate", this.headerCellTpl) } this.columns = [{}]; this.addEvents("timeheaderdblclick", "timeaxiscolumnreconfigured"); this.enableBubble("timeheaderdblclick"); this.stubForResizer = new Ext.Component({ isOnLeftEdge : function() { return false }, isOnRightEdge : function() { return false }, el : { dom : { style : {} } } }); this.callParent(arguments); this.onTimeAxisReconfigure(); this .mon(this.timeAxis, "reconfigure", this.onTimeAxisReconfigure, this) }, getSchedulingView : function() { return this.getOwnerHeaderCt().view }, onTimeAxisReconfigure : function() { var e = this.timeAxis, d = e.preset.timeColumnWidth, f = this.rendered && this.getSchedulingView(), g = e.headerConfig, b = e .getStart(), c = e.getEnd(), h = { renderer : this.timeColumnRenderer, scope : this, width : this.rendered ? f.calculateTimeColumnWidth(d) : d }; delete this.previousWidth; delete this.previousHeight; var j = this.columnConfig = this.createColumns(this.timeAxis, g, h); Ext.suspendLayouts(); this.removeAll(); if (this.rendered) { var a = this.el.child(".x-column-header-inner"); a.select("table").remove(); var i = this.initRenderData(); if (j.top) { Ext.core.DomHelper.append(a, i.topHeaderCells) } if (j.middle) { Ext.core.DomHelper.append(a, i.middleHeaderCells) } if (!j.top && !j.middle) { this.addCls("sch-header-single-row") } else { this.removeCls("sch-header-single-row") } } Ext.resumeLayouts(); this.add(j.bottom); if (this.rendered) { if (this.fireEvent("timeaxiscolumnreconfigured", this) !== false) { f.refresh() } } }, beforeRender : function() { var a = this.columnConfig; if (!a.middle && !a.top) { this.addCls("sch-header-single-row") } this.callParent(arguments) }, timeColumnRenderer : function(i, e, f, l, d, c, k) { var a = ""; if (Ext.isIE) { e.style += ";z-index:" + (this.items.getCount() - d) } if (this.timeCellRenderer) { var h = this.timeAxis, b = h.getAt(d), g = b.start, j = b.end; a = this.timeCellRenderer.call(this.timeCellRendererScope || this, e, f, l, d, c, g, j) } return a }, initRenderData : function() { var a = this.columnConfig; var c = a.top ? this.headerRowTpl.apply({ cells : this.headerCellTpl.apply(a.top), position : "top", tstyle : "border-top : 0; width : 100px" }) : ""; var b = a.middle ? this.headerRowTpl.apply({ cells : this.headerCellTpl.apply(a.middle), position : "middle", tstyle : a.top ? "width : 100px" : "border-top : 0; width : 100px" }) : ""; return Ext.apply(this.callParent(arguments), { topHeaderCells : c, middleHeaderCells : b }) }, defaultRenderer : function(c, b, a) { return Ext.Date.format(c, a) }, createColumns : function(f, d, g) { if (!f || !d) { throw "Invalid parameters passed to createColumns" } var c = [], a = d.bottom || d.middle, h, e = this; f.forEachInterval(d.bottom ? "bottom" : "middle", function(l, j, k) { h = { align : a.align || "center", headerCls : "", startDate : l, endDate : j }; if (a.renderer) { h.header = a.renderer.call(a.scope || e, l, j, h, k) } else { h.header = e.defaultRenderer(l, j, a.dateFormat) } c[c.length] = Ext .create("Sch.column.Time", Ext.apply(h, g)) }); var b = this.createHeaderRows(f, d); return { bottom : c, middle : b.middle, top : b.top } }, createHeaderRows : function(e, c) { var d = {}; if (c.top) { var a; if (c.top.cellGenerator) { a = c.top.cellGenerator.call(this, e.getStart(), e.getEnd()) } else { a = this.createHeaderRow(e, c.top) } d.top = this.processHeaderRow(a, "top") } if (c.bottom) { var b; if (c.middle.cellGenerator) { b = c.middle.cellGenerator.call(this, e.getStart(), e.getEnd()) } else { b = this.createHeaderRow(e, c.middle) } d.middle = this.processHeaderRow(b, "middle") } return d }, processHeaderRow : function(c, a) { var b = this; Ext.each(c, function(d, e) { d.index = e; d.position = a; d.headerId = b.stubForResizer.id }); return c }, createHeaderRow : function(e, k) { var n = [], l, a = e.getStart(), c = e.getEnd(), m = c - a, j = [], b = a, d = 0, f, g = k.align || "center", h; while (b < c) { h = Sch.util.Date.min(e.getNext(b, k.unit, k.increment || 1), c); l = { align : g, start : b, end : h, headerCls : "" }; if (k.renderer) { l.header = k.renderer.call(k.scope || this, b, h, l, d) } else { l.header = this.defaultRenderer(b, h, k.dateFormat, l, d) } n.push(l); b = h; d++ } return n }, afterLayout : function() { delete this.columnWidth; this.callParent(arguments); var b = this.getWidth(); var g = this.getHeight(); if (b === this.previousWidth && g === this.previousHeight) { return } this.previousWidth = b; this.previousHeight = g; var i = this.columnConfig; var e = this; var c = this.el; var f = i.top; var d = 0; var a = 0; if (f) { c.select(".sch-header-row-top").setWidth(this.lastBox.width); c.select(".sch-header-row-top td").each(function(l, m, j) { var k = e.getHeaderGroupCellWidth(f[j].start, f[j].end); l.setVisibilityMode(Ext.Element.DISPLAY); if (k) { d += k; l.show(); l.setWidth(k) } else { l.hide() } }) } var h = i.middle; if (h) { c.select(".sch-header-row-middle").setWidth(this.lastBox.width); c.select(".sch-header-row-middle td").each(function(l, m, j) { var k = e.getHeaderGroupCellWidth(h[j].start, h[j].end); l.setVisibilityMode(Ext.Element.DISPLAY); if (k) { a += k; l.show(); l.setWidth(k) } else { l.hide() } }) } }, getHeaderGroupCellWidth : function(h, b) { var e = this.timeAxis.unit, d = this.timeAxis.increment, c, g = Sch.util.Date .getMeasuringUnit(e), a = Sch.util.Date.getDurationInUnit(h, b, g), f = this.getSchedulingView(); if (this.timeAxis.isContinuous()) { c = a * f.getSingleUnitInPixels(g) } else { c = f.getXYFromDate(b)[0] - f.getXYFromDate(h)[0] } return c }, onElDblClick : function(d, f) { this.callParent(arguments); var e = d.getTarget(".sch-column-header"); if (e) { var a = Ext.fly(e).getAttribute("headerPosition"), b = Ext.fly(e) .getAttribute("headerIndex"), c = this.columnConfig[a][b]; this.fireEvent("timeheaderdblclick", this, c.start, c.end, d) } }, getTimeColumnWidth : function() { if (this.columnWidth === null) { this.columnWidth = this.items.get(0).getWidth() } return this.columnWidth }, setTimeColumnWidth : function(a) { this.suspendEvents(); this.items.each(function(b) { b.setWidth(a) }); this.resumeEvents() } }); Ext.define("Sch.column.timeAxis.HorizontalSingle", { extend : "Sch.column.Time", alias : "widget.singletimeaxiscolumn", requires : ["Ext.Date", "Ext.XTemplate", "Sch.preset.Manager"], cls : "sch-simple-timeaxis", timeAxis : null, trackHeaderOver : true, compactCellWidthThreshold : 16, renderTpl : '
{topHeaderCells}{middleHeaderCells}{bottomHeaderCells}
{%this.renderContainer(out,values)%}', headerRowTpl : '
{header}
', columnConfig : {}, columnWidth : null, nbrTimeColumns : null, initComponent : function() { this.tdCls += " sch-singletimetd"; if (!(this.headerRowTpl instanceof Ext.Template)) { this.headerRowTpl = Ext.create("Ext.XTemplate", this.headerRowTpl) } this.addEvents("timeheaderdblclick", "timeaxiscolumnreconfigured"); this.enableBubble("timeheaderdblclick"); this.callParent(arguments); this.onTimeAxisReconfigure(); this .mon(this.timeAxis, "reconfigure", this.onTimeAxisReconfigure, this); this.on("resize", this.refreshHeaderSizes, this); this.ownHoverCls = this.hoverCls; this.hoverCls = "" }, getSchedulingView : function() { return this.getOwnerHeaderCt().view }, onTimeAxisReconfigure : function() { var h = this.timeAxis, g = h.preset.timeColumnWidth, j = this.rendered && this.getSchedulingView(), l = h.headerConfig, c = h .getStart(), f = h.getEnd(), d = this.rendered ? j .calculateTimeColumnWidth(g) : g; var o = this.columnConfig = this.createHeaderRows(l); var a = o.bottom || o.middle; if (this.rendered) { var e; var b = this.el.child(".x-column-header-inner"); var i = b.dom; var k = i.style.display; var m = i.parentNode; i.style.display = "none"; m.removeChild(i); i.innerHTML = ""; var n = this.initRenderData(); if (o.top) { e = Ext.core.DomHelper.append(b, n.topHeaderCells); this.refreshHeaderRow("top", e) } if (o.middle) { e = Ext.core.DomHelper.append(b, n.middleHeaderCells); this.refreshHeaderRow("middle", e) } if (o.bottom) { e = Ext.core.DomHelper.append(b, n.bottomHeaderCells); this.refreshHeaderRow("bottom", e) } if (!o.top && !o.middle) { this.addCls("sch-header-single-row") } else { this.removeCls("sch-header-single-row") } m.appendChild(i); i.style.display = k; if (d !== this.columnWidth || this.nbrTimeColumns !== a.length) { this.nbrTimeColumns = a.length; this.setTimeColumnWidth(d) } if (this.fireEvent("timeaxiscolumnreconfigured", this) !== false) { j.refreshKeepingResourceScroll(true) } } else { if (d !== this.columnWidth || this.nbrTimeColumns !== a.length) { this.nbrTimeColumns = a.length; this.setTimeColumnWidth(d) } } }, beforeRender : function() { var b = this, a = this.columnConfig; if (!a.middle && !a.top) { b.addCls("sch-header-single-row") } b.callParent(arguments) }, afterRender : function() { var a = this; if (this.trackHeaderOver) { a.el.on({ mousemove : a.highlightCell, delegate : "div.sch-simple-timeheader", scope : a }); a.el.on({ mouseleave : a.clearHighlight, scope : a }) } a.callParent(arguments) }, initRenderData : function() { var a = this.columnConfig; var c = a.top ? this.headerRowTpl.apply({ cells : a.top, position : "top", tstyle : "border-top : 0; width : 100px" }) : ""; var b = a.middle ? this.headerRowTpl.apply({ cells : a.middle, position : "middle", tstyle : a.top ? "width : 100px" : "border-top : 0; width : 100px" }) : ""; var d = a.bottom ? this.headerRowTpl.apply({ cells : a.bottom, position : "bottom", tstyle : "width : 100px" }) : ""; return Ext.apply(this.callParent(arguments), { topHeaderCells : c, middleHeaderCells : b, bottomHeaderCells : d }) }, defaultRenderer : function(c, b, a) { return Ext.Date.format(c, a) }, createHeaderRows : function(a) { var b = {}; for (var c in a) { if (a[c].cellGenerator) { b[c] = a[c].cellGenerator.call(this, this.timeAxis.getStart(), this.timeAxis.getEnd()) } else { b[c] = this.createHeaderRow(c, a[c]) } } return b }, createHeaderRow : function(a, c) { var b = [], d = this, f, e = c.align || "center"; this.timeAxis.forEachInterval(a, function(j, g, h) { f = { align : e, start : j, end : g, headerCls : "" }; if (c.renderer) { f.header = c.renderer.call(c.scope || d, j, g, f, h) } else { f.header = d.defaultRenderer(j, g, c.dateFormat, f, h) } if (c.unit === Sch.util.Date.DAY && (!c.increment || c.increment === 1)) { f.headerCls += " sch-dayheadercell-" + j.getDay() } b.push(f) }); return b }, afterLayout : function() { this.callParent(arguments); this.refreshHeaderSizes() }, refreshHeaderSizes : function() { var a = this.columnConfig; if (a.top) { this.refreshHeaderRow("top") } if (a.middle) { this.refreshHeaderRow("middle") } if (a.bottom) { this.refreshHeaderRow("bottom") } }, refreshHeaderRow : function(a, b) { var e = this.el; var f = this.columnConfig[a]; var d = this; var c; var g = a === "bottom" || (a === "middle" && !this.columnConfig.bottom); b = b || e.down(".sch-header-row-" + a, true); Ext.fly(b).setWidth(d.getTotalWidth()); Ext.fly(b).select(" thead > tr > td").each(function(i, j, h) { c = g ? d.columnWidth : d.getHeaderGroupCellWidth(f[h].start, f[h].end); i.setVisibilityMode(Ext.Element.DISPLAY); if (c) { if (Ext.isSafari && Ext.isMac) { c -= 2 } i.show(); i.setWidth(c - (Ext.chromeVersion === 19 ? (h ? 1 : 0) : 0)) } else { i.hide() } }); if (a === "bottom") { if (c < this.compactCellWidthThreshold) { Ext.fly(b).addCls("sch-header-row-compact") } else { Ext.fly(b).removeCls("sch-header-row-compact") } } }, getHeaderGroupCellWidth : function(c, a) { var b = this.getSchedulingView(); return b.getXYFromDate(a)[0] - b.getXYFromDate(c)[0] }, onElDblClick : function(d, f) { var e = d.getTarget(".sch-column-header"); if (e) { var a = Ext.fly(e).getAttribute("headerPosition"), b = Ext.fly(e) .getAttribute("headerIndex"), c = this.columnConfig[a][b]; this.fireEvent("timeheaderdblclick", this, c.start, c.end, d) } }, getTimeColumnWidth : function() { if (this.columnWidth === null) { this.columnWidth = this.getWidth() / this.nbrTimeColumns } return this.columnWidth }, setTimeColumnWidth : function(a) { this.columnWidth = a; if (this.rendered) { Ext.suspendLayouts(); this.setWidth(a * this.nbrTimeColumns); Ext.resumeLayouts(); this.refreshHeaderSizes(); this.ownerCt.updateLayout() } else { this.setWidth(a * this.nbrTimeColumns) } }, getTotalWidth : function() { return this.columnWidth * this.nbrTimeColumns }, highlightCell : function(c, a) { var b = this; if (a !== b.highlightedCell) { b.clearHighlight(); b.highlightedCell = a; Ext.fly(a).addCls(b.ownHoverCls) } }, clearHighlight : function() { var b = this, a = b.highlightedCell; if (a) { Ext.fly(a).removeCls(b.ownHoverCls); delete b.highlightedCell } } }); Ext.define("Sch.mixin.Lockable", { extend : "Ext.grid.Lockable", requires : ["Sch.column.timeAxis.Horizontal", "Sch.column.timeAxis.HorizontalSingle"], findEditingPlugin : function() { var b = this.plugins || []; var c = this; var a; Ext.each(b, function(e, d) { if (Ext.grid.plugin && Ext.grid.plugin.CellEditing && e instanceof Ext.grid.plugin.CellEditing) { a = e; Ext.Array.remove(b, e); return false } }); return a }, processSchedulerPlugins : function() { var e = []; var d = []; var g = []; var a = this.plugins || []; var c = this; for (var b = a.length - 1; b >= 0; b--) { var f = a[b]; if (f.lockableScope) { switch (f.lockableScope) { case "top" : g.push(f); break; case "locked" : e.push(f); break; case "normal" : d.push(f); break } Ext.Array.remove(a, f) } } if (e.length > 0) { c.lockedGridConfig.plugins = (c.lockedGridConfig.plugins || []) .concat(e) } if (d.length > 0) { c.normalGridConfig.plugins = (c.normalGridConfig.plugins || []) .concat(d) } c.topPlugins = g }, injectLockable : function() { var d = this.findEditingPlugin(); var k = this; var g = Ext.data.TreeStore && k.store instanceof Ext.data.TreeStore; var m = k.store.buffered; var c = k.getEventSelectionModel ? k.getEventSelectionModel() : k .getSelectionModel(); k.lockedGridConfig = Ext.apply({}, k.lockedGridConfig || {}); k.normalGridConfig = Ext.apply({}, k.schedulerConfig || k.normalGridConfig || {}); var a = k.lockedGridConfig, j = k.normalGridConfig; Ext.applyIf(k.lockedGridConfig, { xtype : k.lockedXType, id : k.id + "_locked", enableLocking : false, lockable : false, useArrows : true, columnLines : k.columnLines, rowLines : k.rowLines, stateful : k.stateful, delayScroll : function() { if (this.rendered) { return this.self.prototype.delayScroll.apply(this, arguments) } }, split : true, animCollapse : false, collapseDirection : "left", region : "west" }); if (d) { k.lockedGridConfig.plugins = (k.lockedGridConfig.plugins || []) .concat(d) } k.processSchedulerPlugins(); Ext.applyIf(k.normalGridConfig, { xtype : k.normalXType, enableLocking : false, lockable : false, viewType : k.viewType, layout : "fit", sortableColumns : false, enableColumnMove : false, enableColumnResize : false, enableColumnHide : false, selModel : c, eventSelModel : c, _top : k, orientation : k.orientation, viewPreset : k.viewPreset, timeAxis : k.timeAxis, columnLines : k.columnLines, rowLines : k.rowLines, collapseDirection : "right", animCollapse : false, region : "center" }); k.bothCfgCopy = k.bothCfgCopy || (Ext.grid.Panel && Ext.grid.Panel.prototype.bothCfgCopy) || ["invalidateScrollerOnRefresh", "hideHeaders", "enableColumnHide", "enableColumnMove", "enableColumnResize", "sortableColumns"]; if (k.orientation === "vertical") { a.store = j.store = k.timeAxis.tickStore; k.mon(k.resourceStore, { clear : k.refreshResourceColumns, datachanged : k.refreshResourceColumns, update : k.refreshResourceColumns, load : k.refreshResourceColumns, scope : k }) } if (a.width) { k.syncLockedWidth = Ext.emptyFn; a.scroll = "horizontal"; a.scrollerOwner = true } if (k.resourceStore) { j.resourceStore = k.resourceStore } if (k.eventStore) { j.eventStore = k.eventStore } if (k.dependencyStore) { j.dependencyStore = k.dependencyStore } var e = k.lockedViewConfig = k.lockedViewConfig || {}; var l = k.normalViewConfig = k.normalViewConfig || {}; if (g && m && Ext.getScrollbarSize().width === 0) { k.lockedGridConfig.scroll = "horizontal" } if (m) { e.preserveScrollOnRefresh = true } e.enableAnimations = k.normalViewConfig.enableAnimations = false; if (g) { if (Ext.versions.extjs.isLessThan("4.1.3")) { k.normalViewConfig.providedStore = e.providedStore = k.store.nodeStore } else { k.normalViewConfig.store = e.store = k.store.nodeStore } k.overrideNodeStore(k.store.nodeStore) } var f = k.layout; this.callParent(arguments); if (k.topPlugins) { k.plugins = k.topPlugins } if (a.width) { k.lockedGrid.setWidth(a.width); k.normalGrid.getView().addCls("sch-timeline-horizontal-scroll"); k.lockedGrid.getView().addCls("sch-locked-horizontal-scroll") } else { if (k.normalGrid.collapsed) { k.normalGrid.collapsed = false; k.normalGrid.view.on("boxready", function() { k.normalGrid.collapse() }, k, { delay : 10 }) } } var n = k.lockedGrid.getView(); var b = k.normalGrid.getView(); var h; if (m) { h = k.normalGrid.verticalScroller; n.on("render", this.onLockedViewRender, this); this.fixPagingScroller(h); if (Ext.getVersion("extjs").isLessThan("4.1.1")) { if (Ext.getScrollbarSize().width > 0) { n.on({ scroll : { fn : k.onLockedViewScroll, element : "el", scope : k } }) } } } if (Ext.getScrollbarSize().width === 0) { n.addCls("sch-ganttpanel-force-locked-scroll") } if (g) { this.setupLockableTree() } if (!b.deferInitialRefresh) { var i = b.onRender; b.onRender = function() { this.doFirstRefresh = function() { }; i.apply(this, arguments); delete this.doFirstRefresh } } if (m) { b.el = { un : function() { } }; h.bindView(b); b.un("refresh", h.self.prototype.onViewRefresh, h); delete b.el } k.view.clearListeners(); n.on({ refresh : k.updateSpacer, scope : k }); if (!Ext.grid.Lockable.prototype.updateSpacer) { b.on({ refresh : k.updateSpacer, scope : k }) } k.view = Ext.create("Sch.view.Locking", { locked : k.lockedGrid, normal : k.normalGrid, panel : k }); if (k.syncRowHeight) { n.on("refresh", this.onLockedViewRefresh, this); if (g) { k.mon(k.store, { beforeload : function() { n.un({ itemadd : k.onViewItemAdd, scope : k }); b.un({ itemadd : k.onViewItemAdd, scope : k }) }, load : function() { n.un({ itemadd : k.onViewItemAdd, scope : k }); b.un({ itemadd : k.onViewItemAdd, scope : k }); k.prepareFullRowHeightSync(); k.syncRowHeights() } }); k.normalGrid.on("afteritemexpand", k.afterNormalGridItemExpand, k) } n.on({ itemadd : k.onViewItemAdd, scope : k }); b.on({ itemadd : k.onViewItemAdd, itemupdate : k.onNormalViewItemUpdate, groupexpand : k.onNormalViewGroupExpand, scope : k }); if (Ext.isIE9 && Ext.isStrict) { k.onNormalViewItemUpdate = function(o, p, r) { r = r.dom ? r.dom : r; if (k.lockedGridDependsOnSchedule) { var q = k.lockedGrid.getView(); q.suspendEvents(); q.onUpdate(k.lockedGrid.store, o); q.resumeEvents() } var s = k.normalGrid.getView().getNode(p); s.style.height = r.style.height; k.normalHeights[p] = r.style.height; k.syncRowHeights() } } } if (f !== "fit") { k.layout = f } k.normalGrid.on({ collapse : k.onNormalGridCollapse, expand : k.onNormalGridExpand, scope : k }); k.lockedGrid.on({ collapse : k.onLockedGridCollapse, scope : k }); if (this.lockedGrid.view.store !== this.normalGrid.view.store) { Ext.Error .raise("Sch.mixin.Lockable setup failed, not sharing store between the two views") } }, onLockedGridCollapse : function() { if (this.normalGrid.collapsed) { this.normalGrid.expand() } }, onNormalGridCollapse : function() { var a = this; if (!a.normalGrid.reExpander) { a.normalGrid.reExpander = a.normalGrid.placeholder } if (!a.lockedGrid.rendered) { a.lockedGrid.on("render", a.onNormalGridCollapse, a, { delay : 1 }) } else { a.lastLockedWidth = a.lockedGrid.getWidth(); a.lockedGrid.setWidth(a.getWidth() - 35); if (a.lockedGrid.collapsed) { a.lockedGrid.expand() } a.addCls("sch-normalgrid-collapsed") } }, onNormalGridExpand : function() { this.removeCls("sch-normalgrid-collapsed"); this.lockedGrid.setWidth(this.lastLockedWidth) }, fixPagingScroller : function(a) { var b = a.onViewRefresh; a.onViewRefresh = function() { var j = this, l = j.store, i, k = j.view, o = k.el, p = o.dom, r, n, h, q = k.table.dom, m, g; if (j.focusOnRefresh) { o.focus(); j.focusOnRefresh = false } j.disabled = true; var f = l.getCount() === l.getTotalCount(); j.stretcher.setHeight(i = j.getScrollHeight()); g = p.scrollTop; j.isScrollRefresh = (g > 0); if (j.scrollProportion !== undefined) { j.setTablePosition("absolute"); j.setTableTop((j.scrollProportion && j.tableStart > 0 ? (i * j.scrollProportion) - (q.offsetHeight * j.scrollProportion) : 0) + "px") } else { j.setTablePosition("absolute"); j.setTableTop((m = (j.tableStart || 0) * j.rowHeight) + "px"); if (j.scrollOffset) { r = k.getNodes(); n = -o.getOffsetsTo(r[j.commonRecordIndex])[1]; h = n - j.scrollOffset; j.position = (p.scrollTop += h) } else { if ((m > g) || ((m + q.offsetHeight) < g + p.clientHeight)) { if (!(f && !m)) { j.lastScrollDirection = -1; j.position = p.scrollTop = m } } } } j.disabled = false }; a.setViewTableStyle = function(f, h, g) { if (f.table.dom) { f.table.dom.style[h] = g } f = f.lockingPartner; if (f) { if (f.table.dom) { f.table.dom.style[h] = g } } }; var d = a.view.lockingPartner; if (d) { var e = a.onLockRefresh; var c = function(f) { if (f.table.dom) { e.apply(this, arguments) } }; d.un("refresh", e, a); d.on("refresh", c, a); a.onLockRefresh = c } a.view.un("render", a.onViewRender, a); a.onViewRender = function() { var g = this, f = g.view.el; f.setStyle("position", "relative"); g.stretcher = f.createChild({ style : { position : "absolute", width : "1px", height : 0, top : 0, left : 0 } }, f.dom.firstChild) }; a.view.on("render", a.onViewRender, a); if (Ext.getVersion("extjs").isLessThan("4.1.3")) { a.scrollTo = function(m, g, p, r) { var j = this, l = j.view, q = l.el.dom, n = j.store, k = n .getTotalCount(), i, f, h, o; m = Math.min(Math.max(m, 0), k - 1); i = Math .max( Math .min( m - ((j.leadingBufferZone + j.trailingBufferZone) / 2), k - j.viewSize + 1), 0); o = i * j.rowHeight; f = i + j.viewSize - 1; j.lastScrollDirection = undefined; j.disabled = true; n.guaranteeRange(i, f, function() { h = n.pageMap.getRange(m, m)[0]; l.table.dom.style.top = o + "px"; q.scrollTop = o = Math.min(Math.max(0, o - l.table.getOffsetsTo(l .getNode(h))[1]), q.scrollHeight - q.clientHeight); if (Ext.isIE) { q.scrollTop = o } j.disabled = false; if (g) { j.grid.selModel.select(h) } if (p) { p.call(r || j, m, h) } }) } } }, onLockedViewScroll : function() { if (this.store.buffered) { var a = this.normalGrid.getView().el; if (!a || !a.child("table", true)) { return } } return this.callParent(arguments) }, onNormalViewScroll : function() { if (this.store.buffered) { var a = this.lockedGrid.getView().el; if (!a || !a.child("table", true)) { return } } return this.callParent(arguments) }, setupLockableTree : function() { var h = this; var i = h.store.buffered; var c = h.getView(); var l = h.lockedGrid.getView(); var d = h.normalGrid.getView(); var j = d.store; var b = h.store; var e = Sch.mixin.FilterableTreeView.prototype; l.initTreeFiltering = e.initTreeFiltering; l.onFilterChangeStart = e.onFilterChangeStart; l.onFilterChangeEnd = e.onFilterChangeEnd; l.onFilterCleared = e.onFilterCleared; l.onFilterSet = e.onFilterSet; l.initTreeFiltering(); if (i) { b.on("nodestore-datachange-end", function() { if (d.rendered) { h.onNormalViewScroll() } }) } else { this.mon(b, { "root-fill-start" : function() { j.suspendEvents() }, "root-fill-end" : function() { j.resumeEvents(); c.refresh() } }) } this.mon(b, "filter", function(n, m) { j.filter.apply(j, m); c.refresh() }); this.mon(b, "clearfilter", function(m) { j.clearFilter(); c.refresh() }); var g = h.normalGrid.verticalScroller; if (i && g) { var a = g.onGuaranteedRange; g.onGuaranteedRange = function() { a.apply(this, arguments); Ext.suspendLayouts(); c.refresh(); Ext.resumeLayouts() } } var k = l.onAdd; var f = l.onRemove; l.onAdd = function() { Ext.suspendLayouts(); k.apply(this, arguments); Ext.resumeLayouts() }; l.onRemove = function() { Ext.suspendLayouts(); f.apply(this, arguments); Ext.resumeLayouts() } }, onNormalViewItemUpdate : function(a, b, d) { d = d.dom ? d.dom : d; if (this.lockedGridDependsOnSchedule) { var c = this.lockedGrid.getView(); c.suspendEvents(); c.onUpdate(this.lockedGrid.store, a); c.resumeEvents() } var f = this.normalGrid.getView().getNode(b); var e = f.style.height !== d.style.height; f.style.height = d.style.height; this.normalHeights[b] = d.style.height; this.syncRowHeights(e) }, afterNormalGridItemExpand : function(a) { var c = this; var b = c.getSchedulingView(); a.cascadeBy(function(f) { if (f !== a) { var e = b.getNode(f); if (e) { var d = b.indexOf(e); c.normalHeights[d] = e.style.height } } }); c.syncRowHeights(true) }, onViewItemAdd : function(c, d, b) { var e = this.normalGrid.getView(); var f = this.lockedGrid.getView(); if (e.getNodes().length !== f.getNodes().length) { return } var a = this.normalHeights; Ext.each(c, function(h, g) { var i = e.getNode(h); if (i) { a[i.viewIndex] = i.style.height } }); this.syncRowHeights() }, processColumns : function(b) { var a = this.callParent(arguments); var c = []; Ext.each(b, function(d) { if (d.position == "right") { d.processed = true; if (!Ext.isNumber(d.width)) { Ext.Error .raise('"Right" columns must have a fixed width') } c.push(d); Ext.Array.remove(a.locked.items, d); a.lockedWidth -= d.width } }); if (this.orientation === "horizontal") { a.normal.items = [{ xtype : this.lightWeight ? "singletimeaxiscolumn" : "timeaxiscolumn", timeAxis : this.timeAxis, timeCellRenderer : this.timeCellRenderer, timeCellRendererScope : this.timeCellRendererScope, trackHeaderOver : this.trackHeaderOver }].concat(c) } else { a.locked.items = [Ext.apply({ xtype : "verticaltimeaxis", width : 100, timeAxis : this.timeAxis }, this.timeAxisColumnCfg || {})]; a.lockedWidth = a.locked.items[0].width } return a }, prepareFullRowHeightSync : function() { var g = this, h = g.normalGrid.getView(), j = g.lockedGrid.getView(); if (!h.rendered || !j.rendered) { return } var a = h.el, d = j.el, f = a.query(h.getItemSelector()), b = d.query(j .getItemSelector()), e = f.length, c = 0; g.lockedHeights = []; g.normalHeights = []; if (b.length !== e) { return } for (; c < e; c++) { g.normalHeights[c] = f[c].style.height } }, onLockedViewRefresh : function() { this.prepareFullRowHeightSync(); this.syncRowHeights() }, onNormalViewRefresh : function() { var a = this.lockedGrid.getView(); if (this.lockedGridDependsOnSchedule) { a.un("refresh", this.onLockedViewRefresh, this); this.lockedGrid.getView().refresh(); a.on("refresh", this.onLockedViewRefresh, this) } this.prepareFullRowHeightSync(); this.syncRowHeights() }, syncRowHeights : function(b) { if (!this.lockedGrid.getView().rendered || !this.normalGrid.getView().rendered) { return } var j = this, c = j.lockedHeights, k = j.normalHeights, a = [], h = c.length || k.length, f = 0, l, d, e, g; if (c.length || k.length) { l = j.lockedGrid.getView(); d = j.normalGrid.getView(); e = l.el.query(l.getItemSelector()); g = d.el.query(d.getItemSelector()); if (g.length !== e.length) { return } for (; f < h; f++) { if (e[f] && k[f]) { e[f].style.height = k[f] } } j.lockedHeights = []; j.normalHeights = [] } if (b !== false) { j.updateSpacer() } }, getMenuItems : function() { if (Ext.versions.extjs.isGreaterThanOrEqual("4.1.2")) { return this.callParent(arguments) } return function() { return Ext.grid.header.Container.prototype.getMenuItems.apply(this, arguments) } }, applyColumnsState : Ext.emptyFn, updateSpacer : function() { var g = this.lockedGrid.getView(); var e = this.normalGrid.getView(); if (g.rendered && e.rendered && g.el.child("table") && !this.getSchedulingView().__lightRefresh) { var f = this, c = g.el, d = e.el.dom, b = c.dom.id + "-spacer", h = (d.offsetHeight - d.clientHeight) + "px"; f.spacerEl = Ext.getDom(b); if (Ext.isIE6 || Ext.isIE7 || (Ext.isIEQuirks && Ext.isIE8) && f.spacerEl) { Ext.removeNode(f.spacerEl); f.spacerEl = null } if (f.spacerEl) { f.spacerEl.style.height = h } else { var a; if (this.store.buffered) { a = f.normalGrid.verticalScroller.stretcher.item(0).dom.parentNode === c.dom ? f.normalGrid.verticalScroller.stretcher.item(0) : f.normalGrid.verticalScroller.stretcher.item(1) } else { a = c } Ext.core.DomHelper.append(a, { id : b, cls : this.store.buffered ? "sch-locked-buffered-spacer" : "", style : "height: " + h }) } } }, onLockedViewRender : function() { var e = this.normalGrid; if (!this.lockedStretcher) { var c = this.lockedGrid.getView().el; var a = this.lockedStretcher = c.createChild({ cls : "x-stretcher", style : { position : "absolute", width : "1px", height : 0, top : 0, left : 0 } }, c.dom.firstChild) } if (!e.rendered) { e.getView().on("render", this.onLockedViewRender, this); return } var d = this; setTimeout(function() { var f = e.getView().el; if (f && f.dom) { e.getView().el.un("scroll", d.onNormalViewScroll, d); e.getView().el.on("scroll", d.onNormalViewScroll, d) } }, 0); var b = e.verticalScroller; b.stretcher.addCls("x-stretcher"); b.stretcher = new Ext.dom.CompositeElement([this.lockedStretcher, b.stretcher]) }, onNormalViewGroupExpand : function() { this.prepareFullRowHeightSync(); this.syncRowHeights() }, overrideNodeStore : function(c) { var a = c.onNodeCollapse; var b = c.onNodeExpand; c.onNodeCollapse = function() { Ext.suspendLayouts(); a.apply(this, arguments); Ext.resumeLayouts() }; c.onNodeExpand = function() { Ext.suspendLayouts(); b.apply(this, arguments); Ext.resumeLayouts() } } }); Ext.define("Sch.plugin.TreeCellEditing", { extend : "Ext.grid.plugin.CellEditing", init : function(a) { this._grid = a; this.on("beforeedit", this.checkReadOnly, this); this.callParent(arguments) }, checkReadOnly : function() { var a = this._grid; if (!(a instanceof Sch.panel.TimelineTreePanel)) { a = a.up("tablepanel") } return !a.isReadOnly() }, startEditByClick : function(c, a, h, b, g, d, f) { if (f.getTarget(c.expanderSelector)) { return } this.callParent(arguments) }, startEdit : function(a, f) { if (!a || !f) { return } var d = this, b = d.getEditor(a, f), e = a.get(f.dataIndex), c = d .getEditingContext(a, f); a = c.record; f = c.column; d.completeEdit(); if (f && !f.getEditor(a)) { return false } if (b) { c.originalValue = c.value = e; if (d.beforeEdit(c) === false || d.fireEvent("beforeedit", c) === false || c.cancel) { return false } d.context = c; d.setActiveEditor(b); d.setActiveRecord(a); d.setActiveColumn(f); d.grid.view.focusCell({ column : c.colIdx, row : c.rowIdx }); d.editTask.delay(15, d.showEditor, d, [b, c, c.value]) } else { d.grid.getView().getEl(f).focus((Ext.isWebKit || Ext.isIE) ? 10 : false) } }, showEditor : function(b, c, g) { var e = this, a = c.record, f = c.column, h = e.grid .getSelectionModel(), d = h.getCurrentPosition && h.getCurrentPosition(); e.context = c; e.setActiveEditor(b); e.setActiveRecord(a); e.setActiveColumn(f); if (h.selectByPosition && (!d || d.column !== c.colIdx || d.row !== c.rowIdx)) { h.selectByPosition({ row : c.rowIdx, column : c.colIdx }) } b.startEdit(e.getCell(a, f), g, c); e.editing = true; e.scroll = e.view.el.getScroll() }, getEditingContext : function(e, c) { var f = this, a = f.grid, i = a.store, b, d, g = a.getView(), h; if (Ext.isNumber(e)) { b = e; e = i.getAt(b) } else { if (i instanceof Ext.data.Store) { b = i.indexOf(e) } else { b = g.indexOf(g.getNode(e)) } } if (Ext.isNumber(c)) { d = c; c = a.headerCt.getHeaderAtIndex(d) } else { d = c.getIndex() } h = e.get(c.dataIndex); return { grid : a, record : e, field : c.dataIndex, value : h, row : g.getNode(b), column : c, rowIdx : b, colIdx : d } }, startEditByPosition : function(a) { var f = this, d = f.grid, h = d.getSelectionModel(), b = f.view, e = this.view .getNode(a.row), g = d.headerCt.getHeaderAtIndex(a.column), c = b .getRecord(e); if (h.selectByPosition) { h.selectByPosition(a) } f.startEdit(c, g) }, onEditComplete : function(c, g, b) { var f = this, d = f.grid, e = f.getActiveColumn(), h = d .getSelectionModel(), a; if (e) { a = f.context.record; f.setActiveEditor(null); f.setActiveColumn(null); f.setActiveRecord(null); if (!f.validateEdit()) { return } if (!f.context.doNotUpdateRecord && !a.isEqual(g, b)) { a.set(e.dataIndex, g) } if (h.setCurrentPosition) { h.setCurrentPosition(h.getCurrentPosition()) } d.getView().getEl(e).focus(); f.context.value = g; f.fireEvent("edit", f, f.context) } }, onSpecialKey : function(a, f, d) { if (!Ext.versions.extjs.equals("4.1.2.381")) { return this.callParent(arguments) } var c = this, b = this.grid, g; if (d.getKey() === d.TAB) { d.stopEvent(); if (a) { a.onEditorTab(d) } g = b.getSelectionModel(); if (g.onEditorTab) { return g.onEditorTab(b === c.grid ? c : c.lockingPartner, d) } } } }); Ext.define("Sch.feature.ColumnLines", { extend : "Sch.plugin.Lines", cls : "sch-column-line", showTip : false, requires : ["Ext.data.Store"], init : function(b) { this.timeAxis = b.getTimeAxis(); this.store = Ext.create("Ext.data.JsonStore", { model : Ext.define("Sch.model.TimeLine", { extend : "Ext.data.Model", fields : ["start", { name : "Date", convert : function(d, c) { return c.data.start } }] }), data : b.getOrientation() === "horizontal" ? this .getData() : [] }); this.callParent(arguments); var a = this.schedulerView; a.timeAxis.on("reconfigure", this.populate, this) }, populate : function() { var a = this.schedulerView; var b = a.getOrientation() === "horizontal" && a.store.getCount() > 0; this.store.removeAll(b); if (b) { this.store.add(this.getData()) } }, getElementData : function() { var a = this.schedulerView; if (a.getOrientation() === "horizontal" && a.store.getCount() > 0) { return this.callParent(arguments) } return [] }, getData : function() { var a = []; this.timeAxis.forEachMainInterval(function(d, b, c) { if (c > 0) { a.push({ start : d }) } }); a.push({ start : this.timeAxis.getEnd() }); return a } }); Ext.define("Sch.plugin.CurrentTimeLine", { extend : "Sch.plugin.Lines", tooltipText : "Current time", updateInterval : 60000, autoUpdate : true, expandToFitView : true, init : function(c) { var b = Ext.create("Ext.data.JsonStore", { fields : ["Date", "Cls", "Text"], data : [{ Date : new Date(), Cls : "sch-todayLine", Text : this.tooltipText }] }); var a = b.first(); if (this.autoUpdate) { this.runner = Ext.create("Ext.util.TaskRunner"); this.runner.start({ run : function() { a.set("Date", new Date()) }, interval : this.updateInterval }) } c.on("destroy", this.onHostDestroy, this); this.store = b; this.callParent(arguments) }, onHostDestroy : function() { if (this.runner) { this.runner.stopAll() } if (this.store.autoDestroy) { this.store.destroy() } } }); Ext.define("Sch.mixin.TimelineView", { requires : ["Sch.column.Time", "Sch.data.TimeAxis"], orientation : "horizontal", overScheduledEventClass : "sch-event-hover", selectedEventCls : "sch-event-selected", altColCls : "sch-col-alt", timeCellCls : "sch-timetd", timeCellSelector : ".sch-timetd", ScheduleEventMap : { click : "Click", mousedown : "MouseDown", mouseup : "MouseUp", dblclick : "DblClick", contextmenu : "ContextMenu", keydown : "KeyDown", keyup : "KeyUp" }, suppressFitCheck : 0, forceFit : false, inheritables : function() { return { cellBorderWidth : 1, initComponent : function() { this.setOrientation(this.panel._top.orientation || this.orientation); this.addEvents("beforetooltipshow", "scheduleclick", "scheduledblclick", "schedulecontextmenu", "columnwidthchange"); this.enableBubble("columnwidthchange"); var a = {}, c = Sch.util.Date; a[c.DAY] = a[c.WEEK] = a[c.MONTH] = a[c.QUARTER] = a[c.YEAR] = null; Ext.applyIf(this, { eventPrefix : this.id + "-", largeUnits : a }); this.callParent(arguments); if (this.orientation === "horizontal") { this.getTimeAxisColumn().on("timeaxiscolumnreconfigured", this.checkHorizontalFit, this) } var b = this.panel._top; Ext.apply(this, { eventRendererScope : b.eventRendererScope, eventRenderer : b.eventRenderer, eventBorderWidth : b.eventBorderWidth, timeAxis : b.timeAxis, dndValidatorFn : b.dndValidatorFn || Ext.emptyFn, resizeValidatorFn : b.resizeValidatorFn || Ext.emptyFn, createValidatorFn : b.createValidatorFn || Ext.emptyFn, tooltipTpl : b.tooltipTpl, validatorFnScope : b.validatorFnScope || this, snapToIncrement : b.snapToIncrement, timeCellRenderer : b.timeCellRenderer, timeCellRendererScope : b.timeCellRendererScope, readOnly : b.readOnly, eventResizeHandles : b.eventResizeHandles, enableEventDragDrop : b.enableEventDragDrop, enableDragCreation : b.enableDragCreation, dragConfig : b.dragConfig, dropConfig : b.dropConfig, resizeConfig : b.resizeConfig, createConfig : b.createConfig, tipCfg : b.tipCfg, orientation : b.orientation, getDateConstraints : b.getDateConstraints || Ext.emptyFn }); if (this.emptyText) { this.emptyText = '' + this.emptyText + "" } }, onDestroy : function() { if (this.tip) { this.tip.destroy() } this.callParent(arguments) }, afterComponentLayout : function() { this.callParent(arguments); var b = this.getWidth(); var a = this.getHeight(); if (b === this.__prevWidth && a === this.__prevHeight) { return } this.__prevWidth = b; this.__prevHeight = a; if (!this.lockable && !this.suppressFitCheck) { this.checkHorizontalFit() } }, beforeRender : function() { this.callParent(arguments); this.addCls("sch-timelineview"); if (this.readOnly) { this.addCls(this._cmpCls + "-readonly") } }, afterRender : function() { this.callParent(arguments); if (this.overScheduledEventClass) { this.mon(this.el, { mouseover : this.onMouseOver, mouseout : this.onMouseOut, delegate : this.eventSelector, scope : this }) } if (this.tooltipTpl) { this.el.on("mousemove", this.setupTooltip, this, { single : true }) } this.setupTimeCellEvents() }, processUIEvent : function(f) { var c = this, a = f.getTarget(this.eventSelector), d = c.ScheduleEventMap, b = f.type, g = false; if (a && b in d) { this.fireEvent(this.scheduledEventName + b, this, this .resolveEventRecord(a), f); g = !(this.panel.getSelectionModel() instanceof Ext.selection.RowModel) } if (!g) { this.callParent(arguments) } }, refresh : function() { this.fixedNodes = 0; this.callParent(arguments) }, clearViewEl : function() { var c = this, b = c.getTargetEl(); b.down("table").remove(); if (this.emptyText) { var a = b.down(".sch-empty-text"); if (a) { a.remove() } } }, onMouseOver : function(b, a) { if (a !== this.lastItem) { this.lastItem = a; Ext.fly(a).addCls(this.overScheduledEventClass); this.fireEvent("eventmouseenter", this, this .resolveEventRecord(a), b) } }, onMouseOut : function(b, a) { if (this.lastItem) { if (!b.within(this.lastItem, true, true)) { Ext.fly(this.lastItem) .removeCls(this.overScheduledEventClass); this.fireEvent("eventmouseleave", this, this .resolveEventRecord(this.lastItem), b); delete this.lastItem } } }, highlightItem : function(b) { if (b) { var a = this; a.clearHighlight(); a.highlightedItem = b; Ext.fly(b).addCls(a.overItemCls) } }, shouldUpdateCell : function() { return true } } }, hasRightColumns : function() { return this.headerCt.items.getCount() > 1 }, checkHorizontalFit : function() { if (this.orientation === "horizontal") { var a = this.getActualTimeColumnWidth(); var c = this.getFittingColumnWidth(); if (this.forceFit) { if (c != a) { this.fitColumns() } } else { if (this.snapToIncrement) { var b = this.calculateTimeColumnWidth(a); if (b > 0 && b !== a) { this.setColumnWidth(b) } } else { if (a < c) { this.fitColumns() } } } } }, getTimeAxisColumn : function() { return this.headerCt.items.get(0) }, getFirstTimeColumn : function() { return this.headerCt.getGridColumns()[0] }, getFormattedDate : function(a) { return Ext.Date.format(a, this.getDisplayDateFormat()) }, getFormattedEndDate : function(d, a) { var b = this.timeAxis, c = b.getResolution().unit; if (c in this.largeUnits && d.getHours() === 0 && d.getMinutes() === 0 && !(d.getYear() === a.getYear() && d.getMonth() === a.getMonth() && d.getDate() === a .getDate())) { d = Sch.util.Date.add(d, Sch.util.Date.DAY, -1) } return Ext.Date.format(d, this.getDisplayDateFormat()) }, getDisplayDateFormat : function() { return this.displayDateFormat }, setDisplayDateFormat : function(a) { this.displayDateFormat = a }, getSingleUnitInPixels : function(a) { return Sch.util.Date.getUnitToBaseUnitRatio(this.timeAxis.getUnit(), a) * this.getSingleTickInPixels() / this.timeAxis.getIncrement() }, getSingleTickInPixels : function() { throw "Must be implemented by horizontal/vertical" }, scrollEventIntoView : function(f, c, a, j, k) { k = k || this; var h = this; var d = this.panel._top.store; var i = function(l) { l.scrollIntoView(h.el, true, a); if (c) { if (typeof c === "boolean") { l.highlight() } else { l.highlight(null, c) } } j && j.call(k) }; var e = Ext.data && Ext.data.TreeStore && d instanceof Ext.data.TreeStore && !f.isVisible(); if (e) { f.bubble(function(l) { l.expand() }) } var b = this.getOuterElementFromEventRecord(f); if (b) { i(b) } else { var g = this.panel.verticalScroller; if (d.buffered && g) { Ext.Function.defer(function() { g.scrollTo(d.getIndexInTotalDataset(f), false, function() { var l = h .getOuterElementFromEventRecord(f); if (l) { i(l) } }) }, e ? 10 : 0) } } }, calculateTimeColumnWidth : function(e) { if (!this.panel.rendered) { return e } var h = this.forceFit; var b = 0, d = this.timeAxis.getUnit(), k = this.timeAxis.getCount(), g = Number.MAX_VALUE; if (this.snapToIncrement) { var i = this.timeAxis.getResolution(), j = i.unit, c = i.increment; g = Sch.util.Date.getUnitToBaseUnitRatio(d, j) * c } var f = Sch.util.Date.getMeasuringUnit(d); g = Math.min(g, Sch.util.Date.getUnitToBaseUnitRatio(d, f)); var a = Math.floor(this.getAvailableWidthForSchedule() / k); b = (h || e < a) ? a : e; if (g > 0 && (!h || g < 1)) { b = Math.round(Math.max(1, Math[h ? "floor" : "round"](g * b)) / g) } return b }, getFittingColumnWidth : function() { var a = Math.floor(this.getAvailableWidthForSchedule() / this.timeAxis.getCount()); return this.calculateTimeColumnWidth(a) }, fitColumns : function(b) { var a = 0; if (this.orientation === "horizontal") { a = this.getFittingColumnWidth() } else { a = Math.floor((this.panel.getWidth() - Ext.getScrollbarSize().width - 1) / this.headerCt.getColumnCount()) } this.setColumnWidth(a, b) }, getAvailableWidthForSchedule : function() { var c = (this.lastBox && this.lastBox.width) || this.getWidth(); var a = this.headerCt.items.items; for (var b = 1; b < a.length; b++) { c -= a[b].getWidth() } return c - Ext.getScrollbarSize().width - 1 }, getRightColumnsWidth : function() { var c = 0; var a = this.headerCt.items.items; for (var b = 1; b < a.length; b++) { c += a[b].getWidth() } return c }, fixRightColumnsPositions : function() { var a = this.headerCt.items.items; var c = a[0].getWidth(); for (var b = 1; b < a.length; b++) { var d = a[b]; d.el.setLeft(c); c += d.getWidth() } }, getElementFromEventRecord : function(a) { return Ext.get(this.eventPrefix + a.internalId) }, getEventNodeByRecord : function(a) { return document.getElementById(this.eventPrefix + a.internalId) }, getOuterElementFromEventRecord : function(a) { return Ext.get(this.eventPrefix + a.internalId) }, resolveColumnIndex : function(a) { return Math.floor(a / this.getActualTimeColumnWidth()) }, getStartEndDatesFromRegion : function(b, a) { throw "Must be implemented by horizontal/vertical" }, setupTooltip : function() { var b = this, a = Ext.apply({ renderTo : Ext.getBody(), delegate : b.eventSelector, target : b.el, anchor : "b" }, b.tipCfg); b.tip = Ext.create("Ext.ToolTip", a); b.tip.on({ beforeshow : function(d) { if (!d.triggerElement || !d.triggerElement.id) { return false } var c = this.resolveEventRecord(d.triggerElement); if (!c || this.fireEvent("beforetooltipshow", this, c) === false) { return false } d.update(this.tooltipTpl.apply(this.getDataForTooltipTpl(c))); return true }, scope : this }) }, getDataForTooltipTpl : function(a) { return a.data }, getTimeResolution : function() { return this.timeAxis.getResolution() }, setTimeResolution : function(b, a) { this.timeAxis.setResolution(b, a); if (this.snapToIncrement) { this.refreshKeepingScroll() } }, getEventIdFromDomNodeId : function(a) { return a.substring(this.eventPrefix.length) }, getDateFromDomEvent : function(b, a) { return this.getDateFromXY(b.getXY(), a) }, handleScheduleEvent : function(c) { var b = c.getTarget("." + this.timeCellCls, 2); if (b) { var a = this.getDateFromDomEvent(c, "floor"); this.fireEvent("schedule" + c.type, this, a, this.indexOf(this .findItemByChild(b)), c) } }, setupTimeCellEvents : function() { this.mon(this.el, { click : this.handleScheduleEvent, dblclick : this.handleScheduleEvent, contextmenu : this.handleScheduleEvent, scope : this }, this) }, getSnapPixelAmount : function() { if (this.snapToIncrement) { var a = this.timeAxis.getResolution(); return (a.increment || 1) * this.getSingleUnitInPixels(a.unit) } else { return 1 } }, getActualTimeColumnWidth : function() { return this.headerCt.items.get(0).getTimeColumnWidth() }, setSnapEnabled : function(a) { this.snapToIncrement = a; if (a) { this.refreshKeepingScroll() } }, setReadOnly : function(a) { this.readOnly = a; this[a ? "addCls" : "removeCls"](this._cmpCls + "-readonly") }, isReadOnly : function() { return this.readOnly }, setOrientation : function(a) { this.orientation = a; Ext.apply(this, Sch.view[Ext.String.capitalize(a)].prototype.props) }, getOrientation : function() { return this.orientation }, translateToScheduleCoordinate : function(a) { throw "Abstract method call!" }, translateToPageCoordinate : function(a) { throw "Abstract method call!" }, getDateFromXY : function(c, b, a) { throw "Abstract method call!" }, getXYFromDate : function(a, b) { throw "Abstract method call!" }, getTimeSpanRegion : function(a, b) { throw "Abstract method call!" }, getStart : function() { return this.timeAxis.getStart() }, getEnd : function() { return this.timeAxis.getEnd() }, setBarMargin : function(b, a) { this.barMargin = b; if (!a) { this.refreshKeepingScroll() } }, setRowHeight : function(a, b) { this.rowHeight = a || 24; if (this.rendered && !b) { this.refreshKeepingScroll() } }, refreshKeepingScroll : function(a) { this.saveScrollState(); if (this.lightRefresh) { this.lightRefresh() } else { this.refresh() } this.restoreScrollState() }, refreshKeepingResourceScroll : function(c) { var d = this.el.dom, b = d.scrollTop, a = d.scrollLeft; if (this.lightRefresh) { this.lightRefresh() } else { this.refresh() } if (this.getOrientation() === "horizontal") { d.scrollTop = b } else { d.scrollLeft = a } }, lightRefresh : function() { var a = this.refreshSize; Ext.suspendLayouts(); this.refreshSize = Ext.emptyFn; this.__lightRefresh = true; this.refresh(); delete this.__lightRefresh; this.refreshSize = a; Ext.resumeLayouts() } }, function() { Ext.apply(Sch, { VERSION : "2.1.11" }) }); Ext.define("Sch.view.Horizontal", { props : { translateToScheduleCoordinate : function(a) { return a - this.el.getX() + this.el.getScroll().left }, translateToPageCoordinate : function(a) { return a + this.el.getX() - this.el.getScroll().left }, getDateFromXY : function(h, f, e) { var b, a = e ? h[0] : this.translateToScheduleCoordinate(h[0]), d = a / this.getActualTimeColumnWidth(), c = this.timeAxis .getCount(); if (d < 0 || d > c) { b = null } else { var g = d - this.resolveColumnIndex(a); if (g > 2 && d >= c) { return null } b = this.timeAxis.getDateFromTick(d, f) } return b }, getXYFromDate : function(b, d) { var a, c = this.timeAxis.getTickFromDate(b); if (c >= 0) { a = this.getActualTimeColumnWidth() * c } if (d === false) { a = this.translateToPageCoordinate(a) } return [Math.round(a), 0] }, getEventBox : function(e, b) { var a = Math.floor(this.getXYFromDate(e)[0]), c = Math.floor(this .getXYFromDate(b)[0]), d = Math; if (this.managedEventSizing) { return { top : Math.max(0, (this.barMargin - (Ext.isIE && !Ext.isStrict) ? 0 : this.eventBorderWidth - this.cellBorderWidth)), left : d.min(a, c), width : d.max(1, d.abs(a - c) - this.eventBorderWidth), height : this.rowHeight - (2 * this.barMargin) - this.eventBorderWidth } } return { left : d.min(a, c), width : d.max(1, d.abs(a - c)) } }, layoutEvents : function(a) { var c = Ext.Array.clone(a); c.sort(this.sortEvents); var b = this.layoutEventsInBands(0, c); return b }, layoutEventsInBands : function(d, a) { var c = a[0], b = d === 0 ? this.barMargin : (d * this.rowHeight - ((d - 1) * this.barMargin)); if (b >= this.cellBorderWidth) { b -= this.cellBorderWidth } while (c) { c.top = b; Ext.Array.remove(a, c); c = this.findClosestSuccessor(c, a) } d++; if (a.length > 0) { return this.layoutEventsInBands(d, a) } else { return d } }, getScheduleRegion : function(d, f) { var h = d ? Ext.fly(this.getNodeByRecord(d)).getRegion() : this.el .down(".x-grid-table").getRegion(), e = this.timeAxis .getStart(), j = this.timeAxis.getEnd(), b = this .getDateConstraints(d, f) || { start : e, end : j }, c = this.translateToPageCoordinate(this .getXYFromDate(b.start)[0]), i = this .translateToPageCoordinate(this.getXYFromDate(b.end)[0]) - this.eventBorderWidth, g = h.top + this.barMargin, a = h.bottom - this.barMargin - this.eventBorderWidth; return new Ext.util.Region(g, Math.max(c, i), a, Math.min(c, i)) }, getResourceRegion : function(h, d, g) { var k = Ext.fly(this.getNodeByRecord(h)).getRegion(), i = this.timeAxis .getStart(), n = this.timeAxis.getEnd(), c = d ? Sch.util.Date.max(i, d) : i, e = g ? Sch.util.Date.min(n, g) : n, f = this .getXYFromDate(c)[0], m = this.getXYFromDate(e)[0] - this.eventBorderWidth, l = this.el.getTop(), b = this.el .getScroll(), j = k.top + 1 - l + b.top, a = k.bottom - 1 - l + b.top; return new Ext.util.Region(j, Math.max(f, m), a, Math.min(f, m)) }, collectRowData : function(g, p, o) { var c = this.eventStore.getEventsForResource(p); if (c.length === 0 || this.headerCt.getColumnCount() === 0) { g.rowHeight = this.rowHeight; return g } var a = Sch.util.Date, m = this.timeAxis, n = m.getStart(), r = m .getEnd(), k = [], j, f; for (j = 0, f = c.length; j < f; j++) { var b = c[j], d = b.getStartDate(), h = b.getEndDate(); if (d && h && m.timeSpanInAxis(d, h)) { var q = this.generateTplData(b, n, r, p, o); k[k.length] = q } } var e = 1; if (this.dynamicRowHeight) { e = this.layoutEvents(k) } g.rowHeight = (e * this.rowHeight) - ((e - 1) * this.barMargin); g[this.getFirstTimeColumn().id] += " " + this.eventTpl.apply(k); return g }, resolveResource : function(a) { var b = this.findItemByChild(a); if (b) { return this.getRecord(b) } return null }, getTimeSpanRegion : function(b, h, g) { var d = this.getXYFromDate(b)[0], f = this.getXYFromDate(h || b)[0], a, c; if (this.store.buffered) { var e; if (this.panel.verticalScroller.stretcher instanceof Ext.CompositeElement) { e = this.panel.verticalScroller.stretcher.first() } else { e = this.el.down(".x-stretcher") } if (e.dom.clientHeight) { c = e } } if (!c) { c = this.el.down(".x-grid-table") } if (g) { a = Math.max(c ? c.dom.clientHeight : 0, this.el.dom.clientHeight) } else { a = c ? c.dom.clientHeight : 0 } return new Ext.util.Region(0, Math.max(d, f), a, Math.min(d, f)) }, getStartEndDatesFromRegion : function(c, b) { var a = this.getDateFromXY([c.left, 0], b), d = this.getDateFromXY( [c.right, 0], b); if (d && a) { return { start : Sch.util.Date.min(a, d), end : Sch.util.Date.max(a, d) } } else { return null } }, onEventAdd : function(m, h) { var e = {}; for (var g = 0, c = h.length; g < c; g++) { var a = h[g].getResources(); for (var f = 0, d = a.length; f < d; f++) { var b = a[f]; e[b.getId()] = b } } Ext.Object.each(e, function(j, i) { this.onUpdate(this.resourceStore, i) }, this) }, onEventRemove : function(e, b) { var h = b.getResources(); var f = this.resourceStore; var a = Ext.tree.View && this instanceof Ext.tree.View; var d = function(i) { if (a && this.store.indexOf(i)) { this.onUpdate(this.store, i) } else { if (f.indexOf(i) >= 0) { this.onUpdate(f, i) } } }; if (h.length > 1) { Ext.each(h, d, this) } else { var c = this.getElementFromEventRecord(b); if (c) { var g = this.resolveResource(c); c.fadeOut({ callback : function() { d.call(this, g) }, scope : this }) } } }, onEventUpdate : function(b, c, a) { var d = c.previous; if (d && d[c.resourceIdField]) { var e = c.getResource(d[c.resourceIdField]); if (e) { this.onUpdate(this.resourceStore, e) } } var f = c.getResources(); Ext.each(f, function(g) { this.onUpdate(this.resourceStore, g) }, this) }, getSingleTickInPixels : function() { return this.getActualTimeColumnWidth() }, getColumnWidth : function() { if (this.getTimeAxisColumn()) { return this.getTimeAxisColumn().getTimeColumnWidth() } }, setColumnWidth : function(b, a) { if (this.getTimeAxisColumn()) { this.getTimeAxisColumn().setTimeColumnWidth(b); if (!a) { this.refreshKeepingScroll() } } this.fireEvent("columnwidthchange", this, b) }, getVisibleDateRange : function() { if (!this.rendered) { return null } var c = this.getEl().getScroll(), b = this.panel.getStart(), f = this.panel .getEnd(), e = this.getWidth(), d = this.getEl() .down(".x-grid-table").dom, a = d.clientWidth; if (a < e) { return { startDate : b, endDate : f } } return { startDate : this.getDateFromXY([c.left, 0], null, true), endDate : this.getDateFromXY([Math.min(c.left + e, a), 0], null, true) } } } }); Ext.define("Sch.mixin.FilterableTreeView", { initTreeFiltering : function() { var a = function() { var b = this.up("tablepanel").store; this.mon(b, "nodestore-datachange-start", this.onFilterChangeStart, this); this.mon(b, "nodestore-datachange-end", this.onFilterChangeEnd, this); this.mon(b, "filter-clear", this.onFilterCleared, this); this.mon(b, "filter-set", this.onFilterSet, this) }; if (this.rendered) { a.call(this) } else { this.on("beforerender", a, this, { single : true }) } }, onFilterChangeStart : function() { Ext.suspendLayouts() }, onFilterChangeEnd : function() { Ext.resumeLayouts() }, onFilterCleared : function() { delete this.toggle; var a = this.getEl(); if (a) { a.removeCls("sch-tree-filtered") } }, onFilterSet : function() { this.toggle = function() { }; var a = this.getEl(); if (a) { a.addCls("sch-tree-filtered") } } }); Ext.define("Sch.view.TimelineTreeView", { extend : "Ext.tree.View", mixins : ["Sch.mixin.TimelineView", "Sch.mixin.FilterableTreeView"], requires : ["Sch.patches.TreeView"], cellBorderWidth : 0, constructor : function() { this.callParent(arguments); this.initTreeFiltering() } }, function() { this .override(Sch.mixin.TimelineView.prototype.inheritables() || {}) }); Ext.define("Sch.mixin.Zoomable", { zoomLevels : [{ width : 30, increment : 1, resolution : 1, preset : "year", resolutionUnit : "MONTH" }, { width : 50, increment : 1, resolution : 1, preset : "year", resolutionUnit : "MONTH" }, { width : 100, increment : 1, resolution : 1, preset : "year", resolutionUnit : "MONTH" }, { width : 200, increment : 1, resolution : 1, preset : "year", resolutionUnit : "MONTH" }, { width : 100, increment : 1, resolution : 7, preset : "monthAndYear", resolutionUnit : "DAY" }, { width : 30, increment : 1, resolution : 1, preset : "weekDateAndMonth", resolutionUnit : "DAY" }, { width : 35, increment : 1, resolution : 1, preset : "weekAndMonth", resolutionUnit : "DAY" }, { width : 50, increment : 1, resolution : 1, preset : "weekAndMonth", resolutionUnit : "DAY" }, { width : 20, increment : 1, resolution : 1, preset : "weekAndDayLetter" }, { width : 50, increment : 1, resolution : 1, preset : "weekAndDay", resolutionUnit : "HOUR" }, { width : 100, increment : 1, resolution : 1, preset : "weekAndDay", resolutionUnit : "HOUR" }, { width : 50, increment : 6, resolution : 30, preset : "hourAndDay", resolutionUnit : "MINUTE" }, { width : 100, increment : 6, resolution : 30, preset : "hourAndDay", resolutionUnit : "MINUTE" }, { width : 60, increment : 2, resolution : 30, preset : "hourAndDay", resolutionUnit : "MINUTE" }, { width : 60, increment : 1, resolution : 30, preset : "hourAndDay", resolutionUnit : "MINUTE" }, { width : 30, increment : 15, resolution : 5, preset : "minuteAndHour" }, { width : 60, increment : 15, resolution : 5, preset : "minuteAndHour" }, { width : 130, increment : 15, resolution : 5, preset : "minuteAndHour" }, { width : 60, increment : 5, resolution : 5, preset : "minuteAndHour" }, { width : 100, increment : 5, resolution : 5, preset : "minuteAndHour" }], minZoomLevel : null, maxZoomLevel : null, visibleZoomFactor : 5, cachedCenterDate : null, isFirstZoom : true, isZooming : false, initializeZooming : function() { this.zoomLevels = this.zoomLevels.slice(); this.setMinZoomLevel(this.minZoomLevel || 0); this.setMaxZoomLevel(this.maxZoomLevel !== null ? this.maxZoomLevel : this.zoomLevels.length - 1); this.on("viewchange", this.clearCenterDateCache, this) }, getZoomLevelUnit : function(b) { var a = Sch.preset.Manager.getPreset(b.preset).headerConfig; return a.bottom ? a.bottom.unit : a.middle.unit }, getMilliSecondsPerPixelForZoomLevel : function(b) { var a = Sch.util.Date; return Math.round((a.add(new Date(1, 0, 1), this.getZoomLevelUnit(b), b.increment) - new Date(1, 0, 1)) / b.width) }, presetToZoomLevel : function(e) { var d = Sch.preset.Manager.getPreset(e); var c = d.headerConfig; var a = c.bottom; var b = c.middle; return { preset : e, increment : (a ? a.increment : b.increment) || 1, resolution : d.timeResolution.increment, resolutionUnit : d.timeResolution.unit, width : d.timeColumnWidth } }, calculateCurrentZoomLevel : function() { var d = this.presetToZoomLevel(this.viewPreset); var c = this.timeAxis.headerConfig; var a = c.bottom; var b = c.middle; d.width = this.timeAxis.preset.timeColumnWidth; d.increment = (a ? a.increment : b.increment) || 1; return d }, getCurrentZoomLevelIndex : function() { var f = this.calculateCurrentZoomLevel(); var b = this.getMilliSecondsPerPixelForZoomLevel(f); var e = this.zoomLevels; for (var c = 0; c < e.length; c++) { var d = this.getMilliSecondsPerPixelForZoomLevel(e[c]); if (d == b) { return c } if (c === 0 && b > d) { return -0.5 } if (c == e.length - 1 && b < d) { return e.length - 1 + 0.5 } var a = this.getMilliSecondsPerPixelForZoomLevel(e[c + 1]); if (d > b && b > a) { return c + 0.5 } } throw "Can't find current zoom level index" }, setMaxZoomLevel : function(a) { if (a < 0 || a >= this.zoomLevels.length) { throw new Error("Invalid range for `setMinZoomLevel`") } this.maxZoomLevel = a }, setMinZoomLevel : function(a) { if (a < 0 || a >= this.zoomLevels.length) { throw new Error("Invalid range for `setMinZoomLevel`") } this.minZoomLevel = a }, getViewportCenterDateCached : function() { if (this.cachedCenterDate) { return this.cachedCenterDate } return this.cachedCenterDate = this.getViewportCenterDate() }, clearCenterDateCache : function() { this.cachedCenterDate = null }, zoomToLevel : function(b) { b = Ext.Number.constrain(b, this.minZoomLevel, this.maxZoomLevel); var n = this.calculateCurrentZoomLevel(); var d = this.getMilliSecondsPerPixelForZoomLevel(n); var i = this.zoomLevels[b]; var a = this.getMilliSecondsPerPixelForZoomLevel(i); if (d == a) { return null } var p = this; var j = this.getSchedulingView(); var f = j.getEl(); if (this.isFirstZoom) { this.isFirstZoom = false; f.on("scroll", this.clearCenterDateCache, this) } var h = this.orientation == "vertical"; var e = this.getViewportCenterDateCached(); var k = h ? f.getHeight() : f.getWidth(); var l = Ext.clone(Sch.preset.Manager.getPreset(i.preset)); var o = this.calculateOptimalDateRange(e, k, i); var c = l.headerConfig; var g = c.bottom; var r = c.middle; l[h ? "rowHeight" : "timeColumnWidth"] = i.width; if (g) { g.increment = i.increment } else { r.increment = i.increment } this.isZooming = true; this.viewPreset = i.preset; var m = g ? g.unit : r.unit; this.timeAxis.reconfigure({ preset : l, headerConfig : c, unit : m, increment : i.increment, resolutionUnit : Sch.util.Date.getUnitByName(i.resolutionUnit || m), resolutionIncrement : i.resolution, weekStartDay : this.weekStartDay, mainUnit : r.unit, shiftUnit : l.shiftUnit, shiftIncrement : l.shiftIncrement || 1, defaultSpan : l.defaultSpan || 1, start : o.startDate || this.getStart(), end : o.endDate || this.getEnd() }); var q = j.getXYFromDate(e, true); f.on("scroll", function() { p.cachedCenterDate = e }, this, { single : true }); if (h) { f.scrollTo("top", q[1] - k / 2) } else { f.scrollTo("left", q[0] - k / 2) } p.isZooming = false; this.fireEvent("zoomchange", this, b); return b }, zoomIn : function(a) { a = a || 1; var b = this.getCurrentZoomLevelIndex(); if (b >= this.zoomLevels.length - 1) { return null } return this.zoomToLevel(Math.floor(b) + a) }, zoomOut : function(a) { a = a || 1; var b = this.getCurrentZoomLevelIndex(); if (b <= 0) { return null } return this.zoomToLevel(Math.ceil(b) - a) }, zoomInFull : function() { return this.zoomToLevel(this.maxZoomLevel) }, zoomOutFull : function() { return this.zoomToLevel(this.minZoomLevel) }, calculateOptimalDateRange : function(c, h, e) { var b = Sch.util.Date; var i = Sch.preset.Manager.getPreset(e.preset).headerConfig; var f = i.top ? i.top.unit : i.middle.unit; var j = this.getZoomLevelUnit(e); var d = Math.ceil(h / e.width * e.increment * this.visibleZoomFactor / 2); var a = b.add(c, j, -d); var g = b.add(c, j, d); return { startDate : this.timeAxis.floorDate(a, false, f), endDate : this.timeAxis.ceilDate(g, false, f) } } }); Ext.define("Sch.mixin.TimelinePanel", { requires : ["Sch.util.Patch", "Sch.patches.LoadMask", "Sch.patches.Model", "Sch.patches.Table", "Sch.data.TimeAxis", "Sch.feature.ColumnLines", "Sch.view.Locking", "Sch.mixin.Lockable", "Sch.preset.Manager"], mixins : ["Sch.mixin.Zoomable"], orientation : "horizontal", weekStartDay : 1, snapToIncrement : false, readOnly : false, eventResizeHandles : "both", viewPreset : "weekAndDay", trackHeaderOver : true, startDate : null, endDate : null, eventBorderWidth : 1, tooltipTpl : null, tipCfg : { cls : "sch-tip", showDelay : 1000, hideDelay : 0, autoHide : true, anchor : "b" }, lightWeight : true, timeCellRenderer : null, timeCellRendererScope : null, inheritables : function() { return { columnLines : true, enableColumnMove : false, enableLocking : true, lockable : true, lockedXType : null, normalXType : null, initComponent : function() { this.lightWeight = this.lightWeight && !this.timeCellRenderer; this.addEvents("timeheaderdblclick", "beforeviewchange", "viewchange"); if (!this.timeAxis) { this.timeAxis = Ext.create("Sch.data.TimeAxis") } if (!this.columns && !this.colModel) { this.columns = [] } this.timeAxis.on("reconfigure", this.onTimeAxisReconfigure, this); if (this.enableLocking) { this.self.mixin("lockable", Sch.mixin.Lockable); var b = 0, a = this.columns.length, c; for (; b < a; ++b) { c = this.columns[b]; if (c.locked !== false) { c.locked = true } c.lockable = false } this.switchViewPreset(this.viewPreset, this.startDate || this.timeAxis.getStart(), this.endDate || this.timeAxis.getEnd(), true) } this.callParent(arguments); if (this.lockable) { this.applyViewSettings(this.timeAxis.preset); if (!this.viewPreset) { throw "You must define a valid view preset object. See Sch.preset.Manager class for reference" } if (this.lightWeight && this.columnLines) { this.columnLinesFeature = new Sch.feature.ColumnLines(); this.columnLinesFeature.init(this) } } this.initializeZooming(); this.relayEvents(this.getView(), ["beforetooltipshow", "scheduleclick", "scheduledblclick", "schedulecontextmenu"]) }, getState : function() { var a = this, b = a.callParent(arguments); Ext.apply(b, { viewPreset : a.viewPreset, startDate : a.getStart(), endDate : a.getEnd(), zoomMinLevel : a.zoomMinLevel, zoomMaxLevel : a.zoomMaxLevel, currentZoomLevel : a.currentZoomLevel }); return b }, getOrientation : function() { return this.orientation }, applyState : function(b) { var a = this; a.callParent(arguments); if (b && b.viewPreset) { a.switchViewPreset(b.viewPreset, b.startDate, b.endDate) } if (b && b.currentZoomLevel) { a.zoomToLevel(b.currentZoomLevel) } }, beforeRender : function() { this.callParent(arguments); if (this.lockable) { this.addCls("sch-" + this.orientation) } }, afterRender : function() { this.callParent(arguments); if (this.lockable) { this.lockedGrid.on("itemdblclick", function(d, c, e, g, f) { if (this.orientation == "vertical" && c) { this.fireEvent("timeheaderdblclick", this, c.get("start"), c.get("end"), g, f) } }, this) } else { var b = this.headerCt; if (b && b.reorderer && b.reorderer.dropZone) { var a = b.reorderer.dropZone; a.positionIndicator = Ext.Function.createSequence( a.positionIndicator, function() { this.valid = false }) } } }, delayScroll : function() { var a = this.getScrollTarget().el; if (a) { this.scrollTask.delay(10, function() { if (a.dom) { this.syncHorizontalScroll(a.dom.scrollLeft) } }, this) } } } }, setReadOnly : function(a) { this.getSchedulingView().setReadOnly(a) }, isReadOnly : function() { return this.getSchedulingView().isReadOnly() }, switchViewPreset : function(d, a, f, b) { if (this.fireEvent("beforeviewchange", this, d, a, f) !== false) { if (Ext.isString(d)) { this.viewPreset = d; d = Sch.preset.Manager.getPreset(d) } if (!d) { throw "View preset not found" } var e = d.headerConfig; var c = { unit : e.bottom ? e.bottom.unit : e.middle.unit, increment : (e.bottom ? e.bottom.increment : e.middle.increment) || 1, resolutionUnit : d.timeResolution.unit, resolutionIncrement : d.timeResolution.increment, weekStartDay : this.weekStartDay, mainUnit : e.middle.unit, shiftUnit : d.shiftUnit, headerConfig : d.headerConfig, shiftIncrement : d.shiftIncrement || 1, preset : d, defaultSpan : d.defaultSpan || 1 }; if (b) { if (this.timeAxis.getCount() === 0 || a) { c.start = a || new Date(); c.end = f } } else { c.start = a || this.timeAxis.getStart(); c.end = f } if (!b) { this.applyViewSettings(d) } this.timeAxis.reconfigure(c) } }, applyViewSettings : function(b) { var a = this.getSchedulingView(); a.setDisplayDateFormat(b.displayDateFormat); if (this.orientation === "horizontal") { a.setRowHeight(this.rowHeight || b.rowHeight, true) } }, getStart : function() { return this.timeAxis.getStart() }, getEnd : function() { return this.timeAxis.getEnd() }, getViewportCenterDate : function() { var b = this.getSchedulingView(), c = b.getEl(), a = c.getScroll(), d; if (this.orientation === "vertical") { d = [0, a.top + c.getHeight() / 2] } else { d = [a.left + c.getWidth() / 2, 0] } return b.getDateFromXY(d, null, true) }, setTimeColumnWidth : function(b, a) { this.getSchedulingView().setColumnWidth(b, a) }, onTimeAxisReconfigure : function() { this.fireEvent("viewchange", this); if (this.stateful && this.lockedGrid) { this.saveState() } }, getColumnsState : function() { var b = this, a = b.lockedGrid.headerCt.getColumnsState(); return a }, shiftNext : function(a) { this.timeAxis.shiftNext(a) }, shiftPrevious : function(a) { this.timeAxis.shiftPrevious(a) }, goToNow : function() { this.setTimeSpan(new Date()) }, setTimeSpan : function(b, a) { if (this.timeAxis) { this.timeAxis.setTimeSpan(b, a) } }, setStart : function(a) { this.setTimeSpan(a) }, setEnd : function(a) { this.setTimeSpan(null, a) }, getTimeAxis : function() { return this.timeAxis }, getResourceByEventRecord : function(a) { return a.getResource() }, scrollToDate : function(c, b) { var a = this.getSchedulingView(), d = a.getXYFromDate(c, true); if (this.orientation == "horizontal") { a.getEl().scrollTo("left", Math.max(0, d[0]), b) } else { a.getEl().scrollTo("top", Math.max(0, d[1]), b) } }, getSchedulingView : function() { return this.lockable ? this.normalGrid.getView() : this.getView() }, setOrientation : function(a) { this.removeCls("sch-" + this.orientation); this.addCls("sch-" + a); this.orientation = a } }); Ext.define("Sch.panel.TimelineTreePanel", { extend : "Ext.tree.Panel", requires : ["Ext.data.TreeStore"], mixins : ["Sch.mixin.TimelinePanel"], useArrows : true, rootVisible : false, constructor : function(a) { a = a || {}; a.animate = false; this.callParent(arguments) }, initComponent : function() { this.callParent(arguments); if (this.lockable && this.lockedGrid.headerCt.query("treecolumn").length === 0) { Ext.Error .raise("You must define an Ext.tree.Column (or use xtype : 'treecolumn').") } }, onRootChange : function(a) { if (!this.lockable) { this.callParent(arguments) } }, bindStore : function(b) { this.callParent(arguments); if (Ext.getVersion("extjs").isGreaterThanOrEqual("4.1.2")) { var c = this, a = c.getView(); if (b.buffered && c.verticalScroll) { c.verticalScroller = new Ext.grid.PagingScroller(Ext.apply({ panel : c, store : b, view : c.view }, c.initialConfig.verticalScroller)) } if (b && b.buffered) { a.preserveScrollOnRefresh = true } else { if (c.invalidateScrollerOnRefresh !== undefined) { a.preserveScrollOnRefresh = !c.invalidateScrollerOnRefresh } } } } }, function() { this.override(Sch.mixin.TimelinePanel.prototype.inheritables() || {}) }); Ext.define("Sch.plugin.Printable", { extend : "Ext.AbstractPlugin", lockableScope : "top", docType : "", beforePrint : Ext.emptyFn, afterPrint : Ext.emptyFn, autoPrintAndClose : true, fakeBackgroundColor : true, scheduler : null, constructor : function(a) { Ext.apply(this, a) }, init : function(a) { this.scheduler = a; a.print = Ext.Function.bind(this.print, this) }, mainTpl : new Ext.XTemplate( '{docType}{title}{styles}
{[this.printLockedHeader(values)]}{[this.printNormalHeader(values)]}
{[this.printLockedGrid(values)]}{[this.printNormalGrid(values)]}