页面树结构

版本比较

标识

  • 该行被添加。
  • 该行被删除。
  • 格式已经改变。

...

代码块
languagejs
linenumberstrue
QueryView.prototype.appendHandlers = function(handlerList) {
	if (!handlerList || !handlerList.length)
		return;
	this.processTemplate(this.panel);
	var parentElem = this.elemToolbarTr;
	var title2text = {
		'透视分析' : '透视',
		'' : ''
	};
	if (!this.handlers) {
		this.handlers = [];
	}
	for ( var i = 0, len = handlerList.length; i < len; i++) {
		var clz = null;
		try {
			clz = jsloader.resolve(handlerList[i].className);
		} catch (e) {
			continue;
		}
		var handler = new clz(this);
		this.handlers.push(handler);
		if ("function" != typeof handler.readConfig)
			continue;
		var config = handler.readConfig();
		var items = config && config.toolbar && config.toolbar.items;
		if (!items)
			continue;
		for ( var j = 0, lenj = items.length; j < lenj; j++) {
			var item = items[j];
			var bofid = item.bofid;
			var image = item.image;
			if (!bofid || !image)
				continue; // 不指定bofid或image的忽略
			if (this.getElementByBofid(bofid))
				continue; // 对于bofid重复的忽略
			if (jsloader.getLang() == "en") {
				continue;
			}
			var isSpace = (image == "img/banner/toolbar_tab_space.gif");
			var beforeElem = this.getElementByBofid(item.before
					|| "toolbarLastTd");
			var tdElem = document.createElement("td");
			tdElem.noWrap = true;
			parentElem.insertBefore(tdElem, beforeElem);
			var itemElem = null;
			if (isSpace) {
				itemElem = document.createElement("span");
				itemElem.className = "queryview-toolbar-space";
			} else {
				tdElem.className = 'queryview-toolbar-button-normal';
				itemElem = document.createElement("input");
				itemElem.type = "button";
				itemElem.className = "queryview-toolbar-button";
				itemElem.style.background = "url(" + image
						+ ") no-repeat left center";
				this.addBtnClickListener(handler, item.command, itemElem);
			}
			tdElem.appendChild(itemElem);
			if ((item.visible === false)
					|| (item.functionCode && !util
							.checkFunctionValid(item.functionCode))) {
				tdElem.style.display = "none";
			}
			for ( var k in item) {
				if (k == "image" || k == "before") {
					continue;
				}
				itemElem.setAttribute(k, item[k]);
			}
			var propName = this.getPropNameByBofid(bofid);
			this[propName] = itemElem;
			//
			var title = itemElem.title;
			if (!title || itemElem.tagName != 'INPUT'
					|| itemElem.type != 'button') {
				continue;
			}
			itemElem.value = title2text[title] || title;
			itemElem.style.backgroundPositionX = 'left';
			itemElem.style.paddingLeft = '20px';
 
			//修改宽度为auto实现宽度自适应
			itemElem.style.width = 'auto';
		}
		if ("function" == typeof handler.initItemsVisible)
			handler.initItemsVisible();
	}
};

示例工程源码

ThemeJumpQueryViewHandler.rar