From d3afc7706cd9e0533f5bf1ac1782b7fd0c7992c6 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Fri, 16 Dec 2011 16:37:36 +0100 Subject: [PATCH] [IMP] shorter embed code bzr revid: al@openerp.com-20111216153736-z10to08j5zcb1lw4 --- addons/web/static/src/js/chrome.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 412e74a5b6a..0e25e098ec8 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -1093,15 +1093,6 @@ openerp.web.WebClient = openerp.web.Widget.extend(/** @lends openerp.web.WebClie }, }); -openerp.currentScript = function() { - var currentScript = document.currentScript; - if (!currentScript) { - var sc = document.getElementsByTagName('script'); - currentScript = sc[sc.length-1]; - } - return currentScript; -}; - openerp.web.EmbeddedClient = openerp.web.Widget.extend({ template: 'EmptyComponent', init: function(action_id, options) { @@ -1114,9 +1105,7 @@ openerp.web.EmbeddedClient = openerp.web.Widget.extend({ start: function() { var self = this; - this.am.appendTo(this.$element.addClass('openerp')); - return this.rpc("/web/action/load", { action_id: this.action_id }, function(result) { var action = result.result; action.flags = _.extend({ @@ -1133,6 +1122,19 @@ openerp.web.EmbeddedClient = openerp.web.Widget.extend({ }); +openerp.web.embed = function (origin, dbname, login, key, action, options) { + var currentScript = document.currentScript; + if (!currentScript) { + var sc = document.getElementsByTagName('script'); + currentScript = sc[sc.length-1]; + } + openerp.connection.bind(origin).then(function () { + openerp.connection.session_authenticate(dbname, login, key).then(function () { + var client = new session.web.EmbeddedClient(action_id, options); + client.insertAfter(currentScript); + }); + }); +} };