livefyre 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data.tar.gz.sig CHANGED
Binary file
@@ -16,14 +16,11 @@
16
16
  load = null;
17
17
 
18
18
  (function() {
19
- var head, __loadedScripts;
19
+ var fjs, __loadedScripts;
20
20
  __loadedScripts = [];
21
- head = null;
22
- return load = function(source, id, content, options) {
21
+ fjs = null;
22
+ return load = function(source, id, options) {
23
23
  var js, k, v;
24
- if (!content) {
25
- content = null;
26
- }
27
24
  if (document.getElementById(id)) {
28
25
  return;
29
26
  }
@@ -31,21 +28,20 @@
31
28
  return;
32
29
  }
33
30
  __loadedScripts[id] = true;
34
- if (!head) {
35
- head = document.getElementsByTagName('head')[0];
31
+ if (!fjs) {
32
+ fjs = document.getElementsByTagName('script')[0];
36
33
  }
37
34
  js = document.createElement("script");
38
35
  js.id = id;
39
36
  js.async = true;
40
37
  js.src = source;
41
- js.innerHTML = content;
42
38
  if (options) {
43
39
  for (k in options) {
44
40
  v = options[k];
45
41
  js[k] = v;
46
42
  }
47
43
  }
48
- head.appendChild(js);
44
+ fjs.parentNode.insertBefore(js, fjs);
49
45
  return js;
50
46
  };
51
47
  })();
@@ -64,7 +60,7 @@
64
60
  var obj;
65
61
  return obj = {
66
62
  load: load,
67
- startLogin: function(url, width, height, callback) {
63
+ startLogin: function(url, width, height, callback, windowName) {
68
64
  var left, popup, top;
69
65
  if (width == null) {
70
66
  width = 600;
@@ -75,9 +71,12 @@
75
71
  if (callback == null) {
76
72
  callback = null;
77
73
  }
74
+ if (windowName == null) {
75
+ windowName = null;
76
+ }
78
77
  left = (screen.width / 2) - (width / 2);
79
78
  top = (screen.height / 2) - (height / 2);
80
- popup = window.open(url, name, "menubar=no,toolbar=no,status=no,width=" + width + ",height=" + height + ",toolbar=no,left=" + left + ",top=" + top);
79
+ popup = window.open(url, windowName, "menubar=no,toolbar=no,status=no,width=" + width + ",height=" + height + ",toolbar=no,left=" + left + ",top=" + top);
81
80
  this.finishCallback = callback;
82
81
  return this.startLoginPopup(popup);
83
82
  },
@@ -86,33 +85,34 @@
86
85
  this.tries = 0;
87
86
  this.popup = popup;
88
87
  return this.timer = setInterval(function() {
89
- _this.tries += 1;
90
88
  return _this.__checkLogin();
91
89
  }, 100);
92
90
  },
93
91
  __checkLogin: function() {
94
92
  var token;
95
93
  token = cookie(options.cookie_name || "livefyre_utoken");
96
- if (this.popup) {
97
- try {
98
- if (this.popup.closed === false && this.tries > 30) {
99
- clearInterval(this.timer);
100
- this.timer = null;
101
- this.popup = null;
102
- }
103
- } catch (err) {
104
-
105
- }
106
- }
107
- if (token) {
94
+ if (token && this.timer) {
108
95
  clearInterval(this.timer);
109
- this.popup.close();
96
+ if (this.popup) {
97
+ this.popup.close();
98
+ }
110
99
  this.popup = null;
111
100
  this.timer = null;
112
101
  if (this.finishCallback) {
113
102
  this.finishCallback();
114
103
  }
115
104
  return window.fyre.conv.login(token);
105
+ } else if (this.popup && this.popup.closed) {
106
+ try {
107
+ this.tries += 1;
108
+ if (this.tries > 30) {
109
+ clearInterval(this.timer);
110
+ this.timer = null;
111
+ return this.popup = null;
112
+ }
113
+ } catch (err) {
114
+
115
+ }
116
116
  }
117
117
  }
118
118
  };
@@ -164,7 +164,7 @@
164
164
  });
165
165
  };
166
166
  if (!options.manualLoad) {
167
- element = load("http://" + options.root + "/wjs/v3.0/javascripts/livefyre.js", null, null, {
167
+ element = load("http://" + options.root + "/wjs/v3.0/javascripts/livefyre.js", null, {
168
168
  "data-lf-domain": options.network
169
169
  });
170
170
  }
@@ -29,10 +29,12 @@ cookie = (token) ->
29
29
  utils = (options) ->
30
30
  obj =
31
31
  load: load
32
- startLogin: (url, width = 600, height = 400, callback = null) ->
32
+ # At some point, callback should move to the last param
33
+ # keeping this order for backwards compat for now.
34
+ startLogin: (url, width = 600, height = 400, callback = null, windowName = null) ->
33
35
  left = (screen.width / 2) - (width / 2)
34
36
  top = (screen.height / 2) - (height / 2)
35
- popup = window.open url, name, "menubar=no,toolbar=no,status=no,width=#{width},height=#{height},toolbar=no,left=#{left},top=#{top}"
37
+ popup = window.open url, windowName, "menubar=no,toolbar=no,status=no,width=#{width},height=#{height},toolbar=no,left=#{left},top=#{top}"
36
38
  @finishCallback = callback
37
39
  @startLoginPopup(popup)
38
40
 
@@ -40,27 +42,27 @@ utils = (options) ->
40
42
  @tries = 0
41
43
  @popup = popup
42
44
  @timer = setInterval(=>
43
- @tries += 1
44
45
  @__checkLogin()
45
46
  , 100)
46
47
 
47
48
  __checkLogin: ->
48
49
  token = cookie(options.cookie_name || "livefyre_utoken")
49
- if @popup
50
- try
51
- if @popup.closed == false and @tries > 30 # 3 seconds
52
- clearInterval(@timer)
53
- @timer = null
54
- @popup = null
55
- catch err
56
50
 
57
- if token
51
+ if token and @timer
58
52
  clearInterval(@timer)
59
- @popup.close()
53
+ @popup.close() if @popup
60
54
  @popup = null
61
55
  @timer = null
62
56
  @finishCallback() if @finishCallback
63
57
  window.fyre.conv.login(token)
58
+ else if @popup and @popup.closed
59
+ try
60
+ @tries += 1
61
+ if @tries > 30 # 3 seconds
62
+ clearInterval(@timer)
63
+ @timer = null
64
+ @popup = null
65
+ catch err
64
66
 
65
67
  _initialized = false
66
68
  @initLivefyre = (options) ->
@@ -1,3 +1,3 @@
1
1
  module Livefyre
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: livefyre
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Mashable
@@ -37,7 +37,7 @@ cert_chain:
37
37
  U29GRmU5TVlJNGkwMXFQWC9IcWE5d3FMYmJFYVVTQ1VRZmNITnpnSzNvMlNZ
38
38
  am1RZTZObQp5bGQ2RkdnOXpPWT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0t
39
39
  LQo=
40
- date: 2013-02-02 00:00:00.000000000 Z
40
+ date: 2013-06-20 00:00:00.000000000 Z
41
41
  dependencies:
42
42
  - !ruby/object:Gem::Dependency
43
43
  type: :runtime
metadata.gz.sig CHANGED
Binary file