<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 241,  comments - 116,  trackbacks - 0
    /*!
     * Ext JS Library 3.2.1
     * Copyright(c) 2006-2010 Ext JS, Inc.
     * licensing@extjs.com
     * http://www.extjs.com/license
     */
    Ext.ns('Ext.ux');
    /*
     * @class Ext.ux.DatePicker
     * @extends Ext.DatePicker
     * Ext.ux.DatePicker
     */
    Ext.ux.DatePicker = Ext.extend(Ext.DatePicker,{
        
        // bind this component to normal <input/> tag
        bindToInput : false,
        
        initComponent:function(){
            Ext.ux.DatePicker.superclass.initComponent.call(this);
            if(this.bindToInput){//create container to render
                this.createAlignToContainer();
                this.render(this.alignToContainerId);
            }
        },
        
        // private
        onRender : function(container, position){
            Ext.ux.DatePicker.superclass.onRender.call(this, container, position);
            if(this.bindToInput){
                Ext.getDoc().on('mousedown',function(e,t,o){
                    if(t == this.bindTo.dom || e.getTarget('div.x-date-picker')){
                        //do nothing
                    }else{// hide this component when click other area except <input/> tag and datepicker area
                        this.hide();
                    }
                },this);
            }
        },
        
        // bind a singleton datepicker to <input/> tag while it onclick
        bindingTo: function(bindTo){
            if(bindTo){
                this.bindTo = Ext.get(bindTo);
                if(this.bindTo){
                    if(this.bindTo.dom.prev){
                        this.prev = Ext.get(this.bindTo.dom.prev);
                    }
                    if(this.bindTo.dom.next){
                        this.next = Ext.get(this.bindTo.dom.next);
                    }
                    if(this.bindToInput){
                        this.alignToContainer.alignTo(bindTo,'tl-bl?');// alignment
                    }
                }
            }
        },
        
        // create container
        createAlignToContainer : function(){
            var divElement = document.createElement('div');
            this.alignToContainerId = Ext.id();
            document.body.appendChild(divElement);
            divElement.setAttribute('id',this.alignToContainerId)
            this.alignToContainer = Ext.get(this.alignToContainerId);
            this.alignToContainer.applyStyles("position:absolute");
            this.alignToContainer.applyStyles("z-index:99999");
        },
        
        // override
        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);
                this.mpSelYear = (this.activeDate || this.value).getFullYear();
                this.updateMPYear(this.mpSelYear);

                if(this.format.indexOf('d') != -1){// format with days
                    this.monthPicker.slideIn('t', {duration:0.2});
                }else{//format no days
                    this.monthPicker.show();
                    this.monthPicker.child('> table',false).setWidth(this.el.getWidth() - 2);
                    this.monthPicker.setWidth(this.el.getWidth() - 2);
                }
            }
        },
        
        // override
        show : function(){
            Ext.ux.DatePicker.superclass.show.call(this);
            if(this.format.indexOf('d') == -1){
                this.showMonthPicker();
            }
        },
        
        // override
        onMonthClick : function(e, t){
            e.stopEvent();
            var el = new Ext.Element(t), pn;
            if(el.is('button.x-date-mp-cancel')){
                if(this.format.indexOf('d') == -1){
                    this.hide();
                }else{
                    this.hideMonthPicker();
                }
            }
            else if(el.is('button.x-date-mp-ok')){
                var d = new Date(this.mpSelYear, this.mpSelMonth, (this.activeDate || this.value).getDate());
                if(d.getMonth() != this.mpSelMonth){
                    // 'fix' the JS rolling date conversion if needed
                    d = new Date(this.mpSelYear, this.mpSelMonth, 1).getLastDateOfMonth();
                }
                this.update(d);
                if(this.format.indexOf('d') == -1){
                    this.bindTo.dom.value = d.format(this.format);
                    this.setValue(Date.parseDate(d.format(this.format),this.format),true);
                    this.hide();
                    if(this.fireEvent('select', this, this.value) == true){
                        this.validateDate();
                    }
                }else{
                    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);
            }
        },

        // override
        onMonthDblClick : function(e, t){
            e.stopEvent();
            var el = new Ext.Element(t), pn, d;
            if((pn = el.up('td.x-date-mp-month', 2))){
                d = new Date(this.mpSelYear, pn.dom.xmonth, (this.activeDate || this.value).getDate());
                this.update(d);
                
                if(this.format.indexOf('d') == -1){
                    this.bindTo.dom.value = d.format(this.format);
                    this.setValue(Date.parseDate(d.format(this.format),this.format),true);
                    this.hide();
                    if(this.fireEvent('select', this, this.value) == true){
                        this.validateDate();
                    }
                }else{
                    this.hideMonthPicker();
                }
            }
            else if((pn = el.up('td.x-date-mp-year', 2))){
                d = new Date(pn.dom.xyear, this.mpSelMonth, (this.activeDate || this.value).getDate());
                this.update(d);
                
                if(this.format.indexOf('d') == -1){
                    this.bindTo.dom.value = d.format(this.format);
                    this.setValue(Date.parseDate(d.format(this.format),this.format),true);
                    this.hide();
                    if(this.fireEvent('select', this, this.value) == true){
                        this.validateDate();
                    }
                }else{
                    this.hideMonthPicker();
                }
            }
        },
        
        // 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(new Date(t.dateValue));
                delete this.cancelFocus;
                if(this.fireEvent('select', this, this.value) == true){
                    this.validateDate();
                }
            }
        },

        // private
        selectToday : function(){
            if(this.todayBtn && !this.todayBtn.disabled){
                this.setValue(new Date().clearTime());
                if(this.fireEvent('select', this, this.value) == true){
                    this.validateDate();
                }
            }
        },
        
        //validate when a date is selected
        validateDate : function(){
            if(this.bindToInput){
                if(this.bindTo){
                    if(this.prev){
                        if(Ext.get(this.prev)){
                            var prev_date = Date.parseDate(Ext.get(this.prev).getValue(),this.format,true);
                            if(prev_date){
                                var this_date = Date.parseDate(this.getValue().format(this.format),this.format,true);
                                if(prev_date.getTime() > this_date.getTime()){
                                    Ext.Msg.alert('warning','"u6240"u9009"u65f6"u95f4"u7684"u524d"u540e"u987a"u5e8f"u6709"u8bef"uff01"uff01"uff01',function(){
                                        this.bindTo.focus();
                                        this.bindTo.dom.select();
                                    },this);
                                }
                            }
                        }
                    }
                    if(this.next){
                        if(Ext.get(this.next)){
                            var next_date = Date.parseDate(Ext.get(this.next).getValue(),this.format,true);
                            if(next_date){
                                var this_date = Date.parseDate(this.getValue().format(this.format),this.format,true);
                                if(next_date.getTime() < this_date.getTime()){
                                    Ext.Msg.alert('warning','"u6240"u9009"u65f6"u95f4"u7684"u524d"u540e"u987a"u5e8f"u6709"u8bef"uff01"uff01"uff01',function(){
                                        this.bindTo.focus();
                                        this.bindTo.dom.select();
                                    },this);
                                }
                            }
                        }
                    }
                }
            }
        }
    });

    /*
     * bind a datePicker,an example like this:
     * <input type='text' id='from_date' name='date1' next='to_date' onclick='showDatePicker(this);'/>
     * <input type='text' id='to_date' name='date2' prev='from_date' onclick='showDatePicker(this);'/>
     */
    function showDatePicker(input){

        //singleton datePicker
        if(Ext.getCmp('x-datepicker-ux')){
            var datePicker = Ext.getCmp('x-datepicker-ux');
            datePicker.bindingTo(input);
            datePicker.show();
        }else{
            var datePicker = new Ext.ux.DatePicker({
                id: 'x-datepicker-ux',
                format: 'Y-m',
                bindToInput: true,
                handler: function(_datePicker,_date){
                    _datePicker.bindTo.dom.value = _date.format(_datePicker.format);
                    _datePicker.hide();
                }
            });
            datePicker.bindingTo(input);
            datePicker.show();
        }
    }

    posted on 2011-05-11 11:02 墻頭草 閱讀(1771) 評(píng)論(0)  編輯  收藏

    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    人人游戲網(wǎng) 軟件開(kāi)發(fā)網(wǎng) 貨運(yùn)專(zhuān)家
    主站蜘蛛池模板: 一级毛片在线免费视频| 久久精品国产亚洲5555| 精品久久久久久亚洲综合网| 亚洲人成色77777在线观看大| 亚洲乱亚洲乱妇24p| 亚洲av无码不卡私人影院| 免费黄网站在线看| 亚洲日韩精品国产一区二区三区| 国内精品久久久久久久亚洲| 一区免费在线观看| 亚洲视频在线观看视频| 免费吃奶摸下激烈视频| 久久久久久AV无码免费网站| 亚洲av第一网站久章草| 亚洲国产女人aaa毛片在线| 免费看a级黄色片| 人妻无码一区二区三区免费 | 亚洲高清免费视频| 人妻无码久久一区二区三区免费| 亚洲AV成人一区二区三区观看| 情人伊人久久综合亚洲| 国产高清在线精品免费软件| 亚洲第一成年免费网站| 久久精品视频亚洲| 日韩精品无码专区免费播放| 亚洲av日韩av永久无码电影| 亚洲婷婷综合色高清在线| 丁香五月亚洲综合深深爱| 四虎影院在线免费播放| 免费能直接在线观看黄的视频| 一个人看的免费观看日本视频www 一个人看的免费视频www在线高清动漫 | 亚欧免费无码aⅴ在线观看| 偷自拍亚洲视频在线观看99| 亚洲爽爽一区二区三区| 国产成人无码区免费内射一片色欲| 中文有码亚洲制服av片| 亚洲精品成人av在线| 77777亚洲午夜久久多人| 亚洲精品国产精品国自产观看| 处破痛哭A√18成年片免费| 亚洲人成免费网站|