forked from 0x2620/pandora
text panel: skeleton for chapters/footnotes/keywords
This commit is contained in:
parent
ec652cc06e
commit
e469c0904e
1 changed files with 43 additions and 0 deletions
|
@ -295,6 +295,49 @@ pandora.ui.textHTML = function(text) {
|
||||||
collapseToEnd: false,
|
collapseToEnd: false,
|
||||||
editable: text.editable,
|
editable: text.editable,
|
||||||
format: function(text) {
|
format: function(text) {
|
||||||
|
/*
|
||||||
|
var $text = $('<div>').html(text),
|
||||||
|
$chapterElement = $text.find('[data-type="chapters"]')[0],
|
||||||
|
$footnoteElement = $text.find('[data-type="footnotes"]')[0],
|
||||||
|
$keywordElement = $text.find('[data-type="keywords"]')[0],
|
||||||
|
$chapters = [],
|
||||||
|
$footnotes = [],
|
||||||
|
$keywords = [],
|
||||||
|
footnote = 0,
|
||||||
|
keywords = [];
|
||||||
|
// chapters
|
||||||
|
$text.find('[data-type="chapter"]').each(function(index, element) {
|
||||||
|
var $element = $(element),
|
||||||
|
name = $element.attr('data-name') || $element.html(),
|
||||||
|
level;
|
||||||
|
Ox.loop(1, 7, function(i) {
|
||||||
|
if ($element.is('h' + i)) {
|
||||||
|
level = i;
|
||||||
|
return false; // break
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!level) {
|
||||||
|
level = name.split(' ')[0].split('.').length || 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// footnotes
|
||||||
|
$text.find('[data-type="footnote"]').each(function(index, element) {
|
||||||
|
var $element = $(element),
|
||||||
|
value = $element.attr('data-value');
|
||||||
|
footnote = value ? parseInt(value) : footnote + 1;
|
||||||
|
});
|
||||||
|
// keywords
|
||||||
|
$text.find('[data-type="keywords"]').each(function(index, element) {
|
||||||
|
var $element = $(element),
|
||||||
|
value = $element.attr('data-value') || element.html();
|
||||||
|
keywords.append(value);
|
||||||
|
});
|
||||||
|
$keywords = Ox.map(Ox.sort(Ox.unique(keywords)), function(keyword) {
|
||||||
|
return $('<a>').attr({href: '#'}).html(keyword);
|
||||||
|
});
|
||||||
|
text = $text.html();
|
||||||
|
*/
|
||||||
|
// embeds
|
||||||
var index = 0;
|
var index = 0;
|
||||||
return text.replace(
|
return text.replace(
|
||||||
/<a [^<>]*?href="(.+?)".*?>/gi,
|
/<a [^<>]*?href="(.+?)".*?>/gi,
|
||||||
|
|
Loading…
Reference in a new issue