vue_jqxdockinglayout.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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/jqxbuttons.js';
  9. import '../jqwidgets/jqxwindow.js';
  10. import '../jqwidgets/jqxribbon.js';
  11. import '../jqwidgets/jqxlayout.js';
  12. import '../jqwidgets/jqxmenu.js';
  13. import '../jqwidgets/jqxscrollbar.js';
  14. import '../jqwidgets/jqxdockinglayout.js';
  15. export default {
  16. props: {
  17. contextMenu: Boolean,
  18. height: [Number, String],
  19. layout: Array,
  20. minGroupHeight: Number,
  21. minGroupWidth: Number,
  22. resizable: Boolean,
  23. rtl: Boolean,
  24. theme: String,
  25. width: [Number, String],
  26. autoCreate: {
  27. default: true,
  28. type: Boolean
  29. }
  30. },
  31. created: function () {
  32. this.id = 'jqxDockingLayout' + JQXLite.generateID();
  33. this.componentSelector = '#' + this.id;
  34. },
  35. mounted: function () {
  36. if (this.autoCreate) this.__createComponent__();
  37. },
  38. methods: {
  39. createComponent: function (options) {
  40. if (!this.autoCreate) this.__createComponent__(options)
  41. else console.warn('Component is already created! If you want to use createComponent, please set "autoCreate" property to "false".');
  42. },
  43. setOptions: function (options) {
  44. JQXLite(this.componentSelector).jqxDockingLayout(options);
  45. },
  46. getOptions: function () {
  47. const usedProps = Object.keys(this.__manageProps__());
  48. const resultToReturn = {};
  49. for (let i = 0; i < usedProps.length; i++) {
  50. resultToReturn[usedProps[i]] = JQXLite(this.componentSelector).jqxDockingLayout(usedProps[i]);
  51. }
  52. return resultToReturn;
  53. },
  54. addFloatGroup: function(width, height, position, panelType, title, content, initContent) {
  55. JQXLite(this.componentSelector).jqxDockingLayout('addFloatGroup', width, height, position, panelType, title, content, initContent);
  56. },
  57. destroy: function() {
  58. JQXLite(this.componentSelector).jqxDockingLayout('destroy');
  59. },
  60. loadLayout: function(layout) {
  61. JQXLite(this.componentSelector).jqxDockingLayout('loadLayout', layout);
  62. },
  63. refresh: function() {
  64. JQXLite(this.componentSelector).jqxDockingLayout('refresh');
  65. },
  66. render: function() {
  67. JQXLite(this.componentSelector).jqxDockingLayout('render');
  68. },
  69. saveLayout: function() {
  70. return JQXLite(this.componentSelector).jqxDockingLayout('saveLayout');
  71. },
  72. _contextMenu: function(arg) {
  73. if (arg !== undefined) {
  74. JQXLite(this.componentSelector).jqxDockingLayout('contextMenu', arg)
  75. } else {
  76. return JQXLite(this.componentSelector).jqxDockingLayout('contextMenu');
  77. }
  78. },
  79. _height: function(arg) {
  80. if (arg !== undefined) {
  81. JQXLite(this.componentSelector).jqxDockingLayout('height', arg)
  82. } else {
  83. return JQXLite(this.componentSelector).jqxDockingLayout('height');
  84. }
  85. },
  86. _layout: function(arg) {
  87. if (arg !== undefined) {
  88. JQXLite(this.componentSelector).jqxDockingLayout('layout', arg)
  89. } else {
  90. return JQXLite(this.componentSelector).jqxDockingLayout('layout');
  91. }
  92. },
  93. _minGroupHeight: function(arg) {
  94. if (arg !== undefined) {
  95. JQXLite(this.componentSelector).jqxDockingLayout('minGroupHeight', arg)
  96. } else {
  97. return JQXLite(this.componentSelector).jqxDockingLayout('minGroupHeight');
  98. }
  99. },
  100. _minGroupWidth: function(arg) {
  101. if (arg !== undefined) {
  102. JQXLite(this.componentSelector).jqxDockingLayout('minGroupWidth', arg)
  103. } else {
  104. return JQXLite(this.componentSelector).jqxDockingLayout('minGroupWidth');
  105. }
  106. },
  107. _resizable: function(arg) {
  108. if (arg !== undefined) {
  109. JQXLite(this.componentSelector).jqxDockingLayout('resizable', arg)
  110. } else {
  111. return JQXLite(this.componentSelector).jqxDockingLayout('resizable');
  112. }
  113. },
  114. _rtl: function(arg) {
  115. if (arg !== undefined) {
  116. JQXLite(this.componentSelector).jqxDockingLayout('rtl', arg)
  117. } else {
  118. return JQXLite(this.componentSelector).jqxDockingLayout('rtl');
  119. }
  120. },
  121. _theme: function(arg) {
  122. if (arg !== undefined) {
  123. JQXLite(this.componentSelector).jqxDockingLayout('theme', arg)
  124. } else {
  125. return JQXLite(this.componentSelector).jqxDockingLayout('theme');
  126. }
  127. },
  128. _width: function(arg) {
  129. if (arg !== undefined) {
  130. JQXLite(this.componentSelector).jqxDockingLayout('width', arg)
  131. } else {
  132. return JQXLite(this.componentSelector).jqxDockingLayout('width');
  133. }
  134. },
  135. __createComponent__: function (options) {
  136. let widgetOptions;
  137. options ? widgetOptions = options : widgetOptions = this.__manageProps__();
  138. JQXLite(this.componentSelector).jqxDockingLayout(widgetOptions);
  139. this.__extendProps__();
  140. this.__wireEvents__();
  141. },
  142. __manageProps__: function () {
  143. const widgetProps = ['contextMenu','height','layout','minGroupHeight','minGroupWidth','resizable','rtl','theme','width'];
  144. const componentProps = this.$options.propsData;
  145. let options = {};
  146. for (let prop in componentProps) {
  147. if (widgetProps.indexOf(prop) !== -1) {
  148. options[prop] = componentProps[prop];
  149. }
  150. }
  151. return options;
  152. },
  153. __extendProps__: function () {
  154. const that = this;
  155. Object.defineProperty(that, 'contextMenu', {
  156. get: function() {
  157. return that._contextMenu();
  158. },
  159. set: function(newValue) {
  160. that._contextMenu(newValue);
  161. },
  162. enumerable: true,
  163. configurable: true
  164. });
  165. Object.defineProperty(that, 'height', {
  166. get: function() {
  167. return that._height();
  168. },
  169. set: function(newValue) {
  170. that._height(newValue);
  171. },
  172. enumerable: true,
  173. configurable: true
  174. });
  175. Object.defineProperty(that, 'layout', {
  176. get: function() {
  177. return that._layout();
  178. },
  179. set: function(newValue) {
  180. that._layout(newValue);
  181. },
  182. enumerable: true,
  183. configurable: true
  184. });
  185. Object.defineProperty(that, 'minGroupHeight', {
  186. get: function() {
  187. return that._minGroupHeight();
  188. },
  189. set: function(newValue) {
  190. that._minGroupHeight(newValue);
  191. },
  192. enumerable: true,
  193. configurable: true
  194. });
  195. Object.defineProperty(that, 'minGroupWidth', {
  196. get: function() {
  197. return that._minGroupWidth();
  198. },
  199. set: function(newValue) {
  200. that._minGroupWidth(newValue);
  201. },
  202. enumerable: true,
  203. configurable: true
  204. });
  205. Object.defineProperty(that, 'resizable', {
  206. get: function() {
  207. return that._resizable();
  208. },
  209. set: function(newValue) {
  210. that._resizable(newValue);
  211. },
  212. enumerable: true,
  213. configurable: true
  214. });
  215. Object.defineProperty(that, 'rtl', {
  216. get: function() {
  217. return that._rtl();
  218. },
  219. set: function(newValue) {
  220. that._rtl(newValue);
  221. },
  222. enumerable: true,
  223. configurable: true
  224. });
  225. Object.defineProperty(that, 'theme', {
  226. get: function() {
  227. return that._theme();
  228. },
  229. set: function(newValue) {
  230. that._theme(newValue);
  231. },
  232. enumerable: true,
  233. configurable: true
  234. });
  235. Object.defineProperty(that, 'width', {
  236. get: function() {
  237. return that._width();
  238. },
  239. set: function(newValue) {
  240. that._width(newValue);
  241. },
  242. enumerable: true,
  243. configurable: true
  244. });
  245. },
  246. __wireEvents__: function () {
  247. const that = this;
  248. JQXLite(this.componentSelector).on('dock', function (event) { that.$emit('dock', event); });
  249. JQXLite(this.componentSelector).on('floatGroupClosed', function (event) { that.$emit('floatGroupClosed', event); });
  250. JQXLite(this.componentSelector).on('float', function (event) { that.$emit('float', event); });
  251. JQXLite(this.componentSelector).on('pin', function (event) { that.$emit('pin', event); });
  252. JQXLite(this.componentSelector).on('resize', function (event) { that.$emit('resize', event); });
  253. JQXLite(this.componentSelector).on('unpin', function (event) { that.$emit('unpin', event); });
  254. }
  255. }
  256. }
  257. </script>