123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764 |
- Ext.require([
- 'Ext.form.*',
- 'Ext.layout.container.Column',
- 'Ext.tab.Panel'
- ]);
- /**
- * @class Ext.aria.AriaController
- * <p>This class supplies support methods for integrating ARIA support into Components.</p>
- *
- */
- Ext.define('Ext.aria.AriaController', {
- singleton: true,
- requires: ['Ext.AbstractComponent'],
- handlerRe: /^on(\w+)/,
- // This function is called as an interceptor of the target class's fireEvent method
- // It invokes the event's ariaHandler if present
- ariaFireEvent: function(evt){
- var me = this,
- evtName = evt.toLowerCase(),
- args = Array.prototype.slice.call(arguments, 1),
- classFn = Ext.aria.AriaController.getClassAriaHandler(this.self.prototype, evtName),
- ariaFn = Ext.aria.AriaController[evtName],
- result;
-
- // Call user event handlers first.
- result = Ext.util.Observable.prototype.fireEvent.apply(me, arguments);
- if (result !== false) {
- // Then AriaController's event handler
- if (typeof ariaFn === 'function') {
- result = ariaFn.apply(me, args);
- }
- // Then class's configured ARIA event handler
- if (typeof classFn === 'function') {
- result = classFn.apply(me, args);
- }
- }
- return result;
- },
- // Examine the passed class prototype for an aria_event_handler, and if not found, continue up the prototype chain.
- getClassAriaHandler: function(clsProto, evtName) {
- var curProto = clsProto,
- generatedHandlerName = 'generated_aria_' + evtName + '_handler',
- configuredHandlerName = 'aria_' + evtName + '_handler',
- fn,
- result = clsProto.hasOwnProperty(generatedHandlerName) ? clsProto[generatedHandlerName] : null;
- // If there is no generated ariaEventHandler for the class/event, we must generate one
- // which calls the cascade of event handlers for the inheritance chain
- if (!result) {
- var handlerStack = [];
- // Collect the stack of event handlers from each level in the inheritance tree
- while (curProto) {
- if (curProto.hasOwnProperty(configuredHandlerName)) {
- fn = curProto[configuredHandlerName];
- if (fn) {
- handlerStack.unshift(fn);
- }
- }
- curProto = curProto.superclass;
- }
- // Generate a closure which captures the handler stack, and loops through it
- // to invoke them all.
- result = clsProto[generatedHandlerName] = (function(handlerStack) {
- var result = handlerStack.length ? function() {
- var i = 0, len = handlerStack.length;
- for (; i < len; i++) {
- handlerStack[i].apply(this, arguments);
- }
- } : Ext.emptyFn;
- return result;
- })(handlerStack);
- }
- return result;
- },
- processClass: function(cls, props) {
- var me = this,
- clsProto = cls.prototype,
- propName,
- value,
- k;
- for (propName in props) {
- if (props.hasOwnProperty(propName)) {
- value = props[propName];
- k = me.handlerRe.exec(propName);
- // Handle properties like onHide: function(){...}
- // Copy it into ariaHandlers.hide where it can be called
- // by the fireEvent interceptor
- if (k && (typeof value === 'function')) {
- propName = propName.toLowerCase();
- // Hang the ariaHandlers on the class's prototype.
- clsProto['aria_' + k[1].toLowerCase() + '_handler'] = value;
- } else if (propName === 'role') {
- clsProto.ariaRole = value;
- }
- }
- }
- // Replace the class's fireEvent method with our code which intercepts relevant events,
- // performs known processing (such as setting the role on render), and calls any defined
- // ariaHandlers
- clsProto.fireEvent = me.ariaFireEvent;
- },
- // ARIA event handler for the render event.
- render: function() {
- var me = this,
- p = me.pendingProps,
- len = p ? p.length : 0,
- i = 0;
- // Apply any pending ARIA updates from when applied before render
- for (; i < len; i++) {
- me.updateAria.apply(me, p[i]);
- }
- }
- }, function() {
-
- // Inject an updateAria method into AbstractComponent's prorotype
- Ext.override(Ext.AbstractComponent, {
- getElConfig: function() {
- var result = this.callOverridden();
- result.role = this.ariaRole;
- return result;
- },
- updateAria: function(el, props) {
- var me = this;
- // Queue the attributes up if not rendered.
- // They will be applied in the global render handler.
- if (!me.rendered) {
- if (!me.pendingProps) {
- me.pendingProps = [];
- }
- me.pendingProps.push(Array.prototype.slice.call(arguments));
- return;
- }
- // The one argument form updates the actionEl
- if (arguments.length == 1) {
- props = el;
- el = this.getActionEl();
- }
- // Ensure events are added
- if (!me.events.beforeariaupdate) {
- me.addEvents('beforeariaupdate', 'ariaupdate');
- }
- if (me.fireEvent('beforeariaupdate', el, props) !== false) {
- Ext.fly(el).set(props);
- me.fireEvent('ariaupdate', el, props);
- }
- }
- });
-
- Ext.core.Element.prototype.set = function(o, useSet) {
- var el = this.dom,
- attr,
- val;
- useSet = (useSet !== false) && !!el.setAttribute;
- for (attr in o) {
- if (o.hasOwnProperty(attr)) {
- val = o[attr];
- if (attr == 'style') {
- DH.applyStyles(el, val);
- } else if (attr == 'cls') {
- el.className = val;
- } else if (useSet) {
- if (val === undefined) {
- el.removeAttribute(attr);
- } else {
- el.setAttribute(attr, val);
- }
- } else {
- el[attr] = val;
- }
- }
- }
- return this;
- };
- });
- Ext.onReady(function() {
- Ext.aria.AriaController.processClass(Ext.AbstractComponent, {
- onDisable: function() {
- this.updateAria(this.getActionEl(), {
- 'aria-disabled': true
- })
- },
- onEnable: function() {
- this.updateAria(this.getActionEl(), {
- 'aria-disabled': false
- })
- },
- onHide: function() {
- this.updateAria(this.getActionEl(), {
- 'aria-hidden': true
- })
- },
- onShow: function() {
- this.updateAria(this.getActionEl(), {
- 'aria-hidden': false
- })
- }
- });
- Ext.aria.AriaController.processClass(Ext.form.FieldSet, {
- onRender: function() {
- this.updateAria({
- 'aria-expanded': !this.collapsed
- });
- },
- onExpand: function() {
- this.updateAria({
- 'aria-expanded': true
- });
- },
- onCollapse: function() {
- this.updateAria({
- 'aria-expanded': false
- });
- }
- });
- Ext.aria.AriaController.processClass(Ext.form.field.Base, {
- onRender: function() {
- if (this.labelEl) {
- this.updateAria(this.inputEl, {
- 'aria-labelledby': this.labelEl.id
- });
- }
- },
- onValidityChange: function(f, isValid) {
- this.updateAria(this.inputEl, {
- 'aria-invalid': !isValid,
- 'aria-describedby': isValid ? undefined : f.errorEl.id
- });
- }
- });
- Ext.aria.AriaController.processClass(Ext.form.field.Text, {
- role: 'textbox'
- });
- Ext.aria.AriaController.processClass(Ext.form.field.Number, {
- role: 'spinbutton',
- onRender: function() {
- var me = this,
- props = {};
- if (isFinite(me.minValue)) {
- props['aria-valuemin'] = me.minValue;
- }
- if (isFinite(me.maxValue)) {
- props['aria-valuemax'] = me.maxValue;
- }
- me.updateAria(me.inputEl, props);
- },
- onChange: function(f) {
- var v = this.getValue();
- this.updateAria(this.inputEl, {
- 'aria-valuenow': (this.isValid() && v !== null) ? v: undefined
- });
- }
- });
- // Picker fields are combobox type functionality
- Ext.aria.AriaController.processClass(Ext.form.field.Picker, function() {
- var listFns = {
- onListHighlight: function(node) {
- this.updateAria({
- 'aria-activedescendant': node.id
- });
- },
- onListUnhighlight: function(node) {
- var n = this.getPicker().getSelectedNodes();
- this.updateAria({
- 'aria-activedescendant': n.length ? n[0].id : undefined
- });
- },
- onListSelectionChange: function(sm, selected) {
- if (selected.length) {
- var n = this.getPicker().getSelectedNodes();
- this.updateAria({
- 'aria-activedescendant': n[0].id
- });
- } else {
- this.updateAria({
- 'aria-activedescendant': undefined
- });
- }
- }
- };
-
- return {
- role: 'combobox',
- onRender: function() {
- this.updateAria(this.inputEl, {
- 'aria-autocomplete': 'inline'
- });
- },
- onExpand: function() {
- var me = this,
- picker = me.getPicker();
- me.updateAria(me.inputEl, {
- 'aria-owns': picker.el.id,
- 'aria-expanded': true
- });
- // On first expand, add listeners to the "picker" list to maintain our ARIA state
- if (!me.pickerListenersAdded) {
- picker.mon(picker, {
- highlight: listFns.onListHighlight,
- unhighlight: listFns.onListUnhighlight,
- selectionchange: listFns.onListSelectionChange,
- scope: me
- });
- me.pickerListenersAdded = true;
- }
- },
- onCollapse: function() {
- var p = this.getPicker(),
- n = p.getSelectedNodes ? p.getSelectedNodes() : [null];
- this.updateAria({
- 'aria-expanded': false,
- 'aria-activedescendant': n.length ? n[0].id: undefined
- });
- }
- };
- }());
- Ext.aria.AriaController.processClass(Ext.view.BoundList, {
- role: 'listbox'
- });
- Ext.QuickTips.init();
- var bd = Ext.getBody();
- /*
- * ================ Simple form =======================
- */
- bd.createChild({tag: 'h2', html: 'Form 1 - Very Simple'});
- var simple = Ext.create('Ext.form.Panel', {
- url:'save-form.php',
- frame:true,
- title: 'Simple Form',
- bodyStyle:'padding:5px 5px 0',
- width: 350,
- fieldDefaults: {
- msgTarget: 'side',
- labelWidth: 75
- },
- defaultType: 'textfield',
- defaults: {
- anchor: '100%'
- },
- items: [{
- fieldLabel: 'First Name',
- name: 'first',
- allowBlank:false
- },{
- fieldLabel: 'Last Name',
- name: 'last'
- },{
- fieldLabel: 'Company',
- name: 'company'
- }, {
- fieldLabel: 'Email',
- name: 'email',
- vtype:'email'
- }, {
- fieldLabel: 'DOB',
- name: 'dob',
- xtype: 'datefield'
- }, {
- fieldLabel: 'Age',
- name: 'age',
- xtype: 'numberfield',
- minValue: 0,
- maxValue: 100
- }, {
- xtype: 'timefield',
- fieldLabel: 'Time',
- name: 'time',
- minValue: '8:00am',
- maxValue: '6:00pm'
- }],
- buttons: [{
- text: 'Save'
- },{
- text: 'Cancel'
- }]
- });
- simple.render(document.body);
- /*
- * ================ Form 2 =======================
- */
- bd.createChild({tag: 'h2', html: 'Form 2 - Adding fieldsets'});
- var fsf = Ext.create('Ext.form.Panel', {
- url:'save-form.php',
- frame:true,
- title: 'Simple Form with FieldSets',
- bodyStyle:'padding:5px 5px 0',
- width: 350,
- fieldDefaults: {
- msgTarget: 'side',
- labelWidth: 75
- },
- defaults: {
- anchor: '100%'
- },
- items: [{
- xtype:'fieldset',
- checkboxToggle:true,
- title: 'User Information',
- defaultType: 'textfield',
- collapsed: true,
- layout: 'anchor',
- defaults: {
- anchor: '100%'
- },
- items :[{
- fieldLabel: 'First Name',
- name: 'first',
- allowBlank:false
- },{
- fieldLabel: 'Last Name',
- name: 'last'
- },{
- fieldLabel: 'Company',
- name: 'company'
- }, {
- fieldLabel: 'Email',
- name: 'email',
- vtype:'email'
- }]
- },{
- xtype:'fieldset',
- title: 'Phone Number',
- collapsible: true,
- defaultType: 'textfield',
- layout: 'anchor',
- defaults: {
- anchor: '100%'
- },
- items :[{
- fieldLabel: 'Home',
- name: 'home',
- value: '(888) 555-1212'
- },{
- fieldLabel: 'Business',
- name: 'business'
- },{
- fieldLabel: 'Mobile',
- name: 'mobile'
- },{
- fieldLabel: 'Fax',
- name: 'fax'
- }]
- }],
- buttons: [{
- text: 'Save'
- },{
- text: 'Cancel'
- }]
- });
- fsf.render(document.body);
- /*
- * ================ Form 3 =======================
- */
- bd.createChild({tag: 'h2', html: 'Form 3 - A little more complex'});
- var top = Ext.create('Ext.form.Panel', {
- frame:true,
- title: 'Multi Column, Nested Layouts and Anchoring',
- bodyStyle:'padding:5px 5px 0',
- width: 600,
- fieldDefaults: {
- labelAlign: 'top',
- msgTarget: 'side'
- },
- items: [{
- xtype: 'container',
- anchor: '100%',
- layout:'column',
- items:[{
- xtype: 'container',
- columnWidth:.5,
- layout: 'anchor',
- items: [{
- xtype:'textfield',
- fieldLabel: 'First Name',
- name: 'first',
- anchor:'96%'
- }, {
- xtype:'textfield',
- fieldLabel: 'Company',
- name: 'company',
- anchor:'96%'
- }]
- },{
- xtype: 'container',
- columnWidth:.5,
- layout: 'anchor',
- items: [{
- xtype:'textfield',
- fieldLabel: 'Last Name',
- name: 'last',
- anchor:'100%'
- },{
- xtype:'textfield',
- fieldLabel: 'Email',
- name: 'email',
- vtype:'email',
- anchor:'100%'
- }]
- }]
- }, {
- xtype: 'htmleditor',
- name: 'bio',
- fieldLabel: 'Biography',
- height: 200,
- anchor: '100%'
- }],
- buttons: [{
- text: 'Save'
- },{
- text: 'Cancel'
- }]
- });
- top.render(document.body);
- /*
- * ================ Form 4 =======================
- */
- bd.createChild({tag: 'h2', html: 'Form 4 - Forms can be a TabPanel...'});
- var tabs = Ext.create('Ext.form.Panel', {
- width: 350,
- border: false,
- bodyBorder: false,
- fieldDefaults: {
- labelWidth: 75,
- msgTarget: 'side'
- },
- defaults: {
- anchor: '100%'
- },
- items: {
- xtype:'tabpanel',
- activeTab: 0,
- defaults:{
- bodyStyle:'padding:10px'
- },
- items:[{
- title:'Personal Details',
- defaultType: 'textfield',
- items: [{
- fieldLabel: 'First Name',
- name: 'first',
- allowBlank:false,
- value: 'Ed'
- },{
- fieldLabel: 'Last Name',
- name: 'last',
- value: 'Spencer'
- },{
- fieldLabel: 'Company',
- name: 'company',
- value: 'Ext JS'
- }, {
- fieldLabel: 'Email',
- name: 'email',
- vtype:'email'
- }]
- },{
- title:'Phone Numbers',
- defaultType: 'textfield',
- items: [{
- fieldLabel: 'Home',
- name: 'home',
- value: '(888) 555-1212'
- },{
- fieldLabel: 'Business',
- name: 'business'
- },{
- fieldLabel: 'Mobile',
- name: 'mobile'
- },{
- fieldLabel: 'Fax',
- name: 'fax'
- }]
- }]
- },
- buttons: [{
- text: 'Save'
- },{
- text: 'Cancel'
- }]
- });
- tabs.render(document.body);
- /*
- * ================ Form 5 =======================
- */
- bd.createChild({tag: 'h2', html: 'Form 5 - ... and forms can contain TabPanel(s)'});
- var tab2 = Ext.create('Ext.form.Panel', {
- title: 'Inner Tabs',
- bodyStyle:'padding:5px',
- width: 600,
- fieldDefaults: {
- labelAlign: 'top',
- msgTarget: 'side'
- },
- defaults: {
- anchor: '100%'
- },
- items: [{
- layout:'column',
- border:false,
- items:[{
- columnWidth:.5,
- border:false,
- layout: 'anchor',
- defaultType: 'textfield',
- items: [{
- fieldLabel: 'First Name',
- name: 'first',
- anchor:'95%'
- }, {
- fieldLabel: 'Company',
- name: 'company',
- anchor:'95%'
- }]
- },{
- columnWidth:.5,
- border:false,
- layout: 'anchor',
- defaultType: 'textfield',
- items: [{
- fieldLabel: 'Last Name',
- name: 'last',
- anchor:'95%'
- },{
- fieldLabel: 'Email',
- name: 'email',
- vtype:'email',
- anchor:'95%'
- }]
- }]
- },{
- xtype:'tabpanel',
- plain:true,
- activeTab: 0,
- height:235,
- defaults:{bodyStyle:'padding:10px'},
- items:[{
- title:'Personal Details',
- defaults: {width: 230},
- defaultType: 'textfield',
- items: [{
- fieldLabel: 'First Name',
- name: 'first',
- allowBlank:false,
- value: 'Jamie'
- },{
- fieldLabel: 'Last Name',
- name: 'last',
- value: 'Avins'
- },{
- fieldLabel: 'Company',
- name: 'company',
- value: 'Ext JS'
- }, {
- fieldLabel: 'Email',
- name: 'email',
- vtype:'email'
- }]
- },{
- title:'Phone Numbers',
- defaults: {width: 230},
- defaultType: 'textfield',
- items: [{
- fieldLabel: 'Home',
- name: 'home',
- value: '(888) 555-1212'
- },{
- fieldLabel: 'Business',
- name: 'business'
- },{
- fieldLabel: 'Mobile',
- name: 'mobile'
- },{
- fieldLabel: 'Fax',
- name: 'fax'
- }]
- },{
- cls: 'x-plain',
- title: 'Biography',
- layout: 'fit',
- items: {
- xtype: 'htmleditor',
- name: 'bio2',
- fieldLabel: 'Biography'
- }
- }]
- }],
- buttons: [{
- text: 'Save'
- },{
- text: 'Cancel'
- }]
- });
- tab2.render(document.body);
- });
- /**
- * @class Ext.picker.Date
- * @extends Ext.Component
- * <p>A date picker. This class is used by the {@link Ext.form.field.Date} field to allow browsing and
- * selection of valid dates in a popup next to the field, but may also be used with other components.</p>
- * <p>Typically you will need to implement a handler function to be notified when the user chooses a color from the
- * picker; you can register the handler using the {@link #select} event, or by implementing the {@link #handler}
- * method.</p>
- * <p>By default the user will be allowed to pick any date; this can be changed by using the {@link #minDate},
- * {@link #maxDate}, {@link #disabledDays}, {@link #disabledDatesRE}, and/or {@link #disabledDates} configs.</p>
- * <p>All the string values documented below may be overridden by including an Ext locale file in your page.</p>
- * <p>Example usage:</p>
- * <pre><code>new Ext.panel.Panel({
- title: 'Choose a future date:',
- width: 200,
- bodyPadding: 10,
- renderTo: Ext.getBody(),
- items: [{
- xtype: 'datepicker',
- minDate: new Date(),
- handler: function(picker, date) {
- // do something with the selected date
- }
- }]
- });</code></pre>
- * {@img Ext.picker.Date/Ext.picker.Date.png Ext.picker.Date component}
- *
- */
- Ext.define('Ext.picker.NewDate', {
- extend: 'Ext.Container',
- requires: [
- 'Ext.data.Model',
- 'Ext.view.BoundList',
- 'Ext.XTemplate',
- 'Ext.button.Button',
- 'Ext.button.Split',
- 'Ext.util.ClickRepeater',
- 'Ext.util.KeyNav',
- 'Ext.EventObject',
- 'Ext.fx.Manager',
- 'Ext.picker.Month'
- ],
- alias: 'widget.newdatepicker',
- alternateClassName: 'Ext.DatePicker',
- renderTpl: [
- '<div class="{cls}" id="{id}" role="grid" title="{ariaTitle} {value:this.longDay}">',
- '<div role="presentation" class="{baseCls}-header">',
- '<div class="{baseCls}-prev"><a id="{id}-prevEl" href="#" role="button" title="{prevText}"></a></div>',
- '<div class="{baseCls}-month" id="{id}-middleBtnEl"></div>',
- '<div class="{baseCls}-next"><a id="{id}-nextEl" href="#" role="button" title="{nextText}"></a></div>',
- '</div>',
- '<div id="{id}-calendarContainer"></div>',
- '<tpl if="showToday">',
- '<div id="{id}-footerEl" role="presentation" class="{baseCls}-footer"></div>',
- '</tpl>',
- '</div>',
- {
- longDay: function(value){
- return Ext.Date.format(value, this.longDayFormat);
- }
- }
- ],
- calendarTpl: [
- '<table class="{baseCls}-inner" cellspacing="0" role="presentation">' +
- '<thead role="presentation"><tr role="presentation">' +
- '<tpl for="dayNames">' +
- '<th role="columnheader" title="{.}"><span>{.:this.firstInitial}</span></th>' +
- '</tpl>' +
- '</tr></thead>' +
- '<tbody role="presentation"><tr role="presentation">' +
- '<tpl for="days">' +
- '{#:this.isEndOfWeek}' +
- '<td role="gridcell" id="{[Ext.id()]}" class="{[this.getCellClass(values, parent)]}" title="{date:this.titleFormat}">' +
- '<a role="presentation" href="#" hidefocus="on" class="{parent.baseCls}-date" tabIndex="1">' +
- '<em role="presentation"><span role="presentation">{.:date("j")</span></em>' +
- '</a>' +
- '</td>' +
- '</tpl>' +
- '</tr></tbody>' +
- '</table>', {
-
- cellClass: function(value, data) {
-
- },
- titleFormat: function(value) {
- return Ext.date.format(value, this.longDayFormat);
- },
- firstInitial: function(value) {
- return value.substr(0,1);
- },
- isEndOfWeek: function(value) {
- // convert from 1 based index to 0 based
- // by decrementing value once.
- value--;
- var end = value % 7 === 0 && value !== 0;
- return end ? '</tr><tr role="row">' : '';
- }
- }],
- ariaTitle: 'Date Picker',
- /**
- * @cfg {String} todayText
- * The text to display on the button that selects the current date (defaults to <code>'Today'</code>)
- */
- todayText : 'Today',
- /**
- * @cfg {Function} handler
- * Optional. A function that will handle the select event of this picker.
- * The handler is passed the following parameters:<div class="mdetail-params"><ul>
- * <li><code>picker</code> : Ext.picker.Date <div class="sub-desc">This Date picker.</div></li>
- * <li><code>date</code> : Date <div class="sub-desc">The selected date.</div></li>
- * </ul></div>
- */
- /**
- * @cfg {Object} scope
- * The scope (<code><b>this</b></code> reference) in which the <code>{@link #handler}</code>
- * function will be called. Defaults to this DatePicker instance.
- */
- /**
- * @cfg {String} todayTip
- * A string used to format the message for displaying in a tooltip over the button that
- * selects the current date. Defaults to <code>'{0} (Spacebar)'</code> where
- * the <code>{0}</code> token is replaced by today's date.
- */
- todayTip : '{0} (Spacebar)',
- /**
- * @cfg {String} minText
- * The error text to display if the minDate validation fails (defaults to <code>'This date is before the minimum date'</code>)
- */
- minText : 'This date is before the minimum date',
- /**
- * @cfg {String} maxText
- * The error text to display if the maxDate validation fails (defaults to <code>'This date is after the maximum date'</code>)
- */
- maxText : 'This date is after the maximum date',
- /**
- * @cfg {String} format
- * The default date format string which can be overriden for localization support. The format must be
- * valid according to {@link Ext.Date#parse} (defaults to {@link Ext.Date#defaultFormat}).
- */
- /**
- * @cfg {String} disabledDaysText
- * The tooltip to display when the date falls on a disabled day (defaults to <code>'Disabled'</code>)
- */
- disabledDaysText : 'Disabled',
- /**
- * @cfg {String} disabledDatesText
- * The tooltip text to display when the date falls on a disabled date (defaults to <code>'Disabled'</code>)
- */
- disabledDatesText : 'Disabled',
- /**
- * @cfg {Array} monthNames
- * An array of textual month names which can be overriden for localization support (defaults to Ext.Date.monthNames)
- */
- /**
- * @cfg {Array} dayNames
- * An array of textual day names which can be overriden for localization support (defaults to Ext.Date.dayNames)
- */
- /**
- * @cfg {String} nextText
- * The next month navigation button tooltip (defaults to <code>'Next Month (Control+Right)'</code>)
- */
- nextText : 'Next Month (Control+Right)',
- /**
- * @cfg {String} prevText
- * The previous month navigation button tooltip (defaults to <code>'Previous Month (Control+Left)'</code>)
- */
- prevText : 'Previous Month (Control+Left)',
- /**
- * @cfg {String} monthYearText
- * The header month selector tooltip (defaults to <code>'Choose a month (Control+Up/Down to move years)'</code>)
- */
- monthYearText : 'Choose a month (Control+Up/Down to move years)',
- /**
- * @cfg {Number} startDay
- * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
- */
- startDay : 0,
- /**
- * @cfg {Boolean} showToday
- * False to hide the footer area containing the Today button and disable the keyboard handler for spacebar
- * that selects the current date (defaults to <code>true</code>).
- */
- showToday : true,
- /**
- * @cfg {Date} minDate
- * Minimum allowable date (JavaScript date object, defaults to null)
- */
- /**
- * @cfg {Date} maxDate
- * Maximum allowable date (JavaScript date object, defaults to null)
- */
- /**
- * @cfg {Array} disabledDays
- * An array of days to disable, 0-based. For example, [0, 6] disables Sunday and Saturday (defaults to null).
- */
- /**
- * @cfg {RegExp} disabledDatesRE
- * JavaScript regular expression used to disable a pattern of dates (defaults to null). The {@link #disabledDates}
- * config will generate this regex internally, but if you specify disabledDatesRE it will take precedence over the
- * disabledDates value.
- */
- /**
- * @cfg {Array} disabledDates
- * An array of 'dates' to disable, as strings. These strings will be used to build a dynamic regular
- * expression so they are very powerful. Some examples:
- * <ul>
- * <li>['03/08/2003', '09/16/2003'] would disable those exact dates</li>
- * <li>['03/08', '09/16'] would disable those days for every year</li>
- * <li>['^03/08'] would only match the beginning (useful if you are using short years)</li>
- * <li>['03/../2006'] would disable every day in March 2006</li>
- * <li>['^03'] would disable every day in every March</li>
- * </ul>
- * Note that the format of the dates included in the array should exactly match the {@link #format} config.
- * In order to support regular expressions, if you are using a date format that has '.' in it, you will have to
- * escape the dot when restricting dates. For example: ['03\\.08\\.03'].
- */
- /**
- * @cfg {Boolean} disableAnim True to disable animations when showing the month picker. Defaults to <tt>false</tt>.
- */
- disableAnim: false,
- /**
- * @cfg {String} baseCls
- * The base CSS class to apply to this components element (defaults to <tt>'x-datepicker'</tt>).
- */
- baseCls: Ext.baseCSSPrefix + 'datepicker',
- /**
- * @cfg {String} selectedCls
- * The class to apply to the selected cell. Defaults to <tt>'x-datepicker-selected'</tt>
- */
- /**
- * @cfg {String} disabledCellCls
- * The class to apply to disabled cells. Defaults to <tt>'x-datepicker-disabled'</tt>
- */
- /**
- * @cfg {String} longDayFormat
- * The format for displaying a date in a longer format. Defaults to <tt>'F d, Y'</tt>
- */
- longDayFormat: 'F d, Y',
- /**
- * @cfg {Object} keyNavConfig Specifies optional custom key event handlers for the {@link Ext.util.KeyNav}
- * attached to this date picker. Must conform to the config format recognized by the {@link Ext.util.KeyNav}
- * constructor. Handlers specified in this object will replace default handlers of the same name.
- */
- /**
- * @cfg {Boolean} focusOnShow
- * True to automatically focus the picker on show. Defaults to <tt>false</tt>.
- */
- focusOnShow: false,
- // private
- // Set by other components to stop the picker focus being updated when the value changes.
- focusOnSelect: true,
- width: 178,
- // default value used to initialise each date in the DatePicker
- // (note: 12 noon was chosen because it steers well clear of all DST timezone changes)
- initHour: 12, // 24-hour format
- numDays: 42,
- // private, inherit docs
- initComponent : function() {
- var me = this,
- clearTime = Ext.Date.clearTime;
- me.selectedCls = me.baseCls + '-selected';
- me.disabledCellCls = me.baseCls + '-disabled';
- me.prevCls = me.baseCls + '-prevday';
- me.activeCls = me.baseCls + '-active';
- me.nextCls = me.baseCls + '-prevday';
- me.todayCls = me.baseCls + '-today';
- me.dayNames = me.dayNames.slice(me.startDay).concat(me.dayNames.slice(0, me.startDay));
- this.callParent();
- me.value = me.value ?
- clearTime(me.value, true) : clearTime(new Date());
- me.addEvents(
- /**
- * @event select
- * Fires when a date is selected
- * @param {DatePicker} this DatePicker
- * @param {Date} date The selected date
- */
- 'select'
- );
- me.initDisabledDays();
- },
- // private, inherit docs
- onRender : function(container, position){
- /*
- * days array for looping through 6 full weeks (6 weeks * 7 days)
- * Note that we explicitly force the size here so the template creates
- * all the appropriate cells.
- */
- var me = this,
- days = new Array(me.numDays),
- today = Ext.Date.format(new Date(), me.format),
- calendarTpl = Ext.create('Ext.XTemplate', me.calendarTpl);
- Ext.apply(me.renderData, {
- dayNames: me.dayNames,
- ariaTitle: me.ariaTitle,
- value: me.value,
- showToday: me.showToday,
- prevText: me.prevText,
- nextText: me.nextText,
- days: days
- });
- me.getTpl('renderTpl').longDayFormat = me.longDayFormat;
- me.addChildEls('calendarContainer', 'prevEl', 'nextEl', 'middleBtnEl', 'footerEl');
- this.callParent(arguments);
- me.el.unselectable();
- // The calendar is a BoundList with aen empty Store.
- // collectData returns the fields.
- calendarTpl.longDayFormat = me.longDayFormat;
- me.calendarView = Ext.create('Ext.view.BoundList', {
- store: new Ext.data.Store({fields:[]}),
- collectData: function() {
- return me.collectData();
- },
- renderTo: me.calendarContainer,
- tpl: calendarTpl,
- itemSelector: 'td',
- selectedItemCls: me.baseCls + '-selected'
- });
- me.monthBtn = Ext.create('Ext.button.Split', {
- ownerCt: me,
- text: '',
- tooltip: me.monthYearText,
- renderTo: me.middleBtnEl
- });
- //~ me.middleBtnEl.down('button').addCls(Ext.baseCSSPrefix + 'btn-arrow');
- me.todayBtn = Ext.create('Ext.button.Button', {
- renderTo: me.footerEl,
- text: Ext.String.format(me.todayText, today),
- tooltip: Ext.String.format(me.todayTip, today),
- handler: me.selectToday,
- scope: me
- });
- },
- // Collect a data object for use by the calendar View
- collectData : function() {
- var me = this;
- return {
- today: new Date(),
- daynames: me.dayNames.slice(me.startDay).concat(me.dayNames.slice(0, me.startDay)),
- days: Ext.AbstractView.prototype.apply(me, arguments)
- };
- },
- // private, inherit docs
- initEvents: function(){
- var me = this;
- this.callParent();
- me.prevRepeater = Ext.create('Ext.util.ClickRepeater', me.prevEl, {
- handler: me.showPrevMonth,
- scope: me,
- preventDefault: true,
- stopDefault: true
- });
- me.nextRepeater = Ext.create('Ext.util.ClickRepeater', me.nextEl, {
- handler: me.showNextMonth,
- scope: me,
- preventDefault:true,
- stopDefault:true
- });
- me.keyNav = Ext.create('Ext.util.KeyNav', me.calendarView.el, Ext.apply({
- scope: me,
- 'left' : function(e){
- if(e.ctrlKey){
- me.showPrevMonth();
- }
- },
- 'right' : function(e){
- if(e.ctrlKey){
- me.showNextMonth();
- }
- },
- 'up' : function(e){
- if(e.ctrlKey){
- me.showNextYear();
- }
- },
- 'down' : function(e){
- if(e.ctrlKey){
- me.showPrevYear();
- }
- },
- 'pageUp' : me.showNextMonth,
- 'pageDown' : me.showPrevMonth,
- 'enter' : function(e){
- e.stopPropagation();
- return true;
- }
- }, me.keyNavConfig));
- if(me.showToday){
- me.todayKeyListener = me.calendarView.el.addKeyListener(Ext.EventObject.SPACE, me.selectToday, me);
- }
- me.mon(me.calendarView.el, 'mousewheel', me.handleMouseWheel, me);
- me.mon(me.monthBtn, 'click', me.showMonthPicker, me);
- me.mon(me.monthBtn, 'arrowclick', me.showMonthPicker, me);
- me.update(me.value);
- },
- /**
- * Setup the disabled dates regex based on config options
- * @private
- */
- initDisabledDays : function(){
- var me = this,
- dd = me.disabledDates,
- re = '(?:',
- len;
- if(!me.disabledDatesRE && dd){
- len = dd.length - 1;
- Ext.each(dd, function(d, i){
- re += Ext.isDate(d) ? '^' + Ext.String.escapeRegex(Ext.Date.dateFormat(d, me.format)) + '$' : dd[i];
- if(i != len){
- re += '|';
- }
- }, me);
- me.disabledDatesRE = new RegExp(re + ')');
- }
- },
- /**
- * Replaces any existing disabled dates with new values and refreshes the DatePicker.
- * @param {Array/RegExp} disabledDates An array of date strings (see the {@link #disabledDates} config
- * for details on supported values), or a JavaScript regular expression used to disable a pattern of dates.
- * @return {Ext.picker.Date} this
- */
- setDisabledDates : function(dd){
- var me = this;
- if(Ext.isArray(dd)){
- me.disabledDates = dd;
- me.disabledDatesRE = null;
- }else{
- me.disabledDatesRE = dd;
- }
- me.initDisabledDays();
- me.update(me.value, true);
- return me;
- },
- /**
- * Replaces any existing disabled days (by index, 0-6) with new values and refreshes the DatePicker.
- * @param {Array} disabledDays An array of disabled day indexes. See the {@link #disabledDays} config
- * for details on supported values.
- * @return {Ext.picker.Date} this
- */
- setDisabledDays : function(dd){
- this.disabledDays = dd;
- return this.update(this.value, true);
- },
- /**
- * Replaces any existing {@link #minDate} with the new value and refreshes the DatePicker.
- * @param {Date} value The minimum date that can be selected
- * @return {Ext.picker.Date} this
- */
- setMinDate : function(dt){
- this.minDate = dt;
- return this.update(this.value, true);
- },
- /**
- * Replaces any existing {@link #maxDate} with the new value and refreshes the DatePicker.
- * @param {Date} value The maximum date that can be selected
- * @return {Ext.picker.Date} this
- */
- setMaxDate : function(dt){
- this.maxDate = dt;
- return this.update(this.value, true);
- },
- /**
- * Sets the value of the date field
- * @param {Date} value The date to set
- * @return {Ext.picker.Date} this
- */
- setValue : function(value){
- this.value = Ext.Date.clearTime(value, true);
- return this.update(this.value);
- },
- /**
- * Gets the current selected value of the date field
- * @return {Date} The selected date
- */
- getValue : function(){
- return this.value;
- },
- // private
- focus : function(){
- this.update(this.activeDate);
- },
- // private, inherit docs
- onEnable: function(){
- this.callParent();
- this.setDisabledStatus(false);
- this.update(this.activeDate);
- },
- // private, inherit docs
- onDisable : function(){
- this.callParent();
- this.setDisabledStatus(true);
- },
- /**
- * Set the disabled state of various internal components
- * @private
- * @param {Boolean} disabled
- */
- setDisabledStatus : function(disabled){
- var me = this;
- me.keyNav.setDisabled(disabled);
- me.prevRepeater.setDisabled(disabled);
- me.nextRepeater.setDisabled(disabled);
- if (me.showToday) {
- me.todayKeyListener.setDisabled(disabled);
- me.todayBtn.setDisabled(disabled);
- }
- },
- /**
- * Get the current active date.
- * @private
- * @return {Date} The active date
- */
- getActive: function(){
- return this.activeDate || this.value;
- },
- /**
- * Run any animation required to hide/show the month picker.
- * @private
- * @param {Boolean} isHide True if it's a hide operation
- */
- runAnimation: function(isHide){
- var options = {
- duration: 200
- };
- if (isHide) {
- this.monthPicker.el.slideOut('t', options);
- } else {
- this.monthPicker.el.slideIn('t', options);
- }
- },
- /**
- * Hides the month picker, if it's visible.
- * @return {Ext.picker.Date} this
- */
- hideMonthPicker : function(){
- var me = this,
- picker = me.monthPicker;
- if (picker) {
- if (me.disableAnim) {
- picker.hide();
- } else {
- this.runAnimation(true);
- }
- }
- return me;
- },
- /**
- * Show the month picker
- * @return {Ext.picker.Date} this
- */
- showMonthPicker : function(){
- var me = this,
- picker;
- if (me.rendered && !me.disabled) {
- picker = me.createMonthPicker();
- picker.setValue(me.getActive());
- picker.setSize(me.getSize());
- picker.setPosition(-1, -1);
- if (me.disableAnim) {
- picker.show();
- } else {
- me.runAnimation(false);
- }
- }
- return me;
- },
- /**
- * Create the month picker instance
- * @private
- * @return {Ext.picker.Month} picker
- */
- createMonthPicker: function(){
- var me = this,
- picker = me.monthPicker;
- if (!picker) {
- me.monthPicker = picker = Ext.create('Ext.picker.Month', {
- renderTo: me.el,
- floating: true,
- shadow: false,
- small: me.showToday === false,
- listeners: {
- scope: me,
- cancelclick: me.onCancelClick,
- okclick: me.onOkClick,
- yeardblclick: me.onOkClick,
- monthdblclick: me.onOkClick
- }
- });
- if (!me.disableAnim) {
- // hide the element if we're animating to prevent an initial flicker
- picker.el.setStyle('display', 'none');
- }
- me.on('beforehide', me.hideMonthPicker, me);
- }
- return picker;
- },
- /**
- * Respond to an ok click on the month picker
- * @private
- */
- onOkClick: function(picker, value){
- var me = this,
- month = value[0],
- year = value[1],
- date = new Date(year, month, me.getActive().getDate());
- if (date.getMonth() !== month) {
- // 'fix' the JS rolling date conversion if needed
- date = new Date(year, month, 1).getLastDateOfMonth();
- }
- me.update(date);
- me.hideMonthPicker();
- },
- /**
- * Respond to a cancel click on the month picker
- * @private
- */
- onCancelClick: function(){
- this.hideMonthPicker();
- },
- /**
- * Show the previous month.
- * @return {Ext.picker.Date} this
- */
- showPrevMonth : function(e){
- return this.update(Ext.Date.add(this.activeDate, Ext.Date.MONTH, -1));
- },
- /**
- * Show the next month.
- * @return {Ext.picker.Date} this
- */
- showNextMonth : function(e){
- return this.update(Ext.Date.add(this.activeDate, Ext.Date.MONTH, 1));
- },
- /**
- * Show the previous year.
- * @return {Ext.picker.Date} this
- */
- showPrevYear : function(){
- this.update(Ext.Date.add(this.activeDate, Ext.Date.YEAR, -1));
- },
- /**
- * Show the next year.
- * @return {Ext.picker.Date} this
- */
- showNextYear : function(){
- this.update(Ext.Date.add(this.activeDate, Ext.Date.YEAR, 1));
- },
- /**
- * Respond to the mouse wheel event
- * @private
- * @param {Ext.EventObject} e
- */
- handleMouseWheel : function(e){
- e.stopEvent();
- if(!this.disabled){
- var delta = e.getWheelDelta();
- if(delta > 0){
- this.showPrevMonth();
- } else if(delta < 0){
- this.showNextMonth();
- }
- }
- },
- /**
- * Respond to a date being clicked in the picker
- * @private
- * @param {Ext.EventObject} e
- * @param {HTMLElement} t
- */
- handleDateClick : function(e, t){
- var me = this,
- handler = me.handler;
- e.stopEvent();
- if(!me.disabled && t.dateValue && !Ext.fly(t.parentNode).hasCls(me.disabledCellCls)){
- me.cancelFocus = me.focusOnSelect === false;
- me.setValue(new Date(t.dateValue));
- delete me.cancelFocus;
- me.fireEvent('select', me, me.value);
- if (handler) {
- handler.call(me.scope || me, me, me.value);
- }
- // event handling is turned off on hide
- // when we are using the picker in a field
- // therefore onSelect comes AFTER the select
- // event.
- me.onSelect();
- }
- },
- /**
- * Perform any post-select actions
- * @private
- */
- onSelect: function() {
- if (this.hideOnSelect) {
- this.hide();
- }
- },
- /**
- * Sets the current value to today.
- * @return {Ext.picker.Date} this
- */
- selectToday : function(){
- var me = this,
- btn = me.todayBtn,
- handler = me.handler;
- if(btn && !btn.disabled){
- me.setValue(Ext.Date.clearTime(new Date()));
- me.fireEvent('select', me, me.value);
- if (handler) {
- handler.call(me.scope || me, me, me.value);
- }
- me.onSelect();
- }
- return me;
- },
- /**
- * Update the selected cell
- * @private
- * @param {Date} date The new date
- * @param {Date} active The active date
- */
- selectedUpdate: function(date, active){
- var me = this,
- t = date.getTime(),
- cells = me.cells,
- cls = me.selectedCls;
- cells.removeCls(cls);
- cells.each(function(c){
- if (c.dom.firstChild.dateValue == t) {
- me.el.dom.setAttribute('aria-activedescendent', c.dom.id);
- c.addCls(cls);
- if(me.isVisible() && !me.cancelFocus){
- Ext.fly(c.dom.firstChild).focus(50);
- }
- return false;
- }
- }, this);
- },
- /**
- * Update the contents of the picker for a new month
- * @private
- * @param {Date} date The new date
- * @param {Date} active The active date
- */
- fullUpdate: function(date, active){
- var me = this,
- cells = me.cells.elements,
- textNodes = me.textNodes,
- disabledCls = me.disabledCellCls,
- eDate = Ext.Date,
- i = 0,
- extraDays = 0,
- visible = me.isVisible(),
- sel = +eDate.clearTime(date, true),
- today = +eDate.clearTime(new Date()),
- min = me.minDate ? eDate.clearTime(me.minDate, true) : Number.NEGATIVE_INFINITY,
- max = me.maxDate ? eDate.clearTime(me.maxDate, true) : Number.POSITIVE_INFINITY,
- ddMatch = me.disabledDatesRE,
- ddText = me.disabledDatesText,
- ddays = me.disabledDays ? me.disabledDays.join('') : false,
- ddaysText = me.disabledDaysText,
- format = me.format,
- days = eDate.getDaysInMonth(date),
- firstOfMonth = eDate.getFirstDateOfMonth(date),
- startingPos = firstOfMonth.getDay() - me.startDay,
- previousMonth = eDate.add(date, eDate.MONTH, -1),
- longDayFormat = me.longDayFormat,
- prevStart,
- current,
- disableToday,
- tempDate,
- setCellClass,
- html,
- cls,
- formatValue,
- value;
- if (startingPos < 0) {
- startingPos += 7;
- }
- days += startingPos;
- prevStart = eDate.getDaysInMonth(previousMonth) - startingPos;
- current = new Date(previousMonth.getFullYear(), previousMonth.getMonth(), prevStart, me.initHour);
- if (me.showToday) {
- tempDate = eDate.clearTime(new Date());
- disableToday = (tempDate < min || tempDate > max ||
- (ddMatch && format && ddMatch.test(eDate.dateFormat(tempDate, format))) ||
- (ddays && ddays.indexOf(tempDate.getDay()) != -1));
- if (!me.disabled) {
- me.todayBtn.setDisabled(disableToday);
- me.todayKeyListener.setDisabled(disableToday);
- }
- }
- setCellClass = function(cell){
- value = +eDate.clearTime(current, true);
- cell.title = eDate.format(current, longDayFormat);
- // store dateValue number as an expando
- cell.firstChild.dateValue = value;
- if(value == today){
- cell.className += ' ' + me.todayCls;
- cell.title = me.todayText;
- }
- if(value == sel){
- cell.className += ' ' + me.selectedCls;
- me.el.dom.setAttribute('aria-activedescendant', cell.id);
- if (visible && me.floating) {
- Ext.fly(cell.firstChild).focus(50);
- }
- }
- // disabling
- if(value < min) {
- cell.className = disabledCls;
- cell.title = me.minText;
- return;
- }
- if(value > max) {
- cell.className = disabledCls;
- cell.title = me.maxText;
- return;
- }
- if(ddays){
- if(ddays.indexOf(current.getDay()) != -1){
- cell.title = ddaysText;
- cell.className = disabledCls;
- }
- }
- if(ddMatch && format){
- formatValue = eDate.dateFormat(current, format);
- if(ddMatch.test(formatValue)){
- cell.title = ddText.replace('%0', formatValue);
- cell.className = disabledCls;
- }
- }
- };
- for(; i < me.numDays; ++i) {
- if (i < startingPos) {
- html = (++prevStart);
- cls = me.prevCls;
- } else if (i >= days) {
- html = (++extraDays);
- cls = me.nextCls;
- } else {
- html = i - startingPos + 1;
- cls = me.activeCls;
- }
- textNodes[i].innerHTML = html;
- cells[i].className = cls;
- current.setDate(current.getDate() + 1);
- setCellClass(cells[i]);
- }
- me.monthBtn.setText(me.monthNames[date.getMonth()] + ' ' + date.getFullYear());
- },
- /**
- * Update the contents of the picker
- * @private
- * @param {Date} date The new date
- * @param {Boolean} forceRefresh True to force a full refresh
- */
- update : function(date, forceRefresh){
- var me = this,
- active = me.activeDate;
- if (me.rendered) {
- me.activeDate = date;
- if(!forceRefresh && active && me.el && active.getMonth() == date.getMonth() && active.getFullYear() == date.getFullYear()){
- me.selectedUpdate(date, active);
- } else {
- me.fullUpdate(date, active);
- }
- }
- return me;
- },
- // private, inherit docs
- beforeDestroy : function() {
- var me = this;
- if (me.rendered) {
- Ext.destroy(
- me.todayKeyListener,
- me.keyNav,
- me.monthPicker,
- me.monthBtn,
- me.nextRepeater,
- me.prevRepeater,
- me.todayBtn
- );
- delete me.textNodes;
- delete me.cells.elements;
- }
- },
- // private, inherit docs
- onShow: function() {
- this.callParent(arguments);
- if (this.focusOnShow) {
- this.focus();
- }
- }
- },
- // After dependencies have loaded:
- function() {
- var proto = this.prototype;
- proto.monthNames = Ext.Date.monthNames;
- proto.dayNames = Ext.Date.dayNames;
- proto.format = Ext.Date.defaultFormat;
- });
|