diff options
| author | Christophe Matthieu <chm@openerp.com> | 2013-01-09 13:33:57 +0100 |
|---|---|---|
| committer | Christophe Matthieu <chm@openerp.com> | 2013-01-09 13:33:57 +0100 |
| commit | 62d202d2599da47d1934ad8d190cee825f20ebe3 (patch) | |
| tree | e4d59451e5ef1b471d87b3bc2e30fa14816e2337 /addons/web_linkedin/static/src/js/linkedin.js | |
| parent | c46be224e6f81309bd2a4bd23b97097a5b1c0051 (diff) | |
[FIX] linkedin: display a button to connect on linkedin if there are an error of connected linkedin module
bzr revid: chm@openerp.com-20130109123357-2e2ogcy510ctqk8q
Diffstat (limited to 'addons/web_linkedin/static/src/js/linkedin.js')
| -rw-r--r-- | addons/web_linkedin/static/src/js/linkedin.js | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/addons/web_linkedin/static/src/js/linkedin.js b/addons/web_linkedin/static/src/js/linkedin.js index d6237e48d51..8fca845673a 100644 --- a/addons/web_linkedin/static/src/js/linkedin.js +++ b/addons/web_linkedin/static/src/js/linkedin.js @@ -6,6 +6,13 @@ openerp.web_linkedin = function(instance) { var QWeb = instance.web.qweb; var _t = instance.web._t; + openerp.web_linkedin.onLinkedInAuth = function () { + IN.API.Profile("me") + .result( function(me) { + console.log("me", me); + }); + }; + instance.web_linkedin.LinkedinTester = instance.web.Class.extend({ init: function() { this.linkedin_added = false; @@ -15,8 +22,12 @@ openerp.web_linkedin = function(instance) { test_linkedin: function() { var self = this; return this.test_api_key().then(function() { - if (self.linkedin_added) + if (self.linkedin_added) { + if (IN.User.isAuthorized()) { + self.auth_def.resolve(); + } return self.linkedin_def.promise(); + } var tag = document.createElement('script'); tag.type = 'text/javascript'; tag.src = "http://platform.linkedin.com/in.js"; @@ -178,6 +189,7 @@ openerp.web_linkedin = function(instance) { instance.web_linkedin.LinkedinPopup = instance.web.Dialog.extend({ template: "Linkedin.popup", init: function(parent, text) { + var self = this; this._super(parent, {title:_t("LinkedIn search")}); this.text = text; this.limit = 5; @@ -189,6 +201,20 @@ openerp.web_linkedin = function(instance) { instance.web_linkedin.tester.test_authentication().done(function() { self.trigger("authentified"); }); + + this.bind_error(); + }, + bind_error: function() { + var self = this; + this.error_message = window.setTimeout(function() {self.$(".oe_social_network_login .oe_error").show();}, 500); + this.$el.on("DOMNodeInserted", function (e) { + self.$el.off("DOMNodeInserted"); + window.clearTimeout(self.error_message); + self.$(".oe_social_network_login .oe_error").hide(); + }); + this.$(".oe_social_network_login .oe_error").click(function () { + IN.User.authorize(); + }); }, authentified: function() { var self = this; |
