Bookdetail is handled with ajax. Template is not complete though. re #73
Fixes some small bugs with the other template.
This commit is contained in:
parent
b7ab8bd9d9
commit
a0cb911ce9
5
base.php
5
base.php
|
@ -343,6 +343,7 @@ class Page
|
|||
public $query;
|
||||
public $favicon;
|
||||
public $n;
|
||||
public $book;
|
||||
public $totalNumber = -1;
|
||||
public $entryArray = array();
|
||||
|
||||
|
@ -678,8 +679,8 @@ class PageBookDetail extends Page
|
|||
{
|
||||
public function InitializeContent ()
|
||||
{
|
||||
$book = Book::getBookById ($this->idGet);
|
||||
$this->title = $book->title;
|
||||
$this->book = Book::getBookById ($this->idGet);
|
||||
$this->title = $this->book->title;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
39
book.php
39
book.php
|
@ -115,7 +115,16 @@ class Book extends Base {
|
|||
}
|
||||
}
|
||||
$serie = $this->getSerie ();
|
||||
if (is_null ($serie)) $serie = "";
|
||||
if (is_null ($serie)) {
|
||||
$sn = "";
|
||||
$scn = "";
|
||||
$su = "";
|
||||
} else {
|
||||
$sn = $serie->name;
|
||||
$scn = str_format (localize ("content.series.data"), $this->seriesIndex, $serie->name);
|
||||
$link = new LinkNavigation ($serie->getUri ());
|
||||
$su = $link->hrefXhtml ();
|
||||
}
|
||||
|
||||
return array ("hasCover" => $this->hasCover,
|
||||
"preferedData" => $preferedData,
|
||||
|
@ -124,7 +133,33 @@ class Book extends Base {
|
|||
"pubDate" => $this->getPubDate (),
|
||||
"authorsName" => $this->getAuthorsName (),
|
||||
"tagsName" => $this->getTagsName (),
|
||||
"seriesName" => $serie);
|
||||
"seriesName" => $sn,
|
||||
"seriesCompleteName" => $scn,
|
||||
"seriesurl" => $su);
|
||||
|
||||
}
|
||||
public function getFullContentArray () {
|
||||
$out = $this->getContentArray ();
|
||||
|
||||
$out ["detailurl"] = $this->getDetailUrl (true);
|
||||
$out ["coverurl"] = Data::getLink ($this, "jpg", "image/jpeg", Link::OPDS_IMAGE_TYPE, "cover.jpg", NULL)->hrefXhtml ();
|
||||
$out ["thumbnailurl"] = Data::getLink ($this, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL, NULL, 150)->hrefXhtml ();
|
||||
$out ["datas"] = array ();
|
||||
foreach ($this->getDatas() as $data) {
|
||||
array_push ($out ["datas"], array ("format" => $data->format, "url" => $data->getHtmlLink ()));
|
||||
}
|
||||
$out ["authors"] = array ();
|
||||
foreach ($this->getAuthors () as $author) {
|
||||
$link = new LinkNavigation ($author->getUri ());
|
||||
array_push ($out ["authors"], array ("name" => $author->name, "url" => $link->hrefXhtml ()));
|
||||
}
|
||||
$out ["tags"] = array ();
|
||||
foreach ($this->getTags () as $tag) {
|
||||
$link = new LinkNavigation ($tag->getUri ());
|
||||
array_push ($out ["tags"], array ("name" => $tag->name, "url" => $link->hrefXhtml ()));
|
||||
}
|
||||
;
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function getDetailUrl ($permalink = false) {
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
foreach ($currentPage->entryArray as $entry) {
|
||||
array_push ($entries, $entry->getContentArray ());
|
||||
}
|
||||
if (!is_null ($currentPage->book)) {
|
||||
$out ["book"] = $currentPage->book->getFullContentArray ();
|
||||
}
|
||||
$out ["databaseId"] = GetUrlParam (DB, "");
|
||||
$out ["databaseName"] = Base::getDbName ();
|
||||
$out ["page"] = $page;
|
||||
|
@ -60,7 +63,8 @@
|
|||
"previousAlt" => localize ("paging.previous.alternate"),
|
||||
"nextAlt" => localize ("paging.next.alternate"),
|
||||
"searchAlt" => localize ("search.alternate"),
|
||||
"homeAlt" => localize ("home.alternate"));
|
||||
"homeAlt" => localize ("home.alternate"),
|
||||
"permalinkAlt" => localize ("permalink.alternate"));
|
||||
|
||||
$out ["containsBook"] = 0;
|
||||
if ($currentPage->containsBook ()) {
|
||||
|
|
11
index.php
11
index.php
|
@ -95,13 +95,6 @@
|
|||
nextEffect : 'none'
|
||||
<?php if ($isEink) echo ", openEffect : 'none', closeEffect : 'none', helpers : {overlay : null}"; ?>
|
||||
});
|
||||
|
||||
$(".fancydetail").fancybox({
|
||||
'type' : 'ajax',
|
||||
prevEffect : 'none',
|
||||
nextEffect : 'none'
|
||||
<?php if ($isEink) echo ", openEffect : 'none', closeEffect : 'none', helpers : {overlay : null}"; ?>
|
||||
});
|
||||
<?php } ?>
|
||||
|
||||
$(".headright").click(function(){
|
||||
|
@ -114,6 +107,10 @@
|
|||
}
|
||||
});
|
||||
|
||||
$.get('templates/default/bookdetail.html', function(data){
|
||||
templateBookDetail = doT.template (data);
|
||||
});
|
||||
|
||||
$.get('templates/default/frontpage.html', function(data){
|
||||
template = doT.template(data);
|
||||
$.getJSON('<?php echo "getJSON.php?" . str_replace ("&", "&", $_SERVER["QUERY_STRING"]); ?>', function(data) {
|
||||
|
|
34
templates/default/bookdetail.html
Normal file
34
templates/default/bookdetail.html
Normal file
|
@ -0,0 +1,34 @@
|
|||
<article class="bookpopup">
|
||||
<span class="cover">
|
||||
{{? it.book.hasCover == 1}}
|
||||
<a href="{{=it.book.coverurl}}">
|
||||
<img src="{{=it.book.thumbnailurl}}" alt="{{=it.i18n.coverAlt}}" />
|
||||
</a>
|
||||
{{?}}
|
||||
</span>
|
||||
<h2 class="download">
|
||||
{{~it.book.datas:data:i}}
|
||||
<a href="{{=data.url}}">{{=data.format}}</a><br />
|
||||
{{~}}
|
||||
</h2>
|
||||
<h1><a rel="bookmark" href="{{=it.book.detailurl}}"><img src="images/Link.png?v={{=it.version}}" alt="{{=it.i18n.permalinkAlt}}" /></a>{{=htmlEscape (it.title)}}</h1>
|
||||
<p class="popupless">
|
||||
<h3>{{=it.i18n.authorsTitle}}: </h3>
|
||||
{{~it.book.authors:author:j}}
|
||||
{{? j > 0}}, {{?}}<a href="{{=author.url}}">{{=htmlEscape (author.name)}}</a>
|
||||
{{~}}
|
||||
</p>
|
||||
{{? it.book.tagsName != ""}}
|
||||
<p class="popupless">
|
||||
<h3>{{=it.i18n.tagsTitle}}: </h3>
|
||||
{{~it.book.tags:tag:k}}
|
||||
{{? k > 0}}, {{?}}<a href="{{=tag.url}}">{{=htmlEscape (tag.name)}}</a>
|
||||
{{~}}
|
||||
</p>
|
||||
{{?}}
|
||||
{{? it.book.seriesName != ""}}
|
||||
<p class="popupless">
|
||||
<h3><a href="{{=it.book.seriesurl}}">{{=it.i18n.seriesTitle}}</a> : </h3>{{=htmlEscape (it.book.seriesCompleteName)}}
|
||||
</p>
|
||||
{{?}}
|
||||
</article>
|
|
@ -55,7 +55,7 @@
|
|||
</h2>
|
||||
<h4>{{=it.i18n.authorsTitle}} : </h4><span class="sa">{{=htmlEscape (entry.book.authorsName)}}</span><br />
|
||||
{{? entry.book.tagsName != ""}}<h4>{{=it.i18n.tagsTitle}} : </h4>{{=htmlEscape (entry.book.tagsName)}}<br />{{?}}
|
||||
{{? entry.book.seriesName != ""}}<h4>{{=it.i18n.seriesTitle}} : </h4>{{=htmlEscape (entry.book.SeriesName)}}<br />{{?}}
|
||||
{{? entry.book.seriesName != ""}}<h4>{{=it.i18n.seriesTitle}} : </h4>{{=htmlEscape (entry.book.seriesName)}}<br />{{?}}
|
||||
</div></a>
|
||||
</article>
|
||||
{{?}}
|
||||
|
|
18
util.js
18
util.js
|
@ -1,4 +1,4 @@
|
|||
var template, result;
|
||||
var template, templateBookDetail, result;
|
||||
|
||||
function htmlEscape(str) {
|
||||
return String(str)
|
||||
|
@ -10,7 +10,7 @@ function htmlEscape(str) {
|
|||
}
|
||||
|
||||
function navigateTo (url) {
|
||||
jsonurl = url.replace ("index", "getJSON");
|
||||
var jsonurl = url.replace ("index", "getJSON");
|
||||
$.getJSON(jsonurl, function(data) {
|
||||
history.pushState(data, "", url);
|
||||
updatePage (data);
|
||||
|
@ -23,6 +23,20 @@ function updatePage (data) {
|
|||
$(".container").html (result);
|
||||
|
||||
ajaxifyLinks ();
|
||||
|
||||
$(".fancydetail").click(function(event){
|
||||
event.preventDefault();
|
||||
var url = $(this).attr("href");
|
||||
var jsonurl = url.replace ("bookdetail", "getJSON");
|
||||
$.getJSON(jsonurl, function(data) {
|
||||
var detail = templateBookDetail (data);
|
||||
$.fancybox( {
|
||||
content: detail,
|
||||
autoSize: true
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function ajaxifyLinks () {
|
||||
|
|
Loading…
Reference in a new issue