topic.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  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. sendXMLDocument.call(this, smf_prepareScriptUrl(this.opt.sScriptUrl) + 'action=quotefast;quote=' + iMessageId + ';modify;xml', this.onMessageReceived);
  198. }
  199. // The callback function used for the XMLhttp request retrieving the message.
  200. QuickModify.prototype.onMessageReceived = function (XMLDoc)
  201. {
  202. var sBodyText = '', sSubjectText = '';
  203. // No longer show the 'loading...' sign.
  204. ajax_indicator(false);
  205. // Grab the message ID.
  206. this.sCurMessageId = XMLDoc.getElementsByTagName('message')[0].getAttribute('id');
  207. // If this is not valid then simply give up.
  208. if (!document.getElementById(this.sCurMessageId))
  209. return this.modifyCancel();
  210. // Replace the body part.
  211. for (var i = 0; i < XMLDoc.getElementsByTagName("message")[0].childNodes.length; i++)
  212. sBodyText += XMLDoc.getElementsByTagName("message")[0].childNodes[i].nodeValue;
  213. this.oCurMessageDiv = document.getElementById(this.sCurMessageId);
  214. this.sMessageBuffer = getInnerHTML(this.oCurMessageDiv);
  215. // We have to force the body to lose its dollar signs thanks to IE.
  216. sBodyText = sBodyText.replace(/\$/g, '{&dollarfix;$}');
  217. // Actually create the content, with a bodge for disappearing dollar signs.
  218. setInnerHTML(this.oCurMessageDiv, this.opt.sTemplateBodyEdit.replace(/%msg_id%/g, this.sCurMessageId.substr(4)).replace(/%body%/, sBodyText).replace(/\{&dollarfix;\$\}/g, '$'));
  219. // Replace the subject part.
  220. this.oCurSubjectDiv = document.getElementById('subject_' + this.sCurMessageId.substr(4));
  221. this.sSubjectBuffer = getInnerHTML(this.oCurSubjectDiv);
  222. sSubjectText = XMLDoc.getElementsByTagName('subject')[0].childNodes[0].nodeValue.replace(/\$/g, '{&dollarfix;$}');
  223. setInnerHTML(this.oCurSubjectDiv, this.opt.sTemplateSubjectEdit.replace(/%subject%/, sSubjectText).replace(/\{&dollarfix;\$\}/g, '$'));
  224. return true;
  225. }
  226. // Function in case the user presses cancel (or other circumstances cause it).
  227. QuickModify.prototype.modifyCancel = function ()
  228. {
  229. // Roll back the HTML to its original state.
  230. if (this.oCurMessageDiv)
  231. {
  232. setInnerHTML(this.oCurMessageDiv, this.sMessageBuffer);
  233. setInnerHTML(this.oCurSubjectDiv, this.sSubjectBuffer);
  234. }
  235. // No longer in edit mode, that's right.
  236. this.bInEditMode = false;
  237. return false;
  238. }
  239. // The function called after a user wants to save his precious message.
  240. QuickModify.prototype.modifySave = function (sSessionId, sSessionVar)
  241. {
  242. // We cannot save if we weren't in edit mode.
  243. if (!this.bInEditMode)
  244. return true;
  245. // Add backwards compatibility with old themes.
  246. if (typeof(sSessionVar) == 'undefined')
  247. sSessionVar = 'sesc';
  248. var i, x = new Array();
  249. x[x.length] = 'subject=' + escape(document.forms.quickModForm['subject'].value.replace(/&#/g, "&#38;#").php_to8bit()).replace(/\+/g, "%2B");
  250. x[x.length] = 'message=' + escape(document.forms.quickModForm['message'].value.replace(/&#/g, "&#38;#").php_to8bit()).replace(/\+/g, "%2B");
  251. x[x.length] = 'topic=' + parseInt(document.forms.quickModForm.elements['topic'].value);
  252. x[x.length] = 'msg=' + parseInt(document.forms.quickModForm.elements['msg'].value);
  253. // Send in the XMLhttp request and let's hope for the best.
  254. ajax_indicator(true);
  255. 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);
  256. return false;
  257. }
  258. // Callback function of the XMLhttp request sending the modified message.
  259. QuickModify.prototype.onModifyDone = function (XMLDoc)
  260. {
  261. // We've finished the loading stuff.
  262. ajax_indicator(false);
  263. // If we didn't get a valid document, just cancel.
  264. if (!XMLDoc || !XMLDoc.getElementsByTagName('smf')[0])
  265. {
  266. // Mozilla will nicely tell us what's wrong.
  267. if (XMLDoc.childNodes.length > 0 && XMLDoc.firstChild.nodeName == 'parsererror')
  268. setInnerHTML(document.getElementById('error_box'), XMLDoc.firstChild.textContent);
  269. else
  270. this.modifyCancel();
  271. return;
  272. }
  273. var message = XMLDoc.getElementsByTagName('smf')[0].getElementsByTagName('message')[0];
  274. var body = message.getElementsByTagName('body')[0];
  275. var error = message.getElementsByTagName('error')[0];
  276. if (body)
  277. {
  278. // Show new body.
  279. var bodyText = '';
  280. for (var i = 0; i < body.childNodes.length; i++)
  281. bodyText += body.childNodes[i].nodeValue;
  282. this.sMessageBuffer = this.opt.sTemplateBodyNormal.replace(/%body%/, bodyText.replace(/\$/g, '{&dollarfix;$}')).replace(/\{&dollarfix;\$\}/g,'$');
  283. setInnerHTML(this.oCurMessageDiv, this.sMessageBuffer);
  284. // Show new subject.
  285. var oSubject = message.getElementsByTagName('subject')[0];
  286. var sSubjectText = oSubject.childNodes[0].nodeValue.replace(/\$/g, '{&dollarfix;$}');
  287. this.sSubjectBuffer = this.opt.sTemplateSubjectNormal.replace(/%msg_id%/g, this.sCurMessageId.substr(4)).replace(/%subject%/, sSubjectText).replace(/\{&dollarfix;\$\}/g,'$');
  288. setInnerHTML(this.oCurSubjectDiv, this.sSubjectBuffer);
  289. // If this is the first message, also update the topic subject.
  290. if (oSubject.getAttribute('is_first') == '1')
  291. setInnerHTML(document.getElementById('top_subject'), this.opt.sTemplateTopSubject.replace(/%subject%/, sSubjectText).replace(/\{&dollarfix;\$\}/g, '$'));
  292. // Show this message as 'modified on x by y'.
  293. if (this.opt.bShowModify)
  294. setInnerHTML(document.getElementById('modified_' + this.sCurMessageId.substr(4)), message.getElementsByTagName('modified')[0].childNodes[0].nodeValue);
  295. }
  296. else if (error)
  297. {
  298. setInnerHTML(document.getElementById('error_box'), error.childNodes[0].nodeValue);
  299. document.forms.quickModForm.message.style.border = error.getAttribute('in_body') == '1' ? this.opt.sErrorBorderStyle : '';
  300. document.forms.quickModForm.subject.style.border = error.getAttribute('in_subject') == '1' ? this.opt.sErrorBorderStyle : '';
  301. }
  302. }
  303. function InTopicModeration(oOptions)
  304. {
  305. this.opt = oOptions;
  306. this.bButtonsShown = false;
  307. this.iNumSelected = 0;
  308. // Add backwards compatibility with old themes.
  309. if (typeof(this.opt.sSessionVar) == 'undefined')
  310. this.opt.sSessionVar = 'sesc';
  311. this.init();
  312. }
  313. InTopicModeration.prototype.init = function()
  314. {
  315. // Add checkboxes to all the messages.
  316. for (var i = 0, n = this.opt.aMessageIds.length; i < n; i++)
  317. {
  318. // Create the checkbox.
  319. var oCheckbox = document.createElement('input');
  320. oCheckbox.type = 'checkbox';
  321. oCheckbox.className = 'input_check';
  322. oCheckbox.name = 'msgs[]';
  323. oCheckbox.value = this.opt.aMessageIds[i];
  324. oCheckbox.instanceRef = this;
  325. oCheckbox.onclick = function () {
  326. this.instanceRef.handleClick(this);
  327. }
  328. // Append it to the container
  329. var oCheckboxContainer = document.getElementById(this.opt.sCheckboxContainerMask + this.opt.aMessageIds[i]);
  330. oCheckboxContainer.appendChild(oCheckbox);
  331. oCheckboxContainer.style.display = '';
  332. }
  333. }
  334. InTopicModeration.prototype.handleClick = function(oCheckbox)
  335. {
  336. if (!this.bButtonsShown && this.opt.sButtonStripDisplay)
  337. {
  338. var oButtonStrip = document.getElementById(this.opt.sButtonStrip);
  339. var oButtonStripDisplay = document.getElementById(this.opt.sButtonStripDisplay);
  340. // Make sure it can go somewhere.
  341. if (typeof(oButtonStripDisplay) == 'object' && oButtonStripDisplay != null)
  342. oButtonStripDisplay.style.display = "";
  343. else
  344. {
  345. var oNewDiv = document.createElement('div');
  346. var oNewList = document.createElement('ul');
  347. oNewDiv.id = this.opt.sButtonStripDisplay;
  348. oNewDiv.className = this.opt.sButtonStripClass ? this.opt.sButtonStripClass : 'buttonlist floatbottom';
  349. oNewDiv.appendChild(oNewList);
  350. oButtonStrip.appendChild(oNewDiv);
  351. }
  352. // Add the 'remove selected items' button.
  353. if (this.opt.bCanRemove)
  354. smf_addButton(this.opt.sButtonStrip, this.opt.bUseImageButton, {
  355. sId: this.opt.sSelf + '_remove_button',
  356. sText: this.opt.sRemoveButtonLabel,
  357. sImage: this.opt.sRemoveButtonImage,
  358. sUrl: '#',
  359. sCustom: ' onclick="return ' + this.opt.sSelf + '.handleSubmit(\'remove\')"'
  360. });
  361. // Add the 'restore selected items' button.
  362. if (this.opt.bCanRestore)
  363. smf_addButton(this.opt.sButtonStrip, this.opt.bUseImageButton, {
  364. sId: this.opt.sSelf + '_restore_button',
  365. sText: this.opt.sRestoreButtonLabel,
  366. sImage: this.opt.sRestoreButtonImage,
  367. sUrl: '#',
  368. sCustom: ' onclick="return ' + this.opt.sSelf + '.handleSubmit(\'restore\')"'
  369. });
  370. // Add the 'split selected items' button.
  371. if (this.opt.bCanSplit)
  372. smf_addButton(this.opt.sButtonStrip, this.opt.bUseImageButton, {
  373. sId: this.opt.sSelf + '_split_button',
  374. sText: this.opt.sSplitButtonLabel,
  375. sImage: this.opt.sSplitButtonImage,
  376. sUrl: '#',
  377. sCustom: ' onclick="return ' + this.opt.sSelf + '.handleSubmit(\'split\')"'
  378. });
  379. // Adding these buttons once should be enough.
  380. this.bButtonsShown = true;
  381. }
  382. // Keep stats on how many items were selected.
  383. this.iNumSelected += oCheckbox.checked ? 1 : -1;
  384. // Show the number of messages selected in the button.
  385. if (this.opt.bCanRemove && !this.opt.bUseImageButton)
  386. {
  387. setInnerHTML(document.getElementById(this.opt.sSelf + '_remove_button'), this.opt.sRemoveButtonLabel + ' [' + this.iNumSelected + ']');
  388. document.getElementById(this.opt.sSelf + '_remove_button').style.display = this.iNumSelected < 1 ? "none" : "";
  389. }
  390. if (this.opt.bCanRestore && !this.opt.bUseImageButton)
  391. {
  392. setInnerHTML(document.getElementById(this.opt.sSelf + '_restore_button'), this.opt.sRestoreButtonLabel + ' [' + this.iNumSelected + ']');
  393. document.getElementById(this.opt.sSelf + '_restore_button').style.display = this.iNumSelected < 1 ? "none" : "";
  394. }
  395. if (this.opt.bCanSplit && !this.opt.bUseImageButton)
  396. {
  397. setInnerHTML(document.getElementById(this.opt.sSelf + '_split_button'), this.opt.sSplitButtonLabel + ' [' + this.iNumSelected + ']');
  398. document.getElementById(this.opt.sSelf + '_split_button').style.display = this.iNumSelected < 1 ? "none" : "";
  399. }
  400. // Try to restore the correct position.
  401. var aItems = document.getElementById(this.opt.sButtonStrip).getElementsByTagName('span');
  402. if (aItems.length > 3)
  403. {
  404. if (this.iNumSelected < 1)
  405. {
  406. aItems[aItems.length - 3].className = aItems[aItems.length - 3].className.replace(/\s*position_holder/, 'last');
  407. aItems[aItems.length - 2].className = aItems[aItems.length - 2].className.replace(/\s*position_holder/, 'last');
  408. }
  409. else
  410. {
  411. aItems[aItems.length - 2].className = aItems[aItems.length - 2].className.replace(/\s*last/, 'position_holder');
  412. aItems[aItems.length - 3].className = aItems[aItems.length - 3].className.replace(/\s*last/, 'position_holder');
  413. }
  414. }
  415. }
  416. InTopicModeration.prototype.handleSubmit = function (sSubmitType)
  417. {
  418. var oForm = document.getElementById(this.opt.sFormId);
  419. // Make sure this form isn't submitted in another way than this function.
  420. var oInput = document.createElement('input');
  421. oInput.type = 'hidden';
  422. oInput.name = this.opt.sSessionVar;
  423. oInput.value = this.opt.sSessionId;
  424. oForm.appendChild(oInput);
  425. switch (sSubmitType)
  426. {
  427. case 'remove':
  428. if (!confirm(this.opt.sRemoveButtonConfirm))
  429. return false;
  430. oForm.action = oForm.action.replace(/;split_selection=1/, '');
  431. oForm.action = oForm.action.replace(/;restore_selected=1/, '');
  432. break;
  433. case 'restore':
  434. if (!confirm(this.opt.sRestoreButtonConfirm))
  435. return false;
  436. oForm.action = oForm.action.replace(/;split_selection=1/, '');
  437. oForm.action = oForm.action + ';restore_selected=1';
  438. break;
  439. case 'split':
  440. if (!confirm(this.opt.sRestoreButtonConfirm))
  441. return false;
  442. oForm.action = oForm.action.replace(/;restore_selected=1/, '');
  443. oForm.action = oForm.action + ';split_selection=1';
  444. break;
  445. default:
  446. return false;
  447. break;
  448. }
  449. oForm.submit();
  450. return true;
  451. }
  452. // *** Other functions...
  453. function expandThumb(thumbID)
  454. {
  455. var img = document.getElementById('thumb_' + thumbID);
  456. var link = document.getElementById('link_' + thumbID);
  457. // save the currently displayed image attributes
  458. var tmp_src = img.src;
  459. var tmp_height = img.style.height;
  460. var tmp_width = img.style.width;
  461. // set the displayed image attributes to the link attributes, this will expand in place
  462. img.src = link.href;
  463. img.style.width = link.style.width;
  464. img.style.height = link.style.height;
  465. // place the image attributes back
  466. link.href = tmp_src;
  467. link.style.width = tmp_width;
  468. link.style.height = tmp_height;
  469. return false;
  470. }
  471. // For templating, shown when an inline edit is made.
  472. function modify_topic_show_edit(subject)
  473. {
  474. // Just template the subject.
  475. 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) + '" />');
  476. }
  477. function modify_topic_click()
  478. {
  479. if (in_edit_mode == 1 && mouse_on_div == 0)
  480. modify_topic_save(smf_sesion_id, smf_session_var);
  481. }
  482. function modify_topic_keypress(oEvent)
  483. {
  484. if (typeof(oEvent.keyCode) != "undefined" && oEvent.keyCode == 13)
  485. {
  486. modify_topic_save(smf_sesion_id, smf_session_var);
  487. if (typeof(oEvent.preventDefault) == "undefined")
  488. oEvent.returnValue = false;
  489. else
  490. oEvent.preventDefault();
  491. }
  492. }
  493. // And the reverse for hiding it.
  494. function modify_topic_hide_edit(subject)
  495. {
  496. // Re-template the subject!
  497. setInnerHTML(cur_subject_div, '<a href="' + smf_scripturl + '?topic=' + cur_topic_id + '.0">' + subject + '<' +'/a>');
  498. }
  499. function ignore_toggles(msgids, text)
  500. {
  501. for (i = 0; i < msgids.length; i++)
  502. {
  503. var msgid = msgids[i];
  504. new smc_Toggle({
  505. bToggleEnabled: true,
  506. bCurrentlyCollapsed: true,
  507. aSwappableContainers: [
  508. 'msg_' + msgid + '_extra_info',
  509. 'msg_' + msgid,
  510. 'msg_' + msgid + '_footer',
  511. 'msg_' + msgid + '_quick_mod',
  512. 'modify_button_' + msgid,
  513. 'msg_' + msgid + '_signature'
  514. ],
  515. aSwapLinks: [
  516. {
  517. sId: 'msg_' + msgid + '_ignored_link',
  518. msgExpanded: '',
  519. msgCollapsed: text
  520. }
  521. ]
  522. });
  523. }
  524. }