annotate media/js/markitup/sets/markdown/set.js @ 201:bc958bc3c6eb

Futzing with CSS side blocks
author Brian Neal <bgneal@gmail.com>
date Mon, 12 Apr 2010 02:56:31 +0000
parents 5b69d6e01fd4
children 0231aad9e211
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:'First Level Heading', key:'1', placeHolder:'Your title here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '=') } },
gremmie@1 22 {name:'Second Level Heading', key:'2', placeHolder:'Your title here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '-') } },
gremmie@1 23 {name:'Heading 3', key:'3', openWith:'### ', placeHolder:'Your title here...' },
gremmie@1 24 {name:'Heading 4', key:'4', openWith:'#### ', placeHolder:'Your title here...' },
gremmie@1 25 {name:'Heading 5', key:'5', openWith:'##### ', placeHolder:'Your title here...' },
gremmie@1 26 {name:'Heading 6', key:'6', openWith:'###### ', placeHolder:'Your title here...' },
gremmie@1 27 {separator:'---------------' },
gremmie@1 28 {name:'Bold', key:'B', openWith:'**', closeWith:'**'},
gremmie@1 29 {name:'Italic', key:'I', openWith:'_', closeWith:'_'},
gremmie@1 30 {separator:'---------------' },
gremmie@1 31 {name:'Bulleted List', openWith:'- ' },
gremmie@1 32 {name:'Numeric List', openWith:function(markItUp) {
gremmie@1 33 return markItUp.line+'. ';
gremmie@1 34 }},
gremmie@1 35 {separator:'---------------' },
gremmie@1 36 {name:'Picture', key:'P', replaceWith:'![[![Alternative text]!]]([![Url:!:http://]!] "[![Title]!]")'},
gremmie@1 37 {name:'Link', key:'L', openWith:'[', closeWith:']([![Url:!:http://]!] "[![Title]!]")', placeHolder:'Your text to link here...' },
gremmie@1 38 {separator:'---------------'},
gremmie@1 39 {name:'Quotes', openWith:'> '},
gremmie@1 40 {name:'Code Block / Code', openWith:'(!(\t|!|`)!)', closeWith:'(!(`)!)'},
gremmie@1 41 {separator:'---------------'},
gremmie@1 42 {name:'Smilies', className:'smilies', dropMenu: [
gremmie@1 43 {name:'Argh', replaceWith:' :argh: ', className:'col1-1' },
gremmie@1 44 {name:'Grin', replaceWith:' :-D ', className:'col1-2' },
gremmie@1 45 {name:'Razz', replaceWith:' :-P ', className:'col1-3' },
gremmie@1 46 {name:'Confused', replaceWith:' o_O ', className:'col1-4' },
gremmie@1 47 {name:'Cool', replaceWith:' 8^) ', className:'col1-5' },
gremmie@1 48 {name:'Cry', replaceWith:' :-( ', className:'col2-1' },
gremmie@1 49 {name:'Dead', replaceWith:' x_x ', className:'col2-2' },
gremmie@1 50 {name:'Embarrassed', replaceWith:' :-# ', className:'col2-3' },
gremmie@1 51 {name:'LOL', replaceWith:' :lol: ', className:'col2-4' },
gremmie@1 52 {name:'Mad', replaceWith:' X-( ', className:'col2-5' },
gremmie@1 53 {name:'No', replaceWith:' :no: ', className:'col3-1' },
gremmie@1 54 {name:'None', replaceWith:' :-| ', className:'col3-2' },
gremmie@1 55 {name:'Shock', replaceWith:' :shock: ', className:'col3-3' },
gremmie@1 56 {name:'Sigh', replaceWith:' :sigh: ', className:'col3-4' },
gremmie@1 57 {name:'Smile', replaceWith:' :-) ', className:'col3-5' },
gremmie@1 58 {name:'Uh-oh', replaceWith:' :uh-oh: ', className:'col4-1' },
gremmie@1 59 {name:'Whatever', replaceWith:' :whatever: ', className:'col4-2' },
gremmie@1 60 {name:'Wink', replaceWith:' ;-) ', className:'col4-3' },
gremmie@1 61 {name:'Yes', replaceWith:' :yes: ', className:'col4-4' },
gremmie@1 62 {name:'Sleep', replaceWith:' :sleep: ', className:'col4-5' }
gremmie@1 63 ]
gremmie@1 64 },
gremmie@1 65 {separator:'---------------'},
gremmie@1 66 {name:'Preview', call:'preview', className:"preview"}
gremmie@1 67 ]
gremmie@1 68 }
gremmie@1 69
gremmie@1 70 // mIu nameSpace to avoid conflict.
gremmie@1 71 miu = {
gremmie@1 72 markdownTitle: function(markItUp, char) {
gremmie@1 73 heading = '';
gremmie@1 74 n = $.trim(markItUp.selection||markItUp.placeHolder).length;
gremmie@1 75 for(i = 0; i < n; i++) {
gremmie@1 76 heading += char;
gremmie@1 77 }
gremmie@1 78 return '\n'+heading;
gremmie@1 79 }
gremmie@1 80 }
bgneal@131 81
bgneal@131 82 $(document).ready(function() {
bgneal@131 83 $('.markItUp').markItUp(mySettings);
bgneal@131 84
bgneal@131 85 $('#smileys_dialog_popup').dialog({autoOpen:false});
bgneal@131 86 var firstTimeSmiley = true;
bgneal@131 87 $('#more_smileys_link').click(function () {
bgneal@131 88 $('#smileys_dialog_popup').dialog('open');
bgneal@131 89 var smileyTarget = $('.smileyTarget')[0];
bgneal@131 90 if (firstTimeSmiley) {
bgneal@131 91 $.ajax({
bgneal@131 92 url: '/smiley/farm/extra/',
bgneal@131 93 type: 'GET',
bgneal@131 94 dataType: 'html',
bgneal@131 95 success: function(data, textStatus) {
bgneal@131 96 var img = $('#smiley_busy');
bgneal@131 97 img.hide();
bgneal@131 98 img.after(data);
bgneal@131 99 $('#smileys_dialog_popup .smiley_farm img').click(function() {
bgneal@131 100 smileyTarget.value += ' ' + this.alt + ' ';
bgneal@131 101 smileyTarget.focus();
bgneal@131 102 });
bgneal@131 103 firstTimeSmiley = false;
bgneal@131 104 },
bgneal@131 105 error: function (xhr, textStatus, ex) {
bgneal@131 106 alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText);
bgneal@131 107 }
bgneal@131 108 });
bgneal@131 109 }
bgneal@131 110 return false;
bgneal@131 111 });
bgneal@131 112 $('#markdown_help_dialog_popup').dialog({autoOpen: false, width: 720, height: 600});
bgneal@131 113 var firstTimeMdHelp = true;
bgneal@131 114 $('#markdown_help_link').click(function () {
bgneal@131 115 $('#markdown_help_dialog_popup').dialog('open');
bgneal@131 116 if (firstTimeMdHelp) {
bgneal@131 117 $.ajax({
bgneal@131 118 url: '/core/markdown_help/',
bgneal@131 119 type: 'GET',
bgneal@131 120 dataType: 'html',
bgneal@131 121 success: function(data, textStatus) {
bgneal@131 122 var img = $('#markdown_busy');
bgneal@131 123 img.hide();
bgneal@131 124 img.after(data);
bgneal@131 125 firstTimeMdHelp = false;
bgneal@131 126 },
bgneal@131 127 error: function (xhr, textStatus, ex) {
bgneal@131 128 alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText);
bgneal@131 129 }
bgneal@131 130 });
bgneal@131 131 }
bgneal@131 132 return false;
bgneal@131 133 });
bgneal@131 134 });