annotate media/js/markitup/sets/markdown/set.js @ 304:0231aad9e211

Fixing #123; removed the H1-H6 buttons from the markitup editor.
author Brian Neal <bgneal@gmail.com>
date Sat, 15 Jan 2011 21:11:50 +0000
parents 5b69d6e01fd4
children d502a997360e
rev   line source
gremmie@1 1 // -------------------------------------------------------------------
gremmie@1 2 // markItUp!
gremmie@1 3 // -------------------------------------------------------------------
gremmie@1 4 // Copyright (C) 2008 Jay Salvat
gremmie@1 5 // http://markitup.jaysalvat.com/
gremmie@1 6 // -------------------------------------------------------------------
gremmie@1 7 // MarkDown tags example
gremmie@1 8 // http://en.wikipedia.org/wiki/Markdown
gremmie@1 9 // http://daringfireball.net/projects/markdown/
gremmie@1 10 // -------------------------------------------------------------------
gremmie@1 11 // Feel free to add more tags
gremmie@1 12 // -------------------------------------------------------------------
gremmie@1 13 mySettings = {
gremmie@1 14 previewParserPath: '/comments/markdown/',
gremmie@1 15 previewParserVar: 'data',
gremmie@1 16 previewInWindow: false,
gremmie@1 17 previewAutoRefresh: false,
gremmie@1 18 previewPosition: 'after',
gremmie@1 19 onShiftEnter: {keepDefault:false, openWith:'\n\n'},
gremmie@1 20 markupSet: [
gremmie@1 21 {name:'Bold', key:'B', openWith:'**', closeWith:'**'},
gremmie@1 22 {name:'Italic', key:'I', openWith:'_', closeWith:'_'},
gremmie@1 23 {separator:'---------------' },
gremmie@1 24 {name:'Bulleted List', openWith:'- ' },
gremmie@1 25 {name:'Numeric List', openWith:function(markItUp) {
gremmie@1 26 return markItUp.line+'. ';
gremmie@1 27 }},
gremmie@1 28 {separator:'---------------' },
gremmie@1 29 {name:'Picture', key:'P', replaceWith:'![[![Alternative text]!]]([![Url:!:http://]!] "[![Title]!]")'},
gremmie@1 30 {name:'Link', key:'L', openWith:'[', closeWith:']([![Url:!:http://]!] "[![Title]!]")', placeHolder:'Your text to link here...' },
gremmie@1 31 {separator:'---------------'},
gremmie@1 32 {name:'Quotes', openWith:'> '},
gremmie@1 33 {name:'Code Block / Code', openWith:'(!(\t|!|`)!)', closeWith:'(!(`)!)'},
gremmie@1 34 {separator:'---------------'},
gremmie@1 35 {name:'Smilies', className:'smilies', dropMenu: [
gremmie@1 36 {name:'Argh', replaceWith:' :argh: ', className:'col1-1' },
gremmie@1 37 {name:'Grin', replaceWith:' :-D ', className:'col1-2' },
gremmie@1 38 {name:'Razz', replaceWith:' :-P ', className:'col1-3' },
gremmie@1 39 {name:'Confused', replaceWith:' o_O ', className:'col1-4' },
gremmie@1 40 {name:'Cool', replaceWith:' 8^) ', className:'col1-5' },
gremmie@1 41 {name:'Cry', replaceWith:' :-( ', className:'col2-1' },
gremmie@1 42 {name:'Dead', replaceWith:' x_x ', className:'col2-2' },
gremmie@1 43 {name:'Embarrassed', replaceWith:' :-# ', className:'col2-3' },
gremmie@1 44 {name:'LOL', replaceWith:' :lol: ', className:'col2-4' },
gremmie@1 45 {name:'Mad', replaceWith:' X-( ', className:'col2-5' },
gremmie@1 46 {name:'No', replaceWith:' :no: ', className:'col3-1' },
gremmie@1 47 {name:'None', replaceWith:' :-| ', className:'col3-2' },
gremmie@1 48 {name:'Shock', replaceWith:' :shock: ', className:'col3-3' },
gremmie@1 49 {name:'Sigh', replaceWith:' :sigh: ', className:'col3-4' },
gremmie@1 50 {name:'Smile', replaceWith:' :-) ', className:'col3-5' },
gremmie@1 51 {name:'Uh-oh', replaceWith:' :uh-oh: ', className:'col4-1' },
gremmie@1 52 {name:'Whatever', replaceWith:' :whatever: ', className:'col4-2' },
gremmie@1 53 {name:'Wink', replaceWith:' ;-) ', className:'col4-3' },
gremmie@1 54 {name:'Yes', replaceWith:' :yes: ', className:'col4-4' },
gremmie@1 55 {name:'Sleep', replaceWith:' :sleep: ', className:'col4-5' }
gremmie@1 56 ]
gremmie@1 57 },
gremmie@1 58 {separator:'---------------'},
gremmie@1 59 {name:'Preview', call:'preview', className:"preview"}
gremmie@1 60 ]
gremmie@1 61 }
gremmie@1 62
gremmie@1 63 // mIu nameSpace to avoid conflict.
gremmie@1 64 miu = {
gremmie@1 65 markdownTitle: function(markItUp, char) {
gremmie@1 66 heading = '';
gremmie@1 67 n = $.trim(markItUp.selection||markItUp.placeHolder).length;
gremmie@1 68 for(i = 0; i < n; i++) {
gremmie@1 69 heading += char;
gremmie@1 70 }
gremmie@1 71 return '\n'+heading;
gremmie@1 72 }
gremmie@1 73 }
bgneal@131 74
bgneal@131 75 $(document).ready(function() {
bgneal@131 76 $('.markItUp').markItUp(mySettings);
bgneal@131 77
bgneal@131 78 $('#smileys_dialog_popup').dialog({autoOpen:false});
bgneal@131 79 var firstTimeSmiley = true;
bgneal@131 80 $('#more_smileys_link').click(function () {
bgneal@131 81 $('#smileys_dialog_popup').dialog('open');
bgneal@131 82 var smileyTarget = $('.smileyTarget')[0];
bgneal@131 83 if (firstTimeSmiley) {
bgneal@131 84 $.ajax({
bgneal@131 85 url: '/smiley/farm/extra/',
bgneal@131 86 type: 'GET',
bgneal@131 87 dataType: 'html',
bgneal@131 88 success: function(data, textStatus) {
bgneal@131 89 var img = $('#smiley_busy');
bgneal@131 90 img.hide();
bgneal@131 91 img.after(data);
bgneal@131 92 $('#smileys_dialog_popup .smiley_farm img').click(function() {
bgneal@131 93 smileyTarget.value += ' ' + this.alt + ' ';
bgneal@131 94 smileyTarget.focus();
bgneal@131 95 });
bgneal@131 96 firstTimeSmiley = false;
bgneal@131 97 },
bgneal@131 98 error: function (xhr, textStatus, ex) {
bgneal@131 99 alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText);
bgneal@131 100 }
bgneal@131 101 });
bgneal@131 102 }
bgneal@131 103 return false;
bgneal@131 104 });
bgneal@131 105 $('#markdown_help_dialog_popup').dialog({autoOpen: false, width: 720, height: 600});
bgneal@131 106 var firstTimeMdHelp = true;
bgneal@131 107 $('#markdown_help_link').click(function () {
bgneal@131 108 $('#markdown_help_dialog_popup').dialog('open');
bgneal@131 109 if (firstTimeMdHelp) {
bgneal@131 110 $.ajax({
bgneal@131 111 url: '/core/markdown_help/',
bgneal@131 112 type: 'GET',
bgneal@131 113 dataType: 'html',
bgneal@131 114 success: function(data, textStatus) {
bgneal@131 115 var img = $('#markdown_busy');
bgneal@131 116 img.hide();
bgneal@131 117 img.after(data);
bgneal@131 118 firstTimeMdHelp = false;
bgneal@131 119 },
bgneal@131 120 error: function (xhr, textStatus, ex) {
bgneal@131 121 alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText);
bgneal@131 122 }
bgneal@131 123 });
bgneal@131 124 }
bgneal@131 125 return false;
bgneal@131 126 });
bgneal@131 127 });