(function($) { $.fn.bannerPopup = async function(options) { const opts = $.extend({}, $.fn.bannerPopup.defaults, options) const langJson = await loadLangJson.call(this, opts['basePath'], opts['langType']) callBannerApi.call(this, opts, langJson) }; function appendSlide(bannerList, opts) { return bannerList.reduce((html, banner) => { return html + `
  • ` }, '') } function callBannerApi(opts, langJson) { const self = this const connectionDevice = opts['connectionDevice']; $.fn.dataLinker.localApi('list-type1-book', { "Book": [ { "QueryVars": { "QueryName": "post/banner-input", "SimpleFilter": "(mx.post_type_id = 8 and mx.status = '0') and (DATE_FORMAT(now(), '%Y-%m-%d') BETWEEN mx.pc6 AND mx.pc7)", "IsntPagination": true, }, "ListType1Vars" : { 'OrderBy': 'mx.pc3 asc' }, "PageVars": { "Limit": 100000 } }, { "QueryVars": { "QueryName": "pro/setup", "SimpleFilter": "setup_code='popup-slider'", "IsntPagination": true, }, "PageVars": { "Limit": 100000 } } ] }, function (response) { const bannerList = response['Book'][0]['Page'] if (bannerList) { if(connectionDevice == 'desktop'){ bannerList['Setup'] = JSON.parse(response['Book'][1]['Page'][0]['C1']) }else{ bannerList['Setup'] = JSON.parse(response['Book'][1]['Page'][1]['C1']) } opts['width'] = bannerList['Setup']['Width'] opts['left'] = bannerList[0]['C7'] opts['top'] = bannerList[0]['C8'] self.append(html.call(self, bannerList, opts, langJson)) loadModule.call(self, bannerList.map(banner => banner['C1']), bannerList['Setup']) } }) } async function loadLangJson(basePath, langType) { let langJson = null if (langType === 'ko') { return langJson } const filePath = `${basePath}/lang/${langType}.json` await $.getJSON(filePath, function (data) { langJson = data }); return langJson } // function loadScript(basePath) { // if (typeof Swiper === 'undefined') { // $('head').append(``) // } // if (jQuery().draggable === undefined) { // $('head').append(``) // } // if ($.cookie === undefined) { // $('head').append(``) // } // } function loadSwiper(popupTitleList, setup) { const swiper = new Swiper($(this).find('.dabory-container')[0], { allowTouchMove: false, pagination: { el: $(this).find('.dabory-pagination')[0], clickable: true, renderBullet: function (index, className) { const titleList = popupTitleList[index].split(' ') let caption = '' titleList.forEach((title, index) => { if (index === 0) { caption += title } else if (index === 1) { caption += (`
    ${title}`) } else { caption += ' ' + title } }); return `
    ` } }, autoplay: { delay: 5000, disableOnInteraction: false, }, }); $(this).find('.dabory-slide').on('mouseover', function() { swiper.autoplay.stop(); }); $(this).find('.dabory-slide').on('mouseout', function() { swiper.autoplay.start(); }); } function todayCloseBanner(today = false) { if (today) { $.cookie($(this).getSelector(), 'ok', { expires: 1, path: '/' }); } $(this).find('.dabory-bannermanager').hide() $(this).closest('#dabory-widget-list').trigger('hide.widget', 'banner') } function loadModule(titleList, setup) { const self = this $(document).ready(function () { $(self).find('.dabory-multipopup').draggable() if ($.cookie($(self).getSelector()) === 'ok') { $(self).find('.dabory-bannermanager').css('display', 'none') } else { $(self).find('.dabory-bannermanager').css('display', 'block') } $(self).find('.dabory-multipopup-btn-item_close').on('click', function() { todayCloseBanner.call(self) }); $(self).find('.dabory-multipopup-btn-item_todayclose').on('click', function() { todayCloseBanner.call(self, true) }); loadSwiper.call(self, titleList, setup) }); } function html(bannerList, opts, langJson) { return `` } function getLangText(langJson, key) { if (! langJson) { return key } return langJson[key] } $.fn.bannerPopup.defaults = { top: 0, left: 0, width: 650, langType: 'ko', basePath: '/dabory/widget/banner-popup', hide: true }; }(jQuery));