toolbar.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. (function (){
  2. var utils = baidu.editor.utils,
  3. uiUtils = baidu.editor.ui.uiUtils,
  4. UIBase = baidu.editor.ui.UIBase,
  5. Toolbar = baidu.editor.ui.Toolbar = function (options){
  6. this.initOptions(options);
  7. this.initToolbar();
  8. };
  9. Toolbar.prototype = {
  10. items: null,
  11. initToolbar: function (){
  12. this.items = this.items || [];
  13. this.initUIBase();
  14. },
  15. add: function (item){
  16. this.items.push(item);
  17. },
  18. getHtmlTpl: function (){
  19. var buff = [];
  20. for (var i=0; i<this.items.length; i++) {
  21. buff[i] = this.items[i].renderHtml();
  22. }
  23. return '<div id="##" class="edui-toolbar %%" onselectstart="return false;" onmousedown="return $$._onMouseDown(event, this);">' +
  24. buff.join('') +
  25. '</div>'
  26. },
  27. postRender: function (){
  28. var box = this.getDom();
  29. for (var i=0; i<this.items.length; i++) {
  30. this.items[i].postRender();
  31. }
  32. uiUtils.makeUnselectable(box);
  33. },
  34. _onMouseDown: function (){
  35. return false;
  36. }
  37. };
  38. utils.inherits(Toolbar, UIBase);
  39. })();