Пример #1
0
    show: function(evt) {
    	var oThis = this;
    	if(this.value && this.value.indexOf('-') > -1){
    		var vA = this.value.split("-");
    		var month = vA[0];
    		this.month = month % 12;
    		if(this.month == 0)
    			this.month = 12;
            this.date = vA[1];
            if(this.date>31) {
                this.date = 1;
            }
    	}
    	this.createPanel();
        if(this.options.showFix){
            document.body.appendChild(this.panelDiv);
            this.panelDiv.style.position = 'fixed';
            showPanelByEle({
                ele:this.input,
                panel:this.panelDiv,
                position:"bottomLeft"
            });
        }else{

            var bodyWidth = document.body.clientWidth,bodyHeight = document.body.clientHeight,
            panelWidth = this.panelDiv.offsetWidth,panelHeight = this.panelDiv.offsetHeight;

            this.element.appendChild(this.panelDiv);
            this.element.style.position = 'relative';
            this.left = this.input.offsetLeft;
            var inputHeight = this.input.offsetHeight;
            this.top = this.input.offsetTop + inputHeight;

            if(this.left + panelWidth > bodyWidth){
                this.left = bodyWidth - panelWidth;
            }

            if((this.top + panelHeight) > bodyHeight){
                this.top = bodyHeight - panelHeight;
            }


            this.panelDiv.style.left = this.left + 'px';
            this.panelDiv.style.top = this.top + 'px';
        }


    	this.panelDiv.style.zIndex = getZIndex();
        addClass(this.panelDiv, 'is-visible');
        var oThis = this;
        var callback = function (e) {
            if (e !== evt && e.target !== oThis.input && !oThis.clickPanel(e.target)  && oThis._inputFocus != true) {
                // document.removeEventListener('click', callback);
                off(document,'click',callback);
            	oThis.hide();
        	}
        };
        on(document,'click',callback);
        // document.addEventListener('click', callback);
    },
Пример #2
0
    show: function (evt) {

        var self = this,width=this._input.offsetWidth;
        if(this.options.showFix){
            document.body.appendChild(this._ul);
            this._ul.style.position = 'fixed';
            showPanelByEle({
                ele:this._input,
                panel:this._ul,
                position:"bottomLeft"
            });
        }else{
            // this.element.parentNode.appendChild(this._ul);
            // var left = this.element.offsetLeft,
            // inputHeight = this.element.offsetHeight,
            // top = this.element.offsetTop + inputHeight;
            // this._ul.style.left = left + 'px';
            // this._ul.style.top = top + 'px';
            var bodyWidth = document.body.clientWidth,bodyHeight = document.body.clientHeight,
                panelWidth = this._ul.offsetWidth,panelHeight = this._ul.offsetHeight;
            this.element.appendChild(this._ul);
            this.element.style.position = 'relative';
            this.left = this._input.offsetLeft;
            var inputHeight = this._input.offsetHeight;
            this.top = this._input.offsetTop + inputHeight;
            if(this.left + panelWidth > bodyWidth){
                this.left = bodyWidth - panelWidth;
            }

            if((this.top + panelHeight) > bodyHeight){
                this.top = bodyHeight - panelHeight;
            }

            this._ul.style.left = this.left + 'px';
            this._ul.style.top = this.top + 'px';
        }
	    this._ul.style.width = width + 'px';
        $(this._ul).addClass('is-animating');
        this._ul.style.zIndex = getZIndex();
        $(this._ul).addClass('is-visible');

        var callback = function (e) {
            if(e === evt || e.target === this._input || self._inputFocus == true) return;
            if(this.mutilSelect && (closest(e.target,'u-combo-ul') === self._ul || closest(e.target, 'u-combo-name-par') || closest(e.target, 'u-combo-name')) ) return;
            off(document,'click',callback);
            // document.removeEventListener('click', callback);
            this.hide();
        }.bind(this);
        this.callback = callback;
        on(document,'click',callback);
        on(document.body,'touchend',callback)
        // document.addEventListener('click', callback);

    },
