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; } for (var k = 0; k < params.length; k++) { 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) { var style = document.createElement('link'); style.rel = 'stylesheet'; style.type = 'text/css'; style.href = linkText[1]; document.getElementsByTagName('head')[0].appendChild(style); } // 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.contentType != 'table' || this.requestParameters.toString().indexOf(this.contentId+'_offset') == -1) { // normal update if (flag) { new Rico.Effect.FadeTo(this.id, .1, // 20% opacity 500, // 500ms (1/2 second) 10, // 10 steps {complete:function() { that.fadeIn(ajaxResponse); }}); } else { new Rico.Effect.FadeTo(this.id, .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'; } }