bug with loadJSON turned out to be a quirk in jQuery that refuses to set background:none on just created but not attached elements...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-02-07 01:03:36 +04:00
parent 785bada4a4
commit 0ab4ff3c85
3 changed files with 41 additions and 36 deletions

View File

@ -9,15 +9,17 @@
[_] 50% move some of the current configuration options to the magazine...
[X] page align
[_] resize settings (.no-resize class)
[_] add transition-duration editors to config page (a-la PAGES_IN_RIBBON)...
| will help tuning the system,,,
[_] Editor: add toggleEditiorMode to all editables in all versions...
| text areas, inputs, ...
[_] EXPERIMENT: Try using scroll instead of left of .magazine....
| this might improve speed...
[_] 0% add two main page themes (global/local applicable):
[_] light
[_] dark
[_] Editor: add toggleEditiorMode to all editables in all versions...
| text areas, inputs, ...
[_] add global credits and copyright page...
| list and link all the used software and authors...
[_] add transition-duration editors to config page (a-la PAGES_IN_RIBBON)...
| will help tuning the system,,,
[_] EXPERIMENT: Try using scroll instead of left of .magazine....
| this might improve speed...
[_] JSON: add page URLs as an alternative to direct content...
| use AJAX to get remote pages and their nested content
[_] JSON: add metadata section that can be downloaded separately...
@ -46,8 +48,6 @@
[X] (i) info
[_] (+) new
[_] (x) remove
[_] add global credits and copyright page...
| list and link all the used software and authors...
[_] add default empty state to viewer, magazine and article...
| use it to trigger a "New Magazine", "New Cover"/"New Article" and
| "New Cover"/"New Page" actions...
@ -85,6 +85,8 @@
[_] BUG: href to existing anchors will mess up layout...
| need to find out how can we disable anchor links from actually
| going to the anchor...
[X] BUG: jquery does not set background to none on detached elements...
| use transparent instead!!
[X] 100% add page sets..
[X] general page navigation
[X] serialization

View File

@ -499,7 +499,7 @@ $(document).ready(function(){
</div>
</div>
<div class="page">
<div class="page" style="background: black; color: white;">
<div class="content">
<h1>Two column</h1>
<div style="float:left; width: 45%; height: 100%; margin: 10px;">
@ -570,21 +570,21 @@ $(document).ready(function(){
<div class="article">
<!-- page set -->
<div class="page-set" style="background: url(img.jpg) no-repeat right top; background-size: 100% auto; color: white;">
<div class="page cover no-resize page-align-left" style="background:none">
<div class="page cover no-resize page-align-left" style="background:transparent">
<div class="content">
<h1>Page Set Example</h1>
<div class="page-number-text">[PAGE NUMBER]</div>
</div>
</div>
<div class="page no-resize" style="background:none">
<div class="page no-resize" style="background:transparent">
<div class="content">
Page in set<br>
<div class="page-number-text">[PAGE NUMBER]</div>
</div>
</div>
<div class="page no-resize page-align-right" style="background:none">
<div class="page no-resize page-align-right" style="background:transparent">
<div class="content">
Page in set<br>

View File

@ -1032,6 +1032,8 @@ JSONMetadata = {
id: 'as-is',
name: 'as-is',
title: 'as-is',
// NOTE: do not use background:none as jQuery refuses to set it on
// detached elements.
style: 'as-is',
authors: {
reader: function(data){
@ -1140,55 +1142,56 @@ function buildJSON(export_bookmarks, export_position){
// XXX this does not load page attrs correctly...
function loadJSON(data, load_user_data){
function _build(block, elem){
function _build(parent, data){
// page...
if(elem.type == 'page'){
var res = createPage(elem.content)
.addClass(elem['class'])
.appendTo(block)
if(data.type == 'page'){
var res = createPage(data.content)
.addClass(data['class'])
.appendTo(parent)
// cover...
} else if(elem.type == 'cover'){
var res = createCoverPage(elem.content)
.addClass(elem['class'])
.appendTo(block)
} else if(data.type == 'cover'){
var res = createCoverPage(data.content)
.addClass(data['class'])
.appendTo(parent)
// page-set...
} else if(elem.type == 'page-set') {
} else if(data.type == 'page-set') {
// buiold an article...
var res = createEmptyPageSet()
.addClass(elem['class'])
.appendTo(block)
.addClass(data['class'])
.appendTo(parent)
// populate article with pages...
$(elem.pages).each(function(_, e){
$(data.pages).each(function(_, e){
_build(res, e)
})
// article...
} else if(elem.type == 'article') {
} else if(data.type == 'article') {
// buiold an article...
var res = createEmptyArticle()
.addClass(elem['class'])
.appendTo(block)
.addClass(data['class'])
.appendTo(parent)
// populate article with pages...
$(elem.pages).each(function(_, e){
$(data.pages).each(function(_, e){
_build(res, e)
})
// other...
// NOTE: on a wll-formed JSON we'll never go in here, but just
// in case...
} else if(elem.type == 'raw-html') {
var res = createPage(elem.content)
.addClass(elem['class'])
.appendTo(block)
} else if(data.type == 'raw-html') {
var res = createPage(data.content)
.addClass(data['class'])
.appendTo(parent)
}
// metadata...
// XXX still might be a bit buggy -- might not be loading some
// data correctly...
writeMetadata(elem, res)
// XXX for some reason this does not set the style attr on pages in page-set...
writeMetadata(res, data)
return res
}
// check version...