Fully operational ul and ol buttons.
This commit is contained in:
@@ -48,6 +48,14 @@
|
||||
background-position: 2px -1438px;
|
||||
}
|
||||
|
||||
#editbar .ul {
|
||||
background-position: 2px -1366px;
|
||||
}
|
||||
|
||||
#editbar .ol {
|
||||
background-position: 2px -1078px;
|
||||
}
|
||||
|
||||
#editbar .tab {
|
||||
float: left;
|
||||
display: block;
|
||||
|
||||
@@ -8,6 +8,15 @@ Gollum = {
|
||||
}
|
||||
},
|
||||
|
||||
prefixStrategy: function(prefix, content, newline) {
|
||||
return {
|
||||
type: 'prefixLine',
|
||||
prefix: prefix,
|
||||
content: content,
|
||||
newline: newline
|
||||
}
|
||||
},
|
||||
|
||||
enclose: function(el, format, kind) {
|
||||
var cfg = Gollum.Formats[format][kind]
|
||||
var sel = el.getSelectionRange()
|
||||
@@ -17,17 +26,41 @@ Gollum = {
|
||||
} else {
|
||||
el.insertText(cfg.prefix + el.getSelectedText() + cfg.suffix, sel.start, sel.end, false)
|
||||
}
|
||||
},
|
||||
|
||||
prefix: function(el, format, kind) {
|
||||
var cfg = Gollum.Formats[format][kind]
|
||||
var sel = el.getSelectionRange()
|
||||
var cnt = el.getSelectedText()
|
||||
var prefix = cfg.prefix
|
||||
if (cfg.newline) {
|
||||
el.setSelectionRange(sel.start - 1, sel.start)
|
||||
var before = el.getSelectedText()
|
||||
if (before != '\n') {
|
||||
prefix = '\n' + prefix
|
||||
}
|
||||
}
|
||||
if (sel.start == sel.end) {
|
||||
el.insertText(prefix + cfg.content, sel.start, sel.start, false)
|
||||
el.setSelectionRange(sel.start + prefix.length, sel.start + prefix.length + cfg.content.length)
|
||||
} else {
|
||||
el.insertText(prefix + cnt + '\n', sel.start, sel.end, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Gollum.Formats = {
|
||||
asciidoc: {
|
||||
bold: Gollum.encloseStrategy('*', 'bold text', '*'),
|
||||
italic: Gollum.encloseStrategy('_', 'italic text', '_')
|
||||
italic: Gollum.encloseStrategy('_', 'italic text', '_'),
|
||||
ul: Gollum.prefixStrategy('* ', 'Bullet list item', true),
|
||||
ol: Gollum.prefixStrategy('. ', 'Numbered list item', true)
|
||||
},
|
||||
creole: {
|
||||
bold: Gollum.encloseStrategy('**', 'bold text', '**'),
|
||||
italic: Gollum.encloseStrategy('//', 'italic text', '//')
|
||||
italic: Gollum.encloseStrategy('//', 'italic text', '//'),
|
||||
ul: Gollum.prefixStrategy('* ', 'Bullet list item', true),
|
||||
ol: Gollum.prefixStrategy('# ', 'Numbered list item', true)
|
||||
},
|
||||
gollum: {
|
||||
link: Gollum.encloseStrategy('[[', 'Page Name', ']]'),
|
||||
@@ -35,23 +68,33 @@ Gollum.Formats = {
|
||||
},
|
||||
markdown: {
|
||||
bold: Gollum.encloseStrategy('**', 'bold text', '**'),
|
||||
italic: Gollum.encloseStrategy('*', 'italic text', '*')
|
||||
italic: Gollum.encloseStrategy('*', 'italic text', '*'),
|
||||
ul: Gollum.prefixStrategy('* ', 'Bullet list item', true),
|
||||
ol: Gollum.prefixStrategy('1. ', 'Numbered list item', true)
|
||||
},
|
||||
org: {
|
||||
bold: Gollum.encloseStrategy('*', 'bold text', '*'),
|
||||
italic: Gollum.encloseStrategy('/', 'italic text', '/')
|
||||
italic: Gollum.encloseStrategy('/', 'italic text', '/'),
|
||||
ul: Gollum.prefixStrategy('* ', 'Bullet list item', true),
|
||||
ol: Gollum.prefixStrategy('1. ', 'Numbered list item', true)
|
||||
},
|
||||
pod: {
|
||||
bold: Gollum.encloseStrategy('B<', 'bold text', '>'),
|
||||
italic: Gollum.encloseStrategy('I<', 'italic text', '>')
|
||||
italic: Gollum.encloseStrategy('I<', 'italic text', '>'),
|
||||
ul: Gollum.prefixStrategy('=item * ', 'Bullet list item', true),
|
||||
ol: Gollum.prefixStrategy('=item 1. ', 'Numbered list item', true)
|
||||
},
|
||||
rest: {
|
||||
bold: Gollum.encloseStrategy('**', 'bold text', '**'),
|
||||
italic: Gollum.encloseStrategy('*', 'italic text', '*')
|
||||
italic: Gollum.encloseStrategy('*', 'italic text', '*'),
|
||||
ul: Gollum.prefixStrategy('* ', 'Bullet list item', true),
|
||||
ol: Gollum.prefixStrategy('1. ', 'Numbered list item', true)
|
||||
},
|
||||
rdoc: {
|
||||
bold: Gollum.encloseStrategy('*', 'bold text', '*'),
|
||||
italic: Gollum.encloseStrategy('_', 'italic text', '_')
|
||||
italic: Gollum.encloseStrategy('_', 'italic text', '_'),
|
||||
ul: Gollum.prefixStrategy('* ', 'Bullet list item', true),
|
||||
ol: Gollum.prefixStrategy('1. ', 'Numbered list item', true)
|
||||
},
|
||||
roff: {
|
||||
bold: Gollum.encloseStrategy('\\fB', 'bold text', '\\fP'),
|
||||
@@ -59,7 +102,9 @@ Gollum.Formats = {
|
||||
},
|
||||
textile: {
|
||||
bold: Gollum.encloseStrategy('*', 'bold text', '*'),
|
||||
italic: Gollum.encloseStrategy('_', 'italic text', '_')
|
||||
italic: Gollum.encloseStrategy('_', 'italic text', '_'),
|
||||
ul: Gollum.prefixStrategy('* ', 'Bullet list item', true),
|
||||
ol: Gollum.prefixStrategy('# ', 'Numbered list item', true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,18 +117,6 @@ $(function(){
|
||||
|
||||
/* EditBar */
|
||||
|
||||
$('#editbar .bold').click(function() {
|
||||
var el = $('#guides .write textarea')
|
||||
var format = $('#guides .write select[name=format] option:selected').attr('value')
|
||||
Gollum.enclose(el, format, 'bold')
|
||||
})
|
||||
|
||||
$('#editbar .italic').click(function() {
|
||||
var el = $('#guides .write textarea')
|
||||
var format = $('#guides .write select[name=format] option:selected').attr('value')
|
||||
Gollum.enclose(el, format, 'italic')
|
||||
})
|
||||
|
||||
$('#editbar .link').click(function() {
|
||||
var el = $('#guides .write textarea')
|
||||
var format = $('#guides .write select[name=format] option:selected').attr('value')
|
||||
@@ -96,6 +129,30 @@ $(function(){
|
||||
Gollum.enclose(el, 'gollum', 'image')
|
||||
})
|
||||
|
||||
$('#editbar .bold').click(function() {
|
||||
var el = $('#guides .write textarea')
|
||||
var format = $('#guides .write select[name=format] option:selected').attr('value')
|
||||
Gollum.enclose(el, format, 'bold')
|
||||
})
|
||||
|
||||
$('#editbar .italic').click(function() {
|
||||
var el = $('#guides .write textarea')
|
||||
var format = $('#guides .write select[name=format] option:selected').attr('value')
|
||||
Gollum.enclose(el, format, 'italic')
|
||||
})
|
||||
|
||||
$('#editbar .ul').click(function() {
|
||||
var el = $('#guides .write textarea')
|
||||
var format = $('#guides .write select[name=format] option:selected').attr('value')
|
||||
Gollum.prefix(el, format, 'ul')
|
||||
})
|
||||
|
||||
$('#editbar .ol').click(function() {
|
||||
var el = $('#guides .write textarea')
|
||||
var format = $('#guides .write select[name=format] option:selected').attr('value')
|
||||
Gollum.prefix(el, format, 'ol')
|
||||
})
|
||||
|
||||
$('#editbar .tab a').click(function() {
|
||||
if ($(this).hasClass("open")) {
|
||||
$(this).removeClass("open")
|
||||
|
||||
@@ -13,13 +13,17 @@
|
||||
</label>
|
||||
<label>
|
||||
<div id="editbar">
|
||||
<div class="group group-separator">
|
||||
<span title="Link" class="link button">Link</span>
|
||||
<span title="Image" class="image button">Image</span>
|
||||
</div>
|
||||
<div class="group group-separator">
|
||||
<span title="Bold" class="bold button">Bold</span>
|
||||
<span title="Italic" class="italic button">Italic</span>
|
||||
</div>
|
||||
<div class="group">
|
||||
<span title="Link" class="link button">Link</span>
|
||||
<span title="Image" class="image button">Image</span>
|
||||
<div class="group group-separator">
|
||||
<span title="Unordered List" class="ul button">Unordered List</span>
|
||||
<span title="Ordered List" class="ol button">Ordered List</span>
|
||||
</div>
|
||||
<div class="group">
|
||||
<span class="tab advanced">
|
||||
|
||||
Reference in New Issue
Block a user