not really known
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.5 KiB

  1. define(["sugar-web/graphics/palette"], function (palette) {
  2. 'use strict';
  3. var textpalette = {};
  4. textpalette.TextPalette = function (textButton, toonModel, title) {
  5. palette.Palette.call(this, textButton);
  6. this.getPalette().id = "text-palette";
  7. var containerElem = document.createElement('div');
  8. var content = '<div class="row small">' +
  9. '<label>' + title + '</label>' +
  10. '</div>' +
  11. '<div class="row expand">' +
  12. '<textarea rows="8" id="editor" class="expand"></textarea>' +
  13. '</div>';
  14. var styleToolbar = '<div class="toolbar" id="text-style-toolbar">' +
  15. '<button class="toolbutton" id="text-inc-size"></button>' +
  16. '<button class="toolbutton" id="text-dec-size"></button>' +
  17. '<button class="toolbutton" id="text-set-bold"></button>' +
  18. '<button class="toolbutton" id="text-set-italic"></button>'+
  19. '</div>';
  20. content = content + styleToolbar;
  21. var colors = ['#000000', '#ff0000', '#00008b', '#006400', '#8b008b',
  22. '#c0c0c0', '#ffd700', '#008000', '#ff4500', '#8b4513' ];
  23. content = content + '<table><tr>';
  24. for (var i = 0; i < colors.length; i++) {
  25. content = content + '<td><button class="color-picker" ' +
  26. 'value="' + colors[i] + '" ' +
  27. 'style="background-color: ' + colors[i] + '"></button></td>';
  28. if (i == 4) {
  29. content = content + '</tr><tr>';
  30. };
  31. };
  32. content = content + '</tr></table>';
  33. containerElem.innerHTML = content;
  34. this.setContent([containerElem]);
  35. this.editorElem = containerElem.querySelector('#editor');
  36. this.colorButtons = document.querySelectorAll(".color-picker");
  37. this.incTextBtn = containerElem.querySelector('#text-inc-size');
  38. this.decTextBtn = containerElem.querySelector('#text-dec-size');
  39. this.boldTextBtn = containerElem.querySelector('#text-set-bold');
  40. this.italicTextBtn = containerElem.querySelector('#text-set-italic');
  41. };
  42. var setText = function (text) {
  43. this.editorElem.value = text;
  44. };
  45. textpalette.TextPalette.prototype =
  46. Object.create(palette.Palette.prototype, {
  47. setText: {
  48. value: setText,
  49. enumerable: true,
  50. configurable: true,
  51. writable: true
  52. }
  53. });
  54. return textpalette;
  55. });