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 methods
static each(callback) { static each(callback) {
$('.js-carousel').each(function(i, e) { $('.js-carousel').each((i, e) => {
callback(i, $(e)); callback(i, $(e));
}); });
} }
@ -34,17 +34,17 @@ const CarouselUI = (($) => {
// create carousel-controls // create carousel-controls
if ($e.data('indicators')) { if ($e.data('indicators')) {
const $indicators = $('<ol class="carousel-indicators"></ol>'); 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++) { 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); $e.prepend($indicators);
} }
// create arrows // create arrows
if ($e.data('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-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-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 // init carousel

View File

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

View File

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

View File

@ -49,8 +49,8 @@ const DatetimeUI = (($) => {
defaultTime: $el.data('default-time'), defaultTime: $el.data('default-time'),
icons: { icons: {
up: 'fas fa-chevron-up', 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) => { ui._stepNext.on('click', (e) => {
e.preventDefault(); e.preventDefault();
@ -96,7 +96,7 @@ const SteppedForm = (($) => {
return; return;
} }
ui.step('.step[data-step="' + (ui._currentStep + 1) + '"]'); ui.step(`.step[data-step="${ ui._currentStep + 1 }"]`);
} }
prev() { prev() {

View File

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

View File

@ -94,7 +94,7 @@ const FormValidateField = (($) => {
$field.addClass('error'); $field.addClass('error');
if (msg) { 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) { if (scrollTo) {

View File

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

View File

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

View File

@ -45,7 +45,7 @@ const NoCaptcha = (($) => {
return; 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 //For the invisible captcha we need to setup some callback listeners
if ($field.data('size') === 'invisible' && !$field.data('callback')) { if ($field.data('size') === 'invisible' && !$field.data('callback')) {

View File

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

View File

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

View File

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