|
@@ -1,66 +1,134 @@
|
|
-var cur_topic_id, cur_msg_id, buff_subject, cur_subject_div, in_edit_mode = 0;
|
|
+
|
|
-var hide_prefixes = Array();
|
|
+function QuickModifyTopic(oOptions)
|
|
|
|
+{
|
|
|
|
+ this.opt = oOptions;
|
|
|
|
+ this.aHidePrefixes = this.opt.aHidePrefixes;
|
|
|
|
+ this.iCurTopicId = 0;
|
|
|
|
+ this.sCurMessageId = '';
|
|
|
|
+ this.sBuffSubject = '';
|
|
|
|
+ this.oCurSubjectDiv = null;
|
|
|
|
+ this.oTopicModHandle = document;
|
|
|
|
+ this.bInEditMode = false;
|
|
|
|
+ this.bMouseOnDiv = false;
|
|
|
|
+ this.bXmlHttpCapable = this.isXmlHttpCapable();
|
|
|
|
+ this.init();
|
|
|
|
+}
|
|
|
|
|
|
-function modify_topic(topic_id, first_msg_id)
|
|
+
|
|
|
|
+
|
|
|
|
+QuickModifyTopic.prototype.isXmlHttpCapable = function ()
|
|
{
|
|
{
|
|
- if (!('XMLHttpRequest' in window))
|
|
+ if (typeof(window.XMLHttpRequest) == 'undefined')
|
|
- return;
|
|
+ return false;
|
|
|
|
|
|
|
|
+
|
|
if ('opera' in window)
|
|
if ('opera' in window)
|
|
{
|
|
{
|
|
var oTest = new XMLHttpRequest();
|
|
var oTest = new XMLHttpRequest();
|
|
if (!('setRequestHeader' in oTest))
|
|
if (!('setRequestHeader' in oTest))
|
|
- return;
|
|
+ return false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ return true;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+QuickModifyTopic.prototype.init = function ()
|
|
|
|
+{
|
|
|
|
+
|
|
|
|
+ this.oTopicModHandle.instanceRef = this;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ this.oTopicModHandle.onkeydown = function (oEvent) {return this.instanceRef.modify_topic_keypress(oEvent);};
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ this.oTopicModHandle.onclick = function (oEvent) {return this.instanceRef.modify_topic_click(oEvent);};
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+QuickModifyTopic.prototype.modify_topic = function (topic_id, first_msg_id)
|
|
|
|
+{
|
|
|
|
|
|
if (typeof(cur_session_var) == 'undefined')
|
|
if (typeof(cur_session_var) == 'undefined')
|
|
cur_session_var = 'sesc';
|
|
cur_session_var = 'sesc';
|
|
|
|
|
|
- if (in_edit_mode == 1)
|
|
+
|
|
|
|
+ if (this.bInEditMode)
|
|
{
|
|
{
|
|
- if (cur_topic_id == topic_id)
|
|
+
|
|
|
|
+ if (this.iCurTopicId == topic_id)
|
|
return;
|
|
return;
|
|
else
|
|
else
|
|
- modify_topic_cancel();
|
|
+ this.modify_topic_cancel();
|
|
}
|
|
}
|
|
|
|
|
|
- in_edit_mode = 1;
|
|
+ this.bInEditMode = true;
|
|
- mouse_on_div = 1;
|
|
+ this.bMouseOnDiv = true;
|
|
- cur_topic_id = topic_id;
|
|
+ this.iCurTopicId = topic_id;
|
|
|
|
|
|
- if (typeof window.ajax_indicator == "function")
|
|
+
|
|
- ajax_indicator(true);
|
|
+ ajax_indicator(true);
|
|
- getXMLDocument(smf_prepareScriptUrl(smf_scripturl) + "action=quotefast;quote=" + first_msg_id + ";modify;xml", onDocReceived_modify_topic);
|
|
+ sendXMLDocument.call(this, smf_prepareScriptUrl(smf_scripturl) + "action=quotefast;quote=" + first_msg_id + ";modify;xml", '', this.onDocReceived_modify_topic);
|
|
}
|
|
}
|
|
|
|
|
|
-function onDocReceived_modify_topic(XMLDoc)
|
|
+
|
|
|
|
+QuickModifyTopic.prototype.onDocReceived_modify_topic = function (XMLDoc)
|
|
{
|
|
{
|
|
- cur_msg_id = XMLDoc.getElementsByTagName("message")[0].getAttribute("id");
|
|
+
|
|
|
|
+ if (!XMLDoc || !XMLDoc.getElementsByTagName('message'))
|
|
|
|
+ {
|
|
|
|
+ this.modify_topic_cancel();
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.sCurMessageId = XMLDoc.getElementsByTagName("message")[0].getAttribute("id");
|
|
|
|
+ this.oCurSubjectDiv = document.getElementById('msg_' + this.sCurMessageId.substr(4));
|
|
|
|
+ this.sBuffSubject = getInnerHTML(this.oCurSubjectDiv);
|
|
|
|
|
|
- cur_subject_div = document.getElementById('msg_' + cur_msg_id.substr(4));
|
|
+
|
|
- buff_subject = getInnerHTML(cur_subject_div);
|
|
+ this.set_hidden_topic_areas('none');
|
|
|
|
|
|
-
|
|
+
|
|
- set_hidden_topic_areas('none');
|
|
+ ajax_indicator(false);
|
|
|
|
+ this.modify_topic_show_edit(XMLDoc.getElementsByTagName("subject")[0].childNodes[0].nodeValue);
|
|
|
|
+}
|
|
|
|
|
|
- modify_topic_show_edit(XMLDoc.getElementsByTagName("subject")[0].childNodes[0].nodeValue);
|
|
+
|
|
- if (typeof window.ajax_indicator == "function")
|
|
+QuickModifyTopic.prototype.modify_topic_cancel = function ()
|
|
- ajax_indicator(false);
|
|
+{
|
|
|
|
+ setInnerHTML(this.oCurSubjectDiv, this.sBuffSubject);
|
|
|
|
+ this.set_hidden_topic_areas('');
|
|
|
|
+ this.bInEditMode = false;
|
|
|
|
+
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
|
|
|
|
-function modify_topic_cancel()
|
|
+
|
|
|
|
+QuickModifyTopic.prototype.set_hidden_topic_areas = function (set_style)
|
|
{
|
|
{
|
|
- setInnerHTML(cur_subject_div, buff_subject);
|
|
+ for (var i = 0; i < this.aHidePrefixes.length; i++)
|
|
- set_hidden_topic_areas('');
|
|
+ {
|
|
|
|
+ if (document.getElementById(this.aHidePrefixes[i] + this.sCurMessageId.substr(4)) != null)
|
|
|
|
+ document.getElementById(this.aHidePrefixes[i] + this.sCurMessageId.substr(4)).style.display = set_style;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
|
|
- in_edit_mode = 0;
|
|
+
|
|
- return false;
|
|
+QuickModifyTopic.prototype.modify_topic_show_edit = function (subject)
|
|
|
|
+{
|
|
|
|
+
|
|
|
|
+ setInnerHTML(this.oCurSubjectDiv, '<input type="text" name="subject" value="' + subject + '" size="60" style="width: 95%;" maxlength="80" class="input_text" /><input type="hidden" name="topic" value="' + this.iCurTopicId + '" /><input type="hidden" name="msg" value="' + this.sCurMessageId.substr(4) + '" />');
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ this.oCurSubjectDiv.instanceRef = this;
|
|
|
|
+ this.oCurSubjectDiv.onmouseout = function (oEvent) {return this.instanceRef.modify_topic_mouseout(oEvent);};
|
|
|
|
+ this.oCurSubjectDiv.onmouseover = function (oEvent) {return this.instanceRef.modify_topic_mouseover(oEvent);};
|
|
}
|
|
}
|
|
|
|
|
|
-function modify_topic_save(cur_session_id, cur_session_var)
|
|
+
|
|
|
|
+QuickModifyTopic.prototype.modify_topic_save = function (cur_session_id, cur_session_var)
|
|
{
|
|
{
|
|
- if (!in_edit_mode)
|
|
+ if (!this.bInEditMode)
|
|
return true;
|
|
return true;
|
|
|
|
|
|
|
|
|
|
@@ -72,18 +140,22 @@ function modify_topic_save(cur_session_id, cur_session_var)
|
|
x[x.length] = 'topic=' + parseInt(document.forms.quickModForm.elements['topic'].value);
|
|
x[x.length] = 'topic=' + parseInt(document.forms.quickModForm.elements['topic'].value);
|
|
x[x.length] = 'msg=' + parseInt(document.forms.quickModForm.elements['msg'].value);
|
|
x[x.length] = 'msg=' + parseInt(document.forms.quickModForm.elements['msg'].value);
|
|
|
|
|
|
- if (typeof window.ajax_indicator == "function")
|
|
+
|
|
- ajax_indicator(true);
|
|
+ ajax_indicator(true);
|
|
- 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);
|
|
+ sendXMLDocument.call(this, smf_prepareScriptUrl(smf_scripturl) + "action=jsmodify;topic=" + parseInt(document.forms.quickModForm.elements['topic'].value) + ";" + cur_session_var + "=" + cur_session_id + ";xml", x.join("&"), this.modify_topic_done);
|
|
|
|
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
-function modify_topic_done(XMLDoc)
|
|
+
|
|
|
|
+QuickModifyTopic.prototype.modify_topic_done = function (XMLDoc)
|
|
{
|
|
{
|
|
- if (!XMLDoc)
|
|
+ ajax_indicator(false);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (!XMLDoc || !XMLDoc.getElementsByTagName('subject'))
|
|
{
|
|
{
|
|
- modify_topic_cancel();
|
|
+ this.modify_topic_cancel();
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -91,33 +163,68 @@ function modify_topic_done(XMLDoc)
|
|
var subject = message.getElementsByTagName("subject")[0];
|
|
var subject = message.getElementsByTagName("subject")[0];
|
|
var error = message.getElementsByTagName("error")[0];
|
|
var error = message.getElementsByTagName("error")[0];
|
|
|
|
|
|
- if (typeof window.ajax_indicator == "function")
|
|
+
|
|
- ajax_indicator(false);
|
|
|
|
|
|
|
|
if (!subject || error)
|
|
if (!subject || error)
|
|
return false;
|
|
return false;
|
|
|
|
|
|
- subjectText = subject.childNodes[0].nodeValue;
|
|
+ this.modify_topic_hide_edit(subject.childNodes[0].nodeValue);
|
|
-
|
|
+ this.set_hidden_topic_areas('');
|
|
- modify_topic_hide_edit(subjectText);
|
|
+ this.bInEditMode = false;
|
|
-
|
|
|
|
- set_hidden_topic_areas('');
|
|
|
|
-
|
|
|
|
- in_edit_mode = 0;
|
|
|
|
|
|
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
+
|
|
-function set_hidden_topic_areas(set_style)
|
|
+QuickModifyTopic.prototype.modify_topic_hide_edit = function (subject)
|
|
|
|
+{
|
|
|
|
+
|
|
|
|
+ setInnerHTML(this.oCurSubjectDiv, '<a href="' + smf_scripturl + '?topic=' + this.iCurTopicId + '.0">' + subject + '<' +'/a>');
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+QuickModifyTopic.prototype.modify_topic_keypress = function (oEvent)
|
|
{
|
|
{
|
|
- for (var i = 0; i < hide_prefixes.length; i++)
|
|
+ if (typeof(oEvent.keyCode) != "undefined")
|
|
{
|
|
{
|
|
- if (document.getElementById(hide_prefixes[i] + cur_msg_id.substr(4)) != null)
|
|
+ if (oEvent.keyCode == 27)
|
|
- document.getElementById(hide_prefixes[i] + cur_msg_id.substr(4)).style.display = set_style;
|
|
+ {
|
|
|
|
+ this.modify_topic_cancel();
|
|
|
|
+ if (typeof(oEvent.preventDefault) == "undefined")
|
|
|
|
+ oEvent.returnValue = false;
|
|
|
|
+ else
|
|
|
|
+ oEvent.preventDefault();
|
|
|
|
+ }
|
|
|
|
+ else if (oEvent.keyCode == 13)
|
|
|
|
+ {
|
|
|
|
+ this.modify_topic_save(smf_session_id, smf_session_var);
|
|
|
|
+ if (typeof(oEvent.preventDefault) == "undefined")
|
|
|
|
+ oEvent.returnValue = false;
|
|
|
|
+ else
|
|
|
|
+ oEvent.preventDefault();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+QuickModifyTopic.prototype.modify_topic_click = function (oEvent)
|
|
|
|
+{
|
|
|
|
+ if (this.bInEditMode && !this.bMouseOnDiv)
|
|
|
|
+ this.modify_topic_save(smf_session_id, smf_session_var);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+QuickModifyTopic.prototype.modify_topic_mouseout = function (oEvent)
|
|
|
|
+{
|
|
|
|
+ this.bMouseOnDiv = false;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+QuickModifyTopic.prototype.modify_topic_mouseover = function (oEvent)
|
|
|
|
+{
|
|
|
|
+ this.bMouseOnDiv = true;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
|
|
function QuickReply(oOptions)
|
|
function QuickReply(oOptions)
|
|
{
|
|
{
|
|
@@ -628,38 +735,6 @@ function expandThumb(thumbID)
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-function modify_topic_show_edit(subject)
|
|
|
|
-{
|
|
|
|
-
|
|
|
|
- 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) + '" />');
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-function modify_topic_click()
|
|
|
|
-{
|
|
|
|
- if (in_edit_mode == 1 && mouse_on_div == 0)
|
|
|
|
- modify_topic_save(smf_sesion_id, smf_session_var);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-function modify_topic_keypress(oEvent)
|
|
|
|
-{
|
|
|
|
- if (typeof(oEvent.keyCode) != "undefined" && oEvent.keyCode == 13)
|
|
|
|
- {
|
|
|
|
- modify_topic_save(smf_sesion_id, smf_session_var);
|
|
|
|
- if (typeof(oEvent.preventDefault) == "undefined")
|
|
|
|
- oEvent.returnValue = false;
|
|
|
|
- else
|
|
|
|
- oEvent.preventDefault();
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-function modify_topic_hide_edit(subject)
|
|
|
|
-{
|
|
|
|
-
|
|
|
|
- setInnerHTML(cur_subject_div, '<a href="' + smf_scripturl + '?topic=' + cur_topic_id + '.0">' + subject + '<' +'/a>');
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
function ignore_toggles(msgids, text)
|
|
function ignore_toggles(msgids, text)
|
|
{
|
|
{
|
|
for (i = 0; i < msgids.length; i++)
|
|
for (i = 0; i < msgids.length; i++)
|