Merge with @h5bp
[ReadingsJQM.git] / js / example.js
1 /*\r
2   Copyright 2010 Google Inc.\r
3 \r
4   Licensed under the Apache License, Version 2.0 (the "License");\r
5   you may not use this file except in compliance with the License.\r
6   You may obtain a copy of the License at\r
7 \r
8        http://www.apache.org/licenses/LICENSE-2.0\r
9 \r
10   Unless required by applicable law or agreed to in writing, software\r
11   distributed under the License is distributed on an "AS IS" BASIS,\r
12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13   See the License for the specific language governing permissions and\r
14   limitations under the License.\r
15 */\r
16 \r
17 /** @fileoverview Example of how to use the bookmark bubble. */\r
18 \r
19 window.addEventListener('load', function() {\r
20   window.setTimeout(function() {\r
21     var bubble = new google.bookmarkbubble.Bubble();\r
22 \r
23 \r
24     bubble.hasHashParameter = function() {\r
25       return $.cookie('bubble');\r
26     };\r
27 \r
28     bubble.setHashParameter = function() {\r
29       if (!this.hasHashParameter()) {\r
30         $.cookie('bubble', true, { expires: 365 });\r
31       }\r
32     };\r
33 \r
34     bubble.getViewportHeight = function() {\r
35       window.console.log('Example of how to override getViewportHeight.');\r
36       return window.innerHeight;\r
37     };\r
38 \r
39     bubble.getViewportScrollY = function() {\r
40       window.console.log('Example of how to override getViewportScrollY.');\r
41       return window.pageYOffset;\r
42     };\r
43 \r
44     bubble.registerScrollHandler = function(handler) {\r
45       window.console.log('Example of how to override registerScrollHandler.');\r
46       window.addEventListener('scroll', handler, false);\r
47     };\r
48 \r
49     bubble.deregisterScrollHandler = function(handler) {\r
50       window.console.log('Example of how to override deregisterScrollHandler.');\r
51       window.removeEventListener('scroll', handler, false);\r
52     };\r
53 \r
54     bubble.showIfAllowed();\r
55   }, 1000);\r
56 }, false);\r