From ed1a9b28e3f33ac1575b8397988c2b31fd4fe5bf Mon Sep 17 00:00:00 2001 From: Tony Air Date: Thu, 6 Feb 2020 22:14:17 +0700 Subject: [PATCH] IMPROVEMENT: emulate links --- package.json | 2 +- src/js/_layout.js | 31 +++++++++++++++++++++++++++++-- src/js/_main.js | 20 ++++++++++++++++---- 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index c8a0da6..c5316c7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@a2nt/ss-bootstrap-ui-webpack-boilerplate", - "version": "1.7.2", + "version": "1.7.3", "author": "Tony Air ", "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.", diff --git a/src/js/_layout.js b/src/js/_layout.js index 86e8f62..661d485 100755 --- a/src/js/_layout.js +++ b/src/js/_layout.js @@ -1,10 +1,10 @@ -"use strict"; +'use strict'; import $ from 'jquery'; import Events from './_events'; -const LayoutUI = (($) => { +const LayoutUI = ($ => { // Constants const W = window; const D = document; @@ -28,6 +28,33 @@ const LayoutUI = (($) => { console.log(`Initializing: ${NAME}`); // your custom UI + // Custom fonts + $Body.append( + '', + ); + + /*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() { diff --git a/src/js/_main.js b/src/js/_main.js index 2ae0a53..9f0a260 100755 --- a/src/js/_main.js +++ b/src/js/_main.js @@ -15,7 +15,7 @@ import FormBasics from './_components/_ui.form.basics'; import SmoothScroll from 'smooth-scroll'; const smoothScroll = SmoothScroll(); -const MainUI = (($) => { +const MainUI = ($ => { // Constants const W = window; const D = document; @@ -174,7 +174,7 @@ const MainUI = (($) => { // // scroll links - $('.js-scrollTo').on('click', (e) => { + $('.js-scrollTo').on('click', e => { e.preventDefault(); const el = e.currentTarget; const $el = $(e.currentTarget); @@ -203,7 +203,7 @@ const MainUI = (($) => { } // data-set links - $('[data-set-target]').on('click', (e) => { + $('[data-set-target]').on('click', e => { const $el = $(e.currentTarget); const $target = $($el.data('set-target')); @@ -226,6 +226,18 @@ const MainUI = (($) => { $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 Spinner.hide(() => { $Body.addClass('loaded'); @@ -350,7 +362,7 @@ const MainUI = (($) => { $el.addClass('loading'); AjaxUI.preload([lazySrc]).then(() => { - $el.css({ 'background-image': `url(${ lazySrc })` }); + $el.css({ 'background-image': `url(${lazySrc})` }); $el.addClass('loaded'); $el.removeClass('loading');