How to use the base/1.0.x/.mix function in base

To help you get started, we’ve selected a few base examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github heeroluo / jraiser / ajax / 1.1.x / index-debug.js View on Github external
send: function(url, opts) {
		// 重载,允许把url写到opts中
		if (typeof url !== 'string') {
			opts = url;
			url = opts.url;
		}
		if (opts.dataType) { opts.dataType = opts.dataType.toLowerCase(); }

		if (opts.dataType === 'jsonp') {
			return this.jsonp( url, base.mix({ }, opts, {
				whiteList: ['callbackName', 'onsuccess', 'oncomplete', 'data', 'charset', 'nocache'],
				ignoreNull: true
			}) );
		}

		// readystatechange回调函数
		var onreadystatechange = function(e, statusText) {
			var readyState = xhr.readyState;
			if (readyState !== 4 && !statusText) { return; }

			var status = readyState === 4 ? xhr.status : 0, evtType;
			if ( (status >= 200 && status < 300) || status === 1223 || status === 304 ) {
				evtType = 'onsuccess';
				statusText = 'success';
			} else if (status || statusText) { // 忽略status为0的情况
				evtType = 'onerror';
github heeroluo / jraiser / widget / 1.0.x / index-debug.js View on Github external
function create(body, methods, defaultOptions, parentClass) {
	parentClass = parentClass || WidgetBase;

	// 继承父类的默认设置
	if (parentClass && parentClass.defaultOptions) {
		defaultOptions = base.mix(defaultOptions || { }, parentClass.defaultOptions, {
			overwrite: false
		});
	}

	var extendOptions = function(options) {
		return base.extend({ }, defaultOptions, options);
	};

	var trueClass = base.createClass(function(options) {
		// disabled参数,兼容原来的enable
		if ( options && ('enable' in options) ) {
			options.disabled = !options.enable;
			delete options.enable;
		}

		options = this._options = extendOptions(options);
github heeroluo / jraiser / dialogbox / 1.0.x / index-debug.js View on Github external
return widget.create(function(options) {
	var t = this, wrapper = t._wrapper = options.wrapper;

	// 修正从PopupLayer继承而来的内部属性
	t._popupContent = wrapper;
	delete t._popupTrigger;

	// 创建固定定位组件
	if (options.fixedLayer) {
		t._fixedLayer = new FixedLayer( base.mix({
			wrapper: wrapper,
			disabled: true
		}, options.fixedLayer, { overwrite: false }) );
	}
	// 创建拖动功能组件
	if (options.draggable) {
		t._draggable = new Draggable( base.mix({
			wrapper: wrapper,
			disabled: true
		}, options.draggable, { overwrite: false }) );

		if (t._fixedLayer) {
			// 开始拖动时暂停固定定位,停止拖动后重新定位
			t._draggable.on('dragstart', function() {
				t._fixedLayer.destroy();
			}).on('dragend', function() {
github heeroluo / jraiser / dom / 1.0.x / dom-event-debug.js View on Github external
if (options.allowRepeated === false) {
			// 检查重复
			for (var i = spaceByType.length - 1; i >= 0; i--) {
				if (spaceByType[i].handler === fn &&
					spaceByType[i].bindType === bindType) { return; }
			}
		}
	} else {
		space[bindType] = [ ];
		addEvent(node, bindType, globalHandler);
	}

	// 移除冗余数据
	delete options.allowRepeated;

	space[bindType].push( base.mix({
		handler: fn,
		bindType: type,
		handle: hook ? hook.handle : null
	}, options, {
		overwrite: false
	}) );
}
github heeroluo / jraiser / dialogbox / 1.0.x / index-debug.js View on Github external
var t = this, wrapper = t._wrapper = options.wrapper;

	// 修正从PopupLayer继承而来的内部属性
	t._popupContent = wrapper;
	delete t._popupTrigger;

	// 创建固定定位组件
	if (options.fixedLayer) {
		t._fixedLayer = new FixedLayer( base.mix({
			wrapper: wrapper,
			disabled: true
		}, options.fixedLayer, { overwrite: false }) );
	}
	// 创建拖动功能组件
	if (options.draggable) {
		t._draggable = new Draggable( base.mix({
			wrapper: wrapper,
			disabled: true
		}, options.draggable, { overwrite: false }) );

		if (t._fixedLayer) {
			// 开始拖动时暂停固定定位,停止拖动后重新定位
			t._draggable.on('dragstart', function() {
				t._fixedLayer.destroy();
			}).on('dragend', function() {
				t._fixedLayer.reposition();
			});
		}
	}
}, {
	_init: function() {
github heeroluo / jraiser / slideshow / 1.0.x / index-debug.js View on Github external
function genAnimateOptions(e) {
	var t = this;

	return base.mix(e ? {
		callback: function() {
			delete t._showing;
			/**
			 * 内容项显示完毕后触发
			 * @event completeshow
			 * @for SlideShow
			 */
			t.trigger('completeshow', e);
		}
	} : { }, t._options.animation, {
		overwrite: false
	});
}
github heeroluo / jraiser / draggable / 1.0.x / index-debug.js View on Github external
if (boundary.top != null && newOffset.top < boundary.top) {
					newPos.top = boundary.top - parentOffset.top;
				}
			}

			t._wrapper.css(newPos);
			t._oldPos = newPos;

			/**
			 * 拖动到新位置后触发
			 * @event drag
			 * @for Draggable
			 * @param {Object} e 事件对象
			 *   @param {Object} e.position 新位置(top、left)
			 */
			t.trigger('drag', base.mix({
				position: newPos
			}, e, {
				overwrite: false
			}));
		};
github heeroluo / jraiser / slideshow / 1.0.x / pager-debug.js View on Github external
select: function(i, e) {
		var t = this;
		t._triggerIndex = i;

		t.trigger('select', base.mix({
			newIndex: i % t._total,
			oldIndex: t._current
		}, e, { overwrite: false }));
	},
github heeroluo / jraiser / overlayer / 1.0.x / index-debug.js View on Github external
var overlayer = t._overlayer;
		if (overlayer) {
			if (visible) { t.adjustSize(); }

			var fade = t._options.fade;
			if (fade) {
				if (visible) {
					overlayer.css({
						opacity: 0,
						display: 'block'
					});
				}
				overlayer.animate({
					opacity: visible ? t._options.opacity : 0,
					display: visible ? 'block' : 'none'
				}, base.mix({
					callback: function() {
						t._actionDone(visible);
					}
				}, fade, {
					overwrite: false
				}));
			} else {
				overlayer[visible ? 'show' : 'hide']();
				t._actionDone(visible);
			}
		}
	},
github heeroluo / jraiser / popuplayer / 1.0.x / index-debug.js View on Github external
* @event beforeclose
		 * @for PopupLayer
		 * @param {Object} e 事件对象
		 *   @param {Function} e.preventDefault() 如果调用了此方法,则层不会关闭
		 */
		var t = this, e = t.trigger(isPopup ? 'beforepopup' : 'beforeclose');

		if ( !e.isDefaultPrevented() ) {
			var animation = t._options.animation,
				styleName = isPopup ? 'popupStyle' : 'closedStyle',
				style = t['_' + styleName];

			t._computeStyle(styleName);

			if (animation) {
				t._popupContent.animate( style, base.mix({
					callback: t._actionDone.bind(t, isPopup)
				}, animation, { overwrite: false }) );
			} else {
				t._popupContent.css(style);
				t._actionDone(isPopup);
			}
		}
	},