Skip to content
This repository
Browse code

A little bit of cleanup. Including removing the Vert dimension.

  • Loading branch information...
commit 1b5c86f255335420363cdc8379951e85275a7e04 1 parent 83cf064
Joseph Pearson authored

Showing 30 changed files with 21 additions and 136 deletions. Show diff stats Hide diff stats

  1. +4 1 src/compat/browser.js
  2. +2 0  src/compat/css.js
  3. +3 0  src/compat/env.js
  4. +9 0 src/compat/stubs.js
  5. +0 3  src/controls/contents.js
  6. +0 4 src/controls/magnifier.js
  7. +0 3  src/controls/placesaver.js
  8. +0 3  src/controls/scrubber.js
  9. +0 3  src/controls/spinner.js
  10. +0 2  src/controls/stencil.js
  11. +0 1  src/core/book.js
  12. +1 1  src/core/events.js
  13. +1 8 src/core/monocle.js
  14. +0 3  src/core/reader.js
  15. +1 0  src/core/styles.js
  16. +0 87 src/dimensions/vert.js
  17. +0 3  src/flippers/slider.js
  18. +0 1  test/bookdata/index.html
  19. +0 1  test/componentry/index.html
  20. +0 1  test/controls/index.html
  21. +0 2  test/dogfood/index.html
  22. +0 1  test/dogfood/simplest.html
  23. +0 1  test/events/index.html
  24. +0 1  test/flippers/index.html
  25. +0 1  test/locus-search/index.html
  26. +0 1  test/panels/index.html
  27. +0 1  test/rich_content/index.html
  28. +0 1  test/showcase/01-velveteen/index.html
  29. +0 1  test/stencil/index.html
  30. +0 1  test/stylesheet/index.html
5 src/compat/browser.js
... ... @@ -1,4 +1,4 @@
1   -Monocle.Browser = {}
  1 +Monocle.Browser = {};
2 2
3 3 // Compare the user-agent string to a string or regex pattern.
4 4 //
@@ -20,6 +20,8 @@ Monocle.Browser.is = {
20 20 }
21 21
22 22
  23 +// Set the browser engine string.
  24 +//
