function openUrlPrompt(markup_obj){ var selected = markup_obj.selection; var caretposition = markup_obj.caretPosition; var textarea = markup_obj.textarea; var promptcontent = ''; promptcontent += '
'; promptcontent += '
'; promptcontent += '
'; /* e is the event * v is the value of the button clicked. * m is a jQuery object of the message within the active state when the user clicked the button. * f is an object of key/value pairs of the form values. The keys are the name attribute for the form element. */ $.prompt(promptcontent,{ close: function(e,v,m,f){ //if cancel button, no values or no linkurl if(v == 0 || !f || !f.linkurl) return; replace = '[url='+f.linkurl+( f.newwindow ? "|newwindow": "")+']'+f.texturl+'[/url]'; //bring focus and caret position back to what it was before replacing the string. Necessary for IE. textarea.focus(); setTextareaCaretPosition(textarea, caretposition, selected.length); $.markItUp({replaceWith: replace }); }, buttons: { Ok: 1, Cancel: 0 } }); } function openEmailPrompt(markup_obj){ var selected = markup_obj.selection; var caretposition = markup_obj.caretPosition; var textarea = markup_obj.textarea; var promptcontent = ''; promptcontent += '
'; promptcontent += '
'; /* e is the event * v is the value of the button clicked. * m is a jQuery object of the message within the active state when the user clicked the button. * f is an object of key/value pairs of the form values. The keys are the name attribute for the form element. */ $.prompt(promptcontent,{ close: function(e,v,m,f){ //if cancel button, no values or no linkurl if(v == 0 || !f || !f.email) return; replace = '[email='+f.email+']'+f.texturl+'[/email]'; //bring focus and caret position back to what it was before replacing the string. Necessary for IE. textarea.focus(); setTextareaCaretPosition(textarea, caretposition, selected.length); $.markItUp({replaceWith: replace }); }, buttons: { Ok: 1, Cancel: 0 } }); } function openPopupPrompt(markup_obj){ var selected = markup_obj.selection; var caretposition = markup_obj.caretPosition; var textarea = markup_obj.textarea; var promptcontent = ''; promptcontent += '
'; promptcontent += '
'; promptcontent += '
pixels
'; promptcontent += '
pixels
'; /* e is the event * v is the value of the button clicked. * m is a jQuery object of the message within the active state when the user clicked the button. * f is an object of key/value pairs of the form values. The keys are the name attribute for the form element. */ $.prompt(promptcontent,{ close: function(e,v,m,f){ //if cancel button, no values or no linkurl if(v == 0 || !f || !f.linkurl) return; replace = '[popup='+f.linkurl+( f.width ? "|width="+f.width : "")+( f.height ? "|height="+f.height : "")+']'+f.texturl+'[/popup]'; //bring focus and caret position back to what it was before replacing the string. Necessary for IE. textarea.focus(); setTextareaCaretPosition(textarea, caretposition, selected.length); $.markItUp({replaceWith: replace }); }, buttons: { Ok: 1, Cancel: 0 } }); } function openAnchorLinkPrompt(markup_obj){ var selected = markup_obj.selection; var caretposition = markup_obj.caretPosition; var textarea = markup_obj.textarea; var promptcontent = ''; promptcontent += '
'; promptcontent += '
'; /* e is the event * v is the value of the button clicked. * m is a jQuery object of the message within the active state when the user clicked the button. * f is an object of key/value pairs of the form values. The keys are the name attribute for the form element. */ $.prompt(promptcontent,{ close: function(e,v,m,f){ //if cancel button, no values or no linkurl if(v == 0 || !f || !f.targetname) return; replace = '[anchorlink='+f.targetname+']'+f.texturl+'[/anchorlink]'; //bring focus and caret position back to what it was before replacing the string. Necessary for IE. textarea.focus(); setTextareaCaretPosition(textarea, caretposition, selected.length); $.markItUp({replaceWith: replace }); }, buttons: { Ok: 1, Cancel: 0 } }); } function openAnchorTargetPrompt(markup_obj){ var selected = markup_obj.selection; var caretposition = markup_obj.caretPosition; var textarea = markup_obj.textarea; var promptcontent = ''; promptcontent += '
'; promptcontent += '
'; /* e is the event * v is the value of the button clicked. * m is a jQuery object of the message within the active state when the user clicked the button. * f is an object of key/value pairs of the form values. The keys are the name attribute for the form element. */ $.prompt(promptcontent,{ close: function(e,v,m,f){ //if cancel button, no values or no linkurl if(v == 0 || !f || !f.targetname) return; replace = '[anchor='+f.targetname+']'+f.texturl+'[/anchor]'; //bring focus and caret position back to what it was before replacing the string. Necessary for IE. textarea.focus(); setTextareaCaretPosition(textarea, caretposition, selected.length); $.markItUp({replaceWith: replace }); }, buttons: { Ok: 1, Cancel: 0 } }); } function openOrderedListPrompt(markup_obj){ var selected = markup_obj.selection; var caretposition = markup_obj.caretPosition; var textarea = markup_obj.textarea; var promptcontent = ''; promptcontent += '
'; /* e is the event * v is the value of the button clicked. * m is a jQuery object of the message within the active state when the user clicked the button. * f is an object of key/value pairs of the form values. The keys are the name attribute for the form element. */ $.prompt(promptcontent,{ close: function(e,v,m,f){ //if cancel button, no values or no number given if(v == 0 || !f || !f.numberfrom) return; res = '[list='+f.numberfrom+']\n[*]'; res += selected.replace(/\n/mg, "\n[*]");//replace newlines with liststarters res += "\n[/list]";//end list //bring focus and caret position back to what it was before replacing the string. Necessary for IE. textarea.focus(); setTextareaCaretPosition(textarea, caretposition, selected.length); $.markItUp({replaceWith: res }); }, buttons: { Ok: 1, Cancel: 0 } }); } // set caret position in textarea, because we lost the focus when using the above prompts. //this is a copy (and adjustment) of the set() function in jquery.markitup.js. function setTextareaCaretPosition(textarea, start, len) { if (textarea.createTextRange){ // quick fix to make it work on Opera 9.5 if ($.browser.opera && $.browser.version >= 9.5 && len == 0) { return false; } range = textarea.createTextRange(); range.collapse(true); range.moveStart('character', start); range.moveEnd('character', len); range.select(); } else if (textarea.setSelectionRange ){ textarea.setSelectionRange(start, start + len); } textarea.focus(); }