cobot_client 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -50,6 +50,10 @@ Add the following code to your application controller:
50
50
 
51
51
  This will automatically resize Cobot's iframe whenever a new page is loaded. To manually trigger a resize call `window.Cobot.iframeResize()`.
52
52
 
53
+ The default script determine's the iframe height by calling `jQuery('body').outerHeight()`. To provide your own height you can either pass it to the `iframeResize` function or you can define a function `window.Cobot.iframeHeight`.
54
+
55
+ When you display layers in the iframe that are positioned relative to the window you have to take into account how much the user scrolled down in the parent frame. For this purpose the script provides the property `window.Cobot.scrollTop`, which returns the no. of pixels the user has scrolled down.
56
+
53
57
  ### Generating URLs to the Cobot API
54
58
 
55
59
  There is a module `CobotClient::UrlHelper`. After you include it you can call `cobot_url`. Examples:
@@ -1,16 +1,24 @@
1
1
  <script>
2
2
  window.Cobot = window.Cobot || {};
3
- window.Cobot.iframeResize = function(height) {
4
- if(window.socket) {
5
- window.socket.postMessage(height || $('body').outerHeight());
3
+ window.Cobot.iframeResize = function(height) {
4
+ window.socket.postMessage(height || window.Cobot.iframeHeight());
6
5
  }
7
- }
8
- easyXDM.query = <%== xdm_params.to_json %>;
9
- window.socket = new easyXDM.Socket({
10
- onReady: function() {
11
- setTimeout(function() {
12
- window.Cobot.iframeResize();
13
- }, 100);
6
+ window.Cobot.iframeHeight = window.Cobot.iframeHeight || function() {
7
+ $('body').outerHeight();
14
8
  }
15
- });
9
+ window.Cobot.scrollTop = 0;
10
+ easyXDM.query = <%== xdm_params.to_json %>;
11
+ window.socket = new easyXDM.Socket({
12
+ onReady: function() {
13
+ setTimeout(function() {
14
+ window.Cobot.iframeResize();
15
+ }, 100);
16
+ },
17
+ onMessage: function(message) {
18
+ var message = JSON.parse(message);
19
+ if(message.scrollTop) {
20
+ window.Cobot.scrollTop = message.scrollTop;
21
+ }
22
+ }
23
+ });
16
24
  </script>
@@ -1,3 +1,3 @@
1
1
  module CobotClient
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cobot_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-05 00:00:00.000000000 Z
12
+ date: 2013-05-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport