th_simple_content_management 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +15 -0
  2. data/app/assets/javascripts/simple_content_management/simple_pages/form.js +4 -0
  3. data/app/assets/javascripts/th-page-editor/column.js +65 -6
  4. data/app/assets/javascripts/th-page-editor/index.js +244 -12
  5. data/app/assets/javascripts/th-page-editor/row.js +71 -1
  6. data/app/assets/stylesheets/simple_content_management/simple_menus.css.scss +1 -1
  7. data/app/assets/stylesheets/simple_content_management/simple_pages.css.scss +52 -20
  8. data/app/controllers/redactor_rails/documents_controller.rb +1 -2
  9. data/app/controllers/redactor_rails/pictures_controller.rb +1 -2
  10. data/app/controllers/simple_content_management/link_banners_controller.rb +14 -0
  11. data/app/controllers/simple_content_management/simple_menus_controller.rb +2 -0
  12. data/app/controllers/simple_content_management/simple_pages_controller.rb +7 -0
  13. data/app/controllers/simple_content_management/simple_posts_controller.rb +8 -0
  14. data/app/helpers/simple_content_management/simple_menus_helper.rb +1 -5
  15. data/app/helpers/simple_content_management/simple_pages_helper.rb +2 -2
  16. data/app/models/simple_content_management/image_uploader.rb +13 -0
  17. data/app/models/simple_content_management/link_banner.rb +13 -0
  18. data/app/models/simple_content_management/simple_menu_item.rb +14 -0
  19. data/app/models/simple_content_management/simple_page.rb +23 -9
  20. data/app/models/simple_content_management/simple_route.rb +1 -2
  21. data/app/views/simple_content_management/link_banners/_form.html.erb +26 -0
  22. data/app/views/simple_content_management/link_banners/edit.html.erb +2 -0
  23. data/app/views/simple_content_management/link_banners/new.html.erb +2 -0
  24. data/app/views/simple_content_management/link_banners/show.html.erb +3 -0
  25. data/app/views/simple_content_management/simple_menus/show.html.erb +1 -1
  26. data/app/views/simple_content_management/simple_pages/_form.html.erb +167 -10
  27. data/app/views/simple_content_management/simple_pages/index.html.erb +4 -2
  28. data/app/views/simple_content_management/simple_pages/show.html.erb +9 -1
  29. data/app/views/simple_content_management/simple_posts/preview.html.erb +13 -0
  30. data/config/locales/simple_content_management/nl/layouts.yml +6 -0
  31. data/config/locales/simple_content_management/nl/models/link_banner.yml +13 -0
  32. data/config/locales/simple_content_management/nl/models/simple_page.yml +3 -1
  33. data/config/routes.rb +7 -1
  34. data/lib/simple_content_management/breadcrumbs.rb +13 -0
  35. data/lib/simple_content_management/content_text.rb +2 -1
  36. data/lib/simple_content_management/version.rb +1 -1
  37. data/lib/simple_content_management.rb +1 -0
  38. data/vendor/assets/javascripts/jquery.ajaxform.js +1190 -0
  39. metadata +82 -83
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MGRhZjY5YmRiOWNhMDg3Yzg0YTZlZWM1NzY0NmYwNjNmZjQ2ZWYyNw==
5
+ data.tar.gz: !binary |-
6
+ NGQ2NDRkNGFlYTI3ZThjNmE5NzlmODU5N2RjYzBjOGI0ZjUxNmJlNQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ YWFhZWIyMTcxMzRkYTI1NzQxZWNhMTU1YWFmNDYzZmQ0OGMzMjc0MWM0NzMz
10
+ YzQ5YjY1Zjk4OTc0MTdiZTdhZDM5OTJmNTUyZjgwOTI0OTFmNDc5NDdlYTNk
11
+ NmZmNzc0NjA2OTUyMTMzZjM1N2Q1NDAwZTYyMmEyOTE5NWE1ZDY=
12
+ data.tar.gz: !binary |-
13
+ ZjgyZmZjMTNjZjBhYmZkZmEyM2JiMjcwZDVmY2ViM2I2NzAyZWQwMWNkMTk3
14
+ NzQ3ZGE0MTEzNjQ5OTQxYjBmZTc0OTMxMDhmZjE3MDM2NzI1YzE1MGZlMjAy
15
+ Njk3OTY4Yjg5ZmQ2ZjEzNjRjMGI3ZjNjZTI2OGUxZDk5YWJkZTQ=
@@ -1,4 +1,5 @@
1
1
  //= require th-page-editor
