/** * Plugin Banners: ZyGCBanners * Plugin URI: https://gcboost.ru/shop/zygcbanners * Description: Модуль для вывода всплывающих баннеров с информационной или рекламной информацией * Version: 1.1 * Author: Evgeniy Nayden * Author URI: https://gcboost.ru/ */ !function(n,e){var t={},i="zy-gc-banners",a={init:function(e){t=n.extend(!0,{uri:"teach/control",debug:!0,access:"admin",scale:.6,iframeWidth:"992px"},e),a.debug("options",e),a.debug("settings",t),n("head").append(a.getStyles());let o=window.gcGetCookie(`${i}-not-show`);if(o&&"1"===o)return!1;a.setup()},setup:function(){if(null!==window.frameElement&&window.location.pathname.indexOf("/banners")>=0&&a.editFrame(),!a.checkAccess())return!1;n("body").append(a.template()),window.addEventListener("message",(function(e){e.data&&"frame-size"===e.data.action&&(a.debug("event.data",e.data),n(`.${i}__banner-content`).css({width:e.data.width,height:e.data.height}),n(`#${i}__banner-iframe`).css({height:e.data.height}),n(`#${i}__banner-wrap`).css({visibility:"visible",left:"75px"}))}),!1),window.addEventListener("message",(function(n){n.data&&"close-banner"===n.data.action&&(a.debug("event.data",n.data),a.close(n.data.id))}),!1)},editFrame:function(){n("body").append("\n \n "),n(document).ready((function(){n(`.${i}__parent`).hide(),n(`.${i}__parent`).each((function(){let e=n(this).data("block-id"),t=`${i}-${e}`,a=window.gcGetCookie(t)||1;if(a&&"0"!==a)return n(this).show(),setTimeout((()=>{window.parent.postMessage({action:"frame-size",height:n("body").outerHeight(!0)+"px",width:n("body").outerWidth(!0)+"px"})}),1e3),n(`.${i}__close-banner`).on("click",(function(){let e=n(this).closest(`.${i}__parent`);window.parent.postMessage({action:"close-banner",id:e.data("block-id")})})),!1}))}))},template:function(){return`\n
\n
\n \n
\n
\n `},checkAccess:function(){a.debug("checkAccess",window.userInfo);let n=!1;return window.userInfo&&("user"===t.access&&window.userInfo.isInAccount&&(n=!0),"manager"===t.access&&window.userInfo.isManager&&(n=!0),"admin"===t.access&&window.userInfo.isAdmin&&(n=!0)),window.location.pathname.indexOf(t.uri)>0&&n},close:function(e){let t=`${i}-${e}`,a=`${i}-not-show`;setTimeout((()=>{n(`#${i}__banner-wrap`).remove(),window.gcSetCookie(t,0,{expires:31536e3,path:"/",priority:"High"}),window.gcSetCookie(a,1,{expires:86400,path:"/",priority:"High"})}),100)},debug:function(n="key",e={}){t.debug},getUrlParam:function(n){a.debug("getUrlParam",n);let e=window.location.href;return new URL(e).searchParams.get(n)},getStorage:function(){if(a.debug("getStorage"),localStorage.getItem(storage_name)){return JSON.parse(localStorage.getItem(storage_name))[window.lessonId]}return!1},updateStorage:function(n){a.debug("updateStorage",n);let e=JSON.parse(localStorage.getItem(storage_name))||{};e[window.lessonId]={rating:n.rating,comment:n.comment},localStorage.setItem(storage_name,JSON.stringify(e))},show:function(n){},hide:function(n){},getStyles:function(){return`\n \n `}};n.zygcbanners=function(e){return a[e]?a[e].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof e&&e?void n.error("Метод с именем "+e+" не существует для jQuery.zygcbanners"):a.init.apply(this,arguments)}}(jQuery); /** КОД ВСТАВКИ В ГЕТКУРС */