Skip to content

Commit

Permalink
Standardising reader move methods to a single moveTo(locus).
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph committed Mar 3, 2010
1 parent a154fd0 commit ba5f213
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 47 deletions.
2 changes: 1 addition & 1 deletion src/controls/placesaver.js
Expand Up @@ -87,7 +87,7 @@ Carlyle.Controls.PlaceSaver = function (reader) {
function restorePlace() {
var place = savedPlace();
if (place) {
reader.moveToPercentageThrough(place.percent, place.component);
reader.moveTo({ percent: place.percent, componentId: place.component });
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/controls/scrubber.js
Expand Up @@ -165,10 +165,10 @@ Carlyle.Controls.Scrubber = function (reader) {

var endEvt = function (evt) {
var place = moveEvt(evt, p.lastX);
p.reader.moveToPercentageThrough(
place.percentageThrough,
place.componentId
);
p.reader.moveTo({
percent: place.percentageThrough,
componentId: place.componentId
});
cntr.removeEventListener(eventType('move'), moveEvt, false);
document.body.removeEventListener(eventType('end'), endEvt, false);
bubble.style.display = "none";
Expand Down
2 changes: 1 addition & 1 deletion src/flippers/legacy.js
Expand Up @@ -68,7 +68,7 @@ Carlyle.Flippers.Legacy = function (reader, setPageFn) {
Carlyle.Styles.Flippers.Legacy.next
);
p.divs.nextButton.onclick = function () {
p.reader.moveToPercentageThrough(1.5);
moveTo({ percent: 1.5 });
}
p.page.scrollerDiv.appendChild(p.divs.nextButton);
}
Expand Down
48 changes: 7 additions & 41 deletions src/reader.js
Expand Up @@ -222,7 +222,7 @@ Carlyle.Reader = function (node, bookData, options) {
p.flipper.overrideDimensions();
}

moveToPage(pageNumber());
moveTo({ page: pageNumber() });
}


Expand All @@ -248,44 +248,11 @@ Carlyle.Reader = function (node, bookData, options) {
}


// Flips to the given page within the current component. If pageN is
// greater than the number of pages in this component, overflows into
// subsequent components.
// Moves the current page as specified by the locus. See
// Carlyle.Book#changePage for documentation on the locus argument.
//
// The componentId is optional, defaults to the current component.
//
function moveToPage(pageN, componentId) {
if (!componentId) {
var currPlace = getPlace();
if (currPlace) {
componentId = currPlace.componentId();
} else {
componentId = null;
}
}

p.flipper.moveTo({ page: pageN, componentId: componentId});
}


// Flips to the page approximately 'percent' of the way
// through the component. Percent, contrary to expectations perhaps,
// should be a float, where 0.0 is the first page and 1.0 is the last page
// of the component.
//
// The componentId is optional, defaults to the current component.
//
function moveToPercentageThrough(percent, componentId) {
if (!componentId) {
var currPlace = getPlace();
if (currPlace) {
componentId = currPlace.componentId();
} else {
componentId = null;
}
}

p.flipper.moveTo({ percent: percent, componentId: componentId});
function moveTo(locus) {
p.flipper.moveTo(locus);
}


Expand All @@ -295,7 +262,7 @@ Carlyle.Reader = function (node, bookData, options) {
console.log("Skipping to chapter: " + src);
//FIXME: SHOULD BE ACTIVE PAGE?
var place = p.book.placeOfChapter(p.divs.pages[0].contentDiv, src);
p.flipper.moveTo(place.getLocus());
moveTo(place.getLocus());
}


Expand Down Expand Up @@ -563,8 +530,7 @@ Carlyle.Reader = function (node, bookData, options) {
API.getBook = getBook;
API.reapplyStyles = reapplyStyles;
API.getPlace = getPlace;
API.moveToPage = moveToPage;
API.moveToPercentageThrough = moveToPercentageThrough;
API.moveTo = moveTo;
API.skipToChapter = skipToChapter;
API.resized = resized;
API.addControl = addControl;
Expand Down

0 comments on commit ba5f213

Please sign in to comment.