IMPROVEMENT: emulate links

This commit is contained in:
Tony Air 2020-02-06 22:14:17 +07:00
parent c6f84ebc5d
commit ed1a9b28e3
3 changed files with 46 additions and 7 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@a2nt/ss-bootstrap-ui-webpack-boilerplate", "name": "@a2nt/ss-bootstrap-ui-webpack-boilerplate",
"version": "1.7.2", "version": "1.7.3",
"author": "Tony Air <tony@twma.pro>", "author": "Tony Air <tony@twma.pro>",
"license": "MIT", "license": "MIT",
"description": "This UI Kit allows you to build Bootstrap 4 webapp with some extra UI features. It's easy to extend and easy to convert HTML templates to CMS templates.", "description": "This UI Kit allows you to build Bootstrap 4 webapp with some extra UI features. It's easy to extend and easy to convert HTML templates to CMS templates.",

View File

@ -1,10 +1,10 @@
"use strict"; 'use strict';
import $ from 'jquery'; import $ from 'jquery';
import Events from './_events'; import Events from './_events';
const LayoutUI = (($) => { const LayoutUI = ($ => {
// Constants // Constants
const W = window; const W = window;
const D = document; const D = document;
@ -28,6 +28,33 @@ const LayoutUI = (($) => {
console.log(`Initializing: ${NAME}`); console.log(`Initializing: ${NAME}`);
// your custom UI // your custom UI
// Custom fonts
$Body.append(
'<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,400i,700,700i&display=swap" rel="stylesheet">',
);
/*google analytics */
/*(function(i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
(i[r] =
i[r] ||
function() {
(i[r].q = i[r].q || []).push(arguments);
}),
(i[r].l = 1 * new Date());
(a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]);
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m);
})(
window,
document,
'script',
'//www.google-analytics.com/analytics.js',
'ga',
);
ga('create', 'UA-********-*', 'auto');
ga('send', 'pageview');*/
} }
static dispose() { static dispose() {

View File

@ -15,7 +15,7 @@ import FormBasics from './_components/_ui.form.basics';
import SmoothScroll from 'smooth-scroll'; import SmoothScroll from 'smooth-scroll';
const smoothScroll = SmoothScroll(); const smoothScroll = SmoothScroll();
const MainUI = (($) => { const MainUI = ($ => {
// Constants // Constants
const W = window; const W = window;
const D = document; const D = document;
@ -174,7 +174,7 @@ const MainUI = (($) => {
// //
// scroll links // scroll links
$('.js-scrollTo').on('click', (e) => { $('.js-scrollTo').on('click', e => {
e.preventDefault(); e.preventDefault();
const el = e.currentTarget; const el = e.currentTarget;
const $el = $(e.currentTarget); const $el = $(e.currentTarget);
@ -203,7 +203,7 @@ const MainUI = (($) => {
} }
// data-set links // data-set links
$('[data-set-target]').on('click', (e) => { $('[data-set-target]').on('click', e => {
const $el = $(e.currentTarget); const $el = $(e.currentTarget);
const $target = $($el.data('set-target')); const $target = $($el.data('set-target'));
@ -226,6 +226,18 @@ const MainUI = (($) => {
$target.closest('form').trigger(Events.SET_TARGET_UPDATE); $target.closest('form').trigger(Events.SET_TARGET_UPDATE);
}); });
// emulate links
$('.a[data-href]').on('click', e => {
const $el = $(e.currentTarget);
const href = $el.data('href');
if (!href.length) {
console.warn('Missing data-href');
console.warn($el);
}
W.location.assign(href);
});
// hide spinner // hide spinner
Spinner.hide(() => { Spinner.hide(() => {
$Body.addClass('loaded'); $Body.addClass('loaded');
@ -350,7 +362,7 @@ const MainUI = (($) => {
$el.addClass('loading'); $el.addClass('loading');
AjaxUI.preload([lazySrc]).then(() => { AjaxUI.preload([lazySrc]).then(() => {
$el.css({ 'background-image': `url(${ lazySrc })` }); $el.css({ 'background-image': `url(${lazySrc})` });
$el.addClass('loaded'); $el.addClass('loaded');
$el.removeClass('loading'); $el.removeClass('loading');