tablebutton.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ///import core
  2. ///import uicore
  3. ///import ui/popup.js
  4. ///import ui/tablepicker.js
  5. ///import ui/splitbutton.js
  6. (function (){
  7. var utils = baidu.editor.utils,
  8. Popup = baidu.editor.ui.Popup,
  9. TablePicker = baidu.editor.ui.TablePicker,
  10. SplitButton = baidu.editor.ui.SplitButton,
  11. TableButton = baidu.editor.ui.TableButton = function (options){
  12. this.initOptions(options);
  13. this.initTableButton();
  14. };
  15. TableButton.prototype = {
  16. initTableButton: function (){
  17. var me = this;
  18. this.popup = new Popup({
  19. content: new TablePicker({
  20. onpicktable: function (t, numCols, numRows){
  21. me._onPickTable(numCols, numRows);
  22. },
  23. onmore: function (){
  24. me.popup.hide();
  25. me.fireEvent('more');
  26. }
  27. }),
  28. 'editor':me.editor
  29. });
  30. this.initSplitButton();
  31. },
  32. _onPickTable: function (numCols, numRows){
  33. if (this.fireEvent('picktable', numCols, numRows) !== false) {
  34. this.popup.hide();
  35. }
  36. }
  37. };
  38. utils.inherits(TableButton, SplitButton);
  39. })();