This commit is contained in:
Tony Air 2019-05-23 20:02:50 +07:00
parent 4fa466157f
commit 5358afd5ec
15 changed files with 1623 additions and 1623 deletions

View File

@ -10,7 +10,7 @@ const CarouselUI = (($) => {
// Static methods
static each(callback) {
$('.js-carousel').each(function(i, e) {
$('.js-carousel').each((i, e) => {
callback(i, $(e));
});
}
@ -34,17 +34,17 @@ const CarouselUI = (($) => {
// create carousel-controls
if ($e.data('indicators')) {
const $indicators = $('<ol class="carousel-indicators"></ol>');
$indicators.append('<li data-target="#' + id + '" data-slide-to="0" class="active"></li>');
$indicators.append(`<li data-target="#${ id }" data-slide-to="0" class="active"></li>`);
for (let i = 1; i < count; i++) {
$indicators.append('<li data-target="#' + id + '" data-slide-to="' + i + '"></li>');
$indicators.append(`<li data-target="#${ id }" data-slide-to="${ i }"></li>`);
}
$e.prepend($indicators);
}
// create arrows
if ($e.data('arrows')) {
$e.prepend('<i class="carousel-control-prev" data-target="#' + id + '" role="button" data-slide="prev"><i class="fas fa-chevron-left" aria-hidden="true"></i><i class="sr-only">Previous</i></i>');
$e.prepend('<i class="carousel-control-next" data-target="#' + id + '" role="button" data-slide="next"><i class="fas fa-chevron-right" aria-hidden="true"></i><i class="sr-only">Next</i></i>');
$e.prepend(`<i class="carousel-control-prev" data-target="#${ id }" role="button" data-slide="prev"><i class="fas fa-chevron-left" aria-hidden="true"></i><i class="sr-only">Previous</i></i>`);
$e.prepend(`<i class="carousel-control-next" data-target="#${ id }" role="button" data-slide="next"><i class="fas fa-chevron-right" aria-hidden="true"></i><i class="sr-only">Next</i></i>`);
}
// init carousel

View File

@ -34,7 +34,7 @@ const FormBasics = (($) => {
virtualScroll: false,
dropupAuto: false,
size: 10,
maxOptions: maxOptions,
maxOptions,
}, $el.data(), {
multipleSeparator: separator,
}));
@ -55,8 +55,8 @@ const FormBasics = (($) => {
return $(e).text() === opt;
});
html += '<span class="option" data-val=' + $opt.attr('value') + '>' + opt +
' <i class="fas fa-times btn-remove"></i></span>';
html += `<span class="option" data-val=${ $opt.attr('value') }>${ opt
} <i class="fas fa-times btn-remove"></i></span>`;
});
$container.html(html);
@ -69,7 +69,7 @@ const FormBasics = (($) => {
const val = $opt.data('val').toString();
//$opt.remove();
let vals = $el.selectpicker('val');
const vals = $el.selectpicker('val');
const i = vals.indexOf(val);
if (i > -1) {
vals.splice(i, 1);

View File

@ -59,7 +59,7 @@ const CroppieUI = (($) => {
viewport: {
width: ui.width / ratio,
height: ui.height / ratio,
}
},
});
ui.uploadCrop.hide();
@ -92,7 +92,7 @@ const CroppieUI = (($) => {
reader.onload = (e) => {
ui.uploadCrop.addClass('ready');
ui.uploadCrop.croppie('bind', {
url: e.target.result
url: e.target.result,
});
ui.uploadCrop.show();
@ -113,9 +113,9 @@ const CroppieUI = (($) => {
type: 'blob',
size: {
width: ui.width,
height: ui.height
height: ui.height,
},
format: 'png'
format: 'png',
}).then((blob) => {
const form = e.currentTarget;
const data = new FormData(form);
@ -123,7 +123,7 @@ const CroppieUI = (($) => {
data.delete('BackURL');
data.delete(name);
data.append(name, blob, name + '-image.png');
data.append(name, blob, `${name }-image.png`);
data.append('ajax', '1');
if (!$(form).data('jsFormValidate').validate()) {
@ -132,7 +132,7 @@ const CroppieUI = (($) => {
$.ajax({
url: $(form).attr('action'),
data: data,
data,
processData: false,
contentType: false,
type: $(form).attr('method'),
@ -177,7 +177,7 @@ const CroppieUI = (($) => {
SpinnerUI.hide();
$(G).trigger(Events.AJAX);
}
},
});
//ui.inputData.val(data);

View File

@ -49,8 +49,8 @@ const DatetimeUI = (($) => {
defaultTime: $el.data('default-time'),
icons: {
up: 'fas fa-chevron-up',
down: 'fas fa-chevron-down'
}
down: 'fas fa-chevron-down',
},
});
}
}

View File

@ -56,7 +56,7 @@ const SteppedForm = (($) => {
}
//
ui.step('.step[data-step="' + ui._currentStep + '"]');
ui.step(`.step[data-step="${ ui._currentStep }"]`);
ui._stepNext.on('click', (e) => {
e.preventDefault();
@ -96,7 +96,7 @@ const SteppedForm = (($) => {
return;
}
ui.step('.step[data-step="' + (ui._currentStep + 1) + '"]');
ui.step(`.step[data-step="${ ui._currentStep + 1 }"]`);
}
prev() {

View File

@ -15,7 +15,7 @@ const FormStorage = (($) => {
const $elements = $element.find('input, textarea, select');
const setRangeValues = function(el) {
let $el = $(el);
const $el = $(el);
$el.siblings('.value').text($el.val());
};

View File

@ -94,7 +94,7 @@ const FormValidateField = (($) => {
$field.addClass('error');
if (msg) {
$field.append('<div class="message alert alert-error alert-danger">' + msg + '</div>');
$field.append(`<div class="message alert alert-error alert-danger">${ msg }</div>`);
}
if (scrollTo) {

View File

@ -70,7 +70,7 @@ const FormValidate = (($) => {
const ui = this;
let valid = true;
ui._fields.each(function(i, el) {
ui._fields.each((i, el) => {
const $el = $(el);
const fieldUI = $el.data('jsFormValidateField');

View File

@ -32,7 +32,7 @@ const MapAPI = (($) => {
];
const popup = new mapboxgl.Popup({
closeOnClick: false,
className: 'popup'
className: 'popup',
});
currentStyle = this.getStyle();
@ -40,12 +40,12 @@ const MapAPI = (($) => {
Map = new mapBoxGL.Map({
'container': $element.find('.mapAPI-map')[0],
'center': center,
center,
//hash: true,
'style': currentStyle,
//localIdeographFontFamily: $BODY.css('font-family'),
'zoom': ($element.data('map-zoom') ? $element.data('map-zoom') : 10),
'attributionControl': false
'attributionControl': false,
/*transformRequest: (url, resourceType)=> {
if(resourceType === 'Source' && url.startsWith('http://myHost')) {
return {
@ -57,7 +57,7 @@ const MapAPI = (($) => {
}*/
})
.addControl(new mapBoxGL.AttributionControl({
compact: true
compact: true,
}))
.addControl(new mapBoxGL.NavigationControl(), 'top-right')
.addControl(new mapBoxGL.GeolocateControl({
@ -68,17 +68,17 @@ const MapAPI = (($) => {
}), 'bottom-right')
.addControl(new mapboxgl.ScaleControl({
maxWidth: 80,
unit: 'metric'
unit: 'metric',
}), 'top-left');
// event.target
Map.on('load', (e) => {
// add markers to map
geojson.features.forEach(function(marker) {
geojson.features.forEach((marker) => {
// create a DOM element for the marker
const $el = $('<div class="marker">' + marker.icon + '</div>');
const $el = $(`<div class="marker">${ marker.icon }</div>`);
$el.on('click', function() {
$el.on('click', () => {
console.log('Marker click');
const coordinates = marker.geometry.coordinates;
const content = marker.properties.content;

View File

@ -45,7 +45,7 @@ const NoCaptcha = (($) => {
return;
}
const $form = $field.data('form') ? $('#' + $field.data('form')) : $field.parents('form');
const $form = $field.data('form') ? $(`#${ $field.data('form')}`) : $field.parents('form');
//For the invisible captcha we need to setup some callback listeners
if ($field.data('size') === 'invisible' && !$field.data('callback')) {

View File

@ -10,7 +10,7 @@ const OpeningHoursUI = (($) => {
// Static methods
static each(callback) {
$('.js-opening-hours').each(function(i, e) {
$('.js-opening-hours').each((i, e) => {
callback(i, $(e));
});
}
@ -48,14 +48,14 @@ const OpeningHoursUI = (($) => {
(v['DisplayStart'] && v['DisplayStart'] <= dateYMD && !v['DisplayEnd']) ||
(v['DisplayEnd'] && v['DisplayEnd'] >= dateYMD && !v['DisplayStart'])
) {
html = 'Open today from ' + v['From'] + ' to ' + v['Till'];
html = `Open today from ${ v['From'] } to ${ v['Till']}`;
return false;
}
} else {
if (i > 0) {
html += ', <br/>';
}
html += 'from ' + v['From'] + ' to ' + v['Till'];
html += `from ${ v['From'] } to ${ v['Till']}`;
}
});
@ -66,9 +66,9 @@ const OpeningHoursUI = (($) => {
typeof hours['holidays'] !== 'undefined' &&
typeof hours['holidays'][dateYMD] !== 'undefined'
) {
html = '<b class="opening-hours-status opening-hours-status-closed">Closed today' +
(hours['holidays'][dateYMD] ? ' for ' + hours['holidays'][dateYMD] : '') +
'</b>';
html = `<b class="opening-hours-status opening-hours-status-closed">Closed today${
hours['holidays'][dateYMD] ? ` for ${ hours['holidays'][dateYMD]}` : ''
}</b>`;
}
this.each((i, e) => {
@ -82,13 +82,13 @@ const OpeningHoursUI = (($) => {
year = String(date.getFullYear());
month = String(date.getMonth() + 1);
if (month.length == 1) {
month = '0' + month;
month = `0${ month}`;
}
day = String(date.getDate());
if (day.length == 1) {
day = '0' + day;
day = `0${ day}`;
}
return year + '-' + month + '-' + day;
return `${year }-${ month }-${ day}`;
}
static dispose() {

View File

@ -8,7 +8,7 @@ const ShrinkUI = (($) => {
const D = document;
// shrink bar
$(G).scroll(function() {
$(G).scroll(() => {
if ($(D).scrollTop() > 100) {
$('body').addClass('shrink');
} else {

View File

@ -42,14 +42,14 @@ const VideoPreviewUI = (($) => {
ui.$_el.addClass('loading');
$.ajax({
type: 'GET',
url: 'https://vimeo.com/api/v2/video/' + video_id + '.json',
url: `https://vimeo.com/api/v2/video/${ video_id }.json`,
jsonp: 'callback',
dataType: 'jsonp',
success: function(data) {
const thumbnail_src = data[0].thumbnail_large;
ui.show(thumbnail_src);
ui.$_el.removeClass('loading');
}
},
});
return;