annotate static/js/markitup/sets/markdown/set.js @ 334:6805d15cda13

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