| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300 |
- <template>
- <div v-bind:id="id">
- <slot></slot>
- </div>
- </template>
- <script>
- import '../jqwidgets/jqxcore.js';
- import '../jqwidgets/jqxbuttons.js';
- import '../jqwidgets/jqxscrollview.js';
- export default {
- props: {
- animationDuration: Number,
- bounceEnabled: Boolean,
- buttonsOffset: Array,
- currentPage: Number,
- disabled: Boolean,
- height: [Number, String],
- moveThreshold: Number,
- showButtons: Boolean,
- slideShow: Boolean,
- slideDuration: Number,
- theme: String,
- width: [Number, String],
- autoCreate: {
- default: true,
- type: Boolean
- }
- },
- created: function () {
- this.id = 'jqxScrollView' + 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).jqxScrollView(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).jqxScrollView(usedProps[i]);
- }
- return resultToReturn;
- },
- back: function() {
- JQXLite(this.componentSelector).jqxScrollView('back');
- },
- changePage: function(index) {
- JQXLite(this.componentSelector).jqxScrollView('changePage', index);
- },
- forward: function() {
- JQXLite(this.componentSelector).jqxScrollView('forward');
- },
- refresh: function() {
- JQXLite(this.componentSelector).jqxScrollView('refresh');
- },
- _animationDuration: function(arg) {
- if (arg !== undefined) {
- JQXLite(this.componentSelector).jqxScrollView('animationDuration', arg)
- } else {
- return JQXLite(this.componentSelector).jqxScrollView('animationDuration');
- }
- },
- _bounceEnabled: function(arg) {
- if (arg !== undefined) {
- JQXLite(this.componentSelector).jqxScrollView('bounceEnabled', arg)
- } else {
- return JQXLite(this.componentSelector).jqxScrollView('bounceEnabled');
- }
- },
- _buttonsOffset: function(arg) {
- if (arg !== undefined) {
- JQXLite(this.componentSelector).jqxScrollView('buttonsOffset', arg)
- } else {
- return JQXLite(this.componentSelector).jqxScrollView('buttonsOffset');
- }
- },
- _currentPage: function(arg) {
- if (arg !== undefined) {
- JQXLite(this.componentSelector).jqxScrollView('currentPage', arg)
- } else {
- return JQXLite(this.componentSelector).jqxScrollView('currentPage');
- }
- },
- _disabled: function(arg) {
- if (arg !== undefined) {
- JQXLite(this.componentSelector).jqxScrollView('disabled', arg)
- } else {
- return JQXLite(this.componentSelector).jqxScrollView('disabled');
- }
- },
- _height: function(arg) {
- if (arg !== undefined) {
- JQXLite(this.componentSelector).jqxScrollView('height', arg)
- } else {
- return JQXLite(this.componentSelector).jqxScrollView('height');
- }
- },
- _moveThreshold: function(arg) {
- if (arg !== undefined) {
- JQXLite(this.componentSelector).jqxScrollView('moveThreshold', arg)
- } else {
- return JQXLite(this.componentSelector).jqxScrollView('moveThreshold');
- }
- },
- _showButtons: function(arg) {
- if (arg !== undefined) {
- JQXLite(this.componentSelector).jqxScrollView('showButtons', arg)
- } else {
- return JQXLite(this.componentSelector).jqxScrollView('showButtons');
- }
- },
- _slideShow: function(arg) {
- if (arg !== undefined) {
- JQXLite(this.componentSelector).jqxScrollView('slideShow', arg)
- } else {
- return JQXLite(this.componentSelector).jqxScrollView('slideShow');
- }
- },
- _slideDuration: function(arg) {
- if (arg !== undefined) {
- JQXLite(this.componentSelector).jqxScrollView('slideDuration', arg)
- } else {
- return JQXLite(this.componentSelector).jqxScrollView('slideDuration');
- }
- },
- _theme: function(arg) {
- if (arg !== undefined) {
- JQXLite(this.componentSelector).jqxScrollView('theme', arg)
- } else {
- return JQXLite(this.componentSelector).jqxScrollView('theme');
- }
- },
- _width: function(arg) {
- if (arg !== undefined) {
- JQXLite(this.componentSelector).jqxScrollView('width', arg)
- } else {
- return JQXLite(this.componentSelector).jqxScrollView('width');
- }
- },
- __createComponent__: function (options) {
- let widgetOptions;
- options ? widgetOptions = options : widgetOptions = this.__manageProps__();
- JQXLite(this.componentSelector).jqxScrollView(widgetOptions);
- this.__extendProps__();
- this.__wireEvents__();
- },
- __manageProps__: function () {
- const widgetProps = ['animationDuration','bounceEnabled','buttonsOffset','currentPage','disabled','height','moveThreshold','showButtons','slideShow','slideDuration','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, 'animationDuration', {
- get: function() {
- return that._animationDuration();
- },
- set: function(newValue) {
- that._animationDuration(newValue);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(that, 'bounceEnabled', {
- get: function() {
- return that._bounceEnabled();
- },
- set: function(newValue) {
- that._bounceEnabled(newValue);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(that, 'buttonsOffset', {
- get: function() {
- return that._buttonsOffset();
- },
- set: function(newValue) {
- that._buttonsOffset(newValue);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(that, 'currentPage', {
- get: function() {
- return that._currentPage();
- },
- set: function(newValue) {
- that._currentPage(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, 'height', {
- get: function() {
- return that._height();
- },
- set: function(newValue) {
- that._height(newValue);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(that, 'moveThreshold', {
- get: function() {
- return that._moveThreshold();
- },
- set: function(newValue) {
- that._moveThreshold(newValue);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(that, 'showButtons', {
- get: function() {
- return that._showButtons();
- },
- set: function(newValue) {
- that._showButtons(newValue);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(that, 'slideShow', {
- get: function() {
- return that._slideShow();
- },
- set: function(newValue) {
- that._slideShow(newValue);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(that, 'slideDuration', {
- get: function() {
- return that._slideDuration();
- },
- set: function(newValue) {
- that._slideDuration(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
- });
- },
- __wireEvents__: function () {
- const that = this;
- JQXLite(this.componentSelector).on('pageChanged', function (event) { that.$emit('pageChanged', event); });
- }
- }
- }
- </script>
|