2
+ //= require jquery.ajaxform.js
2
3
 
3
4
  $(function() {
4
5
  var $simplePageForm = $(".simple-page-form");
@@ -21,6 +22,9 @@ $(function() {
21
22
  })();
22
23
 
23
24
  var $htmlContainer = $simplePageForm.find(".content-html-container");
25
+ if($htmlContainer.html().match(/^\s*$/)) {
26
+ $htmlContainer.html("<div class=row><div class=span12><br><br><center>Klik om mij te bewerken.</center><br><br></div></div>");
27
+ }
24
28
  $htmlContainer.pageeditor({
25
29
  iframeStylePath: $("[data-iframe-style-path]").data("iframe-style-path")
26
30
  });
@@ -3,7 +3,8 @@
3
3
 
4
4
  $.widget("th.pageeditorcolumn", {
5
5
  options: {
6
- row: null
6
+ row: null,
7
+ autoresize: false
7
8
  },
8
9
 
9
10
  _create: function() {
@@ -12,10 +13,40 @@ $.widget("th.pageeditorcolumn", {
12
13
  if(!this.isPlaceholder()) {
13
14
  if(this.element.find(".row").length) {
14
15
  this.convertToEditor();
16
+ } else if(this.element.children("[data-link-banner-id]").length || this.element.find(">.offer-form").length || this.element.find(">#new_appointment_request").length) {
17
+ var spanOffset = 0;
18
+ if(this.element.find(">[data-link-banner-id]>.bloc-sub").length) {
19
+ spanOffset = this.span() - 3;
20
+ } else if(this.element.find(">[data-link-banner-id]>.bloc-main").length) {
21
+ spanOffset = this.span() - 9;
22
+ } else if(this.element.find(">.offer-form").length) {
23
+ spanOffset = this.span() - 7;
24
+ } else if(this.element.find(">#new_appointment_request").length) {
25
+ spanOffset = this.span() - 9;
26
+ }
27
+ this.span(this.span() - spanOffset);
28
+
29
+ // we're not sure if the next element is a valid editorcolumn yet, so we update its offset manually.
30
+ if(spanOffset > 0 && this.element.next().length) {
31
+ var $next = this.element.next();
32
+ var match = null;
33
+ if(match = $next.prop("className").match(/offset(\d+)/)) {
34
+ $this.removeClass(match[0]).addClass("offset" + (parseInt(match[1])+spanOffset));
35
+ }
36
+ }
37
+
38
+ this.enableSortable();
15
39
  } else {
40
+ this.enableSortable();
16
41
  this.enableResize();
17
42
  }
18
43
  }
44
+ var self = this;
45
+ this.element.on("mousedown", function(e) {
46
+ if(e.button == 0 && self.isPlaceholder()) {
47
+ return false;
48
+ }
49
+ });
19
50
  },
20
51
 
21
52
  span: function(newSpan) {
@@ -70,6 +101,7 @@ $.widget("th.pageeditorcolumn", {
70
101
  });
71
102
  this.destroy();
72
103
  this.element.replaceWith($column);
104
+ $column.closest(".row").pageeditorrow("updateToolbar");
73
105
  } else {
74
106
  var $content = this.element.clone();
75
107
  $content.find(".ui-resizable-handle, .hovertool").remove();
@@ -77,6 +109,12 @@ $.widget("th.pageeditorcolumn", {
77
109
  }
78
110
  },
79
111
 
112
+ disableResize: function() {
113
+ if(this.element.data("uiResizable")) {
114
+ this.element.resizable("destroy");
115
+ }
116
+ },
117
+
80
118
  enableResize: function() {
81
119
  var self = this;
82
120
  this.element.resizable({
@@ -112,25 +150,46 @@ $.widget("th.pageeditorcolumn", {
112
150
  });
113
151
  },
114
152
 
153
+ enableSortable: function() {
154
+ var self = this;
155
+ this.element.on("mousedown", function(e) {
156
+ if(!$(e.target).closest(".hovertool").length && e.button == 0) {
157
+ self.row().pageeditorrow("prepareColumnsSortable");
158
+ var mouseupCallback = function() {
159
+ setTimeout(function() {
160
+ self.row().pageeditorrow("unprepareColumnsSortable");
161
+ }, 0);
162
+ $(window).off("mouseup", mouseupCallback);
163
+ };
164
+ $(window).on("mouseup", mouseupCallback);
165
+ }
166
+ });
167
+ },
168
+
115
169
  convertToEditor: function() {
116
- if(!this.element.find(".row").length) {
170
+ if(!this.element.find(".row").length && !this.isPlaceholder()) {
117
171
  this.element.html("<div class=row><div class=span"+this.span()+">"+this.element.html()+"</div></div>");
118
172
  }
173
+ this.element.removeClass("column-add-placeholder");
174
+ this.element.removeAttr("style");
119
175
  if(this.element.data("uiResizable")) {
120
176
  this.element.resizable("destroy");
121
177
  }
122
178
  this.element.addClass("nested-editor").find(".hovertool").remove();
123
- this.asEditor = this.element.pageeditor($.extend(this.options.row.options.editor.options, { spanwidth: this.span() }));
179
+ this.asEditor = this.element.pageeditor($.extend({}, this.options.row.options.editor.options, { spanwidth: this.span() }));
124
180
  },
125
181
 
126
182
  destroy: function() {
127
183
  this.element.find(".hovertool").remove();
128
- if(this.element.data("uiResizable")) {
129
- this.element.resizable("destroy");
130
- }
184
+ this.element.find(".dummy").remove();
185
+ this.disableResize();
131
186
  if(this.asEditor) {
132
187
  this.element.removeClass("nested-editor");
133
188
  this.asEditor.pageeditor("destroy");
189
+ var $children = this.element.children(".row").children();
190
+ if($children.length == 1) {
191
+ this.element.replaceWith($children);
192
+ }
134
193
  }
135
194
  }
136
195
  });
@@ -5,7 +5,7 @@
5
5
 
6
6
  (function($) {
7
7
  var BASIC_SPANS_SELECTOR = ".span1, .span2, .span3, .span4, .span5, .span6, .span7, .span8, .span9, .span10, .span11, .span12".replace(/\.span\d+/g, function(classname) {
8
- return classname + ":not(.nested-editor)";
8
+ return "> .row > " +classname + ":not(.nested-editor)";
9
9
  });
10
10
  var NO_PLACEHOLDER_SELECTOR = BASIC_SPANS_SELECTOR.replace(/\.span\d+/g, function(classname) {
11
11
  return classname + ":not(.column-add-placeholder)";
@@ -16,7 +16,7 @@
16
16
  spanwidth: 12,
17
17
  iframeStylePath: null,
18
18
  editorModal: "#content-editor",
19
- editorArea: "#content-editor textarea"
19
+ editorArea: "#content-editor #editor-html-content textarea"
20
20
  },
21
21
 
22
22
  _create: function() {
@@ -29,7 +29,8 @@
29
29
 
30
30
  this.element.on("mouseenter", NO_PLACEHOLDER_SELECTOR, function() {
31
31
  var $this = $(this);
32
- $("<span class=\"hovertool btn btn-mini\"><i class=icon-trash></i></span>").prependTo(this).css({ marginTop: -11, marginLeft: -11 }).click(function() {
32
+ $("<span class=\"hovertool btn btn-mini\"><i class=icon-trash></i></span>").prependTo(this).css({ marginTop: -11, marginLeft: -11 }).click(function(e) {
33
+ e.preventDefault();
33
34
  var $row = $this.pageeditorcolumn("row");
34
35
  $this.remove();
35
36
  $row.pageeditorrow("refreshColumnPlaceholders");
@@ -47,33 +48,260 @@
47
48
 
48
49
  var $editorModal = $(this.options.editorModal);
49
50
  var $editorArea = $(this.options.editorArea);
50
- this.element.on("click", BASIC_SPANS_SELECTOR, function() {
51
+
52
+ this.element.on("click", BASIC_SPANS_SELECTOR, function(e) {
51
53
  var $column = $(this);
54
+
55
+ if($column.is(".ui-sortable-helper")) {
56
+ return;
57
+ }
58
+
52
59
  var saveCallback = function() {
60
+ var $activePane = $editorModal.find(".tab-pane.active");
61
+ switch($activePane.attr("id")) {
53
62
 
54
- switch($editorModal.find(".tab-pane.active").attr("id")) {
55
63
  case "editor-container":
56
64
  self.subeditors.push($column.pageeditorcolumn("convertToEditor"));
57
65
  break;
66
+
67
+ case "editor-blog-post-preview":
68
+ var path = $activePane.data("path");
69
+ var postId = $activePane.find("select#_blog_post_id option:selected").val();
70
+ $activePane.find("select#_blog_post_id option:first-child").prop("selected", true);
71
+ if(postId && postId.length) {
72
+ $.get(path.replace(/simple_post_id/, postId), function(html) {
73
+ var $row = $column.closest(".row");
74
+ $column.pageeditorcolumn("val", html);
75
+ $row.pageeditorrow("refreshColumnPlaceholders");
76
+ $editorModal.modal("hide");
77
+ self.checkEmptyRowRequired();
78
+ });
79
+ }
80
+ return;
81
+
82
+ case "editor-link-banner":
83
+ $activePane.find("form").ajaxSubmit({
84
+ success: function(html) {
85
+ var $html = $($.parseHTML(html));
86
+ if($html.find(".errors").length) {
87
+ $activePane.find(".errors").replaceWith($html.find(".errors"));
88
+ } else {
89
+ var $row = $column.closest(".row");
90
+ $column.pageeditorcolumn("val", html);
91
+ $row.pageeditorrow("refreshColumnPlaceholders");
92
+ $editorModal.modal("hide");
93
+ self.checkEmptyRowRequired();
94
+ }
95
+ }
96
+ });
97
+ return; // return to prevent immidiate handling of saving
98
+
99
+ case "editor-link-list":
100
+ var $form = $activePane.find("form");
101
+ var title = $form.find("#editor-link-list-title").val();
102
+ var type = $form.find("input[name=listtype]:checked").val();
103
+
104
+ var $html = $("<div class=\""+type+"-container\"></div>");
105
+ $("<h3></h3>").text(title).appendTo($html);
106
+
107
+ var $labels = $form.find("input[name=\"link-label[]\"]");
108
+ var $uris = $form.find("input[name=\"link-uri[]\"]");
109
+
110
+ switch(type) {
111
+ case "linklist":
112
+ var $linklist = $("<ul class=\"link-list\"></ul>").appendTo($html);
113
+ for(var i=0; i<$labels.length; i++) {
114
+ var label = $($labels[i]).val();
115
+ var uri = $($uris[i]).val();
116
+ if(uri.length && label.length) {
117
+ var $listitem = $("<li></li>").appendTo($linklist);
118
+ $("<a></a>").attr("href", uri).text(label).appendTo($listitem);
119
+ }
120
+ }
121
+ break;
122
+ case "dropdown":
123
+ var $linklist = $("<select class=\"link-list\" data-placeholder=\"Maak een keuze\"><option></option></select>").appendTo($html);
124
+ for(var i=0; i<$labels.length; i++) {
125
+ var label = $($labels[i]).val();
126
+ var uri = $($uris[i]).val();
127
+ if(uri.length && label.length) {
128
+ $("<option></option>").attr("value", uri).text(label).appendTo($linklist);
129
+ }
130
+ }
131
+ break;
132
+ }
133
+
134
+ $column.pageeditorcolumn("val", $html[0].outerHTML);
135
+ break;
136
+
137
+ case "editor-blog-links":
138
+ $html = $("<div class=\"blog-posts-section\"></div>");
139
+ $html.append($("<h3></h3>").text($activePane.find("#editor-blog-links-title").val()));
140
+ $linksList = $("<ul class=\"link-list\"></ul>");
141
+
142
+ var tagIds = $activePane.find("#editor-blog-links-tags").val();
143
+ $linksList.attr("data-blog-post-links-list", tagIds ? tagIds.join(",") : "");
144
+
145
+ var linksAmount = parseInt($activePane.find("#editor-blog-links-amount").val());
146
+ $linksList.attr("data-blog-post-links-amount", linksAmount);
147
+
148
+ for(var i=0; i<linksAmount; i++) {
149
+ $linksList.append("<li class=\"dummy\"><a href=\"#\">Link naar blogpost "+(i+1)+"</a></li>");
150
+ }
151
+
152
+ var openAllLinkText = $activePane.find("#editor-blog-links-open-all").val();
153
+ if(openAllLinkText.length) {
154
+ $linksList.append($("<li style=\"font-weight: bold;\"></li>").append($("<a href=\"blog"+( tagIds ? "?tag_ids="+tagIds.join("+") : "" )+"\"></a>").text(openAllLinkText)));
155
+ }
156
+ $html.append($linksList);
157
+
158
+ $column.pageeditorcolumn("val", $html[0].outerHTML);
159
+ break;
160
+
161
+ case "editor-offer":
162
+ var $offerForm = $activePane.find(".offer-form");
163
+ $column.pageeditorcolumn("val", $offerForm[0].outerHTML.replace(/<(\/?)form/g, function(_, slash) {
164
+ return "<"+slash+"dummyformtag";
165
+ }));
166
+ break;
167
+
168
+ case "editor-appointment":
169
+ var $html = $activePane.find("form");
170
+ var $row = $column.closest(".row");
171
+ console.log($html[0].outerHTML);
172
+ $column.pageeditorcolumn("val", $html[0].outerHTML.replace(/<(\/?)form/g, function(_, slash) {
173
+ return "<"+slash+"dummyformtag";
174
+ }));
175
+ $row.pageeditorrow("refreshColumnPlaceholders");
176
+ break;
177
+
58
178
  default:
59
179
  $column.pageeditorcolumn("val", $editorArea.val());
60
180
  }
61
-
62
181
  $editorModal.modal("hide");
63
182
  self.checkEmptyRowRequired();
183
+ };
64
184
 
185
+ var showLinkBannerTabCallback = function() {
186
+ var path = $(this).data("path");
187
+ var linkBannerId = $column.children("[data-link-banner-id]").data("link-banner-id");
188
+ if(linkBannerId) {
189
+ path = path.replace("new", "" +linkBannerId + "/edit");
190
+ }
191
+ var $linkBannerEditor = $("#editor-link-banner");
192
+ $linkBannerEditor.html("<em>laden...</em>");
193
+ $.get(path, function(html) {
194
+ $linkBannerEditor.html(html);
195
+ $linkBannerEditor.find("#link-banner-quick-select").chosen().trigger("liszt:updated").change(function() {
196
+ var data = $(this).find("option:checked").data();
197
+ $("#simple_content_management_link_banner_uri").val(data.route || data.routes[0]);
198
+ });
199
+ });
65
200
  };
66
201
 
67
- $editorModal.modal("show").find("[data-save-button]").on("click", saveCallback)
202
+ var showLinkListTabCallback = function() {
203
+ var $tab = $editorModal.find("#editor-link-list");
204
+ var $form = $tab.find("form");
205
+ var $table = $tab.find("#links-table");
206
+ $table.find("tbody > tr:not(:first-child)").remove();
207
+ $form[0].reset();
208
+ $form.find("#editor-link-list-title").val($column.find("h3").text());
209
+ var $template = $table.find("tbody > tr:first-child").clone();
210
+ var rowCallback = function($row) {
211
+ $row.find(".chzn-container").remove();
212
+ $row.find("select").removeClass("chzn-done").removeAttr("id").show().chosen().val("").trigger("liszt:updated").change(function() {
213
+ var data = $(this).find("option:checked").data();
214
+ $row.find("input[name=\"link-label[]\"]").val(data.name);
215
+ $row.find("input[name=\"link-uri[]\"]").val(data.route || data.routes[0]);
216
+ });
217
+ }
218
+ rowCallback($table.find("tbody > tr:first-child"));
219
+ $form.find("#add-link-button").off("click").on("click", function() {
220
+ var $row = $template.clone();
221
+ $table.find("tbody").append($row);
222
+ rowCallback($row);
223
+ return false;
224
+ });
225
+
226
+ var $linkList = $column.find(".dropdown-container > .link-list, .linklist-container > .link-list");
227
+ if($linkList.length && $linkList.children().length) {
228
+ $table.find("tbody tr").remove();
229
+ $linkList.children().each(function() {
230
+ var uri = $(this).is("option") ? $(this).val() : $(this).find("a").attr("href");
231
+ var label = $(this).text();
232
+ if(uri.length && label.length) {
233
+ var $row = $template.clone();
234
+ $row.find("input[name=\"link-label[]\"]").val(label);
235
+ $row.find("input[name=\"link-uri[]\"]").val(uri);
236
+ $table.find("tbody").append($row);
237
+ rowCallback($row);
238
+ }
239
+ });
240
+ }
241
+ $table.find("tbody").sortable();
242
+ }
243
+
244
+ $editorModal.modal("show").find("[data-save-button]").on("click", saveCallback);
68
245
  $editorModal.on("hide", function() {
246
+ $editorModal.find("a[href=#editor-html-content]").tab("show");
69
247
  $editorModal.find("[data-save-button]").off("click", saveCallback);
248
+ $editorModal.find("a[href=#editor-link-banner]").off("show", showLinkBannerTabCallback);
249
+ $editorModal.find("a[href=#editor-link-list]").off("shown", showLinkListTabCallback);
250
+ });
251
+
252
+ $editorModal.find("a[href=#editor-link-banner]").on("show", showLinkBannerTabCallback);
253
+ $editorModal.find("a[href=#editor-link-list]").on("shown", showLinkListTabCallback);
254
+
255
+ $editorModal.find("a[href=#editor-blog-links]").on("shown", function() {
256
+ $editorModal.find("#editor-blog-links-tags").chosen();
257
+ var $blogSection = $column.find(".blog-posts-section");
258
+ if($blogSection.length) {
259
+ var $list = $column.find("[data-blog-post-links-list]");
260
+ $editorModal.find("#editor-blog-links-tags").val($list.data("blog-post-links-list").toString().split(/,/g)).trigger("liszt:updated");
261
+ $editorModal.find("#editor-blog-links-title").val($blogSection.find("h3").text());
262
+ $editorModal.find("#editor-blog-links-amount").val($list.data("blog-post-links-amount"));
263
+ $editorModal.find("#editor-blog-links-open-all").val($list.children("li:not(.dummy)").text());
264
+ } else {
265
+ $editorModal.find("#editor-blog-links-form")[0].reset();
266
+ $editorModal.find("#editor-blog-links-tags").trigger("liszt:updated");
267
+ }
70
268
  });
71
269
 
72
- $editorArea.redactor($.extend(getRedactorOptions(), {
73
- iframe: true,
74
- css: self.options.iframeStylePath,
75
- formattingTags: ['p', 'plead', 'blockquote', 'pre', 'h1', 'h2', 'h3', 'h4']
76
- })).redactor("set", $column.pageeditorcolumn("val"));
270
+ if($column.children("[data-link-banner-id]").length) {
271
+ $editorModal.find("a[href=#editor-link-banner]").tab("show");
272
+ } else if($column.children(".dropdown-container, .linklist-container").length) {
273
+ $editorModal.find("a[href=#editor-link-list]").tab("show");
274
+ } else if($column.children(".blog-posts-section").length) {
275
+ $editorModal.find("a[href=#editor-blog-links]").tab("show");
276
+ } else if($column.find(".appointment-request-form").length) {
277
+ $editorModal.find("a[href=#editor-appointment]").tab("show");
278
+ } else if($column.find(".offer-form").length) {
279
+ $editorModal.find("a[href=#editor-offer-form]").tab("show");
280
+ } else if($column.find(".simple-post-preview").length) {
281
+ $editorModal.find("a[href=#editor-blog-post-preview]").tab("show");
282
+ }
283
+
284
+ if(!$editorArea.data("redactor")) {
285
+ $editorArea.val($column.pageeditorcolumn("val"));
286
+ $editorArea.redactor($.extend(getRedactorOptions(), {
287
+ iframe: true,
288
+ css: self.options.iframeStylePath,
289
+ formattingTags: ['p', 'plead', 'blockquote', 'pre', 'h1', 'h2', 'h3', 'h4']
290
+ }))
291
+ } else {
292
+ $editorArea.redactor("set", $column.pageeditorcolumn("val"));
293
+ }
294
+ });
295
+
296
+ this.element.sortable({
297
+ axis: "y",
298
+ handle: ".icon-resize-vertical",
299
+ start: function() {
300
+ self.element.addClass("ui-sortable-active");
301
+ },
302
+ stop: function() {
303
+ self.element.removeClass("ui-sortable-active");
304
+ }
77
305
  });
78
306
  },
79
307
 
@@ -99,6 +327,10 @@
99
327
  this.rows().each(function() {
100
328
  $(this).pageeditorrow("destroy");
101
329
  });
330
+ this.element.removeClass("ui-sortable");
331
+ this.element.find("[style=]").each(function() {
332
+ $(this).removeAttr("style");
333
+ });
102
334
  }
103
335
  });
104
336
  })(jQuery);
@@ -1,4 +1,5 @@
1
1
  //= require jquery.ui.widget
2
+ //= require jquery.ui.sortable
2
3
  //= require th-page-editor/column
3
4
 
4
5
  (function($) {
@@ -15,14 +16,26 @@
15
16
  $(this).pageeditorcolumn({ row: self });
16
17
  });
17
18
  this.enableColumnPlaceholders();
19
+ this.updateToolbar();
18
20
  },
19
21
 
20
22
  spanwidth: function() {
21
23
  return this.options.editor.spanwidth();
22
24
  },
23
25
 
26
+ updateToolbar: function() {
27
+ if(this.hasContentColumns() && this.element.children(".hovertool").length == 0) {
28
+ $("<span class=\"hovertool btn btn-mini\"><i class=icon-resize-vertical></i></span>").prependTo(this.element);
29
+ }
30
+ },
31
+
24
32
  columns: function() {
25
- return this.element.children(BASIC_SPANS_SELECTOR);
33
+ var columns = this.element.children(BASIC_SPANS_SELECTOR);
34
+ var self = this;
35
+ columns.each(function() {
36
+ $(this).pageeditorcolumn({ row: self });
37
+ });
38
+ return columns;
26
39
  },
27
40
 
28
41
  refreshColumnPlaceholders: function() {
@@ -34,6 +47,62 @@
34
47
  return $('<div class=column-add-placeholder></div>').pageeditorcolumn({ row: this, span: span, offset: offset });
35
48
  },
36
49
 
50
+ unprepareColumnsSortable: function() {
51
+ this.element.removeClass("ui-sortable");
52
+ this.columns().each(function() {
53
+ var $column = $(this);
54
+ var $next = $column.next();
55
+ if($next.length && $column.is(".column-add-placeholder") && $next.is(".column-add-placeholder")) {
56
+ $next.pageeditorcolumn("span", $next.pageeditorcolumn("span") + $column.pageeditorcolumn("span"));
57
+ $column.remove();
58
+ }
59
+ });
60
+ },
61
+
62
+ prepareColumnsSortable: function() {
63
+ this.disableColumnPlaceholders();
64
+ var $columns = this.columns();
65
+ var spanwidth = this.spanwidth();
66
+ if($columns.length == 0) {
67
+ for(var x=0; x<spanwidth; x++) {
68
+ this.createColumnPlaceholder(1).appendTo(this.element);
69
+ }
70
+ } else {
71
+ var self = this;
72
+ var columnsRemaining = spanwidth;
73
+ $.each(this.columns(), function() {
74
+ var offset = $(this).pageeditorcolumn("offset");
75
+ columnsRemaining -= offset + $(this).pageeditorcolumn("span");
76
+ if(offset > 0) {
77
+ for(var x=0; x<offset; x++) {
78
+ self.createColumnPlaceholder(1).insertBefore($(this));
79
+ }
80
+ $(this).pageeditorcolumn("offset", 0);
81
+ }
82
+ });
83
+ if(columnsRemaining > 0) {
84
+ for(var x=0; x<columnsRemaining; x++) {
85
+ this.createColumnPlaceholder(1).appendTo(this.element);
86
+ }
87
+ }
88
+ }
89
+
90
+ var self = this;
91
+ this.element.sortable({
92
+ axis: "x",
93
+ items: ">:not(.hovertool)",
94
+ stop: function() {
95
+ self.element.removeClass("ui-sortable-active");
96
+ self.unprepareColumnsSortable();
97
+ },
98
+ start: function() {
99
+ self.element.addClass("ui-sortable-active");
100
+ }
101
+ });
102
+ this.element.addClass("ui-sortable");
103
+ this._updatePlaceholderHeights();
104
+ },
105
+
37
106
  disableColumnPlaceholders: function() {
38
107
  this.columns().filter(".column-add-placeholder").each(function() {
39
108
  $(this).next().pageeditorcolumn("offset", $(this).pageeditorcolumn("span"));
@@ -76,6 +145,7 @@
76
145
  this.columns().each(function() {
77
146
  $(this).pageeditorcolumn("destroy");
78
147
  });
148
+ this.element.find(".hovertool").remove();
79
149
  } else {
80
150
  this.element.remove();
81
151
  }
@@ -25,7 +25,7 @@ form.edit_simple_content_management_simple_menu {
25
25
  border: 1px solid #ccc;
26
26
  border-right-width: 0;
27
27
  width: 100%;
28
- box-sizing: border-box;
28
+ @include box-sizing(border-box);
29
29
 
30
30
  a.destroy {
31
31
  display: inline-block;
@@ -1,5 +1,25 @@
1
1
  @import "bootstrap-tagmanager";
2
2
  @import "jquery.ui.resizable";
3
+ @import "chosen";
4
+
5
+ .content-html-preview {
6
+ .row {
7
+ white-space: nowrap;
8
+ margin-bottom: 5px;
9
+ }
10
+
11
+ .span1, .span2, .span3, .span4, .span5, .span6, .span7, .span8, .span9, .span10, .span11, .span12 {
12
+ display: inline-block;
13
+ white-space: normal;
14
+ float: none;
15
+ vertical-align: top;
16
+ }
17
+
18
+ .offer-form {
19
+ .step { display: none; }
20
+ .step0 { display: block; }
21
+ }
22
+ }
3
23
 
4
24
  .simple-page-form {
5
25
 
@@ -18,18 +38,38 @@
18
38
  }
19
39
 
20
40
  .content-html-container {
21
- .row {
22
- white-space: nowrap;
41
+ .hovertool {
42
+ z-index: 91;
43
+ position: absolute;
44
+ border-radius: 22px;
45
+ width: 22px;
46
+ height: 22px;
47
+ margin: 0;
48
+ padding: 0;
49
+ }
50
+
51
+ // I cried myself to sleep after this...
52
+ .nested-editor:nth-child(2) > .row:first-child > .hovertool { margin-top: 22px; }
53
+ .nested-editor:nth-child(2) > .row:first-child > .nested-editor:nth-child(2) > .row:first-child > .hovertool { margin-top: 44px; }
54
+
55
+ &.ui-sortable-active > .row, .nested-editor.ui-sortable-active > .row {
56
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6), 0 0 0 1px rgba(82, 168, 236, 0.8);
57
+ background: rgba(82, 168, 236, 0.075);
58
+ }
59
+
60
+ .row.ui-sortable-active > .column-add-placeholder {
61
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6), 0 0 0 1px rgba(82, 168, 236, 0.8);
62
+ background: rgba(82, 168, 236, 0.075);
63
+ cursor: pointer;
64
+ }
65
+
66
+ .row > .hovertool {
67
+ margin-left: -22px;
23
68
  }
69
+
24
70
  .span1, .span2, .span3, .span4, .span5, .span6, .span7, .span8, .span9, .span10, .span11, .span12 {
25
- display: inline-block;
26
- white-space: normal;
27
- float: none;
28
- vertical-align: top;
29
-
30
- &:hover, &.ui-resizable-resizing {
31
- outline: 1px solid rgba(82, 168, 236, 0.8);
32
- box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
71
+ &:hover, &.ui-resizable-resizing, &.ui-sortable-helper {
72
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6), 0 0 0 1px rgba(82, 168, 236, 0.8);
33
73
  background: rgba(82, 168, 236, 0.075);
34
74
  cursor: pointer;
35
75
 
@@ -50,21 +90,12 @@
50
90
  &.column-add-placeholder {
51
91
  min-height: 60px;
52
92
  }
53
-
54
- > .hovertool {
55
- z-index: 91;
56
- position: absolute;
57
- border-radius: 22px;
58
- width: 22px;
59
- height: 22px;
60
- margin: 0;
61
- padding: 0;
62
- }
63
93
  }
64
94
  }
65
95
  }
66
96
 
67
97
  #content-editor {
98
+ position: absolute;
68
99
  width: 800px;
69
100
  margin-left: -400px;
70
101
 
@@ -78,6 +109,7 @@
78
109
  .modal-body {
79
110
  height: 480px;
80
111
  max-height: 480px;
112
+ overflow: auto;
81
113
 
82
114
  textarea {
83
115
  height: 480px - 32px;