WordPress.org

Plugin Directory

Changeset 1542761 for event-post


Ignore:
Timestamp:
11/29/16 16:12:25 (5 months ago)
Author:
bastho
Message:

Add zoom option to SC/Widget

Location:
event-post/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • event-post/trunk/eventpost.php

    r1542726 r1542761  
    250250            $maps = array_keys($this->maps); 
    251251            $ep_settings['tile'] = $this->maps[$maps[0]]['id']; 
     252            $reg_settings=true; 
     253        } 
     254        if(!isset($ep_settings['zoom']) || !is_numeric($ep_settings['zoom'])){ 
     255            $ep_settings['zoom']=12; 
    252256            $reg_settings=true; 
    253257        } 
     
    423427            'maptiles' => $this->maps, 
    424428            'defaulttile' => $this->settings['tile'], 
     429            'zoom' => $this->settings['zoom'], 
    425430            'ajaxurl' => admin_url() . 'admin-ajax.php', 
    426431            'map_interactions'=>$this->map_interactions, 
     
    878883            'width' => '', 
    879884            'height' => '', 
     885            'zoom' => '', 
    880886            'tile' => $ep_settings['tile'], 
    881887            'title' => '', 
     
    957963            $attributes = ''; 
    958964            if($id == 'event_geolist'){ 
    959                 $attributes = 'data-tile="'.$tile.'" data-width="'.$width.'" data-height="'.$height.'" data-disabled-interactions="'; 
     965                $attributes = 'data-tile="'.$tile.'" data-width="'.$width.'" data-height="'.$height.'" data-zoom="'.$zoom.'" data-disabled-interactions="'; 
    960966                foreach($this->map_interactions as $int_key=>$int_name){ 
    961967                    $attributes.=$atts[$int_key]==false ? $int_key.', ' : ''; 
     
    20612067                        <tr> 
    20622068                            <th> 
     2069                                <label for="ep_zoom"> 
     2070                                    <?php _e('Default zoom', 'event-post') ?> 
     2071                                </label> 
     2072                            </th> 
     2073                            <td> 
     2074                                <input id="ep_zoom" name="ep_settings[zoom]" value="<?php echo $ep_settings['zoom']; ?>" type="number" min="3" max="18" size="3"/> 
     2075                            </td> 
     2076                        </tr> 
     2077                        <tr> 
     2078                            <th> 
    20632079                                <?php _e('Makers custom directory (leave empty for default settings)', 'event-post') ?> 
    20642080                            </th> 
  • event-post/trunk/inc/shortcodes.php

    r1518630 r1542761  
    113113    public function shortcode_list($_atts) { 
    114114        $atts = shortcode_atts(apply_filters('eventpost_params', array( 
     115            // Filters 
    115116            'nb' => 0, 
    116117            'type' => 'div', 
     
    118119            'past' => false, 
    119120            'geo' => 0, 
    120             'width' => '', 
    121             'height' => 'auto', 
     121            'cat' => '', 
     122            'tag' => '', 
     123            'orderby' => 'meta_value', 
     124            'order' => 'ASC', 
    122125            'title' => '', 
     126            // Display 
    123127            'before_title' => '<h3>', 
    124128            'after_title' => '</h3>', 
    125             'cat' => '', 
    126             'tag' => '', 
    127129            'thumbnail' => '', 
    128130            'thumbnail_size' => '', 
    129131            'excerpt' => '', 
     132            'width' => '', 
     133            'height' => 'auto', 
    130134            'style' => '', 
    131             'orderby' => 'meta_value', 
    132             'order' => 'ASC', 
    133135            'container_schema' => $this->EP->list_shema['container'], 
    134136            'item_schema' => $this->EP->list_shema['item'], 
     
    163165            'thumbnail_size' => '', 
    164166            'excerpt' => '', 
     167            'zoom'=>'', 
    165168            // Filters 
    166169            'nb' => 0, 
     
    326329                    'attr'        => 'height', 
    327330                    'type'        => 'text', 
     331                ), 
     332        array( 
     333                    'label'       => __('Zoom','event-post'), 
     334                    'attr'        => 'zoom', 
     335                    'type'        => 'number', 
    328336                ) 
    329337    ); 
  • event-post/trunk/inc/widget.map.php

    r1377700 r1542761  
    2424            'excerpt'       => 0, 
    2525            'tile'          => $EventPost->settings['tile'], 
     26            'zoom'         => '', 
    2627        ); 
    2728          // UI options 
     
    6061                'width' => $instance['width'], 
    6162                'height' => $instance['height'], 
     63                'zoom' => $instance['zoom'], 
    6264                'geo' => 1, 
    6365                'class' => 'eventpost_widget', 
     
    170172       <input id="<?php echo $this->get_field_id('height'); ?>" name="<?php echo $this->get_field_name('height'); ?>" value="<?php echo $instance['height']; ?>" /> 
    171173       </label> (px, %) 
     174       </p> 
     175       <p style="margin-top:10px;"> 
     176       <label for="<?php echo $this->get_field_id('zoom'); ?>"><?php _e('Force zoom','event-post'); ?> 
     177       <input id="<?php echo $this->get_field_id('zoom'); ?>" name="<?php echo $this->get_field_name('zoom'); ?>" value="<?php echo $instance['zoom']; ?>" type="number" min="3" max="20" size="2"/> 
     178       </label> 
    172179       </p> 
    173180 
  • event-post/trunk/js/eventpost.js

    r1542726 r1542761  
    2727                var marker = jQuery(this).parent().data('marker'); 
    2828                var id = jQuery(this).parent().data('id'); 
    29                 var zoom = 16; 
    3029                var map_id = 'event_map' + id; 
    3130                var position = new ol.proj.transform([lon, lat], ep_proj_source, ep_proj_destination); 
     
    5554                        view: new ol.View({ 
    5655                            center: position, 
    57                             zoom: 12 
     56                            zoom: eventpost_params.zoom 
    5857                        }) 
    5958                    }); 
     
    101100            var width = jQuery(this).data('width'); 
    102101            var height = jQuery(this).data('height'); 
     102            var zoom = jQuery(this).data('zoom'); 
    103103            var maptile = jQuery(this).data('tile'); 
    104104            if(maptile===''){ 
     
    147147                view: new ol.View({ 
    148148                    center: [0, 0], 
    149                     zoom: 12, 
     149                    zoom: isNaN(zoom) ? 12 : zoom, 
    150150                    maxZoom: 18 
    151151                }), 
     
    231231            //Center the map to show all markers 
    232232            ep_maps[map_id].getView().fit(ep_vectorSources[map_id].getExtent(), ep_maps[map_id].getSize()); 
     233            if(!isNaN(zoom) && zoom !== '' && zoom>0){ 
     234                ep_maps[map_id].getView().setZoom(zoom); 
     235            } 
    233236 
    234237            m_i=0; 
  • event-post/trunk/js/eventpost.min.js

    r1542726 r1542761  
    11 
    2 jQuery(window).load(function(){if(typeof ol!=="undefined"){ep_maps=[];ep_vectorSources=[];ep_pop_elements=[];ep_popups=[];ep_icons=[];ep_proj_source=new ol.proj.Projection({code:"EPSG:4326"});ep_proj_destination=new ol.proj.Projection({code:"EPSG:900913"});ep_interactions=eventpost_params.map_interactions;ep_retina=(window.retina||window.devicePixelRatio>1.5);function b(c){return(eventpost_params.maptiles[c]["urls_retina"]&&ep_retina)}jQuery("a.event_link.gps").click(function(){if(jQuery(this).parent().data("latitude")!==undefined&&jQuery(this).parent().data("longitude")!==undefined){var h=jQuery(this).parent().data("latitude");var i=jQuery(this).parent().data("longitude");var e=jQuery(this).parent().data("marker");var j=jQuery(this).parent().data("id");var f=16;var d="event_map"+j;var c=new ol.proj.transform([i,h],ep_proj_source,ep_proj_destination);if(jQuery("#"+d).length===0){jQuery(this).parent().append('<div id="'+d+'-wrap"><div id="'+d+'" class="event_map"></div></div>');jQuery("#"+d+"-wrap").css({height:"400px",margin:"auto",clear:"both"}).animate({height:"toggle"},1);ep_vectorSources[d]=new ol.source.Vector();ep_maps[d]=new ol.Map({target:d,layers:[new ol.layer.Tile({source:new ol.source.XYZ({urls:(b(eventpost_params.defaulttile)?eventpost_params.maptiles[eventpost_params.defaulttile]["urls_retina"]:eventpost_params.maptiles[eventpost_params.defaulttile]["urls"]),tilePixelRatio:(b(eventpost_params.defaulttile)?2:1),attribution:eventpost_params.maptiles[eventpost_params.defaulttile]["attribution"]})}),new ol.layer.Vector({source:ep_vectorSources[d]})],view:new ol.View({center:c,zoom:12})});ep_maps[d].addControl(new ol.control.Zoom());var g=new ol.Feature({geometry:new ol.geom.Point(c)});if(ep_icons[e]===undefined){ep_icons[e]=new ol.style.Style({image:new ol.style.Icon(({anchor:[16,32],anchorXUnits:"pixels",anchorYUnits:"pixels",opacity:1,src:e}))})}g.setStyle(ep_icons[e]);ep_vectorSources[d].addFeature(g)}jQuery("#"+d+"-wrap").animate({height:"toggle"},1000,function(){ep_maps[d].getView().setCenter(c)});return false}});jQuery(".event_geolist").each(function(){var f=jQuery(this).attr("id");var e="event_map_all"+f;var h="event_markersall"+f;var g=jQuery(this).data("width");var d=jQuery(this).data("height");var c=jQuery(this).data("tile");if(c===""){c=eventpost_params.defaulttile}var j=jQuery(this).data("disabled-interactions");jQuery(this).addClass("event_geolist_parsed").append('<div id="'+e+'" class="event_map map"></div><div id="'+e+'-popup" class="event_map_popup"></div>');css={margin:"auto",clear:"both"};if(g!=="auto"){css.width=g}if(d!=="auto"){css.height=d}jQuery("#"+e).css(css);ep_vectorSources[e]=new ol.source.Vector();ep_pop_elements[e]=document.getElementById(e+"-popup");ep_popups[e]=new ol.Overlay({element:ep_pop_elements[e],positioning:"bottom-center",stopEvent:false});map_settings={target:e,layers:[new ol.layer.Tile({source:new ol.source.XYZ({urls:(b(c)?eventpost_params.maptiles[c]["urls_retina"]:eventpost_params.maptiles[c]["urls"]),tilePixelRatio:(b(c)?2:1),attribution:eventpost_params.maptiles[c]["attribution"]})}),new ol.layer.Vector({source:ep_vectorSources[e]})],view:new ol.View({center:[0,0],zoom:12,maxZoom:18}),overlays:[ep_popups[e]]};ep_maps[e]=new ol.Map(map_settings);ep_maps[e].addControl(new ol.control.ZoomSlider());ep_maps[e].on("click",function(k){var l=ep_maps[e].forEachFeatureAtPixel(k.pixel,function(q,p){return q});if(l){jQuery(ep_pop_elements[e]).hide(0);view=ep_maps[e].getView();var n=l.getGeometry();var o=n.getCoordinates();var m=ol.animation.pan({duration:1000,source:view.getCenter()});ep_maps[e].beforeRender(m);view.setCenter(o);ep_popups[e].setPosition(o);html_output='<a href="'+l.get("link")+'">'+(l.get("thumbnail")!==""&&l.get("thumbnail")!==undefined?'<img src="'+l.get("thumbnail")+'">':"")+"<strong>"+l.get("name")+"</strong><br><time>"+l.get("date")+"</time><br><address>"+l.get("address")+"</address>"+(l.get("desc")!==""&&l.get("desc")!==undefined?"<p>"+l.get("desc")+"</p>":"")+"</a>";jQuery(ep_pop_elements[e]).delay(500).html(html_output).show(500)}else{jQuery(ep_pop_elements[e]).hide(200)}});jQuery(this).find("address").each(function(){var n=parseFloat(jQuery(this).data("latitude"));var o=parseFloat(jQuery(this).data("longitude"));if(n!==undefined&&o!==undefined){var l=jQuery(this).parent().parent();var k=jQuery(this).data("marker");var p=jQuery(this).data("id");coords=new ol.proj.transform([o,n],ep_proj_source,ep_proj_destination);obj={geometry:new ol.geom.Point(coords),name:l.find("h5").text(),address:jQuery(this).html(),date:l.find("time").text(),link:l.find("a").attr("href"),desc:l.find(".event_exerpt").html()};if(l.find("img").length>0){obj.thumbnail=l.find("img").attr("src")}var m=new ol.Feature(obj);if(ep_icons[k]===undefined){ep_icons[k]=new ol.style.Style({image:new ol.style.Icon(({anchor:[16,32],anchorXUnits:"pixels",anchorYUnits:"pixels",opacity:1,src:k}))})}m.setStyle(ep_icons[k]);ep_vectorSources[e].addFeature(m)}});ep_maps[e].getView().fit(ep_vectorSources[e].getExtent(),ep_maps[e].getSize());m_i=0;var i;for(i in ep_interactions){if(j.indexOf(i+",")>-1){ep_maps[e].getInteractions().getArray()[m_i].setActive(false)}m_i++}})}else{jQuery(".event_geolist").hide()}function a(){jQuery(".eventpost_cal_bt").click(function(){var c=jQuery(this).parents(".eventpost_calendar");jQuery.get(eventpost_params.ajaxurl,{action:"EventPostCalendar",date:jQuery(this).data("date"),cat:c.data("cat"),mf:c.data("mf"),dp:c.data("dp"),color:c.data("color"),thumbnail:c.data("thumbnail")},function(d){c.html(d);a()})});jQuery(".eventpost_cal_link").click(function(){var c=jQuery(this).parents(".eventpost_calendar");jQuery(".eventpost_cal_list",c).fadeOut(function(){jQuery(this).remove()});jQuery.get(eventpost_params.ajaxurl,{action:"EventPostCalendarDate",date:jQuery(this).data("date"),cat:c.data("cat"),mf:c.data("mf"),dp:c.data("dp"),color:c.data("color"),thumbnail:c.data("thumbnail")},function(d){c.append('<div class="eventpost_cal_list"><button class="eventpost_cal_close">x</button>'+d+"</div>");c.find(".eventpost_cal_list").hide(1).fadeIn(500);c.find(".eventpost_cal_close").click(function(){jQuery(this).parent().hide(500).remove()})})})}jQuery(".eventpost_calendar").each(function(){var c=jQuery(this);c.html('<img src="'+eventpost_params.imgpath+'cal-loader.gif" class="eventpost_cal_loader"/>');jQuery.get(eventpost_params.ajaxurl,{action:"EventPostCalendar",date:jQuery(this).data("date"),cat:jQuery(this).data("cat"),mf:jQuery(this).data("mf"),dp:jQuery(this).data("dp"),color:jQuery(this).data("color"),thumbnail:jQuery(this).data("thumbnail")},function(d){c.html(d);a()})})}); 
     2jQuery(window).load(function(){if(typeof ol!=="undefined"){ep_maps=[];ep_vectorSources=[];ep_pop_elements=[];ep_popups=[];ep_icons=[];ep_proj_source=new ol.proj.Projection({code:"EPSG:4326"});ep_proj_destination=new ol.proj.Projection({code:"EPSG:900913"});ep_interactions=eventpost_params.map_interactions;ep_retina=(window.retina||window.devicePixelRatio>1.5);function b(c){return(eventpost_params.maptiles[c]["urls_retina"]&&ep_retina)}jQuery("a.event_link.gps").click(function(){if(jQuery(this).parent().data("latitude")!==undefined&&jQuery(this).parent().data("longitude")!==undefined){var g=jQuery(this).parent().data("latitude");var h=jQuery(this).parent().data("longitude");var e=jQuery(this).parent().data("marker");var i=jQuery(this).parent().data("id");var d="event_map"+i;var c=new ol.proj.transform([h,g],ep_proj_source,ep_proj_destination);if(jQuery("#"+d).length===0){jQuery(this).parent().append('<div id="'+d+'-wrap"><div id="'+d+'" class="event_map"></div></div>');jQuery("#"+d+"-wrap").css({height:"400px",margin:"auto",clear:"both"}).animate({height:"toggle"},1);ep_vectorSources[d]=new ol.source.Vector();ep_maps[d]=new ol.Map({target:d,layers:[new ol.layer.Tile({source:new ol.source.XYZ({urls:(b(eventpost_params.defaulttile)?eventpost_params.maptiles[eventpost_params.defaulttile]["urls_retina"]:eventpost_params.maptiles[eventpost_params.defaulttile]["urls"]),tilePixelRatio:(b(eventpost_params.defaulttile)?2:1),attribution:eventpost_params.maptiles[eventpost_params.defaulttile]["attribution"]})}),new ol.layer.Vector({source:ep_vectorSources[d]})],view:new ol.View({center:c,zoom:eventpost_params.zoom})});ep_maps[d].addControl(new ol.control.Zoom());var f=new ol.Feature({geometry:new ol.geom.Point(c)});if(ep_icons[e]===undefined){ep_icons[e]=new ol.style.Style({image:new ol.style.Icon(({anchor:[16,32],anchorXUnits:"pixels",anchorYUnits:"pixels",opacity:1,src:e}))})}f.setStyle(ep_icons[e]);ep_vectorSources[d].addFeature(f)}jQuery("#"+d+"-wrap").animate({height:"toggle"},1000,function(){ep_maps[d].getView().setCenter(c)});return false}});jQuery(".event_geolist").each(function(){var g=jQuery(this).attr("id");var e="event_map_all"+g;var i="event_markersall"+g;var c=jQuery(this).data("width");var j=jQuery(this).data("height");var k=jQuery(this).data("zoom");var h=jQuery(this).data("tile");if(h===""){h=eventpost_params.defaulttile}var d=jQuery(this).data("disabled-interactions");jQuery(this).addClass("event_geolist_parsed").append('<div id="'+e+'" class="event_map map"></div><div id="'+e+'-popup" class="event_map_popup"></div>');css={margin:"auto",clear:"both"};if(c!=="auto"){css.width=c}if(j!=="auto"){css.height=j}jQuery("#"+e).css(css);ep_vectorSources[e]=new ol.source.Vector();ep_pop_elements[e]=document.getElementById(e+"-popup");ep_popups[e]=new ol.Overlay({element:ep_pop_elements[e],positioning:"bottom-center",stopEvent:false});map_settings={target:e,layers:[new ol.layer.Tile({source:new ol.source.XYZ({urls:(b(h)?eventpost_params.maptiles[h]["urls_retina"]:eventpost_params.maptiles[h]["urls"]),tilePixelRatio:(b(h)?2:1),attribution:eventpost_params.maptiles[h]["attribution"]})}),new ol.layer.Vector({source:ep_vectorSources[e]})],view:new ol.View({center:[0,0],zoom:isNaN(k)?12:k,maxZoom:18}),overlays:[ep_popups[e]]};ep_maps[e]=new ol.Map(map_settings);ep_maps[e].addControl(new ol.control.ZoomSlider());ep_maps[e].on("click",function(l){var m=ep_maps[e].forEachFeatureAtPixel(l.pixel,function(r,q){return r});if(m){jQuery(ep_pop_elements[e]).hide(0);view=ep_maps[e].getView();var o=m.getGeometry();var p=o.getCoordinates();var n=ol.animation.pan({duration:1000,source:view.getCenter()});ep_maps[e].beforeRender(n);view.setCenter(p);ep_popups[e].setPosition(p);html_output='<a href="'+m.get("link")+'">'+(m.get("thumbnail")!==""&&m.get("thumbnail")!==undefined?'<img src="'+m.get("thumbnail")+'">':"")+"<strong>"+m.get("name")+"</strong><br><time>"+m.get("date")+"</time><br><address>"+m.get("address")+"</address>"+(m.get("desc")!==""&&m.get("desc")!==undefined?"<p>"+m.get("desc")+"</p>":"")+"</a>";jQuery(ep_pop_elements[e]).delay(500).html(html_output).show(500)}else{jQuery(ep_pop_elements[e]).hide(200)}});jQuery(this).find("address").each(function(){var o=parseFloat(jQuery(this).data("latitude"));var p=parseFloat(jQuery(this).data("longitude"));if(o!==undefined&&p!==undefined){var m=jQuery(this).parent().parent();var l=jQuery(this).data("marker");var q=jQuery(this).data("id");coords=new ol.proj.transform([p,o],ep_proj_source,ep_proj_destination);obj={geometry:new ol.geom.Point(coords),name:m.find("h5").text(),address:jQuery(this).html(),date:m.find("time").text(),link:m.find("a").attr("href"),desc:m.find(".event_exerpt").html()};if(m.find("img").length>0){obj.thumbnail=m.find("img").attr("src")}var n=new ol.Feature(obj);if(ep_icons[l]===undefined){ep_icons[l]=new ol.style.Style({image:new ol.style.Icon(({anchor:[16,32],anchorXUnits:"pixels",anchorYUnits:"pixels",opacity:1,src:l}))})}n.setStyle(ep_icons[l]);ep_vectorSources[e].addFeature(n)}});ep_maps[e].getView().fit(ep_vectorSources[e].getExtent(),ep_maps[e].getSize());if(!isNaN(k)&&k!==""&&k>0){ep_maps[e].getView().setZoom(k)}m_i=0;var f;for(f in ep_interactions){if(d.indexOf(f+",")>-1){ep_maps[e].getInteractions().getArray()[m_i].setActive(false)}m_i++}})}else{jQuery(".event_geolist").hide()}function a(){jQuery(".eventpost_cal_bt").click(function(){var c=jQuery(this).parents(".eventpost_calendar");jQuery.get(eventpost_params.ajaxurl,{action:"EventPostCalendar",date:jQuery(this).data("date"),cat:c.data("cat"),mf:c.data("mf"),dp:c.data("dp"),color:c.data("color"),thumbnail:c.data("thumbnail")},function(d){c.html(d);a()})});jQuery(".eventpost_cal_link").click(function(){var c=jQuery(this).parents(".eventpost_calendar");jQuery(".eventpost_cal_list",c).fadeOut(function(){jQuery(this).remove()});jQuery.get(eventpost_params.ajaxurl,{action:"EventPostCalendarDate",date:jQuery(this).data("date"),cat:c.data("cat"),mf:c.data("mf"),dp:c.data("dp"),color:c.data("color"),thumbnail:c.data("thumbnail")},function(d){c.append('<div class="eventpost_cal_list"><button class="eventpost_cal_close">x</button>'+d+"</div>");c.find(".eventpost_cal_list").hide(1).fadeIn(500);c.find(".eventpost_cal_close").click(function(){jQuery(this).parent().hide(500).remove()})})})}jQuery(".eventpost_calendar").each(function(){var c=jQuery(this);c.html('<img src="'+eventpost_params.imgpath+'cal-loader.gif" class="eventpost_cal_loader"/>');jQuery.get(eventpost_params.ajaxurl,{action:"EventPostCalendar",date:jQuery(this).data("date"),cat:jQuery(this).data("cat"),mf:jQuery(this).data("mf"),dp:jQuery(this).data("dp"),color:jQuery(this).data("color"),thumbnail:jQuery(this).data("thumbnail")},function(d){c.html(d);a()})})}); 
Note: See TracChangeset for help on using the changeset viewer.