-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[add] The MapEx widget initial version
- Loading branch information
Showing
5 changed files
with
172 additions
and
22 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,25 @@ | ||
<?php | ||
/* | ||
MapEx plugin for Widgetkit 2. | ||
Author: Ramil Valitov | ||
E-mail: [email protected] | ||
Web: http://www.valitov.me/ | ||
Git: https://github.com/rvalitov/widgetkit-map-ex | ||
*/ | ||
|
||
return array( | ||
|
||
'name' => 'widget/map', | ||
'name' => 'widget/map_ex', | ||
|
||
'main' => 'YOOtheme\\Widgetkit\\Widget\\Widget', | ||
|
||
'config' => array( | ||
|
||
'name' => 'map', | ||
'label' => 'Map', | ||
'name' => 'map_ex', | ||
'label' => 'MapEx', | ||
'core' => true, | ||
'icon' => 'plugins/widgets/map/widget.svg', | ||
'view' => 'plugins/widgets/map/views/widget.php', | ||
'icon' => 'plugins/widgets/map_ex/widget.svg', | ||
'view' => 'plugins/widgets/map_ex/views/widget.php', | ||
'item' => array('title', 'content', 'media'), | ||
'fields' => array( | ||
array('name' => 'location') | ||
|
@@ -31,6 +38,11 @@ | |
'draggable' => true, | ||
'directions' => false, | ||
'disabledefaultui' => false, | ||
'responsive' => true, | ||
'modal_fix' => true, | ||
'map_center' => '', | ||
'debug_output' => false, | ||
|
||
|
||
'styler_invert_lightness' => false, | ||
'styler_hue' => '', | ||
|
@@ -67,11 +79,12 @@ | |
'events' => array( | ||
|
||
'init.site' => function($event, $app) { | ||
$app['scripts']->add('widgetkit-maps', 'plugins/widgets/map/assets/maps.js', array('uikit')); | ||
//We replace the original Map widget js file with ours. It must be done to avoid issues with multiple loading of Google Map API JS libraies. | ||
$app['scripts']->add('widgetkit-maps', 'plugins/widgets/map_ex/assets/maps.js', array('uikit')); | ||
}, | ||
|
||
'init.admin' => function($event, $app) { | ||
$app['angular']->addTemplate('map.edit', 'plugins/widgets/map/views/edit.php', true); | ||
$app['angular']->addTemplate('map_ex.edit', 'plugins/widgets/map_ex/views/edit.php', true); | ||
} | ||
|
||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
<?php | ||
/* | ||
MapEx plugin for Widgetkit 2. | ||
Author: Ramil Valitov | ||
E-mail: [email protected] | ||
Web: http://www.valitov.me/ | ||
Git: https://github.com/rvalitov/widgetkit-map-ex | ||
*/ | ||
|
||
$map_id = uniqid('wk-map'); | ||
$map_id = uniqid('wk-map-ex'); | ||
$markers = array(); | ||
$width = $settings['width'] == 'auto' ? 'auto' : ((int)$settings['width']).'px'; | ||
$height = $settings['height'] == 'auto' ? '300px' : ((int)$settings['height']).'px'; | ||
|
@@ -28,9 +35,95 @@ | |
} | ||
|
||
$settings['markers'] = $markers; | ||
|
||
$settings['map_id'] = $map_id; | ||
$settings['map_center'] = trim($settings['map_center']); | ||
?> | ||
|
||
<script type="widgetkit/map" data-id="<?php echo $map_id;?>" data-class="<?php echo $settings['class']; ?> uk-img-preserve" data-style="width:<?php echo $width?>;height:<?php echo $height?>;"> | ||
<?php echo json_encode($settings) ?> | ||
</script> | ||
|
||
<?php if ( ($settings['responsive']) || (!empty($settings['map_center'])) || ($settings['modal_fix']) ):?> | ||
<script> | ||
jQuery(document).ready(function($){ | ||
function checkWidgetkitMaps() { | ||
var item=getWidgetkitMap("<?php echo $settings['map_id']?>"); | ||
if (item) { | ||
<?php if (!empty($settings['map_center'])):?> | ||
item.setCenter(new google.maps.LatLng(<?php echo $settings['map_center']?>)); | ||
<?php if ($settings['debug_output']):?> | ||
console.log('[MapEx] map centered to <?php echo $settings['map_center']?> for id#<?php echo $settings['map_id']?>'); | ||
<?php endif;?> | ||
<?php endif;?> | ||
|
||
<?php if ($settings['responsive']):?> | ||
google.maps.event.addDomListener(window, 'resize', function() { | ||
<?php if (!empty($settings['map_center'])):?> | ||
item.panTo(new google.maps.LatLng(<?php echo $settings['map_center']?>)); | ||
<?php if ($settings['debug_output']):?> | ||
console.log('[MapEx] auto pan performed to <?php echo $settings['map_center']?> for id#<?php echo $settings['map_id']?>'); | ||
<?php endif;?> | ||
<?php endif;?> | ||
item.setZoom(<?php echo $settings['zoom']?>); | ||
<?php if ($settings['debug_output']):?> | ||
console.log('[MapEx] auto zoom performed to level <?php echo $settings['zoom']?> for id#<?php echo $settings['map_id']?>'); | ||
<?php endif;?> | ||
}); | ||
<?php if ($settings['debug_output']):?> | ||
console.log('[MapEx] responsive setup performed for id#<?php echo $settings['map_id']?>'); | ||
<?php endif;?> | ||
<?php endif;?> | ||
|
||
<?php if ($settings['modal_fix']):?> | ||
var modal_id='#<?php echo $settings['map_id']?>'; | ||
var modal_dialog=$(modal_id).closest('.uk-modal'); | ||
if (modal_dialog){ | ||
var box_id=modal_dialog.attr("id"); | ||
if (box_id){ | ||
<?php if ($settings['debug_output']):?> | ||
console.log('[MapEx] modal fix setup successfull for id'+modal_id); | ||
<?php endif;?> | ||
$('#'+box_id).on({ | ||
'show.uk.modal': function(){ | ||
var map = jQuery('#<?php echo $settings['map_id']?>', '#'+box_id).first().get(0); | ||
<?php if (!empty($settings['map_center'])):?> | ||
item.setCenter(new google.maps.LatLng(<?php echo $settings['map_center']?>)); | ||
item.panTo(new google.maps.LatLng(<?php echo $settings['map_center']?>)); | ||
<?php if ($settings['debug_output']):?> | ||
console.log('[MapEx] map centered to <?php echo $settings['map_center']?> for id#<?php echo $settings['map_id']?>'); | ||
console.log('[MapEx] auto pan performed to <?php echo $settings['map_center']?> for id#<?php echo $settings['map_id']?>'); | ||
<?php endif;?> | ||
<?php endif;?> | ||
|
||
item.setZoom(<?php echo $settings['zoom']?>); | ||
<?php if ($settings['debug_output']):?> | ||
console.log('[MapEx] auto zoom performed to level <?php echo $settings['zoom']?> for id#<?php echo $settings['map_id']?>'); | ||
<?php endif;?> | ||
|
||
google.maps.event.trigger(map, 'resize'); | ||
<?php if ($settings['debug_output']):?> | ||
console.log('[MapEx] modal fix performed for id'+modal_id); | ||
<?php endif;?> | ||
} | ||
}); | ||
} | ||
<?php if ($settings['debug_output']):?> | ||
else | ||
console.log('[MapEx] failed to get id for modal dailog for id'+modal_id); | ||
<?php endif;?> | ||
|
||
} | ||
<?php if ($settings['debug_output']):?> | ||
else | ||
console.log('[MapEx] failed to find modal dailog for id'+modal_id); | ||
<?php endif;?> | ||
|
||
<?php endif;//modal fix?> | ||
} | ||
else | ||
setTimeout(checkWidgetkitMaps,1000); | ||
} | ||
setTimeout(checkWidgetkitMaps,1000); | ||
}); | ||
</script> | ||
<?php endif;?> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.