topic.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. var cur_topic_id, cur_msg_id, buff_subject, cur_subject_div, in_edit_mode = 0;
  2. var hide_prefixes = Array();
  3. function modify_topic(topic_id, first_msg_id)
  4. {
  5. if (!('XMLHttpRequest' in window))
  6. return;
  7. if ('opera' in window)
  8. {
  9. var oTest = new XMLHttpRequest();
  10. if (!('setRequestHeader' in oTest))
  11. return;
  12. }
  13. // Add backwards compatibility with old themes.
  14. if (typeof(cur_session_var) == 'undefined')
  15. cur_session_var = 'sesc';
  16. if (in_edit_mode == 1)
  17. {
  18. if (cur_topic_id == topic_id)
  19. return;
  20. else
  21. modify_topic_cancel();
  22. }
  23. in_edit_mode = 1;
  24. mouse_on_div = 1;
  25. cur_topic_id = topic_id;
  26. if (typeof window.ajax_indicator == "function")
  27. ajax_indicator(true);
  28. getXMLDocument(smf_prepareScriptUrl(smf_scripturl) + "action=quotefast;quote=" + first_msg_id + ";modify;xml", onDocReceived_modify_topic);
  29. }
  30. function onDocReceived_modify_topic(XMLDoc)
  31. {
  32. cur_msg_id = XMLDoc.getElementsByTagName("message")[0].getAttribute("id");
  33. cur_subject_div = document.getElementById('msg_' + cur_msg_id.substr(4));
  34. buff_subject = getInnerHTML(cur_subject_div);
  35. // Here we hide any other things they want hiding on edit.
  36. set_hidden_topic_areas('none');
  37. modify_topic_show_edit(XMLDoc.getElementsByTagName("subject")[0].childNodes[0].nodeValue);
  38. if (typeof window.ajax_indicator == "function")
  39. ajax_indicator(false);
  40. }
  41. function modify_topic_cancel()
  42. {
  43. setInnerHTML(cur_subject_div, buff_subject);
  44. set_hidden_topic_areas('');
  45. in_edit_mode = 0;
  46. return false;
  47. }
  48. function modify_topic_save(cur_session_id, cur_session_var)
  49. {
  50. if (!in_edit_mode)
  51. return true;
  52. // Add backwards compatibility with old themes.
  53. if (typeof(cur_session_var) == 'undefined')
  54. cur_session_var = 'sesc';
  55. var i, x = new Array();
  56. x[x.length] = 'subject=' + document.forms.quickModForm['subject'].value.replace(/&#/g, "&#").php_to8bit().php_urlencode();
  57. x[x.length] = 'topic=' + parseInt(document.forms.quickModForm.elements['topic'].value);
  58. x[x.length] = 'msg=' + parseInt(document.forms.quickModForm.elements['msg'].value);
  59. if (typeof window.ajax_indicator == "function")
  60. ajax_indicator(true);
  61. sendXMLDocument(smf_prepareScriptUrl(smf_scripturl) + "action=jsmodify;topic=" + parseInt(document.forms.quickModForm.elements['topic'].value) + ";" + cur_session_var + "=" + cur_session_id + ";xml", x.join("&"), modify_topic_done);
  62. return false;
  63. }
  64. function modify_topic_done(XMLDoc)
  65. {
  66. if (!XMLDoc)
  67. {
  68. modify_topic_cancel();
  69. return true;
  70. }
  71. var message = XMLDoc.getElementsByTagName("smf")[0].getElementsByTagName("message")[0];
  72. var subject = message.getElementsByTagName("subject")[0];
  73. var error = message.getElementsByTagName("error")[0];
  74. if (typeof window.ajax_indicator == "function")
  75. ajax_indicator(false);
  76. if (!subject || error)
  77. return false;
  78. subjectText = subject.childNodes[0].nodeValue;
  79. modify_topic_hide_edit(subjectText);
  80. set_hidden_topic_areas('');
  81. in_edit_mode = 0;
  82. return false;
  83. }
  84. // Simply restore any hidden bits during topic editing.
  85. function set_hidden_topic_areas(set_style)
  86. {
  87. for (var i = 0; i < hide_prefixes.length; i++)
  88. {
  89. if (document.getElementById(hide_prefixes[i] + cur_msg_id.substr(4)) != null)
  90. document.getElementById(hide_prefixes[i] + cur_msg_id.substr(4)).style.display = set_style;
  91. }
  92. }
  93. // *** QuickReply object.
  94. function QuickReply(oOptions)
  95. {
  96. this.opt = oOptions;
  97. this.bCollapsed = this.opt.bDefaultCollapsed;
  98. this.bIsFull = this.opt.bIsFull;
  99. }
  100. // When a user presses quote, put it in the quick reply box (if expanded).
  101. QuickReply.prototype.quote = function (iMessageId, xDeprecated)
  102. {
  103. // Compatibility with older templates.
  104. if (typeof(xDeprecated) != 'undefined')
  105. return true;
  106. if (this.bCollapsed)
  107. {
  108. window.location.href = smf_prepareScriptUrl(this.opt.sScriptUrl) + 'action=post;quote=' + iMessageId + ';topic=' + this.opt.iTopicId + '.' + this.opt.iStart;
  109. return false;
  110. }
  111. else
  112. {
  113. // Doing it the XMLhttp way?
  114. if (window.XMLHttpRequest)
  115. {
  116. ajax_indicator(true);
  117. if (this.bIsFull)
  118. insertQuoteFast(iMessageId);
  119. else
  120. getXMLDocument(smf_prepareScriptUrl(this.opt.sScriptUrl) + 'action=quotefast;quote=' + iMessageId + ';xml', this.onQuoteReceived);
  121. }
  122. // Or with a smart popup!
  123. else
  124. reqWin(smf_prepareScriptUrl(this.opt.sScriptUrl) + 'action=quotefast;quote=' + iMessageId, 240, 90);
  125. // Move the view to the quick reply box.
  126. if (navigator.appName == 'Microsoft Internet Explorer')
  127. window.location.hash = this.opt.sJumpAnchor;
  128. else
  129. window.location.hash = '#' + this.opt.sJumpAnchor;
  130. return false;
  131. }
  132. }
  133. // This is the callback function used after the XMLhttp request.
  134. QuickReply.prototype.onQuoteReceived = function (oXMLDoc)
  135. {
  136. var sQuoteText = '';
  137. for (var i = 0; i < oXMLDoc.getElementsByTagName('quote')[0].childNodes.length; i++)
  138. sQuoteText += oXMLDoc.getElementsByTagName('quote')[0].childNodes[i].nodeValue;
  139. replaceText(sQuoteText, document.forms.postmodify.message);
  140. ajax_indicator(false);
  141. }
  142. // The function handling the swapping of the quick reply.
  143. QuickReply.prototype.swap = function ()
  144. {
  145. document.getElementById(this.opt.sImageId).src = this.opt.sImagesUrl + "/" + (this.bCollapsed ? this.opt.sImageCollapsed : this.opt.sImageExpanded);
  146. $('#' + this.opt.sContainerId).slideToggle();
  147. this.bCollapsed = !this.bCollapsed;
  148. }
  149. // *** QuickModify object.
  150. function QuickModify(oOptions)
  151. {
  152. this.opt = oOptions;
  153. this.bInEditMode = false;
  154. this.sCurMessageId = '';
  155. this.oCurMessageDiv = null;
  156. this.oCurSubjectDiv = null;
  157. this.sMessageBuffer = '';
  158. this.sSubjectBuffer = '';
  159. this.bXmlHttpCapable = this.isXmlHttpCapable();
  160. // Show the edit buttons
  161. if (this.bXmlHttpCapable)
  162. {
  163. for (var i = document.images.length - 1; i >= 0; i--)
  164. if (document.images[i].id.substr(0, 14) == 'modify_button_')
  165. document.images[i].style.display = '';
  166. }
  167. }
  168. // Determine whether the quick modify can actually be used.
  169. QuickModify.prototype.isXmlHttpCapable = function ()
  170. {
  171. if (typeof(window.XMLHttpRequest) == 'undefined')
  172. return false;
  173. // Opera didn't always support POST requests. So test it first.
  174. if ('opera' in window)
  175. {
  176. var oTest = new XMLHttpRequest();
  177. if (!('setRequestHeader' in oTest))
  178. return false;
  179. }
  180. return true;
  181. }
  182. // Function called when a user presses the edit button.
  183. QuickModify.prototype.modifyMsg = function (iMessageId)
  184. {
  185. if (!this.bXmlHttpCapable)
  186. return;
  187. // Add backwards compatibility with old themes.
  188. if (typeof(sSessionVar) == 'undefined')
  189. sSessionVar = 'sesc';
  190. // First cancel if there's another message still being edited.
  191. if (this.bInEditMode)
  192. this.modifyCancel();
  193. // At least NOW we're in edit mode
  194. this.bInEditMode = true;
  195. // Send out the XMLhttp request to get more info
  196. ajax_indicator(true);
  197. // For IE 5.0 support, 'call' is not yet used.
  198. this.tmpMethod = getXMLDocument;
  199. this.tmpMethod(smf_prepareScriptUrl(this.opt.sScriptUrl) + 'action=quotefast;quote=' + iMessageId + ';modify;xml', this.onMessageReceived);
  200. delete this.tmpMethod;
  201. }
  202. // The callback function used for the XMLhttp request retrieving the message.
  203. QuickModify.prototype.onMessageReceived = function (XMLDoc)
  204. {
  205. var sBodyText = '', sSubjectText = '';
  206. // No longer show the 'loading...' sign.
  207. ajax_indicator(false);
  208. // Grab the message ID.
  209. this.sCurMessageId = XMLDoc.getElementsByTagName('message')[0].getAttribute('id');
  210. // If this is not valid then simply give up.
  211. if (!document.getElementById(this.sCurMessageId))
  212. return this.modifyCancel();
  213. // Replace the body part.
  214. for (var i = 0; i < XMLDoc.getElementsByTagName("message")[0].childNodes.length; i++)
  215. sBodyText += XMLDoc.getElementsByTagName("message")[0].childNodes[i].nodeValue;
  216. this.oCurMessageDiv = document.getElementById(this.sCurMessageId);
  217. this.sMessageBuffer = getInnerHTML(this.oCurMessageDiv);
  218. // We have to force the body to lose its dollar signs thanks to IE.
  219. sBodyText = sBodyText.replace(/\$/g, '{&dollarfix;$}');
  220. // Actually create the content, with a bodge for disappearing dollar signs.
  221. setInnerHTML(this.oCurMessageDiv, this.opt.sTemplateBodyEdit.replace(/%msg_id%/g, this.sCurMessageId.substr(4)).replace(/%body%/, sBodyText).replace(/\{&dollarfix;\$\}/g, '$'));
  222. // Replace the subject part.
  223. this.oCurSubjectDiv = document.getElementById('subject_' + this.sCurMessageId.substr(4));
  224. this.sSubjectBuffer = getInnerHTML(this.oCurSubjectDiv);
  225. sSubjectText = XMLDoc.getElementsByTagName('subject')[0].childNodes[0].nodeValue.replace(/\$/g, '{&dollarfix;$}');
  226. setInnerHTML(this.oCurSubjectDiv, this.opt.sTemplateSubjectEdit.replace(/%subject%/, sSubjectText).replace(/\{&dollarfix;\$\}/g, '$'));
  227. return true;
  228. }
  229. // Function in case the user presses cancel (or other circumstances cause it).
  230. QuickModify.prototype.modifyCancel = function ()
  231. {
  232. // Roll back the HTML to its original state.
  233. if (this.oCurMessageDiv)
  234. {
  235. setInnerHTML(this.oCurMessageDiv, this.sMessageBuffer);
  236. setInnerHTML(this.oCurSubjectDiv, this.sSubjectBuffer);
  237. }
  238. // No longer in edit mode, that's right.
  239. this.bInEditMode = false;
  240. return false;
  241. }
  242. // The function called after a user wants to save his precious message.
  243. QuickModify.prototype.modifySave = function (sSessionId, sSessionVar)
  244. {
  245. // We cannot save if we weren't in edit mode.
  246. if (!this.bInEditMode)
  247. return true;
  248. // Add backwards compatibility with old themes.
  249. if (typeof(sSessionVar) == 'undefined')
  250. sSessionVar = 'sesc';
  251. var i, x = new Array();
  252. x[x.length] = 'subject=' + escape(document.forms.quickModForm['subject'].value.replace(/&#/g, "&#38;#").php_to8bit()).replace(/\+/g, "%2B");
  253. x[x.length] = 'message=' + escape(document.forms.quickModForm['message'].value.replace(/&#/g, "&#38;#").php_to8bit()).replace(/\+/g, "%2B");
  254. x[x.length] = 'topic=' + parseInt(document.forms.quickModForm.elements['topic'].value);
  255. x[x.length] = 'msg=' + parseInt(document.forms.quickModForm.elements['msg'].value);
  256. // Send in the XMLhttp request and let's hope for the best.
  257. ajax_indicator(true);
  258. sendXMLDocument.call(this, smf_prepareScriptUrl(this.opt.sScriptUrl) + "action=jsmodify;topic=" + this.opt.iTopicId + ";" + smf_session_var + "=" + smf_session_id + ";xml", x.join("&"), this.onModifyDone);
  259. return false;
  260. }
  261. // Callback function of the XMLhttp request sending the modified message.
  262. QuickModify.prototype.onModifyDone = function (XMLDoc)
  263. {
  264. // We've finished the loading stuff.
  265. ajax_indicator(false);
  266. // If we didn't get a valid document, just cancel.
  267. if (!XMLDoc || !XMLDoc.getElementsByTagName('smf')[0])
  268. {
  269. // Mozilla will nicely tell us what's wrong.
  270. if (XMLDoc.childNodes.length > 0 && XMLDoc.firstChild.nodeName == 'parsererror')
  271. setInnerHTML(document.getElementById('error_box'), XMLDoc.firstChild.textContent);
  272. else
  273. this.modifyCancel();
  274. return;
  275. }
  276. var message = XMLDoc.getElementsByTagName('smf')[0].getElementsByTagName('message')[0];
  277. var body = message.getElementsByTagName('body')[0];
  278. var error = message.getElementsByTagName('error')[0];
  279. if (body)
  280. {
  281. // Show new body.
  282. var bodyText = '';
  283. for (var i = 0; i < body.childNodes.length; i++)
  284. bodyText += body.childNodes[i].nodeValue;
  285. this.sMessageBuffer = this.opt.sTemplateBodyNormal.replace(/%body%/, bodyText.replace(/\$/g, '{&dollarfix;$}')).replace(/\{&dollarfix;\$\}/g,'$');
  286. setInnerHTML(this.oCurMessageDiv, this.sMessageBuffer);
  287. // Show new subject.
  288. var oSubject = message.getElementsByTagName('subject')[0];
  289. var sSubjectText = oSubject.childNodes[0].nodeValue.replace(/\$/g, '{&dollarfix;$}');
  290. this.sSubjectBuffer = this.opt.sTemplateSubjectNormal.replace(/%msg_id%/g, this.sCurMessageId.substr(4)).replace(/%subject%/, sSubjectText).replace(/\{&dollarfix;\$\}/g,'$');
  291. setInnerHTML(this.oCurSubjectDiv, this.sSubjectBuffer);
  292. // If this is the first message, also update the topic subject.
  293. if (oSubject.getAttribute('is_first') == '1')
  294. setInnerHTML(document.getElementById('top_subject'), this.opt.sTemplateTopSubject.replace(/%subject%/, sSubjectText).replace(/\{&dollarfix;\$\}/g, '$'));
  295. // Show this message as 'modified on x by y'.
  296. if (this.opt.bShowModify)
  297. setInnerHTML(document.getElementById('modified_' + this.sCurMessageId.substr(4)), message.getElementsByTagName('modified')[0].childNodes[0].nodeValue);
  298. }
  299. else if (error)
  300. {
  301. setInnerHTML(document.getElementById('error_box'), error.childNodes[0].nodeValue);
  302. document.forms.quickModForm.message.style.border = error.getAttribute('in_body') == '1' ? this.opt.sErrorBorderStyle : '';
  303. document.forms.quickModForm.subject.style.border = error.getAttribute('in_subject') == '1' ? this.opt.sErrorBorderStyle : '';
  304. }
  305. }
  306. function InTopicModeration(oOptions)
  307. {
  308. this.opt = oOptions;
  309. this.bButtonsShown = false;
  310. this.iNumSelected = 0;
  311. // Add backwards compatibility with old themes.
  312. if (typeof(this.opt.sSessionVar) == 'undefined')
  313. this.opt.sSessionVar = 'sesc';
  314. this.init();
  315. }
  316. InTopicModeration.prototype.init = function()
  317. {
  318. // Add checkboxes to all the messages.
  319. for (var i = 0, n = this.opt.aMessageIds.length; i < n; i++)
  320. {
  321. // Create the checkbox.
  322. var oCheckbox = document.createElement('input');
  323. oCheckbox.type = 'checkbox';
  324. oCheckbox.className = 'input_check';
  325. oCheckbox.name = 'msgs[]';
  326. oCheckbox.value = this.opt.aMessageIds[i];
  327. oCheckbox.instanceRef = this;
  328. oCheckbox.onclick = function () {
  329. this.instanceRef.handleClick(this);
  330. }
  331. // Append it to the container
  332. var oCheckboxContainer = document.getElementById(this.opt.sCheckboxContainerMask + this.opt.aMessageIds[i]);
  333. oCheckboxContainer.appendChild(oCheckbox);
  334. oCheckboxContainer.style.display = '';
  335. }
  336. }
  337. InTopicModeration.prototype.handleClick = function(oCheckbox)
  338. {
  339. if (!this.bButtonsShown && this.opt.sButtonStripDisplay)
  340. {
  341. var oButtonStrip = document.getElementById(this.opt.sButtonStrip);
  342. var oButtonStripDisplay = document.getElementById(this.opt.sButtonStripDisplay);
  343. // Make sure it can go somewhere.
  344. if (typeof(oButtonStripDisplay) == 'object' && oButtonStripDisplay != null)
  345. oButtonStripDisplay.style.display = "";
  346. else
  347. {
  348. var oNewDiv = document.createElement('div');
  349. var oNewList = document.createElement('ul');
  350. oNewDiv.id = this.opt.sButtonStripDisplay;
  351. oNewDiv.className = this.opt.sButtonStripClass ? this.opt.sButtonStripClass : 'buttonlist floatbottom';
  352. oNewDiv.appendChild(oNewList);
  353. oButtonStrip.appendChild(oNewDiv);
  354. }
  355. // Add the 'remove selected items' button.
  356. if (this.opt.bCanRemove)
  357. smf_addButton(this.opt.sButtonStrip, this.opt.bUseImageButton, {
  358. sId: this.opt.sSelf + '_remove_button',
  359. sText: this.opt.sRemoveButtonLabel,
  360. sImage: this.opt.sRemoveButtonImage,
  361. sUrl: '#',
  362. sCustom: ' onclick="return ' + this.opt.sSelf + '.handleSubmit(\'remove\')"'
  363. });
  364. // Add the 'restore selected items' button.
  365. if (this.opt.bCanRestore)
  366. smf_addButton(this.opt.sButtonStrip, this.opt.bUseImageButton, {
  367. sId: this.opt.sSelf + '_restore_button',
  368. sText: this.opt.sRestoreButtonLabel,
  369. sImage: this.opt.sRestoreButtonImage,
  370. sUrl: '#',
  371. sCustom: ' onclick="return ' + this.opt.sSelf + '.handleSubmit(\'restore\')"'
  372. });
  373. // Add the 'split selected items' button.
  374. if (this.opt.bCanSplit)
  375. smf_addButton(this.opt.sButtonStrip, this.opt.bUseImageButton, {
  376. sId: this.opt.sSelf + '_split_button',
  377. sText: this.opt.sSplitButtonLabel,
  378. sImage: this.opt.sSplitButtonImage,
  379. sUrl: '#',
  380. sCustom: ' onclick="return ' + this.opt.sSelf + '.handleSubmit(\'split\')"'
  381. });
  382. // Adding these buttons once should be enough.
  383. this.bButtonsShown = true;
  384. }
  385. // Keep stats on how many items were selected.
  386. this.iNumSelected += oCheckbox.checked ? 1 : -1;
  387. // Show the number of messages selected in the button.
  388. if (this.opt.bCanRemove && !this.opt.bUseImageButton)
  389. {
  390. setInnerHTML(document.getElementById(this.opt.sSelf + '_remove_button'), this.opt.sRemoveButtonLabel + ' [' + this.iNumSelected + ']');
  391. document.getElementById(this.opt.sSelf + '_remove_button').style.display = this.iNumSelected < 1 ? "none" : "";
  392. }
  393. if (this.opt.bCanRestore && !this.opt.bUseImageButton)
  394. {
  395. setInnerHTML(document.getElementById(this.opt.sSelf + '_restore_button'), this.opt.sRestoreButtonLabel + ' [' + this.iNumSelected + ']');
  396. document.getElementById(this.opt.sSelf + '_restore_button').style.display = this.iNumSelected < 1 ? "none" : "";
  397. }
  398. if (this.opt.bCanSplit && !this.opt.bUseImageButton)
  399. {
  400. setInnerHTML(document.getElementById(this.opt.sSelf + '_split_button'), this.opt.sSplitButtonLabel + ' [' + this.iNumSelected + ']');
  401. document.getElementById(this.opt.sSelf + '_split_button').style.display = this.iNumSelected < 1 ? "none" : "";
  402. }
  403. // Try to restore the correct position.
  404. var aItems = document.getElementById(this.opt.sButtonStrip).getElementsByTagName('span');
  405. if (aItems.length > 3)
  406. {
  407. if (this.iNumSelected < 1)
  408. {
  409. aItems[aItems.length - 3].className = aItems[aItems.length - 3].className.replace(/\s*position_holder/, 'last');
  410. aItems[aItems.length - 2].className = aItems[aItems.length - 2].className.replace(/\s*position_holder/, 'last');
  411. }
  412. else
  413. {
  414. aItems[aItems.length - 2].className = aItems[aItems.length - 2].className.replace(/\s*last/, 'position_holder');
  415. aItems[aItems.length - 3].className = aItems[aItems.length - 3].className.replace(/\s*last/, 'position_holder');
  416. }
  417. }
  418. }
  419. InTopicModeration.prototype.handleSubmit = function (sSubmitType)
  420. {
  421. var oForm = document.getElementById(this.opt.sFormId);
  422. // Make sure this form isn't submitted in another way than this function.
  423. var oInput = document.createElement('input');
  424. oInput.type = 'hidden';
  425. oInput.name = this.opt.sSessionVar;
  426. oInput.value = this.opt.sSessionId;
  427. oForm.appendChild(oInput);
  428. switch (sSubmitType)
  429. {
  430. case 'remove':
  431. if (!confirm(this.opt.sRemoveButtonConfirm))
  432. return false;
  433. oForm.action = oForm.action.replace(/;split_selection=1/, '');
  434. oForm.action = oForm.action.replace(/;restore_selected=1/, '');
  435. break;
  436. case 'restore':
  437. if (!confirm(this.opt.sRestoreButtonConfirm))
  438. return false;
  439. oForm.action = oForm.action.replace(/;split_selection=1/, '');
  440. oForm.action = oForm.action + ';restore_selected=1';
  441. break;
  442. case 'split':
  443. if (!confirm(this.opt.sRestoreButtonConfirm))
  444. return false;
  445. oForm.action = oForm.action.replace(/;restore_selected=1/, '');
  446. oForm.action = oForm.action + ';split_selection=1';
  447. break;
  448. default:
  449. return false;
  450. break;
  451. }
  452. oForm.submit();
  453. return true;
  454. }
  455. // *** Other functions...
  456. function expandThumb(thumbID)
  457. {
  458. var img = document.getElementById('thumb_' + thumbID);
  459. var link = document.getElementById('link_' + thumbID);
  460. // save the currently displayed image attributes
  461. var tmp_src = img.src;
  462. var tmp_height = img.style.height;
  463. var tmp_width = img.style.width;
  464. // set the displayed image attributes to the link attributes, this will expand in place
  465. img.src = link.href;
  466. img.style.width = link.style.width;
  467. img.style.height = link.style.height;
  468. // place the image attributes back
  469. link.href = tmp_src;
  470. link.style.width = tmp_width;
  471. link.style.height = tmp_height;
  472. return false;
  473. }
  474. // For templating, shown when an inline edit is made.
  475. function modify_topic_show_edit(subject)
  476. {
  477. // Just template the subject.
  478. setInnerHTML(cur_subject_div, '<input type="text" name="subject" value="' + subject + '" size="60" style="width: 95%;" maxlength="80" onkeypress="modify_topic_keypress(event)" class="input_text" /><input type="hidden" name="topic" value="' + cur_topic_id + '" /><input type="hidden" name="msg" value="' + cur_msg_id.substr(4) + '" />');
  479. }
  480. function modify_topic_click()
  481. {
  482. if (in_edit_mode == 1 && mouse_on_div == 0)
  483. modify_topic_save(smf_sesion_id, smf_session_var);
  484. }
  485. function modify_topic_keypress(oEvent)
  486. {
  487. if (typeof(oEvent.keyCode) != "undefined" && oEvent.keyCode == 13)
  488. {
  489. modify_topic_save(smf_sesion_id, smf_session_var);
  490. if (typeof(oEvent.preventDefault) == "undefined")
  491. oEvent.returnValue = false;
  492. else
  493. oEvent.preventDefault();
  494. }
  495. }
  496. // And the reverse for hiding it.
  497. function modify_topic_hide_edit(subject)
  498. {
  499. // Re-template the subject!
  500. setInnerHTML(cur_subject_div, '<a href="' + smf_scripturl + '?topic=' + cur_topic_id + '.0">' + subject + '<' +'/a>');
  501. }