| 1 |
var ep_map, ep_can_drag_map, ep_view, ep_vectorSource, ep_feature, ep_proj_source, ep_proj_destination, marker, ep_marker, lat, lon, map_id, ep_geoloasked = false, ep_geolocalized = false, ep_currentloc = [0, 0]; |
| 2 |
|
| 3 |
// DATE |
| 4 |
|
| 5 |
/** |
| 6 |
* |
| 7 |
* @param {type} str |
| 8 |
* @returns {unresolved} |
| 9 |
*/ |
| 10 |
function eventpost_numdate(str) { |
| 11 |
var r = new RegExp("[-: T/]", "g"); |
| 12 |
if (str.replace) { |
| 13 |
str = str.replace(r, ''); |
| 14 |
} |
| 15 |
return parseInt(str); |
| 16 |
} |
| 17 |
/** |
| 18 |
* |
| 19 |
* @param {type} field |
| 20 |
* @returns {unresolved|String} |
| 21 |
*/ |
| 22 |
function eventpost_getdate(field) { |
| 23 |
d = jQuery('#' + field + '_date').val(); |
| 24 |
return d ? eventpost_numdate(d.substring(0, 16) + ':00') : ''; |
| 25 |
} |
| 26 |
/** |
| 27 |
* |
| 28 |
* @param {type} field |
| 29 |
* @returns {jQuery} |
| 30 |
*/ |
| 31 |
function eventpost_getdate_sql(field) { |
| 32 |
return jQuery('#' + field + '_date').val(); |
| 33 |
} |
| 34 |
/** |
| 35 |
* |
| 36 |
* @returns {undefined} |
| 37 |
*/ |
| 38 |
function eventpost_concat_time() { |
| 39 |
jQuery('.eventpost-datepicker-simple-wrap').each(function () { |
| 40 |
d = jQuery(this).find('.eventpost-datepicker-simple-date').val() + ' ' |
| 41 |
+ jQuery(this).find('.eventpost-datepicker-simple-hour').val() + ':' |
| 42 |
+ jQuery(this).find('.eventpost-datepicker-simple-time').val() + ':00'; |
| 43 |
jQuery(this).find('.eventpost-datepicker-simple').val(d); |
| 44 |
}); |
| 45 |
jQuery('.eventpost-datepicker-native-wrap').each(function () { |
| 46 |
year = parseInt(jQuery(this).find('.eventpost-datepicker-native-year').val()); |
| 47 |
|
| 48 |
month = parseInt(jQuery(this).find('.eventpost-datepicker-native-month').val()); |
| 49 |
if(month<10){ |
| 50 |
month='0'+month; |
| 51 |
} |
| 52 |
day = parseInt(jQuery(this).find('.eventpost-datepicker-native-day').val()); |
| 53 |
if(day<10){ |
| 54 |
day='0'+day; |
| 55 |
} |
| 56 |
hour = parseInt(jQuery(this).find('.eventpost-datepicker-native-hour').val()); |
| 57 |
if(hour<10){ |
| 58 |
hour='0'+hour; |
| 59 |
} |
| 60 |
minute = parseInt(jQuery(this).find('.eventpost-datepicker-native-minute').val()); |
| 61 |
if(minute<10){ |
| 62 |
minute='0'+minute; |
| 63 |
} |
| 64 |
d = year + '-' |
| 65 |
+ month + '-' |
| 66 |
+ day + ' ' |
| 67 |
+ (isNaN(hour)?'00':hour) + ':' |
| 68 |
+ (isNaN(minute)?'00':minute) + ':00'; |
| 69 |
jQuery(this).find('.eventpost-datepicker-native').val(d); |
| 70 |
}); |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
function eventpost_set_allday(){ |
| 75 |
set = jQuery('#event-post-date-all-day').is(':checked'); |
| 76 |
if(set===true){ |
| 77 |
jQuery('.eventpost-datepicker-native-hour, .eventpost-datepicker-native-minute, .eventpost-datepicker-simple-hour, .eventpost-datepicker-simple-time').val('00').trigger('change').parent().hide(300); |
| 78 |
} |
| 79 |
else{ |
| 80 |
jQuery('.eventpost-datepicker-native-hour, .eventpost-datepicker-native-minute, .eventpost-datepicker-simple-hour, .eventpost-datepicker-simple-time').parent().show(300); |
| 81 |
} |
| 82 |
} |
| 83 |
/** |
| 84 |
* |
| 85 |
* @returns {undefined} |
| 86 |
*/ |
| 87 |
function eventpost_chkdate() { |
| 88 |
//console.log('change date'); |
| 89 |
var date_start = eventpost_getdate(eventpost.META_START); |
| 90 |
var date_end = eventpost_getdate(eventpost.META_END); |
| 91 |
//console.log(date_start + ' ' + date_end); |
| 92 |
if (date_end === '' || date_start > date_end) { |
| 93 |
jQuery('#' + eventpost.META_END + '_date').val(jQuery('#' + eventpost.META_START + '_date').val()); |
| 94 |
jQuery('#' + eventpost.META_END + '_date').parents('label').find('.human_date').html(jQuery('#' + eventpost.META_START + '_date').parents('label').find('.human_date').html()); |
| 95 |
jQuery('#' + eventpost.META_END + '_date').parents('label').effect( "shake" ); |
| 96 |
|
| 97 |
fields = [ |
| 98 |
'simple-date', |
| 99 |
'simple-hour', |
| 100 |
'simple-time', |
| 101 |
'native-year', |
| 102 |
'native-month', |
| 103 |
'native-day', |
| 104 |
'native-hour', |
| 105 |
'native-minute', |
| 106 |
] |
| 107 |
for(f in fields){ |
| 108 |
fname = fields[f]; |
| 109 |
jQuery('.eventpost-datepicker-'+fname, jQuery('#' + eventpost.META_END + '_date').parents('label')).val(jQuery('.eventpost-datepicker-'+fname, jQuery('#' + eventpost.META_START + '_date').parents('label')).val()); |
| 110 |
} |
| 111 |
jQuery(".eventpost-datepicker-control", jQuery('#' + eventpost.META_END + '_date').parents('label')).last().trigger('change'); |
| 112 |
date_end = date_start; |
| 113 |
} |
| 114 |
//console.log(date_start); |
| 115 |
// UI |
| 116 |
if (date_start === 0) { |
| 117 |
jQuery('.event-post-event_begin_date-remove').hide(); |
| 118 |
} else { |
| 119 |
jQuery('.event-post-event_begin_date-remove').show(); |
| 120 |
} |
| 121 |
if (date_end === 0) { |
| 122 |
jQuery('.event-post-event_end_date-remove').hide(); |
| 123 |
} else { |
| 124 |
jQuery('.event-post-event_end_date-remove').show(); |
| 125 |
} |
| 126 |
} |
| 127 |
|
| 128 |
// MAP |
| 129 |
|
| 130 |
/** |
| 131 |
* |
| 132 |
* @param {type} location |
| 133 |
* @returns {undefined} |
| 134 |
*/ |
| 135 |
function eventpost_getlocation(location) { |
| 136 |
ep_currentloc = [location.coords.latitude, location.coords.longitude]; |
| 137 |
} |
| 138 |
/** |
| 139 |
* |
| 140 |
* @returns {Array|ep_currentloc} |
| 141 |
*/ |
| 142 |
function eventpost_location() { |
| 143 |
if ("geolocation" in navigator) { |
| 144 |
if (ep_geoloasked === false) { |
| 145 |
ep_geoloasked = true; |
| 146 |
navigator.geolocation.getCurrentPosition(eventpost_getlocation); |
| 147 |
var watchID = navigator.geolocation.watchPosition(function (position) { |
| 148 |
if (ep_geolocalized === false) { |
| 149 |
ep_geolocalized = true; |
| 150 |
eventpost_getlocation(position); |
| 151 |
eventpost_apply('', ep_currentloc[0], ep_currentloc[1]); |
| 152 |
} |
| 153 |
}); |
| 154 |
} else if (ep_geolocalized === true) { |
| 155 |
eventpost_apply('', ep_currentloc[0], ep_currentloc[1]); |
| 156 |
} |
| 157 |
} |
| 158 |
if (ep_currentloc !== 'no') { |
| 159 |
return ep_currentloc; |
| 160 |
} else { |
| 161 |
return [lat, lon]; |
| 162 |
} |
| 163 |
} |
| 164 |
/** |
| 165 |
* |
| 166 |
* @param {type} addr |
| 167 |
* @param {type} lat |
| 168 |
* @param {type} lon |
| 169 |
* @returns {undefined} |
| 170 |
*/ |
| 171 |
function eventpost_apply(addr, lat, lon) { |
| 172 |
if (jQuery('#geo_address').val() === '' && addr !== '') { |
| 173 |
jQuery('#geo_address').val(addr); |
| 174 |
} |
| 175 |
jQuery('#geo_latitude').val(lat); |
| 176 |
jQuery('#geo_longitude').val(lon).trigger('change'); |
| 177 |
eventpost_search_form(); |
| 178 |
} |
| 179 |
/** |
| 180 |
* |
| 181 |
* @returns {undefined} |
| 182 |
*/ |
| 183 |
function eventpost_edit() { |
| 184 |
sctype = jQuery('#ep_sce_type').val(); |
| 185 |
if (sctype === 'list') { |
| 186 |
jQuery('#ep_sce_maponly').hide(); |
| 187 |
jQuery('#ep_sce_listonly').show(); |
| 188 |
} |
| 189 |
if (sctype === 'map') { |
| 190 |
jQuery('#ep_sce_maponly').show(); |
| 191 |
jQuery('#ep_sce_listonly').hide(); |
| 192 |
} |
| 193 |
var ep_sce = '[events_' + sctype; |
| 194 |
jQuery('#event_post_sc_edit input,#event_post_sc_edit select').each(function () { |
| 195 |
if (!jQuery(this).hasClass('event_post_sc_no_use')) { |
| 196 |
var pc = jQuery(this).parent().parent().parent().attr('class'); |
| 197 |
var att = jQuery(this).data('att'); |
| 198 |
var val = jQuery(this).val(); |
| 199 |
if (att !== null && val !== '' && (pc === 'all' || pc === sctype)) { |
| 200 |
ep_sce += ' ' + att + '="' + val + '"'; |
| 201 |
} |
| 202 |
} |
| 203 |
}); |
| 204 |
ep_sce += ']'; |
| 205 |
jQuery('#ep_sce_shortcode').html(ep_sce); |
| 206 |
} |
| 207 |
/** |
| 208 |
* |
| 209 |
* @param {type} str |
| 210 |
* @returns {undefined} |
| 211 |
*/ |
| 212 |
function eventpost_insertcontent(str) { |
| 213 |
if (IEbof) { |
| 214 |
switchEditors.go('content', 'html'); |
| 215 |
document.post.content.value += str; |
| 216 |
switchEditors.go('content', 'tinymce'); |
| 217 |
} else { |
| 218 |
document.post.content.value += str; |
| 219 |
if (document.all) { |
| 220 |
value = str; |
| 221 |
document.getElementById('content_ifr').name = 'content_ifr'; |
| 222 |
var ec_sel = document.getElementById('content_ifr').document.selection; |
| 223 |
if (tinyMCE.activeEditor.selection) { |
| 224 |
tinyMCE.activeEditor.selection.setContent(str); |
| 225 |
} else if (tinyMCE.activeEditor) { |
| 226 |
tinyMCE.activeEditor.execCommand("mceInsertRawHTML", false, str); |
| 227 |
} else if (ec_sel) { |
| 228 |
var ec_rng = ec_sel.createRange(); |
| 229 |
ec_rng.pasteHTML(value); |
| 230 |
} else { |
| 231 |
} |
| 232 |
} else { |
| 233 |
document.getElementById('content_ifr').name = 'content_ifr'; |
| 234 |
if (document.content_ifr) { |
| 235 |
document.content_ifr.document.execCommand('insertHTML', false, str); |
| 236 |
} else if (document.getElementById('content_ifr').contentDocument) { |
| 237 |
document.getElementById('content_ifr').contentDocument.execCommand('insertHTML', false, str); |
| 238 |
} else if (tinyMCE.activeEditor.selection) { |
| 239 |
tinyMCE.activeEditor.selection.setContent(str); |
| 240 |
} else { |
| 241 |
tinyMCE.activeEditor.execCommand("mceInsertRawHTML", false, str); |
| 242 |
} |
| 243 |
} |
| 244 |
} |
| 245 |
} |
| 246 |
/** |
| 247 |
* |
| 248 |
* @returns {undefined} |
| 249 |
*/ |
| 250 |
function eventpost_search_location() { |
| 251 |
var addr = jQuery('#event_address_search_txt').attr('value'); |
| 252 |
|
| 253 |
if (addr === '') { |
| 254 |
eventpost_search_form(); |
| 255 |
jQuery('#eventaddress_result').append('<span class="alert">' + eventpost.empty_address + '</span>'); |
| 256 |
return; |
| 257 |
} |
| 258 |
//console.log(addr); |
| 259 |
var data = { |
| 260 |
action: 'EventPostGetLatLong', |
| 261 |
q: addr |
| 262 |
}; |
| 263 |
|
| 264 |
jQuery('#eventaddress_result').html(addr + '<br/><img src="' + eventpost.imgpath + 'loader.gif" alt="..."/>'); |
| 265 |
|
| 266 |
jQuery.post(ajaxurl, data, function (data) { |
| 267 |
eventpost_search_form(); |
| 268 |
var html_ret = ''; |
| 269 |
for (var lieu in data) { |
| 270 |
//console.log(data[lieu]); |
| 271 |
lieu = data[lieu]; |
| 272 |
if (lieu.lat !== undefined && lieu.lon !== undefined && lieu.display_name !== undefined) { |
| 273 |
html_ret += '<p><a onclick=\'eventpost_apply("' + lieu.display_name.replace('\'', ''').replace('"', '"') + '","' + lieu.lat + '","' + lieu.lon + '")\'>'; |
| 274 |
if (lieu.icon !== undefined) { |
| 275 |
html_ret += '<img src="' + lieu.icon + '" alt="' + lieu.type + '"/>'; |
| 276 |
} |
| 277 |
html_ret += lieu.display_name + '</a></p>'; |
| 278 |
} |
| 279 |
} |
| 280 |
jQuery('#eventaddress_result').append(html_ret); |
| 281 |
}, 'json'); |
| 282 |
} |
| 283 |
|
| 284 |
/** |
| 285 |
* |
| 286 |
* @returns {undefined} |
| 287 |
*/ |
| 288 |
function eventpost_search_form() { |
| 289 |
jQuery('#eventaddress_result').html('<input type="search" id="event_address_search_txt" placeholder="' + eventpost.search + '"/><button id="event_address_search_bt" class="button"><span class="dashicons dashicons-search"></span><span class="screen-reader-text">ok</span></button>'); |
| 290 |
jQuery('#event_address_search_txt').on("keydown", function (e) { |
| 291 |
var code = e.keyCode || e.which; |
| 292 |
|
| 293 |
if (code === 13) { |
| 294 |
// alert('enter pressed'); |
| 295 |
e.preventDefault(); |
| 296 |
eventpost_search_location(); |
| 297 |
return false; |
| 298 |
} |
| 299 |
}); |
| 300 |
jQuery('#event_address_search_bt').click(function () { |
| 301 |
eventpost_search_location(); |
| 302 |
}); |
| 303 |
} |
| 304 |
/** |
| 305 |
* |
| 306 |
* @returns {undefined} |
| 307 |
*/ |
| 308 |
function ep_set_coord() { |
| 309 |
lat = parseFloat(jQuery('#geo_latitude').val()); |
| 310 |
lon = parseFloat(jQuery('#geo_longitude').val()); |
| 311 |
if (isNaN(lat)) { |
| 312 |
lat = 0; |
| 313 |
} |
| 314 |
if (isNaN(lon)) { |
| 315 |
lon = 0; |
| 316 |
} |
| 317 |
var position = new ol.proj.transform([lon, lat], ep_proj_source, ep_proj_destination); |
| 318 |
|
| 319 |
ep_map.getView().setCenter(position); |
| 320 |
|
| 321 |
if (lat === 0 && lon === 0) { |
| 322 |
ep_map.getView().setZoom(1); |
| 323 |
} else { |
| 324 |
ep_map.getView().setZoom(12); |
| 325 |
} |
| 326 |
} |
| 327 |
|
| 328 |
/** |
| 329 |
* |
| 330 |
* @param {type} can |
| 331 |
* @returns {undefined} |
| 332 |
*/ |
| 333 |
function ep_set_can_drag(can) { |
| 334 |
if (can === true) { |
| 335 |
ep_can_drag_map = true; |
| 336 |
jQuery('.ep-block-draging').hide(); |
| 337 |
jQuery('.ep-stop-draging').show(); |
| 338 |
} else { |
| 339 |
ep_can_drag_map = false; |
| 340 |
jQuery('.ep-block-draging').show(); |
| 341 |
jQuery('.ep-stop-draging').hide(); |
| 342 |
} |
| 343 |
} |
| 344 |
|
| 345 |
// LOAD |
| 346 |
|
| 347 |
jQuery(window).load(function () { |
| 348 |
jQuery('#event_address_coords').hide(); |
| 349 |
jQuery('#event_address_search').click(function () { |
| 350 |
if (jQuery('#event_address_coords').css('display') === 'block') { |
| 351 |
jQuery('#event_address_coords').hide(100); |
| 352 |
} else { |
| 353 |
jQuery('#event_address_coords').show(100); |
| 354 |
eventpost_search_form(); |
| 355 |
|
| 356 |
} |
| 357 |
}); |
| 358 |
jQuery('#event_address_unsearch').click(function () { |
| 359 |
jQuery('#event_address_coords').hide(); |
| 360 |
}); |
| 361 |
jQuery('#event_post_sc_edit input,#event_post_sc_edit select').change(function () { |
| 362 |
eventpost_edit(); |
| 363 |
}); |
| 364 |
jQuery('#ep_sce_submit').click(function () { |
| 365 |
eventpost_insertcontent(jQuery('#ep_sce_shortcode').html()); |
| 366 |
}); |
| 367 |
jQuery('#ep_sce_nball').click(function () { |
| 368 |
jQuery('#ep_sce_nb').val('-1'); |
| 369 |
eventpost_edit(); |
| 370 |
}); |
| 371 |
jQuery('#ep_sce_shortcode').click(function () { |
| 372 |
jQuery(this).select(); |
| 373 |
}); |
| 374 |
|
| 375 |
|
| 376 |
eventpost_edit(); |
| 377 |
/* |
| 378 |
* Hide icons |
| 379 |
*/ |
| 380 |
|
| 381 |
jQuery('#eventpost-color-dropdown').hide().before(' <a href="#" id="event-color-section-more-btn">' + eventpost.datepickeri18n.edit + '</a>'); |
| 382 |
jQuery('#eventpost-color-preview, #event-color-section-more-btn').click(function (e) { |
| 383 |
e.preventDefault(); |
| 384 |
jQuery('#eventpost-color-dropdown').toggle(300); |
| 385 |
}); |
| 386 |
jQuery('#eventpost-color-dropdown input').on('change click', function(){ |
| 387 |
jQuery('#eventpost-color-preview').attr('src', jQuery('#eventpost-color-preview').data('url')+jQuery(this).val()+'.png'); |
| 388 |
jQuery('#eventpost-color-dropdown').hide(300); |
| 389 |
}); |
| 390 |
/* |
| 391 |
* Date picker Dual |
| 392 |
*/ |
| 393 |
eventpost_chkdate(); |
| 394 |
/* |
| 395 |
* Date picker Separate |
| 396 |
*/ |
| 397 |
jQuery(".eventpost-datepicker-simple").each(function () { |
| 398 |
current_date = jQuery(this).val(); |
| 399 |
current_id = jQuery(this).attr('id'); |
| 400 |
jQuery(this).wrap('<div class="eventpost-datepicker-simple-wrap eventpost-date-wrapper" id="eventpost-datepicker-simple-wrap-' + current_id + '" data-id="' + current_id + '">'); |
| 401 |
jQuery(this).after('<input class="eventpost-datepicker-control eventpost-datepicker-simple-date" value="' + current_date.substr(0, 10) + '" size="10" data-value="'+current_date.substr(0, 10)+'">' |
| 402 |
+ '<label><span class="screen-reader-text">'+eventpost.datepickeri18n.hour+'</span><select class="eventpost-datepicker-control eventpost-datepicker-simple-hour" data-value="'+current_date.substr(11, 2)+'"></select></label>' |
| 403 |
+ '<label><span class="screen-reader-text">'+eventpost.datepickeri18n.minute+'</span><select class="eventpost-datepicker-control eventpost-datepicker-simple-time" data-value="'+current_date.substr(14, 2)+'"></select></label>'); |
| 404 |
jQuery(this).hide(); |
| 405 |
for (h = 0; h < 24; h++) { |
| 406 |
h0 = h > 9 ? h : '0' + h; |
| 407 |
h0h = h0; |
| 408 |
if (eventpost.lang === 'en') { |
| 409 |
if (h <= 12) { |
| 410 |
h0h = h + ' AM'; |
| 411 |
} else { |
| 412 |
h0h = (h - 12) + ' PM'; |
| 413 |
} |
| 414 |
} |
| 415 |
jQuery("#eventpost-datepicker-simple-wrap-" + current_id + " .eventpost-datepicker-simple-hour").append('<option value="' + h0 + '"' + (h === parseInt(current_date.substr(11, 2)) ? ' selected' : '') + '>' + h0h + '</option>'); |
| 416 |
} |
| 417 |
m_sel = false; |
| 418 |
for (m = 0; m < 60; m += 5) { |
| 419 |
m0 = m > 9 ? m : '0' + m; |
| 420 |
selected = ''; |
| 421 |
if (!m_sel && Math.abs(m - parseInt(current_date.substr(14, 2))) <= 3) { |
| 422 |
selected = ' selected'; |
| 423 |
m_sel = true; |
| 424 |
} |
| 425 |
jQuery("#eventpost-datepicker-simple-wrap-" + current_id + " .eventpost-datepicker-simple-time").append('<option value="' + m0 + '"' + selected + '>' + m0 + '</option>'); |
| 426 |
} |
| 427 |
}); |
| 428 |
if (jQuery.datepicker) { |
| 429 |
jQuery(".eventpost-datepicker-simple-date").wrap('<div class="eventpost-datepicker-simple-inputgroup">').datepicker({ |
| 430 |
firstDay: 1, |
| 431 |
changeYear: true, |
| 432 |
changeMonth: true, |
| 433 |
showMonthAfterYear: true, |
| 434 |
yearRange: "c-5:+5", |
| 435 |
buttonText: eventpost.date_choose, |
| 436 |
showOn: "both", |
| 437 |
dateFormat: "yy-mm-dd", |
| 438 |
autoSize: true |
| 439 |
});/*.change(function () { |
| 440 |
var date_id = jQuery(this).attr('id').replace('_date', ''); |
| 441 |
var hd = jQuery('#' + date_id + '_date_human'); |
| 442 |
if (jQuery(this).val() !== '') { |
| 443 |
eventpost_concat_time(); |
| 444 |
eventpost_chkdate(); |
| 445 |
jQuery.post(ajaxurl, {action: 'EventPostHumanDate', date: eventpost_getdate_sql(date_id)}, function (data) { |
| 446 |
hd.html(data); |
| 447 |
}); |
| 448 |
} |
| 449 |
})*/ |
| 450 |
} |
| 451 |
/** |
| 452 |
* Date picker native |
| 453 |
*/ |
| 454 |
jQuery(".eventpost-datepicker-native").each(function () { |
| 455 |
current_date = jQuery(this).val(); |
| 456 |
current_id = jQuery(this).attr('id'); |
| 457 |
jQuery(this).wrap('<div class="timestamp-wrap eventpost-timestamp-wrap eventpost-date-wrapper eventpost-datepicker-native-wrap" id="eventpost-datepicker-native-wrap-' + current_id + '" data-id="' + current_id + '">'); |
| 458 |
dp_month='<label><span class="screen-reader-text">'+eventpost.datepickeri18n.month+'</span><select class="eventpost-datepicker-control eventpost-datepicker-native-month" id="eventpost-datepicker-native-' + current_id + '-month" data-value="'+current_date.substr(5, 2)+'"></select></label>'; |
| 459 |
dp_day='<label><span class="screen-reader-text">'+eventpost.datepickeri18n.day+'</span><input type="text" class="eventpost-datepicker-control eventpost-datepicker-native-day" id="eventpost-datepicker-native-' + current_id + '-day" value="'+current_date.substr(8, 2)+'" data-value="'+current_date.substr(8, 2)+'" size="2" maxlength="2" autocomplete="off" /></label>'; |
| 460 |
dp_year='<label><span class="screen-reader-text">'+eventpost.datepickeri18n.year+'</span><input type="text" class="eventpost-datepicker-control eventpost-datepicker-native-year" id="eventpost-datepicker-native-' + current_id + '-year" value="'+current_date.substr(0, 4)+'" data-value="'+current_date.substr(0, 4)+'" size="4" maxlength="4" autocomplete="off" /></label>'; |
| 461 |
dp_hour='<label><span class="screen-reader-text">'+eventpost.datepickeri18n.hour+'</span><input type="text" class="eventpost-datepicker-control eventpost-datepicker-native-hour" id="eventpost-datepicker-native-' + current_id + '-hour" value="'+current_date.substr(11, 2)+'" data-value="'+current_date.substr(11, 2)+'" size="2" maxlength="2" autocomplete="off" /></label>'; |
| 462 |
dp_minute='<label><span class="screen-reader-text">'+eventpost.datepickeri18n.minute+'</span><input type="text" class="eventpost-datepicker-control eventpost-datepicker-native-minute" id="eventpost-datepicker-native-' + current_id + '-minute" value="'+current_date.substr(14, 2)+'" data-value="'+current_date.substr(14, 2)+'" size="2" maxlength="2" autocomplete="off" /></label>'; |
| 463 |
/* translators: 1: month, 2: day, 3: year, 4: hour, 5: minute */ |
| 464 |
datepickerhtml=eventpost.datepickeri18n.order; |
| 465 |
datepickerhtml = datepickerhtml.replace('%1$s', dp_month); |
| 466 |
datepickerhtml = datepickerhtml.replace('%2$s', dp_day); |
| 467 |
datepickerhtml = datepickerhtml.replace('%3$s', dp_year); |
| 468 |
datepickerhtml = datepickerhtml.replace('%4$s', dp_hour); |
| 469 |
datepickerhtml = datepickerhtml.replace('%5$s', dp_minute); |
| 470 |
jQuery(this).after(datepickerhtml); |
| 471 |
for (m = 1; m < 12; m += 1) { |
| 472 |
m0 = m > 9 ? m : '0' + m; |
| 473 |
selected = ''; |
| 474 |
if ( m0 === current_date.substr(5, 2)) { |
| 475 |
selected = ' selected'; |
| 476 |
} |
| 477 |
jQuery('select', jQuery(this).parent()).append('<option value="' + m0 + '"' + selected + '>' + m0+'-'+eventpost.datepickeri18n.months[m] + '</option>'); |
| 478 |
} |
| 479 |
}).hide(); |
| 480 |
|
| 481 |
jQuery('.postbox .eventpost-datepicker-simple-wrap, .postbox .eventpost-datepicker-native-wrap').each(function(){ |
| 482 |
jQuery(this).append('<p>\n\ |
| 483 |
<a href="#eventpost-edit_timestamp-' + current_id + '" class="save-timestamp hide-if-no-js button">'+eventpost.datepickeri18n.ok+'</a>\n\ |
| 484 |
<a href="#eventpost-edit_timestamp-' + current_id + '" class="cancel-timestamp hide-if-no-js button-cancel">'+eventpost.datepickeri18n.cancel+'</a>\n\ |
| 485 |
</p>').before('<a href="#'+jQuery(this).attr('id')+'" class="eventpost-datepicker-native-edit-link">'+eventpost.datepickeri18n.edit+'</a>'); |
| 486 |
}).hide(); |
| 487 |
jQuery('.eventpost-datepicker-simple-edit-link, .eventpost-datepicker-native-edit-link').click(function(e){ |
| 488 |
e.preventDefault(); |
| 489 |
jQuery(this).next('.eventpost-datepicker-simple-wrap, .eventpost-datepicker-native-wrap').toggle(300); |
| 490 |
}); |
| 491 |
jQuery('.eventpost-datepicker-simple-wrap .save-timestamp, .eventpost-datepicker-native-wrap .save-timestamp').click(function(e){ |
| 492 |
jQuery(this).parent().parent().toggle(300); |
| 493 |
}); |
| 494 |
jQuery('.eventpost-datepicker-simple-wrap .cancel-timestamp, .eventpost-datepicker-native-wrap .cancel-timestamp').click(function(e){ |
| 495 |
jQuery('.eventpost-datepicker-control', jQuery(this).parent().parent()).each(function(){ |
| 496 |
jQuery(this).val(jQuery(this).data('value')); |
| 497 |
}).last().trigger('change'); |
| 498 |
jQuery(this).parent().parent().toggle(300); |
| 499 |
}); |
| 500 |
|
| 501 |
jQuery(".eventpost-datepicker-control").change(function () { |
| 502 |
eventpost_concat_time(); |
| 503 |
eventpost_chkdate(); |
| 504 |
var date_id = jQuery(this).parents('.eventpost-date-wrapper').data('id').replace('_date', ''); |
| 505 |
var hd = jQuery('#' + date_id + '_date_human'); |
| 506 |
if (jQuery(this).val() !== '') { |
| 507 |
jQuery.post(ajaxurl, {action: 'EventPostHumanDate', date: eventpost_getdate_sql(date_id)}, function (data) { |
| 508 |
hd.html(data); |
| 509 |
}); |
| 510 |
} |
| 511 |
}); |
| 512 |
|
| 513 |
jQuery('#event-post-date-all-day').on('change click', function(){ |
| 514 |
eventpost_set_allday(); |
| 515 |
}); |
| 516 |
eventpost_set_allday(); |
| 517 |
|
| 518 |
|
| 519 |
/** |
| 520 |
* Map preview |
| 521 |
*/ |
| 522 |
if (typeof ol !== 'undefined') { |
| 523 |
ep_map = undefined; |
| 524 |
ep_vectorSource = undefined; |
| 525 |
ep_feature = undefined; |
| 526 |
ep_proj_source = new ol.proj.Projection({code: 'EPSG:4326'}); |
| 527 |
ep_proj_destination = new ol.proj.Projection({code: 'EPSG:900913'}); |
| 528 |
marker = ''; |
| 529 |
ep_marker = undefined; |
| 530 |
lat = 0; |
| 531 |
lon = 0; |
| 532 |
map_id = 'event-post-map-preview'; |
| 533 |
} |
| 534 |
jQuery('#' + map_id).each(function () { |
| 535 |
marker = jQuery(this).data('marker'); |
| 536 |
|
| 537 |
jQuery(this).css({ |
| 538 |
"width": "100%", |
| 539 |
"height": "200px", |
| 540 |
"position": "relative", |
| 541 |
"cursor": "move" |
| 542 |
}); |
| 543 |
var position = new ol.proj.transform([lon, lat], ep_proj_source, ep_proj_destination); |
| 544 |
ep_vectorSource = new ol.source.Vector(); |
| 545 |
ep_view = new ol.View({ |
| 546 |
center: position, |
| 547 |
zoom: 12 |
| 548 |
}); |
| 549 |
ep_map = new ol.Map({ |
| 550 |
target: map_id, |
| 551 |
layers: [ |
| 552 |
new ol.layer.Tile({ |
| 553 |
source: new ol.source.XYZ({ |
| 554 |
urls: eventpost_params.maptiles[eventpost_params.defaulttile]['urls'] |
| 555 |
}) |
| 556 |
}), |
| 557 |
new ol.layer.Vector({ |
| 558 |
source: ep_vectorSource |
| 559 |
}) |
| 560 |
], |
| 561 |
view: ep_view |
| 562 |
}); |
| 563 |
ep_map.addControl(new ol.control.Zoom()); |
| 564 |
|
| 565 |
jQuery(this).append('<img id="' + map_id + '-fixed-marker" src="' + marker + '" tabIndex="-1" draggable="false" alt="position">'); |
| 566 |
jQuery(this).append('<div id="' + map_id + '-startdrag" class="ep-block-draging"><span>' + eventpost.start_drag + '</span></div>'); |
| 567 |
jQuery(this).append('<a id="' + map_id + '-stopdrag" class="ep-stop-draging button button-default">' + eventpost.stop_drag + '</a>'); |
| 568 |
jQuery(this).after('<p style="text-align:center;"><a class="button button-default" id="' + map_id + '-get-current-loc"><span class="dashicons dashicons-marker"></span> ' + eventpost.use_current_location + '</a></p>'); |
| 569 |
|
| 570 |
jQuery('#' + map_id + '-fixed-marker').css({ |
| 571 |
"left": jQuery(this).width() / 2 - 16, |
| 572 |
"top": 100 - 16, |
| 573 |
}); |
| 574 |
jQuery('#' + map_id + '-get-current-loc').click(function () { |
| 575 |
eventpost_location(); |
| 576 |
}); |
| 577 |
jQuery('.ep-stop-draging').hide().click(function () { |
| 578 |
ep_set_can_drag(false); |
| 579 |
}); |
| 580 |
jQuery('.ep-block-draging').click(function () { |
| 581 |
ep_set_can_drag(true); |
| 582 |
}); |
| 583 |
|
| 584 |
ep_map.on("moveend", function () { |
| 585 |
if (ep_can_drag_map) { |
| 586 |
map_coord = ep_view.getCenter(); |
| 587 |
local_coord = new ol.proj.transform(map_coord, ep_proj_destination, ep_proj_source); |
| 588 |
if (local_coord[0] === 0 && local_coord[1] === 0) { |
| 589 |
local_coord = ['', '']; |
| 590 |
} |
| 591 |
jQuery('#geo_longitude').val(local_coord[0]); |
| 592 |
jQuery('#geo_latitude').val(local_coord[1]); |
| 593 |
} |
| 594 |
}); |
| 595 |
|
| 596 |
ep_set_coord(); |
| 597 |
jQuery('#geo_longitude, #geo_latitude').on('change blur', function () { |
| 598 |
ep_set_coord(); |
| 599 |
}); |
| 600 |
}); |
| 601 |
jQuery('#event_post_date .event-color-section label').on('focus click', function () { |
| 602 |
jQuery('#' + map_id + '-fixed-marker').attr('src', jQuery('img', jQuery(this)).attr('src')); |
| 603 |
}); |
| 604 |
/* |
| 605 |
* Widgets stylish with icons |
| 606 |
*/ |
| 607 |
if (jQuery('body').hasClass('widgets-php')) { |
| 608 |
jQuery('.widget').each(function () { |
| 609 |
wid = jQuery(this).attr('id'); |
| 610 |
if (wid.indexOf('eventpostmap') > -1) { |
| 611 |
jQuery(this).addClass('eventpost_admin_widget eventpost_widget_map'); |
| 612 |
} else if (wid.indexOf('eventpostcal') > -1) { |
| 613 |
jQuery(this).addClass('eventpost_admin_widget eventpost_widget_cal'); |
| 614 |
} else if (wid.indexOf('eventpost') > -1) { |
| 615 |
jQuery(this).addClass('eventpost_admin_widget eventpost_widget_list'); |
| 616 |
} |
| 617 |
}); |
| 618 |
} |
| 619 |
}); |