/* name : ClassBehaviours, the javascript framework based on class-name parsing update : 9.2.2 author : Maurice van Creij dependencies : jquery.classbehaviours.js info : http://www.classbehaviours.com/ This file is part of jQuery.classBehaviours. ClassBehaviours is a javascript framework based on class-name parsing. Copyright (C) 2008 Maurice van Creij ClassBehaviours is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. ClassBehaviours is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with ClassBehaviours. If not, see http://www.gnu.org/licenses/gpl.html. */ // create the jQuery object if it doesn't already exist if(typeof(jQuery)=='undefined') jQuery = function(){}; // create the root classbehaviours object if it doesn't already exist if(typeof(jQuery.classBehaviours)=='undefined') jQuery.classBehaviours = function(){}; // create the handlers child object if it doesn't already exist if(typeof(jQuery.classBehaviours.handlers)=='undefined') jQuery.classBehaviours.handlers = function(){} // Open an overlay as a popup window jQuery.classBehaviours.handlers.openLayerPopUp = { // properties name: 'openLayerPopUp', popUpClass: 'layerPopUp', step: 10, begin: 0, end: 50, index: 0, // methods start: function(node){ //alert('1001'); // find the target layer targetPopUp = null; // the node's open button node.onclick = this.load; // open the popup immediately if required node.id = (node.id) ? node.id : this.name + 'Link' + this.index++ ; if(jQuery.classBehaviours.utilities.getClassParameter(node, 'auto', 'no')=='yes') setTimeout('jQuery.classBehaviours.handlers.openLayerPopUp.load(document.getElementById("'+node.id+'"))', 250); }, fadeIn: function(id, amount){ //alert('1002'); var olp = jQuery.classBehaviours.handlers.openLayerPopUp; node = document.getElementById(id); nodes = node.getElementsByTagName('div'); nodeShadow = nodes[0]; nodeContent = nodes[1]; // if the amount is not 50 if(amountolp.begin){ // hide the popup content nodeContent.style.visibility = 'hidden'; // set the fade to the next step if(typeof(nodeShadow.style.MozOpacity)!='undefined') nodeShadow.style.MozOpacity = amount/100; if(typeof(nodeShadow.style.filter)!='undefined') nodeShadow.style.filter = "alpha(opacity=" + amount + ")"; if(typeof(nodeShadow.style.opacity)!='undefined') nodeShadow.style.opacity = amount/100; // repeat the fade setTimeout("jQuery.classBehaviours.handlers.openLayerPopUp.fadeOut('" + id + "'," + (amount-olp.step) + ")",10); }else{ // hide the popup content node.style.display = 'none'; // hide the popup's shadow nodeShadow.style.display = 'none'; } }, loadUrl: function(strXmlUrl, strHrefUrl, strId, strTitle, intStep, intBegin, intEnd){ //alert('1004'); var olp = jQuery.classBehaviours.handlers.openLayerPopUp; // create a new link newA = document.createElement('a'); newA.id = strId + 'Opener' newA.href = strXmlUrl + '?url=' + strHrefUrl; if(strTitle!=null) newA.title = strTitle; newA.className = 'openLayerPopUp id_' + strId; if(intStep!=null) newA.className += 'step_' + intStep; if(intBegin!=null) newA.className += 'begin_' + intBegin; if(intEnd!=null) newA.className += 'end_' + intEnd; newA.style.display = 'none'; document.body.appendChild(newA); // trigger it like a click olp.load(document.getElementById(strId + 'Opener'), strId); }, // events load: function(that){ //alert('1005'); var objNode = (typeof(this.nodeName)=='undefined') ? that : this ; var olp = jQuery.classBehaviours.handlers.openLayerPopUp; // get the popup id popUpHref = (objNode.href) ? objNode.href : '' ; popUpId = (popUpHref.indexOf('#')>-1) ? popUpHref.split('#')[1] : jQuery.classBehaviours.utilities.getClassParameter(objNode, 'id', 'popUpWithScrollBar') ; // if the popup is allready loaded popUpObj = document.getElementById(popUpId); if(popUpObj){ olp.show(objNode, popUpId); }else{ jQuery.classBehaviours.ajax.addRequest(popUpHref, olp.insert, olp.wait, null, objNode); } // cancel the click return false; }, wait: function(progress, referNode){ //alert('1006'); var olp = jQuery.classBehaviours.handlers.openLayerPopUp; // it'd be fun to see a background image behind the link text be the progress-indicator referNode.parentNode.style.backgroundPosition = (100-progress*100) +'% 0px'; }, insert: function(importedObj, referNode, importedText){ //alert('1007'); var olp = jQuery.classBehaviours.handlers.openLayerPopUp; // get the popup's id olp.instance += 1; popUpId = jQuery.classBehaviours.utilities.getClassParameter(referNode, 'id', olp.name+olp.instance); popUpWidth = jQuery.classBehaviours.utilities.getClassParameter(referNode, 'width', '470'); popUpHeight = jQuery.classBehaviours.utilities.getClassParameter(referNode, 'height', '300'); // make a new node at the end of the page newNode = document.createElement('div'); document.body.appendChild(newNode); // get the node and fill it with delicous html allDivs = document.getElementsByTagName('div'); lastDiv = allDivs[allDivs.length-1]; importedText = (importedText.indexOf('')>-1) ? importedText.split('')[1].split('')[0] : importedText.replace('', '') ; importedText = importedText.replace(/{id}/gi, popUpId); importedText = importedText.replace(/{title}/gi, referNode.title); importedText = importedText.replace(/{url}/gi, referNode.href.split('?url=')[1]); importedText = importedText.replace(/{width}/gi, popUpWidth); importedText = importedText.replace(/{height}/gi, popUpHeight); lastDiv.innerHTML = importedText; // apply any classbehaviours jQuery.classBehaviours.parser.parseNode(lastDiv); // show the pop-up olp.show(referNode, popUpId); }, center: function(popUpObj){ //alert('1008'); if(popUpObj){ // the dimensions can not be measured with "display:none;" popUpObj.style.display = 'block'; // get the content segment popupContent = popUpObj.getElementsByTagName('DIV')[2]; // how high is the content popupHeight = popupContent.offsetHeight; // how high is the screen screenHeight = (window.innerHeight) ? window.innerHeight : document.documentElement.clientHeight ; // center the popup popupContent.style.marginTop = (screenHeight>popupHeight) ? Math.round((screenHeight-popupHeight)/2) + 'px' : '30px' ; } }, show: function(openerObj, popUpId){ //alert('1009'); var olp = jQuery.classBehaviours.handlers.openLayerPopUp; var submit = false; // adjust the fade parameters if it needs to open instantly /////alert(popUpId); //******************************************************************* if(openerObj){ olp.step = parseInt(jQuery.classBehaviours.utilities.getClassParameter(openerObj, 'step', 10)); olp.begin = parseInt(jQuery.classBehaviours.utilities.getClassParameter(openerObj, 'begin', 0)); olp.end = parseInt(jQuery.classBehaviours.utilities.getClassParameter(openerObj, 'end', 50)); } // get the popup popUpObj = document.getElementById(popUpId); // hide the popup for now popUpObj.style.visibility = 'hidden'; // center the popup this.center(popUpObj); // if the link had a title and if the popup has a title. put the link title in the popup popUpTitles = popUpObj.getElementsByTagName('h1'); if(openerObj) if(openerObj.title && popUpTitles.length>0) popUpTitles[0].innerHTML = openerObj.title; // load a given url in the iframe it it's not there allready popUpIframes = popUpObj.getElementsByTagName('iframe'); if(popUpIframes.length>0 && openerObj.href.indexOf('?url=')>-1){ if(popUpIframes[0].src!=openerObj.href.split('?url=')[1]) popUpIframes[0].src = openerObj.href.split('?url=')[1]; } // find the close gadget popUpClosers = popUpObj.getElementsByTagName('a'); //alert('10010 c'); if(popUpClosers.length>0){ popUpClosers[0].onclick = olp.hide; } // remove the scroll bars if(navigator.appVersion.indexOf('MSIE 6')>-1 || navigator.appVersion.indexOf('MSIE 5')>-1){ // manage the scroll positions if(popUpObj.className.indexOf('fullHeightPopUp')<0){ // reset the scroll position document.documentElement.scrollLeft = 0; document.documentElement.scrollTop = 0; // hide the scrollbars if needed document.body.parentNode.style.overflow = "hidden"; // reposition the popup according to the scroll position popUpObj.getElementsByTagName('DIV')[2].style.marginTop = Math.round(document.documentElement.scrollTop + (screenHeight-popupHeight)/2) + 'px' ; } // size the shadow under the popup popUpObj.getElementsByTagName('DIV')[0].style.height = document.body.offsetHeight + 'px'; // hide the selects allSelects = document.getElementsByTagName('select'); for(var a=0; a-1 || navigator.appVersion.indexOf('MSIE 5')>-1){ // show the scrollbars if(popUp.className.indexOf('fullHeightPopUp')<0) document.body.parentNode.style.overflow = ""; // show the selects allSelects = document.getElementsByTagName('select'); for(var a=0; a0){ popUpIframes[0].src = ""; } // note that nothing is opened olp.opened = null; // cancel the click return false; } } // move the node to the bottom of the document jQuery.classBehaviours.handlers.layerPopUp = { // properties name: 'layerPopUp', // methods start: function(node){ // if this node wasn't moved if(node.className.indexOf('doNotMove')<0) this.process(node); }, process: function(objNode){ // take this node removedChild = objNode.parentNode.removeChild(objNode); removedChild.className += ' doNotMove'; // and put it at the end of the document document.body.appendChild(removedChild); } } // use a button to hide the popup layer jQuery.classBehaviours.handlers.closeLayerPopUp = { // properties name: 'closeLayerPopUp', // methods start: function(node){ node.onclick = this.closePopUp; }, closePopUp: function(that){ //alert('hola'); var objNode = (typeof(this.nodeName)=='undefined') ? that : this ; // deal with framesets if(parent!=self){ allPopUps = parent.jQuery.classBehaviours.utilities.getElementsByClassName('layerPopUp'); for(var a=0; a