(function (exports) {
'use strict';

/**
 * Module : Sparrow extend enum
 * Author : Kvkens(yueming@yonyou.com)
 * Date	  : 2016-07-27 21:46:50
 */

var U_LOCALE = "u_locale";
var enumerables = true;
var enumerablesTest = {
		toString: 1
	};
for(var i in enumerablesTest) {
	enumerables = null;
}
if(enumerables) {
	enumerables = ['hasOwnProperty', 'valueOf', 'isPrototypeOf', 'propertyIsEnumerable',
		'toLocaleString', 'toString', 'constructor'
	];
}

/**
 * Module : Sparrow extend
 * Author : Kvkens(yueming@yonyou.com)
 * Date	  : 2016-07-27 21:46:50
 */

/**
 * 复制对象属性
 *
 * @param {Object}  目标对象
 * @param {config} 源对象
 */
var extend = function(object, config) {
	var args = arguments,
		options;
	if(args.length > 1) {
		for(var len = 1; len < args.length; len++) {
			options = args[len];
			if(object && options && typeof options === 'object') {
				var i, j, k;
				for(i in options) {
					object[i] = options[i];
				}
				if(enumerables) {
					for(j = enumerables.length; j--;) {
						k = enumerables[j];
						if(options.hasOwnProperty && options.hasOwnProperty(k)) {
							object[k] = options[k];
						}
					}
				}
			}
		}
	}
	return object;
};

if(!Object.assign){
	Object.assign = extend;
}

/**
 * Module : Sparrow touch event
 * Author : Kvkens(yueming@yonyou.com)
 * Date	  : 2016-07-28 14:41:17
 */

var on = function(element, eventName, child, listener) {
	if(!element)
		return;
	if(arguments.length < 4) {
		listener = child;
		child = undefined;
	} else {
		var childlistener = function(e) {
			if(!e) {
				return;
			}
			var tmpchildren = element.querySelectorAll(child);
			tmpchildren.forEach(function(node) {
				if(node == e.target) {
					listener.call(e.target, e);
				}
			});
		};
	}
	//capture = capture || false;

	if(!element["uEvent"]) {
		//在dom上添加记录区
		element["uEvent"] = {};
	}
	//判断是否元素上是否用通过on方法填加进去的事件
	if(!element["uEvent"][eventName]) {
		element["uEvent"][eventName] = [child ? childlistener : listener];
		if(u.event && u.event[eventName] && u.event[eventName].setup) {
			u.event[eventName].setup.call(element);
		}
		element["uEvent"][eventName + 'fn'] = function(e) {
			//火狐下有问题修改判断
			if(!e)
				e = typeof event != 'undefined' && event ? event : window.event;
			element["uEvent"][eventName].forEach(function(fn) {
				try {
					e.target = e.target || e.srcElement; //兼容IE8
				} catch(ee) {}
				if(fn)
					fn.call(element, e);
			});
		};
		if(element.addEventListener) { // 用于支持DOM的浏览器
			element.addEventListener(eventName, element["uEvent"][eventName + 'fn']);
		} else if(element.attachEvent) { // 用于IE浏览器
			element.attachEvent("on" + eventName, element["uEvent"][eventName + 'fn']);
		} else { // 用于其它浏览器
			element["on" + eventName] = element["uEvent"][eventName + 'fn'];
		}
	} else {
		//如果有就直接往元素的记录区添加事件
		var lis = child ? childlistener : listener;
		var hasLis = false;
		element["uEvent"][eventName].forEach(function(fn) {
			if(fn == lis) {
				hasLis = true;
			}
		});
		if(!hasLis) {
			element["uEvent"][eventName].push(child ? childlistener : listener);
		}
	}

};

/**
 * 阻止冒泡
 */
var stopEvent = function(e) {
	if(typeof(e) != "undefined") {
		if(e.stopPropagation)
			e.stopPropagation();
		else {
			e.cancelBubble = true;
		}
		//阻止默认浏览器动作(W3C)
		if(e && e.preventDefault)
			e.preventDefault();
		//IE中阻止函数器默认动作的方式
		else
			window.event.returnValue = false;
	}
};

/**
 * Module : Sparrow dom
 * Author : Kvkens(yueming@yonyou.com)
 * Date	  : 2016-08-16 13:59:17
 */
/**
 * 元素增加指定样式
 * @param value
 * @returns {*}
 */
var addClass = function(element, value) {
	if(element){
		if(typeof element.classList === 'undefined') {
			if(u._addClass){
				u._addClass(element, value);
			}else{
				$(element).addClass(value);
			}

		} else {
			element.classList.add(value);
		}
	}

	return this;
};
/**
 * 删除元素上指定样式
 * @param {Object} element
 * @param {Object} value
 */
var removeClass = function(element, value) {
	if(element){
		if(typeof element.classList === 'undefined') {
			if(u._removeClass){
				u._removeClass(element, value);
			}else{
				$(element).removeClass(value);
			}

		} else {
			element.classList.remove(value);
		}
	}
	return this;
};
var globalZIndex;
/**
 * 统一zindex值, 不同控件每次显示时都取最大的zindex，防止显示错乱
 */
var getZIndex = function() {
	if(!globalZIndex) {
		globalZIndex = 2000;
	}
	return globalZIndex++;
};
var makeDOM = function(htmlString) {
	var tempDiv = document.createElement("div");
	tempDiv.innerHTML = htmlString;
	var _dom = tempDiv.children[0];
	return _dom;
};
/**
 * element
 */
var makeModal = function(element, parEle) {
	var overlayDiv = document.createElement('div');
	$(overlayDiv).addClass('u-overlay');
	overlayDiv.style.zIndex = getZIndex();
	// 如果有父元素则插入到父元素上，没有则添加到body上
	if(parEle && parEle != document.body) {
		addClass(overlayDiv, 'hasPar');
		parEle.appendChild(overlayDiv);
	} else {
		document.body.appendChild(overlayDiv);
	}
	$('.u-overlay').css('display',"none");
	$('.u-overlay:eq(0)').css('display',"block");

	element.style.zIndex = getZIndex();
	on(overlayDiv, 'click', function(e) {
		stopEvent(e);
	});
	return overlayDiv;
};

/**
 * Module : Sparrow util tools
 * Author : Kvkens(yueming@yonyou.com)
 * Date	  : 2016-07-27 21:46:50
 */

/**
 * 创建一个带壳的对象,防止外部修改
 * @param {Object} proto
 */
try{
	NodeList.prototype.forEach = Array.prototype.forEach;
}catch(e){
	
}


/**
 * 获得字符串的字节长度
 */
String.prototype.lengthb = function() {
	//	var str = this.replace(/[^\x800-\x10000]/g, "***");
	var str = this.replace(/[^\x00-\xff]/g, "**");
	return str.length;
};

/**
 * 将AFindText全部替换为ARepText
 */
String.prototype.replaceAll = function(AFindText, ARepText) {
	//自定义String对象的方法
	var raRegExp = new RegExp(AFindText, "g");
	return this.replace(raRegExp, ARepText);
};

/**
 * Module : Sparrow browser environment
 * Author : Kvkens(yueming@yonyou.com)
 * Date	  : 2016-07-27 21:46:50
 */

var u$1 = {};


extend(u$1, {
	isIE:  false,
	isFF: false,
	isOpera: false,
	isChrome: false,
	isSafari: false,
	isWebkit: false,
	isIE8_BEFORE: false,
	isIE8: false,
	isIE8_CORE: false,
	isIE9: false,
	isIE9_CORE: false,
	isIE10: false,
	isIE10_ABOVE: false,
	isIE11: false,
	isEdge: false,
	isIOS: false,
	isIphone: false,
	isIPAD: false,
	isStandard: false,
	version: 0,
	isWin: false,
	isUnix: false,
	isLinux: false,
	isAndroid: false,
	isAndroidPAD:false,
	isAndroidPhone:false,
	isMac: false,
	hasTouch: false,
	isMobile: false
});

(function() {
	var userAgent = navigator.userAgent,
		rMsie = /(msie\s|trident.*rv:)([\w.]+)/,
		rFirefox = /(firefox)\/([\w.]+)/,
		rOpera = /(opera).+version\/([\w.]+)/,
		rChrome = /(chrome)\/([\w.]+)/,
		rSafari = /version\/([\w.]+).*(safari)/,
		version,
		ua = userAgent.toLowerCase(),
		s,
		browserMatch = {
			browser: "",
			version: ''
		},
		match = rMsie.exec(ua);

	if(match != null) {
		browserMatch = {
			browser: "IE",
			version: match[2] || "0"
		};
	}
	match = rFirefox.exec(ua);
	if(match != null) {
		browserMatch = {
			browser: match[1] || "",
			version: match[2] || "0"
		};
	}
	match = rOpera.exec(ua);
	if(match != null) {
		browserMatch = {
			browser: match[1] || "",
			version: match[2] || "0"
		};
	}
	match = rChrome.exec(ua);
	if(match != null) {
		browserMatch = {
			browser: match[1] || "",
			version: match[2] || "0"
		};
	}
	match = rSafari.exec(ua);
	if(match != null) {
		browserMatch = {
			browser: match[2] || "",
			version: match[1] || "0"
		};
	}

	if(userAgent.indexOf("Edge") > -1){
		u$1.isEdge = true;
	}
	if(s = ua.match(/opera.([\d.]+)/)) {
		u$1.isOpera = true;
	} else if(browserMatch.browser == "IE" && browserMatch.version == 11) {
		u$1.isIE11 = true;
		u$1.isIE = true;
	} else if(s = ua.match(/chrome\/([\d.]+)/)) {
		u$1.isChrome = true;
		u$1.isStandard = true;
	} else if(s = ua.match(/version\/([\d.]+).*safari/)) {
		u$1.isSafari = true;
		u$1.isStandard = true;
	} else if(s = ua.match(/gecko/)) {
		//add by licza : support XULRunner
		u$1.isFF = true;
		u$1.isStandard = true;
	} else if(s = ua.match(/msie ([\d.]+)/)) {
		u$1.isIE = true;
	} else if(s = ua.match(/firefox\/([\d.]+)/)) {
		u$1.isFF = true;
		u$1.isStandard = true;
	}
	if(ua.match(/webkit\/([\d.]+)/)) {
		u$1.isWebkit = true;
	}
	if(ua.match(/ipad/i)) {
		u$1.isIOS = true;
		u$1.isIPAD = true;
		u$1.isStandard = true;
	}

	if(ua.match(/iphone/i)) {
		u$1.isIOS = true;
		u$1.isIphone = true;
	}

	if((navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") || (navigator.platform == "Macintosh") || (navigator.platform == "MacIntel")) {
		//u.isIOS = true;
		u$1.isMac = true;
	}

	if((navigator.platform == "Win32") || (navigator.platform == "Windows") || (navigator.platform == "Win64")) {
		u$1.isWin = true;
	}

	if((navigator.platform == "X11") && !u$1.isWin && !u$1.isMac) {
		u$1.isUnix = true;
	}
	if((String(navigator.platform).indexOf("Linux") > -1)) {
		u$1.isLinux = true;
	}

	if(ua.indexOf('Android') > -1 || ua.indexOf('android') > -1 || ua.indexOf('Adr') > -1 || ua.indexOf('adr') > -1) {
		u$1.isAndroid = true;
	}

	u$1.version = version ? (browserMatch.version ? browserMatch.version : 0) : 0;
	if(u$1.isAndroid){
		if(window.screen.width>=768&&window.screen.width<1024){
			u$1.isAndroidPAD=true;
		}
		if(window.screen.width<=768) {
			u$1.isAndroidPhone = true;
		}
	}
	if(u$1.isIE) {
		var intVersion = parseInt(u$1.version);
		var mode = document.documentMode;
		if(mode == null) {
			if(intVersion == 6 || intVersion == 7) {
				u$1.isIE8_BEFORE = true;
			}
		} else {
			if(mode == 7) {
				u$1.isIE8_BEFORE = true;
			} else if(mode == 8) {
				u$1.isIE8 = true;
			} else if(mode == 9) {
				u$1.isIE9 = true;
				u$1.isSTANDARD = true;
			} else if(mode == 10) {
				u$1.isIE10 = true;
				u$1.isSTANDARD = true;
				u$1.isIE10_ABOVE = true;
			} else {
				u$1.isSTANDARD = true;
			}
			if(intVersion == 8) {
				u$1.isIE8_CORE = true;
			} else if(intVersion == 9) {
				u$1.isIE9_CORE = true;
			} else if(browserMatch.version == 11) {
				u$1.isIE11 = true;
			}
		}
	}
	if("ontouchend" in document) {
		u$1.hasTouch = true;
	}
	if(u$1.isIphone || u$1.isAndroidPhone)
		u$1.isMobile = true;

})();

var env = u$1;

/**
 * Module : Sparrow ripple
 * Author : Kvkens(yueming@yonyou.com)
 * Date	  : 2016-07-29 08:42:13
 */

var URipple = function URipple(element) {
    if (env.isIE8 || env.isMobile || env.isAndroidPAD || env.isIPAD) return;
    this._element = element;

    // Initialize instance.
    this.init();
  };
  //window['URipple'] = URipple;

  URipple.prototype._down = function(event) {
    if (env.isIE8 || env.isMobile || env.isAndroidPAD || env.isIPAD) return;
    if (!this._rippleElement.style.width && !this._rippleElement.style.height) {
      var rect = this._element.getBoundingClientRect();
      this.rippleSize_ = Math.sqrt(rect.width * rect.width + rect.height * rect.height) * 2 + 2;
      if(this.rippleSize_ > 0){
            this._rippleElement.style.width = this.rippleSize_ + 'px';
            this._rippleElement.style.height = this.rippleSize_ + 'px';
        }

    }

    addClass(this._rippleElement, 'is-visible');

    if (event.type === 'mousedown' && this._ignoringMouseDown) {
      this._ignoringMouseDown = false;
    } else {
      if (event.type === 'touchstart') {
        this._ignoringMouseDown = true;
      }
      var frameCount = this.getFrameCount();
      if (frameCount > 0) {
        return;
      }
      this.setFrameCount(1);
      var t = event.currentTarget || event.target || event.srcElement;
      var bound = t.getBoundingClientRect();
      var x;
      var y;
      // Check if we are handling a keyboard click.
      if (event.clientX === 0 && event.clientY === 0) {
        x = Math.round(bound.width / 2);
        y = Math.round(bound.height / 2);
      } else {
        var clientX = event.clientX ? event.clientX : event.touches[0].clientX;
        var clientY = event.clientY ? event.clientY : event.touches[0].clientY;
        x = Math.round(clientX - bound.left);
        y = Math.round(clientY - bound.top);
      }
      this.setRippleXY(x, y);
      this.setRippleStyles(true);
      if(window.requestAnimationFrame)
        window.requestAnimationFrame(this.animFrameHandler.bind(this));
    }
  };

  /**
   * Handle mouse / finger up on element.
   *
   * @param {Event} event The event that fired.
   * @private
   */
  URipple.prototype._up = function(event) {
    if (env.isIE8 || env.isMobile || env.isAndroidPAD || env.isIPAD) return;
    var self = this;
    // Don't fire for the artificial "mouseup" generated by a double-click.
    if (event && event.detail !== 2) {
      removeClass(this._rippleElement,'is-visible');
    }
    // Allow a repaint to occur before removing this class, so the animation
    // shows for tap events, which seem to trigger a mouseup too soon after
    // mousedown.
    window.setTimeout(function() {
      removeClass(self._rippleElement,'is-visible');
    }, 0);
  };

  /**
       * Getter for frameCount_.
       * @return {number} the frame count.
       */
  URipple.prototype.getFrameCount = function() {
    if (env.isIE8 || env.isMobile || env.isAndroidPAD || env.isIPAD) return;
    return this.frameCount_;
  };
  /**
       * Setter for frameCount_.
       * @param {number} fC the frame count.
       */
  URipple.prototype.setFrameCount = function(fC) {
    if (env.isIE8 || env.isMobile || env.isAndroidPAD || env.isIPAD) return;
    this.frameCount_ = fC;
  };


  /**
       * Getter for _rippleElement.
       * @return {Element} the ripple element.
       */
      URipple.prototype.getRippleElement = function() {
        if (env.isIE8 || env.isMobile || env.isAndroidPAD || env.isIPAD) return;
        return this._rippleElement;
      };

      /**
       * Sets the ripple X and Y coordinates.
       * @param  {number} newX the new X coordinate
       * @param  {number} newY the new Y coordinate
       */
      URipple.prototype.setRippleXY = function(newX, newY) {
        if (env.isIE8 || env.isMobile || env.isAndroidPAD || env.isIPAD) return;
        this.x_ = newX;
        this.y_ = newY;
      };

      /**
       * Sets the ripple styles.
       * @param  {boolean} start whether or not this is the start frame.
       */
      URipple.prototype.setRippleStyles = function(start) {
        if (env.isIE8 || env.isMobile || env.isAndroidPAD || env.isIPAD) return;
        if (this._rippleElement !== null) {
          var transformString;
          var scale;
          var size;
          var offset = 'translate(' + this.x_ + 'px, ' + this.y_ + 'px)';

          if (start) {
            scale = 'scale(0.0001, 0.0001)';
            size = '1px';
          } else {
            scale = '';
            size = this.rippleSize_ + 'px';
          }

          transformString = 'translate(-50%, -50%) ' + offset + scale;

          this._rippleElement.style.webkitTransform = transformString;
          this._rippleElement.style.msTransform = transformString;
          this._rippleElement.style.transform = transformString;

          if (start) {
            removeClass(this._rippleElement,'is-animating');
          } else {
            addClass(this._rippleElement,'is-animating');
          }
        }
      };

    /**
       * Handles an animation frame.
       */
      URipple.prototype.animFrameHandler = function() {
        if (env.isIE8 || env.isMobile || env.isAndroidPAD || env.isIPAD) return;
        if (this.frameCount_-- > 0) {
          window.requestAnimationFrame(this.animFrameHandler.bind(this));
        } else {
          this.setRippleStyles(false);
        }
      };

  /**
   * Initialize element.
   */
  URipple.prototype.init = function() {
    if (env.isIE8 || env.isMobile || env.isAndroidPAD || env.isIPAD) return;
    var self = this;
    if (this._element) {
      this._rippleElement = this._element.querySelector('.u-ripple');
      if (!this._rippleElement){
        this._rippleElement = document.createElement('span');
        addClass(this._rippleElement,'u-ripple');
        this._element.appendChild(this._rippleElement);
        this._element.style.overflow = 'hidden';
        this._element.style.position = 'relative';
      }
      this.frameCount_ = 0;
      this.rippleSize_ = 0;
      this.x_ = 0;
      this.y_ = 0;

      // Touch start produces a compat mouse down event, which would cause a
      // second ripples. To avoid that, we use this property to ignore the first
      // mouse down after a touch start.
      this._ignoringMouseDown = false;
      on(this._element, 'mousedown',function(e){self._down(e);});
      on(this._element, 'touchstart',function(e){self._down(e);});

      on(this._element, 'mouseup',function(e){self._up(e);});
      on(this._element, 'mouseleave',function(e){self._up(e);});
      on(this._element, 'touchend',function(e){self._up(e);});
      on(this._element, 'blur',function(e){self._up(e);});
    }
  };

var Ripple = URipple;

/**
 * Module : neoui-button
 * Author : Kvkens(yueming@yonyou.com)
 * Date	  : 2016-08-02 13:01:05
 */

var Button = u.BaseComponent.extend({
    init: function() {
        try {
            var rippleContainer = document.createElement('span');
            addClass(rippleContainer, 'u-button-container');
            this._rippleElement = document.createElement('span');
            addClass(this._rippleElement, 'u-ripple');
            if (env.isIE8)
                addClass(this._rippleElement, 'oldIE');
            rippleContainer.appendChild(this._rippleElement);
            on(this._rippleElement, 'mouseup', this.element.blur);
            this.element.appendChild(rippleContainer);
        } catch (e) {

        }


        // 增加disabled效果
        var disableAttr = this.element.getAttribute('disabled');
        if (disableAttr != null && disableAttr != '') {
            this.element.className += " disable";
        }

        on(this.element, 'mouseup', this.element.blur);
        on(this.element, 'mouseleave', this.element.blur);
        this.ripple = new Ripple(this.element);
    }

});

if (u.compMgr)
    u.compMgr.regComp({
        comp: Button,
        compAsString: 'u.Button',
        css: 'u-button'
    });

/**
 * Module : Sparrow cookies
 * Author : Kvkens(yueming@yonyou.com)
 * Date	  : 2016-07-27 21:46:50
 */

var getCookie = function(sName) {
	var sRE = "(?:; )?" + sName + "=([^;]*);?";
	var oRE = new RegExp(sRE);

	if(oRE.test(document.cookie)) {
		return decodeURIComponent(RegExp["$1"]);
	} else
		return null;
};

/**
 * Module : Sparrow i18n
 * Author : Kvkens(yueming@yonyou.com)
 * Date	  : 2016-07-29 10:16:54
 */
//import {uuii18n} from '?';//缺失故修改为default值
// 从datatable/src/compatiable/u/JsExtension.js抽取
window.getCurrentJsPath = function() {
	var doc = document,
	a = {},
	expose = +new Date(),
	rExtractUri = /((?:http|https|file):\/\/.*?\/[^:]+)(?::\d+)?:\d+/,
	isLtIE8 = ('' + doc.querySelector).indexOf('[native code]') === -1;
	// FF,Chrome
	if (doc.currentScript){
		return doc.currentScript.src;
	}

	var stack;
	try{
		a.b();
	}
	catch(e){
		stack = e.stack || e.fileName || e.sourceURL || e.stacktrace;
	}
	// IE10
	if (stack){
		var absPath = rExtractUri.exec(stack)[1];
		if (absPath){
			return absPath;
		}
	}

	// IE5-9
	for(var scripts = doc.scripts,
		i = scripts.length - 1,
		script; script = scripts[i--];){
		if (script.className !== expose && script.readyState === 'interactive'){
			script.className = expose;
			// if less than ie 8, must get abs path by getAttribute(src, 4)
			return isLtIE8 ? script.getAttribute('src', 4) : script.src;
		}
	}
};

if (window.i18n) {
	window.u = window.u || {};
    var scriptPath = getCurrentJsPath(),
        _temp = scriptPath.substr(0, scriptPath.lastIndexOf('/')),
        __FOLDER__ = _temp.substr(0, _temp.lastIndexOf('/')),
        resGetPath = u.i18nPath || __FOLDER__ + '/locales/__lng__/__ns__.json';
    i18n.init({
        postAsync: false,
        getAsync: false,
        fallbackLng: false,
        ns: {namespaces: ['uui-trans']},
		lng:getCookie(U_LOCALE) || 'zh',
        resGetPath: resGetPath
    });
}

var trans = function (key, dftValue) {
    return  window.i18n ?  i18n.t('uui-trans:' + key) : dftValue
};

/**
 * Module : neoui-dialog
 * Author : Kvkens(yueming@yonyou.com)
 * Date	  : 2016-08-02 15:29:55
 */

/**
 * 消息提示框
 * @param options
 */

var messageDialogTemplate = '<div class="u-msg-dialog-top" id="{id}_top">' +
    '<div class="u-msg-dialog" style="{width}{height}{top}">' +
    '<div class="u-msg-dialog-content">' +
    '<div class="u-msg-title">' +
    '<h4>{title}</h4>' +
    '</div>' +
    '<div class="u-msg-content"></div>' +
    '{footer}' +
    '</div></div>';



var messageDialogF = function(options) {

    if (typeof options === 'string') {
        options = {
            content: options
        };
    }
    var defaultOptions = {
        id: '',
        msg: '',
        template: messageDialogTemplate,
        width: '',
        height: '',
        top: '',
        hasFooter: true,
        // title: '提示',
        // btnText: '确定',
        title: trans('dialog.title', '提示'),
        btnText: trans('dialog.okText', '确定'),
        closeFun: function() {}

    };
    options = extend(defaultOptions, options);
    this.id = options['id'];
    this.hasFooter = options['hasFooter'];
    this.content = options['msg'];
    this.title = options['title'];
    this.template = options['template'];
    this.width = options['width'];
    this.height = options['height'];
    this.top = options['top'];
    this.bthText = options['btnText'];
    this.lazyShow = options['lazyShow'];
    this.closeFun = options['closeFun'];
    this.create();

    var msgDom = this.templateDom.querySelector('.u-msg-dialog');
    if (this.height) {
        this.resizeFun = function() {
            var cDom = msgDom.querySelector('.u-msg-content');
            if (!cDom) return;
            cDom.style.height = '';
            var wholeHeight = msgDom.offsetHeight;
            var contentHeight = msgDom.scrollHeight;
            // if(contentHeight > wholeHeight && cDom)
            cDom.style.height = wholeHeight - (56 + 46) + 'px';
        }.bind(this);

        this.resizeFun();
        on(window, 'resize', this.resizeFun);
    }
};

messageDialogF.prototype.create = function() {
    var self = this,
        closeStr = '';
    if (this.hasFooter) {
        var footerStr = '<div class="u-msg-footer only-one-btn"><button class="u-msg-ok u-button u-button-primary raised">' + this.bthText + '</button></div>' +
            '</div>';
    }
    var templateStr = this.template.replace('{id}', this.id).replace('{id}', this.id);
    templateStr = templateStr.replace('{width}', this.width ? 'width:' + this.width + ';' : '');
    templateStr = templateStr.replace('{height}', this.height ? 'height:' + this.height + ';' : '');
    templateStr = templateStr.replace('{top}', this.top ? 'top:' + this.top + ';' : '');
    templateStr = templateStr.replace('{title}', this.title);
    templateStr = templateStr.replace('{footer}', footerStr);
    var htmlReg = /^(\s*)?<[a-zA-Z]+/ig;
    var selectReg = /^(\.|#)/;
    if (htmlReg.test(this.content)) {
        this.contentDom = makeDOM(this.content);
        this.contentDomParent = this.contentDom.parentNode;
        this.contentDom.style.display = 'block';
    } else if (selectReg.test(this.content)) {
        this.contentDom = document.querySelector(this.content);
        this.contentDomParent = this.contentDom.parentNode;
        this.contentDom.style.display = 'block';
    } else {
        this.contentDom = makeDOM('<p>' + this.content + '</p>');
    }
    this.templateDom = makeDOM(templateStr);


    this.templateDom.querySelector('.u-msg-content').appendChild(this.contentDom);
    this.overlayDiv = makeModal(this.templateDom);

    this.okDiv = this.templateDom.querySelector('.u-msg-ok');
    on(this.okDiv, 'click', function() {
        self.close();
    });

    if (this.lazyShow) {
        this.templateDom.style.display = 'none';
        this.overlayDiv.style.display = 'none';
    }
    document.body.appendChild(this.templateDom);
    disable_mouseWheel();
    this.isClosed = false;
};

messageDialogF.prototype.close = function() {
    this.closeFun && this.closeFun.call(this);
    if (this.contentDom) {
        this.contentDom.style.display = 'none';
        this.contentDomParent && this.contentDomParent.appendChild(this.contentDom);
    }
    document.body.removeChild(this.templateDom);
    document.body.removeChild(this.overlayDiv);
    this.isClosed = true;
    enable_mouseWheel();
};

/**
 * Module : confirmDialog
 * Author : Kvkens(yueming@yonyou.com)
 * Date	  : 2016-07-29 10:21:33
 */
var confirmDialogTemplate = '<div class="u-msg-dialog-top" id="{id}_top">' +
    '<div class="u-msg-dialog" style="{width}{height}{top}">' + '<div class="u-msg-dialog-content">' +
    '<div class="u-msg-title">' +
    '<h4>{title}</h4>' +
    '</div>' +
    '<div class="u-msg-content">' +
    '</div>' +
    '{footer}' +
    '</div></div>';



var confirmDialogF = function(options) {
    if (typeof options === 'string') {
        options = {
            content: options
        };
    }
    var defaultOptions = {
        id: '',
        msg: '',
        template: confirmDialogTemplate,
        width: '',
        height: '',
        top: '',
        hasFooter: true,
        onOk: function() {},
        onCancel: function() {},
        okText: trans('dialog.okText', '确定'),
        cancelText: trans('dialog.cancelText', '取消')
    };

    options = extend(defaultOptions, options);
    this.id = options['id'];
    this.hasFooter = options['hasFooter'];
    this.content = options['msg'];
    this.template = options['template'];
    this.width = options['width'];
    this.height = options['height'];
    this.height = options['top'];
    this.title = options['title'];
    this.titleIcon = options['titleIcon'];
    this.lazyShow = options['lazyShow'];
    this.onOk = options['onOk'];
    this.onCancel = options['onCancel'];
    this.okText = options['okText'];
    this.cancelText = options['cancelText'];
    this.create();

    var msgDom = this.templateDom.querySelector('.u-msg-dialog');

    if (this.height) {
        this.resizeFun = function() {
            var cDom = msgDom.querySelector('.u-msg-content');
            if (!cDom) return;
            cDom.style.height = '';
            var wholeHeight = msgDom.offsetHeight;
            var contentHeight = msgDom.scrollHeight;
            // if(contentHeight > wholeHeight && cDom)
            cDom.style.height = wholeHeight - (56 + 46) + 'px';

        }.bind(this);

        this.resizeFun();
        on(window, 'resize', this.resizeFun);
    }

};

confirmDialogF.prototype.create = function() {
    var footerStr = '',
        oThis = this;
    if (this.hasFooter) {
        var footerStr = '<div class="u-msg-footer"><button class="u-msg-ok u-button u-button-primary raised">{okText}</button><button class="u-msg-cancel u-button u-grey">{cancelText}</button></div>' +
            '</div>';
    }
    var templateStr = this.template.replace('{id}', this.id).replace('{id}', this.id);
    templateStr = templateStr.replace('{title}', this.title);
    templateStr = templateStr.replace('{width}', this.width ? 'width:' + this.width + ';' : '');
    templateStr = templateStr.replace('{height}', this.height ? 'height:' + this.height + ';' : '');
    templateStr = templateStr.replace('{top}', this.top ? 'top:' + this.top + ';' : '');
    templateStr = templateStr.replace('{footer}', footerStr);
    templateStr = templateStr.replace('{okText}', this.okText);
    templateStr = templateStr.replace('{cancelText}', this.cancelText);
    var htmlReg = /^(\s*)?<[a-zA-Z]+/ig;
    var selectReg = /^(\.|#)/;
    if (htmlReg.test(this.content)) {
        this.contentDom = makeDOM(this.content);
        this.contentDomParent = this.contentDom.parentNode;
        this.contentDom.style.display = 'block';
    } else if (selectReg.test(this.content)) {
        this.contentDom = document.querySelector(this.content);
        this.contentDomParent = this.contentDom.parentNode;
        this.contentDom.style.display = 'block';
    } else {
        this.contentDom = makeDOM('<p>' + this.content + '</p>');
    }
    /*头部只用图标 <a><i class="uf uf-"></i></a>*/
    // this.titleIconDom = makeDOM('<a><i class="' + this.titleIcon + '"></i></a>');
    this.templateDom = makeDOM(templateStr);

    // this.templateDom.querySelector('.u-msg-title').appendChild(this.titleIconDom);
    this.templateDom.querySelector('.u-msg-content').appendChild(this.contentDom);
    this.overlayDiv = makeModal(this.templateDom);

    if (this.lazyShow) {
        this.templateDom.style.display = 'none';
        this.overlayDiv.style.display = 'none';
    }

    if (this.hasFooter) {
        var okBtn = this.templateDom.querySelector('.u-msg-ok');
        var cancelBtn = this.templateDom.querySelector('.u-msg-cancel');
        var closeBtn =
            new Button({
                el: okBtn
            });
        new Button({
            el: cancelBtn
        });
        on(okBtn, 'click', function() {
            if (oThis.onOk() !== false) {
                oThis.close();
            }
        });
        on(cancelBtn, 'click', function() {
            if (oThis.onCancel() !== false) {
                oThis.close();
            }
        });
    }

    document.body.appendChild(this.templateDom);
    disable_mouseWheel();
    this.isClosed = false;
};

confirmDialogF.prototype.close = function() {
    document.body.removeChild(this.templateDom);
    document.body.removeChild(this.overlayDiv);
    this.isClosed = true;
    enable_mouseWheel();
};

/**
 * 禁用鼠标滚轮事件
 * @return {[type]} [description]
 */
var disable_mouseWheel = function() {
    document.body.style.paddingRight = '17px';
    document.body.style.overflow = 'hidden';
};
/**
 * 开启鼠标滚轮事件
 * @return {[type]} [description]
 */
var enable_mouseWheel = function() {
    document.body.style.paddingRight = '';
    document.body.style.overflow = '';
};

/**
 * dialog.js
 */



var dialogTemplate = '<div class="u-msg-dialog-top" id="{id}_top">' +
    '<div class="u-msg-dialog" id="{id}" style="{width}{height}">' +
    '{close}' +
    '<div class="u-msg-dialog-content"></div>' +
    '</div></div>';

var dialogMode = function(options) {
    // 传入字符串的情况直接将字符串作为内容显示
    if (typeof options === 'string') {
        options = {
            content: options
        };
    }
    var defaultOptions = {
        id: '',
        content: '',
        hasCloseMenu: true,
        template: dialogTemplate,
        width: '',
        height: '',
        is_drag: false
    };

    options = extend(defaultOptions, options);
    this.id = options['id'];
    this.hasCloseMenu = options['hasCloseMenu'];
    this.content = options['content'];
    this.template = options['template'];
    this.width = options['width'];
    this.height = options['height'];
    this.lazyShow = options['lazyShow'];
    this.closeFun = options['closeFun'];
    this.is_drag = options['is_drag'];
    this.create();
    if (this.is_drag) {
        this.drag();
    }

    var msgDom = this.templateDom.querySelector('.u-msg-dialog');

    if (this.height) {
        this.resizeFun = function() {
            var cDom = msgDom.querySelector('.u-msg-content');
            if (!cDom) return;
            cDom.style.height = '';
            var wholeHeight = msgDom.offsetHeight;
            var contentHeight = msgDom.scrollHeight;
            // if(contentHeight > wholeHeight && cDom)
            cDom.style.height = wholeHeight - (56 + 46) + 'px';

        }.bind(this);

        this.resizeFun();
        on(window, 'resize', this.resizeFun);
    }
};

dialogMode.prototype.create = function() {
    var closeStr = '',
        oThis = this;
    if (this.hasCloseMenu) {
        var closeStr = '<div class="u-msg-close"> <span aria-hidden="true">&times;</span></div>';
    }
    var templateStr = this.template.replace('{id}', this.id).replace('{id}', this.id);
    templateStr = templateStr.replace('{close}', closeStr);
    templateStr = templateStr.replace('{width}', this.width ? 'width:' + this.width + ';' : '');
    templateStr = templateStr.replace('{height}', this.height ? 'height:' + this.height + ';' : '');

    var htmlReg = /^(\s*)?<[a-zA-Z]+/ig;
    var selectReg = /^(\.|#)/;
    if (htmlReg.test(this.content)) {
        this.contentDom = makeDOM(this.content);
        this.contentDomParent = this.contentDom.parentNode;
        this.contentDom.style.display = 'block';
    } else if (selectReg.test(this.content)) {
        this.contentDom = document.querySelector(this.content);
        this.contentDomParent = this.contentDom.parentNode;
        this.contentDom.style.display = 'block';
    } else {
        this.contentDom = makeDOM('<div><div class="u-msg-content"><p>' + this.content + '</p></div></div>');
    }
    this.templateDom = makeDOM(templateStr);


    this.templateDom.querySelector('.u-msg-dialog-content').appendChild(this.contentDom);
    this.overlayDiv = makeModal(this.templateDom);
    if (this.hasCloseMenu) {
        this.closeDiv = this.templateDom.querySelector('.u-msg-close');
        on(this.closeDiv, 'click', function() {
            oThis.close();
        });
    }
    if (this.lazyShow) {
        this.templateDom.style.display = 'none';
        this.overlayDiv.style.display = 'none';
    }
    document.body.appendChild(this.templateDom);
    disable_mouseWheel();
    this.isClosed = false;
};
dialogMode.prototype.drag = function() {
    var oThis = this,
        $this = $(oThis.content).closest('.u-msg-dialog'),
        _move = false, //移动标记
        _x, _y; //鼠标离控件左上角的相对位置
    $this.mousedown(function(e) {
        var offset = $this.offset(),
            m_left = e.pageX,
            m_top = e.pageY,
            d_left = offset.left,
            d_top = offset.top;
        _move = true;
        _x = e.pageX - parseInt($this.css("left"));
        _y = e.pageY - parseInt($this.css("top"));
    });
    $this.mousemove(function(e) {
        if (_move) {
            var x = e.pageX - _x; //移动时根据鼠标位置计算控件左上角的绝对位置
            var y = e.pageY - _y;
            $this.css({
                top: y,
                left: x
            }); //控件新位置
        }
    }).mouseup(function() {
        _move = false;
    });
};

dialogMode.prototype.show = function() {
    if (this.isClosed) {
        this.create();
    }
    this.templateDom.style.display = 'block';
    this.overlayDiv.style.display = 'block';
    disable_mouseWheel();
};

dialogMode.prototype.hide = function() {
    this.templateDom.style.display = 'none';
    this.overlayDiv.style.display = 'none';
    enable_mouseWheel();
};

dialogMode.prototype.close = function() {
    this.closeFun && this.closeFun.call(this);
    if (this.contentDom) {
        this.contentDom.style.display = 'none';
        this.contentDomParent && this.contentDomParent.appendChild(this.contentDom);
    }
    document.body.removeChild(this.templateDom);
    try {
        document.body.removeChild(this.overlayDiv);
    } catch (e) {

    }

    this.isClosed = true;
    enable_mouseWheel();
};



var dialog = function(options) {
    return new dialogMode(options);
};

/**
 * Module : iframeDialog
 * Author : wh(wanghaoo@yonyou.com)
 * Date	  : 2016-09-8 9:33
 */
var iframeDialogTemplate = '<div class="u-msg-dialog u-iframe-dialog" style="{width}{height}{top}">' +
    '{close}' +
    '<div class="u-msg-title">' +
    '<h4>{title}</h4>' +
    '</div>' +
    '<div class="u-msg-content">' +
    '<iframe src="{url}" width = "99%" height ="100%"></iframe>' +
    '</div>' +
    '{footer}';



// '<div class="u-msg-title">' +
// '<h4>{title}</h4>' +
// '</div>' +
// '<div class="u-msg-content">' +

// '</div>' +
// '<div class="u-msg-footer"><button class="u-msg-ok u-button primary raised">{okText}</button><button class="u-msg-cancel u-button">{cancelText}</button></div>' +
// '</div>';

var iframeDialogF = function(options) {

    var defaultOptions = {
        hasCloseMenu: true,
        hasFooter: false,
        url: '',
        width: '',
        height: '',
        title: '标题',
        top: '10%',
        onClose: function() {},
        onCancel: function() {},
        onOk: function() {}
    };

    options = extend(defaultOptions, options);
    this.id = options['id'];
    this.template = iframeDialogTemplate;
    this.hasCloseMenu = options['hasCloseMenu'];
    this.hasFooter = options['hasFooter'];
    this.url = options['url'];
    this.top = options['top'];
    this.title = options['title'];
    this.width = options['width'];
    this.height = options['height'];
    this.onClose = options['onClose'];
    this.onOk = options['onOk'];
    this.onCancel = options['onCancel'];
    //是否有url，没有url直接跳出
    if (!this.url) {
        return;
    }

    this.create();

    this.resizeFun = function() {
        // var cDom = this.contentDom.querySelector('.u-msg-content');
        // cDom.style.height = '';
        // var wholeHeight = this.templateDom.offsetHeight;
        // var contentHeight = this.contentDom.offsetHeight;
        // if(contentHeight > wholeHeight && cDom)
        // 	cDom.style.height = wholeHeight - (56 + 46) + 'px';

        var wholeHeight = this.templateDom.offsetHeight;
        var cDom = this.templateDom.querySelector('.u-msg-content');
        if (this.hasFooter) {
            cDom.style.height = wholeHeight - (56 + 52) + 'px';
        } else {
            cDom.style.height = wholeHeight - 52 + 'px';
        }

    }.bind(this);

    this.resizeFun();
    on(window, 'resize', this.resizeFun);

};

iframeDialogF.prototype.create = function() {
    var closeStr = '',
        footerStr = '';
    var oThis = this;
    if (this.hasCloseMenu) {
        var closeStr = '<div class="u-msg-close"> <span aria-hidden="true">&times;</span></div>';
    }
    if (this.hasFooter) {
        var footerStr = '<div class="u-msg-footer"><button class="u-msg-ok u-button u-button-primary raised">确定</button><button class="u-msg-cancel u-button">取消</button></div>' +
            '</div>';
    }
    var templateStr = this.template.replace('{close}', closeStr);
    templateStr = templateStr.replace('{url}', this.url);
    templateStr = templateStr.replace('{title}', this.title);
    templateStr = templateStr.replace('{footer}', footerStr);
    templateStr = templateStr.replace('{width}', this.width ? 'width:' + this.width + ';' : '');
    templateStr = templateStr.replace('{height}', this.height ? 'height:' + this.height + ';' : '');
    templateStr = templateStr.replace('{top}', this.top ? 'top:' + this.top + ';' : '');

    this.templateDom = makeDOM(templateStr);
    this.overlayDiv = makeModal(this.templateDom);



    if (this.hasCloseMenu) {
        this.closeDiv = this.templateDom.querySelector('.u-msg-close');
        on(this.closeDiv, 'click', function() {
            if (oThis.onClose() !== false) {
                oThis.close();
            }
        });
    }

    if (this.hasFooter) {
        var okBtn = this.templateDom.querySelector('.u-msg-ok');
        var cancelBtn = this.templateDom.querySelector('.u-msg-cancel');
        var closeBtn =
            new Button({
                el: okBtn
            });
        new Button({
            el: cancelBtn
        });
        on(okBtn, 'click', function() {
            if (oThis.onOk() !== false) {
                oThis.close();
            }
        });
        on(cancelBtn, 'click', function() {
            if (oThis.onCancel() !== false) {
                oThis.close();
            }
        });
    }

    document.body.appendChild(this.templateDom);
    this.isClosed = false;
};



iframeDialogF.prototype.close = function() {


    document.body.removeChild(this.templateDom);
    document.body.removeChild(this.overlayDiv);
    this.isClosed = true;


};

/**
 * Module : neoui-refer
 * Author : Kvkens(yueming@yonyou.com)
 * Date	  : 2016-08-03 11:29:40
 */
var Refer = function (options) {
    this.options = extend({}, Refer.DEFAULTS, options);
    var contentId = this.options['contentId'];
    // if (isEmptyObject(contentId))
    //     throw new Error('contentId is null');
    this.params = this.options['params'];
    this.create();
    this.loaded = false;
};

Refer.DEFAULTS = {
    isPOPMode: true,
    searchInput: null,
    contentId: 'referWrap',
    okId: 'okBtn',//暂时没用
    cancelId: 'cancelBtn',//暂时没用
    width: null,
    height: null,
    title: '参照',
    setVal: function () {
    },
    onOk: function () {
    },
    onCancel: function () {
    }
};

Refer.fn = Refer.prototype;

Refer.fn.create = function () {
    var self = this;
    self.setVal = this.options.setVal;
    self.searchInput = this.options.searchInput;

    var prefixID = this.options.contentId.replace(/[^\w\s]/gi, '\\$&');
    if (!this.options.isPOPMode) {
        //TODO 后续支持非弹窗模式

        //if ($('#' + this.options.contentId).length === 0) {
        //    $('body').append($('<div>').attr('id', this.options.contentId));
        //}
        //this.$contentEle = $('#' + prefixID)
        //this.$okBtn = $('#' + prefixID + this.options.okId)
        //this.$cancelBtn = $('#' + prefixID + this.options.cancelId)
    } else {
        var dialog$$1 = document.querySelector('#' + prefixID);
        self.isDefaultDialog = true;
        if (dialog$$1 == null) {
            //var d = document.createElement('DIV')
            //d.innerHTML = '<div class="modal" id="' + prefixID + '"><div class="modal-dialog"><div class="modal-content">' + '<div class="modal-header"><h4 class="modal-title">Modal title</h4></div>' + '<div class="modal-body"></div><div class="modal-footer">' + '<button   type="button" class="btn btn-primary okBtn">确定</button>' + '<button  type="button" class="btn btn-default cancelBtn" data-dismiss="modal">取消</button></div></div></div></div>'
            dialog$$1 = makeDOM('	<div style="display:none;height:100%" id="' + prefixID + '">' +
                    '<div class="u-msg-title"><h4 class="title">单据名称</h4></div>' +
                    '<div class="u-msg-content">' +
                        '<div class="content"></div>' +
                    '</div>' +
                    '<div class="u-msg-footer">' +
                        '<button class="u-msg-ok u-button">'+ trans('public.confirm','确定') +'<span class="u-button-container"><span class="u-ripple"></span></span></button>' +
                        '<button class="u-msg-cancel u-button">' + trans('public.cancel','取消') + '<span class="u-button-container"><span class="u-ripple"></span></span></button>' +
                    '</div>' +
                '</div>');
            document.body.appendChild(dialog$$1);
            //dialog = document.body.querySelector('#' + prefixID);
        }
        //this.$contentEle = dialog.find('.modal-body');
        this.titleDiv =dialog$$1.querySelector('.title');
        this.contentDiv = dialog$$1.querySelector('.content');
        this.okBtn = dialog$$1.querySelector('.u-msg-ok');
        this.cancelBtn = dialog$$1.querySelector('.u-msg-cancel');
        this.dialog = dialog$$1;
        //if (this.options.width)
        //    dialog.find('.modal-content').css('width', this.options.width)
        //if (this.options.height)
        //    this.$contentEle.css('height', this.options.height)
        //this.dialog.find('.modal-title').html(this.options.title)
        this.titleDiv.innerHTML = this.options.title;

    }
    on(this.okBtn, 'click', function(){
        self.submit();
    });

    on(this.cancelBtn, 'click', function(){
        self.cancel();
    });
};


Refer.fn.submit = function () {
    var data = this.submitData();
    this.options.onOk(data);
    Plugin.destroy(this);
};

Refer.fn.cancel = function () {
    this.options.onCancel();
    Plugin.destroy(this);
};

Refer.fn.open = function () {
    var self = this;
    if (self.isDefaultDialog) {
        var opt = {id:this.options.contentId,content:'#' + this.options.contentId,hasCloseMenu:true};
        if (this.options.height)
            opt.height = this.options.height;
        if (this.options.width)
            opt.width = this.options.width;
        self.modalDialog = dialog(opt);
        //self.dialog.modal('show')
    }
    if (this.options['module']){
        self.contentDiv.innerHTML = this.options['module'].template;
        this.options['module'].init ? this.options['module'].init(self) : '';
    }
    else if(require){
       require([this.options.pageUrl], function(module) {
           self.contentDiv.innerHTML =  module.template;
           module.init ? module.init(self) : '';
           self.loaded = true;
       });
    }
};

/**
 * 参照页面中需注册此方法
 */
Refer.fn.registerSubmitFunc = function (func) {
    this.submitData = func;
};

Refer.fn.submitData = function () {
};

var Plugin = function (options) {
    var r = new Refer(options);

    Plugin.addRefer(r);
    r.open();
    return r
};

Refer.fn.destroy = function () {
    if (this.dialog) {
        if (this.isDefaultDialog) {
            //this.dialog.modal('hide');
//	            this.dialog.modal('removeBackdrop');
            this.modalDialog.close();
        }
        //this.dialog.parent().remove();
        this.dialog.parentElement.removeChild(this.dialog);
    }
    delete this.options;
};

/**
 * 参照实列
 */
Plugin.instances = {};

Plugin.openRefer = function (options) {
    var r = new Refer(options);
    Plugin.addRefer(r);
    r.open();
};

Plugin.getRefer = function (id) {
    return Plugin.instances[id]
};

Plugin.addRefer = function (refer) {
    Plugin.instances[refer.options.id] = refer;
};

Plugin.destroy = function (refer) {
    var r = Plugin.instances[refer.options.id];
    delete Plugin.instances[refer.options.id];
    r.destroy();
};

var refer = Plugin;

exports.refer = refer;

}((this.bar = this.bar || {})));
