Changeset 33145 for main


Ignore:
Timestamp:
2019-06-11T19:11:35+12:00 (5 years ago)
Author:
wy59
Message:
  1. Merging improvements of map-scripts::toggleSection() into classifier_scripts::toggleSection(), as the code was intended originally to be mostly duplicated. But improvements had been made to map-scripts::toggleSection independently, so bringing those across. 2. Likewise, map-scripts::httpRequest() originally largely duplicated classifier_scripts::httpRequest(), but documentbasket related conditional branch may have been added at a later point and had not been ported across into the map-scripts version. With Dr Bainbridge's permission, we've now done that. 3. Rest is cleanup
Location:
main/trunk/greenstone3/web/interfaces/default/js
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/js/classifier_scripts.js

    r33128 r33145  
    3737   
    3838    //If the div exists
    39     if(section.length)
     39    // Test if 'section' exists. 
     40    // ==> Because we're using jQuery to do this we need to test the length of the object returned
     41    // http://stackoverflow.com/questions/920236/how-can-i-detect-if-a-selector-returns-null
     42    if(section.length !== 0)
    4043    {
    4144        if(isExpanded(sectionID))
     
    4447            sectionToggle.attr("src", gs.imageURLs.expand);
    4548
    46             if(openClassifiers[sectionID] != undefined)
     49            if(openClassifiers[sectionID].length !== 0) //if(openClassifiers[sectionID] != undefined)
    4750            {
    4851                delete openClassifiers[sectionID];
  • main/trunk/greenstone3/web/interfaces/default/js/map-scripts.js

    r33143 r33145  
    346346                doc.marker.setVisible(true);
    347347            }
    348             markersOnMap++; // TODO: what do we do with this when we have shapes. This variable may be connected with centring the map?
     348            markersOnMap++;
    349349        }
    350350
     
    364364    if(markersOnMap > 1)
    365365    {
    366         //alert("@@@@ fitting bounds, current zoom is: " + _map.getZoom());         
    367366    _map.fitBounds(bounds);
    368367    } else if (markersOnMap == 1) {
     
    404403    for(var i = 0; i < _docList.ids.length; i++)
    405404    {
    406         var doc = _docList.getDocByIndex(i);
     405        var doc = _docList.getDocByIndex(i);
    407406        if(doc.marker.getVisible())
    408407        {
     
    439438}
    440439
    441 // Unused at present, called by draggableCreateMarker
    442 // Map used to have editable markers. Now editable markers are restricted to the map-editor.
    443 function attachDraggableClickHandler(marker, nodeID)
    444 {   
    445     google.maps.event.addListener(marker, 'click', function()
    446     {
    447         document.location.href = gs.xsltParams.library_name + "?a=d&ed=1&c=" + gs.cgiParams.c + "&d=" + nodeID + "&dt=hierarchy&p.a=b&p.sa=&p.s=ClassifierBrowse";
    448        
    449     });
    450    
    451     if (("docEdit" in gs.cgiParams) && (gs.cgiParams['docEdit'])) {
    452         google.maps.event.addListener(marker, 'mouseup', function()
    453         {
    454             var lat = marker.getPosition().lat();
    455             var lng = marker.getPosition().lng();
    456             var collection = gs.cgiParams.c;
    457             var site_name = gs.xsltParams.site_name;
    458            
    459             if (nodeID == "") {
    460                 nodeID = gs.cgiParams.d;
    461             }
    462             console.log("GPS Click handler in collection:" + collection + " in site: " + site_name + " for Doc: " + nodeID + "(" + lat + "," + lng + ")");
    463            
    464             var callbackFunction = function(){console.log("Completed saving metadata changes. You must rebuild the collection for the changes to take effect.");};
    465    
    466             // set 5th parameter, metapos (metadata position) or 7th param prevMetaValue (previous metadata value) to non-null if you want metamode=override to work
    467             // if neither of these 2 are set, then metamode is changed to 'accumulate' instead.
    468             gs.functions.setArchivesMetadata(collection, site_name, nodeID, "Latitude", null, lat, null, "override", function(){callbackFunction();});
    469             gs.functions.setArchivesMetadata(collection, site_name, nodeID, "Longitude", null, lng, null, "override", function(){callbackFunction();});
    470             gs.functions.setArchivesMetadata(collection, site_name, nodeID, "Coordinate", null, lat + " " + lng, null, "override", function(){callbackFunction();});
    471             console.log("NodeID: " + nodeID);
    472             console.log("GPS Click handler in collection:" + collection + " in site: " + site_name + " for Doc: " + nodeID + "(" + lat + "," + lng + ")");
    473         });
    474     }
    475 }
    476440
    477441function focusDocument(id)
     
    673637        document.location.href = gs.xsltParams.library_name + "?a=d&ed=1&c=" + gs.cgiParams.c + "&d=" + nodeID + "&dt=hierarchy&p.a=b&p.sa=&p.s=ClassifierBrowse";
    674638    });
    675 }
    676 
    677 // TODO:
    678 // Version of createMarker function containing Zeddy's modifications (pre-mapeditor?) to make markers
    679 // on the public *map* (not on map-editor) draggable/editable and to save these edits/rebuild with them.
    680 // Do we want to continue supporting editing on the main map? I thought we weren't going to and that editing
    681 // was exclusive to the map-editor, with the public map only displaying the saved features?
    682 function draggableCreateMarker(doc, pos, mainMarker)
    683 {
    684     var docEdit = (("docEdit" in gs.cgiParams) && (gs.cgiParams['docEdit']));
    685     //var draggable_val = (docEdit) ? true : false;
    686    
    687     // When user logs out, the very first page they're returned to has logout set
    688     // If the user logged out when leaving docEdit on, then the very first page has docEdit=1 AND logout.
    689     // In that case, don't allow editing. Subsequent pages in logged out mode have neither logout nor docEdit=1 set.
    690     var loggedOutVar = ("logout" in gs.cgiParams);
    691    
    692     // Don't allow dragging if either 1. docEdit not on OR 2. logout is in the cgiParams
    693     var draggable_val = (!docEdit || loggedOutVar) ? false : true;
    694    
    695     var marker;
    696     if(mainMarker)
    697     {
    698         marker = new google.maps.Marker
    699         ({
    700             position: pos,
    701             title:doc.title,
    702             map:_map,
    703             draggable: draggable_val
    704         });
    705     }
    706     else
    707     {
    708         marker = new google.maps.Marker
    709         ({
    710             position: pos,
    711             title:doc.title,
    712             map:_map,
    713             icon:"interfaces/" + gs.xsltParams.interface_name + "/images/bluemarker.png",
    714             draggable: draggable_val
    715         });
    716     }
    717    
    718     var docElement = gs.jqGet("div" + doc.nodeID);
    719     var parent;
    720     if(docElement)
    721     {
    722         parent = docElement.parentNode;
    723     }
    724 
    725     while(parent && parent.nodeName != "BODY")
    726     {
    727         if($(parent).attr("id") && $(parent).attr("id").search("divCL") != -1)
    728         {
    729             doc.parentCL = parent;
    730             break;
    731         }
    732        
    733         parent = parent.parentNode;
    734     }
    735 
    736     var info = new google.maps.InfoWindow({content:doc.title});
    737     marker.markerInfo = info;
    738     doc.marker = marker;
    739     attachDraggableClickHandler(marker, doc.nodeID);
    740 
    741     ////////////////////////////////////////////////////// TEST
    742    
    743     newLat = marker.getPosition().lat();
    744     newLng = marker.getPosition().lng();
    745     //console.log("Latitude " + newLat);
    746     //console.log("Longitude " + newLng);
    747     //NewLatLng(newLat, newLng);
    748    
    749 //  // Define the LatLng coordinates for the polygon's path.
    750 //        var triangleCoords = [
    751 //          {lat: 18.774, lng: -80.190},
    752 //          {lat: 18.466, lng: -64.600},
    753 //          {lat: 32.321, lng: -64.757},
    754 //          {lat: 32.300, lng: -80.190},
    755 //        {lat: 28.300, lng: -90.190}
    756 //        ];
    757 //
    758 //        // Construct the polygon.
    759 //        var bermudaTriangle = new google.maps.Polygon({
    760 //          paths: triangleCoords,
    761 //          strokeColor: '#FF0000',
    762 //          strokeOpacity: 0.8,
    763 //          strokeWeight: 2,
    764 //          fillColor: '#FF0000',
    765 //          fillOpacity: 0.35
    766 //        });
    767 //        bermudaTriangle.setMap(map);
    768639}
    769640
     
    1006877}
    1007878
     879// This function "overrides" (or rather, redefines) toggleSection in both classifier_scripts.js and document_scripts.js
     880// However, classifier_scripts.js::toggleSection() only took one parameter, sectionID, whereas
     881// document_scripts.js::toggleSection() took 3 params (sectionID, callback, tocDisabled).
     882// So to be compatible with both, need map-scripts::toggleSection() here to support all 3 in that order.
    1008883function modifyFunctions()
    1009 {
    1010     // This function "overrides" toggleSection in both classifier_scripts.js and document_scripts.js
    1011     // However, classifier_scripts.js::toggleSection() only took one parameter, sectionID, whereas
    1012     // document_scripts.js::toggleSection() took 3 params (sectionID, callback, tocDisabled).
    1013     // So to be compatible with both, need map-scripts::toggleSection() here to support all 3 in that order.
     884{   
    1014885    toggleSection = function(sectionID, callback, tocDisabled)
    1015886    {
     
    1024895        }       
    1025896       
     897        //If the div exists
    1026898        // Test if 'section' exists. 
    1027899        // ==> Because we're using jQuery to do this we need to test the length of the object returned
     
    1091963                    checkout();
    1092964                }
    1093                 /*else if(gs.cgiParams.documentbasket == "on") // TODO: copied from classifier_scripts.js - should this else block be included here (and happen when mapEnabled) or not?
     965                else if(gs.cgiParams.documentbasket == "on")
    1094966                {
    1095967                    dmcheckout();
    1096                 }*/
     968                }
    1097969                updateOpenClassifiers();
    1098970                getSubClassifier(sectionID);
Note: See TracChangeset for help on using the changeset viewer.