[IMP] shorter embed code

bzr revid: al@openerp.com-20111216153736-z10to08j5zcb1lw4
This commit is contained in:
Antony Lesuisse
2011-12-16 16:37:36 +01:00
parent 9c42c6aa87
commit d3afc7706c
+13 -11
View File
@@ -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);
});
});
}
};