From 977db823c7c84e9edc7c8cf8384eb9cf47275b3a Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 8 Apr 2016 14:53:34 +0200 Subject: [REF] web: stop duplicating web Avoid duplicating web addon in enterprise by extracting a common basis. Enterprise features stay in enterprise, but use that common basis. Mainly: - JS refactoring and linting - Conversion of .sass into .less split into multiple files - Templates cleaning and DOM simplification - Re-generation of web.pot, and update of .po files --- addons/web/static/src/js/control_panel.js | 51 ++++++++++++++++--------------- 1 file changed, 27 insertions(+), 24 deletions(-) (limited to 'addons/web/static/src/js/control_panel.js') diff --git a/addons/web/static/src/js/control_panel.js b/addons/web/static/src/js/control_panel.js index 5e2cc36a6a1..3a233564368 100644 --- a/addons/web/static/src/js/control_panel.js +++ b/addons/web/static/src/js/control_panel.js @@ -54,17 +54,15 @@ var ControlPanel = Widget.extend({ * @return {jQuery.Deferred} */ start: function() { - this.$title_col = this.$('.oe-cp-title'); - // Exposed jQuery nodesets this.nodes = { - $breadcrumbs: this.$('.oe-view-title'), - $buttons: this.$('.oe-cp-buttons'), - $pager: this.$('.oe-cp-pager'), - $searchview: this.$('.oe-cp-search-view'), - $searchview_buttons: this.$('.oe-search-options'), - $sidebar: this.$('.oe-cp-sidebar'), - $switch_buttons: this.$('.oe-cp-switch-buttons'), + $breadcrumbs: this.$('.breadcrumb'), + $buttons: this.$('.o_cp_buttons'), + $pager: this.$('.o_cp_pager'), + $searchview: this.$('.o_cp_searchview'), + $searchview_buttons: this.$('.o_search_options'), + $sidebar: this.$('.o_cp_sidebar'), + $switch_buttons: this.$('.o_cp_switch_buttons'), }; // By default, hide the ControlPanel and remove its contents from the DOM @@ -120,7 +118,7 @@ var ControlPanel = Widget.extend({ // Update the searchview and switch buttons this._update_search_view(status.searchview, status.search_view_hidden); - if (status.active_view_selector) { + if (status.active_view_selector) { this._update_switch_buttons(status.active_view_selector); } } @@ -182,22 +180,25 @@ var ControlPanel = Widget.extend({ */ _render_breadcrumbs: function (breadcrumbs) { var self = this; - return breadcrumbs.map(function (bc, index) { - return make_breadcrumb(bc, index === breadcrumbs.length - 1); + return self._render_breadcrumbs_li(bc, index, breadcrumbs.length); }); - - function make_breadcrumb (bc, is_last) { - var $bc = $('
  • ') - .append(is_last ? _.escape(bc.title) : $('').text(bc.title)) - .toggleClass('active', is_last); - if (!is_last) { - $bc.click(function () { - self.trigger("on_breadcrumb_click", bc.action, bc.index); - }); - } - return $bc; + }, + /** + * Private function that renders a breadcrumbs' li Jquery element + */ + _render_breadcrumbs_li: function (bc, index, length) { + var self = this; + var is_last = (index === length-1); + var $bc = $('
  • ') + .append(is_last ? _.escape(bc.title) : $('').text(bc.title)) + .toggleClass('active', is_last); + if (!is_last) { + $bc.click(function () { + self.trigger("on_breadcrumb_click", bc.action, bc.index); + }); } + return $bc; }, /** * Private function that updates the SearchView's visibility and extend the @@ -211,8 +212,10 @@ var ControlPanel = Widget.extend({ // have been appended to a jQuery node not in the DOM at SearchView initialization searchview.$buttons = this.nodes.$searchview_buttons; searchview.toggle_visibility(!is_hidden); - this.$title_col.toggleClass('col-md-6', !is_hidden).toggleClass('col-md-12', is_hidden); } + + this.nodes.$searchview.toggle(!is_hidden); + this.$el.toggleClass('o_breadcrumb_full', !!is_hidden); }, }); -- cgit v1.2.3