general cleanup of magazine.js...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-02-06 20:52:44 +04:00
parent 335342ccfa
commit a6ab8d33bd

View File

@ -27,19 +27,16 @@ var FULL_PAGE_ALIGN = 'center'
// if true will make page resizes after window resize animated...
var ANIMATE_WINDOW_RESIZE = true
// if true will disable page dragging in single page mode...
// if false will disable page dragging in single page mode...
var DRAG_FULL_PAGE = true
// XXX make this default and remove the option...
// XXX this produces a funny animation that gets more ampletude the farther
// we get to the right from the no-resize element...
// ...think the reason is .no-resize page centering...
// XXX still buggy on togglePageView to TN after funny sized pages...
// XXX will produce a bad transition on togglePageView to TN and back after no-resize sized pages...
// ...the most probable reason is that we waste too much time between
// setting different values to elements...
// need to keep wrights as tight as possible...
//var USE_REAL_PAGE_SIZES = true
var USE_REAL_PAGE_SIZES = false
var USE_REAL_PAGE_SIZES = true
//var USE_REAL_PAGE_SIZES = false
// if true this will make each page flip update the hash url...
// if false, only direct linking will update the url.
@ -110,8 +107,9 @@ function getPageAlign(page){
: FULL_PAGE_ALIGN)
}
// XXX need a way to get the title without a magazine loaded...
// ...something like a current magazine option...
// NOTE: this will only produce a title if a magazine is loaded and it
// has a title, otherwise undefined is returned....
function getMagazineTitle(){
return ($('.magazine').attr('title')
|| $('.magazine').attr('name'))
@ -282,8 +280,6 @@ function swipeHandler(evt, phase, direction, distance, duration, fingers){
// NOTE: if n is 1 then fit_to_content bool argument controls wether:
// - the page will be stretched to viewer (false)
// - or to content (true)
// XXX on USE_REAL_PAGE_SIZES offset is a bit off...
// this is most noticable when going into full page mode...
function fitNPages(n, fit_to_content){
if(n == null){
n = 1
@ -356,8 +352,6 @@ function fitNPages(n, fit_to_content){
// NOTE: we need to calculate the offset as the actual widths during
// the animation are not correct... so just looking at .position()
// will be counterproductive...
// XXX still there is some error (rounding, page zoom?)...
// calculate offset...
if(!USE_REAL_PAGE_SIZES && fit_to_content){
var offset = rW * getPageNumber()-1
} else {
@ -871,7 +865,6 @@ function saveJSONStorage(title){
return data
}
// load JSON magazine data from storage...
// XXX we're losing the bookmarks at some point...
function loadJSONStorage(title){
if(title == null){
title = getMagazineTitle()
@ -1122,7 +1115,7 @@ function loadJSON(data, load_user_data){
writeMetadata(elem, res)
}
// XXX check version...
// check version...
var version = data['format-version']
if(version != JSON_FORMAT_VERSION){
// XXX this might be a good spot to add data conversion between
@ -1132,7 +1125,6 @@ function loadJSON(data, load_user_data){
// create an empty magazine...
var mag = createEmptyMagazine(data.title)
// XXX for some reason this does not restore name/title...
writeMetadata(mag, data)
// build the actual strcture...
$(data.pages).each(function(_, e){
@ -1296,8 +1288,8 @@ function loadMagazineUserData(position, bookmarks){
}
// XXX some things get really surprized when this is called, make things
// work with the mag cleared...
// XXX check that all code does not err if the .magazine element is not
// present...
// XXX do we need to clear the event handlers here?
// ...this mostly concerns bookmarking and how jQuery handles events
// on removed elements -- unbind and remove or just forget about it?