Merge lp:~openerp-dev/openobject-addons/trunk-snippet-col-all-chm2 into lp:openobject-addons

Proposed by Christophe Matthieu (OpenERP)
Status: Work in progress
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-snippet-col-all-chm2
Merge into: lp:openobject-addons
Diff against target: 130 lines (+26/-16)
2 files modified
website/static/src/js/website.snippets.editor.js (+24/-14)
website/views/snippets.xml (+2/-2)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-snippet-col-all-chm2
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+214982@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

9300. By Christophe Matthieu (OpenERP)

[FIX] website editor, repport: can't change col for the repports. Imp: change col function of the col already set, by default col-md

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'website/static/src/js/website.snippets.editor.js'
2--- website/static/src/js/website.snippets.editor.js 2014-03-24 14:54:16 +0000
3+++ website/static/src/js/website.snippets.editor.js 2014-04-09 15:57:26 +0000
4@@ -1100,6 +1100,12 @@
5 var self = this;
6 this._super();
7
8+ var _class = this.$target.attr("class");
9+ var col_style = _class.match(/(?=^|\s)col-([a-z]+)-/i);
10+ this.col_style = col_style && _class.indexOf("col-md") === -1 ? col_style[1] : "md";
11+
12+ if (this.$target.attr("class").match())
13+
14 var resize_values = this.getSize();
15 if (resize_values.n) this.$overlay.find(".oe_handle.n").removeClass("readonly");
16 if (resize_values.s) this.$overlay.find(".oe_handle.s").removeClass("readonly");
17@@ -1228,10 +1234,10 @@
18 change_cursor : function () {
19 var _class = this.$target.attr("class") || "";
20
21- var col = _class.match(/col-md-([0-9-]+)/i);
22+ var col = _class.match(/col-[a-z]+-([0-9-]+)/i);
23 col = col ? +col[1] : 0;
24
25- var offset = _class.match(/col-md-offset-([0-9-]+)/i);
26+ var offset = _class.match(/col-[a-z]+-offset-([0-9-]+)/i);
27 offset = offset ? +offset[1] : 0;
28
29 var overlay_class = this.$overlay.attr("class").replace(/(^|\s+)block-[^\s]*/gi, '');
30@@ -1278,14 +1284,15 @@
31 });
32 website.snippet.options["margin-x"] = website.snippet.options.marginAndResize.extend({
33 getSize: function () {
34+ var self = this;
35 this.grid = this._super();
36 var width = this.$target.parents(".row:first").first().outerWidth();
37
38 var grid = [1,2,3,4,5,6,7,8,9,10,11,12];
39- this.grid.e = [_.map(grid, function (v) {return 'col-md-'+v;}), _.map(grid, function (v) {return width/12*v;})];
40+ this.grid.e = [_.map(grid, function (v) {return 'col-'+self.col_style+'-'+v;}), _.map(grid, function (v) {return width/12*v;})];
41
42 var grid = [-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10,11];
43- this.grid.w = [_.map(grid, function (v) {return 'col-md-offset-'+v;}), _.map(grid, function (v) {return width/12*v;}), 12];
44+ this.grid.w = [_.map(grid, function (v) {return 'col-'+self.col_style+'-offset-'+v;}), _.map(grid, function (v) {return width/12*v;}), 12];
45
46 return this.grid;
47 },
48@@ -1301,7 +1308,7 @@
49 pos = $(this).position().left;
50 });
51 if (width > pos + self.size.width) {
52- $row.append("<div class='col-md-1 oe_drop_to_remove'/>");
53+ $row.append("<div class='col-"+this.col_style+"-1 oe_drop_to_remove'/>");
54 var $add_drop = $last.clone();
55 $row.append($add_drop);
56 self._drag_and_drop_active_drop_zone($add_drop);
57@@ -1311,10 +1318,10 @@
58 },
59 _drag_and_drop_start: function () {
60 this._super();
61- this.$target.attr("class",this.$target.attr("class").replace(/\s*(col-lg-offset-|col-md-offset-)([0-9-]+)/g, ''));
62+ this.$target.attr("class",this.$target.attr("class").replace(/\s*(col-[a-z]+-offset-)([0-9-]+)/g, ''));
63 },
64 _drag_and_drop_stop: function () {
65- this.$target.addClass("col-md-offset-" + this.$target.prevAll(".oe_drop_to_remove").length);
66+ this.$target.addClass("col-"+this.col_style+"-offset-" + this.$target.prevAll(".oe_drop_to_remove").length);
67 this._super();
68 },
69 hide_remove_button: function() {
70@@ -1325,7 +1332,7 @@
71 this.hide_remove_button();
72 },
73 on_clone: function ($clone) {
74- var _class = $clone.attr("class").replace(/\s*(col-lg-offset-|col-md-offset-)([0-9-]+)/g, '');
75+ var _class = $clone.attr("class").replace(/\s*(col-[a-z]+-offset-)([0-9-]+)/g, '');
76 $clone.attr("class", _class);
77 this.hide_remove_button();
78 return false;
79@@ -1349,9 +1356,12 @@
80 on_resize: function (compass, beginClass, current) {
81 if (compass === 'w') {
82 // don't change the right border position when we change the offset (replace col size)
83- var beginCol = Number(beginClass.match(/col-md-([0-9]+)|$/)[1] || 0);
84- var beginOffset = Number(beginClass.match(/col-md-offset-([0-9-]+)|$/)[1] || beginClass.match(/col-lg-offset-([0-9-]+)|$/)[1] || 0);
85- var offset = Number(this.grid.w[0][current].match(/col-md-offset-([0-9-]+)|$/)[1] || 0);
86+ var beginCol = beginClass.match(/col-[a-z]+-([0-9]+)|$/);
87+ beginCol = Number(beginCol && beginCol[1] || 0);
88+ var beginOffset = beginClass.match(/col-[a-z]+-offset-([0-9-]+)|$/);
89+ beginOffset = Number(beginOffset && beginOffset[1] || 0);
90+ var offset = this.grid.w[0][current].match(/col-[a-z]+-offset-([0-9-]+)|$/);
91+ var offset = Number(offset && offset[1] || 0);
92 if (offset < 0) {
93 offset = 0;
94 }
95@@ -1360,11 +1370,11 @@
96 colSize = 1;
97 offset = beginOffset + beginCol - 1;
98 }
99- this.$target.attr("class",this.$target.attr("class").replace(/\s*(col-lg-offset-|col-md-offset-|col-md-)([0-9-]+)/g, ''));
100+ this.$target.attr("class",this.$target.attr("class").replace(/\s*(col-[a-z]+-offset-|col-[a-z]+-)([0-9-]+)/g, ''));
101
102- this.$target.addClass('col-md-' + (colSize > 12 ? 12 : colSize));
103+ this.$target.addClass('col-'+this.col_style+'-' + (colSize > 12 ? 12 : colSize));
104 if (offset > 0) {
105- this.$target.addClass('col-md-offset-' + offset);
106+ this.$target.addClass('col-'+this.col_style+'-offset-' + offset);
107 }
108 }
109 this._super(compass, beginClass, current);
110
111=== modified file 'website/views/snippets.xml'
112--- website/views/snippets.xml 2014-04-09 14:07:33 +0000
113+++ website/views/snippets.xml 2014-04-09 15:57:26 +0000
114@@ -923,7 +923,7 @@
115 </div>
116
117 <div data-snippet-option-id='margin-y'
118- data-selector="section, .row > [class*='col-md-'], .carousel, .parallax, hr">
119+ data-selector="section, .row > [class*='col-'], .carousel, .parallax, hr">
120 </div>
121
122 <div data-snippet-option-id='resize'
123@@ -932,7 +932,7 @@
124 </div>
125
126 <div data-snippet-option-id='margin-x'
127- data-selector=".row > [class*='col-md-']"
128+ data-selector=".row > [class*='col-']"
129 data-selector-vertical-children='.row'>
130 </div>
131

Subscribers

People subscribed via source and target branches

to all changes: