Ignore:
Timestamp:
Jul 2, 2010, 6:53:40 AM (14 years ago)
Author:
rvelices
Message:

rv_gmaps - start using google.maps JS namespace + upgrade prototype.js

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/rv_gmaps/trunk/template/data_handler.js

    r6245 r6651  
    1010                , opts || {} );
    1111
    12         GEvent.addListener( map, "infowindowclose", function() {map.getInfoWindow().pwgMarker=null;} );
     12        google.maps.Event.addListener( map, "infowindowclose", function() {map.getInfoWindow().pwgMarker=null;} );
    1313}
    1414
     
    8383                        {
    8484                                this._map.removeOverlay( marker );
    85                                 GEvent.clearListeners(marker, "click" );
    86                                 GEvent.clearListeners(marker, "dblclick" );
     85                                google.maps.Event.clearListeners(marker, "click" );
     86                                google.maps.Event.clearListeners(marker, "dblclick" );
    8787                                this._map.getInfoWindow().pwgMarker = infoWindowMarker = null;
    88                                 if (document.is_debug) GLog.write('removed marker with infoWindow');
     88                                if (document.is_debug) google.maps.Log.write('removed marker with infoWindow');
    8989                                marker = this._markers.pop();
    9090                        }
     
    9292                        if (!marker)
    9393                        {
    94                                 marker = new GMarker( cluster.position, {title:  theTitle, icon: this.options.icon } );
    95                                 GEvent.addListener( marker, "click", this._onMarkerClick.bind(this, marker) );
    96                                 GEvent.addListener( marker, "dblclick", this._onMarkerDblClick.bind(this, marker) );
     94                                marker = new google.maps.Marker( cluster.position, {title:  theTitle, icon: this.options.icon } );
     95                                google.maps.Event.addListener( marker, "click", this._onMarkerClick.bind(this, marker) );
     96                                google.maps.Event.addListener( marker, "dblclick", this._onMarkerDblClick.bind(this, marker) );
    9797                                this._map.addOverlay( marker );
    9898                        }
     
    144144                {
    145145                        this._map.removeOverlay( this._markers[i] );
    146                         GEvent.clearListeners(this._markers[i], "click" );
    147                         GEvent.clearListeners(this._markers[i], "dblclick" );
     146                        google.maps.Event.clearListeners(this._markers[i], "click" );
     147                        google.maps.Event.clearListeners(this._markers[i], "dblclick" );
    148148                }
    149149
     
    160160        if (this._map.getInfoWindow().pwgMarker == marker )
    161161                return; // already open
    162   var content = "";
    163   if ( !marker.currentImageIndex )
    164     marker.currentImageIndex = 0;
    165   content += '<div class="gmiw_header" style="' + (marker.pwg.images.length>1 ? '': 'display:none')+ '">';
    166   content += '<span id="pwgImageCounters">'+this.buildCurrentPictureCounterHtml(marker)+'</span> ';
    167   content += '<a href="javascript:void(0);" id="'+this._navHtmlIds[0]+'">';
    168   content +=    '<span>'+ "&laquo; " + Localization.get('Prev') + '</span>';
    169   content += '</a>';
    170   content += " ";
    171   content += '<a href="javascript:void(0);" id="'+this._navHtmlIds[1]+'">';
    172   content +=    '<span>'+Localization.get('Next') + " &raquo;"+'</span>';
    173   content += '</a>';
    174   content += " ";
    175   var imgShowAll = '';
    176   if (this.options.show_all_img_src)
    177     imgShowAll = '<img src="'+this.options.show_all_img_src+'" alt="" style="border:0" /> ';
    178   content += '<a id="pwgImageBlowup" href="'+marker.pwg.blowup_url+'" onclick="return PwgDataHandler.blowupUrl(this.href);" title='+Localization.getQ('show all pictures around this location')+'>'+
    179             imgShowAll+ '<span>'+Localization.get('Show all')+'</span>'+
    180           '</a>';
    181   content += '</div>';
    182   content += '<div id="pwgImageDetail">' + this.buildCurrentPictureHtml( marker ) + '</div>';
    183 
    184   marker.openInfoWindowHtml( content );
    185 
    186   // bind to next / prev a little later because sometimes the nodes are not immediately created
    187   if (this._timerBindPictureNavigation) clearTimeout(this._timerBindPictureNavigation);
    188   this._timerBindPictureNavigation = null;
    189   if (marker.pwg.images.length>1)
    190     this._timerBindPictureNavigation = setTimeout( this._onTimeoutBindPictureNavigation.bind(this, marker), 250 );
     162        var content = "";
     163        if ( !marker.currentImageIndex )
     164                marker.currentImageIndex = 0;
     165        content += '<div class="gmiw_header" style="' + (marker.pwg.images.length>1 ? '': 'display:none')+ '">';
     166        content += '<span id="pwgImageCounters">'+this.buildCurrentPictureCounterHtml(marker)+'</span> ';
     167        content += '<a href="javascript:void(0);" id="'+this._navHtmlIds[0]+'">';
     168        content +=    '<span>'+ "&laquo; " + Localization.get('Prev') + '</span>';
     169        content += '</a>';
     170        content += " ";
     171        content += '<a href="javascript:void(0);" id="'+this._navHtmlIds[1]+'">';
     172        content +=    '<span>'+Localization.get('Next') + " &raquo;"+'</span>';
     173        content += '</a>';
     174        content += " ";
     175        var imgShowAll = '';
     176        if (this.options.show_all_img_src)
     177                imgShowAll = '<img src="'+this.options.show_all_img_src+'" alt="" style="border:0" /> ';
     178        content += '<a id="pwgImageBlowup" href="'+marker.pwg.blowup_url+'" onclick="return PwgDataHandler.blowupUrl(this.href);" title='+Localization.getQ('show all pictures around this location')+'>'+
     179                                                imgShowAll+ '<span>'+Localization.get('Show all')+'</span>'+
     180                                        '</a>';
     181        content += '</div>';
     182        content += '<div id="pwgImageDetail">' + this.buildCurrentPictureHtml( marker ) + '</div>';
     183
     184        marker.openInfoWindowHtml( content );
     185
     186        // bind to next / prev a little later because sometimes the nodes are not immediately created
     187        if (this._timerBindPictureNavigation) clearTimeout(this._timerBindPictureNavigation);
     188        this._timerBindPictureNavigation = null;
     189        if (marker.pwg.images.length>1)
     190                this._timerBindPictureNavigation = setTimeout( this._onTimeoutBindPictureNavigation.bind(this, marker), 250 );
    191191},
    192192
    193193_onMarkerDblClick: function( marker )
    194194{
    195   this._map.setCenter( marker.pwg.bounds.getCenter(), this._map.getBoundsZoomLevel( marker.pwg.bounds ) );
     195        this._map.setCenter( marker.pwg.bounds.getCenter(), this._map.getBoundsZoomLevel( marker.pwg.bounds ) );
    196196},
    197197
    198198buildCurrentPictureHtml: function( marker )
    199199{
    200   var imageDetail = marker.pwg.images[marker.currentImageIndex];
    201   var res = "";
    202   res += '<div class="gmiw_imageTitle">' + imageDetail.name + "</div>";
    203   res +=
     200        var imageDetail = marker.pwg.images[marker.currentImageIndex];
     201        var res = "";
     202        res += '<div class="gmiw_imageTitle">' + imageDetail.name + "</div>";
     203        res +=
    204204'<div class="gmiw_imageContent">' +
    205205'<div class="gmiw_imageWrap">'+
     
    209209'<div class="gmiw_imageComment">' + imageDetail.comment + '</div>' +
    210210'</div>';
    211   return res;
     211        return res;
    212212},
    213213
    214214buildCurrentPictureCounterHtml: function( marker )
    215215{
    216   var res =
    217     '<b>'+(marker.currentImageIndex+1)+'</b>'+
    218     '/' +
    219     '<b>'+marker.pwg.images.length+'</b>';
    220   if (marker.pwg.nb_items>marker.pwg.images.length)
    221     res+= " "+Localization.fmt1("out of %d", marker.pwg.nb_items );
    222   return res;
     216        var res =
     217                '<b>'+(marker.currentImageIndex+1)+'</b>'+
     218                '/' +
     219                '<b>'+marker.pwg.images.length+'</b>';
     220        if (marker.pwg.nb_items>marker.pwg.images.length)
     221                res+= " "+Localization.fmt1("out of %d", marker.pwg.nb_items );
     222        return res;
    223223},
    224224
     
    226226_onTimeoutBindPictureNavigation: function( marker )
    227227{
    228   clearTimeout(this._timerBindPictureNavigation);
    229   this._timerBindPictureNavigation = null;
    230   this._map.getInfoWindow().pwgMarker = marker;
    231   for (var i=0; i< this._navHtmlIds.length; i++)
    232   {
    233     var elt = document.getElementById( this._navHtmlIds[i] );
    234     if (elt)
    235       GEvent.addDomListener(elt, "click", this._onPictureNavigate.bind(this, marker, i) );
    236   }
     228        clearTimeout(this._timerBindPictureNavigation);
     229        this._timerBindPictureNavigation = null;
     230        this._map.getInfoWindow().pwgMarker = marker;
     231        for (var i=0; i< this._navHtmlIds.length; i++)
     232        {
     233                var elt = document.getElementById( this._navHtmlIds[i] );
     234                if (elt)
     235                        google.maps.Event.addDomListener(elt, "click", this._onPictureNavigate.bind(this, marker, i) );
     236        }
    237237},
    238238
    239239_onPictureNavigate: function(marker, dir )
    240240{
    241   if (dir==0) dir=-1;
    242   marker.currentImageIndex += dir;
    243   if (marker.currentImageIndex<0)
    244     marker.currentImageIndex = marker.pwg.images.length-1;
    245   else if (marker.currentImageIndex >= marker.pwg.images.length)
    246     marker.currentImageIndex = 0;
    247 
    248   try {
    249     var elt = document.getElementById( "pwgImageDetail" );
    250     elt.innerHTML = this.buildCurrentPictureHtml( marker );
    251   }
    252   catch (e)
    253   {
    254     alert (e.message);
    255   }
    256 
    257   try {
    258     var elt = document.getElementById( "pwgImageCounters" );
    259     elt.innerHTML = this.buildCurrentPictureCounterHtml( marker );
    260   }
    261   catch (e)
    262   {
    263     alert (e.message);
    264   }
    265   return false;
     241        if (dir==0) dir=-1;
     242        marker.currentImageIndex += dir;
     243        if (marker.currentImageIndex<0)
     244                marker.currentImageIndex = marker.pwg.images.length-1;
     245        else if (marker.currentImageIndex >= marker.pwg.images.length)
     246                marker.currentImageIndex = 0;
     247
     248        try {
     249                var elt = document.getElementById( "pwgImageDetail" );
     250                elt.innerHTML = this.buildCurrentPictureHtml( marker );
     251        }
     252        catch (e)
     253        {
     254                alert (e.message);
     255        }
     256
     257        try {
     258                var elt = document.getElementById( "pwgImageCounters" );
     259                elt.innerHTML = this.buildCurrentPictureCounterHtml( marker );
     260        }
     261        catch (e)
     262        {
     263                alert (e.message);
     264        }
     265        return false;
    266266}
    267267
     
    270270PwgDataHandler.blowupUrl = function(theUrl)
    271271{
    272   var win = new Window({
    273     title: document.title,
    274     url: theUrl,
    275     classname: "alphacube",
    276     left: 0, top: 0,
    277     width:"640", height:"480",
    278     minimizable: false,
    279     maximizable: false,
    280     draggable: false,
    281     resizable: false,
    282     destroyOnClose: true,
    283     hideEffect: Element.hide,
    284     showEffectOptions: {duration:1.5}
    285   });
    286 
    287   win.setConstraint(true, {top:20, left:20, bottom:30, right:20} );
    288   win.maximize();
    289   win.showCenter(true, 20, 20);
    290   return false;
     272        var win = new Window({
     273                title: document.title,
     274                url: theUrl,
     275                classname: "alphacube",
     276                left: 0, top: 0,
     277                width:"640", height:"480",
     278                minimizable: false,
     279                maximizable: false,
     280                draggable: false,
     281                resizable: false,
     282                destroyOnClose: true,
     283                hideEffect: Element.hide,
     284                showEffectOptions: {duration:1.5}
     285        });
     286
     287        win.setConstraint(true, {top:20, left:20, bottom:30, right:20} );
     288        win.maximize();
     289        win.showCenter(true, 20, 20);
     290        return false;
    291291}
    292292
     
    294294String.prototype.urlNoHtm = function()
    295295{
    296   return this.replace( "&amp;", "&" );
    297 }
     296        return this.replace( "&amp;", "&" );
     297}
Note: See TracChangeset for help on using the changeset viewer.