diff options
| author | Aaron Bohy <aab@odoo.com> | 2016-04-21 13:58:22 +0200 |
|---|---|---|
| committer | Géry Debongnie <ged@odoo.com> | 2016-04-21 15:21:42 +0200 |
| commit | 6768bbfcc02e0f498110cda2ba9adbc2fd23d24c (patch) | |
| tree | 7dccb1019434582874b285276189b1b3dcbb96a9 /addons/web/static/src/js/control_panel.js | |
| parent | e1bfd3fbda97ac7a64a585b07be161d5be606cf9 (diff) | |
| parent | 8e440b173e3b273b3aac541f2ec12527f67dfa60 (diff) | |
[MERGE] *: stop duplicating web
Avoid duplicating web addon in enterprise by extracting a common basis.
Enterprise features stay in enterprise, but use that common basis.
In web, 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
Minor tweaks in some other addons to make them work with this new structure.
Diffstat (limited to 'addons/web/static/src/js/control_panel.js')
| -rw-r--r-- | addons/web/static/src/js/control_panel.js | 51 |
1 files changed, 27 insertions, 24 deletions
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 = $('<li>') - .append(is_last ? _.escape(bc.title) : $('<a>').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 = $('<li>') + .append(is_last ? _.escape(bc.title) : $('<a>').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); }, }); |
