⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 paneset-globals.js

📁 zapatec suite 最新版 20070204,非常棒的ajax widgets 工具包
💻 JS
字号:
//$Id: paneset-globals.js 6238 2007-02-09 19:59:42Z slip $//Global refference to the template of vertical dividerZapatec.PaneSet.vDivider = null;//Global refference to the template of horizontal dividerZapatec.PaneSet.hDivider = null;/** * Loads and parses data according to its type.  * @param params {object} object with following  * possible properties: * - from {mixed} - depending on type this is representation * of data needed to be loaded and parsed. * - type {string} - all data types we support, see Zapatec.Widget comments. * - onSuccess {function} - callback to be called on success. * - onFailure {function} - callback to be called on failure. * - paneSet {object} - PaneSet that called the function. */Zapatec.PaneSet.loadPanesObject = function(params) {	//we will always return null for wrong arguments passed!	if (typeof params != "object") {		return false;	}	switch (params.type) {		case "html" : {			return Zapatec.PaneSet.loadHtml(params);		}		case "html/text" : {			return Zapatec.PaneSet.loadHtmlText(params);		}		case "html/url" : {			return Zapatec.PaneSet.loadHtmlUrl(params);		}		case "json" : {			return Zapatec.PaneSet.loadJsonObject(params);		}		case "json/url" : {			return Zapatec.PaneSet.loadJsonUrl(params);		}		case "xml" : {			return Zapatec.PaneSet.loadXml(params);		}		case "xml/url" : {			return Zapatec.PaneSet.loadXmlUrl(params);		}		default : {			return null;		}	}};/** * Creates a "panes" object from DOM object. * @param params {object} object with following  * possible properties: * - from {mixed} - depending on type this is representation * of data needed to be loaded and parsed. * - onSuccess {function} - callback to be called on success. * - onFailure {function} - callback to be called on failure. * - paneSet {object} - PaneSet that called the function. */Zapatec.PaneSet.loadHtml = function(params) {	var data = params.from;	var paneSet = params.paneSet;	//trying to get element by its id if data is string.	data = Zapatec.Widget.getElementById(data);	//must be HTML Element, not any other DOM element	if (!data || data.nodeType !== 1) {		if (!Zapatec.windowLoaded && !data) {			setTimeout(function() {				Zapatec.PaneSet.loadHtml(params);			}, 50);			return;		} else {			Zapatec.Log({description : "No element to parse panes object found!"});			if (typeof params.onFailure == "function") {				params.onFailure();			}			return;		}	}	if (!data.parentNode || data.parentNode.nodeType != 1) {		if (document.body) {			document.body.insertBefore(data, document.body.firstChild);		} else {			setTimeout(function() {				Zapatec.PaneSet.loadHtml(params);			}, 50);			return;		}	}	//resulting panes object	var panesObj = [];	//looping through all the child elements to determine panes	var pane = data.firstChild;	while (pane) {		//only marked HTNL elements are parsed		if (pane.className && pane.className.indexOf("zpPaneMarker") >= 0) {			//object to store configuration			var paneConfig = {};			paneConfig.containerType = "current";			paneConfig.el = pane;			paneConfig.id = pane.id;			if (paneSet.config.orientation == "vertical") {				paneConfig.breadth = pane.offsetHeight;			} else {				paneConfig.breadth = pane.offsetWidth;			}			//pushing it to the whole array			panesObj.push(paneConfig);			pane = pane.nextSibling;		} else if (pane.className && pane.className.indexOf("zpPaneSetMarker") >= 0) {			//object to store configuration			var paneSetConfig = {};			paneSetConfig.panes = pane;			paneSetConfig.dataType = "html";			paneSetConfig.orientation = (paneSet.config.orientation == "vertical") ? "horizontal" : "vertical";			paneSetConfig.parent = paneSet;			paneSetConfig.reuseContainer = pane;			paneSetConfig.id = pane.id			if (paneSet.config.orientation == "vertical") {				if (pane.style.height !== "" || pane.style.height !== "auto") {					paneSetConfig.breadth = pane.offsetHeight;				}				if (pane.style.width !== "" || pane.style.width !== "auto") {					paneSetConfig.length = pane.offsetWidth;				}			} else {				if (pane.style.height !== "" || pane.style.height !== "auto") {					paneSetConfig.length = pane.offsetHeight;				}				if (pane.style.width !== "" || pane.style.width !== "auto") {					paneSetConfig.breadth = pane.offsetWidth;				}			}			panesObj.push(paneSetConfig);			pane = pane.nextSibling;		} else {			var notPane = pane;			pane = pane.nextSibling;			notPane.parentNode.removeChild(notPane);		}	}	data = panesObj;	//returning panes object	if (typeof params.onSuccess == "function") {		params.onSuccess(data);	}};/** * Creates a "panes" object from DOM object or string. * @param params {object} object with following  * possible properties: * - from {mixed} - depending on type this is representation * of data needed to be loaded and parsed. * - onSuccess {function} - callback to be called on success. * - onFailure {function} - callback to be called on failure. */Zapatec.PaneSet.loadHtmlText = function(params) {	//parsing HTML string by using Transport	var data = Zapatec.Transport.parseHtml(params.from);	data = data.firstChild;	while(data && data.className.indexOf("zpPaneSetMarker") == -1) {		data = data.nextSibling;	}	if (data) {		data = data.parentNode.removeChild(data);		paneSet.config.reuseContainer = data;	} else {		Zapatec.Log({description : "No root PaneSet element found!"});		if (typeof params.onFailure == "function") {			params.onFailure();		}		return;	}	params.from = data;		//parsing panes object for the DOM element.	Zapatec.PaneSet.loadHtml(params);};/** * Loads data to create a "panes" object. * @param params {object} object with following  * possible properties: * - from {mixed} - depending on type this is representation * of data needed to be loaded and parsed. * - onSuccess {function} - callback to be called on success. * - onFailure {function} - callback to be called on failure. */Zapatec.PaneSet.loadHtmlUrl = function(params) {	Zapatec.Transport.fetch({		// URL of the source		url: params.from,		// Suspend script execution until source is loaded or error received		async: true,		// Onload event handler		onLoad: function(objRequest) {			params.from = objRequest.responseText;			Zapatec.PaneSet.loadHtmlText(params);		},		// Onerror event handler		onError: function(objError) {			Zapatec.Log({description : "Couldn't load the data for PaneSet from the following URL: " + params.from});			if (typeof params.onFailure == "function") {				params.onFailure();			}		}	});};/** * Creates a "panes" object from JSON object or string. * @param params {object} object with following  * possible properties: * - from {mixed} - depending on type this is representation * of data needed to be loaded and parsed. * - onSuccess {function} - callback to be called on success. * - onFailure {function} - callback to be called on failure. */Zapatec.PaneSet.loadJsonObject = function(params) {	if (typeof params.from != "object") {		params.from = Zapatec.Transport.parseJson({strJson: params.from});	}	if (typeof params.from == "object") {		if (typeof params.onSuccess == "function") {			params.onSuccess(params.from);		}	} else {		Zapatec.Log({description : "Not a valid JSON object passed!"});		if (typeof params.onFailure == "function") {			params.onFailure();		}	}};/** * Loads JSON string from URL and parses it. * @param params {object} object with following  * possible properties: * - from {mixed} - depending on type this is representation * of data needed to be loaded and parsed. * - onSuccess {function} - callback to be called on success. * - onFailure {function} - callback to be called on failure. */Zapatec.PaneSet.loadJsonUrl = function(params) {	Zapatec.Transport.fetch({		// URL of the source		url: params.from,		// Suspend script execution until source is loaded or error received		async: true,		// Onload event handler		onLoad: function(objRequest) {			params.from = objRequest.responseText;			Zapatec.PaneSet.loadJsonObject(params);		},		// Onerror event handler		onError: function(objError) {			Zapatec.Log({description : "Couldn't load the data for PaneSet from the following URL: " + params.from});			if (typeof params.onFailure == "function") {				params.onFailure();			}		}	});};/** * Creates a "panes" object from XML string or object. * @param params {object} object with following  * possible properties: * - from {mixed} - depending on type this is representation * of data needed to be loaded and parsed. * - onSuccess {function} - callback to be called on success. * - onFailure {function} - callback to be called on failure. */Zapatec.PaneSet.loadXml = function(params) {	if (typeof params.from != 'object') {		params.from = Zapatec.Transport.parseXml({strXml: params.from});	}	if (typeof params.from == "object") {		if (typeof params.onSuccess == "function") {			params.onSuccess(params.from);		}	} else {		Zapatec.Log({description : "Not a valid XML passed!"});		if (typeof params.onFailure == "function") {			params.onFailure();		}	}};/** * Loads XML page and parses it. * @param params {object} object with following  * possible properties: * - from {mixed} - depending on type this is representation * of data needed to be loaded and parsed. * - onSuccess {function} - callback to be called on success. * - onFailure {function} - callback to be called on failure. */Zapatec.PaneSet.loadXmlUrl = function(params) {	Zapatec.Transport.fetch({		// URL of the source		url: params.from,		// Suspend script execution until source is loaded or error received		async: true,		// Onload event handler		onLoad: function(objRequest) {			params.from = objRequest.responseText;			Zapatec.PaneSet.loadXml(params);		},		// Onerror event handler		onError: function(objError) {			Zapatec.Log({description : "Couldn't load the data for PaneSet from the following URL: " + params.from});			if (typeof params.onFailure == "function") {				params.onFailure();			}		}	});};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -