tablebutton.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. editor:me.editor,
  21. onpicktable: function (t, numCols, numRows){
  22. me._onPickTable(numCols, numRows);
  23. }
  24. }),
  25. 'editor':me.editor
  26. });
  27. this.initSplitButton();
  28. },
  29. _onPickTable: function (numCols, numRows){
  30. if (this.fireEvent('picktable', numCols, numRows) !== false) {
  31. this.popup.hide();
  32. }
  33. }
  34. };
  35. utils.inherits(TableButton, SplitButton);
  36. })();