toolbar.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. var items = [
  2. 'source', '|', 'fullscreen', 'undo', 'redo', 'print', 'cut', 'copy', 'paste',
  3. 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
  4. 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
  5. 'superscript', '|', 'selectall', '/',
  6. 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
  7. 'italic', 'underline', 'strikethrough', 'removeformat', '|', 'image',
  8. 'flash', 'media', 'table', 'hr', 'emoticons', 'link', 'unlink', '|', 'about'
  9. ];
  10. var list = [];
  11. K.each(items, function(i, name) {
  12. if (name == '|') {
  13. list.push('<span class="ke-inline-block ke-separator"></span>');
  14. } else if (name == '/') {
  15. list.push('<br />');
  16. } else {
  17. list.push('<span class="ke-inline-block ke-outline" unselectable="on" data-name="' + name + '" title="' + name + '">');
  18. list.push('<span class="ke-inline-block ke-toolbar-icon ke-toolbar-icon-url ke-icon-' + name + '" unselectable="on"></span></span>');
  19. }
  20. });
  21. var toolbar = K.toolbar({
  22. src : 'div#toolbar',
  23. width : '100%',
  24. html : list.join(''),
  25. click : function(e, name) {
  26. alert(name);
  27. }
  28. });
  29. K('#enable').bind('click', function(e) {
  30. if (toolbar) {
  31. toolbar.disableAll(false);
  32. }
  33. });
  34. K('#disable').bind('click', function(e) {
  35. if (toolbar) {
  36. toolbar.disableAll(true);
  37. }
  38. });
  39. K('#toggle').bind('click', function(e) {
  40. if (toolbar) {
  41. toolbar.disableAll();
  42. }
  43. });
  44. K('#select').bind('click', function(e) {
  45. if (toolbar) {
  46. toolbar.select('bold');
  47. }
  48. });
  49. K('#unselect').bind('click', function(e) {
  50. if (toolbar) {
  51. toolbar.unselect('bold');
  52. }
  53. });