📄 ajaxtags.js
字号:
/** * Copyright 2007-2008 Jens Kapitza * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ //--------------------------------------------// just load all files // prototype is not loaded for now // we only can use normal js functions here//-------------------------------------------- var AjaxJspTag = { Version: '1.3', require: function(libraryName) { // inserting via DOM fails in Safari 2.0, so brute force approach document.write('<script type="text/javascript" src="'+libraryName+'"><\/script>'); }, load: function() { var elements = document.getElementsByTagName("script"); var i=0; var s = null; for (i=0; i < elements.length; i++) { var s = elements[i]; if (s.src && s.src.match(/ajaxtags\.js(\?.*)?$/)) { break; } } var path = s.src.replace(/ajaxtags\.js(\?.*)?$/,''); var includes = s.src.match(/\?.*load=([a-z,]*)/); includes = (includes ? includes[1] : 'prototype,scriptaculous/scriptaculous,overlibmws/overlibmws,ajax/ajaxtags_parser,ajax/ajaxtags_tags').split(','); for (i=0; i < includes.length; i++){ AjaxJspTag.require(path+includes[i]+'.js'); } }};AjaxJspTag.load();/** * Global Variables */AJAX_DEFAULT_PARAMETER = "ajaxParameter";AJAX_PORTLET_MAX = 1;AJAX_PORTLET_MIN = 2;AJAX_PORTLET_CLOSE = 3;AJAX_CALLOUT_OVERLIB_DEFAULT = "STICKY,CLOSECLICK,DELAY,250,TIMEOUT,5000,VAUTO,WRAPMAX,240,CSSCLASS,FGCLASS,'olfg',BGCLASS,'olbg',CGCLASS,'olcg',CAPTIONFONTCLASS,'olcap',CLOSEFONTCLASS,'olclo',TEXTFONTCLASS,'oltxt'";/** * Utility Functions */// encode , =function buildParameterString(parameterList) { var returnString = ''; var params = (parameterList || '').split(','); var p = 0; // counter // XXX use params.each - we use prototype! // if (params !== null) { for (p = 0; p < params.length; p++) { pair = params[p].split('='); key = pair[0].strip(); // trim string no spaces allowed in key a, b // should work val = pair[1]; // if val is not null and it contains a match for a variable, then // proceed if (Object.isString(val)) { varList = val.match(new RegExp("\\{[\\w\\.\\(\\)\\[\\]]*\\}", 'g')); if (varList !== null) { field = $(varList[0].substring(1, varList[0].length - 1)); switch (field.type) { case 'checkbox': case 'radio': case 'text': case 'textarea': case 'password': case 'hidden': case 'select-one': returnString += '&' + key + '=' + encodeURIComponent(field.value); break; case 'select-multiple': fieldValue = $F(varList[0].substring(1, varList[0].length - 1)); for (i = 0; i < fieldValue.length; i++) { returnString += '&' + key + '=' + encodeURIComponent(fieldValue[i]); } break; default: returnString += '&' + key + '=' + encodeURIComponent(field.innerHTML); break; } } else { // just add back the pair returnString += '&' + key + '=' + encodeURIComponent(val); } } } } if (returnString.charAt(0) == '&') { returnString = returnString.substr(1); } return returnString;}function parseBoolean(value) { if (value != null && Object.isString(value)) { return ("true" == value.toLowerCase() || "yes" == value.toLowerCase()); } else { if (value) { return true; } return false; }}// read function parameterstringfunction evalJScriptParameters(paramString) { if (paramString !== null || !Object.isString(paramString)) { return null; } return eval("[" + paramString + "]");}// listener wieder anhaengen fuer TREE tag wird von htmlcontent benutztfunction reloadAjaxListeners() { for (i = 0; i < this.ajaxListeners.length; i++) { if (Object.isFunction(this.ajaxListeners[i].setListeners)) { this.ajaxListeners[i].setListeners(); } }}function removeAjaxListener(obj){ if (this.ajaxListeners) { this.ajaxListeners = this.ajaxListeners.without(obj); }}function addAjaxListener(obj) { if (!this.ajaxListeners) { this.ajaxListeners = [obj]; } else { this.ajaxListeners.push(obj); }}/* ---------------------------------------------------------------------- *//* * Example File From "_JavaScript and DHTML Cookbook" Published by O'Reilly & * Associates Copyright 2003 Danny Goodman */// http://jslint.com/// Missing radix parameter -- setDate setHours setMinutes// utility function to retrieve a future expiration date in proper format;// pass three integer parameters for the number of days, hours,// and minutes from now you want the cookie to expire; all three// parameters required, so use zeros where appropriatefunction getExpDate(days, hours, minutes) { var expDate = new Date(); if (typeof days == "number" && typeof hours == "number" && typeof hours == "number") { expDate.setDate(expDate.getDate() + parseInt(days)); expDate.setHours(expDate.getHours() + parseInt(hours)); expDate.setMinutes(expDate.getMinutes() + parseInt(minutes)); return expDate.toGMTString(); }}// utility function called by getCookie()function getCookieVal(offset) { var endstr = document.cookie.indexOf(";", offset); if (endstr == -1) { endstr = document.cookie.length; } return unescape(document.cookie.substring(offset, endstr));}// primary function to retrieve cookie by namefunction getCookie(name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; var j; while (i < clen) { j = i + alen; if (document.cookie.substring(i, j) == arg) { return getCookieVal(j); } i = document.cookie.indexOf(" ", i) + 1; if (i == 0) { break; } } return null;}// store cookie value with optional details as neededfunction setCookie(name, value, expires, path, domain, secure) { document.cookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");}// remove the cookie by setting ancient expiration datefunction deleteCookie(name, path, domain) { if (getCookie(name)) { document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; }}/* ---------------------------------------------------------------------- *//* End Copyright 2003 Danny Goodman */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -