I do not know why but I added a page index template...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-02-02 06:25:27 +04:00
parent d1a8745c1c
commit ad1dcf7616
2 changed files with 41 additions and 1 deletions

View File

@ -463,7 +463,16 @@ $(document).ready(function(){
<div class="cover page"> <div class="cover page">
<div class="content" name="ArticleAnchorExample"> <div class="content" name="ArticleAnchorExample">
<h1>Page Templates</h1> <h1>Page Templates</h1>
<a href="#home">home</a><br>
<p>
This page contains several examples of template fields,
the first one is the simplest, the magazine name
(<span class="magazine-title-text">[MAGAZINE NAME]</span>),
then we'll have the index (see next) and in the bottom-right
corner is the page number...
</p>
<div class="article-index">[ARTICLE INDEX]</div>
<div class="page-number-text">[PAGE NUMBER]</div> <div class="page-number-text">[PAGE NUMBER]</div>
</div> </div>

View File

@ -1181,6 +1181,37 @@ var MagazineTemplates = {
|| 'PortableMag') || 'PortableMag')
}, },
// index...
'.article-index': function(elem){
var list = $('<ul/>')
var mag = $('.magazine')
// get the articles...
$('.magazine .article .cover h1').each(function(i, e){
e = $(e)
var lnk = $('<a/>')
.attr('href', '#' + getPageNumber(e.parents('.page').first()))
// XXX is this the right way to go?
.text(e.text() || 'No title')
list.append(
$('<li/>')
.append(lnk))
})
var root = $('<ul/>')
.append($('<li/>')
.append($('<a/>')
.attr('href', '#' + getPageNumber($('.magazine > .cover').first()))
// XXX is this the right way to go?
.text(mag.attr('title')
|| mag.attr('name')
|| 'Magazine')))
root.append(list)
elem
.html('')
// cover...
.append(root)
},
// setup page numbers... // setup page numbers...
'.page-number-text': function(elem){ '.page-number-text': function(elem){
elem.each(function(_, e){ elem.each(function(_, e){