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