comparison static/js/markitup/sets/markdown/set.js @ 312:88b2b9cb8c1f

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