UNPKG

vue-cookie-accept-decline

Version:

Show a banner with text, a decline button, and an accept button on your page.

1 lines 11.3 kB
!function(t){function e(e){for(var i,c,a=e[0],l=e[1],r=e[2],p=0,d=[];p<a.length;p++)c=a[p],n[c]&&d.push(n[c][0]),n[c]=0;for(i in l)Object.prototype.hasOwnProperty.call(l,i)&&(t[i]=l[i]);for(u&&u(e);d.length;)d.shift()();return s.push.apply(s,r||[]),o()}function o(){for(var t,e=0;e<s.length;e++){for(var o=s[e],i=!0,a=1;a<o.length;a++){var l=o[a];0!==n[l]&&(i=!1)}i&&(s.splice(e--,1),t=c(c.s=o[0]))}return t}var i={},n={0:0},s=[];function c(e){if(i[e])return i[e].exports;var o=i[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,c),o.l=!0,o.exports}c.m=t,c.c=i,c.d=function(t,e,o){c.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},c.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},c.t=function(t,e){if(1&e&&(t=c(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(c.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)c.d(o,i,function(e){return t[e]}.bind(null,i));return o},c.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return c.d(e,"a",e),e},c.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},c.p="./";var a=window.webpackJsonp=window.webpackJsonp||[],l=a.push.bind(a);a.push=e,a=a.slice();for(var r=0;r<a.length;r++)e(a[r]);var u=l;s.push([8,1]),o()}([,,function(t,e,o){},function(t,e,o){},,,function(t,e,o){"use strict";var i=o(0),n={name:"vue-cookie-accept-decline",props:{elementId:{type:String,required:!0},debug:{type:Boolean,default:!1},disableDecline:{type:Boolean,default:!1},position:{type:String,default:"bottom-left"},type:{type:String,default:"floating"},transitionName:{type:String,default:"slideFromBottom"},showPostponeButton:{type:Boolean,default:!1}},data:function(){return{status:null,supportsLocalStorage:!0,isOpen:!1}},computed:{containerPosition:function(){return"cookie--".concat(this.position)},containerType:function(){return"cookie--".concat(this.type)}},mounted:function(){this.checkLocalStorageFunctionality(),this.init()},methods:{init:function(){var t=this.getCookieStatus();!t||"accept"!==t&&"decline"!==t&&"postpone"!==t||(this.isOpen=!1),t||(this.isOpen=!0),this.status=t,this.$emit("status",t)},checkLocalStorageFunctionality:function(){try{var t="__vue-cookie-accept-decline-check-localStorage";window.localStorage.setItem(t,t),window.localStorage.removeItem(t)}catch(t){console.error("Local storage is not supported, falling back to cookie use"),this.supportsLocalStorage=!1}},setCookieStatus:function(t){this.supportsLocalStorage?("accept"===t&&localStorage.setItem("vue-cookie-accept-decline-".concat(this.elementId),"accept"),"decline"===t&&localStorage.setItem("vue-cookie-accept-decline-".concat(this.elementId),"decline"),"postpone"===t&&localStorage.setItem("vue-cookie-accept-decline-".concat(this.elementId),"postpone")):("accept"===t&&i.b("vue-cookie-accept-decline-".concat(this.elementId),"accept"),"decline"===t&&i.b("vue-cookie-accept-decline-".concat(this.elementId),"decline"),"postpone"===t&&i.b("vue-cookie-accept-decline-".concat(this.elementId),"postpone"))},getCookieStatus:function(){return this.supportsLocalStorage?localStorage.getItem("vue-cookie-accept-decline-".concat(this.elementId)):i.a("vue-cookie-accept-decline-".concat(this.elementId))},accept:function(){this.debug||this.setCookieStatus("accept"),this.status="accept",this.isOpen=!1,this.$emit("clicked-accept")},decline:function(){this.debug||this.setCookieStatus("decline"),this.status="decline",this.isOpen=!1,this.$emit("clicked-decline")},postpone:function(){this.debug||this.setCookieStatus("postpone"),this.status="postpone",this.isOpen=!1,this.$emit("clicked-postpone")},removeCookie:function(){localStorage.removeItem("vue-cookie-accept-decline-".concat(this.elementId)),this.status=null,this.$emit("removed-cookie")}}},s=(o(10),o(4)),c=Object(s.a)(n,function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("transition",{attrs:{appear:"",name:t.transitionName}},[t.isOpen?o("div",{staticClass:"cookie",class:["cookie__"+t.type,"cookie__"+t.type+"--"+t.position],attrs:{id:t.elementId}},[!0===t.showPostponeButton?o("div",{class:"cookie__"+t.type+"__postpone-button",attrs:{title:"Close"},on:{click:t.postpone}},[t._t("postponeContent",[t._v("\n ×\n ")])],2):t._e(),t._v(" "),o("div",{class:"cookie__"+t.type+"__content"},[t._t("message",[t._v("\n We use cookies to ensure you get the best experience on our website. "),o("a",{attrs:{href:"https://cookiesandyou.com/",target:"_blank"}},[t._v("Learn More...")])])],2),t._v(" "),o("div",{class:"cookie__"+t.type+"__buttons"},[!1===t.disableDecline?o("button",{class:["cookie__"+t.type+"__buttons__button","cookie__"+t.type+"__buttons__button--decline"],on:{click:t.decline}},[t._t("declineContent",[t._v("\n Opt Out\n ")])],2):t._e(),t._v(" "),o("button",{class:["cookie__"+t.type+"__buttons__button","cookie__"+t.type+"__buttons__button--accept"],on:{click:t.accept}},[t._t("acceptContent",[t._v("\n Got It!\n ")])],2)])]):t._e()])},[],!1,null,null,null);e.a=c.exports},function(t,e,o){"use strict";(function(t){var i=o(6);var n={install:function t(e){t.installed||(t.installed=!0,e.component("VueCookieAcceptDecline",i.a))}},s=null;"undefined"!=typeof window?s=window.Vue:void 0!==t&&(s=t.Vue),s&&s.use(n),e.a=i.a}).call(this,o(1))},function(t,e,o){t.exports=o(14)},function(t,e,o){"use strict";var i=o(2);o.n(i).a},function(t,e,o){"use strict";var i=o(3);o.n(i).a},,,,function(t,e,o){"use strict";o.r(e);var i=o(5),n={name:"app",data:function(){return{status:null}},methods:{cookieStatus:function(t){console.log("status: "+t),this.status=t},cookieClickedAccept:function(){console.log("here in accept"),this.status="accept"},cookieClickedDecline:function(){console.log("here in decline"),this.status="decline"},cookieClickedPostpone:function(){console.log("here in postpone"),this.status="postpone"},cookieRemovedCookie:function(){console.log("here in cookieRemoved"),this.status=null,this.$refs.myPanel1.init()},removeCookie:function(){console.log("Cookie removed"),this.$refs.myPanel1.removeCookie()}},computed:{statusText:function(){return this.status||"No cookie set"}}},s=(o(9),o(4)),c=Object(s.a)(n,function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{attrs:{id:"app"}},[o("a",{staticClass:"github-corner",attrs:{href:"https://github.com/promosis/vue-cookie-accept-decline",target:"_blank","aria-label":"View source on Github"}},[o("svg",{staticStyle:{fill:"#54AD58",color:"#fff",position:"absolute",top:"0",border:"0",right:"0"},attrs:{width:"80",height:"80",viewBox:"0 0 250 250","aria-hidden":"true"}},[o("path",{attrs:{d:"M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"}}),o("path",{staticClass:"octo-arm",staticStyle:{"transform-origin":"130px 106px"},attrs:{d:"M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2",fill:"currentColor"}}),o("path",{staticClass:"octo-body",attrs:{d:"M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z",fill:"currentColor"}})])]),t._v(" "),t._m(0),t._v(" "),t._m(1),t._v(" "),t._m(2),t._v(" "),t._m(3),t._v(" "),o("div",{staticClass:"container py-3"},[o("div",{staticClass:"row justify-content-center"},[o("div",{staticClass:"col-xl-4"},[o("button",{staticClass:"btn btn-primary btn-block mb-4",on:{click:t.removeCookie}},[t._v("×   Remove Browser Cookie")])]),t._v(" "),o("div",{staticClass:"col-xl-4"},[o("div",{staticClass:"code-text"},[t._v("\n Status: "),o("strong",[t._v(t._s(t.statusText))])])])])]),t._v(" "),o("vue-cookie-accept-decline",{ref:"myPanel1",attrs:{elementId:"myPanel1",debug:!1,position:"bottom-left",type:"floating",disableDecline:!1,transitionName:"slideFromBottom",showPostponeButton:!1},on:{status:t.cookieStatus,"clicked-accept":t.cookieClickedAccept,"clicked-decline":t.cookieClickedDecline,"clicked-postpone":t.cookieClickedPostpone,"removed-cookie":t.cookieRemovedCookie}},[o("div",{attrs:{slot:"postponeContent"},slot:"postponeContent"},[t._v("\n ×\n ")]),t._v(" "),o("div",{attrs:{slot:"message"},slot:"message"},[t._v("\n We use cookies to ensure you get the best experience on our website. "),o("a",{attrs:{href:"https://cookiesandyou.com/",target:"_blank"}},[t._v("Learn More...")])]),t._v(" "),o("div",{attrs:{slot:"declineContent"},slot:"declineContent"},[t._v("\n OPT OUT\n ")]),t._v(" "),o("div",{attrs:{slot:"acceptContent"},slot:"acceptContent"},[t._v("\n GOT IT!\n ")])])],1)},[function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"container pt-4 pb-1"},[e("div",{staticClass:"row"},[e("div",{staticClass:"col-lg-12"},[e("a",{attrs:{href:"https://www.promosis.com"}},[e("img",{staticClass:"img-fluid promosis-image",attrs:{src:"https://s3.amazonaws.com/promosis-com/promosis-logo-color-with-tag.png",alt:"Promosis Logo",target:"_blank"}})])])])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"container py-4"},[e("div",{staticClass:"row justify-content-center"},[e("div",{staticClass:"col-lg-12 text-center"},[e("h3",[e("strong",[this._v("vue-cookie-accept-decline")])])])])])},function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"container pt-3 pb-4"},[o("div",{staticClass:"row justify-content-center"},[o("div",{staticClass:"col-lg-6"},[o("span",{staticClass:"badge badge-primary mb-1"},[t._v("install")]),t._v(" "),o("div",{staticClass:"code-text"},[t._v("npm i vue-cookie-accept-decline")])]),t._v(" "),o("div",{staticClass:"col-lg-4"},[o("div",{staticClass:"list-group"},[o("a",{staticClass:"list-group-item list-group-item-action",attrs:{href:"https://github.com/promosis/vue-cookie-accept-decline",target:"_blank"}},[t._v("View on GitHub")]),t._v(" "),o("a",{staticClass:"list-group-item list-group-item-action",attrs:{href:"https://www.npmjs.com/package/vue-cookie-accept-decline",target:"_blank"}},[t._v("View on NPM")]),t._v(" "),o("a",{staticClass:"list-group-item list-group-item-action list-group-item-success",attrs:{href:"https://www.promosis.com",target:"_blank"}},[t._v("Visit Promosis.com")])])])])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"container py-3"},[e("div",{staticClass:"row justify-content-center"},[e("div",{staticClass:"col-lg-10"},[e("hr")])])])}],!1,null,null,null).exports,a=o(7);i.a.component("vue-cookie-accept-decline",a.a),new i.a({el:"#app",render:function(t){return t(c)}})}]);