gremmie@1: // ------------------------------------------------------------------- gremmie@1: // markItUp! gremmie@1: // ------------------------------------------------------------------- gremmie@1: // Copyright (C) 2008 Jay Salvat gremmie@1: // http://markitup.jaysalvat.com/ gremmie@1: // ------------------------------------------------------------------- gremmie@1: // MarkDown tags example gremmie@1: // http://en.wikipedia.org/wiki/Markdown gremmie@1: // http://daringfireball.net/projects/markdown/ gremmie@1: // ------------------------------------------------------------------- gremmie@1: // Feel free to add more tags gremmie@1: // ------------------------------------------------------------------- gremmie@1: mySettings = { gremmie@1: previewParserPath: '/comments/markdown/', gremmie@1: previewParserVar: 'data', gremmie@1: previewInWindow: false, gremmie@1: previewAutoRefresh: false, gremmie@1: previewPosition: 'after', gremmie@1: onShiftEnter: {keepDefault:false, openWith:'\n\n'}, gremmie@1: markupSet: [ gremmie@1: {name:'First Level Heading', key:'1', placeHolder:'Your title here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '=') } }, gremmie@1: {name:'Second Level Heading', key:'2', placeHolder:'Your title here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '-') } }, gremmie@1: {name:'Heading 3', key:'3', openWith:'### ', placeHolder:'Your title here...' }, gremmie@1: {name:'Heading 4', key:'4', openWith:'#### ', placeHolder:'Your title here...' }, gremmie@1: {name:'Heading 5', key:'5', openWith:'##### ', placeHolder:'Your title here...' }, gremmie@1: {name:'Heading 6', key:'6', openWith:'###### ', placeHolder:'Your title here...' }, gremmie@1: {separator:'---------------' }, gremmie@1: {name:'Bold', key:'B', openWith:'**', closeWith:'**'}, gremmie@1: {name:'Italic', key:'I', openWith:'_', closeWith:'_'}, gremmie@1: {separator:'---------------' }, gremmie@1: {name:'Bulleted List', openWith:'- ' }, gremmie@1: {name:'Numeric List', openWith:function(markItUp) { gremmie@1: return markItUp.line+'. '; gremmie@1: }}, gremmie@1: {separator:'---------------' }, gremmie@1: {name:'Picture', key:'P', replaceWith:'![[![Alternative text]!]]([![Url:!:http://]!] "[![Title]!]")'}, gremmie@1: {name:'Link', key:'L', openWith:'[', closeWith:']([![Url:!:http://]!] "[![Title]!]")', placeHolder:'Your text to link here...' }, gremmie@1: {separator:'---------------'}, gremmie@1: {name:'Quotes', openWith:'> '}, gremmie@1: {name:'Code Block / Code', openWith:'(!(\t|!|`)!)', closeWith:'(!(`)!)'}, gremmie@1: {separator:'---------------'}, gremmie@1: {name:'Smilies', className:'smilies', dropMenu: [ gremmie@1: {name:'Argh', replaceWith:' :argh: ', className:'col1-1' }, gremmie@1: {name:'Grin', replaceWith:' :-D ', className:'col1-2' }, gremmie@1: {name:'Razz', replaceWith:' :-P ', className:'col1-3' }, gremmie@1: {name:'Confused', replaceWith:' o_O ', className:'col1-4' }, gremmie@1: {name:'Cool', replaceWith:' 8^) ', className:'col1-5' }, gremmie@1: {name:'Cry', replaceWith:' :-( ', className:'col2-1' }, gremmie@1: {name:'Dead', replaceWith:' x_x ', className:'col2-2' }, gremmie@1: {name:'Embarrassed', replaceWith:' :-# ', className:'col2-3' }, gremmie@1: {name:'LOL', replaceWith:' :lol: ', className:'col2-4' }, gremmie@1: {name:'Mad', replaceWith:' X-( ', className:'col2-5' }, gremmie@1: {name:'No', replaceWith:' :no: ', className:'col3-1' }, gremmie@1: {name:'None', replaceWith:' :-| ', className:'col3-2' }, gremmie@1: {name:'Shock', replaceWith:' :shock: ', className:'col3-3' }, gremmie@1: {name:'Sigh', replaceWith:' :sigh: ', className:'col3-4' }, gremmie@1: {name:'Smile', replaceWith:' :-) ', className:'col3-5' }, gremmie@1: {name:'Uh-oh', replaceWith:' :uh-oh: ', className:'col4-1' }, gremmie@1: {name:'Whatever', replaceWith:' :whatever: ', className:'col4-2' }, gremmie@1: {name:'Wink', replaceWith:' ;-) ', className:'col4-3' }, gremmie@1: {name:'Yes', replaceWith:' :yes: ', className:'col4-4' }, gremmie@1: {name:'Sleep', replaceWith:' :sleep: ', className:'col4-5' } gremmie@1: ] gremmie@1: }, gremmie@1: {separator:'---------------'}, gremmie@1: {name:'Preview', call:'preview', className:"preview"} gremmie@1: ] gremmie@1: } gremmie@1: gremmie@1: // mIu nameSpace to avoid conflict. gremmie@1: miu = { gremmie@1: markdownTitle: function(markItUp, char) { gremmie@1: heading = ''; gremmie@1: n = $.trim(markItUp.selection||markItUp.placeHolder).length; gremmie@1: for(i = 0; i < n; i++) { gremmie@1: heading += char; gremmie@1: } gremmie@1: return '\n'+heading; gremmie@1: } gremmie@1: } bgneal@131: bgneal@131: $(document).ready(function() { bgneal@131: $('.markItUp').markItUp(mySettings); bgneal@131: bgneal@131: $('#smileys_dialog_popup').dialog({autoOpen:false}); bgneal@131: var firstTimeSmiley = true; bgneal@131: $('#more_smileys_link').click(function () { bgneal@131: $('#smileys_dialog_popup').dialog('open'); bgneal@131: var smileyTarget = $('.smileyTarget')[0]; bgneal@131: if (firstTimeSmiley) { bgneal@131: $.ajax({ bgneal@131: url: '/smiley/farm/extra/', bgneal@131: type: 'GET', bgneal@131: dataType: 'html', bgneal@131: success: function(data, textStatus) { bgneal@131: var img = $('#smiley_busy'); bgneal@131: img.hide(); bgneal@131: img.after(data); bgneal@131: $('#smileys_dialog_popup .smiley_farm img').click(function() { bgneal@131: smileyTarget.value += ' ' + this.alt + ' '; bgneal@131: smileyTarget.focus(); bgneal@131: }); bgneal@131: firstTimeSmiley = false; bgneal@131: }, bgneal@131: error: function (xhr, textStatus, ex) { bgneal@131: alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText); bgneal@131: } bgneal@131: }); bgneal@131: } bgneal@131: return false; bgneal@131: }); bgneal@131: $('#markdown_help_dialog_popup').dialog({autoOpen: false, width: 720, height: 600}); bgneal@131: var firstTimeMdHelp = true; bgneal@131: $('#markdown_help_link').click(function () { bgneal@131: $('#markdown_help_dialog_popup').dialog('open'); bgneal@131: if (firstTimeMdHelp) { bgneal@131: $.ajax({ bgneal@131: url: '/core/markdown_help/', bgneal@131: type: 'GET', bgneal@131: dataType: 'html', bgneal@131: success: function(data, textStatus) { bgneal@131: var img = $('#markdown_busy'); bgneal@131: img.hide(); bgneal@131: img.after(data); bgneal@131: firstTimeMdHelp = false; bgneal@131: }, bgneal@131: error: function (xhr, textStatus, ex) { bgneal@131: alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText); bgneal@131: } bgneal@131: }); bgneal@131: } bgneal@131: return false; bgneal@131: }); bgneal@131: });