[Phpfreechat-svn] SF.net SVN: phpfreechat: [690] trunk/src/client
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-08-22 13:58:49
|
Revision: 690 Author: kerphi Date: 2006-08-22 06:58:44 -0700 (Tue, 22 Aug 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=690&view=rev Log Message: ----------- Fix the insert_text prompt feature Modified Paths: -------------- trunk/src/client/pfcclient.js trunk/src/client/pfcgui.js Modified: trunk/src/client/pfcclient.js =================================================================== --- trunk/src/client/pfcclient.js 2006-08-22 13:46:23 UTC (rev 689) +++ trunk/src/client/pfcclient.js 2006-08-22 13:58:44 UTC (rev 690) @@ -656,7 +656,7 @@ line += ' <span class="pfc_nick">'; line += '‹'; line += '<span '; - line += 'onclick="pfc.insert_text(\'' + sender + ', \',\'\')" '; + line += 'onclick="pfc.insert_text(\'' + sender + ', \',\'\',false)" '; line += 'class="pfc_nickmarker pfc_nick_'+ hex_md5(_to_utf8(sender)) +'">'; line += sender; line += '</span>'; @@ -791,7 +791,7 @@ var nobr = document.createElement('nobr'); var span = document.createElement('span'); span.pfc_nick = nicks[i]; - span.onclick = function(){pfc.insert_text(this.pfc_nick+", ",""); return false;} + span.onclick = function(){pfc.insert_text(this.pfc_nick+", ","",false); return false;} span.appendChild(document.createTextNode(nicks[i])); span.setAttribute('class', 'pfc_nickmarker pfc_nick_'+ hex_md5(_to_utf8(nicks[i]))); span.setAttribute('className', 'pfc_nickmarker pfc_nick_'+ hex_md5(_to_utf8(nicks[i]))); // for IE6 @@ -1176,7 +1176,7 @@ /** * BBcode ToolBar */ - insert_text: function(open, close) + insert_text: function(open, close, promptifselempty) { var msgfield = $('pfc_words'); @@ -1186,9 +1186,10 @@ msgfield.focus(); sel = document.selection.createRange(); var text = sel.text; - if (text == "") + if (text == "" && promptifselempty) text = prompt(this.res.getLabel('Enter the text to format'),''); - if (text.length > 0) + if (text == null) text = ""; + if (text.length > 0 || !promptifselempty) { sel.text = open + text + close; // @todo move the cursor just after the BBCODE, this doesn't work when the text to enclose is selected, IE6 keeps the whole selection active after the operation. @@ -1204,12 +1205,12 @@ var text = msgfield.value.substring(startPos, endPos); var extralength = 0; - if (startPos == endPos) + if (startPos == endPos && promptifselempty) { text = prompt(this.res.getLabel('Enter the text to format'),''); extralength = text.length; } - if (text.length > 0) + if (text.length > 0 || !promptifselempty) { msgfield.value = msgfield.value.substring(0, startPos) + open + text + close + msgfield.value.substring(endPos, msgfield.value.length); msgfield.selectionStart = msgfield.selectionEnd = endPos + open.length + extralength + close.length; @@ -1221,7 +1222,7 @@ else { var text = prompt(this.res.getLabel('Enter the text to format'),''); - if (text.length > 0) + if (text.length > 0 || !promptifselempty) { msgfield.value += open + text + close; msgfield.focus(); Modified: trunk/src/client/pfcgui.js =================================================================== --- trunk/src/client/pfcgui.js 2006-08-22 13:46:23 UTC (rev 689) +++ trunk/src/client/pfcgui.js 2006-08-22 13:58:44 UTC (rev 690) @@ -474,7 +474,7 @@ img.setAttribute('className', 'pfc_bt_strong'); // for IE6 img.setAttribute('title', pfc.res.getLabel("Bold")); img.setAttribute('src', pfc.res.getFileUrl('images/bt_strong.gif')); - img.onclick = function(){ pfc.insert_text('[b]','[/b]'); } + img.onclick = function(){ pfc.insert_text('[b]','[/b]',true); } btn.appendChild(img); bbcontainer.appendChild(btn); @@ -487,7 +487,7 @@ img.setAttribute('className', 'pfc_bt_italics'); // for IE6 img.setAttribute('title', pfc.res.getLabel("Italics")); img.setAttribute('src', pfc.res.getFileUrl('images/bt_em.gif')); - img.onclick = function(){ pfc.insert_text('[i]','[/i]'); } + img.onclick = function(){ pfc.insert_text('[i]','[/i]',true); } btn.appendChild(img); bbcontainer.appendChild(btn); @@ -500,7 +500,7 @@ img.setAttribute('className', 'pfc_bt_underline'); // for IE6 img.setAttribute('title', pfc.res.getLabel("Underline")); img.setAttribute('src', pfc.res.getFileUrl('images/bt_ins.gif')); - img.onclick = function(){ pfc.insert_text('[u]','[/u]'); } + img.onclick = function(){ pfc.insert_text('[u]','[/u]',true); } btn.appendChild(img); bbcontainer.appendChild(btn); @@ -513,7 +513,7 @@ img.setAttribute('className', 'pfc_bt_delete'); // for IE6 img.setAttribute('title', pfc.res.getLabel("Delete")); img.setAttribute('src', pfc.res.getFileUrl('images/bt_del.gif')); - img.onclick = function(){ pfc.insert_text('[s]','[/s]'); } + img.onclick = function(){ pfc.insert_text('[s]','[/s]',true); } btn.appendChild(img); bbcontainer.appendChild(btn); @@ -526,7 +526,7 @@ img.setAttribute('className', 'pfc_bt_mail'); // for IE6 img.setAttribute('title', pfc.res.getLabel("Mail")); img.setAttribute('src', pfc.res.getFileUrl('images/bt_mail.gif')); - img.onclick = function(){ pfc.insert_text('[email]','[/email]'); } + img.onclick = function(){ pfc.insert_text('[email]','[/email]',true); } btn.appendChild(img); bbcontainer.appendChild(btn); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |