//register onload events here. //EventListener.addEvent(window, 'load', function() { //}); // ---------------------- function filterCheckboxList( oInput, elementID ) { var query = oInput.value; var id_ = '#' + elementID + ' .checkbox_container .checkbox_title'; var checkbox_container = id_; var oRE = new RegExp('('+query+')', 'gi' ); $('.minipage').removeClass('none'); $(checkbox_container).each( function( index, oElement ) { var title_value = oElement.innerHTML; if( title_value.toLowerCase().indexOf(query.toLowerCase())==-1 ) { $(oElement.parentNode).fadeOut("fast"); } else { $(oElement.parentNode).fadeIn('fast'); //show("slide", { direction: "left" }, 640); } }); } function checkboxListToggle( checked, elementID ) { var checkbox_container = '#' + elementID + ' .checkbox_container .checkbox_input .checkbox'; $(checkbox_container).each( function( index, oElement ) { oElement.checked = checked; $(oElement).change(); }); } //ANNOYANCE: var editor; function loadRTE(oLink) { editor = Xinha.startEditors(xinha_editors); oLink.parentNode.removeChild(oLink); //have to refresh page in order to toggle rte. kind of lame... //document.getElementById('hideRTE').style.display='inline'; return editor; } function unloadRTE(oLink) { oLink.parentNode.removeChild(oLink); if(__xinhas[0]) { //undo what xihna screwed up __xinhas[0]._textArea.style.display='block'; __xinhas[0]._htmlArea.style.display='none'; __xinhas[0]._textArea.innerText = __xinhas[0].outwardHtml(__xinhas[0].getHTML()); document.getElementById('content_edit_container').appendChild(__xinhas[0]._textArea.parentNode.removeChild(__xinhas[0]._textArea)); __xinhas[0]._htmlArea.parentNode.removeChild(__xinhas[0]._htmlArea); __xinhas[0]._iframe.parentNode.removeChild(__xinhas[0]._iframe); } Xinha.setContent(); } //ANNOYANCE: /*corespin form js bug*/ function validateForm_2(loForm, loInput){ //stub doesn't really do anything just forces a return value of true. var oURLField = document.getElementById('slug'); //if (oURLField!==false) { // setRecordURL(oURLField.value,oURLField); //} loForm = document.getElementById(loForm); lsFormID = ''; if(loForm) { if(loForm.id) { lsFormID = loForm.id } } lsSubmitID = '__submitjs' + lsFormID; lsConfirmID = '__confirmjs' + lsFormID; loSubmit = document.getElementById(lsSubmitID); loConfirm = document.getElementById(lsConfirmID); if(loSubmit) { loSubmit.value = true; } if(loConfirm) { loConfirm.value = true; } lsSubmitID = '__submitjs'; lsConfirmID = '__confirmjs'; loSubmit = document.getElementById(lsSubmitID); loConfirm = document.getElementById(lsConfirmID); if(loSubmit) { loSubmit.value = true; } if(loConfirm) { loConfirm.value = true; } return true; } /*corespin form js bug*/ //JS SCROLLING //***************************************** var scrollUpInterval; var scrollDownInterval; var oScrollDiv; //***************************************** function scrollUp(iElementId, iJumpRate, iRate) { if (scrollUpInterval != null) { return; } oScrollDiv = document.getElementById(iElementId); scrollUpInterval = window.setInterval("oScrollDiv.scrollTop-="+iJumpRate, iRate); } //***************************************** //***************************************** function scrollDown(iElementId, iJumpRate, iRate) { if (scrollDownInterval != null) { return; } oScrollDiv = document.getElementById(iElementId); scrollDownInterval = window.setInterval("oScrollDiv.scrollTop+="+iJumpRate, iRate); } //***************************************** //***************************************** function scrollStop() { if (scrollUpInterval != null) { window.clearInterval(scrollUpInterval); scrollUpInterval = null; } if (scrollDownInterval != null) { window.clearInterval(scrollDownInterval); scrollDownInterval = null; } } //***************************************** function insertAfter(loInsertThisElement,loAfterThisElement) { //why is there no DOM.insertAfter? if(loAfterThisElement.nextSibling) { return (loAfterThisElement.parentNode.insertBefore(loInsertThisElement,loAfterThisElement.nextSibling)); } else { return (loAfterThisElement.parentNode.appendChild(loInsertThisElement)); } } //***************************************** //GENERIC CORESPIN IMPLEMENTATION FUNCTIONS //***************************************** var searchInterval = false; function automaton(lcallback_function,liTime) { //used for list filter... clearInterval(searchInterval); searchInterval = setInterval(lcallback_function, liTime); //fire whatever function //trace('setting::'+searchInterval); removeInterval = setTimeout('clearSearch('+searchInterval+')',liTime); //clear after firing return searchInterval; } function clearSearch(interval) { if(!interval) {return;} //trace('clearing::'+interval); clearInterval(interval); } //***************************************** //****************************************************** function ChangePageLinkage (iObjectID,iLinkageId) { var ID = interstate(iObjectID, 440, 400, '/corespin/content_linkage?_linkage_id='+iLinkageId); return ID; } //***************************************** function select_tier(lsTierType,liValue,context) { if (lsTierType=='architecture_type_id') { //update architecture list as well, indicate type if(context=='architecture') { document.getElementById('_architecture_id').value=''; //remove architecture id, or query returns bad results } else { document.getElementById('_linkage_architecture_id').value=''; //remove architecture id when type changes, or query returns bad results } ArchitectureLinkageSelector('architecture','_architecture_type_id='+liValue,context); } else { updateArchitectureLinkageSelectors(context); } } //***************************************** function ArchitectureLinkageSelector(lsSelector,lsKey,context) { var lsSelectCallBack = ''; if(context!='architecture') { lsSelectCallBack = '_linkage_'; } lsSelectCallBack += lsSelector + '_selector'; if (!document.getElementById(lsSelectCallBack)) {return;} var loSelectCallBack = document.getElementById(lsSelectCallBack); loSelectCallBack.disabled=true; ClassFX.addClass(loSelectCallBack,'obscured'); var lsRequest = '/corespin/' + lsSelector + '_select_list/?' + lsKey + '&_context='+context; ajaxEvent(lsRequest,loSelectCallBack,false,true); //synch ClassFX.removeClass(loSelectCallBack,'obscured'); loSelectCallBack.disabled=false; } //***************************************** function updateArchitectureLinkageSelectors(context) { var oArchitectureField; var oArchitectureTypeField; var oArchitectureSelector = document.getElementById(context+'_architecture_select_list'); var oArchitectureTypeSelector = document.getElementById(context+'_architecture_types_select_list'); if(!oArchitectureSelector) { return; } if(!oArchitectureTypeSelector) { return; } if(context=='architecture') { oArchitectureField = document.getElementById('_architecture_id'); oArchitectureTypeField = document.getElementById('_architecture_type_id'); } else { oArchitectureField = document.getElementById('_linkage_architecture_id'); oArchitectureTypeField = document.getElementById('_linkage_architecture_type_id'); } if(oArchitectureSelector.selectedIndex>-1) { //get select box values oArchitectureField.value=oArchitectureSelector.options[oArchitectureSelector.selectedIndex].value; } else { oArchitectureField.value=''; } if(oArchitectureTypeSelector.selectedIndex>-1) { oArchitectureTypeField.value=oArchitectureTypeSelector.options[oArchitectureTypeSelector.selectedIndex].value; } else { oArchitectureField.value=''; } refreshContent(context); } //***************************************** function refreshContent(context) { if(context=='architecture') { refreshContentList(context); } else { refreshContentLinkage(context); } } //***************************************** function refreshContentLinkage(context) { //called from automaton for content linkage if(!context){context='';} var oArchitectureField; var sArchitectureField; var oArchitectureTypeField; var sArchitectureTypeField; var oLinkage; var sLinkage; var lsURI; var loCallBack; var loLoadingIMG = document.getElementById('_linkage_search_icon'); var oFilter; var sFilter; oArchitectureField = document.getElementById('_linkage_architecture_id'); sArchitectureField = (oArchitectureField.value!=undefined)?(oArchitectureField.value):(''); oArchitectureTypeField = document.getElementById('_linkage_architecture_type_id'); sArchitectureTypeField = (oArchitectureTypeField.value!=undefined)?(oArchitectureTypeField.value):(''); oFilter = document.getElementById('_linkage_slug'); sFilter = (oFilter.value!=undefined)?(oFilter.value):(''); oLinkage = document.getElementById('_linkage_id'); sLinkage = (oLinkage.value!=undefined)?(oLinkage.value):(''); lsURI = '/corespin/content_linkage/?_linkage_filter='+sFilter+'&_linkage_architecture_id='+sArchitectureField+'&_linkage_architecture_type_id='+sArchitectureTypeField+'&_linkage_id='+sLinkage+'&_context='+context; loCallBack = document.getElementById('DDFX_linkage').parentNode; loLoadingIMG.src='/box/system/loading-small.gif'; ajaxEvent(lsURI,loCallBack,false,true); loLoadingIMG.src='/box/system/arrow_switch.png'; this.bFiring = false; //global reference? if(document.getElementById('_linkage_slug')) { setTimeout("document.getElementById('_linkage_slug').focus()",200); } } //***************************************** function refreshContentList(context) { //called from automaton for content list if(!context){context='';} var oArchitectureField; var sArchitectureField; var oArchitectureTypeField; var sArchitectureTypeField; var oFilter; var sFilter; var lsURI; var loCallBack; var loLoadingIMG = document.getElementById('_search_icon'); oArchitectureField = document.getElementById('_architecture_id'); sArchitectureField = (oArchitectureField.value!=undefined)?(oArchitectureField.value):(''); oArchitectureTypeField = document.getElementById('_architecture_type_id'); sArchitectureTypeField = (oArchitectureTypeField.value!=undefined)?(oArchitectureTypeField.value):(''); oFilter = document.getElementById('_architecture_slug'); sFilter = (oFilter.value!=undefined)?(oFilter.value):(''); lsURI = '/corespin/content_list/?_architecture_filter='+sFilter+'&_architecture_id='+sArchitectureField+'&_architecture_type_id='+sArchitectureTypeField+'&_context='+context; loCallBack = document.getElementById('content_list'); loLoadingIMG.src='/box/system/loading-small.gif'; ajaxEvent(lsURI,loCallBack,false,true); loLoadingIMG.src='/box/system/arrow_switch.png'; //this.bFiring = false; //global reference? if(document.getElementById('_architecture_slug')) { setTimeout("document.getElementById('_architecture_slug').focus()",300); } } //***************************************** //ARCHITECTURE CONTENT AND PAGE LINKAGE MANAGEMENT BLOCK //INSERT or UPDATE relationships function MultiPass(key, oElement, primary, relation, primaryID, parameters) { var relationID = 0; //trigger for new record. var statusID = ""; var key = 0; BigLeagueChew(key, oElement, primary, relation, primaryID, relationID, statusID, 'insert', parameters); } //***************************************** //INSERT or UPDATE relationships function BigLeagueChew(liKey, oElement, lsPrimary, lsRelation, liPrimaryID, liRelationID, liStatusID, lsOperation, parameters) { if (!lsPrimary){return;} if ( lsOperation=='update' ) { this.YURI = '/corespin/pattern_update_relation/'; // } else { this.YURI = '/corespin/pattern_insert_relation/'; // } parameters = (parameters)?(parameters):(""); lsRequest = '?_key=' + liKey; lsRequest += '&_primary=' + lsPrimary; lsRequest += '&_relation=' + lsRelation; lsRequest += '&_primary_id=' + liPrimaryID; lsRequest += '&_relation_id=' + liRelationID; lsRequest += '&_status_id=' + liStatusID; this.YURI += lsRequest + parameters; ajaxEvent(this.YURI, oElement, false, true); //callback, replace contents, synchronous. } //***************************************** //INSERT or UPDATE relationships function PassKey(liKey, oElement, lsPrimary, lsRelation, liPrimaryID, liRelationID, liStatusID) { if(!liRelationID) { liRelationID = 0; //trigger for new record. } if(!liStatusID) { liStatusID = ""; } if(!liKey||liKey==0) { BigLeagueChew(liKey, oElement, lsPrimary, lsRelation, liPrimaryID, liRelationID, liStatusID, 'insert'); } else { BigLeagueChew(liKey, oElement, lsPrimary, lsRelation, liPrimaryID, liRelationID, liStatusID, 'update'); } } //***************************************** //this is specifically for INSERTION of a NEW relational value = misnamed, use PassKey|BigLeagueChew Instead function UpdateRelationalField(oElement,lsPrimary,lsRelation,liPrimaryID,liRelationID,callback,contextArguments) { //Single Field Edit if (!lsPrimary){return;} //contextArguments = 'name=value'; //additional arguments can be supplied here, parsed and validated. this.UpdateURI='/corespin/pattern_insert_saved/'; //current XML HTTP Request URI lsRequest='?_primary='+lsPrimary; lsRequest+='&_relation='+lsRelation; lsRequest+='&_primary_id='+liPrimaryID; lsRequest+='&_relation_id='+liRelationID; this.UpdateURI+=lsRequest; ajaxEvent(this.UpdateURI,(callback)?(oElement):(false),false,false); //callback, replace contents, synchronous. } //***************************************** function UpdateSingleField(oElement,context,ID,fieldname,value,callback,callback_function) { //Single Field Edit if (!context){return;} if (!ID){return;} if (!fieldname){return;} this.UpdateURI='/corespin/_update_single_field/';//current XML HTTP Request URI //this.UpdateURI='/corespin/pf_update/';//current XML HTTP Request URI lsRequest='?_context='+context; lsRequest+='&_id='+ID; lsRequest+='&_field='+fieldname; lsRequest+='&_value='+PrepValue(value); this.UpdateURI+=lsRequest; if (!callback) { //oElement=false; } var lcallback_function=''; var lsArguments=''; if (oElement) { if(oElement.id){ if (oElement.id=='RTESaveEdit') { lcallback_function='RTERemoveFrame'; lsArguments=''; oElement = false; } } } if(callback_function!='') { lcallback_function = callback_function; } llQueued=false; if(context=='payments'){llQueued=true;} //custom ajaxEvent(this.UpdateURI,oElement,false,llQueued,lcallback_function,lsArguments); //callback, replace contents, synchronous. return true; } //***************************************** function UpdateFieldSet(oElement, context, ID, fieldset, callback, callback_function) { //Single Field Edit if (!context){return;} if (!ID){return;} if (!fieldset){return;} this.UpdateURI='/corespin/_update_single_field/'; lsRequest='?_context='+context; lsRequest+='&_id='+ID; lsRequest+='&_fieldset='+fieldset; this.UpdateURI+=lsRequest; if (!callback) { //oElement=false; } ajaxEvent(this.UpdateURI, oElement, false, true); //callback, replace contents, synchronous. return true; } //***************************************** //custom functions for insert forms default value completion function setTitleFields(lsQualifier,lsValue) { if(lsQualifier=='locations::schools') { document.getElementById('location').value=lsValue; document.getElementById('company').value=lsValue; document.getElementById('meta_keywords').value=lsValue; setRecordURL(lsValue,document.getElementById('slug')); } if(lsQualifier=='pages') { document.getElementById('meta_keywords').value=lsValue; setRecordURL(lsValue,document.getElementById('slug')); } } //***************************************** function setRecordURL(lsValue,oElement) { if (!oElement){return;} if (typeof(lsValue) == 'string') { lsValue = lsValue.replace(/\//g,""); lsValue = lsValue.replace(/\s/g,"-"); lsValue=lsValue.replace(/\'/g,"''"); lsValue=lsValue.replace(/\"/g,""); lsValue = encodeRE(lsValue); } oElement.value=lsValue.toLowerCase(); } //***************************************** function encodeRE(lsValue) { lsValue=lsValue.replace(/\s/g,""); lsValue=lsValue.replace(/\'/g,""); lsValue=lsValue.replace(/\"/g,""); lsValue = lsValue.replace(/[^a-zA-Z0-9\.\-\_\\]/g,''); return lsValue; //.replace(/([~`@#%*^&*=!+?^${}()|[\]\/\\])/g,''); } //***************************************** function spacer(loContainer) { //returns a reference to a spacer object (used frequently in drag and drop routines as a UI trigger) var loSpacer = loContainer.nextSibling; if(loSpacer=='[object Text]') { //while? loSpacer = loContainer.nextSibling.nextSibling; if(loSpacer=='[object Text]') { //screw it loSpacer = loContainer.nextSibling.nextSibling.nextSibling; } } else { loSpacer = loContainer.nextSibling; } if (ClassFX.hasClass(loSpacer,'spacer')) { return loSpacer; } return false; //no spacer } //***************************************** function showLoadingGIFWOW() { //really unimpressive ui effect if(document.getElementById('loading')) { document.getElementById('loading').style.display='block'; ClassFX.removeClass(document.getElementById('loading'),'none'); return(true); } } //***************************************** /* function NewRelation(lsURI) { var loContainer = createOverlayDiv(750,500); loContainer.appendChild(theLove(lsURI)); } //*****************************************/ function UpdateFile(oElement,context,ID,fieldname,value,callback) { //Singular File for record insert/updating if (!context){return;} if (!ID){return;} if (!fieldname){return;} this.URI='/corespin/add-file/'; lsRequest='?_context='+context; lsRequest+='&_id='+ID; lsRequest+='&_field='+fieldname; lsRequest+='&_value='; this.URI+=lsRequest; var loTheAggravatingIframe = theLove(this.URI); // Variable naming loTheAggravatingIframe.width='337px'; loTheAggravatingIframe.height='430px'; var iFileUpload = interstate(null, 357, 482, loTheAggravatingIframe); } //***************************************** //UI EFFECTS //***************************************** // Change opacity of element. IE requires the element to have (layout) specific width. function changeOpacity(oElement, iOpacity) { if(!oElement) {return(false);} if(!iOpacity) {return(false);} var lsTagName=oElement.tagName.toLowerCase(); var oElementStyle = oElement.style; if(!oElementStyle) {return;} oElementStyle.opacity = (iOpacity / 100); oElementStyle.MozOpacity = (iOpacity / 100); oElementStyle.KhtmlOpacity = (iOpacity / 100); oElementStyle.filter = "alpha(opacity=" + iOpacity + ");"; //if you dont add the semicolon in the filter attrib, IE bombs. if (iOpacity==0) { oElementStyle.display = 'none'; } else { if (lsTagName=='div') { oElementStyle.display = 'block'; } else { oElementStyle.display = 'inline'; } } } //***************************************** // Style based fading. -MM function fadeControl(lsItem, iOpacStart, iOpacEnd, iMilliseconds) { var speed = Math.round(iMilliseconds / 100); //speed for each frame var timer = 0; if(iOpacStart > iOpacEnd) { //determine the direction for the blending, if start and end are the same use pulse effect for(i = iOpacStart; i >= iOpacEnd; i--) { setTimeout("changeOpacity(document.getElementById('" + lsItem + "'),'" + i + "')",(timer*speed)); timer++; } } else if(iOpacStart < iOpacEnd) { for(i = iOpacStart; i <= iOpacEnd; i++) { setTimeout("changeOpacity(document.getElementById('" + lsItem + "'),'" + i + "')",(timer*speed)); timer++; } } else if(iOpacStart==iOpacEnd) { //pulse, not finished -- just pulses without considering value from/to which it's pulsing (just from full opacity to zero and back) for(i=0; i<3.1; i+=0.1) { setTimeout("changeOpacity(document.getElementById('" + lsItem + "'),'" + Math.round(Math.abs(Math.cos(i)*100)) + "')",(timer*speed)); timer++; } changeOpacity(document.getElementById(lsItem),iOpacEnd); //hard set back to iOpacEnd, temp... } } //***************************************** //SOME POTENTIALLY USEFUL TOOLS //***************************************** function $$() { //returns object reference || array of object references.... $$ bill y'all //still working on this one... var oElements = document.getElementsByTagName(arguments[0]); var oElement = oElements[0]; //mostly just want to get the first element in the list oElements = null; //discard for now return oElement; } //***************************************** function functionBroker() { //used for brokering function requests (in dev stage :: doesn't really work yet) if(typeof(this[arguments[0]])=='function') { var loArguments = arguments[0]; //ditch first arg as function name, start from first argument if any. for (var a=1;a