IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Ext JS / Sencha Discussion :

Migration du code extjs 3.4 vers 4.2


Sujet :

Ext JS / Sencha

  1. #1
    Membre régulier
    Homme Profil pro
    Inscrit en
    Juin 2012
    Messages
    180
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juin 2012
    Messages : 180
    Points : 73
    Points
    73
    Par défaut Migration du code extjs 3.4 vers 4.2
    salut,

    j'ai un code de datepiker qui fonctionne avec extjs 3.4 , mais quand je test ce code avec extjs 4.2 je trouve des erreurs

    mon but est d'adapter ce code pour le rendre fonctionnel avec extjs 4.2

    le code est le suivant :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    Ext.apply(this.menu.picker,  {
                minDate : this.minValue,
                maxDate : this.maxValue,
                disabledDatesRE : this.disabledDatesRE,
                disabledDatesText : this.disabledDatesText,
                disabledDays : this.disabledDays,
                disabledDaysText : this.disabledDaysText,
                format : this.format,
                showToday : this.showToday,
                startDay: this.startDay,
                minText : String.format(this.minText, this.formatDate(this.minValue)),
                maxText : String.format(this.maxText, this.formatDate(this.maxValue)),
                field: this
            });
    l'erreur est niveau de ces lignes :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    minText : String.format(this.minText, this.formatDate(this.minValue)),
                    maxText : String.format(this.maxText, this.formatDate(this.maxValue)),
    Uncaught TypeError: Object function String() { [native code] } has no method 'format'

    en fait j'ai ce code dans la page js suivante : Ext.ux.DateHijriField.js


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    /*!
     * Ext JS Library 3.4.0
     * Copyright(c) 2006-2011 Sencha Inc.
     * licensing@sencha.com
     * http://www.sencha.com/license
     */
    /**
     * @class Ext.ux.DateHijriField
     * @extends Ext.form.TriggerField
     * Provides a date input field with a {@link Ext.DatePicker} dropdown and automatic date validation.
     * @constructor
     * Create a new DateHijriField
     * @param {Object} config
     * @xtype datehijrifield
     */
    Ext.ux.DateHijriField = Ext.extend(Ext.form.TriggerField,  {
        /**
         * @cfg {String} format
         * The default date format string which can be overriden for localization support.  The format must be
         * valid according to {@link Date#parseDate} (defaults to <tt>'m/d/Y'</tt>).
         */
        format : "m/d/Y",
        /**
         * @cfg {String} altFormats
         * Multiple date formats separated by "<tt>|</tt>" to try when parsing a user input value and it
         * does not match the defined format (defaults to
         * <tt>'m/d/Y|n/j/Y|n/j/y|m/j/y|n/d/y|m/j/Y|n/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d|Y-m-d|n-j|n/j'</tt>).
         */
        altFormats : "m/d/Y|n/j/Y|n/j/y|m/j/y|n/d/y|m/j/Y|n/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d|Y-m-d|n-j|n/j",
        /**
         * @cfg {String} disabledDaysText
         * The tooltip to display when the date falls on a disabled day (defaults to <tt>'Disabled'</tt>)
         */
        disabledDaysText : "Disabled",
        /**
         * @cfg {String} disabledDatesText
         * The tooltip text to display when the date falls on a disabled date (defaults to <tt>'Disabled'</tt>)
         */
        disabledDatesText : "Disabled",
        /**
         * @cfg {String} minText
         * The error text to display when the date in the cell is before <tt>{@link #minValue}</tt> (defaults to
         * <tt>'The date in this field must be after {minValue}'</tt>).
         */
        minText : "The date in this field must be equal to or after {0}",
        /**
         * @cfg {String} maxText
         * The error text to display when the date in the cell is after <tt>{@link #maxValue}</tt> (defaults to
         * <tt>'The date in this field must be before {maxValue}'</tt>).
         */
        maxText : "The date in this field must be equal to or before {0}",
        /**
         * @cfg {String} invalidText
         * The error text to display when the date in the field is invalid (defaults to
         * <tt>'{value} is not a valid date - it must be in the format {format}'</tt>).
         */
        invalidText : "{0} is not a valid date - it must be in the format {1}",
        /**
         * @cfg {String} triggerClass
         * An additional CSS class used to style the trigger button.  The trigger will always get the
         * class <tt>'x-form-trigger'</tt> and <tt>triggerClass</tt> will be <b>appended</b> if specified
         * (defaults to <tt>'x-form-date-trigger'</tt> which displays a calendar icon).
         */
        triggerClass : 'x-form-date-trigger',
        /**
         * @cfg {Boolean} showToday
         * <tt>false</tt> to hide the footer area of the DatePicker containing the Today button and disable
         * the keyboard handler for spacebar that selects the current date (defaults to <tt>true</tt>).
         */
        showToday : true,
     
        /**
         * @cfg {Number} startDay
         * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
         */
        startDay : 0,
     
        /**
         * @cfg {Date/String} minValue
         * The minimum allowed date. Can be either a Javascript date object or a string date in a
         * valid format (defaults to null).
         */
        /**
         * @cfg {Date/String} maxValue
         * The maximum allowed date. Can be either a Javascript date object or a string date in a
         * valid format (defaults to null).
         */
        /**
         * @cfg {Array} disabledDays
         * An array of days to disable, 0 based (defaults to null). Some examples:<pre><code>
    // disable Sunday and Saturday:
    disabledDays:  [0, 6]
    // disable weekdays:
    disabledDays: [1,2,3,4,5]
         * </code></pre>
         */
        /**
         * @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:<pre><code>
    // disable these exact dates:
    disabledDates: ["03/08/2003", "09/16/2003"]
    // disable these days for every year:
    disabledDates: ["03/08", "09/16"]
    // only match the beginning (useful if you are using short years):
    disabledDates: ["^03/08"]
    // disable every day in March 2006:
    disabledDates: ["03/../2006"]
    // disable every day in every March:
    disabledDates: ["^03"]
         * </code></pre>
         * 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 {@link #format date format} that has "." in
         * it, you will have to escape the dot when restricting dates. For example: <tt>["03\\.08\\.03"]</tt>.
         */
        /**
         * @cfg {String/Object} autoCreate
         * A {@link Ext.DomHelper DomHelper element specification object}, or <tt>true</tt> for the default element
         * specification object:<pre><code>
         * autoCreate: {tag: "input", type: "text", size: "10", autocomplete: "off"}
         * </code></pre>
         */
     
        // private
        defaultAutoCreate : {tag: "input", type: "text", size: "10", autocomplete: "off"},
     
        // in the absence of a time value, a default value of 12 noon will be used
        // (note: 12 noon was chosen because it steers well clear of all DST timezone changes)
        initTime: '12', // 24 hour format
     
        initTimeFormat: 'H',
     
        // PUBLIC -- to be documented
        safeParse : function(value, format) {
            if (Date.formatContainsHourInfo(format)) {
                // if parse format contains hour information, no DST adjustment is necessary
                return Date.parseDate(value, format);
            } else {
                // set time to 12 noon, then clear the time
                var parsedDate = Date.parseDate(value + ' ' + this.initTime, format + ' ' + this.initTimeFormat);
     
                if (parsedDate) {
                    return parsedDate.clearTime();
                }
            }
        },
     
        initComponent : function(){
            Ext.ux.DateHijriField.superclass.initComponent.call(this);
     
            this.addEvents(
                /**
                 * @event select
                 * Fires when a date is selected via the date picker.
                 * @param {Ext.ux.DateHijriField} this
                 * @param {Date} date The date that was selected
                 */
                'select'
            );
     
            if(Ext.isString(this.minValue)){
                this.minValue = this.parseDate(this.minValue);
            }
            if(Ext.isString(this.maxValue)){
                this.maxValue = this.parseDate(this.maxValue);
            }
            this.disabledDatesRE = null;
            this.initDisabledDays();
        },
     
        initEvents: function() {
            Ext.ux.DateHijriField.superclass.initEvents.call(this);
            this.keyNav = new Ext.KeyNav(this.el, {
                "down": function(e) {
                    this.onTriggerClick();
                },
                scope: this,
                forceKeyDown: true
            });
        },
     
     
        // private
        initDisabledDays : function(){
            if(this.disabledDates){
                var dd = this.disabledDates,
                    len = dd.length - 1,
                    re = "(?:";
     
                Ext.each(dd, function(d, i){
                    re += Ext.isDate(d) ? '^' + Ext.escapeRe(d.dateFormat(this.format)) + '$' : dd[i];
                    if(i != len){
                        re += '|';
                    }
                }, this);
                this.disabledDatesRE = new RegExp(re + ')');
            }
     
    		this.initdisabledDays = [];
     
    		if(this.disabledDays){
    			for(var i=0; i<this.disabledDays.length; i++){
    				this.initdisabledDays[i] = this.disabledDays[i];
    				this.disabledDays[i] = ((this.disabledDays[i] - this.startDay) + 7) % 7;
    			}
    		}
        },
     
        /**
         * Replaces any existing disabled dates with new values and refreshes the DatePicker.
         * @param {Array} disabledDates An array of date strings (see the <tt>{@link #disabledDates}</tt> config
         * for details on supported values) used to disable a pattern of dates.
         */
        setDisabledDates : function(dd){
            this.disabledDates = dd;
            this.initDisabledDays();
            if(this.menu){
                this.menu.picker.setDisabledDates(this.disabledDatesRE);
            }
        },
     
        /**
         * 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 <tt>{@link #disabledDays}</tt>
         * config for details on supported values.
         */
        setDisabledDays : function(dd){
            this.disabledDays = dd;
            if(this.menu){
                this.menu.picker.setDisabledDays(dd);
            }
        },
     
        /**
         * Replaces any existing <tt>{@link #minValue}</tt> with the new value and refreshes the DatePicker.
         * @param {Date} value The minimum date that can be selected
         */
        setMinValue : function(dt){
            this.minValue = (Ext.isString(dt) ? this.parseDate(dt) : dt);
            if(this.menu){
                this.menu.picker.setMinDate(this.minValue);
            }
        },
     
        /**
         * Replaces any existing <tt>{@link #maxValue}</tt> with the new value and refreshes the DatePicker.
         * @param {Date} value The maximum date that can be selected
         */
        setMaxValue : function(dt){
            this.maxValue = (Ext.isString(dt) ? this.parseDate(dt) : dt);
            if(this.menu){
                this.menu.picker.setMaxDate(this.maxValue);
            }
        },
     
        /**
         * Runs all of NumberFields validations and returns an array of any errors. Note that this first
         * runs TextField's validations, so the returned array is an amalgamation of all field errors.
         * The additional validation checks are testing that the date format is valid, that the chosen
         * date is within the min and max date constraints set, that the date chosen is not in the disabledDates
         * regex and that the day chosed is not one of the disabledDays.
         * @param {Mixed} value The value to get errors for (defaults to the current field value)
         * @return {Array} All validation errors for this field
         */
        getErrors: function(value) {
            var errors = Ext.ux.DateHijriField.superclass.getErrors.apply(this, arguments);
     
            value = this.formatDate(value || this.processValue(this.getRawValue()));
     
            if (value.length < 1) { // if it's blank and textfield didn't flag it then it's valid
                 return errors;
            }
     
            var svalue = value;
            value = this.parseDate(value);
            if (!value) {
                errors.push(String.format(this.invalidText, svalue, this.format));
                return errors;
            }
     
            var time = value.getTime();
            if (this.minValue && time < this.minValue.clearTime().getTime()) {
                errors.push(String.format(this.minText, this.formatDate(this.minValue)));
            }
     
            if (this.maxValue && time > this.maxValue.clearTime().getTime()) {
                errors.push(String.format(this.maxText, this.formatDate(this.maxValue)));
            }
     
            if (this.disabledDays) {
                var day = ((value.getDay() - this.startDay) + 7) % 7;
     
                for(var i = 0; i < this.initdisabledDays.length; i++) {
                    if (day === this.initdisabledDays[i]) {
                        errors.push(this.disabledDaysText);
                        break;
                    }
                }
            }
     
            var fvalue = this.formatDate(value);
            if (this.disabledDatesRE && this.disabledDatesRE.test(fvalue)) {
                errors.push(String.format(this.disabledDatesText, fvalue));
            }
     
            return errors;
        },
     
        // private
        // Provides logic to override the default TriggerField.validateBlur which just returns true
        validateBlur : function(){
            return !this.menu || !this.menu.isVisible();
        },
     
        /**
         * Returns the current date value of the date field.
         * @return {Date} The date value
         */
        getValue : function(){
            return this.parseDate(Ext.ux.DateHijriField.superclass.getValue.call(this)) || "";
        },
     
        /**
         * Sets the value of the date field.  You can pass a date object or any string that can be
         * parsed into a valid date, using <tt>{@link #format}</tt> as the date format, according
         * to the same rules as {@link Date#parseDate} (the default format used is <tt>"m/d/Y"</tt>).
         * <br />Usage:
         * <pre><code>
    //All of these calls set the same date value (May 4, 2006)
     
    //Pass a date object:
    var dt = new Date('5/4/2006');
    datehijrifield.setValue(dt);
     
    //Pass a date string (default format):
    datehijrifield.setValue('05/04/2006');
     
    //Pass a date string (custom format):l
    datehijrifield.format = 'Y-m-d';
    datehijrifield.setValue('2006-05-04');
    </code></pre>
         * @param {String/Date} date The date or valid date string
         * @return {Ext.form.Field} this
         */
        setValue : function(date){
            return Ext.ux.DateHijriField.superclass.setValue.call(this, date);
        },
     
        // private
        parseDate : function(value) {		
    		if(value){
    			var items = value.split("/");
    			if(items.length >= 3){
    				var myDate = new MyDate(items[0], items[1], items[2]);
    				return myDate;
    			}
    		}
     
            return null;
        },
     
        // private
        onDestroy : function(){
            Ext.destroy(this.menu, this.keyNav);
            Ext.ux.DateHijriField.superclass.onDestroy.call(this);
        },
     
        // private
        formatDate : function(date){
            return date; //Ext.isDate(date) ? date.dateFormat(this.format) : date;
        },
     
        /**
         * @method onTriggerClick
         * @hide
         */
        // private
        // Implements the default empty TriggerField.onTriggerClick function to display the DatePicker
        onTriggerClick : function(){
            if(this.disabled){
                return;
            }
     
    		var field = this;
     
            if(this.menu == null){
                this.menu = new Ext.ux.DateHijriMenu({
                    hideOnClick: false,
                    focusOnSelect: false
                });
            }
            this.onFocus();
            Ext.apply(this.menu.picker,  {
                minDate : this.minValue,
                maxDate : this.maxValue,
                disabledDatesRE : this.disabledDatesRE,
                disabledDatesText : this.disabledDatesText,
                disabledDays : this.disabledDays,
                disabledDaysText : this.disabledDaysText,
                format : this.format,
                showToday : this.showToday,
                startDay: this.startDay,
                minText : String.format(this.minText, this.formatDate(this.minValue)),
                maxText : String.format(this.maxText, this.formatDate(this.maxValue)),
    			field: this
            });
     
    		var date = this.getValue();
     
    		var dateHijri = null; 
    		if(date != ""){
    			dateHijri = date.getYear()+"/"+date.getMonth()+"/"+date.getDay();
    		}
     
    		registrationNewRequestService.getDateNowHijri({
    			callback:function(dateHijri){
    				var items = (dateHijri) ? dateHijri.split("/") : [1400, 1, 1];
    				var date = new MyDate(items[0], items[1], items[2]);
     
    				//alert(dateHijri + "::" + field.getValue())
     
    				field.menu.picker.setValue(field.getValue() || date);
    				field.menu.picker.today = date;
     
    				field.menu.show(field.el, "tl-bl?");
    				field.menuEvents('on');
    			}
    		});
        },
     
        //private
        menuEvents: function(method){
            this.menu[method]('select', this.onSelect, this);
            this.menu[method]('hide', this.onMenuHide, this);
            this.menu[method]('show', this.onFocus, this);
        },
     
        onSelect: function(m, d){
            this.setValue(d.dateFormat());
            this.fireEvent('select', this, d);
            this.menu.hide();
        },
     
        onMenuHide: function(){
            this.focus(false, 60);
            this.menuEvents('un');
        },
     
        // private
        beforeBlur : function(){
            var v = this.parseDate(this.getRawValue());
            if(v){
                this.setValue(v);
            }
        }
     
        /**
         * @cfg {Boolean} grow @hide
         */
        /**
         * @cfg {Number} growMin @hide
         */
        /**
         * @cfg {Number} growMax @hide
         */
        /**
         * @hide
         * @method autoSize
         */
    });
    //Ext.reg('datehijrifield', Ext.ux.DateHijriField);

    comme vous constatez j'ai commenter cette ligne :

    Ext.reg('datehijrifield', Ext.ux.DateHijriField);

    car j'ai trouvé une erreur :

    Ext.reg is not a function

    est ce que quelqu'un pourrez m'aider pour faire la migration

    merci d'avance

  2. #2
    Expert éminent
    Avatar de sekaijin
    Homme Profil pro
    Urbaniste
    Inscrit en
    Juillet 2004
    Messages
    4 205
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 60
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Urbaniste
    Secteur : Santé

    Informations forums :
    Inscription : Juillet 2004
    Messages : 4 205
    Points : 9 127
    Points
    9 127
    Par défaut
    dans la version 4 la façon de créer des classes et des composant à changé il te faut utiliser define
    dans la conf que tu passe tu a un attribut extends et un autre mixins
    qui te permets de faire de héritage simple ou multiple.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    // My/sample/Developer.js
    Ext.define('My.sample.Developer', {
        extend: 'My.sample.Person', // Will automatically load My.sample.Person
                                    // from file: My/sample/Person.js
                                    // if it has not been loaded before
     
        code: function(language) {
            alert(this.name + ' is coding in ' + language);
        }
    });
    http://docs.sencha.com/extjs/4.2.2/#...e/class_system

    A+JYT

  3. #3
    Membre régulier
    Homme Profil pro
    Inscrit en
    Juin 2012
    Messages
    180
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juin 2012
    Messages : 180
    Points : 73
    Points
    73
    Par défaut
    j'ai trouvé a solution pour ce problème en utilisant ce code !

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
      minText : Ext.String.format(this.minText, this.formatDate(this.minValue)),
                maxText : Ext.String.format(this.maxText, this.formatDate(this.maxValue)),
    j'ai essayé sans sucée pour la faire migration en extjs 4.2 avec :

    actuellement mon problème dans cette page js :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    833
    834
    835
    836
    837
    838
    839
    840
    841
    842
    843
    844
    845
    846
    847
    848
    849
    850
    851
    852
    853
    854
    855
    856
    857
    858
    859
    860
    861
    862
    863
    864
    865
    866
    867
    868
    869
    870
    871
    872
    873
    874
    875
    876
    877
    878
    879
    880
    881
    882
    883
    884
    885
    886
    887
    888
    889
    890
    891
    892
    893
    894
    895
    896
    897
    898
    899
    900
    901
    902
    903
    904
    905
    906
    907
    908
    909
    910
    911
    912
    913
    914
    915
    916
    917
    918
    919
    920
    921
    922
    923
    924
    925
    926
    927
    928
    929
    930
    931
    932
    933
    934
    935
    936
    937
    938
    939
    940
    941
    942
    943
    944
    945
    946
    947
    948
    949
    950
    951
    952
    953
    954
    955
    956
    957
    958
    959
    960
    961
    962
    963
    964
    965
    966
    967
    968
    969
    970
    971
    972
    973
    974
    975
    976
    977
    978
    979
    980
    981
    982
    983
    984
    985
    986
    987
    988
    989
    990
    991
    992
    993
    994
    995
    996
    997
    998
    999
    1000
    1001
    1002
    1003
    1004
    1005
    1006
    1007
    1008
    1009
    1010
    1011
    1012
    1013
    1014
    1015
    1016
    1017
    1018
    1019
    1020
    1021
    1022
    1023
    1024
    1025
    1026
    1027
    1028
    1029
    1030
    1031
    1032
    1033
    1034
    1035
    1036
    1037
    1038
    1039
    1040
    1041
    1042
    1043
    1044
    1045
    1046
    1047
    1048
    1049
    1050
    1051
    1052
    1053
    1054
    1055
    1056
    1057
    1058
    1059
    1060
    1061
    1062
    1063
    1064
    1065
    1066
    1067
    1068
    1069
    1070
    1071
    1072
    1073
    1074
    1075
    1076
    1077
    1078
    1079
    1080
    1081
    1082
    1083
    1084
    1085
    1086
    1087
    1088
    1089
    1090
    1091
    1092
    1093
    1094
    1095
    1096
    1097
    1098
    1099
    1100
    1101
    1102
    1103
    1104
    1105
    1106
    1107
    1108
    1109
    1110
    1111
    1112
    1113
    1114
    1115
    1116
    1117
    1118
    1119
    1120
    1121
    1122
    1123
    1124
    1125
    1126
    1127
    1128
    1129
    1130
    1131
    1132
    1133
    1134
    1135
    1136
    1137
    1138
    1139
    1140
    1141
    1142
    1143
    1144
    1145
    1146
    1147
    1148
    1149
    1150
    1151
    1152
    1153
    1154
    1155
    1156
    1157
    1158
    1159
    1160
    1161
    1162
    1163
    1164
    1165
    1166
    1167
    1168
    1169
    1170
    1171
    1172
    1173
    1174
    1175
    1176
    1177
    1178
    1179
    1180
    1181
    1182
    1183
    1184
    1185
    1186
    1187
    1188
    1189
    1190
    1191
    1192
    1193
    1194
    1195
    1196
    1197
    1198
    1199
    1200
    1201
    1202
    1203
    1204
    1205
    1206
    1207
    1208
    1209
    1210
    1211
    1212
    1213
    1214
    1215
    1216
    1217
    1218
    1219
    1220
    1221
    1222
    1223
    1224
    1225
    1226
    1227
    1228
    1229
     
    Ext.define('Ext.ux.DateHijriPicker', {
    	 extend: 'Ext.Component',
    	    requires: [
    	        'Ext.XTemplate',
    	        'Ext.button.Button',
    	        'Ext.button.Split',
    	        'Ext.util.ClickRepeater',
    	        'Ext.util.KeyNav',
    	        'Ext.EventObject',
    	        'Ext.fx.Manager',
    	        'Ext.picker.Month'
    	    ],
    	    alias: 'widget.datepicker',
    	    alternateClassName: 'Ext.DatePicker',
     
    	    childEls: [
    	        'innerEl', 'eventEl', 'prevEl', 'nextEl', 'middleBtnEl', 'footerEl'
    	    ],
     
    	    border: true,
     
    	    renderTpl: [
    	        '<div id="{id}-innerEl" role="grid">',
    	            '<div role="presentation" class="{baseCls}-header">',
    	                 // the href attribute is required for the :hover selector to work in IE6/7/quirks
    	                '<a id="{id}-prevEl" class="{baseCls}-prev {baseCls}-arrow" href="#" role="button" title="{prevText}" hidefocus="on" ></a>',
    	                '<div class="{baseCls}-month" id="{id}-middleBtnEl">{%this.renderMonthBtn(values, out)%}</div>',
    	                 // the href attribute is required for the :hover selector to work in IE6/7/quirks
    	                '<a id="{id}-nextEl" class="{baseCls}-next {baseCls}-arrow" href="#" role="button" title="{nextText}" hidefocus="on" ></a>',
    	            '</div>',
    	            '<table id="{id}-eventEl" class="{baseCls}-inner" cellspacing="0" role="grid">',
    	                '<thead role="presentation"><tr role="row">',
    	                    '<tpl for="dayNames">',
    	                        '<th role="columnheader" class="{parent.baseCls}-column-header" title="{.}">',
    	                            '<div class="{parent.baseCls}-column-header-inner">{.:this.firstInitial}</div>',
    	                        '</th>',
    	                    '</tpl>',
    	                '</tr></thead>',
    	                '<tbody role="presentation"><tr role="row">',
    	                    '<tpl for="days">',
    	                        '{#:this.isEndOfWeek}',
    	                        '<td role="gridcell" id="{[Ext.id()]}">',
    	                            // the href attribute is required for the :hover selector to work in IE6/7/quirks
    	                            '<a role="button" hidefocus="on" class="{parent.baseCls}-date" href="#"></a>',
    	                        '</td>',
    	                    '</tpl>',
    	                '</tr></tbody>',
    	            '</table>',
    	            '<tpl if="showToday">',
    	                '<div id="{id}-footerEl" role="presentation" class="{baseCls}-footer">{%this.renderTodayBtn(values, out)%}</div>',
    	            '</tpl>',
    	        '</div>',
    	        {
    	            firstInitial: function(value) {
    	                return Ext.picker.Date.prototype.getDayInitial(value);
    	            },
    	            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">' : '';
    	            },
    	            renderTodayBtn: function(values, out) {
    	                Ext.DomHelper.generateMarkup(values.$comp.todayBtn.getRenderTree(), out);
    	            },
    	            renderMonthBtn: function(values, out) {
    	                Ext.DomHelper.generateMarkup(values.$comp.monthBtn.getRenderTree(), out);
    	            }
    	        }
    	    ],
     
    	    //<locale>
    	    /**
    	     * @cfg {String} todayText
    	     * The text to display on the button that selects the current date
    	     */
    	    todayText : 'Today',
    	    //</locale>
     
    	    //<locale>
    	    /**
    	     * @cfg {String} ariaTitle
    	     * The text to display for the aria title
    	     */
    	    ariaTitle: 'Date Picker: {0}',
    	    //</locale>
     
    	    //<locale>
    	    /**
    	     * @cfg {String} ariaTitleDateFormat
    	     * The date format to display for the current value in the {@link #ariaTitle}
    	     */
    	    ariaTitleDateFormat: 'F d, Y',
    	    //</locale>
     
    	    /**
    	     * @cfg {Function} handler
    	     * Optional. A function that will handle the select event of this picker. The handler is passed the following
    	     * parameters:
    	     *
    	     *   - `picker` : Ext.picker.Date
    	     *
    	     * This Date picker.
    	     *
    	     *   - `date` : Date
    	     *
    	     * The selected date.
    	     */
     
    	    /**
    	     * @cfg {Object} scope
    	     * The scope (`this` reference) in which the `{@link #handler}` function will be called.
    	     *
    	     * Defaults to this DatePicker instance.
    	     */
     
    	    //<locale>
    	    /**
    	     * @cfg {String} todayTip
    	     * A string used to format the message for displaying in a tooltip over the button that selects the current date.
    	     * The `{0}` token in string is replaced by today's date.
    	     */
    	    todayTip : '{0} (Spacebar)',
    	    //</locale>
     
    	    //<locale>
    	    /**
    	     * @cfg {String} minText
    	     * The error text to display if the minDate validation fails.
    	     */
    	    minText : 'This date is before the minimum date',
    	    //</locale>
     
    	    //<locale>
    	    /**
    	     * @cfg {String} maxText
    	     * The error text to display if the maxDate validation fails.
    	     */
    	    maxText : 'This date is after the maximum date',
    	    //</locale>
     
    	    /**
    	     * @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}).
    	     */
     
    	    //<locale>
    	    /**
    	     * @cfg {String} disabledDaysText
    	     * The tooltip to display when the date falls on a disabled day.
    	     */
    	    disabledDaysText : 'Disabled',
    	    //</locale>
     
    	    //<locale>
    	    /**
    	     * @cfg {String} disabledDatesText
    	     * The tooltip text to display when the date falls on a disabled date.
    	     */
    	    disabledDatesText : 'Disabled',
    	    //</locale>
     
    	    /**
    	     * @cfg {String[]} monthNames
    	     * An array of textual month names which can be overriden for localization support (defaults to Ext.Date.monthNames)
    	     * @deprecated This config is deprecated. In future the month names will be retrieved from {@link Ext.Date}
    	     */
     
    	    /**
    	     * @cfg {String[]} dayNames
    	     * An array of textual day names which can be overriden for localization support (defaults to Ext.Date.dayNames)
    	     * @deprecated This config is deprecated. In future the day names will be retrieved from {@link Ext.Date}
    	     */
     
    	    //<locale>
    	    /**
    	     * @cfg {String} nextText
    	     * The next month navigation button tooltip
    	     */
    	    nextText : 'Next Month (Control+Right)',
    	    //</locale>
     
    	    //<locale>
    	    /**
    	     * @cfg {String} prevText
    	     * The previous month navigation button tooltip
    	     */
    	    prevText : 'Previous Month (Control+Left)',
    	    //</locale>
     
    	    //<locale>
    	    /**
    	     * @cfg {String} monthYearText
    	     * The header month selector tooltip
    	     */
    	    monthYearText : 'Choose a month (Control+Up/Down to move years)',
    	    //</locale>
     
    	    //<locale>
    	    /**
    	     * @cfg {String} monthYearFormat
    	     * The date format for the header month
    	     */
    	    monthYearFormat: 'F Y',
    	    //</locale>
     
    	    //<locale>
    	    /**
    	     * @cfg {Number} [startDay=undefined]
    	     * Day index at which the week should begin, 0-based.
    	     *
    	     * Defaults to `0` (Sunday).
    	     */
    	    startDay : 0,
    	    //</locale>
     
    	    //<locale>
    	    /**
    	     * @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.
    	     */
    	    showToday : true,
    	    //</locale>
     
    	    /**
    	     * @cfg {Date} [minDate=null]
    	     * Minimum allowable date (JavaScript date object)
    	     */
     
    	    /**
    	     * @cfg {Date} [maxDate=null]
    	     * Maximum allowable date (JavaScript date object)
    	     */
     
    	    /**
    	     * @cfg {Number[]} [disabledDays=null]
    	     * An array of days to disable, 0-based. For example, [0, 6] disables Sunday and Saturday.
    	     */
     
    	    /**
    	     * @cfg {RegExp} [disabledDatesRE=null]
    	     * JavaScript regular expression used to disable a pattern of dates. The {@link #disabledDates}
    	     * config will generate this regex internally, but if you specify disabledDatesRE it will take precedence over the
    	     * disabledDates value.
    	     */
     
    	    /**
    	     * @cfg {String[]} 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:
    	     *
    	     *   - ['03/08/2003', '09/16/2003'] would disable those exact dates
    	     *   - ['03/08', '09/16'] would disable those days for every year
    	     *   - ['^03/08'] would only match the beginning (useful if you are using short years)
    	     *   - ['03/../2006'] would disable every day in March 2006
    	     *   - ['^03'] would disable every day in every March
    	     *
    	     * 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.
    	     */
    	    disableAnim: false,
     
    	    /**
    	     * @cfg {String} [baseCls='x-datepicker']
    	     * The base CSS class to apply to this components element.
    	     */
    	    baseCls: Ext.baseCSSPrefix + 'datepicker',
     
    	    /**
    	     * @cfg {String} [selectedCls='x-datepicker-selected']
    	     * The class to apply to the selected cell.
    	     */
     
    	    /**
    	     * @cfg {String} [disabledCellCls='x-datepicker-disabled']
    	     * The class to apply to disabled cells.
    	     */
     
    	    //<locale>
    	    /**
    	     * @cfg {String} longDayFormat
    	     * The format for displaying a date in a longer format.
    	     */
    	    longDayFormat: 'F d, Y',
    	    //</locale>
     
    	    /**
    	     * @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.
    	     */
    	    focusOnShow: false,
     
    	    // @private
    	    // Set by other components to stop the picker focus being updated when the value changes.
    	    focusOnSelect: true,
     
    	    // 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.cellCls = me.baseCls + '-cell';
    	        me.nextCls = me.baseCls + '-prevday';
    	        me.todayCls = me.baseCls + '-today';
     
     
    	        if (!me.format) {
    	            me.format = Ext.Date.defaultFormat;
    	        }
    	        if (!me.dayNames) {
    	            me.dayNames = Ext.Date.dayNames;
    	        }
    	        me.dayNames = me.dayNames.slice(me.startDay).concat(me.dayNames.slice(0, me.startDay));
     
    	        me.callParent();
     
    	        me.value = me.value ?
    	                 clearTime(me.value, true) : clearTime(new Date());
     
    	        me.addEvents(
    	            /**
    	             * @event select
    	             * Fires when a date is selected
    	             * @param {Ext.picker.Date} this DatePicker
    	             * @param {Date} date The selected date
    	             */
    	            'select'
    	        );
     
    	        me.initDisabledDays();
    	    },
     
    	    beforeRender: function () {
    	        /*
    	         * 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);
     
    	        // If there's a Menu among our ancestors, then add the menu class.
    	        // This is so that the MenuManager does not see a mousedown in this Component as a document mousedown, outside the Menu
    	        if (me.up('menu')) {
    	            me.addCls(Ext.baseCSSPrefix + 'menu');
    	        }
     
    	        if (me.padding && !me.width) {
    	            me.cacheWidth();
    	        }
     
    	        me.monthBtn = new Ext.button.Split({
    	            ownerCt: me,
    	            ownerLayout: me.getComponentLayout(),
    	            text: '',
    	            tooltip: me.monthYearText,
    	            listeners: {
    	                click: me.doShowMonthPicker,
    	                arrowclick: me.doShowMonthPicker,
    	                scope: me
    	            }
    	        });
     
    	        if (me.showToday) {
    	            me.todayBtn = new Ext.button.Button({
    	                ownerCt: me,
    	                ownerLayout: me.getComponentLayout(),
    	                text: Ext.String.format(me.todayText, today),
    	                tooltip: Ext.String.format(me.todayTip, today),
    	                tooltipType: 'title',
    	                handler: me.selectToday,
    	                scope: me
    	            });
    	        }
     
    	        me.callParent();
     
    	        Ext.applyIf(me, {
    	            renderData: {}
    	        });
     
    	        Ext.apply(me.renderData, {
    	            dayNames: me.dayNames,
    	            showToday: me.showToday,
    	            prevText: me.prevText,
    	            nextText: me.nextText,
    	            days: days
    	        });
     
    	        me.protoEl.unselectable();
    	    },
     
    	    cacheWidth: function() {
    	        var me = this,
    	            padding = me.parseBox(me.padding),
    	            widthEl = Ext.getBody().createChild({
    	                cls: me.baseCls + ' ' + me.borderBoxCls,
    	                style: 'position:absolute;top:-1000px;left:-1000px;'
    	            });
     
    	        me.self.prototype.width = widthEl.getWidth() + padding.left + padding.right;
    	        widthEl.remove();
    	    },
     
    	    // Do the job of a container layout at this point even though we are not a Container.
    	    // TODO: Refactor as a Container.
    	    finishRenderChildren: function () {
    	        var me = this;
     
    	        me.callParent();
    	        me.monthBtn.finishRender();
    	        if (me.showToday) {
    	            me.todayBtn.finishRender();
    	        }
    	    },
     
    	    // @private
    	    // @inheritdoc
    	    onRender : function(container, position){
    	        var me = this;
     
    	        me.callParent(arguments);
     
    	        me.cells = me.eventEl.select('tbody td');
    	        me.textNodes = me.eventEl.query('tbody td a');
     
    	        me.mon(me.eventEl, {
    	            scope: me,
    	            mousewheel: me.handleMouseWheel,
    	            click: {
    	                fn: me.handleDateClick,
    	                delegate: 'a.' + me.baseCls + '-date'
    	            }
    	        });
     
    	    },
     
    	    // @private
    	    // @inheritdoc
    	    initEvents: function(){
    	        var me = this,
    	            eDate = Ext.Date,
    	            day = eDate.DAY;
     
    	        me.callParent();
     
    	        me.prevRepeater = new Ext.util.ClickRepeater(me.prevEl, {
    	            handler: me.showPrevMonth,
    	            scope: me,
    	            preventDefault: true,
    	            stopDefault: true
    	        });
     
    	        me.nextRepeater = new Ext.util.ClickRepeater(me.nextEl, {
    	            handler: me.showNextMonth,
    	            scope: me,
    	            preventDefault:true,
    	            stopDefault:true
    	        });
     
    	        me.keyNav = new Ext.util.KeyNav(me.eventEl, Ext.apply({
    	            scope: me,
    	            left : function(e){
    	                if(e.ctrlKey){
    	                    me.showPrevMonth();
    	                }else{
    	                    me.update(eDate.add(me.activeDate, day, -1));
    	                }
    	            },
     
    	            right : function(e){
    	                if(e.ctrlKey){
    	                    me.showNextMonth();
    	                }else{
    	                    me.update(eDate.add(me.activeDate, day, 1));
    	                }
    	            },
     
    	            up : function(e){
    	                if(e.ctrlKey){
    	                    me.showNextYear();
    	                }else{
    	                    me.update(eDate.add(me.activeDate, day, -7));
    	                }
    	            },
     
    	            down : function(e){
    	                if(e.ctrlKey){
    	                    me.showPrevYear();
    	                }else{
    	                    me.update(eDate.add(me.activeDate, day, 7));
    	                }
    	            },
     
    	            pageUp:function (e) {
    	                if (e.altKey) {
    	                    me.showPrevYear();
    	                } else {
    	                    me.showPrevMonth();
    	                }
    	            },
     
    	            pageDown:function (e) {
    	                if (e.altKey) {
    	                    me.showNextYear();
    	                } else {
    	                    me.showNextMonth();
    	                }
    	            },
     
    	            tab:function (e) {
    	                me.doCancelFieldFocus = true;
    	                me.handleTabClick(e);
    	                delete me.doCancelFieldFocus;
    	                return true;
    	            },
     
    	            enter : function(e){
    	                e.stopPropagation();
    	                return true;
    	            },
     
    	            //space: ???
     
    	            home:function (e) {
    	                me.update(eDate.getFirstDateOfMonth(me.activeDate));
    	            },
     
    	            end:function (e) {
    	                me.update(eDate.getLastDateOfMonth(me.activeDate));
    	            }
    	        }, me.keyNavConfig));
     
    	        if (me.showToday) {
    	            me.todayKeyListener = me.eventEl.addKeyListener(Ext.EventObject.SPACE, me.selectToday,  me);
    	        }
    	        me.update(me.value);
    	    },
     
    	    handleTabClick:function (e) {
    	        var me = this,
    	            t = me.getSelectedDate(me.activeDate),
    	            handler = me.handler;
     
    	        // The following code is like handleDateClick without the e.stopEvent()
    	        if (!me.disabled && t.dateValue && !Ext.fly(t.parentNode).hasCls(me.disabledCellCls)) {
    	            me.doCancelFocus = me.focusOnSelect === false;
    	            me.setValue(new Date(t.dateValue));
    	            delete me.doCancelFocus;
    	            me.fireEvent('select', me, me.value);
    	            if (handler) {
    	                handler.call(me.scope || me, me, me.value);
    	            }
    	            me.onSelect();
    	        }
    	    },
     
    	    getSelectedDate:function (date) {
    	        var me = this,
    	            t = date.getTime(),
    	            cells = me.cells,
    	            cls = me.selectedCls,
    	            cellItems = cells.elements,
    	            c,
    	            cLen = cellItems.length,
    	            cell;
     
    	        cells.removeCls(cls);
     
    	        for (c = 0; c < cLen; c++) {
    	            cell = Ext.fly(cellItems[c]);
     
    	            if (cell.dom.firstChild.dateValue == t) {
    	                return cell.dom.firstChild;
    	            }
    	        }
    	        return null;
    	    },
     
    	    /**
    	     * Setup the disabled dates regex based on config options
    	     * @private
    	     */
    	    initDisabledDays : function(){
    	        var me = this,
    	            dd = me.disabledDates,
    	            re = '(?:',
    	            len,
    	            d, dLen, dI;
     
    	        if(!me.disabledDatesRE && dd){
    	                len = dd.length - 1;
     
    	            dLen = dd.length;
     
    	            for (d = 0; d < dLen; d++) {
    	                dI = dd[d];
     
    	                re += Ext.isDate(dI) ? '^' + Ext.String.escapeRegex(Ext.Date.dateFormat(dI, me.format)) + '$' : dI;
    	                if (d != len) {
    	                    re += '|';
    	                }
    	            }
     
    	            me.disabledDatesRE = new RegExp(re + ')');
    	        }
    	    },
     
    	    /**
    	     * Replaces any existing disabled dates with new values and refreshes the DatePicker.
    	     * @param {String[]/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 {Number[]} 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;
    	    },
     
    	    //<locale type="function">
    	    /**
    	     * Gets a single character to represent the day of the week
    	     * @return {String} The character
    	     */
    	    getDayInitial: function(value){
    	        return value.substr(0,1);
    	    },
    	    //</locale>
     
    	    // @private
    	    focus : function(){
    	        this.update(this.activeDate);
    	    },
     
    	    // @private
    	    // @inheritdoc
    	    onEnable: function(){
    	        this.callParent();
    	        this.setDisabledStatus(false);
    	        this.update(this.activeDate);
     
    	    },
     
    	    // @private
    	    // @inheritdoc
    	    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 picker = this.monthPicker,
    	            options = {
    	                duration: 200,
    	                callback: function(){
    	                    if (isHide) {
    	                        picker.hide();
    	                    } else {
    	                        picker.show();
    	                    }
    	                }
    	            };
     
    	        if (isHide) {
    	            picker.el.slideOut('t', options);
    	        } else {
    	            picker.el.slideIn('t', options);
    	        }
    	    },
     
    	    /**
    	     * Hides the month picker, if it's visible.
    	     * @param {Boolean} [animate] Indicates whether to animate this action. If the animate
    	     * parameter is not specified, the behavior will use {@link #disableAnim} to determine
    	     * whether to animate or not.
    	     * @return {Ext.picker.Date} this
    	     */
    	    hideMonthPicker : function(animate){
    	        var me = this,
    	            picker = me.monthPicker;
     
    	        if (picker) {
    	            if (me.shouldAnimate(animate)) {
    	                me.runAnimation(true);
    	            } else {
    	                picker.hide();
    	            }
    	        }
    	        return me;
    	    },
     
    	    doShowMonthPicker: function(){
    	        // Wrap in an extra call so we can prevent the button
    	        // being passed as an animation parameter.
    	        this.showMonthPicker();
    	    },
     
    	    /**
    	     * Show the month picker
    	     * @param {Boolean} [animate] Indicates whether to animate this action. If the animate
    	     * parameter is not specified, the behavior will use {@link #disableAnim} to determine
    	     * whether to animate or not.
    	     * @return {Ext.picker.Date} this
    	     */
    	    showMonthPicker : function(animate){
    	        var me = this,
    	            el = me.el,
    	            picker;
     
    	        if (me.rendered && !me.disabled) {
    	            picker = me.createMonthPicker();
    	            picker.setValue(me.getActive());
    	            picker.setSize(el.getSize());
    	            picker.setPosition(-el.getBorderWidth('l'), -el.getBorderWidth('t'));
    	            if (me.shouldAnimate(animate)) {
    	                me.runAnimation(false);
    	            } else {
    	                picker.show();
    	            }
    	        }
    	        return me;
    	    },
     
    	    /**
    	     * Checks whether a hide/show action should animate
    	     * @private
    	     * @param {Boolean} [animate] A possible animation value
    	     * @return {Boolean} Whether to animate the action
    	     */
    	    shouldAnimate: function(animate){
    	        return Ext.isDefined(animate) ? animate : !this.disableAnim;
    	    },
     
    	    /**
    	     * Create the month picker instance
    	     * @private
    	     * @return {Ext.picker.Month} picker
    	     */
    	    createMonthPicker: function(){
    	        var me = this,
    	            picker = me.monthPicker;
     
    	        if (!picker) {
    	            me.monthPicker = picker = new Ext.picker.Month({
    	                renderTo: me.el,
    	                floating: true,
    	                padding: me.padding,
    	                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', Ext.Function.bind(me.hideMonthPicker, me, [false]));
    	        }
    	        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 = Ext.Date.getLastDateOfMonth(new Date(year, month, 1));
    	        }
    	        me.setValue(date);
    	        me.hideMonthPicker();
    	    },
     
    	    /**
    	     * Respond to a cancel click on the month picker
    	     * @private
    	     */
    	    onCancelClick: function(){
    	        // update the selected value, also triggers a focus
    	        this.selectedUpdate(this.activeDate);
    	        this.hideMonthPicker();
    	    },
     
    	    /**
    	     * Show the previous month.
    	     * @param {Object} e
    	     * @return {Ext.picker.Date} this
    	     */
    	    showPrevMonth : function(e){
    	        return this.setValue(Ext.Date.add(this.activeDate, Ext.Date.MONTH, -1));
    	    },
     
    	    /**
    	     * Show the next month.
    	     * @param {Object} e
    	     * @return {Ext.picker.Date} this
    	     */
    	    showNextMonth : function(e){
    	        return this.setValue(Ext.Date.add(this.activeDate, Ext.Date.MONTH, 1));
    	    },
     
    	    /**
    	     * Show the previous year.
    	     * @return {Ext.picker.Date} this
    	     */
    	    showPrevYear : function(){
    	        return this.setValue(Ext.Date.add(this.activeDate, Ext.Date.YEAR, -1));
    	    },
     
    	    /**
    	     * Show the next year.
    	     * @return {Ext.picker.Date} this
    	     */
    	    showNextYear : function(){
    	        return this.setValue(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.doCancelFocus = me.focusOnSelect === false;
    	            me.setValue(new Date(t.dateValue));
    	            delete me.doCancelFocus;
    	            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
    	     */
    	    selectedUpdate: function(date){
    	        var me        = this,
    	            t         = date.getTime(),
    	            cells     = me.cells,
    	            cls       = me.selectedCls,
    	            cellItems = cells.elements,
    	            c,
    	            cLen      = cellItems.length,
    	            cell;
     
    	        cells.removeCls(cls);
     
    	        for (c = 0; c < cLen; c++) {
    	            cell = Ext.fly(cellItems[c]);
     
    	            if (cell.dom.firstChild.dateValue == t) {
    	                me.fireEvent('highlightitem', me, cell);
    	                cell.addCls(cls);
     
    	                if(me.isVisible() && !me.doCancelFocus){
    	                    Ext.fly(cell.dom.firstChild).focus(50);
    	                }
     
    	                break;
    	            }
    	        }
    	    },
     
    	    /**
    	     * Update the contents of the picker for a new month
    	     * @private
    	     * @param {Date} date The new date
    	     */
    	    fullUpdate: function(date){
    	        var me = this,
    	            cells = me.cells.elements,
    	            textNodes = me.textNodes,
    	            disabledCls = me.disabledCellCls,
    	            eDate = Ext.Date,
    	            i = 0,
    	            extraDays = 0,
    	            visible = me.isVisible(),
    	            newDate = +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, cls){
    	            value = +eDate.clearTime(current, true);
    	            cell.title = eDate.format(current, longDayFormat);
    	            // store dateValue number as an expando
    	            cell.firstChild.dateValue = value;
    	            if(value == today){
    	                cls += ' ' + me.todayCls;
    	                cell.title = me.todayText;
     
    	                // Extra element for ARIA purposes
    	                me.todayElSpan = Ext.DomHelper.append(cell.firstChild, {
    	                    tag:'span',
    	                    cls: Ext.baseCSSPrefix + 'hide-clip',
    	                    html:me.todayText
    	                }, true);
    	            }
    	            if(value == newDate) {
    	                cls += ' ' + me.selectedCls;
    	                me.fireEvent('highlightitem', me, cell);
    	                if (visible && me.floating) {
    	                    Ext.fly(cell.firstChild).focus(50);
    	                }
    	            }
     
    	            if (value < min) {
    	                cls += ' ' + disabledCls;
    	                cell.title = me.minText;
    	            }
    	            else if (value > max) {
    	                cls += ' ' + disabledCls;
    	                cell.title = me.maxText;
    	            }
    	            else if (ddays && ddays.indexOf(current.getDay()) !== -1){
    	                cell.title = ddaysText;
    	                cls += ' ' + disabledCls;
    	            }
    	            else if (ddMatch && format){
    	                formatValue = eDate.dateFormat(current, format);
    	                if(ddMatch.test(formatValue)){
    	                    cell.title = ddText.replace('%0', formatValue);
    	                    cls += ' ' + disabledCls;
    	                }
    	            }
    	            cell.className = cls + ' ' + me.cellCls;
    	        };
     
    	        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;
    	            current.setDate(current.getDate() + 1);
    	            setCellClass(cells[i], cls);
    	        }
     
    	        me.monthBtn.setText(Ext.Date.format(date, me.monthYearFormat));
    	    },
     
    	    /**
    	     * 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
    	    // @inheritdoc
    	    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;
    	        }
    	        me.callParent();
    	    },
     
    	    // @private
    	    // @inheritdoc
    	    onShow: function() {
    	        this.callParent(arguments);
    	        if (this.focusOnShow) {
    	            this.focus();
    	        }
    	    }
        /**
         * @cfg {String} autoEl @hide
         */
    });
    j'ai essayé de changer suite à cette remarque :

    extJS 4 generates the date picker not in table construct but in divs. , the error is hiding somewhere in the Ext.ux.DateTimePicker onRender method.

    est ce que quelqu'un pouvez m'aider à corriger ce code

    merci d'avance

  4. #4
    Membre régulier
    Homme Profil pro
    Inscrit en
    Juin 2012
    Messages
    180
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juin 2012
    Messages : 180
    Points : 73
    Points
    73
    Par défaut
    A noter que
    l'ancien code avec extjs 3.4 est le suivant :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    833
    834
    835
    836
    837
    838
    839
    840
    841
    842
    843
    844
    845
    846
    847
    848
    849
    850
    851
    852
    853
    854
    855
    856
    857
    858
    859
    860
    861
    862
    863
    864
    865
    866
    867
    868
    869
    870
    871
    872
    873
    874
    875
    /*!
     * Ext JS Library 3.4.0
     * Copyright(c) 2006-2011 Sencha Inc.
     * licensing@sencha.com
     * http://www.sencha.com/license
     */
    /**
     * @class Ext.ux.DateHijriPicker
     * @extends Ext.Component
     * <p>A popup date picker. This class is used by the {@link Ext.form.DateField DateField} class
     * to allow browsing and selection of valid dates.</p>
     * <p>All the string values documented below may be overridden by including an Ext locale file in
     * your page.</p>
     * @constructor
     * Create a new DateHijriPicker
     * @param {Object} config The config object
     * @xtype datehijripicker
     */
    Ext.ux.DateHijriPicker = Ext.extend(Ext.BoxComponent, {
        /**
         * @cfg {String} todayText
         * The text to display on the button that selects the current date (defaults to <code>'Today'</code>)
         */
        todayText : 'Today',
        /**
         * @cfg {String} okText
         * The text to display on the ok button (defaults to <code>' OK '</code> to give the user extra clicking room)
         */
        okText : ' OK ',
        /**
         * @cfg {String} cancelText
         * The text to display on the cancel button (defaults to <code>'Cancel'</code>)
         */
        cancelText : 'Cancel',
        /**
         * @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> : DateHijriPicker<div class="sub-desc">This DateHijriPicker.</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 DateHijriPicker 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 Date#parseDate} (defaults to <code>'m/d/y'</code>).
         */
        format : 'm/d/y',
        /**
         * @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 Date.monthNames)
         */
        monthNames : month_AR/*Date.monthNames*/,
        /**
         * @cfg {Array} dayNames
         * An array of textual day names which can be overriden for localization support (defaults to Date.dayNames)
         */
        dayNames : day_AR/*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'].
         */
     
        // private
        // Set by other components to stop the picker focus being updated when the value changes.
        focusOnSelect: true,
     
        // default value used to initialise each date in the DateHijriPicker
        // (note: 12 noon was chosen because it steers well clear of all DST timezone changes)
        initHour: 12, // 24-hour format
     
        // private
        initComponent : function(){
            Ext.ux.DateHijriPicker.superclass.initComponent.call(this);
     
            this.value = this.value ?
                     this.value.clearTime(true) : new MyDate().clearTime();
     
            this.addEvents(
                /**
                 * @event select
                 * Fires when a date is selected
                 * @param {DateHijriPicker} this DateHijriPicker
                 * @param {Date} date The selected date
                 */
                'select'
            );
     
            if(this.handler){
                this.on('select', this.handler,  this.scope || this);
            }
     
            this.initDisabledDays();
        },
     
        // private
        initDisabledDays : function(){
            /*if(!this.disabledDatesRE && this.disabledDates){
                var dd = this.disabledDates,
                    len = dd.length - 1,
                    re = '(?:';
     
                Ext.each(dd, function(d, i){
                    re += Ext.isDate(d) ? '^' + Ext.escapeRe(d.dateFormat(this.format)) + '$' : dd[i];
                    if(i != len){
                        re += '|';
                    }
                }, this);
                this.disabledDatesRE = new RegExp(re + ')');
            }*/
        },
     
        /**
         * Replaces any existing disabled dates with new values and refreshes the DateHijriPicker.
         * @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.
         */
        setDisabledDates : function(dd){
            /*if(Ext.isArray(dd)){
                this.disabledDates = dd;
                this.disabledDatesRE = null;
            }else{
                this.disabledDatesRE = dd;
            }
            this.initDisabledDays();
            this.update(this.value, true);*/
        },
     
        /**
         * Replaces any existing disabled days (by index, 0-6) with new values and refreshes the DateHijriPicker.
         * @param {Array} disabledDays An array of disabled day indexes. See the {@link #disabledDays} config
         * for details on supported values.
         */
        setDisabledDays : function(dd){
            /*this.disabledDays = dd;
            this.update(this.value, true);*/
        },
     
        /**
         * Replaces any existing {@link #minDate} with the new value and refreshes the DateHijriPicker.
         * @param {Date} value The minimum date that can be selected
         */
        setMinDate : function(dt){
            /*this.minDate = dt;
            this.update(this.value, true);*/
        },
     
        /**
         * Replaces any existing {@link #maxDate} with the new value and refreshes the DateHijriPicker.
         * @param {Date} value The maximum date that can be selected
         */
        setMaxDate : function(dt){
            /*this.maxDate = dt;
            this.update(this.value, true);*/
        },
     
        /**
         * Sets the value of the date field
         * @param {Date} value The date to set
         */
        setValue : function(value){
            this.value = value.clearTime(true);
            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
        onEnable: function(initial){
            /*Ext.ux.DateHijriPicker.superclass.onEnable.call(this);
            this.doDisabled(false);
            this.update(initial ? this.value : this.activeDate);
            if(Ext.isIE){
                this.el.repaint();
            }*/
        },
     
        // private
        onDisable : function(){
            Ext.ux.DateHijriPicker.superclass.onDisable.call(this);
            this.doDisabled(true);
            if(Ext.isIE && !Ext.isIE8){
                /* Really strange problem in IE6/7, when disabled, have to explicitly
                 * repaint each of the nodes to get them to display correctly, simply
                 * calling repaint on the main element doesn't appear to be enough.
                 */
                 Ext.each([].concat(this.textNodes, this.el.query('th span')), function(el){
                     Ext.fly(el).repaint();
                 });
            }
        },
     
        // private
        doDisabled : function(disabled){
            this.keyNav.setDisabled(disabled);
            this.prevRepeater.setDisabled(disabled);
            this.nextRepeater.setDisabled(disabled);
            if(this.showToday){
                this.todayKeyListener.setDisabled(disabled);
                this.todayBtn.setDisabled(disabled);
            }
        },
     
        // private
        onRender : function(container, position){	
            var m = [
                 '<table cellspacing="0">',
                    '<tr><td class="x-date-left"><a href="#" title="', this.prevText ,'"> </a></td><td class="x-date-middle" align="center"></td><td class="x-date-right"><a href="#" title="', this.nextText ,'"> </a></td></tr>',
                    '<tr><td colspan="3"><table class="x-date-inner" cellspacing="0"><thead><tr>'],
                    dn = this.dayNames,
                    i;
     
            for(i = 0; i < 7; i++){
                var d = this.startDay+i;
                if(d > 6){
                    d = d-7;
                }
                m.push('<th><span>', shortday_AR[d]/*dn[d].substr(0,1)*/, '</span></th>');
            }
     
            m[m.length] = '</tr></thead><tbody><tr>';
            for(i = 0; i < 42; i++) {
                if(i % 7 === 0 && i !== 0){
                    m[m.length] = '</tr><tr>';
                }
                m[m.length] = '<td><a href="#" hidefocus="on" class="x-date-date" tabIndex="1"><em><span></span></em></a></td>';
            }
     
            m.push('</tr></tbody></table></td></tr>',
                    this.showToday ? '<tr><td colspan="3" class="x-date-bottom" align="center"></td></tr>' : '',
                    '</table><div class="x-date-mp"></div>');
     
            var el = document.createElement('div');
            el.className = 'x-date-picker';
            el.innerHTML = m.join('');
     
            container.dom.insertBefore(el, position);
     
            this.el = Ext.get(el);
            this.eventEl = Ext.get(el.firstChild);
     
            this.prevRepeater = new Ext.util.ClickRepeater(this.el.child('td.x-date-left a'), {
                handler: this.showPrevMonth,
                scope: this,
                preventDefault:true,
                stopDefault:true
            });
     
            this.nextRepeater = new Ext.util.ClickRepeater(this.el.child('td.x-date-right a'), {
                handler: this.showNextMonth,
                scope: this,
                preventDefault:true,
                stopDefault:true
            });
     
            this.monthPicker = this.el.down('div.x-date-mp');
            this.monthPicker.enableDisplayMode('block');
     
    		var field = this;
     
            this.keyNav = new Ext.KeyNav(this.eventEl, {
                'left' : function(e){
                    if(e.ctrlKey){
                        this.showPrevMonth();
                    }else{
                        this.update(this.activeDate.add('d', -1, field.monthdays, field.bmonthdays));
                    }
                },
     
                'right' : function(e){
                    if(e.ctrlKey){
                        this.showNextMonth();
                    }else{
                        this.update(this.activeDate.add('d', 1, field.monthdays, field.bmonthdays));
                    }
                },
     
                'up' : function(e){
                    if(e.ctrlKey){
                        this.showNextYear();
                    }else{
                        this.update(this.activeDate.add('d', -7, field.monthdays, field.bmonthdays));
                    }
                },
     
                'down' : function(e){
                    if(e.ctrlKey){
                        this.showPrevYear();
                    }else{
                        this.update(this.activeDate.add('d', 7, field.monthdays, field.bmonthdays));
                    }
                },
     
                'pageUp' : function(e){
                    this.showNextMonth();
                },
     
                'pageDown' : function(e){
                    this.showPrevMonth();
                },
     
                'enter' : function(e){
                    e.stopPropagation();
                    return true;
                },
     
                scope : this
            });
     
            this.el.unselectable();
     
            this.cells = this.el.select('table.x-date-inner tbody td');
            this.textNodes = this.el.query('table.x-date-inner tbody span');
     
            this.mbtn = new Ext.Button({
                text: ' ',
                tooltip: this.monthYearText,
                renderTo: this.el.child('td.x-date-middle', true)
            });
            this.mbtn.el.child('em').addClass('x-btn-arrow');
     
            if(this.showToday){
                this.todayKeyListener = this.eventEl.addKeyListener(Ext.EventObject.SPACE, this.selectToday,  this);
                var today = this.today.dateFormat(this.format);
     
                this.todayBtn = new Ext.Button({
                    renderTo: this.el.child('td.x-date-bottom', true),
                    text: String.format(this.todayText, today),
                    tooltip: String.format(this.todayTip, today),
                    handler: this.selectToday,
                    scope: this
                });
            }
            this.mon(this.eventEl, 'mousewheel', this.handleMouseWheel, this);
            this.mon(this.eventEl, 'click', this.handleDateClick,  this, {delegate: 'a.x-date-date'});
            this.mon(this.mbtn, 'click', this.showMonthPicker, this);
            this.onEnable(true);
        },
     
        // private
        createMonthPicker : function(){
            if(!this.monthPicker.dom.firstChild){
                var buf = ['<table border="0" cellspacing="0">'];
                for(var i = 0; i < 6; i++){
                    buf.push(
                        '<tr><td class="x-date-mp-month"><a href="#">', shortmonth_AR[i]/*Date.getShortMonthName(i)*/, '</a></td>',
                        '<td class="x-date-mp-month x-date-mp-sep"><a href="#">', shortmonth_AR[i + 6]/*Date.getShortMonthName(i + 6)*/, '</a></td>',
                        i === 0 ?
                        '<td class="x-date-mp-ybtn" align="center"><a class="x-date-mp-prev"></a></td><td class="x-date-mp-ybtn" align="center"><a class="x-date-mp-next"></a></td></tr>' :
                        '<td class="x-date-mp-year"><a href="#"></a></td><td class="x-date-mp-year"><a href="#"></a></td></tr>'
                    );
                }
                buf.push(
                    '<tr class="x-date-mp-btns"><td colspan="4"><button type="button" class="x-date-mp-ok">',
                        this.okText,
                        '</button><button type="button" class="x-date-mp-cancel">',
                        this.cancelText,
                        '</button></td></tr>',
                    '</table>'
                );
                this.monthPicker.update(buf.join(''));
     
                this.mon(this.monthPicker, 'click', this.onMonthClick, this);
                this.mon(this.monthPicker, 'dblclick', this.onMonthDblClick, this);
     
                this.mpMonths = this.monthPicker.select('td.x-date-mp-month');
                this.mpYears = this.monthPicker.select('td.x-date-mp-year');
     
                this.mpMonths.each(function(m, a, i){
                    i += 1;
                    if((i%2) === 0){
                        m.dom.xmonth = 5 + Math.round(i * 0.5);
                    }else{
                        m.dom.xmonth = Math.round((i-1) * 0.5);
                    }
                });
            }
        },
     
        // private
        showMonthPicker : function(){
            if(!this.disabled){
                this.createMonthPicker();
                var size = this.el.getSize();
                this.monthPicker.setSize(size);
                this.monthPicker.child('table').setSize(size);
     
                this.mpSelMonth = (this.activeDate || this.value).getMonth();
                this.updateMPMonth(this.mpSelMonth-1);
                this.mpSelYear = (this.activeDate || this.value).getYear();
                this.updateMPYear(this.mpSelYear);
     
                this.monthPicker.slideIn('t', {duration:0.2});
            }
        },
     
        // private
        updateMPYear : function(y){
            this.mpyear = y;
            var ys = this.mpYears.elements;
            for(var i = 1; i <= 10; i++){
                var td = ys[i-1], y2;
                if((i%2) === 0){
                    y2 = y + Math.round(i * 0.5);
                    td.firstChild.innerHTML = y2;
                    td.xyear = y2;
                }else{
                    y2 = y - (5-Math.round(i * 0.5));
                    td.firstChild.innerHTML = y2;
                    td.xyear = y2;
                }
                this.mpYears.item(i-1)[y2 == this.mpSelYear ? 'addClass' : 'removeClass']('x-date-mp-sel');
            }
        },
     
        // private
        updateMPMonth : function(sm){
            this.mpMonths.each(function(m, a, i){
                m[m.dom.xmonth == sm ? 'addClass' : 'removeClass']('x-date-mp-sel');
            });
        },
     
        // private
        selectMPMonth : function(m){
     
        },
     
        // private
        onMonthClick : function(e, t){
            e.stopEvent();
            var el = new Ext.Element(t), pn;
            if(el.is('button.x-date-mp-cancel')){
                this.hideMonthPicker();
            }
            else if(el.is('button.x-date-mp-ok')){
                var d = new MyDate(this.mpSelYear, (this.mpSelMonth+1), (this.activeDate || this.value).getDay());
                if(d.getMonth() != (this.mpSelMonth+1)){
                    // 'fix' the JS rolling date conversion if needed
                    d = new MyDate(this.mpSelYear, (this.mpSelMonth+1), 1); //.getLastDateOfMonth();
                }
                this.update(d);
                this.hideMonthPicker();
            }
            else if((pn = el.up('td.x-date-mp-month', 2))){
                this.mpMonths.removeClass('x-date-mp-sel');
                pn.addClass('x-date-mp-sel');
                this.mpSelMonth = pn.dom.xmonth;
            }
            else if((pn = el.up('td.x-date-mp-year', 2))){
                this.mpYears.removeClass('x-date-mp-sel');
                pn.addClass('x-date-mp-sel');
                this.mpSelYear = pn.dom.xyear;
            }
            else if(el.is('a.x-date-mp-prev')){
                this.updateMPYear(this.mpyear-10);
            }
            else if(el.is('a.x-date-mp-next')){
                this.updateMPYear(this.mpyear+10);
            }
        },
     
        // private
        onMonthDblClick : function(e, t){
            e.stopEvent();
            var el = new Ext.Element(t), pn;
            if((pn = el.up('td.x-date-mp-month', 2))){
                this.update(new MyDate(this.mpSelYear, pn.dom.xmonth, (this.activeDate || this.value).getDay()));
                this.hideMonthPicker();
            }
            else if((pn = el.up('td.x-date-mp-year', 2))){
                this.update(new MyDate(pn.dom.xyear, this.mpSelMonth, (this.activeDate || this.value).getDay()));
                this.hideMonthPicker();
            }
        },
     
        // private
        hideMonthPicker : function(disableAnim){
            if(this.monthPicker){
                if(disableAnim === true){
                    this.monthPicker.hide();
                }else{
                    this.monthPicker.slideOut('t', {duration:0.2});
                }
            }
        },
     
        // private
        showPrevMonth : function(e){
            this.update(this.activeDate.add('mo', -1));
        },
     
        // private
        showNextMonth : function(e){
            this.update(this.activeDate.add('mo', 1));
        },
     
        // private
        showPrevYear : function(){
            this.update(this.activeDate.add('y', -1));
        },
     
        // private
        showNextYear : function(){
            this.update(this.activeDate.add('y', 1));
        },
     
        // private
        handleMouseWheel : function(e){
            e.stopEvent();
            if(!this.disabled){
                var delta = e.getWheelDelta();
                if(delta > 0){
                    this.showPrevMonth();
                } else if(delta < 0){
                    this.showNextMonth();
                }
            }
        },
     
        // private
        handleDateClick : function(e, t){
            e.stopEvent();
            if(!this.disabled && t.dateValue && !Ext.fly(t.parentNode).hasClass('x-date-disabled')){
                /*this.cancelFocus = this.focusOnSelect === false;
                this.setValue(t.dateValue);
                delete this.cancelFocus;
                this.fireEvent('select', this, this.value);*/
    			this.setValue(t.dateValue);
    			this.fireEvent('select', this, this.value);
            }
        },
     
        // private
        selectToday : function(){
            if(this.todayBtn && !this.todayBtn.disabled){
                this.setValue(this.today/*new Date()*/.clearTime());
                this.fireEvent('select', this, this.value);
            }
        },
     
        // private
        update : function(date, forceRefresh){
    		var objRef = this;
    		var dateHijri = date.getYear() + "/" + date.getMonth() + "/" + date.getDay();
    		miladitohijri.getHijriPicker(dateHijri, {
    			callback:function(hijriPicker){
    				objRef.updatepicker(hijriPicker, date, forceRefresh);
    			}
    		});
    	},
     
    	//updatepicker
    	updatepicker : function(hijriPicker, date, forceRefresh){	
    		if(this.rendered){
    			var vd = this.activeDate, vis = this.isVisible();
    			this.activeDate = date;
    			if(!forceRefresh && vd && this.el){
    				var t = date.getTime();
    				if(vd.getMonth() == date.getMonth() && vd.getYear() == date.getYear()){
    					this.cells.removeClass('x-date-selected');
    					this.cells.each(function(c){
    					   if(c.dom.firstChild.dateValue.dateFormat() == t.dateFormat()){
    						   c.addClass('x-date-selected');
    						   if(vis && !this.cancelFocus){
    							   Ext.fly(c.dom.firstChild).focus(50);
    						   }
    						   return false;
    					   }
    					}, this);
    					return;
    				}
    			}
     
    			//this.today = new Date();
    			//this.today_h = gregorianToHijri(new MyDate(this.today.getDate(), (this.today.getMonth() + 1), this.today.getFullYear()));	
    			//this.today = this.field.parseDate(this.today_h.getDate());
    			var field = this;
     
    			var date_h = new MyDate(date.getYear(), date.getMonth(), date.getDay());
     
    			var firstday_h = hijriPicker.firstDay; //getHijriFirstDay(date_h);
    			var monthdays_h = hijriPicker.monthDays; //getHijriMonthDays(date_h);
     
    			this.monthdays = monthdays_h;
     
    			var days = monthdays_h;
    			var startingPos = firstday_h; //-this.startDay;
     
    			/*if(startingPos < 0){
    				startingPos += 7;
    			}*/
     
    			days += startingPos;
     
    			var itemsPrev = hijriPicker.datePrevHijri.split("/");
    			var datePrevHijri = new MyDate(itemsPrev[0], itemsPrev[1], itemsPrev[1]);
     
    			var prevMonthFirstDay_h = datePrevHijri; //date_h.getPreviousMonthFirstDayDate();
    			var prevMonthdays_h = hijriPicker.monthPrevDays; //getHijriMonthDays(prevMonthFirstDay_h);
     
    			//alert(this.datePrevHijri + "::" + this.monthPrevDays);
     
    			this.bmonth  = prevMonthFirstDay_h.month;
    			this.bmonthdays = prevMonthdays_h;
     
    			//var pm = this.parseDate(prevMonthFirstDay_h.getDate())/*date.add('mo', -1)*/,
    			var prevStart = prevMonthdays_h/*pm.getDaysInMonth()*/-startingPos,
    				cells = this.cells.elements,
    				textEls = this.textNodes,
     
    				// convert everything to numbers so it's fast
    				//d = (new Date(prevMonthFirstDay_h.year/*pm.getFullYear()*/, prevMonthFirstDay_h.month-1/*pm.getMonth()*/, prevStart, this.initHour)),
    				d = new MyDate(prevMonthFirstDay_h.year, prevMonthFirstDay_h.month, prevStart),
    				today = this.today/*new Date()*/.clearTime().getTime(),
    				sel = date.clearTime(true).getTime(),
     
    				min = this.minDate ? this.minDate.clearTime(true) : Number.NEGATIVE_INFINITY,
    				max = this.maxDate ? this.maxDate.clearTime(true) : Number.POSITIVE_INFINITY,
     
    				ddMatch = this.disabledDatesRE,
    				ddText = this.disabledDatesText,
    				ddays = this.disabledDays ? this.disabledDays.join('') : false,
    				ddaysText = this.disabledDaysText,
    				format = this.format;
     
    			//alert("d:" + d);
     
    			if(this.showToday){
    				var td = this.today/*new Date()*/.clearTime(),
    					disable = (td < min || td > max ||
    					(ddMatch && format && ddMatch.test(td.dateFormat(format))) ||
    					(ddays && ddays.indexOf(td.getDay()) != -1));
     
    				/*if(!this.disabled){
    					this.todayBtn.setDisabled(disable);
    					this.todayKeyListener[disable ? 'disable' : 'enable']();
    				}*/
    			}
     
    			var setCellClass = function(cal, cell, day){
    				cell.title = '';				
    				var t = d.clearTime(true).getTime();
    				cell.firstChild.dateValue = t;
     
    				if(field.today && t.dateFormat() == field.today.dateFormat()){
    					cell.className += ' x-date-today';
    					cell.title = cal.todayText;
    				}
    				//alert(t.dateFormat() +"=="+ sel.dateFormat() + "::" + (t.dateFormat() == sel.dateFormat()))
    				if(sel && t.dateFormat() == sel.dateFormat()){
    					cell.className += ' x-date-selected';
    					if(vis){
    						Ext.fly(cell.firstChild).focus(50);
    					}
    				}
     
    				// disabling
    				/*if(t < min) {
    					cell.className = ' x-date-disabled';
    					cell.title = cal.minText;
    					return;
    				}
    				if(t > max) {
    					cell.className = ' x-date-disabled';
    					cell.title = cal.maxText;
    					return;
    				}
    				if(ddays){
    					if(ddays.indexOf(day) != -1){
    						cell.title = ddaysText;
    						cell.className = ' x-date-disabled';
    					}
    				}
    				if(ddMatch && format){
    					var fvalue = d.dateFormat(format);
    					if(ddMatch.test(fvalue)){
    						cell.title = ddText.replace('%0', fvalue);
    						cell.className = ' x-date-disabled';
    					}
    				}*/
    			};
     
    			var dd="";
    			var i = 0;			
    			for(; i < startingPos; i++) {
    				textEls[i].innerHTML = (++prevStart);
    				d = this.nextDate(d); /*d.setDate(d.getDate()+1);*/
    				cells[i].className = 'x-date-prevday';
    				setCellClass(this, cells[i], (i%7));
    				dd+=i+","+d+","+textEls[i].innerHTML+"\n";
    			}
    			for(; i < days; i++){
    				var intDay = i - startingPos + 1;
    				textEls[i].innerHTML = (intDay);
    				d = this.nextDate(d); /*d.setDate(d.getDate()+1);*/
    				cells[i].className = 'x-date-active';
    				setCellClass(this, cells[i], (i%7));
    				dd+=i+","+d+","+textEls[i].innerHTML+"\n";
    			}
    			var extraDays = 0;
    			for(; i < 42; i++) {
    				 textEls[i].innerHTML = (++extraDays);
    				 d = this.nextDate(d); /*d.setDate(d.getDate()+1);*/
    				 cells[i].className = 'x-date-nextday';
    				 setCellClass(this, cells[i], (i%7));
    				 dd+=i+","+d+","+textEls[i].innerHTML+"\n";
    			}
    			//alert(dd)
    			this.mbtn.setText(month_AR[date.getMonth()-1] + ' ' + date.getYear());
     
    			if(!this.internalRender){
    				var main = this.el.dom.firstChild,
    					w = main.offsetWidth;
    				this.el.setWidth(w + this.el.getBorderWidth('lr'));
    				Ext.fly(main).setWidth(w);
    				this.internalRender = true;
    				// opera does not respect the auto grow header center column
    				// then, after it gets a width opera refuses to recalculate
    				// without a second pass
    				if(Ext.isOpera && !this.secondPass){
    					main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + 'px';
    					this.secondPass = true;
    					this.update.defer(10, this, [date]);
    				}
    			}
    		}
        },
     
    	nextDate: function(date){
    		var myDate = new MyDate();
     
    		if(date.getDay() < this.bmonthdays){
    			myDate.setDay(date.getDay() + 1);
    			myDate.setMonth(date.getMonth());
    			myDate.setYear(date.getYear());
    		}else{					
    			if(this.bmonth < 12){
    				myDate.setDay(1);
    				myDate.setMonth(date.getMonth()+1);
    				myDate.setYear(date.getYear());
    			}else{
    				myDate.setDay(1);
    				myDate.setMonth(1);
    				myDate.setYear(date.getYear() + 1);
    			}
     
    			this.bmonth = myDate.getMonth();
    			this.bmonthdays = this.monthdays;
    		}
     
    		return myDate;
    	},
     
        // private
        beforeDestroy : function() {
            if(this.rendered){
                Ext.destroy(
                    this.keyNav,
                    this.monthPicker,
                    this.eventEl,
                    this.mbtn,
                    this.nextRepeater,
                    this.prevRepeater,
                    this.cells.el,
                    this.todayBtn
                );
                delete this.textNodes;
                delete this.cells.elements;
            }
        }
     
        /**
         * @cfg {String} autoEl @hide
         */
    });
     
    Ext.reg('datehijripicker', Ext.ux.DateHijriPicker);

Discussions similaires

  1. Migration d'un calendrier spécifique du extjs 3.4 vers extjs 4.2
    Par franco9 dans le forum Ext JS / Sencha
    Réponses: 1
    Dernier message: 22/10/2013, 10h37
  2. [Débutant] migration de code sources sharepoint 2007 vers 2010
    Par roubi dans le forum SharePoint
    Réponses: 7
    Dernier message: 13/09/2012, 09h03
  3. Migration extjs 1.x vers 2.x ou plus
    Par mbadjo79 dans le forum Ext JS / Sencha
    Réponses: 1
    Dernier message: 02/03/2010, 10h44
  4. Migrations de codes MFC de Visual 6.0 vers Visual studio 2005
    Par jojo le boss dans le forum VC++ .NET
    Réponses: 12
    Dernier message: 06/08/2006, 11h47

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo