RichText.js
上传用户:kimgenplus
上传日期:2016-06-05
资源大小:20877k
文件大小:39k
源码类别:

OA系统

开发平台:

Java

  1. /*
  2. Copyright (c) 2004-2006, The Dojo Foundation
  3. All Rights Reserved.
  4. Licensed under the Academic Free License version 2.1 or above OR the
  5. modified BSD license. For more information on Dojo licensing, see:
  6. http://dojotoolkit.org/community/licensing.shtml
  7. */
  8. dojo.provide("dojo.widget.RichText");
  9. dojo.require("dojo.widget.*");
  10. dojo.require("dojo.html.*");
  11. dojo.require("dojo.html.layout");
  12. dojo.require("dojo.html.selection");
  13. dojo.require("dojo.event.*");
  14. dojo.require("dojo.string.extras");
  15. dojo.require("dojo.uri.Uri");
  16. dojo.require("dojo.Deferred");
  17. if (!djConfig["useXDomain"] || djConfig["allowXdRichTextSave"]) {
  18. if (dojo.hostenv.post_load_) {
  19. (function () {
  20. var savetextarea = dojo.doc().createElement("textarea");
  21. savetextarea.id = "dojo.widget.RichText.savedContent";
  22. savetextarea.style = "display:none;position:absolute;top:-100px;left:-100px;height:3px;width:3px;overflow:hidden;";
  23. dojo.body().appendChild(savetextarea);
  24. })();
  25. } else {
  26. try {
  27. dojo.doc().write("<textarea id="dojo.widget.RichText.savedContent" " + "style="display:none;position:absolute;top:-100px;left:-100px;height:3px;width:3px;overflow:hidden;"></textarea>");
  28. }
  29. catch (e) {
  30. }
  31. }
  32. }
  33. dojo.widget.defineWidget("dojo.widget.RichText", dojo.widget.HtmlWidget, function () {
  34. this.contentPreFilters = [];
  35. this.contentPostFilters = [];
  36. this.contentDomPreFilters = [];
  37. this.contentDomPostFilters = [];
  38. this.editingAreaStyleSheets = [];
  39. if (dojo.render.html.moz) {
  40. this.contentPreFilters.push(this._fixContentForMoz);
  41. }
  42. this._keyHandlers = {};
  43. if (dojo.Deferred) {
  44. this.onLoadDeferred = new dojo.Deferred();
  45. }
  46. }, {inheritWidth:false, focusOnLoad:false, saveName:"", styleSheets:"", _content:"", height:"", minHeight:"1em", isClosed:true, isLoaded:false, useActiveX:false, relativeImageUrls:false, _SEPARATOR:"@@**%%__RICHTEXTBOUNDRY__%%**@@", onLoadDeferred:null, fillInTemplate:function () {
  47. dojo.event.topic.publish("dojo.widget.RichText::init", this);
  48. this.open();
  49. dojo.event.connect(this, "onKeyPressed", this, "afterKeyPress");
  50. dojo.event.connect(this, "onKeyPress", this, "keyPress");
  51. dojo.event.connect(this, "onKeyDown", this, "keyDown");
  52. dojo.event.connect(this, "onKeyUp", this, "keyUp");
  53. this.setupDefaultShortcuts();
  54. }, setupDefaultShortcuts:function () {
  55. var ctrl = this.KEY_CTRL;
  56. var exec = function (cmd, arg) {
  57. return arguments.length == 1 ? function () {
  58. this.execCommand(cmd);
  59. } : function () {
  60. this.execCommand(cmd, arg);
  61. };
  62. };
  63. this.addKeyHandler("b", ctrl, exec("bold"));
  64. this.addKeyHandler("i", ctrl, exec("italic"));
  65. this.addKeyHandler("u", ctrl, exec("underline"));
  66. this.addKeyHandler("a", ctrl, exec("selectall"));
  67. this.addKeyHandler("s", ctrl, function () {
  68. this.save(true);
  69. });
  70. this.addKeyHandler("1", ctrl, exec("formatblock", "h1"));
  71. this.addKeyHandler("2", ctrl, exec("formatblock", "h2"));
  72. this.addKeyHandler("3", ctrl, exec("formatblock", "h3"));
  73. this.addKeyHandler("4", ctrl, exec("formatblock", "h4"));
  74. this.addKeyHandler("\", ctrl, exec("insertunorderedlist"));
  75. if (!dojo.render.html.ie) {
  76. this.addKeyHandler("Z", ctrl, exec("redo"));
  77. }
  78. }, events:["onBlur", "onFocus", "onKeyPress", "onKeyDown", "onKeyUp", "onClick"], open:function (element) {
  79. if (this.onLoadDeferred.fired >= 0) {
  80. this.onLoadDeferred = new dojo.Deferred();
  81. }
  82. var h = dojo.render.html;
  83. if (!this.isClosed) {
  84. this.close();
  85. }
  86. dojo.event.topic.publish("dojo.widget.RichText::open", this);
  87. this._content = "";
  88. if ((arguments.length == 1) && (element["nodeName"])) {
  89. this.domNode = element;
  90. }
  91. if ((this.domNode["nodeName"]) && (this.domNode.nodeName.toLowerCase() == "textarea")) {
  92. this.textarea = this.domNode;
  93. var html = this._preFilterContent(this.textarea.value);
  94. this.domNode = dojo.doc().createElement("div");
  95. dojo.html.copyStyle(this.domNode, this.textarea);
  96. var tmpFunc = dojo.lang.hitch(this, function () {
  97. with (this.textarea.style) {
  98. display = "block";
  99. position = "absolute";
  100. left = top = "-1000px";
  101. if (h.ie) {
  102. this.__overflow = overflow;
  103. overflow = "hidden";
  104. }
  105. }
  106. });
  107. if (h.ie) {
  108. setTimeout(tmpFunc, 10);
  109. } else {
  110. tmpFunc();
  111. }
  112. if (!h.safari) {
  113. dojo.html.insertBefore(this.domNode, this.textarea);
  114. }
  115. if (this.textarea.form) {
  116. dojo.event.connect("before", this.textarea.form, "onsubmit", dojo.lang.hitch(this, function () {
  117. this.textarea.value = this.getEditorContent();
  118. }));
  119. }
  120. var editor = this;
  121. dojo.event.connect(this, "postCreate", function () {
  122. dojo.html.insertAfter(editor.textarea, editor.domNode);
  123. });
  124. } else {
  125. var html = this._preFilterContent(dojo.string.trim(this.domNode.innerHTML));
  126. }
  127. if (html == "") {
  128. html = "&nbsp;";
  129. }
  130. var content = dojo.html.getContentBox(this.domNode);
  131. this._oldHeight = content.height;
  132. this._oldWidth = content.width;
  133. this._firstChildContributingMargin = this._getContributingMargin(this.domNode, "top");
  134. this._lastChildContributingMargin = this._getContributingMargin(this.domNode, "bottom");
  135. this.savedContent = html;
  136. this.domNode.innerHTML = "";
  137. this.editingArea = dojo.doc().createElement("div");
  138. this.domNode.appendChild(this.editingArea);
  139. if ((this.domNode["nodeName"]) && (this.domNode.nodeName == "LI")) {
  140. this.domNode.innerHTML = " <br>";
  141. }
  142. if (this.saveName != "" && (!djConfig["useXDomain"] || djConfig["allowXdRichTextSave"])) {
  143. var saveTextarea = dojo.doc().getElementById("dojo.widget.RichText.savedContent");
  144. if (saveTextarea.value != "") {
  145. var datas = saveTextarea.value.split(this._SEPARATOR);
  146. for (var i = 0; i < datas.length; i++) {
  147. var data = datas[i].split(":");
  148. if (data[0] == this.saveName) {
  149. html = data[1];
  150. datas.splice(i, 1);
  151. break;
  152. }
  153. }
  154. }
  155. dojo.event.connect("before", window, "onunload", this, "_saveContent");
  156. }
  157. if (h.ie70 && this.useActiveX) {
  158. dojo.debug("activeX in ie70 is not currently supported, useActiveX is ignored for now.");
  159. this.useActiveX = false;
  160. }
  161. if (this.useActiveX && h.ie) {
  162. var self = this;
  163. setTimeout(function () {
  164. self._drawObject(html);
  165. }, 0);
  166. } else {
  167. if (h.ie || this._safariIsLeopard() || h.opera) {
  168. this.iframe = dojo.doc().createElement("iframe");
  169. this.iframe.src = "javascript:void(0)";
  170. this.editorObject = this.iframe;
  171. with (this.iframe.style) {
  172. border = "0";
  173. width = "100%";
  174. }
  175. this.iframe.frameBorder = 0;
  176. this.editingArea.appendChild(this.iframe);
  177. this.window = this.iframe.contentWindow;
  178. this.document = this.window.document;
  179. this.document.open();
  180. this.document.write("<html><head><style>body{margin:0;padding:0;border:0;overflow:hidden;}</style></head><body><div></div></body></html>");
  181. this.document.close();
  182. this.editNode = this.document.body.firstChild;
  183. this.editNode.contentEditable = true;
  184. with (this.iframe.style) {
  185. if (h.ie70) {
  186. if (this.height) {
  187. height = this.height;
  188. }
  189. if (this.minHeight) {
  190. minHeight = this.minHeight;
  191. }
  192. } else {
  193. height = this.height ? this.height : this.minHeight;
  194. }
  195. }
  196. var formats = ["p", "pre", "address", "h1", "h2", "h3", "h4", "h5", "h6", "ol", "div", "ul"];
  197. var localhtml = "";
  198. for (var i in formats) {
  199. if (formats[i].charAt(1) != "l") {
  200. localhtml += "<" + formats[i] + "><span>content</span></" + formats[i] + ">";
  201. } else {
  202. localhtml += "<" + formats[i] + "><li>content</li></" + formats[i] + ">";
  203. }
  204. }
  205. with (this.editNode.style) {
  206. position = "absolute";
  207. left = "-2000px";
  208. top = "-2000px";
  209. }
  210. this.editNode.innerHTML = localhtml;
  211. var node = this.editNode.firstChild;
  212. while (node) {
  213. dojo.withGlobal(this.window, "selectElement", dojo.html.selection, [node.firstChild]);
  214. var nativename = node.tagName.toLowerCase();
  215. this._local2NativeFormatNames[nativename] = this.queryCommandValue("formatblock");
  216. this._native2LocalFormatNames[this._local2NativeFormatNames[nativename]] = nativename;
  217. node = node.nextSibling;
  218. }
  219. with (this.editNode.style) {
  220. position = "";
  221. left = "";
  222. top = "";
  223. }
  224. this.editNode.innerHTML = html;
  225. if (this.height) {
  226. this.document.body.style.overflowY = "scroll";
  227. }
  228. dojo.lang.forEach(this.events, function (e) {
  229. dojo.event.connect(this.editNode, e.toLowerCase(), this, e);
  230. }, this);
  231. this.onLoad();
  232. } else {
  233. this._drawIframe(html);
  234. this.editorObject = this.iframe;
  235. }
  236. }
  237. if (this.domNode.nodeName == "LI") {
  238. this.domNode.lastChild.style.marginTop = "-1.2em";
  239. }
  240. dojo.html.addClass(this.domNode, "RichTextEditable");
  241. this.isClosed = false;
  242. }, _hasCollapseableMargin:function (element, side) {
  243. if (dojo.html.getPixelValue(element, "border-" + side + "-width", false)) {
  244. return false;
  245. } else {
  246. if (dojo.html.getPixelValue(element, "padding-" + side, false)) {
  247. return false;
  248. } else {
  249. return true;
  250. }
  251. }
  252. }, _getContributingMargin:function (element, topOrBottom) {
  253. if (topOrBottom == "top") {
  254. var siblingAttr = "previousSibling";
  255. var childSiblingAttr = "nextSibling";
  256. var childAttr = "firstChild";
  257. var marginProp = "margin-top";
  258. var siblingMarginProp = "margin-bottom";
  259. } else {
  260. var siblingAttr = "nextSibling";
  261. var childSiblingAttr = "previousSibling";
  262. var childAttr = "lastChild";
  263. var marginProp = "margin-bottom";
  264. var siblingMarginProp = "margin-top";
  265. }
  266. var elementMargin = dojo.html.getPixelValue(element, marginProp, false);
  267. function isSignificantNode(element) {
  268. return !(element.nodeType == 3 && dojo.string.isBlank(element.data)) && dojo.html.getStyle(element, "display") != "none" && !dojo.html.isPositionAbsolute(element);
  269. }
  270. var childMargin = 0;
  271. var child = element[childAttr];
  272. while (child) {
  273. while ((!isSignificantNode(child)) && child[childSiblingAttr]) {
  274. child = child[childSiblingAttr];
  275. }
  276. childMargin = Math.max(childMargin, dojo.html.getPixelValue(child, marginProp, false));
  277. if (!this._hasCollapseableMargin(child, topOrBottom)) {
  278. break;
  279. }
  280. child = child[childAttr];
  281. }
  282. if (!this._hasCollapseableMargin(element, topOrBottom)) {
  283. return parseInt(childMargin);
  284. }
  285. var contextMargin = 0;
  286. var sibling = element[siblingAttr];
  287. while (sibling) {
  288. if (isSignificantNode(sibling)) {
  289. contextMargin = dojo.html.getPixelValue(sibling, siblingMarginProp, false);
  290. break;
  291. }
  292. sibling = sibling[siblingAttr];
  293. }
  294. if (!sibling) {
  295. contextMargin = dojo.html.getPixelValue(element.parentNode, marginProp, false);
  296. }
  297. if (childMargin > elementMargin) {
  298. return parseInt(Math.max((childMargin - elementMargin) - contextMargin, 0));
  299. } else {
  300. return 0;
  301. }
  302. }, _drawIframe:function (html) {
  303. var oldMoz = Boolean(dojo.render.html.moz && (typeof window.XML == "undefined"));
  304. if (!this.iframe) {
  305. var currentDomain = (new dojo.uri.Uri(dojo.doc().location)).host;
  306. this.iframe = dojo.doc().createElement("iframe");
  307. with (this.iframe) {
  308. style.border = "none";
  309. style.lineHeight = "0";
  310. style.verticalAlign = "bottom";
  311. scrolling = this.height ? "auto" : "no";
  312. }
  313. }
  314. if (djConfig["useXDomain"] && !djConfig["dojoRichTextFrameUrl"]) {
  315. dojo.debug("dojo.widget.RichText: When using cross-domain Dojo builds," + " please save src/widget/templates/richtextframe.html to your domain and set djConfig.dojoRichTextFrameUrl" + " to the path on your domain to richtextframe.html");
  316. }
  317. this.iframe.src = (djConfig["dojoRichTextFrameUrl"] || dojo.uri.moduleUri("dojo.widget", "templates/richtextframe.html")) + ((dojo.doc().domain != currentDomain) ? ("#" + dojo.doc().domain) : "");
  318. this.iframe.width = this.inheritWidth ? this._oldWidth : "100%";
  319. if (this.height) {
  320. this.iframe.style.height = this.height;
  321. } else {
  322. var height = this._oldHeight;
  323. if (this._hasCollapseableMargin(this.domNode, "top")) {
  324. height += this._firstChildContributingMargin;
  325. }
  326. if (this._hasCollapseableMargin(this.domNode, "bottom")) {
  327. height += this._lastChildContributingMargin;
  328. }
  329. this.iframe.height = height;
  330. }
  331. var tmpContent = dojo.doc().createElement("div");
  332. tmpContent.innerHTML = html;
  333. this.editingArea.appendChild(tmpContent);
  334. if (this.relativeImageUrls) {
  335. var imgs = tmpContent.getElementsByTagName("img");
  336. for (var i = 0; i < imgs.length; i++) {
  337. imgs[i].src = (new dojo.uri.Uri(dojo.global().location, imgs[i].src)).toString();
  338. }
  339. html = tmpContent.innerHTML;
  340. }
  341. var firstChild = dojo.html.firstElement(tmpContent);
  342. var lastChild = dojo.html.lastElement(tmpContent);
  343. if (firstChild) {
  344. firstChild.style.marginTop = this._firstChildContributingMargin + "px";
  345. }
  346. if (lastChild) {
  347. lastChild.style.marginBottom = this._lastChildContributingMargin + "px";
  348. }
  349. this.editingArea.appendChild(this.iframe);
  350. if (dojo.render.html.safari) {
  351. this.iframe.src = this.iframe.src;
  352. }
  353. var _iframeInitialized = false;
  354. var ifrFunc = dojo.lang.hitch(this, function () {
  355. if (!_iframeInitialized) {
  356. _iframeInitialized = true;
  357. } else {
  358. return;
  359. }
  360. if (!this.editNode) {
  361. if (this.iframe.contentWindow) {
  362. this.window = this.iframe.contentWindow;
  363. this.document = this.iframe.contentWindow.document;
  364. } else {
  365. if (this.iframe.contentDocument) {
  366. this.window = this.iframe.contentDocument.window;
  367. this.document = this.iframe.contentDocument;
  368. }
  369. }
  370. var getStyle = (function (domNode) {
  371. return function (style) {
  372. return dojo.html.getStyle(domNode, style);
  373. };
  374. })(this.domNode);
  375. var font = getStyle("font-weight") + " " + getStyle("font-size") + " " + getStyle("font-family");
  376. var lineHeight = "1.0";
  377. var lineHeightStyle = dojo.html.getUnitValue(this.domNode, "line-height");
  378. if (lineHeightStyle.value && lineHeightStyle.units == "") {
  379. lineHeight = lineHeightStyle.value;
  380. }
  381. dojo.html.insertCssText("body,html{background:transparent;padding:0;margin:0;}" + "body{top:0;left:0;right:0;" + (((this.height) || (dojo.render.html.opera)) ? "" : "position:fixed;") + "font:" + font + ";" + "min-height:" + this.minHeight + ";" + "line-height:" + lineHeight + "}" + "p{margin: 1em 0 !important;}" + "body > *:first-child{padding-top:0 !important;margin-top:" + this._firstChildContributingMargin + "px !important;}" + "body > *:last-child{padding-bottom:0 !important;margin-bottom:" + this._lastChildContributingMargin + "px !important;}" + "li > ul:-moz-first-node, li > ol:-moz-first-node{padding-top:1.2em;}n" + "li{min-height:1.2em;}" + "", this.document);
  382. dojo.html.removeNode(tmpContent);
  383. this.document.body.innerHTML = html;
  384. if (oldMoz || dojo.render.html.safari) {
  385. this.document.designMode = "on";
  386. }
  387. this.onLoad();
  388. } else {
  389. dojo.html.removeNode(tmpContent);
  390. this.editNode.innerHTML = html;
  391. this.onDisplayChanged();
  392. }
  393. });
  394. if (this.editNode) {
  395. ifrFunc();
  396. } else {
  397. if (dojo.render.html.moz) {
  398. this.iframe.onload = function () {
  399. setTimeout(ifrFunc, 250);
  400. };
  401. } else {
  402. this.iframe.onload = ifrFunc;
  403. }
  404. }
  405. }, _applyEditingAreaStyleSheets:function () {
  406. var files = [];
  407. if (this.styleSheets) {
  408. files = this.styleSheets.split(";");
  409. this.styleSheets = "";
  410. }
  411. files = files.concat(this.editingAreaStyleSheets);
  412. this.editingAreaStyleSheets = [];
  413. if (files.length > 0) {
  414. for (var i = 0; i < files.length; i++) {
  415. var url = files[i];
  416. if (url) {
  417. this.addStyleSheet(dojo.uri.dojoUri(url));
  418. }
  419. }
  420. }
  421. }, addStyleSheet:function (uri) {
  422. var url = uri.toString();
  423. if (dojo.lang.find(this.editingAreaStyleSheets, url) > -1) {
  424. dojo.debug("dojo.widget.RichText.addStyleSheet: Style sheet " + url + " is already applied to the editing area!");
  425. return;
  426. }
  427. if (url.charAt(0) == "." || (url.charAt(0) != "/" && !uri.host)) {
  428. url = (new dojo.uri.Uri(dojo.global().location, url)).toString();
  429. }
  430. this.editingAreaStyleSheets.push(url);
  431. if (this.document.createStyleSheet) {
  432. this.document.createStyleSheet(url);
  433. } else {
  434. var head = this.document.getElementsByTagName("head")[0];
  435. var stylesheet = this.document.createElement("link");
  436. with (stylesheet) {
  437. rel = "stylesheet";
  438. type = "text/css";
  439. href = url;
  440. }
  441. head.appendChild(stylesheet);
  442. }
  443. }, removeStyleSheet:function (uri) {
  444. var url = uri.toString();
  445. if (url.charAt(0) == "." || (url.charAt(0) != "/" && !uri.host)) {
  446. url = (new dojo.uri.Uri(dojo.global().location, url)).toString();
  447. }
  448. var index = dojo.lang.find(this.editingAreaStyleSheets, url);
  449. if (index == -1) {
  450. dojo.debug("dojo.widget.RichText.removeStyleSheet: Style sheet " + url + " is not applied to the editing area so it can not be removed!");
  451. return;
  452. }
  453. delete this.editingAreaStyleSheets[index];
  454. var links = this.document.getElementsByTagName("link");
  455. for (var i = 0; i < links.length; i++) {
  456. if (links[i].href == url) {
  457. if (dojo.render.html.ie) {
  458. links[i].href = "";
  459. }
  460. dojo.html.removeNode(links[i]);
  461. break;
  462. }
  463. }
  464. }, _drawObject:function (html) {
  465. this.object = dojo.html.createExternalElement(dojo.doc(), "object");
  466. with (this.object) {
  467. classid = "clsid:2D360201-FFF5-11D1-8D03-00A0C959BC0A";
  468. width = this.inheritWidth ? this._oldWidth : "100%";
  469. style.height = this.height ? this.height : (this._oldHeight + "px");
  470. Scrollbars = this.height ? true : false;
  471. Appearance = this._activeX.appearance.flat;
  472. }
  473. this.editorObject = this.object;
  474. this.editingArea.appendChild(this.object);
  475. this.object.attachEvent("DocumentComplete", dojo.lang.hitch(this, "onLoad"));
  476. dojo.lang.forEach(this.events, function (e) {
  477. this.object.attachEvent(e.toLowerCase(), dojo.lang.hitch(this, e));
  478. }, this);
  479. this.object.DocumentHTML = "<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">" + "<html><title></title>" + "<style type="text/css">" + " body,html { padding: 0; margin: 0; }" + (this.height ? "" : " body,  { overflow: hidden; }") + "</style>" + "<body><div>" + html + "<div></body></html>";
  480. this._cacheLocalBlockFormatNames();
  481. }, _local2NativeFormatNames:{}, _native2LocalFormatNames:{}, _cacheLocalBlockFormatNames:function () {
  482. if (!this._native2LocalFormatNames["p"]) {
  483. var obj = this.object;
  484. var error = false;
  485. if (!obj) {
  486. try {
  487. obj = dojo.html.createExternalElement(dojo.doc(), "object");
  488. obj.classid = "clsid:2D360201-FFF5-11D1-8D03-00A0C959BC0A";
  489. dojo.body().appendChild(obj);
  490. obj.DocumentHTML = "<html><head></head><body></body></html>";
  491. }
  492. catch (e) {
  493. error = true;
  494. }
  495. }
  496. try {
  497. var oNamesParm = new ActiveXObject("DEGetBlockFmtNamesParam.DEGetBlockFmtNamesParam");
  498. obj.ExecCommand(this._activeX.command["getblockformatnames"], 0, oNamesParm);
  499. var vbNamesArray = new VBArray(oNamesParm.Names);
  500. var localFormats = vbNamesArray.toArray();
  501. var nativeFormats = ["p", "pre", "address", "h1", "h2", "h3", "h4", "h5", "h6", "ol", "ul", "", "", "", "", "div"];
  502. for (var i = 0; i < nativeFormats.length; ++i) {
  503. if (nativeFormats[i].length > 0) {
  504. this._local2NativeFormatNames[localFormats[i]] = nativeFormats[i];
  505. this._native2LocalFormatNames[nativeFormats[i]] = localFormats[i];
  506. }
  507. }
  508. }
  509. catch (e) {
  510. error = true;
  511. }
  512. if (obj && !this.object) {
  513. dojo.body().removeChild(obj);
  514. }
  515. }
  516. return !error;
  517. }, _isResized:function () {
  518. return false;
  519. }, onLoad:function (e) {
  520. this.isLoaded = true;
  521. if (this.object) {
  522. this.document = this.object.DOM;
  523. this.window = this.document.parentWindow;
  524. this.editNode = this.document.body.firstChild;
  525. this.editingArea.style.height = this.height ? this.height : this.minHeight;
  526. if (!this.height) {
  527. this.connect(this, "onDisplayChanged", "_updateHeight");
  528. }
  529. this.window._frameElement = this.object;
  530. } else {
  531. if (this.iframe && !dojo.render.html.ie) {
  532. this.editNode = this.document.body;
  533. if (!this.height) {
  534. this.connect(this, "onDisplayChanged", "_updateHeight");
  535. }
  536. try {
  537. this.document.execCommand("useCSS", false, true);
  538. this.document.execCommand("styleWithCSS", false, false);
  539. }
  540. catch (e2) {
  541. }
  542. if (dojo.render.html.safari) {
  543. this.connect(this.editNode, "onblur", "onBlur");
  544. this.connect(this.editNode, "onfocus", "onFocus");
  545. this.connect(this.editNode, "onclick", "onFocus");
  546. this.interval = setInterval(dojo.lang.hitch(this, "onDisplayChanged"), 750);
  547. } else {
  548. if (dojo.render.html.mozilla || dojo.render.html.opera) {
  549. var doc = this.document;
  550. var addListener = dojo.event.browser.addListener;
  551. var self = this;
  552. dojo.lang.forEach(this.events, function (e) {
  553. var l = addListener(self.document, e.substr(2).toLowerCase(), dojo.lang.hitch(self, e));
  554. if (e == "onBlur") {
  555. var unBlur = {unBlur:function (e) {
  556. dojo.event.browser.removeListener(doc, "blur", l);
  557. }};
  558. dojo.event.connect("before", self, "close", unBlur, "unBlur");
  559. }
  560. });
  561. }
  562. }
  563. } else {
  564. if (dojo.render.html.ie) {
  565. if (!this.height) {
  566. this.connect(this, "onDisplayChanged", "_updateHeight");
  567. }
  568. this.editNode.style.zoom = 1;
  569. }
  570. }
  571. }
  572. this._applyEditingAreaStyleSheets();
  573. if (this.focusOnLoad) {
  574. this.focus();
  575. }
  576. this.onDisplayChanged(e);
  577. if (this.onLoadDeferred) {
  578. this.onLoadDeferred.callback(true);
  579. }
  580. }, onKeyDown:function (e) {
  581. if ((!e) && (this.object)) {
  582. e = dojo.event.browser.fixEvent(this.window.event);
  583. }
  584. if ((dojo.render.html.ie) && (e.keyCode == e.KEY_TAB)) {
  585. e.preventDefault();
  586. e.stopPropagation();
  587. this.execCommand((e.shiftKey ? "outdent" : "indent"));
  588. } else {
  589. if (dojo.render.html.ie) {
  590. if ((65 <= e.keyCode) && (e.keyCode <= 90)) {
  591. e.charCode = e.keyCode;
  592. this.onKeyPress(e);
  593. }
  594. }
  595. }
  596. }, onKeyUp:function (e) {
  597. return;
  598. }, KEY_CTRL:1, onKeyPress:function (e) {
  599. if ((!e) && (this.object)) {
  600. e = dojo.event.browser.fixEvent(this.window.event);
  601. }
  602. var modifiers = e.ctrlKey ? this.KEY_CTRL : 0;
  603. if (this._keyHandlers[e.key]) {
  604. var handlers = this._keyHandlers[e.key], i = 0, handler;
  605. while (handler = handlers[i++]) {
  606. if (modifiers == handler.modifiers) {
  607. e.preventDefault();
  608. handler.handler.call(this);
  609. break;
  610. }
  611. }
  612. }
  613. dojo.lang.setTimeout(this, this.onKeyPressed, 1, e);
  614. }, addKeyHandler:function (key, modifiers, handler) {
  615. if (!(this._keyHandlers[key] instanceof Array)) {
  616. this._keyHandlers[key] = [];
  617. }
  618. this._keyHandlers[key].push({modifiers:modifiers || 0, handler:handler});
  619. }, onKeyPressed:function (e) {
  620. this.onDisplayChanged();
  621. }, onClick:function (e) {
  622. this.onDisplayChanged(e);
  623. }, onBlur:function (e) {
  624. }, _initialFocus:true, onFocus:function (e) {
  625. if ((dojo.render.html.mozilla) && (this._initialFocus)) {
  626. this._initialFocus = false;
  627. if (dojo.string.trim(this.editNode.innerHTML) == "&nbsp;") {
  628. this.placeCursorAtStart();
  629. }
  630. }
  631. }, blur:function () {
  632. if (this.iframe) {
  633. this.window.blur();
  634. } else {
  635. if (this.object) {
  636. this.document.body.blur();
  637. } else {
  638. if (this.editNode) {
  639. this.editNode.blur();
  640. }
  641. }
  642. }
  643. }, focus:function () {
  644. if (this.iframe && !dojo.render.html.ie) {
  645. this.window.focus();
  646. } else {
  647. if (this.object) {
  648. this.document.focus();
  649. } else {
  650. if (this.editNode && this.editNode.focus) {
  651. this.editNode.focus();
  652. } else {
  653. dojo.debug("Have no idea how to focus into the editor!");
  654. }
  655. }
  656. }
  657. }, onDisplayChanged:function (e) {
  658. }, _activeX:{command:{bold:5000, italic:5023, underline:5048, justifycenter:5024, justifyleft:5025, justifyright:5026, cut:5003, copy:5002, paste:5032, "delete":5004, undo:5049, redo:5033, removeformat:5034, selectall:5035, unlink:5050, indent:5018, outdent:5031, insertorderedlist:5030, insertunorderedlist:5051, inserttable:5022, insertcell:5019, insertcol:5020, insertrow:5021, deletecells:5005, deletecols:5006, deleterows:5007, mergecells:5029, splitcell:5047, setblockformat:5043, getblockformat:5011, getblockformatnames:5012, setfontname:5044, getfontname:5013, setfontsize:5045, getfontsize:5014, setbackcolor:5042, getbackcolor:5010, setforecolor:5046, getforecolor:5015, findtext:5008, font:5009, hyperlink:5016, image:5017, lockelement:5027, makeabsolute:5028, sendbackward:5036, bringforward:5037, sendbelowtext:5038, bringabovetext:5039, sendtoback:5040, bringtofront:5041, properties:5052}, ui:{"default":0, prompt:1, noprompt:2}, status:{notsupported:0, disabled:1, enabled:3, latched:7, ninched:11}, appearance:{flat:0, inset:1}, state:{unchecked:0, checked:1, gray:2}}, _normalizeCommand:function (cmd) {
  659. var drh = dojo.render.html;
  660. var command = cmd.toLowerCase();
  661. if (command == "formatblock") {
  662. if (drh.safari) {
  663. command = "heading";
  664. }
  665. } else {
  666. if (this.object) {
  667. switch (command) {
  668.   case "createlink":
  669. command = "hyperlink";
  670. break;
  671.   case "insertimage":
  672. command = "image";
  673. break;
  674. }
  675. } else {
  676. if (command == "hilitecolor" && !drh.mozilla) {
  677. command = "backcolor";
  678. }
  679. }
  680. }
  681. return command;
  682. }, _safariIsLeopard:function () {
  683. var gt420 = false;
  684. if (dojo.render.html.safari) {
  685. var tmp = dojo.render.html.UA.split("AppleWebKit/")[1];
  686. var ver = parseFloat(tmp.split(" ")[0]);
  687. if (ver >= 420) {
  688. gt420 = true;
  689. }
  690. }
  691. return gt420;
  692. }, queryCommandAvailable:function (command) {
  693. var ie = 1;
  694. var mozilla = 1 << 1;
  695. var safari = 1 << 2;
  696. var opera = 1 << 3;
  697. var safari420 = 1 << 4;
  698. var gt420 = this._safariIsLeopard();
  699. function isSupportedBy(browsers) {
  700. return {ie:Boolean(browsers & ie), mozilla:Boolean(browsers & mozilla), safari:Boolean(browsers & safari), safari420:Boolean(browsers & safari420), opera:Boolean(browsers & opera)};
  701. }
  702. var supportedBy = null;
  703. switch (command.toLowerCase()) {
  704.   case "bold":
  705.   case "italic":
  706.   case "underline":
  707.   case "subscript":
  708.   case "superscript":
  709.   case "fontname":
  710.   case "fontsize":
  711.   case "forecolor":
  712.   case "hilitecolor":
  713.   case "justifycenter":
  714.   case "justifyfull":
  715.   case "justifyleft":
  716.   case "justifyright":
  717.   case "delete":
  718.   case "selectall":
  719. supportedBy = isSupportedBy(mozilla | ie | safari | opera);
  720. break;
  721.   case "createlink":
  722.   case "unlink":
  723.   case "removeformat":
  724.   case "inserthorizontalrule":
  725.   case "insertimage":
  726.   case "insertorderedlist":
  727.   case "insertunorderedlist":
  728.   case "indent":
  729.   case "outdent":
  730.   case "formatblock":
  731.   case "inserthtml":
  732.   case "undo":
  733.   case "redo":
  734.   case "strikethrough":
  735. supportedBy = isSupportedBy(mozilla | ie | opera | safari420);
  736. break;
  737.   case "blockdirltr":
  738.   case "blockdirrtl":
  739.   case "dirltr":
  740.   case "dirrtl":
  741.   case "inlinedirltr":
  742.   case "inlinedirrtl":
  743. supportedBy = isSupportedBy(ie);
  744. break;
  745.   case "cut":
  746.   case "copy":
  747.   case "paste":
  748. supportedBy = isSupportedBy(ie | mozilla | safari420);
  749. break;
  750.   case "inserttable":
  751. supportedBy = isSupportedBy(mozilla | (this.object ? ie : 0));
  752. break;
  753.   case "insertcell":
  754.   case "insertcol":
  755.   case "insertrow":
  756.   case "deletecells":
  757.   case "deletecols":
  758.   case "deleterows":
  759.   case "mergecells":
  760.   case "splitcell":
  761. supportedBy = isSupportedBy(this.object ? ie : 0);
  762. break;
  763.   default:
  764. return false;
  765. }
  766. return (dojo.render.html.ie && supportedBy.ie) || (dojo.render.html.mozilla && supportedBy.mozilla) || (dojo.render.html.safari && supportedBy.safari) || (gt420 && supportedBy.safari420) || (dojo.render.html.opera && supportedBy.opera);
  767. }, execCommand:function (command, argument) {
  768. var returnValue;
  769. this.focus();
  770. command = this._normalizeCommand(command);
  771. if (argument != undefined) {
  772. if (command == "heading") {
  773. throw new Error("unimplemented");
  774. } else {
  775. if (command == "formatblock") {
  776. if (this.object) {
  777. argument = this._native2LocalFormatNames[argument];
  778. } else {
  779. if (dojo.render.html.ie) {
  780. argument = "<" + argument + ">";
  781. }
  782. }
  783. }
  784. }
  785. }
  786. if (this.object) {
  787. switch (command) {
  788.   case "hilitecolor":
  789. command = "setbackcolor";
  790. break;
  791.   case "forecolor":
  792.   case "backcolor":
  793.   case "fontsize":
  794.   case "fontname":
  795. command = "set" + command;
  796. break;
  797.   case "formatblock":
  798. command = "setblockformat";
  799. }
  800. if (command == "strikethrough") {
  801. command = "inserthtml";
  802. var range = this.document.selection.createRange();
  803. if (!range.htmlText) {
  804. return;
  805. }
  806. argument = range.htmlText.strike();
  807. } else {
  808. if (command == "inserthorizontalrule") {
  809. command = "inserthtml";
  810. argument = "<hr>";
  811. }
  812. }
  813. if (command == "inserthtml") {
  814. var range = this.document.selection.createRange();
  815. if (this.document.selection.type.toUpperCase() == "CONTROL") {
  816. for (var i = 0; i < range.length; i++) {
  817. range.item(i).outerHTML = argument;
  818. }
  819. } else {
  820. range.pasteHTML(argument);
  821. range.select();
  822. }
  823. returnValue = true;
  824. } else {
  825. if (arguments.length == 1) {
  826. returnValue = this.object.ExecCommand(this._activeX.command[command], this._activeX.ui.noprompt);
  827. } else {
  828. returnValue = this.object.ExecCommand(this._activeX.command[command], this._activeX.ui.noprompt, argument);
  829. }
  830. }
  831. } else {
  832. if (command == "inserthtml") {
  833. if (dojo.render.html.ie) {
  834. var insertRange = this.document.selection.createRange();
  835. insertRange.pasteHTML(argument);
  836. insertRange.select();
  837. return true;
  838. } else {
  839. return this.document.execCommand(command, false, argument);
  840. }
  841. } else {
  842. if ((command == "unlink") && (this.queryCommandEnabled("unlink")) && (dojo.render.html.mozilla)) {
  843. var selection = this.window.getSelection();
  844. var selectionRange = selection.getRangeAt(0);
  845. var selectionStartContainer = selectionRange.startContainer;
  846. var selectionStartOffset = selectionRange.startOffset;
  847. var selectionEndContainer = selectionRange.endContainer;
  848. var selectionEndOffset = selectionRange.endOffset;
  849. var a = dojo.withGlobal(this.window, "getAncestorElement", dojo.html.selection, ["a"]);
  850. dojo.withGlobal(this.window, "selectElement", dojo.html.selection, [a]);
  851. returnValue = this.document.execCommand("unlink", false, null);
  852. var selectionRange = this.document.createRange();
  853. selectionRange.setStart(selectionStartContainer, selectionStartOffset);
  854. selectionRange.setEnd(selectionEndContainer, selectionEndOffset);
  855. selection.removeAllRanges();
  856. selection.addRange(selectionRange);
  857. return returnValue;
  858. } else {
  859. if ((command == "hilitecolor") && (dojo.render.html.mozilla)) {
  860. this.document.execCommand("useCSS", false, false);
  861. returnValue = this.document.execCommand(command, false, argument);
  862. this.document.execCommand("useCSS", false, true);
  863. } else {
  864. if ((dojo.render.html.ie) && ((command == "backcolor") || (command == "forecolor"))) {
  865. argument = arguments.length > 1 ? argument : null;
  866. returnValue = this.document.execCommand(command, false, argument);
  867. } else {
  868. argument = arguments.length > 1 ? argument : null;
  869. if (argument || command != "createlink") {
  870. returnValue = this.document.execCommand(command, false, argument);
  871. }
  872. }
  873. }
  874. }
  875. }
  876. }
  877. this.onDisplayChanged();
  878. return returnValue;
  879. }, queryCommandEnabled:function (command) {
  880. command = this._normalizeCommand(command);
  881. if (this.object) {
  882. switch (command) {
  883.   case "hilitecolor":
  884. command = "setbackcolor";
  885. break;
  886.   case "forecolor":
  887.   case "backcolor":
  888.   case "fontsize":
  889.   case "fontname":
  890. command = "set" + command;
  891. break;
  892.   case "formatblock":
  893. command = "setblockformat";
  894. break;
  895.   case "strikethrough":
  896. command = "bold";
  897. break;
  898.   case "inserthorizontalrule":
  899. return true;
  900. }
  901. if (typeof this._activeX.command[command] == "undefined") {
  902. return false;
  903. }
  904. var status = this.object.QueryStatus(this._activeX.command[command]);
  905. return ((status != this._activeX.status.notsupported) && (status != this._activeX.status.disabled));
  906. } else {
  907. if (dojo.render.html.mozilla) {
  908. if (command == "unlink") {
  909. return dojo.withGlobal(this.window, "hasAncestorElement", dojo.html.selection, ["a"]);
  910. } else {
  911. if (command == "inserttable") {
  912. return true;
  913. }
  914. }
  915. }
  916. var elem = (dojo.render.html.ie) ? this.document.selection.createRange() : this.document;
  917. return elem.queryCommandEnabled(command);
  918. }
  919. }, queryCommandState:function (command) {
  920. command = this._normalizeCommand(command);
  921. if (this.object) {
  922. if (command == "forecolor") {
  923. command = "setforecolor";
  924. } else {
  925. if (command == "backcolor") {
  926. command = "setbackcolor";
  927. } else {
  928. if (command == "strikethrough") {
  929. return dojo.withGlobal(this.window, "hasAncestorElement", dojo.html.selection, ["strike"]);
  930. } else {
  931. if (command == "inserthorizontalrule") {
  932. return false;
  933. }
  934. }
  935. }
  936. }
  937. if (typeof this._activeX.command[command] == "undefined") {
  938. return null;
  939. }
  940. var status = this.object.QueryStatus(this._activeX.command[command]);
  941. return ((status == this._activeX.status.latched) || (status == this._activeX.status.ninched));
  942. } else {
  943. return this.document.queryCommandState(command);
  944. }
  945. }, queryCommandValue:function (command) {
  946. command = this._normalizeCommand(command);
  947. if (this.object) {
  948. switch (command) {
  949.   case "forecolor":
  950.   case "backcolor":
  951.   case "fontsize":
  952.   case "fontname":
  953. command = "get" + command;
  954. return this.object.execCommand(this._activeX.command[command], this._activeX.ui.noprompt);
  955.   case "formatblock":
  956. var retvalue = this.object.execCommand(this._activeX.command["getblockformat"], this._activeX.ui.noprompt);
  957. if (retvalue) {
  958. return this._local2NativeFormatNames[retvalue];
  959. }
  960. }
  961. } else {
  962. if (dojo.render.html.ie && command == "formatblock") {
  963. return this._local2NativeFormatNames[this.document.queryCommandValue(command)] || this.document.queryCommandValue(command);
  964. }
  965. return this.document.queryCommandValue(command);
  966. }
  967. }, placeCursorAtStart:function () {
  968. this.focus();
  969. if (dojo.render.html.moz && this.editNode.firstChild && this.editNode.firstChild.nodeType != dojo.dom.TEXT_NODE) {
  970. dojo.withGlobal(this.window, "selectElementChildren", dojo.html.selection, [this.editNode.firstChild]);
  971. } else {
  972. dojo.withGlobal(this.window, "selectElementChildren", dojo.html.selection, [this.editNode]);
  973. }
  974. dojo.withGlobal(this.window, "collapse", dojo.html.selection, [true]);
  975. }, placeCursorAtEnd:function () {
  976. this.focus();
  977. if (dojo.render.html.moz && this.editNode.lastChild && this.editNode.lastChild.nodeType != dojo.dom.TEXT_NODE) {
  978. dojo.withGlobal(this.window, "selectElementChildren", dojo.html.selection, [this.editNode.lastChild]);
  979. } else {
  980. dojo.withGlobal(this.window, "selectElementChildren", dojo.html.selection, [this.editNode]);
  981. }
  982. dojo.withGlobal(this.window, "collapse", dojo.html.selection, [false]);
  983. }, replaceEditorContent:function (html) {
  984. html = this._preFilterContent(html);
  985. if (this.isClosed) {
  986. this.domNode.innerHTML = html;
  987. } else {
  988. if (this.window && this.window.getSelection && !dojo.render.html.moz) {
  989. this.editNode.innerHTML = html;
  990. } else {
  991. if ((this.window && this.window.getSelection) || (this.document && this.document.selection)) {
  992. this.execCommand("selectall");
  993. if (dojo.render.html.moz && !html) {
  994. html = "&nbsp;";
  995. }
  996. this.execCommand("inserthtml", html);
  997. }
  998. }
  999. }
  1000. }, _preFilterContent:function (html) {
  1001. var ec = html;
  1002. dojo.lang.forEach(this.contentPreFilters, function (ef) {
  1003. ec = ef(ec);
  1004. });
  1005. if (this.contentDomPreFilters.length > 0) {
  1006. var dom = dojo.doc().createElement("div");
  1007. dom.style.display = "none";
  1008. dojo.body().appendChild(dom);
  1009. dom.innerHTML = ec;
  1010. dojo.lang.forEach(this.contentDomPreFilters, function (ef) {
  1011. dom = ef(dom);
  1012. });
  1013. ec = dom.innerHTML;
  1014. dojo.body().removeChild(dom);
  1015. }
  1016. return ec;
  1017. }, _postFilterContent:function (html) {
  1018. var ec = html;
  1019. if (this.contentDomPostFilters.length > 0) {
  1020. var dom = this.document.createElement("div");
  1021. dom.innerHTML = ec;
  1022. dojo.lang.forEach(this.contentDomPostFilters, function (ef) {
  1023. dom = ef(dom);
  1024. });
  1025. ec = dom.innerHTML;
  1026. }
  1027. dojo.lang.forEach(this.contentPostFilters, function (ef) {
  1028. ec = ef(ec);
  1029. });
  1030. return ec;
  1031. }, _lastHeight:0, _updateHeight:function () {
  1032. if (!this.isLoaded) {
  1033. return;
  1034. }
  1035. if (this.height) {
  1036. return;
  1037. }
  1038. var height = dojo.html.getBorderBox(this.editNode).height;
  1039. if (!height) {
  1040. height = dojo.html.getBorderBox(this.document.body).height;
  1041. }
  1042. if (height == 0) {
  1043. dojo.debug("Can not figure out the height of the editing area!");
  1044. return;
  1045. }
  1046. this._lastHeight = height;
  1047. this.editorObject.style.height = this._lastHeight + "px";
  1048. this.window.scrollTo(0, 0);
  1049. }, _saveContent:function (e) {
  1050. var saveTextarea = dojo.doc().getElementById("dojo.widget.RichText.savedContent");
  1051. saveTextarea.value += this._SEPARATOR + this.saveName + ":" + this.getEditorContent();
  1052. }, getEditorContent:function () {
  1053. var ec = "";
  1054. try {
  1055. ec = (this._content.length > 0) ? this._content : this.editNode.innerHTML;
  1056. if (dojo.string.trim(ec) == "&nbsp;") {
  1057. ec = "";
  1058. }
  1059. }
  1060. catch (e) {
  1061. }
  1062. if (dojo.render.html.ie && !this.object) {
  1063. var re = new RegExp("(?:<p>&nbsp;</p>[nr]*)+$", "i");
  1064. ec = ec.replace(re, "");
  1065. }
  1066. ec = this._postFilterContent(ec);
  1067. if (this.relativeImageUrls) {
  1068. var siteBase = dojo.global().location.protocol + "//" + dojo.global().location.host;
  1069. var pathBase = dojo.global().location.pathname;
  1070. if (pathBase.match(//$/)) {
  1071. } else {
  1072. var pathParts = pathBase.split("/");
  1073. if (pathParts.length) {
  1074. pathParts.pop();
  1075. }
  1076. pathBase = pathParts.join("/") + "/";
  1077. }
  1078. var sameSite = new RegExp("(<img[^>]* src=["'])(" + siteBase + "(" + pathBase + ")?)", "ig");
  1079. ec = ec.replace(sameSite, "$1");
  1080. }
  1081. return ec;
  1082. }, close:function (save, force) {
  1083. if (this.isClosed) {
  1084. return false;
  1085. }
  1086. if (arguments.length == 0) {
  1087. save = true;
  1088. }
  1089. this._content = this._postFilterContent(this.editNode.innerHTML);
  1090. var changed = (this.savedContent != this._content);
  1091. if (this.interval) {
  1092. clearInterval(this.interval);
  1093. }
  1094. if (dojo.render.html.ie && !this.object) {
  1095. dojo.event.browser.clean(this.editNode);
  1096. }
  1097. if (this.iframe) {
  1098. delete this.iframe;
  1099. }
  1100. if (this.textarea) {
  1101. with (this.textarea.style) {
  1102. position = "";
  1103. left = top = "";
  1104. if (dojo.render.html.ie) {
  1105. overflow = this.__overflow;
  1106. this.__overflow = null;
  1107. }
  1108. }
  1109. if (save) {
  1110. this.textarea.value = this._content;
  1111. } else {
  1112. this.textarea.value = this.savedContent;
  1113. }
  1114. dojo.html.removeNode(this.domNode);
  1115. this.domNode = this.textarea;
  1116. } else {
  1117. if (save) {
  1118. if (dojo.render.html.moz) {
  1119. var nc = dojo.doc().createElement("span");
  1120. this.domNode.appendChild(nc);
  1121. nc.innerHTML = this.editNode.innerHTML;
  1122. } else {
  1123. this.domNode.innerHTML = this._content;
  1124. }
  1125. } else {
  1126. this.domNode.innerHTML = this.savedContent;
  1127. }
  1128. }
  1129. dojo.html.removeClass(this.domNode, "RichTextEditable");
  1130. this.isClosed = true;
  1131. this.isLoaded = false;
  1132. delete this.editNode;
  1133. if (this.window._frameElement) {
  1134. this.window._frameElement = null;
  1135. }
  1136. this.window = null;
  1137. this.document = null;
  1138. this.object = null;
  1139. this.editingArea = null;
  1140. this.editorObject = null;
  1141. return changed;
  1142. }, destroyRendering:function () {
  1143. }, destroy:function () {
  1144. this.destroyRendering();
  1145. if (!this.isClosed) {
  1146. this.close(false);
  1147. }
  1148. dojo.widget.RichText.superclass.destroy.call(this);
  1149. }, connect:function (targetObj, targetFunc, thisFunc) {
  1150. dojo.event.connect(targetObj, targetFunc, this, thisFunc);
  1151. }, disconnect:function (targetObj, targetFunc, thisFunc) {
  1152. dojo.event.disconnect(targetObj, targetFunc, this, thisFunc);
  1153. }, disconnectAllWithRoot:function (targetObj) {
  1154. dojo.deprecated("disconnectAllWithRoot", "is deprecated. No need to disconnect manually", "0.5");
  1155. }, _fixContentForMoz:function (html) {
  1156. html = html.replace(/<strong([ >])/gi, "<b$1");
  1157. html = html.replace(/</strong>/gi, "</b>");
  1158. html = html.replace(/<em([ >])/gi, "<i$1");
  1159. html = html.replace(/</em>/gi, "</i>");
  1160. return html;
  1161. }});