Skip to content

Commit

Permalink
Merge branch 'release/0.10'
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris Schneiderman committed Dec 20, 2013
2 parents 96d7a59 + e6fc9bd commit 92405dd
Show file tree
Hide file tree
Showing 29 changed files with 4,582 additions and 657 deletions.
35 changes: 0 additions & 35 deletions host_app_reference_files/host_app_feedback.js

This file was deleted.

71 changes: 0 additions & 71 deletions host_app_reference_files/reader.css

This file was deleted.

101 changes: 0 additions & 101 deletions host_app_reference_files/reader.html

This file was deleted.

99 changes: 39 additions & 60 deletions js/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,10 @@ ReadiumSDK.Helpers.Rect = function(left, top, width, height) {
tolerance = 0;
}

return !(rect.right() < this.left + tolerance
|| rect.left > this.right() - tolerance
|| rect.bottom() < this.top + tolerance
|| rect.top > this.bottom() - tolerance);


return !(rect.right() < this.left + tolerance ||
rect.left > this.right() - tolerance ||
rect.bottom() < this.top + tolerance ||
rect.top > this.bottom() - tolerance);
}
};

Expand All @@ -68,31 +66,6 @@ ReadiumSDK.Helpers.Rect.fromElement = function($element) {
return new ReadiumSDK.Helpers.Rect(offsetLeft, offsetTop, offsetWidth, offsetHeight);
};

ReadiumSDK.Helpers.LoadIframe = function(iframe, src, callback, context) {

var isWaitingForFrameLoad = true;

iframe.onload = function() {

isWaitingForFrameLoad = false;
callback.call(context, true);

};

//yucks! iframe doesn't trigger onerror event - there is no reliable way to know that iframe finished
// attempt tot load resource (successfully or not;
window.setTimeout(function(){

if(isWaitingForFrameLoad) {
isWaitingForFrameLoad = false;
callback.call(context, false);
}

}, 500);

iframe.src = src;
};


/**
* @return {string}
Expand Down Expand Up @@ -158,51 +131,57 @@ ReadiumSDK.Helpers.Margins.empty = function() {
};

ReadiumSDK.Helpers.loadTemplate = function(name, params) {
return ReadiumSDK.Helpers.loadTemplate.cache[name];
};

if( !ReadiumSDK.Helpers.loadTemplate.cache ) {
ReadiumSDK.Helpers.loadTemplate.cache = {};
}
ReadiumSDK.Helpers.loadTemplate.cache = {
"fixed_book_frame" : '<div id="fixed-book-frame" class="clearfix book-frame fixed-book-frame"></div>',
"fixed_page_frame" : '<div class="fixed-page-frame"><iframe scrolling="no" class="iframe-fixed"></iframe></div>',
"reflowable_book_frame" : '<div id="reflowable-book-frame" class="clearfix book-frame reflowable-book-frame"><div id="reflowable-content-frame" class="reflowable-content-frame"><iframe scrolling="no" id="epubContentIframe"></iframe></div></div>'
};

var template = ReadiumSDK.Helpers.loadTemplate.cache[name];
ReadiumSDK.Helpers.setStyles = function(styles, $element) {

if(!template) {
var count = styles.length;

var templText;
if(!count) {
return;
}

if (name == "fixed_book_frame") {
templText = '<div id="fixed-book-frame" class="clearfix book-frame fixed-book-frame"></div>';
}
else if (name == "fixed_page_frame") {
templText = '<div class="fixed-page-frame"><iframe scrolling="no" class="iframe-fixed"></iframe></div>';
}
else if (name == "reflowable_book_frame") {
templText = '<div id="reflowable-book-frame" class="clearfix book-frame reflowable-book-frame"><div id="reflowable-content-frame" class="reflowable-content-frame"><iframe scrolling="no" id="epubContentIframe"></iframe></div></div>';
for(var i = 0; i < count; i++) {
var style = styles[i];
if(style.selector) {
$(style.selector, $element).css(style.declarations);
}
else {
console.error(name + " is not a recognized template name!");
return undefined;
$element.css(style.declarations);
}

template = _.template(templText);
ReadiumSDK.Helpers.loadTemplate.cache[name] = template;
}

return template(params);

};

ReadiumSDK.Helpers.setStyles = function(styles, $element) {
ReadiumSDK.Helpers.getOrientation = function($viewport) {

var count = styles.length;
var viewportWidth = $viewport.width();
var viewportHeight = $viewport.height();

if(!count) {
return;
if(!viewportWidth || !viewportHeight) {
return undefined;
}

for(var i = 0; i < count; i++) {
var style = styles[i];
$(style.selector, $element).css(style.declarations);
}
return viewportWidth >= viewportHeight ? ReadiumSDK.Views.ORIENTATION_LANDSCAPE : ReadiumSDK.Views.ORIENTATION_PORTRAIT;
};

ReadiumSDK.Helpers.isRenditionSpreadPermittedForItem = function(item, orientation) {

return !item.rendition_spread
|| item.rendition_spread == ReadiumSDK.Models.SpineItem.RENDITION_SPREAD_BOTH
|| item.rendition_spread == ReadiumSDK.Models.SpineItem.RENDITION_SPREAD_AUTO
|| (item.rendition_spread == ReadiumSDK.Models.SpineItem.RENDITION_SPREAD_LANDSCAPE
&& orientation == ReadiumSDK.Views.ORIENTATION_LANDSCAPE)
|| (item.rendition_spread == ReadiumSDK.Models.SpineItem.RENDITION_SPREAD_PORTRAIT
&& orientation == ReadiumSDK.Views.ORIENTATION_PORTRAIT );
};



Loading

0 comments on commit 92405dd

Please sign in to comment.