primevue
Version:
[](https://opensource.org/licenses/MIT) [](https://badge.fury.io/js/primevue) [![Join the chat at https://gitter.im/primefaces/primevu
1 lines • 4.51 kB
JavaScript
(function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?exports["togglebutton"]=e():t["togglebutton"]=e()})("undefined"!==typeof self?self:this,function(){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var i=e[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(o,i,function(e){return t[e]}.bind(null,i));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s="fb15")}({f6fd:function(t,e){(function(t){var e="currentScript",n=t.getElementsByTagName("script");e in t||Object.defineProperty(t,e,{get:function(){try{throw new Error}catch(o){var t,e=(/.*at [^\(]*\((.*):.+:.+\)$/gi.exec(o.stack)||[!1])[1];for(t in n)if(n[t].src==e||"interactive"==n[t].readyState)return n[t];return null}}})})(document)},fb15:function(t,e,n){"use strict";var o;(n.r(e),"undefined"!==typeof window)&&(n("f6fd"),(o=window.document.currentScript)&&(o=o.src.match(/(.+\/)[^\/]+\.js(\?.*)?$/))&&(n.p=o[1]));var i=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:t.buttonClass,on:{click:function(e){return t.onClick(e)}}},[n("div",{staticClass:"p-hidden-accessible"},[n("input",{ref:"input",attrs:{type:"checkbox",id:t.inputId,name:t.name,disabled:t.disabled},domProps:{checked:t.value},on:{focus:function(e){return t.onFocus(e)},blur:function(e){return t.onBlur(e)},keydown:function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"enter",13,e.key,"Enter")?null:(e.preventDefault(),t.onClick(e))}}})]),t.hasIcon?n("span",{class:t.iconClass}):t._e(),n("span",{staticClass:"p-button-text p-unselectable-text p-c"},[t._v(t._s(t.label))])])},r=[],s={props:{value:Boolean,onIcon:String,offIcon:String,onLabel:String,offLabel:String,inputId:String,name:String,iconPos:{type:String,default:"left"},disabled:Boolean},data:function(){return{focused:!1}},methods:{onClick:function(t){this.disabled||(this.$emit("click",t),this.$emit("input",!this.value),this.$emit("change",t),this.$refs.input.focus())},onFocus:function(t){this.focused=!0,this.$emit("focus",t)},onBlur:function(){this.focused=!1,this.$emit("blur",event)}},computed:{buttonClass:function(){return{"p-button p-togglebutton p-component":!0,"p-button-icon-only":this.hasIcon&&!this.hasLabel,"p-button-text-icon-left":this.hasIcon&&this.hasLabel&&"left"===this.iconPos,"p-button-text-icon-right":this.hasIcon&&this.hasLabel&&"right"===this.iconPos,"p-button-text-only":!this.hasIcon&&this.hasLabel,"p-disabled":this.disabled,"p-focus":this.focused,"p-highlight":!0===this.value}},iconClass:function(){return[this.value?this.onIcon:this.offIcon,{"p-button-icon-left":"left"===this.iconPos,"p-button-icon-right":"right"===this.iconPos}]},hasLabel:function(){return this.onLabel&&this.onLabel.length>0&&this.offLabel&&this.offLabel.length>0},hasIcon:function(){return this.onIcon&&this.onIcon.length>0&&this.offIcon&&this.offIcon.length>0},label:function(){return this.hasLabel?this.value?this.onLabel:this.offLabel:"p-btn"}}},u=s;function c(t,e,n,o,i,r,s,u){var c,l="function"===typeof t?t.options:t;if(e&&(l.render=e,l.staticRenderFns=n,l._compiled=!0),o&&(l.functional=!0),r&&(l._scopeId="data-v-"+r),s?(c=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"===typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),i&&i.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(s)},l._ssrRegister=c):i&&(c=u?function(){i.call(this,this.$root.$options.shadowRoot)}:i),c)if(l.functional){l._injectStyles=c;var a=l.render;l.render=function(t,e){return c.call(e),a(t,e)}}else{var f=l.beforeCreate;l.beforeCreate=f?[].concat(f,c):[c]}return{exports:t,options:l}}var l=c(u,i,r,!1,null,null,null),a=l.exports;e["default"]=a}})["default"]});