| 1 |
(function () { |
| 2 |
|
| 3 |
WPLeafletMapPlugin.add( initAdminShortcodes ); |
| 4 |
|
| 5 |
function initAdminShortcodes () { |
| 6 |
var map_input = document.getElementById('map-shortcode'), |
| 7 |
marker_input = document.getElementById('marker-shortcode'), |
| 8 |
map_1 = WPLeafletMapPlugin.maps[0], |
| 9 |
marker_1 = WPLeafletMapPlugin.markers[0]; |
| 10 |
|
| 11 |
function update_marker () { |
| 12 |
var latlng = marker_1.getLatLng(); |
| 13 |
marker_input.value = '[leaflet-marker lat=' + |
| 14 |
latlng.lat + |
| 15 |
' lng=' + |
| 16 |
latlng.lng + |
| 17 |
']'; |
| 18 |
} |
| 19 |
|
| 20 |
function update_map () { |
| 21 |
var latlng = map_1.getCenter(); |
| 22 |
map_input.value = '[leaflet-map lat=' + |
| 23 |
latlng.lat + |
| 24 |
' lng=' + |
| 25 |
latlng.lng + |
| 26 |
' zoom=' + |
| 27 |
map_1.getZoom() + |
| 28 |
']'; |
| 29 |
} |
| 30 |
|
| 31 |
marker_1.on('drag', update_marker); |
| 32 |
map_1.on('move', update_map); |
| 33 |
|
| 34 |
update_map(); |
| 35 |
update_marker(); |
| 36 |
|
| 37 |
if (map_input.addEventListener) { |
| 38 |
map_input.addEventListener('click', function () { |
| 39 |
this.select(); |
| 40 |
}); |
| 41 |
|
| 42 |
marker_input.addEventListener('click', function () { |
| 43 |
this.select(); |
| 44 |
}); |
| 45 |
} else { |
| 46 |
// IE 8 |
| 47 |
map_input.attachEvent('onclick', function () { |
| 48 |
map_input.select(); |
| 49 |
}); |
| 50 |
|
| 51 |
marker_input.attachEvent('onclick', function () { |
| 52 |
marker_input.select(); |
| 53 |
}); |
| 54 |
} |
| 55 |
|
| 56 |
}; |
| 57 |
})(); |