File size: 2Kb
{% if S_PHPBB_ADS %}
{% if not definition.INCLUDED_DATETIMEPICKERJS %}
{% INCLUDECSS '@phpbb_ads/datetimepicker/jquery.datetimepicker.min.css' %}
{% INCLUDEJS '@phpbb_ads/datetimepicker/jquery.datetimepicker.full.min.js' %}
{% DEFINE INCLUDED_DATETIMEPICKERJS = true %}
{% endif %}
<script>
/**
* This callback replaces enable links with disable links and vice versa.
* It does this by replacing the text, and replacing all instances of "enable"
* in the href with "disable", and vice versa.
*/
phpbb.addAjaxCallback('toggle_enable', function(res) {
'use strict';
var $this = $(this),
newHref = $this.attr('href');
$this.text(res.text);
$this.attr('title', res.title);
if (newHref.indexOf('disable') !== -1) {
newHref = newHref.replace('disable', 'enable');
} else {
newHref = newHref.replace('enable', 'disable');
}
$this.attr('href', newHref);
});
jQuery(function($) {
$('#ad_start_date, #ad_end_date').datetimepicker({
format:'{{ PICKER_DATE_FORMAT|e('js') }}',
validateOnBlur: false,
minDate: 0,
timepicker: false
});
$.datetimepicker.setLocale('{{ S_USER_LANG }}');
$('#upload_banner').on('click', function(e) {
e.preventDefault();
var file = $('#banner')[0].files[0];
if (file) {
var formData = new FormData();
formData.append('banner', file);
formData.append('upload_banner', true);
$.ajax({
method: 'POST',
url: window.location.href,
data: formData,
processData: false,
async: true,
cache: false,
contentType: false,
success: function(data) {
if (data.success) {
$('#ad_code').val(function(i, text) {
return (text.length ? text + "\n\n" : '') + data.text;
});
}
else {
phpbb.alert(data.title, data.text);
}
},
error: function(err) {
phpbb.alert(err.title, err.text);
}
});
}
else {
phpbb.alert('{{ lang('INFORMATION')|e('js') }}', '{{ lang('NO_FILE_SELECTED')|e('js') }}');
}
});
});
</script>
{% endif %}