vue_jqxpopover.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <div v-bind:id="id">
  3. <slot></slot>
  4. </div>
  5. </template>
  6. <script>
  7. import '../jqwidgets/jqxcore.js';
  8. import '../jqwidgets/jqxpopover.js';
  9. export default {
  10. props: {
  11. arrowOffsetValue: Number,
  12. animationOpenDelay: [String, Number],
  13. animationCloseDelay: [String, Number],
  14. autoClose: Boolean,
  15. animationType: String,
  16. height: [Number, String],
  17. initContent: Function,
  18. isModal: Boolean,
  19. offset: Object,
  20. position: String,
  21. rtl: Boolean,
  22. selector: String,
  23. showArrow: Boolean,
  24. showCloseButton: Boolean,
  25. width: [Number, String],
  26. title: String,
  27. theme: String,
  28. autoCreate: {
  29. default: true,
  30. type: Boolean
  31. }
  32. },
  33. created: function () {
  34. this.id = 'jqxPopover' + JQXLite.generateID();
  35. this.componentSelector = '#' + this.id;
  36. },
  37. mounted: function () {
  38. if (this.autoCreate) this.__createComponent__();
  39. },
  40. methods: {
  41. createComponent: function (options) {
  42. if (!this.autoCreate) this.__createComponent__(options)
  43. else console.warn('Component is already created! If you want to use createComponent, please set "autoCreate" property to "false".');
  44. },
  45. setOptions: function (options) {
  46. JQXLite(this.componentSelector).jqxPopover(options);
  47. },
  48. getOptions: function () {
  49. const usedProps = Object.keys(this.__manageProps__());
  50. const resultToReturn = {};
  51. for (let i = 0; i < usedProps.length; i++) {
  52. resultToReturn[usedProps[i]] = JQXLite(this.componentSelector).jqxPopover(usedProps[i]);
  53. }
  54. return resultToReturn;
  55. },
  56. close: function() {
  57. JQXLite(this.componentSelector).jqxPopover('close');
  58. },
  59. destroy: function() {
  60. JQXLite(this.componentSelector).jqxPopover('destroy');
  61. },
  62. open: function() {
  63. JQXLite(this.componentSelector).jqxPopover('open');
  64. },
  65. _arrowOffsetValue: function(arg) {
  66. if (arg !== undefined) {
  67. JQXLite(this.componentSelector).jqxPopover('arrowOffsetValue', arg)
  68. } else {
  69. return JQXLite(this.componentSelector).jqxPopover('arrowOffsetValue');
  70. }
  71. },
  72. _animationOpenDelay: function(arg) {
  73. if (arg !== undefined) {
  74. JQXLite(this.componentSelector).jqxPopover('animationOpenDelay', arg)
  75. } else {
  76. return JQXLite(this.componentSelector).jqxPopover('animationOpenDelay');
  77. }
  78. },
  79. _animationCloseDelay: function(arg) {
  80. if (arg !== undefined) {
  81. JQXLite(this.componentSelector).jqxPopover('animationCloseDelay', arg)
  82. } else {
  83. return JQXLite(this.componentSelector).jqxPopover('animationCloseDelay');
  84. }
  85. },
  86. _autoClose: function(arg) {
  87. if (arg !== undefined) {
  88. JQXLite(this.componentSelector).jqxPopover('autoClose', arg)
  89. } else {
  90. return JQXLite(this.componentSelector).jqxPopover('autoClose');
  91. }
  92. },
  93. _animationType: function(arg) {
  94. if (arg !== undefined) {
  95. JQXLite(this.componentSelector).jqxPopover('animationType', arg)
  96. } else {
  97. return JQXLite(this.componentSelector).jqxPopover('animationType');
  98. }
  99. },
  100. _height: function(arg) {
  101. if (arg !== undefined) {
  102. JQXLite(this.componentSelector).jqxPopover('height', arg)
  103. } else {
  104. return JQXLite(this.componentSelector).jqxPopover('height');
  105. }
  106. },
  107. _initContent: function(arg) {
  108. if (arg !== undefined) {
  109. JQXLite(this.componentSelector).jqxPopover('initContent', arg)
  110. } else {
  111. return JQXLite(this.componentSelector).jqxPopover('initContent');
  112. }
  113. },
  114. _isModal: function(arg) {
  115. if (arg !== undefined) {
  116. JQXLite(this.componentSelector).jqxPopover('isModal', arg)
  117. } else {
  118. return JQXLite(this.componentSelector).jqxPopover('isModal');
  119. }
  120. },
  121. _offset: function(arg) {
  122. if (arg !== undefined) {
  123. JQXLite(this.componentSelector).jqxPopover('offset', arg)
  124. } else {
  125. return JQXLite(this.componentSelector).jqxPopover('offset');
  126. }
  127. },
  128. _position: function(arg) {
  129. if (arg !== undefined) {
  130. JQXLite(this.componentSelector).jqxPopover('position', arg)
  131. } else {
  132. return JQXLite(this.componentSelector).jqxPopover('position');
  133. }
  134. },
  135. _rtl: function(arg) {
  136. if (arg !== undefined) {
  137. JQXLite(this.componentSelector).jqxPopover('rtl', arg)
  138. } else {
  139. return JQXLite(this.componentSelector).jqxPopover('rtl');
  140. }
  141. },
  142. _selector: function(arg) {
  143. if (arg !== undefined) {
  144. JQXLite(this.componentSelector).jqxPopover('selector', arg)
  145. } else {
  146. return JQXLite(this.componentSelector).jqxPopover('selector');
  147. }
  148. },
  149. _showArrow: function(arg) {
  150. if (arg !== undefined) {
  151. JQXLite(this.componentSelector).jqxPopover('showArrow', arg)
  152. } else {
  153. return JQXLite(this.componentSelector).jqxPopover('showArrow');
  154. }
  155. },
  156. _showCloseButton: function(arg) {
  157. if (arg !== undefined) {
  158. JQXLite(this.componentSelector).jqxPopover('showCloseButton', arg)
  159. } else {
  160. return JQXLite(this.componentSelector).jqxPopover('showCloseButton');
  161. }
  162. },
  163. _width: function(arg) {
  164. if (arg !== undefined) {
  165. JQXLite(this.componentSelector).jqxPopover('width', arg)
  166. } else {
  167. return JQXLite(this.componentSelector).jqxPopover('width');
  168. }
  169. },
  170. _title: function(arg) {
  171. if (arg !== undefined) {
  172. JQXLite(this.componentSelector).jqxPopover('title', arg)
  173. } else {
  174. return JQXLite(this.componentSelector).jqxPopover('title');
  175. }
  176. },
  177. _theme: function(arg) {
  178. if (arg !== undefined) {
  179. JQXLite(this.componentSelector).jqxPopover('theme', arg)
  180. } else {
  181. return JQXLite(this.componentSelector).jqxPopover('theme');
  182. }
  183. },
  184. __createComponent__: function (options) {
  185. let widgetOptions;
  186. options ? widgetOptions = options : widgetOptions = this.__manageProps__();
  187. JQXLite(this.componentSelector).jqxPopover(widgetOptions);
  188. this.__extendProps__();
  189. this.__wireEvents__();
  190. },
  191. __manageProps__: function () {
  192. const widgetProps = ['arrowOffsetValue','animationOpenDelay','animationCloseDelay','autoClose','animationType','height','initContent','isModal','offset','position','rtl','selector','showArrow','showCloseButton','width','title','theme'];
  193. const componentProps = this.$options.propsData;
  194. let options = {};
  195. for (let prop in componentProps) {
  196. if (widgetProps.indexOf(prop) !== -1) {
  197. options[prop] = componentProps[prop];
  198. }
  199. }
  200. return options;
  201. },
  202. __extendProps__: function () {
  203. const that = this;
  204. Object.defineProperty(that, 'arrowOffsetValue', {
  205. get: function() {
  206. return that._arrowOffsetValue();
  207. },
  208. set: function(newValue) {
  209. that._arrowOffsetValue(newValue);
  210. },
  211. enumerable: true,
  212. configurable: true
  213. });
  214. Object.defineProperty(that, 'animationOpenDelay', {
  215. get: function() {
  216. return that._animationOpenDelay();
  217. },
  218. set: function(newValue) {
  219. that._animationOpenDelay(newValue);
  220. },
  221. enumerable: true,
  222. configurable: true
  223. });
  224. Object.defineProperty(that, 'animationCloseDelay', {
  225. get: function() {
  226. return that._animationCloseDelay();
  227. },
  228. set: function(newValue) {
  229. that._animationCloseDelay(newValue);
  230. },
  231. enumerable: true,
  232. configurable: true
  233. });
  234. Object.defineProperty(that, 'autoClose', {
  235. get: function() {
  236. return that._autoClose();
  237. },
  238. set: function(newValue) {
  239. that._autoClose(newValue);
  240. },
  241. enumerable: true,
  242. configurable: true
  243. });
  244. Object.defineProperty(that, 'animationType', {
  245. get: function() {
  246. return that._animationType();
  247. },
  248. set: function(newValue) {
  249. that._animationType(newValue);
  250. },
  251. enumerable: true,
  252. configurable: true
  253. });
  254. Object.defineProperty(that, 'height', {
  255. get: function() {
  256. return that._height();
  257. },
  258. set: function(newValue) {
  259. that._height(newValue);
  260. },
  261. enumerable: true,
  262. configurable: true
  263. });
  264. Object.defineProperty(that, 'initContent', {
  265. get: function() {
  266. return that._initContent();
  267. },
  268. set: function(newValue) {
  269. that._initContent(newValue);
  270. },
  271. enumerable: true,
  272. configurable: true
  273. });
  274. Object.defineProperty(that, 'isModal', {
  275. get: function() {
  276. return that._isModal();
  277. },
  278. set: function(newValue) {
  279. that._isModal(newValue);
  280. },
  281. enumerable: true,
  282. configurable: true
  283. });
  284. Object.defineProperty(that, 'offset', {
  285. get: function() {
  286. return that._offset();
  287. },
  288. set: function(newValue) {
  289. that._offset(newValue);
  290. },
  291. enumerable: true,
  292. configurable: true
  293. });
  294. Object.defineProperty(that, 'position', {
  295. get: function() {
  296. return that._position();
  297. },
  298. set: function(newValue) {
  299. that._position(newValue);
  300. },
  301. enumerable: true,
  302. configurable: true
  303. });
  304. Object.defineProperty(that, 'rtl', {
  305. get: function() {
  306. return that._rtl();
  307. },
  308. set: function(newValue) {
  309. that._rtl(newValue);
  310. },
  311. enumerable: true,
  312. configurable: true
  313. });
  314. Object.defineProperty(that, 'selector', {
  315. get: function() {
  316. return that._selector();
  317. },
  318. set: function(newValue) {
  319. that._selector(newValue);
  320. },
  321. enumerable: true,
  322. configurable: true
  323. });
  324. Object.defineProperty(that, 'showArrow', {
  325. get: function() {
  326. return that._showArrow();
  327. },
  328. set: function(newValue) {
  329. that._showArrow(newValue);
  330. },
  331. enumerable: true,
  332. configurable: true
  333. });
  334. Object.defineProperty(that, 'showCloseButton', {
  335. get: function() {
  336. return that._showCloseButton();
  337. },
  338. set: function(newValue) {
  339. that._showCloseButton(newValue);
  340. },
  341. enumerable: true,
  342. configurable: true
  343. });
  344. Object.defineProperty(that, 'width', {
  345. get: function() {
  346. return that._width();
  347. },
  348. set: function(newValue) {
  349. that._width(newValue);
  350. },
  351. enumerable: true,
  352. configurable: true
  353. });
  354. Object.defineProperty(that, 'title', {
  355. get: function() {
  356. return that._title();
  357. },
  358. set: function(newValue) {
  359. that._title(newValue);
  360. },
  361. enumerable: true,
  362. configurable: true
  363. });
  364. Object.defineProperty(that, 'theme', {
  365. get: function() {
  366. return that._theme();
  367. },
  368. set: function(newValue) {
  369. that._theme(newValue);
  370. },
  371. enumerable: true,
  372. configurable: true
  373. });
  374. },
  375. __wireEvents__: function () {
  376. const that = this;
  377. JQXLite(this.componentSelector).on('close', function (event) { that.$emit('close', event); });
  378. JQXLite(this.componentSelector).on('open', function (event) { that.$emit('open', event); });
  379. }
  380. }
  381. }
  382. </script>