Пример #3
0
	show: function(evt) {
		var oThis = this;
		this.createPanel();

		this.width = this.element.offsetWidth;
		if(this.width < 300)
			this.width = 300;
		 if(this.options.showFix){
		 	document.body.appendChild(this.panelDiv);
	        this.panelDiv.style.position = 'fixed';
	        showPanelByEle({
	            ele:this.input,
	            panel:this.panelDiv,
	            position:"bottomLeft"
	        });
	    }else{
		    var bodyWidth = document.body.clientWidth,bodyHeight = document.body.clientHeight,
	        panelWidth = this.panelDiv.offsetWidth,panelHeight = this.panelDiv.offsetHeight;

	        this.element.appendChild(this.panelDiv);
	        this.element.style.position = 'relative';
	   		this.left = this.input.offsetLeft;
	    	var inputHeight = this.input.offsetHeight;
	    	this.top = this.input.offsetTop + inputHeight;

	        if(this.left + panelWidth > bodyWidth){
	            this.left = bodyWidth - panelWidth;
	        }

	        if((this.top + panelHeight) > bodyHeight){
	            this.top = bodyHeight - panelHeight;
	        }


	        this.panelDiv.style.left = this.left + 'px';
	        this.panelDiv.style.top = this.top + 'px';

	    }


		this.panelDiv.style.width = 152 + 'px';
		this.panelDiv.style.zIndex = getZIndex();
	    addClass(this.panelDiv, 'is-visible');

	    var callback = function (e) {
	        if (e !== evt && e.target !== this.input && !oThis.clickPanel(e.target) && oThis._inputFocus != true) {
	        	off(document,'click',callback);
	            // document.removeEventListener('click', callback);
	        	this.hide();
	    	}
	    }.bind(this);
	    on(document,'click',callback);
	},
Пример #4
0
	show: function () {
		var self = this;
		this.tipDom.querySelector('.tooltip-inner').innerHTML = this.options.title;
		this.tipDom.style.zIndex = getZIndex();

		if (this.options.showFix) {
			document.body.appendChild(this.tipDom);
			this.tipDom.style.position = 'fixed';
			showPanelByEle({
				ele: this.element,
				panel: this.tipDom,
				position: "top"
			});
			// fix情况下滚动时隐藏
			on(document, 'scroll', function () {
				self.hide();
			});
		} else {
			this.container.appendChild(this.tipDom);
			var inputLeft = this.element.offsetLeft;
			var inputTop = this.element.offsetTop;
			var inputWidth = this.element.offsetWidth;
			var inputHeight = this.element.offsetHeight;
			var topWidth = this.tipDom.offsetWidth;
			var topHeight = this.tipDom.offsetHeight;
			var tipDomleft, tipDomTop;

			if (this.options.placement == 'top') {
				// 上部提示

				this.left = this.element.offsetLeft + inputWidth / 2;
				this.top = this.element.offsetTop - topHeight;
				// 水平居中
				tipDomleft = this.left - this.tipDom.clientWidth / 2 + 'px';
				tipDomTop = this.top + 'px';
			} else if (this.options.placement == 'bottom') {
				// 下边提示
				this.left = this.element.offsetLeft + inputWidth / 2;
				this.top = this.element.offsetTop + topHeight;
				// 水平居中
				tipDomleft = this.left - this.tipDom.clientWidth / 2 + 'px';
				tipDomTop = this.top + 'px';
			} else if (this.options.placement == 'left') {
				// 左边提示
				this.left = this.element.offsetLeft;
				this.top = this.element.offsetTop + topHeight / 2;
				tipDomleft = this.left - this.tipDom.clientWidth + 'px';

				tipDomTop = this.top - this.tipDom.clientHeight / 2 + 'px';
			} else {
				// 右边提示

				this.left = this.element.offsetLeft + inputWidth;
				this.top = this.element.offsetTop + topHeight / 2;
				tipDomleft = this.left + 'px';
				tipDomTop = this.top - this.tipDom.clientHeight / 2 + 'px';
			}

			this.tipDom.style.left = tipDomleft;
			this.tipDom.style.top = tipDomTop;
		}

		addClass(this.tipDom, 'active');

		// var placement = this.options.placement;
		// var pos = this.getPosition()
		// var actualWidth = this.tipDom.offsetWidth
		// var actualHeight = this.tipDom.offsetHeight
		// var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)

		// this.applyPlacement(calculatedOffset, placement)
	},