1 function NovaButton() {
5 NovaButton.prototype = new GControl();
9 layerOptionContainer: null,
10 layerOptionVisible: false,
11 searchOptionContainer: null,
12 searchOptionVisible: false,
14 searchResultContainer: null,
16 searchTabSelected: null,
18 originalLayerState: null
21 NovaButton.globals.dragzoom = {
24 cornerBottomDiv: null,
37 // Creates a one DIV for each of the buttons and places them in a container
38 // DIV which is returned as our control element.
39 NovaButton.prototype.initialize = function(map) {
40 var container = document.createElement("div");
41 container.style.zIndex = "150";
45 var cursorDiv = document.createElement("div");
46 cursorDiv.id = "cursorDiv";
47 NovaButton.globals.currentButton = "cursorDiv";
48 this.setButtonStyle(cursorDiv, true);
49 cursorDiv.style.fontWeight = "bold";
50 cursorDiv.appendChild(document.createTextNode("Cursor"));
51 GEvent.addDomListener(cursorDiv, "click", function() {
52 var globals = NovaButton.globals;
53 if (globals.currentButton == "cursorDiv") {
57 this.style.fontWeight = "bold";
58 globals.currentButton = "cursorDiv";
59 if (!map.draggingEnabled()) {
62 document.getElementById("detailDiv").style.fontWeight = "normal";
63 document.getElementById("zoomRectangleDiv").style.fontWeight = "normal";
69 var detailDiv = document.createElement("div");
70 detailDiv.id = "detailDiv";
71 this.setButtonStyle(detailDiv, true);
72 detailDiv.appendChild(document.createTextNode("Detail"));
73 GEvent.addDomListener(detailDiv, "click", function() {
74 var globals = NovaButton.globals;
75 if (globals.currentButton == "detailDiv") {
79 this.style.fontWeight = "bold";
80 globals.currentButton = "detailDiv";
81 if (map.draggingEnabled()) {
82 map.disableDragging();
84 document.getElementById("cursorDiv").style.fontWeight = "normal";
85 document.getElementById("zoomRectangleDiv").style.fontWeight = "normal";
90 // zoom rectangle button
91 var zoomRectangleDiv = document.createElement("div");
92 zoomRectangleDiv.id = "zoomRectangleDiv";
93 this.setButtonStyle(zoomRectangleDiv, true);
94 zoomRectangleDiv.appendChild(document.createTextNode("Zoom Rect."));
95 GEvent.addDomListener(zoomRectangleDiv, "click", function() {
96 var globals = NovaButton.globals;
97 if (globals.currentButton == "zoomRectangleDiv") {
101 this.style.fontWeight = "bold";
102 globals.currentButton = "zoomRectangleDiv";
104 if (map.draggingEnabled()) {
105 map.disableDragging();
107 document.getElementById("cursorDiv").style.fontWeight = "normal";
108 document.getElementById("detailDiv").style.fontWeight = "normal";
114 var zoomInDiv = document.createElement("div");
115 this.setButtonStyle(zoomInDiv, true);
116 zoomInDiv.appendChild(document.createTextNode("Zoom In"));
117 // The "true" argument in the zoomIn() method allows continuous zooming
118 GEvent.addDomListener(zoomInDiv, "click", function() {
119 //map.zoomIn(null,null,true);
124 var zoomOutDiv = document.createElement("div");
125 this.setButtonStyle(zoomOutDiv, true);
126 zoomOutDiv.style.borderTop = 0+'px';
127 zoomOutDiv.appendChild(document.createTextNode("Zoom Out"));
128 // The "true" argument in the zoomOut() method allows continuous zooming
129 GEvent.addDomListener(zoomOutDiv, "click", function() {
130 //map.zoomOut(null,true);
134 // "Default View" button
135 var defaultViewDiv = document.createElement("div");
136 this.setButtonStyle(defaultViewDiv, true);
137 defaultViewDiv.appendChild(document.createTextNode("Default View"));
138 GEvent.addDomListener(defaultViewDiv, "click", function(e) {
139 that.defaultViewClickEvent();
143 var showLayerDiv = document.createElement("div");
144 this.setButtonStyle(showLayerDiv, true);
145 showLayerDiv.appendChild(document.createTextNode("Layers"));
146 GEvent.addDomListener(showLayerDiv, "click", function(e) {
147 that.showLayerClickEvent(e);
150 // initialize layer option
151 var layerOptionContainer = document.createElement("div");
152 this.setMenuContainerStyle(layerOptionContainer);
153 this.initializeLayerDiv(layerOptionContainer);
156 var searchDiv = document.createElement("div");
157 this.setButtonStyle(searchDiv, true);
158 searchDiv.appendChild(document.createTextNode("Search"));
159 GEvent.addDomListener(searchDiv, "click", function(e) {
160 that.searchClickEvent(e);
163 var searchOptionContainer = document.createElement("div");
164 searchOptionContainer.style.position = "absolute";
165 searchOptionContainer.style.left = "100px";
166 searchOptionContainer.style.top = "100px";
167 searchOptionContainer.style.display = "none";
168 this.initializeSearchDiv(searchOptionContainer);
170 var buttonContainer = document.createElement("div");
171 buttonContainer.appendChild(cursorDiv);
172 buttonContainer.appendChild(detailDiv);
173 //buttonContainer.appendChild(zoomRectangleDiv);
174 //buttonContainer.appendChild(zoomInDiv);
175 //buttonContainer.appendChild(zoomOutDiv);
176 //buttonContainer.appendChild(defaultViewDiv);
177 //buttonContainer.appendChild(showLayerDiv);
178 //buttonContainer.appendChild(searchDiv);
181 var zoomAreaDiv = document.createElement("div");
182 this.setZoomAreaStyle(zoomAreaDiv);
183 var DIVS_TO_CREATE = ['outlineDiv', 'cornerTopDiv', 'cornerLeftDiv', 'cornerRightDiv', 'cornerBottomDiv'];
184 for (var i=0; i<DIVS_TO_CREATE.length; i++) {
185 var id = DIVS_TO_CREATE[i];
186 var div = document.createElement("div");
187 div.style.position = "absolute";
188 div.style.display = "none";
189 zoomAreaDiv.appendChild(div);
190 NovaButton.globals.dragzoom[id] = div;
193 GEvent.addDomListener(zoomAreaDiv, 'mousedown', function(e) {
196 GEvent.addDomListener(document, 'mousemove', function(e) {
199 GEvent.addDomListener(document, 'mouseup', function(e) {
203 // assign global variable
204 NovaButton.globals.layerOptionContainer = layerOptionContainer;
205 NovaButton.globals.map = map;
206 NovaButton.globals.dragzoom.zoomArea = zoomAreaDiv;
207 NovaButton.globals.dragzoom.mapPosition = NovaButtonUtils.getElementPosition(map.getContainer());
208 NovaButton.globals.searchOptionContainer = searchOptionContainer;
209 this.setDimensions();
211 zoomAreaDiv.onselectstart = function() {return false;};
214 this.initZoomAreaStyles();
216 container.appendChild(buttonContainer);
217 map.getContainer().appendChild(container);
218 //map.getContainer().appendChild(layerOptionContainer);
219 //map.getContainer().appendChild(searchOptionContainer);
220 document.body.appendChild(layerOptionContainer);
221 document.body.appendChild(searchOptionContainer);
222 map.getContainer().appendChild(zoomAreaDiv);
227 // The control will appear in the top left corner of the map with 5 pixels of padding.
228 NovaButton.prototype.getDefaultPosition = function() {
229 return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(70, 5));
232 NovaButton.prototype.setSearchResultStyle = function(container) {
233 container.style.width = "300px";
234 container.style.height = "150px";
235 container.style.background = "#FFFFF0";
236 container.style.fontFamily = "Verdana";
237 container.style.fontSize = "12px";
238 container.style.position = "absolute";
239 container.style.border = "1px solid black";
240 container.style.top = "201px";
241 container.style.left = "0px";
242 container.style.display = "none";
243 container.style.overflow = "auto";
244 container.align = "left";
247 // Sets the proper CSS for the given button element.
248 NovaButton.prototype.setButtonStyle = function(button, horizontalAlign) {
249 button.style.color = "black";
250 button.style.backgroundColor = "white";
251 button.style.fontFamily = "Verdana";
252 button.style.fontSize = "12px";
253 button.style.fontWeight= "normal";
254 button.style.border = "1px solid gray";
255 button.style.padding = "0px";
256 button.style.marginBottom = "0px";
257 button.style.textAlign = "center";
258 button.style.width = "80px";
259 button.style.height = "15px";
260 button.style.cursor = "pointer";
261 //button.style.zIndex = "200";
263 if (horizontalAlign) {
264 if(button.addEventListener) {
265 button.style.cssFloat = "left" ;
268 button.style.styleFloat = "left" ;
273 NovaButton.prototype.setTabHeaderStyle = function(header) {
274 //header.style.position = "absolute";
275 //header.style.zIndex = "2";
276 header.align = "left";
279 NovaButton.prototype.setTabButtonStyle = function(tab) {
280 tab.style.padding = "3px 5px 3px 5px";
281 tab.style.fontFamily = "Verdana";
282 tab.style.fontSize = "12px";
283 tab.style.textAlign = "center";
284 tab.style.width = "7em";
285 tab.style.height = "15px";
286 tab.style.cursor = "pointer";
287 tab.style.background = "#C6DEFF";
289 if(tab.addEventListener) {
290 tab.style.cssFloat = "left" ;
293 tab.style.styleFloat = "left" ;
297 NovaButton.prototype.setTabBodyStyle = function(body) {
298 body.style.width = "400px";
299 body.style.height = "150px";
300 body.style.background = "#FFFFF0";
301 body.style.fontFamily = "Verdana";
302 body.style.fontSize = "12px";
303 //body.style.zIndex = "1";
304 body.style.padding = "3px 5px 3px 5px";
305 body.style.top = "20px";
306 body.style.left = "0px";
307 body.style.position = "absolute";
308 body.style.display = "none";
312 NovaButton.prototype.setTabFooterStyle = function(footer) {
313 footer.style.width = "400px";
314 footer.style.height = "20px";
315 footer.align = "center";
316 footer.style.padding = "3px 5px 3px 5px";
317 footer.style.background = "#FFFFF0";
318 footer.style.position = "absolute";
319 footer.style.top = "175px";
320 footer.style.left = "0";
323 NovaButton.prototype.tabMouseOver = function(e) {
324 var tab = Event.element(e);
325 tab.style.background = "#ADDFFF";
328 NovaButton.prototype.tabMouseOut = function(e) {
329 var tab = Event.element(e);
330 tab.style.background = "#C6DEFF";
333 NovaButton.prototype.tabClickEvent = function(e) {
334 var tab = Event.element(e);
336 if (tab.id == NovaButton.globals.searchTabSelected) {
340 NovaButton.globals.searchTabSelected = tab.id;
341 tab.style.fontWeight = "bold";
343 if (tab.id == "nodeTab") {
344 document.getElementById("nodeBody").style.display = "inline";
345 document.getElementById("addressBody").style.display = "none";
346 document.getElementById("addressTab").style.fontWeight = "normal";
349 document.getElementById("addressBody").style.display = "inline";
350 document.getElementById("nodeBody").style.display = "none";
351 document.getElementById("nodeTab").style.fontWeight = "normal";
355 NovaButton.prototype.initializeSearchDiv = function(searchOptionContainer) {
356 var header = document.createElement("div");
357 this.setTabHeaderStyle(header);
360 var nodeTab = header.appendChild(document.createElement("div"));
361 nodeTab.id = "nodeTab";
362 this.setTabButtonStyle(nodeTab);
363 nodeTab.appendChild(document.createTextNode("Node"));
364 GEvent.addDomListener(nodeTab, "mouseover", function(e) {
365 that.tabMouseOver(e);
367 GEvent.addDomListener(nodeTab, "mouseout", function(e) {
370 GEvent.addDomListener(nodeTab, "click", function(e) {
371 that.tabClickEvent(e);
374 var addressTab = header.appendChild(document.createElement("div"));
375 addressTab.id = "addressTab";
376 this.setTabButtonStyle(addressTab);
377 addressTab.appendChild(document.createTextNode("Address"));
378 GEvent.addDomListener(addressTab, "mouseover", function(e) {
379 that.tabMouseOver(e);
381 GEvent.addDomListener(addressTab, "mouseout", function(e) {
384 GEvent.addDomListener(addressTab, "click", function(e) {
385 that.tabClickEvent(e);
388 var body = document.createElement("div");
389 var nodeBody = body.appendChild(document.createElement("div"));
390 nodeBody.id = "nodeBody";
391 this.setTabBodyStyle(nodeBody);
392 this.initializeNodeBody(nodeBody);
394 var addressBody = body.appendChild(document.createElement("div"));
395 addressBody.id = "addressBody";
396 this.setTabBodyStyle(addressBody);
397 this.initializeAddressBody(addressBody);
400 var searchResultContainer = body.appendChild(document.createElement("div"));
401 searchResultContainer.style.opacity = "0.8";
402 searchResultContainer.style.filter = 'alpha(opacity=' + (0.6 * 100) + ')';
403 this.setSearchResultStyle(searchResultContainer);
406 var footer = document.createElement("div");
407 this.setTabFooterStyle(footer);
408 var buttonDiv = footer.appendChild(document.createElement("div"));
409 this.setButtonStyle(buttonDiv, false);
410 buttonDiv.appendChild(document.createTextNode("Submit"));
411 GEvent.addDomListener(buttonDiv, "click", function(e) {
412 that.submitSearchClickEvent(e);
415 searchOptionContainer.appendChild(header);
416 searchOptionContainer.appendChild(body);
417 searchOptionContainer.appendChild(footer);
418 //searchOptionContainer.appendChild(nodeBody);
419 //searchOptionContainer.appendChild(addressBody);
422 nodeTab.style.fontWeight = "bold";
423 nodeBody.style.display = "inline";
424 NovaButton.globals.searchTabSelected = "nodeTab";
426 NovaButton.globals.searchResultContainer = searchResultContainer;
430 NovaButton.prototype.initializeNodeBody = function(nodeBody) {
431 var searchByNodeId = document.createElement("input");
432 searchByNodeId.type = "radio";
433 searchByNodeId.defaultChecked = true;
434 searchByNodeId.name = "nodeGroup";
435 searchByNodeId.id = "searchByNodeId";
436 searchByNodeId.value = "searchByNodeId";
437 searchByNodeId.onclick = function () {
438 searchByLocation.checked = false;
439 searchByNodeId.checked = true;
441 nodeBody.appendChild(searchByNodeId);
442 nodeBody.appendChild(document.createTextNode("Node ID"));
443 nodeBody.appendChild(document.createElement("br"));
445 var searchByLocation = document.createElement("input");
446 searchByLocation.type = "radio";
447 searchByLocation.defaultChecked = false;
448 searchByLocation.name = "nodeGroup";
449 searchByLocation.id = "searchByLocation";
450 searchByLocation.value = "searchByLocation";
452 searchByLocation.onclick = function () {
453 searchByLocation.checked = true;
454 searchByNodeId.checked = false;
456 nodeBody.appendChild(searchByLocation);
457 nodeBody.appendChild(document.createTextNode("Node Location"));
458 nodeBody.appendChild(document.createElement("br"));
459 nodeBody.appendChild(document.createElement("br"));
461 var exactMatchSearch = document.createElement("input");
462 exactMatchSearch.type = "checkbox";
463 exactMatchSearch.id = "exactMatch";
464 nodeBody.appendChild(exactMatchSearch);
465 nodeBody.appendChild(document.createTextNode("Exact Match"));
466 nodeBody.appendChild(document.createElement("br"));
468 var searchInput = document.createElement("input");
469 searchInput.id = "nodeSearchInput";
470 searchInput.setAttribute("type", "text");
471 searchInput.setAttribute("size", "60");
473 nodeBody.appendChild(searchInput);
476 NovaButton.prototype.initializeAddressBody = function(addressBody) {
477 var addressLabel = addressBody.appendChild(document.createElement("div"));
478 addressLabel.appendChild(document.createTextNode("Enter address (e.g. 180 park ave, florham park, nj 07932)"));
480 var searchInput = document.createElement("input");
481 searchInput.id = "addressSearchInput";
482 searchInput.setAttribute("type", "text");
483 searchInput.setAttribute("size", "60");
485 addressBody.appendChild(searchInput);
489 NovaButton.prototype.setSearchResult = function(jsonData) {
490 var resultContainer = NovaButton.globals.searchResultContainer;
491 for (var i = resultContainer.childNodes.length - 1; i >= 0; i--) {
492 resultContainer.removeChild(resultContainer.lastChild);
495 var table = resultContainer.appendChild(document.createElement("table"));
496 var tbody = table.appendChild(document.createElement("tbody"));
497 var list = jsonData.list;
500 var tr = tbody.appendChild(document.createElement("tr"));
501 var td = tr.appendChild(document.createElement("td"));
502 td.appendChild(document.createTextNode("Not Found"));
503 td.style.fontSize = "12px";
504 td.style.textDecoration = "none";
505 td.font = "Arial,Helvetica,sans-serif";
506 td.style.fontWeight = "normal";
509 for (var i = 0; i < list.length; i++) {
510 var tr = tbody.appendChild(document.createElement("tr"));
511 var td = tr.appendChild(document.createElement("td"));
513 td.appendChild(document.createTextNode(list[i].type + "(" + list[i].numberOfT1 +
514 "): " + list[i].id));
515 td.style.fontSize = "12px";
516 td.style.textDecoration = "underline";
517 td.style.color = "blue";
518 td.style.fontWeight = "normal";
519 td.style.cursor = "pointer";
520 td.font = "Arial,Helvetica,sans-serif";
521 td.id = list[i].latitude + ">>" + list[i].longitude;
523 td.onmouseover = function() {
524 this.style.fontWeight = "bold";
527 td.onmouseout = function() {
528 this.style.fontWeight = "normal";
531 td.onclick = function() {
532 this.style.color = "red";
533 var latitudeLongitude = this.id.split(">>");
534 var latlng = new GLatLng(latitudeLongitude[0], latitudeLongitude[1]);
535 map.setCenter(latlng, 17);
541 resultContainer.style.display = "";
544 NovaButton.prototype.initializeLayerDiv = function(layerDiv) {
545 for (var i = layerDiv.childNodes.length - 1; i >= 0; i--) {
546 layerDiv.removeChild(layerDiv.lastChild);
549 var colorList = document.getElementById("colorList").value;
550 var selectedLayerList = document.getElementById("selectedLayerList").value;
551 var colorArray = colorList.split("~!");
552 var selectedColorArray = selectedLayerList.split("~!");
553 //layerDiv.style.background = "white";
554 var table = layerDiv.appendChild(document.createElement("table"));
557 //this.setMenuStyle(table);
558 /****Creating the data table****/
559 var tbody = table.appendChild(document.createElement("tbody"));
562 var originalLayerState = new Array();
563 for (i = 0; i < colorArray.length; i++) {
564 tr = tbody.appendChild(document.createElement("tr"));
565 tr.style.height="20px";
566 var colorItem = colorArray[i].split(",");
568 td = tr.appendChild(document.createElement("td"));
569 var chkbox = document.createElement("input");
570 chkbox.type="checkbox";
571 chkbox.name = "" + colorItem[0] + "chk";
572 chkbox.value = colorItem[0];
573 chkbox.id = colorItem[0] + "chk";
574 if (this.checkIfColorSelected(selectedColorArray, colorItem[0]) == true){
575 chkbox.defaultChecked=true;
576 originalLayerState[i] = "true," + colorArray[i];
579 originalLayerState[i] = "false," + colorArray[i];
581 td.appendChild(chkbox);
583 td = tr.appendChild(document.createElement("td"));
585 td.appendChild(document.createTextNode(colorItem[0]));
586 td.style.fontFamily = "Verdana";
587 td.style.fontSize = "12px";
589 td = tr.appendChild(document.createElement("td"));
591 //td.style.background = colorItem[1];
592 td.innerHTML="<input type='text' id='" + colorItem[0] + "colorbx' value='" + colorItem[1] + "' size='6' style='background-color:#" + colorItem[1] + "' background-color='#" + colorItem[1] + "' onclick='openPicker(\"" + colorItem[0] + "colorbx\")'/>"
593 tbody.appendChild(tr);
596 NovaButton.globals.originalLayerState = originalLayerState;
598 /**to get rid of extra space**/
599 /*var layerHeight = layerDiv.style.height.substring(0, layerDiv.style.height.length -2);
600 if (colorArray.length * 30 < layerHeight){
601 tr = tbody.appendChild(document.createElement("tr"));
602 tr.height= (layerHeight - (colorArray.length * 40 ) ) + "px";
603 td = tr.appendChild(document.createElement("td"));
607 tr = tbody.appendChild(document.createElement("tr"));
609 tr.style.height="20px";
610 td = tr.appendChild(document.createElement("td"));
612 var buttonTable = td.appendChild(document.createElement("table"));
613 buttonTable.height="100%";
614 buttonTable.width="100%";
616 var buttonBody = buttonTable.appendChild(document.createElement("tbody"));
617 tr = buttonBody.appendChild(document.createElement("tr"));
618 td = tr.appendChild(document.createElement("td"));
620 td = tr.appendChild(document.createElement("td"));
621 td.appendChild(document.createTextNode("OK"));
622 td.onclick = function ()
624 var selectedLayers = "";
627 var originalLayerState = NovaButton.globals.originalLayerState;
628 //saving the user selected choices
629 for (i = 0; i < colorArray.length; i++) {
630 var colorItem = colorArray[i].split(",");
631 //saving the selected layers
632 var temp; // variable to hold changes value
633 if (document.getElementById("" + colorItem[0] + "chk").checked == true){
634 selectedLayers = selectedLayers + "~!" + colorItem[0];
635 temp = "true," + colorItem[0];
638 temp = "false," + colorItem[0];
640 //saving the colours of all the layers
641 var userSelectedColor = document.getElementById("" + colorItem[0] + "colorbx").value;
642 if (userSelectedColor.charAt(0) == '#') {
643 userSelectedColor = userSelectedColor.substring(1);
645 colorList = colorList + "~!" + colorItem[0] + "," + userSelectedColor;
646 temp = temp + "," + userSelectedColor;
648 //check to see if there is anything change and update
649 // originalLayerState to reflect the changes
651 originalLayerState[i] = temp;
653 else if (originalLayerState[i] != temp) {
655 originalLayerState[i] = temp;
658 selectedLayers = selectedLayers.substring(2, selectedLayers.length);
659 colorList = colorList.substring(2, colorList.length);
660 document.getElementById("selectedLayerList").value = selectedLayers;
661 document.getElementById("colorList").value = colorList;
663 // update if there is anything change
668 //to remove the layer
669 NovaButton.prototype.showLayerClickEvent();
672 this.setButtonStyle(td, true);
673 td.style.cursor = "hand";
675 td = tr.appendChild(document.createElement("td"));
676 td.appendChild(document.createTextNode("Cancel"));
678 this.setButtonStyle(td, true);
679 td.style.cursor = "hand";
680 td.onclick = function ()
682 //remove all the contents
683 layerDiv.innerHTML="";
684 //re-initiate the layers to original values
685 NovaButton.prototype.initializeLayerDiv(layerDiv);
686 NovaButton.prototype.showLayerClickEvent();
688 td = tr.appendChild(document.createElement("td"));
693 NovaButton.prototype.checkIfColorSelected= function(selectedColorArray, colorItem) {
694 for (j = 0; j < selectedColorArray.length; j++) {
695 if (selectedColorArray[j] == colorItem){
702 NovaButton.prototype.setMenuContainerStyle = function(menuContainer) {
703 menuContainer.style.position = "absolute";
704 menuContainer.style.background = "#FFFFF0"
705 menuContainer.style.overflow = "auto";
706 menuContainer.style.scrolling="yes";
707 menuContainer.style.display = "none";
708 menuContainer.style.width = "300px";
709 menuContainer.style.height = "300px";
712 NovaButton.prototype.setMenuStyle = function(menu) {
713 menu.style.width = "300px";
714 menu.style.height = "300px";
715 menu.style.background = "#FFF";
718 NovaButton.prototype.setMenuItemStyle = function(menuItem) {
719 menuItem.style.padding = "4px 3px 4px 33px";
720 menuItem.style.fontFamily = "Vardana, Arial, Helvetica, sans-serif" ;
721 menuItem.style.fontSize = "10pt";
722 menuItem.style.color = "#333" ;
723 menuItem.style.cursor = "default" ;
724 menuItem.style.background = "no-repeat left center" ;
727 NovaButton.prototype.showLayerOption = function(posX, posY) {
728 var globals = NovaButton.globals;
730 //position the menu at the given location
731 if(typeof posX == "number") {
732 globals.layerOptionContainer.style.left = posX + "px";
735 if(typeof posY == "number") {
736 globals.layerOptionContainer.style.top = posY + "px";
739 var resultContainer = globals.searchResultContainer;
740 resultContainer.style.display = "none";
743 globals.layerOptionContainer.style.display = "block";
746 NovaButton.prototype.showSearchOption = function(posX, posY) {
747 var globals = NovaButton.globals;
749 //position the menu at the given location
750 if(typeof posX == "number") {
751 globals.searchOptionContainer.style.left = posX + "px";
754 if(typeof posY == "number") {
755 globals.searchOptionContainer.style.top = posY + "px";
759 globals.searchOptionContainer.style.display = "inline";
762 NovaButton.prototype.defaultViewClickEvent = function() {
763 var defaultZoomLevel = document.getElementById("defaultZoomLevel").value * 1;
764 map.setCenter(new GLatLng(document.getElementById("defaultCenterLatitude").value,
765 document.getElementById("defaultCenterLongitude").value),
770 NovaButton.prototype.showLayerClickEvent = function(e) {
771 if (NovaButton.globals.layerOptionVisible) {
772 //to remove the color picker
774 NovaButton.globals.layerOptionVisible = false;
775 NovaButton.globals.layerOptionContainer.style.display = "none";
779 if (NovaButton.globals.searchOptionContainer.style.display != "none"){
780 NovaButton.prototype.searchClickEvent();
782 if (CingularButton.globals.listOptionContainer.style.display != "none"){
783 currentMonthClickEvent();
790 e.cancelBubble = true;
792 if (e.stopPropagation) {
796 var button = Event.element(e);
797 var posX = button.offsetLeft;
798 var posY = button.offsetTop;
799 this.showLayerOption(posX, posY + button.offsetHeight);
800 NovaButton.globals.layerOptionVisible = true;
803 NovaButton.prototype.searchClickEvent = function(e) {
804 if (NovaButton.globals.searchOptionVisible) {
805 NovaButton.globals.searchOptionVisible = false;
806 NovaButton.globals.searchOptionContainer.style.display = "none";
810 if (NovaButton.globals.layerOptionContainer.style.display != "none"){
811 NovaButton.prototype.showLayerClickEvent();
813 if (CingularButton.globals.listOptionContainer.style.display != "none"){
814 currentMonthClickEvent();
821 e.cancelBubble = true;
823 if (e.stopPropagation) {
827 var button = Event.element(e);
828 var posX = button.offsetLeft;
829 var posY = button.offsetTop;
830 this.showSearchOption(posX, posY + button.offsetHeight + 3);
831 NovaButton.globals.searchOptionVisible = true;
834 NovaButton.prototype.submitSearchClickEvent = function(e) {
835 if (NovaButton.globals.searchTabSelected == "nodeTab") {
836 var input = document.getElementById("nodeSearchInput").value.trim();
838 if (input.length == 0) {
839 alert("Input field required");
845 var searchByNodeId = document.getElementById("searchByNodeId");
847 if (searchByNodeId.checked) {
848 searchType = searchByNodeId.value;
851 searchType = document.getElementById("searchByLocation").value;
854 var checkbox = document.getElementById("exactMatch");
856 searchObject(input, searchType, checkbox.checked, e.clientX, e.clientY);
859 var address = document.getElementById("addressSearchInput").value.trim();
861 if (address.length == 0) {
862 alert("Address field required");
870 if (addressMarker == null) {
871 addressMarker = new GMarker(ll);
872 map.addOverlay(addressMarker);
873 GEvent.addListener(addressMarker, "click", marker_onclick);
876 addressMarker.setLatLng(ll);
886 this.searchClickEvent(e);
889 function marker_onclick() {
890 map.removeOverlay(addressMarker);
891 addressMarker = null;
894 // start drag zoom function
895 NovaButton.prototype.initCover = function() {
896 var dragZoomGlobals = NovaButton.globals.dragzoom;
897 dragZoomGlobals.mapPosition = NovaButtonUtils.getElementPosition(NovaButton.globals.map.getContainer());
898 this.setDimensions();
900 dragZoomGlobals.zoomArea.style.display = "block";
901 dragZoomGlobals.zoomArea.style.background = "#000";
903 dragZoomGlobals.outlineDiv.style.width = "0px";
904 dragZoomGlobals.outlineDiv.style.height = "0px";
907 NovaButton.prototype.initZoomAreaStyles = function(){
908 var dragZoomGlobals = NovaButton.globals.dragzoom;
909 dragZoomGlobals.zoomArea.style.background = "#000";
910 dragZoomGlobals.zoomArea.style.opacity = "0.2";
911 dragZoomGlobals.zoomArea.style.filter = 'alpha(opacity=' + (0.2 * 100) + ')';
913 dragZoomGlobals.cornerTopDiv.style.background = "#000";
914 dragZoomGlobals.cornerTopDiv.style.opacity = "0.2";
915 dragZoomGlobals.cornerTopDiv.style.filter = 'alpha(opacity=' + (0.2 * 100) + ')';
917 dragZoomGlobals.cornerRightDiv.style.background = "#000";
918 dragZoomGlobals.cornerRightDiv.style.opacity = "0.2";
919 dragZoomGlobals.cornerRightDiv.style.filter = 'alpha(opacity=' + (0.2 * 100) + ')';
921 dragZoomGlobals.cornerBottomDiv.style.background = "#000";
922 dragZoomGlobals.cornerBottomDiv.style.opacity = "0.2";
923 dragZoomGlobals.cornerBottomDiv.style.filter = 'alpha(opacity=' + (0.2 * 100) + ')';
925 dragZoomGlobals.cornerLeftDiv.style.background = "#000";
926 dragZoomGlobals.cornerLeftDiv.style.opacity = "0.2";
927 dragZoomGlobals.cornerLeftDiv.style.filter = 'alpha(opacity=' + (0.2 * 100) + ')';
929 dragZoomGlobals.outlineDiv.style.border = "2px solid blue";
932 NovaButton.prototype.resetDragZoom = function() {
933 var dragZoomGlobals = NovaButton.globals.dragzoom;
934 dragZoomGlobals.zoomArea.style.display = "none";
935 dragZoomGlobals.zoomArea.style.opacity = "0.2";
936 dragZoomGlobals.zoomArea.style.filter = 'alpha(opacity=' + (0.2 * 100) + ')';
938 dragZoomGlobals.cornerTopDiv.style.display = "none";
939 dragZoomGlobals.cornerTopDiv.style.opacity = "0.2";
940 dragZoomGlobals.cornerTopDiv.style.filter = 'alpha(opacity=' + (0.2 * 100) + ')';
942 dragZoomGlobals.cornerRightDiv.style.display = "none";
943 dragZoomGlobals.cornerRightDiv.style.opacity = "0.2";
944 dragZoomGlobals.cornerRightDiv.style.filter = 'alpha(opacity=' + (0.2 * 100) + ')';
946 dragZoomGlobals.cornerBottomDiv.style.display = "none";
947 dragZoomGlobals.cornerBottomDiv.style.opacity = "0.2";
948 dragZoomGlobals.cornerBottomDiv.style.filter = 'alpha(opacity=' + (0.2 * 100) + ')';
950 dragZoomGlobals.cornerLeftDiv.style.display = "none";
951 dragZoomGlobals.cornerLeftDiv.style.opacity = "0.2";
952 dragZoomGlobals.cornerLeftDiv.style.filter = 'alpha(opacity=' + (0.2 * 100) + ')';
954 dragZoomGlobals.outlineDiv.style.display = 'none';
957 NovaButton.prototype.setZoomAreaStyle = function(zoomArea) {
958 zoomArea.style.position = "absolute";
959 zoomArea.style.display = "none";
960 zoomArea.style.overflow = "hidden";
961 zoomArea.style.cursor = "crosshair";
962 zoomArea.style.zIndex = "101";
965 NovaButton.prototype.getRectangle = function(startX, startY, pos){
968 var dX = pos.left - startX;
969 var dY = pos.top - startY;
978 delta = dX > dY ? dX : dY;
992 NovaButton.prototype.mouseDown = function(e) {
993 if (NovaButton.globals.currentButton != "zoomRectangleDiv") {
997 var dragZoomGlobals = NovaButton.globals.dragzoom;
998 var pos = this.getRelPos(e);
999 dragZoomGlobals.startX = pos.left;
1000 dragZoomGlobals.startY = pos.top;
1002 dragZoomGlobals.zoomArea.style.background = "transparent";
1003 dragZoomGlobals.zoomArea.style.opacity = "1";
1004 dragZoomGlobals.zoomArea.style.filter = 'alpha(opacity=100)';
1006 dragZoomGlobals.outlineDiv.style.left = dragZoomGlobals.startX + "px";
1007 dragZoomGlobals.outlineDiv.style.top = dragZoomGlobals.startY + "px";
1008 dragZoomGlobals.outlineDiv.style.display = "block";
1009 dragZoomGlobals.outlineDiv.style.width = "1px";
1010 dragZoomGlobals.outlineDiv.style.height = "1px";
1012 dragZoomGlobals.cornerTopDiv.style.top = (dragZoomGlobals.startY - dragZoomGlobals.mapHeight) + 'px';
1013 dragZoomGlobals.cornerTopDiv.style.display ='block';
1014 dragZoomGlobals.cornerLeftDiv.style.left = (dragZoomGlobals.startX - dragZoomGlobals.mapWidth) +'px';
1015 dragZoomGlobals.cornerLeftDiv.style.top = dragZoomGlobals.startY + 'px';
1016 dragZoomGlobals.cornerLeftDiv.style.display = 'block';
1018 dragZoomGlobals.cornerRightDiv.style.left = dragZoomGlobals.startX + 'px';
1019 dragZoomGlobals.cornerRightDiv.style.top = dragZoomGlobals.startY + 'px';
1020 dragZoomGlobals.cornerRightDiv.style.display = 'block';
1021 dragZoomGlobals.cornerBottomDiv.style.left = dragZoomGlobals.startX + 'px';
1022 dragZoomGlobals.cornerBottomDiv.style.top = dragZoomGlobals.startY + 'px';
1023 dragZoomGlobals.cornerBottomDiv.style.width = '0px';
1024 dragZoomGlobals.cornerBottomDiv.style.display = 'block';
1026 dragZoomGlobals.moving = true;
1031 NovaButton.prototype.mouseMove = function(e) {
1032 var dragZoomGlobals = NovaButton.globals.dragzoom;
1034 if(dragZoomGlobals.moving) {
1035 var pos = this.getRelPos(e);
1036 var rect = this.getRectangle(dragZoomGlobals.startX, dragZoomGlobals.startY, pos);
1045 addY = -rect.height;
1050 dragZoomGlobals.outlineDiv.style.left = dragZoomGlobals.startX + addX + "px";
1051 dragZoomGlobals.outlineDiv.style.top = dragZoomGlobals.startY + addY + "px";
1052 dragZoomGlobals.outlineDiv.style.display = "block";
1053 dragZoomGlobals.outlineDiv.style.width = rect.width + "px";
1054 dragZoomGlobals.outlineDiv.style.height = rect.height + "px";
1056 dragZoomGlobals.cornerTopDiv.style.height = ((dragZoomGlobals.startY + addY) - (dragZoomGlobals.startY - dragZoomGlobals.mapHeight)) + 'px';
1057 dragZoomGlobals.cornerLeftDiv.style.top = (dragZoomGlobals.startY + addY) + 'px';
1058 dragZoomGlobals.cornerLeftDiv.style.width = ((dragZoomGlobals.startX + addX) - (dragZoomGlobals.startX - dragZoomGlobals.mapWidth)) + 'px';
1059 dragZoomGlobals.cornerRightDiv.style.top = dragZoomGlobals.cornerLeftDiv.style.top;
1060 dragZoomGlobals.cornerRightDiv.style.left = (dragZoomGlobals.startX + addX + rect.width + 4) + 'px';
1061 dragZoomGlobals.cornerBottomDiv.style.top = (dragZoomGlobals.startY + addY + rect.height + 4) + 'px';
1062 dragZoomGlobals.cornerBottomDiv.style.left = (dragZoomGlobals.startX - dragZoomGlobals.mapWidth + ((dragZoomGlobals.startX + addX) - (dragZoomGlobals.startX - dragZoomGlobals.mapWidth))) + 'px';
1063 dragZoomGlobals.cornerBottomDiv.style.width = (rect.width + 4) + 'px';
1069 NovaButton.prototype.mouseUp = function(e) {
1070 var dragZoomGlobals = NovaButton.globals.dragzoom;
1071 var map = NovaButton.globals.map;
1073 if (dragZoomGlobals.moving) {
1074 var pos = this.getRelPos(e);
1075 dragZoomGlobals.moving = false;
1077 var rect = this.getRectangle(dragZoomGlobals.startX, dragZoomGlobals.startY, pos);
1080 rect.endX = rect.startX - rect.width;
1084 rect.endY = rect.startY - rect.height;
1087 this.resetDragZoom();
1089 if (rect.width >= 0 && rect.height >= 0) {
1090 var nwpx = new GPoint(rect.startX, rect.startY);
1091 var nepx = new GPoint(rect.endX, rect.startY);
1092 var sepx = new GPoint(rect.endX, rect.endY);
1093 var swpx = new GPoint(rect.startX, rect.endY);
1094 var nw = NovaButton.globals.map.fromContainerPixelToLatLng(nwpx);
1095 var ne = NovaButton.globals.map.fromContainerPixelToLatLng(nepx);
1096 var se = NovaButton.globals.map.fromContainerPixelToLatLng(sepx);
1097 var sw = NovaButton.globals.map.fromContainerPixelToLatLng(swpx);
1099 var zoomAreaPoly = new GPolyline([nw, ne, se, sw, nw], "blue", 3, .4);
1100 var polyBounds = zoomAreaPoly.getBounds();
1101 var ne = polyBounds.getNorthEast();
1102 var sw = polyBounds.getSouthWest();
1103 var se = new GLatLng(sw.lat(), ne.lng());
1104 var nw = new GLatLng(ne.lat(), sw.lng());
1105 var zoomLevel = map.getBoundsZoomLevel(polyBounds);
1106 var center = polyBounds.getCenter();
1107 map.setCenter(center, zoomLevel);
1114 NovaButton.prototype.setDimensions = function() {
1115 var dragZoomGlobals = NovaButton.globals.dragzoom;
1116 var mapSize = NovaButton.globals.map.getSize();
1117 dragZoomGlobals.mapWidth = mapSize.width;
1118 dragZoomGlobals.mapHeight = mapSize.height;
1119 dragZoomGlobals.mapRatio = dragZoomGlobals.mapHeight / dragZoomGlobals.mapWidth;
1120 // set left:0px in next <div>s in case we inherit text-align:center from map <div> in IE.
1121 dragZoomGlobals.zoomArea.style.top = "0px";
1122 dragZoomGlobals.zoomArea.style.left = "0px";
1123 dragZoomGlobals.zoomArea.style.width = dragZoomGlobals.mapWidth + "px";
1124 dragZoomGlobals.zoomArea.style.height = dragZoomGlobals.mapHeight + "px";
1126 dragZoomGlobals.cornerTopDiv.style.top = "0px";
1127 dragZoomGlobals.cornerTopDiv.style.left = "0px";
1128 dragZoomGlobals.cornerTopDiv.style.width = dragZoomGlobals.mapWidth + "px";
1129 dragZoomGlobals.cornerTopDiv.style.height = dragZoomGlobals.mapHeight + "px";
1131 dragZoomGlobals.cornerRightDiv.style.top = "0px";
1132 dragZoomGlobals.cornerRightDiv.style.left = "0px";
1133 dragZoomGlobals.cornerRightDiv.style.width = dragZoomGlobals.mapWidth + "px";
1134 dragZoomGlobals.cornerRightDiv.style.height = dragZoomGlobals.mapHeight + "px";
1136 dragZoomGlobals.cornerBottomDiv.style.top = "0px";
1137 dragZoomGlobals.cornerBottomDiv.style.left = "0px";
1138 dragZoomGlobals.cornerBottomDiv.style.width = dragZoomGlobals.mapWidth + "px";
1139 dragZoomGlobals.cornerBottomDiv.style.height = dragZoomGlobals.mapHeight + "px";
1141 dragZoomGlobals.cornerLeftDiv.style.top = "0px";
1142 dragZoomGlobals.cornerLeftDiv.style.left = "0px";
1143 dragZoomGlobals.cornerLeftDiv.style.width = dragZoomGlobals.mapWidth + "px";
1144 dragZoomGlobals.cornerLeftDiv.style.height = dragZoomGlobals.mapHeight + "px";
1147 NovaButton.prototype.getRelPos = function(e) {
1148 var pos = NovaButtonUtils.getMousePosition(e);
1149 var dragZoomGlobals = NovaButton.globals.dragzoom;
1150 return {top: (pos.top - dragZoomGlobals.mapPosition.top),
1151 left: (pos.left - dragZoomGlobals.mapPosition.left)};
1153 // end drag zoom function
1155 var NovaButtonUtils = {
1158 NovaButtonUtils.getElementPosition = function(element) {
1159 var leftPos = element.offsetLeft; // initialize var to store calculations
1160 var topPos = element.offsetTop; // initialize var to store calculations
1161 var parElement = element.offsetParent; // identify first offset parent element
1162 while (parElement != null ) { // move up through element hierarchy
1163 leftPos += parElement.offsetLeft; // appending left offset of each parent
1164 topPos += parElement.offsetTop;
1165 parElement = parElement.offsetParent; // until no more offset parents exist
1167 return {left: leftPos, top: topPos};
1170 NovaButtonUtils.getMousePosition = function(e) {
1173 if (!e) var e = window.event;
1174 if (e.pageX || e.pageY) {
1177 } else if (e.clientX || e.clientY){
1179 (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
1181 (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
1183 return {left: posX, top: posY};