| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344 |
- <template>
- <div v-bind:id="id"><span><slot></slot></span></div>
- </template>
- <script>
- import '../jqwidgets/jqxcore.js';
- import '../jqwidgets/jqxcheckbox.js';
- export default {
- props: {
- animationShowDelay: Number,
- animationHideDelay: Number,
- boxSize: String,
- checked: Boolean,
- disabled: Boolean,
- enableContainerClick: Boolean,
- groupName: String,
- height: [Number, String],
- hasThreeStates: Boolean,
- locked: Boolean,
- rtl: Boolean,
- theme: String,
- width: [Number, String],
- autoCreate: {
- default: true,
- type: Boolean
- }
- },
- created: function () {
- this.id = 'jqxCheckBox' + JQXLite.generateID();
- this.componentSelector = '#' + this.id;
- },
- mounted: function () {
- if (this.autoCreate) this.__createComponent__();
- },
- methods: {
- createComponent: function (options) {
- if (!this.autoCreate) this.__createComponent__(options)
- else console.warn('Component is already created! If you want to use createComponent, please set "autoCreate" property to "false".');
- },
- setOptions: function (options) {
- JQXLite(this.componentSelector).jqxCheckBox(options);
- },
- getOptions: function () {
- const usedProps = Object.keys(this.__manageProps__());
- const resultToReturn = {};
- for (let i = 0; i < usedProps.length; i++) {
- resultToReturn[usedProps[i]] = JQXLite(this.componentSelector).jqxCheckBox(usedProps[i]);
- }
- return resultToReturn;
- },
- check: function() {
- JQXLite(this.componentSelector).jqxCheckBox('check');
- },
- disable: function() {
- JQXLite(this.componentSelector).jqxCheckBox('disable');
- },
- destroy: function() {
- JQXLite(this.componentSelector).jqxCheckBox('destroy');
- },
- enable: function() {
- JQXLite(this.componentSelector).jqxCheckBox('enable');
- },
- focus: function() {
- JQXLite(this.componentSelector).jqxCheckBox('focus');
- },
- indeterminate: function() {
- JQXLite(this.componentSelector).jqxCheckBox('indeterminate');
- },
- render: function() {
- JQXLite(this.componentSelector).jqxCheckBox('render');
- },
- toggle: function() {
- JQXLite(this.componentSelector).jqxCheckBox('toggle');
- },
- uncheck: function() {
- JQXLite(this.componentSelector).jqxCheckBox('uncheck');
- },
- val: function(value) {
- if (value !== undefined) {
- JQXLite(this.componentSelector).jqxCheckBox('val', value)
- } else {
- return JQXLite(this.componentSelector).jqxCheckBox('val');
- }
- },
- _animationShowDelay: function(arg) {
- if (arg !== undefined) {
- JQXLite(this.componentSelector).jqxCheckBox('animationShowDelay', arg)
- } else {
- return JQXLite(this.componentSelector).jqxCheckBox('animationShowDelay');
- }
- },
- _animationHideDelay: function(arg) {
- if (arg !== undefined) {
- JQXLite(this.componentSelector).jqxCheckBox('animationHideDelay', arg)
- } else {
- return JQXLite(this.componentSelector).jqxCheckBox('animationHideDelay');
- }
- },
- _boxSize: function(arg) {
- if (arg !== undefined) {
- JQXLite(this.componentSelector).jqxCheckBox('boxSize', arg)
- } else {
- return JQXLite(this.componentSelector).jqxCheckBox('boxSize');
- }
- },
- _checked: function(arg) {
- if (arg !== undefined) {
- JQXLite(this.componentSelector).jqxCheckBox('checked', arg)
- } else {
- return JQXLite(this.componentSelector).jqxCheckBox('checked');
- }
- },
- _disabled: function(arg) {
- if (arg !== undefined) {
- JQXLite(this.componentSelector).jqxCheckBox('disabled', arg)
- } else {
- return JQXLite(this.componentSelector).jqxCheckBox('disabled');
- }
- },
- _enableContainerClick: function(arg) {
- if (arg !== undefined) {
- JQXLite(this.componentSelector).jqxCheckBox('enableContainerClick', arg)
- } else {
- return JQXLite(this.componentSelector).jqxCheckBox('enableContainerClick');
- }
- },
- _groupName: function(arg) {
- if (arg !== undefined) {
- JQXLite(this.componentSelector).jqxCheckBox('groupName', arg)
- } else {
- return JQXLite(this.componentSelector).jqxCheckBox('groupName');
- }
- },
- _height: function(arg) {
- if (arg !== undefined) {
- JQXLite(this.componentSelector).jqxCheckBox('height', arg)
- } else {
- return JQXLite(this.componentSelector).jqxCheckBox('height');
- }
- },
- _hasThreeStates: function(arg) {
- if (arg !== undefined) {
- JQXLite(this.componentSelector).jqxCheckBox('hasThreeStates', arg)
- } else {
- return JQXLite(this.componentSelector).jqxCheckBox('hasThreeStates');
- }
- },
- _locked: function(arg) {
- if (arg !== undefined) {
- JQXLite(this.componentSelector).jqxCheckBox('locked', arg)
- } else {
- return JQXLite(this.componentSelector).jqxCheckBox('locked');
- }
- },
- _rtl: function(arg) {
- if (arg !== undefined) {
- JQXLite(this.componentSelector).jqxCheckBox('rtl', arg)
- } else {
- return JQXLite(this.componentSelector).jqxCheckBox('rtl');
- }
- },
- _theme: function(arg) {
- if (arg !== undefined) {
- JQXLite(this.componentSelector).jqxCheckBox('theme', arg)
- } else {
- return JQXLite(this.componentSelector).jqxCheckBox('theme');
- }
- },
- _width: function(arg) {
- if (arg !== undefined) {
- JQXLite(this.componentSelector).jqxCheckBox('width', arg)
- } else {
- return JQXLite(this.componentSelector).jqxCheckBox('width');
- }
- },
- __createComponent__: function (options) {
- let widgetOptions;
- options ? widgetOptions = options : widgetOptions = this.__manageProps__();
- JQXLite(this.componentSelector).jqxCheckBox(widgetOptions);
- this.__extendProps__();
- this.__wireEvents__();
- },
- __manageProps__: function () {
- const widgetProps = ['animationShowDelay','animationHideDelay','boxSize','checked','disabled','enableContainerClick','groupName','height','hasThreeStates','locked','rtl','theme','width'];
- const componentProps = this.$options.propsData;
- let options = {};
- for (let prop in componentProps) {
- if (widgetProps.indexOf(prop) !== -1) {
- options[prop] = componentProps[prop];
- }
- }
- return options;
- },
- __extendProps__: function () {
- const that = this;
- Object.defineProperty(that, 'animationShowDelay', {
- get: function() {
- return that._animationShowDelay();
- },
- set: function(newValue) {
- that._animationShowDelay(newValue);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(that, 'animationHideDelay', {
- get: function() {
- return that._animationHideDelay();
- },
- set: function(newValue) {
- that._animationHideDelay(newValue);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(that, 'boxSize', {
- get: function() {
- return that._boxSize();
- },
- set: function(newValue) {
- that._boxSize(newValue);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(that, 'checked', {
- get: function() {
- return that._checked();
- },
- set: function(newValue) {
- that._checked(newValue);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(that, 'disabled', {
- get: function() {
- return that._disabled();
- },
- set: function(newValue) {
- that._disabled(newValue);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(that, 'enableContainerClick', {
- get: function() {
- return that._enableContainerClick();
- },
- set: function(newValue) {
- that._enableContainerClick(newValue);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(that, 'groupName', {
- get: function() {
- return that._groupName();
- },
- set: function(newValue) {
- that._groupName(newValue);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(that, 'height', {
- get: function() {
- return that._height();
- },
- set: function(newValue) {
- that._height(newValue);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(that, 'hasThreeStates', {
- get: function() {
- return that._hasThreeStates();
- },
- set: function(newValue) {
- that._hasThreeStates(newValue);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(that, 'locked', {
- get: function() {
- return that._locked();
- },
- set: function(newValue) {
- that._locked(newValue);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(that, 'rtl', {
- get: function() {
- return that._rtl();
- },
- set: function(newValue) {
- that._rtl(newValue);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(that, 'theme', {
- get: function() {
- return that._theme();
- },
- set: function(newValue) {
- that._theme(newValue);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(that, 'width', {
- get: function() {
- return that._width();
- },
- set: function(newValue) {
- that._width(newValue);
- },
- enumerable: true,
- configurable: true
- });
- },
- __twoWayDataBinding__: function () {
- const value = JQXLite(this.componentSelector).jqxCheckBox('val');
- this.$emit('input', value);
- },
- __wireEvents__: function () {
- const that = this;
- JQXLite(this.componentSelector).on('checked', function (event) { that.$emit('checked', event); });
- JQXLite(this.componentSelector).on('change', function (event) { that.$emit('change', event); that.__twoWayDataBinding__(); });
- JQXLite(this.componentSelector).on('indeterminate', function (event) { that.$emit('indeterminate', event); });
- JQXLite(this.componentSelector).on('unchecked', function (event) { that.$emit('unchecked', event); });
- }
- }
- }
- </script>
|