(function($) { $.fn.quick = async function(options) { const opts = $.extend({}, $.fn.quick.defaults, options) $.fn.quick.zIndex = 5000 callApi.call(this) }; function callApi() { const self = this $.fn.dataLinker.api23Js('setup-get', { "SetupCode": "quick-launcher" }, function (response) { if (response) { self.append(html.call(self, response)) loadModule.call(self) loadWidget.call(self) } }) } function loadWidget() { this.append( `
` ) $(this).find('#dabory-banner').bannerPopup() $(this).find('#dabory-contact-us').contactUs({ top: 170, left: 170, }) $(this).find('#dabory-coupon').coupon({ top: 40, left: 375, }) $(this).find('#dabory-review').review({ top: 100, left: 100, }) loadScript() } function loadScript() { $('head').append(``) } function showWidget(widgetName, active) { const $widget = $(this).find(`.${widgetName}`) if (active) { $($widget).css('z-index', $.fn.quick.zIndex++) $($widget).trigger('show.widget') } $($widget).toggle() } function attachedType(buttons) { return `
` } function floatingType(buttons) { return `
` } function appendButtons(buttons) { return buttons.reduce((html, button) => { return html + `
  • ` }, '') } function html(quickLauncher) { switch (quickLauncher['Type']) { case 'right-floating': return floatingType(quickLauncher['Buttons']) case 'right-attached': return attachedType(quickLauncher['Buttons']) } } function loadModule() { const self = this $(document).ready(function () { $(document).on('hide.widget', '#dabory-widget-list', function (event, widgetName) { $(self).find('.quick-launcher') .find(`[data-widget="${widgetName}"]`) .closest('li').toggleClass('active') }); $(self).find('.show-widget-btn').on('click', function() { $(this).closest('li').toggleClass('active') showWidget.call(self, $(this).data('widget'), $(this).closest('li').hasClass('active')) }); $(self).find('.return-to-top').on('click', function() { $('body,html').animate({ scrollTop: 0 }, 500); }); $(self).find('.return-to-bottom').on('click', function() { $('body,html').animate({ scrollTop: $('body,html')[0].scrollHeight }, 500); }); $(document).on('click', '.tab-close', function () { const widget = $(this).data('widget') $(this).closest(`.${widget}`).hide() $(this).closest('#dabory-widget-list').trigger('hide.widget', widget) }); // $('.show-widget-btn[data-widget="coupon"]').trigger('click') }); } $.fn.quick.defaults = { langType: 'ko', basePath: '/dabory/widget/quick', }; }(jQuery));