PageRenderTime 136ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 1ms

/static/scripts/tiny_mce/plugins/style/js/props.js

http://n23.googlecode.com/
JavaScript | 641 lines | 491 code | 135 blank | 15 comment | 72 complexity | 704cc52cc4973f3a6ae667b634aca2b9 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-2.1
  1. tinyMCEPopup.requireLangPack();
  2. var defaultFonts = "" +
  3. "Arial, Helvetica, sans-serif=Arial, Helvetica, sans-serif;" +
  4. "Times New Roman, Times, serif=Times New Roman, Times, serif;" +
  5. "Courier New, Courier, mono=Courier New, Courier, mono;" +
  6. "Times New Roman, Times, serif=Times New Roman, Times, serif;" +
  7. "Georgia, Times New Roman, Times, serif=Georgia, Times New Roman, Times, serif;" +
  8. "Verdana, Arial, Helvetica, sans-serif=Verdana, Arial, Helvetica, sans-serif;" +
  9. "Geneva, Arial, Helvetica, sans-serif=Geneva, Arial, Helvetica, sans-serif";
  10. var defaultSizes = "9;10;12;14;16;18;24;xx-small;x-small;small;medium;large;x-large;xx-large;smaller;larger";
  11. var defaultMeasurement = "+pixels=px;points=pt;em;in;cm;mm;picas;ems;exs;%";
  12. var defaultSpacingMeasurement = "pixels=px;points=pt;in;cm;mm;picas;+ems;exs;%";
  13. var defaultIndentMeasurement = "pixels=px;+points=pt;in;cm;mm;picas;ems;exs;%";
  14. var defaultWeight = "normal;bold;bolder;lighter;100;200;300;400;500;600;700;800;900";
  15. var defaultTextStyle = "normal;italic;oblique";
  16. var defaultVariant = "normal;small-caps";
  17. var defaultLineHeight = "normal";
  18. var defaultAttachment = "fixed;scroll";
  19. var defaultRepeat = "no-repeat;repeat;repeat-x;repeat-y";
  20. var defaultPosH = "left;center;right";
  21. var defaultPosV = "top;center;bottom";
  22. var defaultVAlign = "baseline;sub;super;top;text-top;middle;bottom;text-bottom";
  23. var defaultDisplay = "inline;block;list-item;run-in;compact;marker;table;inline-table;table-row-group;table-header-group;table-footer-group;table-row;table-column-group;table-column;table-cell;table-caption;none";
  24. var defaultBorderStyle = "none;solid;dashed;dotted;double;groove;ridge;inset;outset";
  25. var defaultBorderWidth = "thin;medium;thick";
  26. var defaultListType = "disc;circle;square;decimal;lower-roman;upper-roman;lower-alpha;upper-alpha;none";
  27. function init() {
  28. var ce = document.getElementById('container'), h;
  29. ce.style.cssText = tinyMCEPopup.getWindowArg('style_text');
  30. h = getBrowserHTML('background_image_browser','background_image','image','advimage');
  31. document.getElementById("background_image_browser").innerHTML = h;
  32. document.getElementById('text_color_pickcontainer').innerHTML = getColorPickerHTML('text_color_pick','text_color');
  33. document.getElementById('background_color_pickcontainer').innerHTML = getColorPickerHTML('background_color_pick','background_color');
  34. document.getElementById('border_color_top_pickcontainer').innerHTML = getColorPickerHTML('border_color_top_pick','border_color_top');
  35. document.getElementById('border_color_right_pickcontainer').innerHTML = getColorPickerHTML('border_color_right_pick','border_color_right');
  36. document.getElementById('border_color_bottom_pickcontainer').innerHTML = getColorPickerHTML('border_color_bottom_pick','border_color_bottom');
  37. document.getElementById('border_color_left_pickcontainer').innerHTML = getColorPickerHTML('border_color_left_pick','border_color_left');
  38. fillSelect(0, 'text_font', 'style_font', defaultFonts, ';', true);
  39. fillSelect(0, 'text_size', 'style_font_size', defaultSizes, ';', true);
  40. fillSelect(0, 'text_size_measurement', 'style_font_size_measurement', defaultMeasurement, ';', true);
  41. fillSelect(0, 'text_case', 'style_text_case', "capitalize;uppercase;lowercase", ';', true);
  42. fillSelect(0, 'text_weight', 'style_font_weight', defaultWeight, ';', true);
  43. fillSelect(0, 'text_style', 'style_font_style', defaultTextStyle, ';', true);
  44. fillSelect(0, 'text_variant', 'style_font_variant', defaultVariant, ';', true);
  45. fillSelect(0, 'text_lineheight', 'style_font_line_height', defaultLineHeight, ';', true);
  46. fillSelect(0, 'text_lineheight_measurement', 'style_font_line_height_measurement', defaultMeasurement, ';', true);
  47. fillSelect(0, 'background_attachment', 'style_background_attachment', defaultAttachment, ';', true);
  48. fillSelect(0, 'background_repeat', 'style_background_repeat', defaultRepeat, ';', true);
  49. fillSelect(0, 'background_hpos_measurement', 'style_background_hpos_measurement', defaultMeasurement, ';', true);
  50. fillSelect(0, 'background_vpos_measurement', 'style_background_vpos_measurement', defaultMeasurement, ';', true);
  51. fillSelect(0, 'background_hpos', 'style_background_hpos', defaultPosH, ';', true);
  52. fillSelect(0, 'background_vpos', 'style_background_vpos', defaultPosV, ';', true);
  53. fillSelect(0, 'block_wordspacing', 'style_wordspacing', 'normal', ';', true);
  54. fillSelect(0, 'block_wordspacing_measurement', 'style_wordspacing_measurement', defaultSpacingMeasurement, ';', true);
  55. fillSelect(0, 'block_letterspacing', 'style_letterspacing', 'normal', ';', true);
  56. fillSelect(0, 'block_letterspacing_measurement', 'style_letterspacing_measurement', defaultSpacingMeasurement, ';', true);
  57. fillSelect(0, 'block_vertical_alignment', 'style_vertical_alignment', defaultVAlign, ';', true);
  58. fillSelect(0, 'block_text_align', 'style_text_align', "left;right;center;justify", ';', true);
  59. fillSelect(0, 'block_whitespace', 'style_whitespace', "normal;pre;nowrap", ';', true);
  60. fillSelect(0, 'block_display', 'style_display', defaultDisplay, ';', true);
  61. fillSelect(0, 'block_text_indent_measurement', 'style_text_indent_measurement', defaultIndentMeasurement, ';', true);
  62. fillSelect(0, 'box_width_measurement', 'style_box_width_measurement', defaultMeasurement, ';', true);
  63. fillSelect(0, 'box_height_measurement', 'style_box_height_measurement', defaultMeasurement, ';', true);
  64. fillSelect(0, 'box_float', 'style_float', 'left;right;none', ';', true);
  65. fillSelect(0, 'box_clear', 'style_clear', 'left;right;both;none', ';', true);
  66. fillSelect(0, 'box_padding_left_measurement', 'style_padding_left_measurement', defaultMeasurement, ';', true);
  67. fillSelect(0, 'box_padding_top_measurement', 'style_padding_top_measurement', defaultMeasurement, ';', true);
  68. fillSelect(0, 'box_padding_bottom_measurement', 'style_padding_bottom_measurement', defaultMeasurement, ';', true);
  69. fillSelect(0, 'box_padding_right_measurement', 'style_padding_right_measurement', defaultMeasurement, ';', true);
  70. fillSelect(0, 'box_margin_left_measurement', 'style_margin_left_measurement', defaultMeasurement, ';', true);
  71. fillSelect(0, 'box_margin_top_measurement', 'style_margin_top_measurement', defaultMeasurement, ';', true);
  72. fillSelect(0, 'box_margin_bottom_measurement', 'style_margin_bottom_measurement', defaultMeasurement, ';', true);
  73. fillSelect(0, 'box_margin_right_measurement', 'style_margin_right_measurement', defaultMeasurement, ';', true);
  74. fillSelect(0, 'border_style_top', 'style_border_style_top', defaultBorderStyle, ';', true);
  75. fillSelect(0, 'border_style_right', 'style_border_style_right', defaultBorderStyle, ';', true);
  76. fillSelect(0, 'border_style_bottom', 'style_border_style_bottom', defaultBorderStyle, ';', true);
  77. fillSelect(0, 'border_style_left', 'style_border_style_left', defaultBorderStyle, ';', true);
  78. fillSelect(0, 'border_width_top', 'style_border_width_top', defaultBorderWidth, ';', true);
  79. fillSelect(0, 'border_width_right', 'style_border_width_right', defaultBorderWidth, ';', true);
  80. fillSelect(0, 'border_width_bottom', 'style_border_width_bottom', defaultBorderWidth, ';', true);
  81. fillSelect(0, 'border_width_left', 'style_border_width_left', defaultBorderWidth, ';', true);
  82. fillSelect(0, 'border_width_top_measurement', 'style_border_width_top_measurement', defaultMeasurement, ';', true);
  83. fillSelect(0, 'border_width_right_measurement', 'style_border_width_right_measurement', defaultMeasurement, ';', true);
  84. fillSelect(0, 'border_width_bottom_measurement', 'style_border_width_bottom_measurement', defaultMeasurement, ';', true);
  85. fillSelect(0, 'border_width_left_measurement', 'style_border_width_left_measurement', defaultMeasurement, ';', true);
  86. fillSelect(0, 'list_type', 'style_list_type', defaultListType, ';', true);
  87. fillSelect(0, 'list_position', 'style_list_position', "inside;outside", ';', true);
  88. fillSelect(0, 'positioning_type', 'style_positioning_type', "absolute;relative;static", ';', true);
  89. fillSelect(0, 'positioning_visibility', 'style_positioning_visibility', "inherit;visible;hidden", ';', true);
  90. fillSelect(0, 'positioning_width_measurement', 'style_positioning_width_measurement', defaultMeasurement, ';', true);
  91. fillSelect(0, 'positioning_height_measurement', 'style_positioning_height_measurement', defaultMeasurement, ';', true);
  92. fillSelect(0, 'positioning_overflow', 'style_positioning_overflow', "visible;hidden;scroll;auto", ';', true);
  93. fillSelect(0, 'positioning_placement_top_measurement', 'style_positioning_placement_top_measurement', defaultMeasurement, ';', true);
  94. fillSelect(0, 'positioning_placement_right_measurement', 'style_positioning_placement_right_measurement', defaultMeasurement, ';', true);
  95. fillSelect(0, 'positioning_placement_bottom_measurement', 'style_positioning_placement_bottom_measurement', defaultMeasurement, ';', true);
  96. fillSelect(0, 'positioning_placement_left_measurement', 'style_positioning_placement_left_measurement', defaultMeasurement, ';', true);
  97. fillSelect(0, 'positioning_clip_top_measurement', 'style_positioning_clip_top_measurement', defaultMeasurement, ';', true);
  98. fillSelect(0, 'positioning_clip_right_measurement', 'style_positioning_clip_right_measurement', defaultMeasurement, ';', true);
  99. fillSelect(0, 'positioning_clip_bottom_measurement', 'style_positioning_clip_bottom_measurement', defaultMeasurement, ';', true);
  100. fillSelect(0, 'positioning_clip_left_measurement', 'style_positioning_clip_left_measurement', defaultMeasurement, ';', true);
  101. TinyMCE_EditableSelects.init();
  102. setupFormData();
  103. showDisabledControls();
  104. }
  105. function setupFormData() {
  106. var ce = document.getElementById('container'), f = document.forms[0], s, b, i;
  107. // Setup text fields
  108. selectByValue(f, 'text_font', ce.style.fontFamily, true, true);
  109. selectByValue(f, 'text_size', getNum(ce.style.fontSize), true, true);
  110. selectByValue(f, 'text_size_measurement', getMeasurement(ce.style.fontSize));
  111. selectByValue(f, 'text_weight', ce.style.fontWeight, true, true);
  112. selectByValue(f, 'text_style', ce.style.fontStyle, true, true);
  113. selectByValue(f, 'text_lineheight', getNum(ce.style.lineHeight), true, true);
  114. selectByValue(f, 'text_lineheight_measurement', getMeasurement(ce.style.lineHeight));
  115. selectByValue(f, 'text_case', ce.style.textTransform, true, true);
  116. selectByValue(f, 'text_variant', ce.style.fontVariant, true, true);
  117. f.text_color.value = tinyMCEPopup.editor.dom.toHex(ce.style.color);
  118. updateColor('text_color_pick', 'text_color');
  119. f.text_underline.checked = inStr(ce.style.textDecoration, 'underline');
  120. f.text_overline.checked = inStr(ce.style.textDecoration, 'overline');
  121. f.text_linethrough.checked = inStr(ce.style.textDecoration, 'line-through');
  122. f.text_blink.checked = inStr(ce.style.textDecoration, 'blink');
  123. // Setup background fields
  124. f.background_color.value = tinyMCEPopup.editor.dom.toHex(ce.style.backgroundColor);
  125. updateColor('background_color_pick', 'background_color');
  126. f.background_image.value = ce.style.backgroundImage.replace(new RegExp("url\\('?([^']*)'?\\)", 'gi'), "$1");
  127. selectByValue(f, 'background_repeat', ce.style.backgroundRepeat, true, true);
  128. selectByValue(f, 'background_attachment', ce.style.backgroundAttachment, true, true);
  129. selectByValue(f, 'background_hpos', getNum(getVal(ce.style.backgroundPosition, 0)), true, true);
  130. selectByValue(f, 'background_hpos_measurement', getMeasurement(getVal(ce.style.backgroundPosition, 0)));
  131. selectByValue(f, 'background_vpos', getNum(getVal(ce.style.backgroundPosition, 1)), true, true);
  132. selectByValue(f, 'background_vpos_measurement', getMeasurement(getVal(ce.style.backgroundPosition, 1)));
  133. // Setup block fields
  134. selectByValue(f, 'block_wordspacing', getNum(ce.style.wordSpacing), true, true);
  135. selectByValue(f, 'block_wordspacing_measurement', getMeasurement(ce.style.wordSpacing));
  136. selectByValue(f, 'block_letterspacing', getNum(ce.style.letterSpacing), true, true);
  137. selectByValue(f, 'block_letterspacing_measurement', getMeasurement(ce.style.letterSpacing));
  138. selectByValue(f, 'block_vertical_alignment', ce.style.verticalAlign, true, true);
  139. selectByValue(f, 'block_text_align', ce.style.textAlign, true, true);
  140. f.block_text_indent.value = getNum(ce.style.textIndent);
  141. selectByValue(f, 'block_text_indent_measurement', getMeasurement(ce.style.textIndent));
  142. selectByValue(f, 'block_whitespace', ce.style.whiteSpace, true, true);
  143. selectByValue(f, 'block_display', ce.style.display, true, true);
  144. // Setup box fields
  145. f.box_width.value = getNum(ce.style.width);
  146. selectByValue(f, 'box_width_measurement', getMeasurement(ce.style.width));
  147. f.box_height.value = getNum(ce.style.height);
  148. selectByValue(f, 'box_height_measurement', getMeasurement(ce.style.height));
  149. if (tinymce.isGecko)
  150. selectByValue(f, 'box_float', ce.style.cssFloat, true, true);
  151. else
  152. selectByValue(f, 'box_float', ce.style.styleFloat, true, true);
  153. selectByValue(f, 'box_clear', ce.style.clear, true, true);
  154. setupBox(f, ce, 'box_padding', 'padding', '');
  155. setupBox(f, ce, 'box_margin', 'margin', '');
  156. // Setup border fields
  157. setupBox(f, ce, 'border_style', 'border', 'Style');
  158. setupBox(f, ce, 'border_width', 'border', 'Width');
  159. setupBox(f, ce, 'border_color', 'border', 'Color');
  160. updateColor('border_color_top_pick', 'border_color_top');
  161. updateColor('border_color_right_pick', 'border_color_right');
  162. updateColor('border_color_bottom_pick', 'border_color_bottom');
  163. updateColor('border_color_left_pick', 'border_color_left');
  164. f.elements.border_color_top.value = tinyMCEPopup.editor.dom.toHex(f.elements.border_color_top.value);
  165. f.elements.border_color_right.value = tinyMCEPopup.editor.dom.toHex(f.elements.border_color_right.value);
  166. f.elements.border_color_bottom.value = tinyMCEPopup.editor.dom.toHex(f.elements.border_color_bottom.value);
  167. f.elements.border_color_left.value = tinyMCEPopup.editor.dom.toHex(f.elements.border_color_left.value);
  168. // Setup list fields
  169. selectByValue(f, 'list_type', ce.style.listStyleType, true, true);
  170. selectByValue(f, 'list_position', ce.style.listStylePosition, true, true);
  171. f.list_bullet_image.value = ce.style.listStyleImage.replace(new RegExp("url\\('?([^']*)'?\\)", 'gi'), "$1");
  172. // Setup box fields
  173. selectByValue(f, 'positioning_type', ce.style.position, true, true);
  174. selectByValue(f, 'positioning_visibility', ce.style.visibility, true, true);
  175. selectByValue(f, 'positioning_overflow', ce.style.overflow, true, true);
  176. f.positioning_zindex.value = ce.style.zIndex ? ce.style.zIndex : "";
  177. f.positioning_width.value = getNum(ce.style.width);
  178. selectByValue(f, 'positioning_width_measurement', getMeasurement(ce.style.width));
  179. f.positioning_height.value = getNum(ce.style.height);
  180. selectByValue(f, 'positioning_height_measurement', getMeasurement(ce.style.height));
  181. setupBox(f, ce, 'positioning_placement', '', '', ['top', 'right', 'bottom', 'left']);
  182. s = ce.style.clip.replace(new RegExp("rect\\('?([^']*)'?\\)", 'gi'), "$1");
  183. s = s.replace(/,/g, ' ');
  184. if (!hasEqualValues([getVal(s, 0), getVal(s, 1), getVal(s, 2), getVal(s, 3)])) {
  185. f.positioning_clip_top.value = getNum(getVal(s, 0));
  186. selectByValue(f, 'positioning_clip_top_measurement', getMeasurement(getVal(s, 0)));
  187. f.positioning_clip_right.value = getNum(getVal(s, 1));
  188. selectByValue(f, 'positioning_clip_right_measurement', getMeasurement(getVal(s, 1)));
  189. f.positioning_clip_bottom.value = getNum(getVal(s, 2));
  190. selectByValue(f, 'positioning_clip_bottom_measurement', getMeasurement(getVal(s, 2)));
  191. f.positioning_clip_left.value = getNum(getVal(s, 3));
  192. selectByValue(f, 'positioning_clip_left_measurement', getMeasurement(getVal(s, 3)));
  193. } else {
  194. f.positioning_clip_top.value = getNum(getVal(s, 0));
  195. selectByValue(f, 'positioning_clip_top_measurement', getMeasurement(getVal(s, 0)));
  196. f.positioning_clip_right.value = f.positioning_clip_bottom.value = f.positioning_clip_left.value;
  197. }
  198. // setupBox(f, ce, '', 'border', 'Color');
  199. }
  200. function getMeasurement(s) {
  201. return s.replace(/^([0-9]+)(.*)$/, "$2");
  202. }
  203. function getNum(s) {
  204. if (new RegExp('^[0-9]+[a-z%]+$', 'gi').test(s))
  205. return s.replace(/[^0-9]/g, '');
  206. return s;
  207. }
  208. function inStr(s, n) {
  209. return new RegExp(n, 'gi').test(s);
  210. }
  211. function getVal(s, i) {
  212. var a = s.split(' ');
  213. if (a.length > 1)
  214. return a[i];
  215. return "";
  216. }
  217. function setValue(f, n, v) {
  218. if (f.elements[n].type == "text")
  219. f.elements[n].value = v;
  220. else
  221. selectByValue(f, n, v, true, true);
  222. }
  223. function setupBox(f, ce, fp, pr, sf, b) {
  224. if (typeof(b) == "undefined")
  225. b = ['Top', 'Right', 'Bottom', 'Left'];
  226. if (isSame(ce, pr, sf, b)) {
  227. f.elements[fp + "_same"].checked = true;
  228. setValue(f, fp + "_top", getNum(ce.style[pr + b[0] + sf]));
  229. f.elements[fp + "_top"].disabled = false;
  230. f.elements[fp + "_right"].value = "";
  231. f.elements[fp + "_right"].disabled = true;
  232. f.elements[fp + "_bottom"].value = "";
  233. f.elements[fp + "_bottom"].disabled = true;
  234. f.elements[fp + "_left"].value = "";
  235. f.elements[fp + "_left"].disabled = true;
  236. if (f.elements[fp + "_top_measurement"]) {
  237. selectByValue(f, fp + '_top_measurement', getMeasurement(ce.style[pr + b[0] + sf]));
  238. f.elements[fp + "_left_measurement"].disabled = true;
  239. f.elements[fp + "_bottom_measurement"].disabled = true;
  240. f.elements[fp + "_right_measurement"].disabled = true;
  241. }
  242. } else {
  243. f.elements[fp + "_same"].checked = false;
  244. setValue(f, fp + "_top", getNum(ce.style[pr + b[0] + sf]));
  245. f.elements[fp + "_top"].disabled = false;
  246. setValue(f, fp + "_right", getNum(ce.style[pr + b[1] + sf]));
  247. f.elements[fp + "_right"].disabled = false;
  248. setValue(f, fp + "_bottom", getNum(ce.style[pr + b[2] + sf]));
  249. f.elements[fp + "_bottom"].disabled = false;
  250. setValue(f, fp + "_left", getNum(ce.style[pr + b[3] + sf]));
  251. f.elements[fp + "_left"].disabled = false;
  252. if (f.elements[fp + "_top_measurement"]) {
  253. selectByValue(f, fp + '_top_measurement', getMeasurement(ce.style[pr + b[0] + sf]));
  254. selectByValue(f, fp + '_right_measurement', getMeasurement(ce.style[pr + b[1] + sf]));
  255. selectByValue(f, fp + '_bottom_measurement', getMeasurement(ce.style[pr + b[2] + sf]));
  256. selectByValue(f, fp + '_left_measurement', getMeasurement(ce.style[pr + b[3] + sf]));
  257. f.elements[fp + "_left_measurement"].disabled = false;
  258. f.elements[fp + "_bottom_measurement"].disabled = false;
  259. f.elements[fp + "_right_measurement"].disabled = false;
  260. }
  261. }
  262. }
  263. function isSame(e, pr, sf, b) {
  264. var a = [], i, x;
  265. if (typeof(b) == "undefined")
  266. b = ['Top', 'Right', 'Bottom', 'Left'];
  267. if (typeof(sf) == "undefined" || sf == null)
  268. sf = "";
  269. a[0] = e.style[pr + b[0] + sf];
  270. a[1] = e.style[pr + b[1] + sf];
  271. a[2] = e.style[pr + b[2] + sf];
  272. a[3] = e.style[pr + b[3] + sf];
  273. for (i=0; i<a.length; i++) {
  274. if (a[i] == null)
  275. return false;
  276. for (x=0; x<a.length; x++) {
  277. if (a[x] != a[i])
  278. return false;
  279. }
  280. }
  281. return true;
  282. };
  283. function hasEqualValues(a) {
  284. var i, x;
  285. for (i=0; i<a.length; i++) {
  286. if (a[i] == null)
  287. return false;
  288. for (x=0; x<a.length; x++) {
  289. if (a[x] != a[i])
  290. return false;
  291. }
  292. }
  293. return true;
  294. }
  295. function applyAction() {
  296. var ce = document.getElementById('container'), ed = tinyMCEPopup.editor;
  297. generateCSS();
  298. tinyMCEPopup.restoreSelection();
  299. ed.dom.setAttrib(ed.selection.getNode(), 'style', tinyMCEPopup.editor.dom.serializeStyle(tinyMCEPopup.editor.dom.parseStyle(ce.style.cssText)));
  300. }
  301. function updateAction() {
  302. applyAction();
  303. tinyMCEPopup.close();
  304. }
  305. function generateCSS() {
  306. var ce = document.getElementById('container'), f = document.forms[0], num = new RegExp('[0-9]+', 'g'), s, t;
  307. ce.style.cssText = "";
  308. // Build text styles
  309. ce.style.fontFamily = f.text_font.value;
  310. ce.style.fontSize = f.text_size.value + (isNum(f.text_size.value) ? (f.text_size_measurement.value || 'px') : "");
  311. ce.style.fontStyle = f.text_style.value;
  312. ce.style.lineHeight = f.text_lineheight.value + (isNum(f.text_lineheight.value) ? f.text_lineheight_measurement.value : "");
  313. ce.style.textTransform = f.text_case.value;
  314. ce.style.fontWeight = f.text_weight.value;
  315. ce.style.fontVariant = f.text_variant.value;
  316. ce.style.color = f.text_color.value;
  317. s = "";
  318. s += f.text_underline.checked ? " underline" : "";
  319. s += f.text_overline.checked ? " overline" : "";
  320. s += f.text_linethrough.checked ? " line-through" : "";
  321. s += f.text_blink.checked ? " blink" : "";
  322. s = s.length > 0 ? s.substring(1) : s;
  323. if (f.text_none.checked)
  324. s = "none";
  325. ce.style.textDecoration = s;
  326. // Build background styles
  327. ce.style.backgroundColor = f.background_color.value;
  328. ce.style.backgroundImage = f.background_image.value != "" ? "url(" + f.background_image.value + ")" : "";
  329. ce.style.backgroundRepeat = f.background_repeat.value;
  330. ce.style.backgroundAttachment = f.background_attachment.value;
  331. if (f.background_hpos.value != "") {
  332. s = "";
  333. s += f.background_hpos.value + (isNum(f.background_hpos.value) ? f.background_hpos_measurement.value : "") + " ";
  334. s += f.background_vpos.value + (isNum(f.background_vpos.value) ? f.background_vpos_measurement.value : "");
  335. ce.style.backgroundPosition = s;
  336. }
  337. // Build block styles
  338. ce.style.wordSpacing = f.block_wordspacing.value + (isNum(f.block_wordspacing.value) ? f.block_wordspacing_measurement.value : "");
  339. ce.style.letterSpacing = f.block_letterspacing.value + (isNum(f.block_letterspacing.value) ? f.block_letterspacing_measurement.value : "");
  340. ce.style.verticalAlign = f.block_vertical_alignment.value;
  341. ce.style.textAlign = f.block_text_align.value;
  342. ce.style.textIndent = f.block_text_indent.value + (isNum(f.block_text_indent.value) ? f.block_text_indent_measurement.value : "");
  343. ce.style.whiteSpace = f.block_whitespace.value;
  344. ce.style.display = f.block_display.value;
  345. // Build box styles
  346. ce.style.width = f.box_width.value + (isNum(f.box_width.value) ? f.box_width_measurement.value : "");
  347. ce.style.height = f.box_height.value + (isNum(f.box_height.value) ? f.box_height_measurement.value : "");
  348. ce.style.styleFloat = f.box_float.value;
  349. if (tinymce.isGecko)
  350. ce.style.cssFloat = f.box_float.value;
  351. ce.style.clear = f.box_clear.value;
  352. if (!f.box_padding_same.checked) {
  353. ce.style.paddingTop = f.box_padding_top.value + (isNum(f.box_padding_top.value) ? f.box_padding_top_measurement.value : "");
  354. ce.style.paddingRight = f.box_padding_right.value + (isNum(f.box_padding_right.value) ? f.box_padding_right_measurement.value : "");
  355. ce.style.paddingBottom = f.box_padding_bottom.value + (isNum(f.box_padding_bottom.value) ? f.box_padding_bottom_measurement.value : "");
  356. ce.style.paddingLeft = f.box_padding_left.value + (isNum(f.box_padding_left.value) ? f.box_padding_left_measurement.value : "");
  357. } else
  358. ce.style.padding = f.box_padding_top.value + (isNum(f.box_padding_top.value) ? f.box_padding_top_measurement.value : "");
  359. if (!f.box_margin_same.checked) {
  360. ce.style.marginTop = f.box_margin_top.value + (isNum(f.box_margin_top.value) ? f.box_margin_top_measurement.value : "");
  361. ce.style.marginRight = f.box_margin_right.value + (isNum(f.box_margin_right.value) ? f.box_margin_right_measurement.value : "");
  362. ce.style.marginBottom = f.box_margin_bottom.value + (isNum(f.box_margin_bottom.value) ? f.box_margin_bottom_measurement.value : "");
  363. ce.style.marginLeft = f.box_margin_left.value + (isNum(f.box_margin_left.value) ? f.box_margin_left_measurement.value : "");
  364. } else
  365. ce.style.margin = f.box_margin_top.value + (isNum(f.box_margin_top.value) ? f.box_margin_top_measurement.value : "");
  366. // Build border styles
  367. if (!f.border_style_same.checked) {
  368. ce.style.borderTopStyle = f.border_style_top.value;
  369. ce.style.borderRightStyle = f.border_style_right.value;
  370. ce.style.borderBottomStyle = f.border_style_bottom.value;
  371. ce.style.borderLeftStyle = f.border_style_left.value;
  372. } else
  373. ce.style.borderStyle = f.border_style_top.value;
  374. if (!f.border_width_same.checked) {
  375. ce.style.borderTopWidth = f.border_width_top.value + (isNum(f.border_width_top.value) ? f.border_width_top_measurement.value : "");
  376. ce.style.borderRightWidth = f.border_width_right.value + (isNum(f.border_width_right.value) ? f.border_width_right_measurement.value : "");
  377. ce.style.borderBottomWidth = f.border_width_bottom.value + (isNum(f.border_width_bottom.value) ? f.border_width_bottom_measurement.value : "");
  378. ce.style.borderLeftWidth = f.border_width_left.value + (isNum(f.border_width_left.value) ? f.border_width_left_measurement.value : "");
  379. } else
  380. ce.style.borderWidth = f.border_width_top.value;
  381. if (!f.border_color_same.checked) {
  382. ce.style.borderTopColor = f.border_color_top.value;
  383. ce.style.borderRightColor = f.border_color_right.value;
  384. ce.style.borderBottomColor = f.border_color_bottom.value;
  385. ce.style.borderLeftColor = f.border_color_left.value;
  386. } else
  387. ce.style.borderColor = f.border_color_top.value;
  388. // Build list styles
  389. ce.style.listStyleType = f.list_type.value;
  390. ce.style.listStylePosition = f.list_position.value;
  391. ce.style.listStyleImage = f.list_bullet_image.value != "" ? "url(" + f.list_bullet_image.value + ")" : "";
  392. // Build positioning styles
  393. ce.style.position = f.positioning_type.value;
  394. ce.style.visibility = f.positioning_visibility.value;
  395. if (ce.style.width == "")
  396. ce.style.width = f.positioning_width.value + (isNum(f.positioning_width.value) ? f.positioning_width_measurement.value : "");
  397. if (ce.style.height == "")
  398. ce.style.height = f.positioning_height.value + (isNum(f.positioning_height.value) ? f.positioning_height_measurement.value : "");
  399. ce.style.zIndex = f.positioning_zindex.value;
  400. ce.style.overflow = f.positioning_overflow.value;
  401. if (!f.positioning_placement_same.checked) {
  402. ce.style.top = f.positioning_placement_top.value + (isNum(f.positioning_placement_top.value) ? f.positioning_placement_top_measurement.value : "");
  403. ce.style.right = f.positioning_placement_right.value + (isNum(f.positioning_placement_right.value) ? f.positioning_placement_right_measurement.value : "");
  404. ce.style.bottom = f.positioning_placement_bottom.value + (isNum(f.positioning_placement_bottom.value) ? f.positioning_placement_bottom_measurement.value : "");
  405. ce.style.left = f.positioning_placement_left.value + (isNum(f.positioning_placement_left.value) ? f.positioning_placement_left_measurement.value : "");
  406. } else {
  407. s = f.positioning_placement_top.value + (isNum(f.positioning_placement_top.value) ? f.positioning_placement_top_measurement.value : "");
  408. ce.style.top = s;
  409. ce.style.right = s;
  410. ce.style.bottom = s;
  411. ce.style.left = s;
  412. }
  413. if (!f.positioning_clip_same.checked) {
  414. s = "rect(";
  415. s += (isNum(f.positioning_clip_top.value) ? f.positioning_clip_top.value + f.positioning_clip_top_measurement.value : "auto") + " ";
  416. s += (isNum(f.positioning_clip_right.value) ? f.positioning_clip_right.value + f.positioning_clip_right_measurement.value : "auto") + " ";
  417. s += (isNum(f.positioning_clip_bottom.value) ? f.positioning_clip_bottom.value + f.positioning_clip_bottom_measurement.value : "auto") + " ";
  418. s += (isNum(f.positioning_clip_left.value) ? f.positioning_clip_left.value + f.positioning_clip_left_measurement.value : "auto");
  419. s += ")";
  420. if (s != "rect(auto auto auto auto)")
  421. ce.style.clip = s;
  422. } else {
  423. s = "rect(";
  424. t = isNum(f.positioning_clip_top.value) ? f.positioning_clip_top.value + f.positioning_clip_top_measurement.value : "auto";
  425. s += t + " ";
  426. s += t + " ";
  427. s += t + " ";
  428. s += t + ")";
  429. if (s != "rect(auto auto auto auto)")
  430. ce.style.clip = s;
  431. }
  432. ce.style.cssText = ce.style.cssText;
  433. }
  434. function isNum(s) {
  435. return new RegExp('[0-9]+', 'g').test(s);
  436. }
  437. function showDisabledControls() {
  438. var f = document.forms, i, a;
  439. for (i=0; i<f.length; i++) {
  440. for (a=0; a<f[i].elements.length; a++) {
  441. if (f[i].elements[a].disabled)
  442. tinyMCEPopup.editor.dom.addClass(f[i].elements[a], "disabled");
  443. else
  444. tinyMCEPopup.editor.dom.removeClass(f[i].elements[a], "disabled");
  445. }
  446. }
  447. }
  448. function fillSelect(f, s, param, dval, sep, em) {
  449. var i, ar, p, se;
  450. f = document.forms[f];
  451. sep = typeof(sep) == "undefined" ? ";" : sep;
  452. if (em)
  453. addSelectValue(f, s, "", "");
  454. ar = tinyMCEPopup.getParam(param, dval).split(sep);
  455. for (i=0; i<ar.length; i++) {
  456. se = false;
  457. if (ar[i].charAt(0) == '+') {
  458. ar[i] = ar[i].substring(1);
  459. se = true;
  460. }
  461. p = ar[i].split('=');
  462. if (p.length > 1) {
  463. addSelectValue(f, s, p[0], p[1]);
  464. if (se)
  465. selectByValue(f, s, p[1]);
  466. } else {
  467. addSelectValue(f, s, p[0], p[0]);
  468. if (se)
  469. selectByValue(f, s, p[0]);
  470. }
  471. }
  472. }
  473. function toggleSame(ce, pre) {
  474. var el = document.forms[0].elements, i;
  475. if (ce.checked) {
  476. el[pre + "_top"].disabled = false;
  477. el[pre + "_right"].disabled = true;
  478. el[pre + "_bottom"].disabled = true;
  479. el[pre + "_left"].disabled = true;
  480. if (el[pre + "_top_measurement"]) {
  481. el[pre + "_top_measurement"].disabled = false;
  482. el[pre + "_right_measurement"].disabled = true;
  483. el[pre + "_bottom_measurement"].disabled = true;
  484. el[pre + "_left_measurement"].disabled = true;
  485. }
  486. } else {
  487. el[pre + "_top"].disabled = false;
  488. el[pre + "_right"].disabled = false;
  489. el[pre + "_bottom"].disabled = false;
  490. el[pre + "_left"].disabled = false;
  491. if (el[pre + "_top_measurement"]) {
  492. el[pre + "_top_measurement"].disabled = false;
  493. el[pre + "_right_measurement"].disabled = false;
  494. el[pre + "_bottom_measurement"].disabled = false;
  495. el[pre + "_left_measurement"].disabled = false;
  496. }
  497. }
  498. showDisabledControls();
  499. }
  500. function synch(fr, to) {
  501. var f = document.forms[0];
  502. f.elements[to].value = f.elements[fr].value;
  503. if (f.elements[fr + "_measurement"])
  504. selectByValue(f, to + "_measurement", f.elements[fr + "_measurement"].value);
  505. }
  506. tinyMCEPopup.onInit.add(init);