23 25 if (Monocle.Browser.is.IE) {
24 26 Monocle.Browser.engine = "IE";
25 27 } else if (Monocle.Browser.is.Opera) {
@@ -29,6 +31,7 @@ if (Monocle.Browser.is.IE) {
29 31 } else if (Monocle.Browser.is.Gecko) {
30 32 Monocle.Browser.engine = "Gecko";
31 33 } else {
  34 + console.warn("Unknown engine; assuming W3C compliant.");
32 35 Monocle.Browser.engine = "W3C";
33 36 }
34 37
2  src/compat/css.js
... ... @@ -1,3 +1,5 @@
  1 +// A class for manipulating CSS properties in a browser-engine-aware way.
  2 +//
1 3 Monocle.CSS = function () {
2 4
3 5 var API = { constructor: Monocle.CSS }
3  src/compat/env.js
... ... @@ -1,3 +1,6 @@
  1 +// A class that tests the browser environment for required capabilities and
  2 +// known bugs (for which we have workarounds).
  3 +//
1 4 Monocle.Env = function () {
2 5
3 6 var API = { constructor: Monocle.Env }
9 src/compat/stubs.js
@@ -27,3 +27,12 @@ window.console.compatDir = function (obj) {
27 27
28 28 window.console.log(stringify(obj));
29 29 }
  30 +
  31 +
  32 +// A convenient alias for setTimeout that assumes 0 if no timeout is specified.
  33 +//
  34 +Monocle.defer = function (fn, time) {
  35 + if (fn && typeof fn == "function") {
  36 + return setTimeout(fn, time || 0);
  37 + }
  38 +}
3  src/controls/contents.js
... ... @@ -1,7 +1,4 @@
1 1 Monocle.Controls.Contents = function (reader) {
2   - if (Monocle.Controls == this) {
3   - return new Monocle.Controls.Contents(reader);
4   - }
5 2
6 3 var API = { constructor: Monocle.Controls.Contents }
7 4 var k = API.constants = API.constructor;
4 src/controls/magnifier.js
... ... @@ -1,9 +1,5 @@
1 1 Monocle.Controls.Magnifier = function (reader) {
2   - if (Monocle.Controls == this) {
3   - return new Monocle.Controls.Magnifier(reader);
4   - }
5 2
6   - // Public methods and properties.
7 3 var API = { constructor: Monocle.Controls.Magnifier }
8 4 var k = API.constants = API.constructor;
9 5 var p = API.properties = {
3  src/controls/placesaver.js
... ... @@ -1,7 +1,4 @@
1 1 Monocle.Controls.PlaceSaver = function (bookId) {
2   - if (Monocle.Controls == this) {
3   - return new Monocle.Controls.PlaceSaver(bookId);
4   - }
5 2
6 3 var API = { constructor: Monocle.Controls.PlaceSaver }
7 4 var k = API.constants = API.constructor;
3  src/controls/scrubber.js
... ... @@ -1,7 +1,4 @@
1 1 Monocle.Controls.Scrubber = function (reader) {
2   - if (Monocle.Controls == this) {
3   - return new Monocle.Controls.Scrubber(reader);
4   - }
5 2
6 3 var API = { constructor: Monocle.Controls.Scrubber }
7 4 var k = API.constants = API.constructor;
3  src/controls/spinner.js
... ... @@ -1,7 +1,4 @@
1 1 Monocle.Controls.Spinner = function (reader) {
2   - if (Monocle.Controls == this) {
3   - return new Monocle.Controls.Spinner(reader);
4   - }
5 2
6 3 var API = { constructor: Monocle.Controls.Spinner }
7 4 var k = API.constants = API.constructor;
2  src/controls/stencil.js
... ... @@ -1,7 +1,5 @@
1 1 Monocle.Controls.Stencil = function (reader) {
2 2
3   - if (Monocle.Controls == this) { return new this.Stencil(reader); }
4   -
5 3 var API = { constructor: Monocle.Controls.Stencil }
6 4 var k = API.constants = API.constructor;
7 5 var p = API.properties = {
1  src/core/book.js
@@ -10,7 +10,6 @@
10 10 *
11 11 */
12 12 Monocle.Book = function (dataSource) {
13   - if (Monocle == this) { return new Monocle.Book(dataSource); }
14 13
15 14 var API = { constructor: Monocle.Book }
16 15 var k = API.constants = API.constructor;
2  src/core/events.js
... ... @@ -1,4 +1,4 @@
1   -Monocle.Events = {}
  1 +Monocle.Events = {};
2 2
3 3
4 4 // Fire a custom event on a given target element. The attached data object will
9 src/core/monocle.js
@@ -10,14 +10,7 @@ Monocle = {
10 10 };
11 11
12 12
13   -Monocle.defer = function (fn, time) {
14   - if (fn && typeof fn == "function") {
15   - return setTimeout(fn, time || 0);
16   - }
17   -}
18   -
19   -
20   -Monocle.Dimensions = {}
  13 +Monocle.Dimensions = {};
21 14 Monocle.Controls = {};
22 15 Monocle.Flippers = {};
23 16 Monocle.Panels = {};
3  src/core/reader.js
@@ -31,9 +31,6 @@
31 31 // systemId: the id for root elements of components, defaults to "RS:monocle"
32 32 //
33 33 Monocle.Reader = function (node, bookData, options, onLoadCallback) {
34   - if (Monocle == this) {
35   - return new Monocle.Reader(node, bookData, options, onLoadCallback);
36   - }
37 34
38 35 var API = { constructor: Monocle.Reader }
39 36 var k = API.constants = API.constructor;
1  src/core/styles.js
@@ -95,6 +95,7 @@ Monocle.Styles = {
95 95 //
96 96 Monocle.Styles.container = {
97 97 "position": "absolute",
  98 + "overflow": "hidden",
98 99 "top": "0",
99 100 "left": "0",
100 101 "bottom": "0",
87 src/dimensions/vert.js
... ... @@ -1,87 +0,0 @@
1   -// This was once used by the legacy flipper, before the legacy flipper was
2   -// removed. It could serve as the basis for a scrolling flipper or something.
3   -//
4   -Monocle.Dimensions.Vert = function (pageDiv) {
5   -
6   - var API = { constructor: Monocle.Dimensions.Vert }
7   - var k = API.constants = API.constructor;
8   - var p = API.properties = {
9   - page: pageDiv,
10   - reader: pageDiv.m.reader
11   - }
12   -
13   -
14   - function initialize() {
15   - p.reader.listen('monocle:componentchange', componentChanged);
16   - }
17   -
18   -
19   - function update(callback) {
20   - p.bodyHeight = getBodyHeight();
21   - p.pageHeight = getPageHeight();
22   - p.length = Math.ceil(p.bodyHeight / p.pageHeight);
23   - callback(p.length);
24   - }
25   -
26   -
27   - function getBodyHeight() {
28   - return p.page.m.activeFrame.contentDocument.body.scrollHeight;
29   - }
30   -
31   -
32   - function getPageHeight() {
33   - return p.page.m.activeFrame.offsetHeight - k.GUTTER;
34   - }
35   -
36   -
37   - function percentageThroughOfNode(target) {
38   - if (!target) {
39   - return 0;
40   - }
41   - var doc = p.page.m.activeFrame.contentDocument;
42   - var offset = 0;
43   - if (target.getBoundingClientRect) {
44   - offset = target.getBoundingClientRect().top;
45   - offset -= doc.body.getBoundingClientRect().top;
46   - } else {
47   - var oldScrollTop = doc.body.scrollTop;
48   - target.scrollIntoView();
49   - offset = doc.body.scrollTop;
50   - doc.body.scrollLeft = 0;
51   - doc.body.scrollTop = oldScrollTop;
52   - }
53   -
54   - //console.log(id + ": " + offset + " of " + p.bodyHeight);
55   - var percent = offset / p.bodyHeight;
56   - return percent;
57   - }
58   -
59   -
60   - function componentChanged(evt) {
61   - if (evt.m['page'] != p.page) { return; }
62   - var sheaf = p.page.m.sheafDiv;
63   - var cmpt = p.page.m.activeFrame;
64   - sheaf.dom.setStyles(k.SHEAF_STYLES);
65   - cmpt.dom.setStyles(k.COMPONENT_STYLES);
66   - var doc = evt.m['document'];
67   - doc.documentElement.style.overflow = 'hidden';
68   - doc.body.style.marginRight = '10px !important';
69   - cmpt.contentWindow.scrollTo(0,0);
70   - }
71   -
72   -
73   - function locusToOffset(locus) {
74   - return p.pageHeight * (locus.page - 1);
75   - }
76   -
77   -
78   - API.update = update;
79   - API.percentageThroughOfNode = percentageThroughOfNode;
80   - API.locusToOffset = locusToOffset;
81   -
82   - initialize();
83   -
84   - return API;
85   -}
86   -
87   -Monocle.Dimensions.Vert.GUTTER = 10;
3  src/flippers/slider.js
... ... @@ -1,7 +1,4 @@
1 1 Monocle.Flippers.Slider = function (reader) {
2   - if (Monocle.Flippers == this) {
3   - return new Monocle.Flippers.Slider(reader);
4   - }
5 2
6 3 var API = { constructor: Monocle.Flippers.Slider }
7 4 var k = API.constants = API.constructor;
1  test/bookdata/index.html
@@ -21,7 +21,6 @@
21 21 height: 400px;
22 22 border: 1px solid #000;
23 23 background-color: #CCC;
24   - overflow: hidden;
25 24 }
26 25 #part1, #part2 {
27 26 display: none;
1  test/componentry/index.html
@@ -18,7 +18,6 @@
18 18 height: 400px;
19 19 border: 1px solid #000;
20 20 background-color: #CCC;
21   - overflow: hidden;
22 21 }
23 22
24 23 #hiddenFrames {
1  test/controls/index.html
@@ -19,7 +19,6 @@
19 19 height: 400px;
20 20 border: 1px solid #000;
21 21 background-color: #CCC;
22   - overflow: hidden;
23 22 }
24 23 #part1, #part2 {
25 24 display: none;
2  test/dogfood/index.html
@@ -13,9 +13,7 @@
13 13 height: 400px;
14 14 border: 1px solid #000;
15 15 background-color: #CCC;
16   - overflow: hidden;
17 16 margin: 2em 0;
18   - float: left;
19 17 }
20 18 #theCode {
21 19 clear: both;
1  test/dogfood/simplest.html
@@ -18,7 +18,6 @@
18 18 width: 300px;
19 19 height: 400px;
20 20 border: 1px solid #000;
21   - overflow: hidden;
22 21 }
23 22 </style>
24 23
1  test/events/index.html
@@ -13,7 +13,6 @@
13 13 height: 400px;
14 14 border: 1px solid #000;
15 15 background-color: #CCC;
16   - overflow: hidden;
17 16 }
18 17 #out {
19 18 font: 9pt Consolas, Inconsolata, Menlo, Andale Mono, Monaco, monospace;
1  test/flippers/index.html
@@ -18,7 +18,6 @@
18 18 height: 400px;
19 19 border: 1px solid #000;
20 20 background-color: #CCC;
21   - overflow: hidden;
22 21 }
23 22 #part1, #part2 {
24 23 display: none;
1  test/locus-search/index.html
@@ -13,7 +13,6 @@
13 13 height: 400px;
14 14 border: 1px solid #000;
15 15 background-color: #CCC;
16   - overflow: hidden;
17 16 }
18 17 </style>
19 18
1  test/panels/index.html
@@ -18,7 +18,6 @@
18 18 height: 400px;
19 19 border: 1px solid #000;
20 20 background-color: #CCC;
21   - overflow: hidden;
22 21 }
23 22 #part1, #part2 {
24 23 display: none;
1  test/rich_content/index.html
@@ -17,7 +17,6 @@
17 17 height: 420px;
18 18 border: 1px solid #000;
19 19 background-color: #CCC;
20   - overflow: hidden;
21 20 }
22 21 </style>
23 22
1  test/showcase/01-velveteen/index.html
@@ -17,7 +17,6 @@
17 17 height: 420px;
18 18 border: 1px solid #000;
19 19 background-color: #CCC;
20   - overflow: hidden;
21 20 }
22 21 </style>
23 22
1  test/stencil/index.html
@@ -23,7 +23,6 @@
23 23 height: 400px;
24 24 border: 1px solid #000;
25 25 background-color: #CCC;
26   - overflow: hidden;
27 26 }
28 27 </style>
29 28
1  test/stylesheet/index.html
@@ -17,7 +17,6 @@
17 17 height: 420px;
18 18 border: 1px solid #000;
19 19 background-color: #CCC;
20   - overflow: hidden;
21 20 }
22 21 </style>
23 22

0 comments on commit 1b5c86f

Please sign in to comment.
Something went wrong with that request. Please try again.