"+value.split(/
/).join("
")+"
"; - value = value.replace(/<\/p>/g, '').replace('
', '
').replace('
', ''); + try { + $(text)[0].innerHTML; + return text; + } catch (e) { + if (value.match(/^\s*$/)) { + value = '"+value.split(/
/).join("
")+"
"; + value = value.replace(/<\/p>/g, '').replace('
', '
').replace('
', ''); + } } return value; }, @@ -213,7 +218,7 @@ var FieldTextHtml = widget.extend({ self.$iframe.css("height", (self.$body.find("#oe_snippets").length ? 500 : 300) + "px"); } }; - $(window).on('resize', self.resize); + $(window).on('resize', this.resize); var def = this._super.apply(this, arguments); this.$translate.remove(); @@ -374,7 +379,7 @@ var FieldTextHtml = widget.extend({ } }, destroy: function () { - $(window).off('resize', self.resize); + $(window).off('resize', this.resize); delete window.odoo[this.callback+"_editor"]; delete window.odoo[this.callback+"_content"]; delete window.odoo[this.callback+"_updown"]; diff --git a/addons/web_kanban/static/src/js/kanban_record.js b/addons/web_kanban/static/src/js/kanban_record.js index 473ebc59e98..c784073f2a5 100644 --- a/addons/web_kanban/static/src/js/kanban_record.js +++ b/addons/web_kanban/static/src/js/kanban_record.js @@ -64,6 +64,7 @@ var KanbanRecord = Widget.extend({ qweb_context[p] = _.bind(this[p], this); } } + this.qweb_context = qweb_context; this.content = this.qweb.render('kanban-box', qweb_context); }, @@ -81,7 +82,18 @@ var KanbanRecord = Widget.extend({ }, start: function() { + var self = this; this.add_widgets(); + this.$('[tooltip]').each(function () { + var $el = $(this); + var tooltip = $el.attr('tooltip'); + if (tooltip) { + $el.tooltip({ + 'html': true, + 'title': self.qweb.render(tooltip, self.qweb_context) + }); + } + }); }, renderElement: function () { @@ -172,14 +184,15 @@ var KanbanRecord = Widget.extend({ if (elem == ev.currentTarget) { ischild = false; } + var test_event = events && events.click && (events.click.length > 1 || events.click[0].namespace !== "tooltip"); if (ischild) { children.push(elem); - if (events && events.click) { + if (test_event) { // do not trigger global click if one child has a click event registered trigger = false; } } - if (trigger && events && events.click) { + if (trigger && test_event) { _.each(events.click, function(click_event) { if (click_event.selector) { // For each parent of original target, check if a diff --git a/addons/web_tip/static/src/js/tip.js b/addons/web_tip/static/src/js/tip.js index 47d20a2f7ee..3f4d908b1eb 100644 --- a/addons/web_tip/static/src/js/tip.js +++ b/addons/web_tip/static/src/js/tip.js @@ -15,6 +15,7 @@ var Tips = Class.extend({ var self = this; this.tips = []; + this.tipObjects = {}; this.view = null; var Tips = new Model('web.tip'); @@ -27,69 +28,47 @@ var Tips = Class.extend({ bus.on('view_shown', this, function(view) { if (_.keys(view.fields_view).length === 0) { view.on('view_loaded', this, function(fields_view) { - self.view = view; - self.on_view(); + if (this.view && this._eval_tips) { + this.view.off('chatter_messages_displayed', this, this._eval_tips); + this.view.off('to_edit_mode', this, this._remove_tips); + this.view.off('to_view_mode', this, this._eval_tips); + this.view.off('view_list_rendered', this, this._eval_tips); + } + this.view = view; }); } else { - self.view = view; - self.on_view(); + this.view = view; } }); - }, - on_view: function() { - var self = this; + bus.on('DOM_updated', this, function() { + if (!this.view) return; - if (this._DOM_updated) { - bus.off('DOM_updated', this, this._DOM_updated); - } - this._DOM_updated = function() { - var action_id = self.view.ViewManager.action ? self.view.ViewManager.action.id : null; - var model = self.view.fields_view.model; - var mode = self.view.fields_view.type; + var self = this; + var action_id = this.view.ViewManager.action ? this.view.ViewManager.action.id : null; + var model = this.view.fields_view.model; + var mode = this.view.fields_view.type; + var type = this.view.datarecord ? this.view.datarecord.type : null; + + this._eval_tips = function() { self.eval_tips(action_id, model, mode, type); }; + this._remove_tips = function() { self.remove_tips(); }; if (mode == 'form') { - self.on_form_view(action_id, model); - } - else if (self.view.hasOwnProperty('editor')) { - if (self._view_list_rendered) { - self.view.off('view_list_rendered', self, self._view_list_rendered); + if ($('.oe_chatter').length > 0) { + this.view.on('chatter_messages_displayed', this, this._eval_tips); + } else { + this._eval_tips(); } - self._view_list_rendered = function() { self.eval_tips(action_id, model, mode); }; - self.view.on('view_list_rendered', self, self._view_list_rendered); + this.view.on('to_edit_mode', this, this._remove_tips); + this.view.on('to_view_mode', this, this._eval_tips); + } + else if (this.view.hasOwnProperty('editor')) { + this.view.on('view_list_rendered', this, this._eval_tips); } else { - self.eval_tips(action_id, model, mode); + this._eval_tips(); } - }; - bus.on('DOM_updated', this, this._DOM_updated); - }, - - on_form_view: function(action_id, model) { - var self = this; - var type = this.view.datarecord ? this.view.datarecord.type : null - - if ($('.oe_chatter').length > 0) { - if (this._chatter_messages_displayed) { - this.view.off('chatter_messages_displayed', this, this._chatter_messages_displayed); - } - this._chatter_messages_displayed = function() { self.eval_tips(action_id, model, 'form', type); }; - this.view.on('chatter_messages_displayed', this, this._chatter_messages_displayed); - } else { - this.eval_tips(action_id, model, 'form', type); - } - - if (this._to_edit_mode) { - this.view.off('to_edit_mode', this, this._to_edit_mode); - } - this._to_edit_mode = function() { self.remove_tips(); }; - this.view.on('to_edit_mode', this, this._to_edit_mode); - - if (this._to_view_mode) { - this.view.off('to_view_mode', this, this._to_view_mode); - } - this._to_view_mode = function() { self.eval_tips(action_id, model, 'form', type); }; - this.view.on('to_view_mode', this, this._to_view_mode); + }); }, eval_tips: function(action_id, model, mode, type) { @@ -109,7 +88,7 @@ var Tips = Class.extend({ filter.is_consumed = false; tips = _.where(self.tips, filter); // To take into account a tip without fixed model : e.g. a generic tip on the breadcrumb - tips = tips.concat(_.where(self.tips, {mode: mode, is_consumed: false, model:false})) + tips = tips.concat(_.where(self.tips, {mode: mode, is_consumed: false, model:false})); if (type) { tips = _.filter(tips, function(tip) { @@ -123,14 +102,21 @@ var Tips = Class.extend({ valid_tips = _.uniq(valid_tips.concat(tips)); _.each(valid_tips, function(tip) { if (!tip.is_consumed) { - var t = new Tip(tip); - t.do_tip(); + if (self.tipObjects[tip.id]) { + self.tipObjects[tip.id].destroy(); + } else { + self.tipObjects[tip.id] = new Tip(tip); + } + self.tipObjects[tip.id].do_tip(); } }); }, remove_tips: function() { - $('.oe_breathing').remove(); + for (var k in this.tipObjects) { + this.tipObjects[k].destroy(); + } + this.tipObjects = {}; }, }); @@ -275,27 +261,9 @@ var Tip = Class.extend({ }, end_tip: function() { - var Tips = new Model('web.tip'); - - this.$element.popover('destroy'); - this.$element.removeClass('oe_tip_show_element'); - this.$breathing.remove(); - this.$helper.remove(); - this.$overlay.remove(); - this.$cross.remove(); - - $('.oe_tip_fix_parent').each(function() { - $(this).removeClass('oe_tip_fix_parent'); - }); - $(document).off('keyup.web_tip'); - - bus.off('resize', this, this._resize_position); - bus.off('resize', this, this._resize); - bus.off('image_loaded', this, this._resize); - bus.off('please_reposition_tip', this, this._resize); - - Tips.call('consume', [this.tip.id], {}); + new Model('web.tip').call('consume', [this.tip.id], {}); this.tip.is_consumed = true; + this.destroy(); }, _set_breathing_position: function() { @@ -327,6 +295,29 @@ var Tip = Class.extend({ } } }, + + destroy: function () { + if (this.$element) { + this.$element.popover('destroy'); + this.$element.removeClass('oe_tip_show_element'); + this.$breathing.off().remove(); + } + if (this.$helper) { + this.$helper.off().remove(); + this.$overlay.off().remove(); + this.$cross.off().remove(); + } + + $('.oe_tip_fix_parent').each(function() { + $(this).removeClass('oe_tip_fix_parent'); + }); + $(document).off('keyup.web_tip'); + + bus.off('resize', this, this._resize_position); + bus.off('resize', this, this._resize); + bus.off('image_loaded', this, this._resize); + bus.off('please_reposition_tip', this, this._resize); + }, }); WebClient.include({ diff --git a/addons/website/static/src/js/website.snippets.gallery.js b/addons/website/static/src/js/website.snippets.gallery.js index 7bcc8f34c4d..17c90008729 100644 --- a/addons/website/static/src/js/website.snippets.gallery.js +++ b/addons/website/static/src/js/website.snippets.gallery.js @@ -367,7 +367,16 @@ options.registry.gallery_img = options.Class.extend({ var gallery = $parent.data('snippet-editor').styles.gallery; gallery.reapply(); }, 0); - } + }, + on_focus: function () { + this._super.apply(this, arguments); + if (this._current_src && this._current_src !== this.$target.attr("src")) { + _.defer((function () { + snippet_editor.globalSelector.closest(this.$target.parent()).data('snippet-editor').styles.gallery.reapply(); + }).bind(this)); + } + this._current_src = this.$target.attr("src"); + }, }); diff --git a/openerp/http.py b/openerp/http.py index 45db589aa28..c54dea5a17a 100644 --- a/openerp/http.py +++ b/openerp/http.py @@ -806,7 +806,7 @@ class HttpRequest(WebRequest): if request.httprequest.method == 'OPTIONS' and request.endpoint and request.endpoint.routing.get('cors'): headers = { 'Access-Control-Max-Age': 60 * 60 * 24, - 'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept' + 'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept, X-Debug-Mode' } return Response(status=200, headers=headers)