/** * this file contains the entire javascript part of the interactive map */ window.pmap = function() { }; loader = new YAHOO.util.YUILoader(); loader.require("event", "container", "dragdrop"); loader.loadOptional = true; loader.insert(function() { pmap.mapW = 663; pmap.mapH = 678; pmap.pinMarkup = '
'; pmap.altPinMarkup = '
'; pmap.pmapPropList = new Array(); /** * presents user with interface to select location on map for */ pmap.selectLocation = function(passedList) { if(document.getElementById('PmapPropCategory').value == 'Sales' && passedList != null) { pmapPropList = passedList[0]; } else if (document.getElementById('PmapPropCategory').value == 'Rentals' && passedList != null) { pmapPropList = passedList[1]; } else { var pmapPropList; var edit = true; } if(xEl = document.getElementById('PmapPropLocX')) x = (xEl.value.length > 0) ? parseInt(xEl.value) : 0; if(yEl = document.getElementById('PmapPropLocY')) y = (yEl.value.length > 0) ? parseInt(yEl.value) : 0; if(!pmap.panel) { pmap.panel = new YAHOO.widget.Panel("selectLocationPanel", { x: 200, y: 100, underlay: 'none', close: true, visible: false } ); pmap.panel.setBody('

Drag the pin to desired the location then close the selection window.

' + '
' + pmap.pinMarkup.replace('%attribs%', 'id="pmapPin"') + '
'); pmap.panel.render(document.body); pmap.dd1 = new YAHOO.util.DD('pmapPin'); pmap.dd1.endDrag = function(e, id) { x = YAHOO.util.Dom.getX(document.getElementById('pmapPin')) - YAHOO.util.Dom.getX(document.getElementById('pmapMapContainer')); y = YAHOO.util.Dom.getY(document.getElementById('pmapPin')) - YAHOO.util.Dom.getY(document.getElementById('pmapMapContainer')); if(xEl) xEl.value = x; if(yEl) yEl.value = y; if(typeof(pmap.onSelectLocationComplete) != 'undefined') pmap.onSelectLocationComplete(); } } // loop properties pmap.pmapPropList = pmapPropList; pinContainerEl = document.getElementById('pmapMapContainer'); /* if(!edit){ pinContainerEl.innerHTML = pmap.pinMarkup.replace('%attribs%', 'id="pmapPin"') + ''; } */ containerX = YAHOO.util.Dom.getX(pinContainerEl); containerY = YAHOO.util.Dom.getY(pinContainerEl); tmpEl = document.createElement('div'); for(pmapPropListK in pmapPropList) { pmapProp = pmapPropList[pmapPropListK]; if(typeof(pmapProp['PmapProp']) != 'undefined') { var pinElId = 'pmapPin' + pmapPropListK; tmpEl.innerHTML = pmap.altPinMarkup.replace('%attribs%', 'id="'+pinElId+'"'); pinEl = tmpEl.firstChild; pinEl.pmapProp = pmapProp; pinContainerEl.appendChild(pinEl); YAHOO.util.Dom.setX(pinEl, parseInt(pmapProp['PmapProp']['loc_x']) + containerX); YAHOO.util.Dom.setY(pinEl, parseInt(pmapProp['PmapProp']['loc_y']) + containerY); } } delete tmpEl; // End loop YAHOO.util.Dom.setX(document.getElementById('pmapPin'), YAHOO.util.Dom.getX(document.getElementById('pmapMapContainer'))+x); YAHOO.util.Dom.setY(document.getElementById('pmapPin'), YAHOO.util.Dom.getY(document.getElementById('pmapMapContainer'))+y); pmap.dd1.setXConstraint(x, pmap.mapW-x, 1); pmap.dd1.setYConstraint(y, pmap.mapH-y, 1); pmap.panel.show(); } /** * displays map with hoverable property pins */ pmap.showMap = function(pmapPropList) { pmap.pmapPropList = pmapPropList; containerX = YAHOO.util.Dom.getX(document.getElementById('pmapMapContainer')); containerY = YAHOO.util.Dom.getY(document.getElementById('pmapMapContainer')); pinContainerEl = document.getElementById('pmapPinContainer'); pmapPropListEl = document.getElementById('pmapPropList'); tmpEl = document.createElement('div'); // loop properties for(pmapPropListK in pmapPropList) { pmapProp = pmapPropList[pmapPropListK]; if(typeof(pmapProp['PmapProp']) != 'undefined') { var pinElId = 'pmapPin' + pmapPropListK; tmpEl.innerHTML = pmap.pinMarkup.replace('%attribs%', 'id="'+pinElId+'"'); pinEl = tmpEl.firstChild; pinEl.pmapProp = pmapProp; pinContainerEl.appendChild(pinEl); YAHOO.util.Event.addListener(pinEl, 'click', pmap.pinClicked); YAHOO.util.Dom.setX(pinEl, parseInt(pmapProp['PmapProp']['loc_x']) + containerX); YAHOO.util.Dom.setY(pinEl, parseInt(pmapProp['PmapProp']['loc_y']) + containerY); // add to list pmapPropListItemEl = document.createElement('li'); pmapPropListItemEl.appendChild(pmapPropLinkEl = document.createElement('a')); pmapPropLinkEl.href = 'javascript:pmap.clickPin(document.getElementById(\'pmapPin' + parseInt(pmapPropListK) + '\'));'; if(document.all) { pmapPropLinkEl.innerText = pmapProp['PmapProp']['name']; } else { pmapPropLinkEl.textContent = pmapProp['PmapProp']['name']; } pmapPropListEl.appendChild(pmapPropListItemEl); } } delete tmpEl; } pmap.pinClicked = function() { pmap.clickPin(this); } pmap.closePin = function(pinId) { var pinDetail = document.getElementById(pinId+'Detail'); pinDetail.style.display='none'; var pinEl = document.getElementById(pinId); pinEl.style.backgroundImage = 'url(/lib24watch/plugin_img/pmap/pin.gif)'; pinEl.style.width = '8px'; pinEl.style.height = '11px'; } pmap.clickPin = function(pinEl) { pinContainerEl = document.getElementById('pmapPinContainer'); // detail element doesn't exist yet, so create & show if(!(detailEl = document.getElementById(detailElId=pinEl.id+'Detail'))) { pinContainerEl.appendChild(detailEl = document.createElement('div')); detailEl.id = detailElId; detailEl.style.zIndex = 2; detailEl.style.position = 'absolute'; detailEl.className = 'pmapDetail'; detailEl.innerHTML = '

' + pinEl.pmapProp['PmapProp']['name'] + '

' + '
' + pinEl.pmapProp['PmapProp']['type'] + '
' + pinEl.pmapProp['PmapProp']['description'] + '
' + ''; photoContainerEl = document.getElementById('pmapPhotos_' + pinEl.pmapProp['PmapProp']['id']); // add images if(pinEl.pmapProp['PmapPropPhoto'].length == 0) photoContainerEl.style.display = 'none'; for(pmapPropPhotoK in pinEl.pmapProp['PmapPropPhoto']) { pmapPropPhoto = pinEl.pmapProp['PmapPropPhoto'][pmapPropPhotoK]; if(typeof(pmapPropPhoto['PmapPropPhotoThumbnail']) != 'undefined') { photoPEl = document.createElement('p'); photoImgEl = document.createElement('img'); photoPEl.appendChild(photoImgEl); photoImgEl.pmapPropPhoto = pmapPropPhoto; photoImgEl.src = '/lib24watch/lib24watch_files/view/' + pmapPropPhoto['PmapPropPhotoThumbnail']['id']; //photoImgEl.style.width = '200px'; //photoImgEl.style.height = '150px'; YAHOO.util.Event.addListener(photoImgEl, 'click', pmap.photoClicked); photoImgEl.style.cursor = 'pointer'; photoContainerEl.appendChild(photoPEl); } } YAHOO.util.Dom.setX(detailEl, YAHOO.util.Dom.getX(pinEl)+8); YAHOO.util.Dom.setY(detailEl, YAHOO.util.Dom.getY(pinEl)); externalLinks(); } // detail element already exists, so show else { detailEl.style.display = 'block'; } pinEl.style.backgroundImage = 'url(/lib24watch/plugin_img/pmap/pin2.gif)'; pinEl.style.width = '8px'; pinEl.style.height = '11px'; } pmap.photoClicked = function() { window.open('/lib24watch/lib24watch_files/view/' + this.pmapPropPhoto['id']); } // init YAHOO.util.Dom.addClass(document.body, 'yui-skin-sam'); // call main function, if available if(pmapMain) pmapMain(); else alert("pmapMain() not found"); });