var contentList = new Array(); var contentNum = 0; function processAjaxChange(form, causedBy, passCurrentParameters, passOtherForms, hasSubmit, isSubmit, affectedBy) { var params = getFormParams(form.action, getFormElements(form, affectedBy), false, false, false); if (params == null || params == '') { // For submit buttons use other forms parameters params = getFormParams(form.action, getFormElements(form, affectedBy), false, true, false); } var updateList = new Array(); for (var i = 0; i < contentList.length; i++) { var content = contentList[i]; if (isContentUpdatable(content, causedBy, params, hasSubmit, isSubmit)) { updateList.push(content); } } // Filter content list var filteredList = new Array(); for (var i = 0; i < updateList.length; i++) { if (!isContentDependsOn(updateList[i],updateList)) { filteredList.push(updateList[i]); } } params = getFormParams(form.action, getFormElements(form, affectedBy), passCurrentParameters, passOtherForms, true, affectedBy); for (var i = 0; i < filteredList.length; i++) { processAjaxUpdate(filteredList[i], params); } } function isContentUpdatable(content, causedBy, params, hasSubmit, isSubmit) { if (hasSubmit && (content.type == 'table' || content.type == 'chart')) { // Charts and tables can be updated only by submit button or if there is no submit button at all return false; } if (isSubmit && content.type != 'table' && content.type != 'chart') { return false; } if (content.id == causedBy) { return false; } if(content.type == 'input' && content.variable == null && content.vars != null && content.vars.length > 0) return false; for (var k = 0; k < params.length; k++) { if (content.type == 'input') if (content.variable && params[k].indexOf(content.variable + "=") == 0) return true; if (content.vars) { for (var l = 0; l < content.vars.length; l++) { if (params[k].indexOf(content.vars[l] + "=") == 0) { return true; } } } } return false; } function isContentDependsOn(content, list) { for (var k = 0; k < list.length; k++) { if (list[k] == content || list[k].variable == null) continue; for (var j = 0; j < content.vars.length; j++) { if (content.vars[j] == list[k].variable) { return true; } } } return false; } function processAjaxUpdate(content, params) { var divId = 'Content-' + content.id; if (document.getElementById(divId) == null) { alert("Object div not found " + divId); return; } var options = new Array(); if (params != null) { for(var i=0 ; i < params.length; i++) options.push(params[i]); } var chartUpdater = new ChartUpdater("Content-" + content.id, document.location.pathname, content.id, content.type, 0, 0, options); chartUpdater.sendRequest(); } function getFormParams(action, elements, passCurrentParameters, passOtherForms, useURL, affectedBy) { action = new String(action); var url = action; var urlWasNull = false; if(url==null || url.length==0) { urlWasNull = true; url = useURL ? new String(window.location) : ''; } var parts = getURLParts(url); var formID = "____dynamicform____"; if (urlWasNull && !passOtherForms && parts[2] && parts[2].length==2) { parts[2].length = 1; } if(passCurrentParameters && url==action && useURL) { var currentParts = getURLParts(new String(window.location)); if(currentParts.length>0) parts[2] = mergeParameters(currentParts[2], parts[2]); } if(passOtherForms) { var others = new Array(); for(var i=0;i 1) ? parsed[1] : defaultValue; }, updateDiv: function(ajaxResponse) { var content = RicoUtil.getContentAsString(ajaxResponse); var plainContent = content.replace(new RegExp(Prototype.ScriptFragment, 'img'), ''); var linkPattern = '(?:)'; plainContent = plainContent.replace(new RegExp(linkPattern, 'img'), ''); var linkText = content.match(new RegExp(linkPattern, 'im')) || []; if (linkText && linkText.length > 1) { var style = document.createElement('link'); style.rel = 'stylesheet'; style.type = 'text/css'; style.href = linkText[1]; document.getElementsByTagName('head')[0].appendChild(style); } var childNodes = this.div.childNodes; var objNode = null; if(!!(window.attachEvent && navigator.userAgent.indexOf('Opera') === -1)) // IE { objNode = childNodes[0]; } else { for(var i = 0; i < childNodes.length; i++) { if(childNodes[i].nodeName == "EMBED") { objNode = childNodes[i]; break; } } } if(window.svgweb != null && objNode != null) { // need to set this height to keep contents from shifting up when the old chart is removed and the new chart is not yet ready this.div.style.height=Element.getHeight(this.div)+"px"; svgweb.removeChild(objNode, this.div); var src = this.parseParam(plainContent, "src", null); if(src == null) { this.div.innerHTML = "Invalid response returned by server"; } else { // example code from http://svgweb.googlecode.com/svn/trunk/docs/UserManual.html#dynamic_object var newObj = document.createElement('object', true); newObj.setAttribute('type', 'image/svg+xml'); newObj.setAttribute('data', src); newObj.setAttribute('width', this.parseParam(plainContent, "width", 400)); newObj.setAttribute('height', this.parseParam(plainContent, "height", 300)); svgweb.appendChild(newObj, this.div); } } else { // Insert content this.div.innerHTML = plainContent; // Execute scripts var that = this; var matchAll = new RegExp(Prototype.ScriptFragment, 'img'); var matchOne = new RegExp(Prototype.ScriptFragment, 'im'); var scriptList = content.match(matchAll) || []; for (var i = 0; i < scriptList.length; i++) { var scriptContent = (scriptList[i].match(matchOne) || ['', ''])[1]; scriptContent = scriptContent.replace('', ''); try{ var scriptElement = document.createElement('script'); scriptElement.type = 'text/javascript'; scriptElement.text = scriptContent; document.body.appendChild(scriptElement); } catch (e) { alert(e.message); } } } }, showDivEffect: function(flag, ajaxResponse) { // Have to set the height so the div's officially in the layout for the fade to work if (document.all) { //IE height = document.getElementById(this.id).offsetHeight; this.div.style.height=height+1; // have to change height slightly (and set back) or else IE will try this.div.style.height=height; // to calculate height, get it wrong, and change the portlet size } else this.div.style.height = 'auto'; // Fade in to .99 instead of 1.0 because there's a flash at 1.0 var that = this; //new Effect.FadeTo(this.id, /*opacity*/0.99, /*duration*/200, /*steps*/10, {complete:function() {that.after()}}); if(this.requestParameters.toString().indexOf(this.contentId+'_offset') == -1) { // normal update if (flag) { new Rico.Effect.FadeTo(this.id, 0.1, // 20% opacity 500, // 500ms (1/2 second) 10, // 10 steps {complete:function() { that.fadeIn(ajaxResponse); }}); } else { new Rico.Effect.FadeTo(this.id, 0.95, // 20% opacity 500, // 500ms (1/2 second) 10, // 10 steps {complete:function() { that.after(); }}); } } else { // pagination, disable control only if (flag) { that.fadeIn(ajaxResponse); } else { that.after(); } } }, after: function() { this.div.style.height='auto'; } }