From f39fc0926708a03f3b8b458cd281ec5d97b43fd6 Mon Sep 17 00:00:00 2001 From: mge-odoo Date: Fri, 20 Mar 2015 17:03:40 +0100 Subject: [ADD] web: generic widget with iframe --- addons/web/static/src/js/framework/misc.js | 43 +++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) (limited to 'addons/web/static/src/js/framework/misc.js') diff --git a/addons/web/static/src/js/framework/misc.js b/addons/web/static/src/js/framework/misc.js index a24c64e5a66..300dabd4d87 100644 --- a/addons/web/static/src/js/framework/misc.js +++ b/addons/web/static/src/js/framework/misc.js @@ -204,6 +204,7 @@ function ReloadContext (parent, action) { } core.action_registry.add("reload_context", ReloadContext); + // nvd3 customization //------------------------------------------------------------------------- if ('nv' in window) { @@ -322,9 +323,6 @@ $.extend( proto, { } }); - - - return { blockUI: blockUI, unblockUI: unblockUI, @@ -339,3 +337,42 @@ odoo.define('web.session', function (require) { return new Session(undefined, undefined, {modules:modules}); }); +odoo.define('web.IFrameWidget', function (require) { +"use strict"; + +var Widget = require('web.Widget'); + +/** + * Generic widget to create an iframe that listens for clicks + * + * It should be extended by overwritting the methods: + * init: function(parent) { + * this._super(parent, + * }, + * iframe_clicked: function(e){ + * filter the clicks you want to use and apply + * an action on it + * } + */ +var IFrameWidget = Widget.extend({ + tagName: 'iframe', + init: function(parent, url) { + this._super(parent); + this.url = url; + }, + start: function() { + this.$el.css({height: '100%', width: '100%', border: 0}); + this.$el.attr({src: this.url}); + this.$el.on("load", this.bind_events.bind(this)); + return this._super(); + }, + bind_events: function(){ + this.$el.contents().click(this.iframe_clicked.bind(this)); + }, + iframe_clicked: function(e){ + } +}); + +return IFrameWidget; + +}); -- cgit v1.2.3