lalala 4.0.0.dev.133 → 4.0.0.dev.134

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6329301663edfc88e1b14baea18850d1796b06ac
4
- data.tar.gz: 2d6c046c1452ae601c8a0a4eb1c6f4237c53ada2
3
+ metadata.gz: 4ff12f23f11e3f4a30243125978c3afed923dcfb
4
+ data.tar.gz: 32268b08b966ad0084f3c64daa9186106cb285d7
5
5
  SHA512:
6
- metadata.gz: f6e326d7b28ec3dfe25e908dd9539abe3ac2a4e85b31ad907720fd665df84bd361692168eda21c053e8d66591d9871f5f235faaede5949febd88bedc3e294463
7
- data.tar.gz: b952b456028c79d336d6a0f475dbe81d97c8463025a978615b8c04bb0afd7f65499b3c3ec1ddcd5c1c39a4cfe54d1787e2e8d053bc212fbaa47a0eedded32905
6
+ metadata.gz: 01a1a6daa3a96804b2ad33fa4a7a7fe986db1af15b196c4b990e1e8cdc9c0c0d4877a6d43ee8bc37a0c7851d567923877bfab89f5c996643116bb73240046456
7
+ data.tar.gz: f0b36b20bfb665ae6087a5a66795ddadb0c3c5b15beb796df5dce3f8dc0f3e0ede1864c014d58833d125e05a0add4982e91a502cbf629426d8565a1b2f6912e3
@@ -15,7 +15,7 @@ Grid = (function() {
15
15
 
16
16
 
17
17
  function G(grid_element) {
18
- this.selected_images = [];
18
+ this.selected_assets = [];
19
19
 
20
20
  this.transform_html(grid_element);
21
21
  this.bind_mouse_events();
@@ -24,25 +24,20 @@ Grid = (function() {
24
24
 
25
25
 
26
26
  G.prototype.transform_html = function(grid_element) {
27
- var fragment, el, el_images, el_input, data_attr, $grid, $original_list;
27
+ var fragment, el, el_assets, el_actions, el_errors, $grid, $original_list;
28
28
 
29
29
  // elements
30
30
  $grid = $(grid_element);
31
31
  $original_list = $grid.children("ul:first-child");
32
32
 
33
- // data -> attributes
34
- data_attr = "data-accessible-attributes";
35
- data_attr = $original_list.attr(data_attr)
36
- data_attr = data_attr ? data_attr.split(",") : [];
37
-
38
- // document fragment for the images
33
+ // document fragment for the assets
39
34
  fragment = document.createDocumentFragment();
40
35
 
41
- // transform images html
36
+ // transform assets html
42
37
  $grid.find("li.asset").not(":last-child").each(function() {
43
38
  var grid_piece = document.createElement("li");
44
39
  grid_piece.className = "asset";
45
- grid_piece.innerHTML = this.innerHTML.replace("<a", "<a class=\"image\"");
40
+ grid_piece.innerHTML = this.innerHTML.replace("<a", "<a class=\"thumbnail\"");
46
41
  var overlay = document.createElement("div");
47
42
  overlay.className = "overlay";
48
43
  grid_piece.appendChild(overlay);
@@ -53,14 +48,14 @@ Grid = (function() {
53
48
  el = document.createElement("div");
54
49
  el.className = "mod-grid";
55
50
 
56
- el_images = document.createElement("ul");
57
- el_images.className = "images";
58
- el_images.appendChild(fragment);
51
+ el_assets = document.createElement("ul");
52
+ el_assets.className = "assets";
53
+ el_assets.appendChild(fragment);
59
54
 
60
55
  el_actions = document.createElement("div");
61
56
  el_actions.className = "actions";
62
57
  el_actions.innerHTML = "" +
63
- $grid.find("li:last-child").html() +
58
+ $grid.find("li.actions").html() +
64
59
  '<a class="button" rel="choose-files">Choose files</a>' +
65
60
  '<div class="files-description"></div>' +
66
61
  '<a class="button unavailable" rel="edit">Edit selected</a>' +
@@ -68,7 +63,15 @@ Grid = (function() {
68
63
 
69
64
  // merge
70
65
  el.appendChild(el_actions);
71
- el.appendChild(el_images);
66
+ el.appendChild(el_assets);
67
+
68
+ // errors
69
+ if ($grid.find("li.errors").length) {
70
+ el_errors = document.createElement("div");
71
+ el_errors.className = "errors";
72
+ el_errors.innerHTML = $grid.find("li.errors").html();
73
+ el.appendChild(el_errors);
74
+ }
72
75
 
73
76
  // replace original with new
74
77
  $original_list.replaceWith(el);
@@ -87,7 +90,7 @@ Grid = (function() {
87
90
  this.$el.children(".actions").find('[rel="edit"], [rel="destroy"]').each(function() {
88
91
  var $btn = $(this);
89
92
 
90
- if (grid.selected_images.length === 0) {
93
+ if (grid.selected_assets.length === 0) {
91
94
  $btn.addClass("unavailable");
92
95
  } else {
93
96
  $btn.removeClass("unavailable");
@@ -100,11 +103,11 @@ Grid = (function() {
100
103
  // Events
101
104
  //
102
105
  G.prototype.bind_mouse_events = function() {
103
- this.$el.children(".images")
106
+ this.$el.children(".assets")
104
107
  .on("mouseleave", "li", this.row_mouseleave)
105
108
  .on("mouseleave", "li label", this.row_label_mouseleave)
106
109
  .on("mouseenter", "li label", this.row_label_mouseenter)
107
- .on("mouseenter", "li .image", this.row_image_mouseenter)
110
+ .on("mouseenter", "li .thumbnail", this.row_thumbnail_mouseenter)
108
111
  .on("click", "li a", function(e) { e.preventDefault(); })
109
112
  .on("click", "li .attributes .close-button", this.close_button_click);
110
113
 
@@ -127,7 +130,7 @@ Grid = (function() {
127
130
  $(this).parent().addClass("properties").removeClass("move");
128
131
  };
129
132
 
130
- G.prototype.row_image_mouseenter = function(e) {
133
+ G.prototype.row_thumbnail_mouseenter = function(e) {
131
134
  var $p = $(this).parent();
132
135
  if ($p.hasClass("edit-block")) return;
133
136
  $p.addClass("properties");
@@ -149,19 +152,19 @@ Grid = (function() {
149
152
  };
150
153
 
151
154
  G.prototype.edit_or_destroy_selected_button_click = function(e) {
152
- var i = 0, j = this.selected_images.length,
155
+ var i = 0, j = this.selected_assets.length,
153
156
  $e = $(e.currentTarget), action = $e.attr("rel");
154
157
 
155
158
  if ($e.hasClass("unavailable")) return;
156
159
 
157
160
  for (; i<j; ++i) {
158
- var id = this.selected_images[i];
161
+ var id = this.selected_assets[i];
159
162
  var $row = $("#" + id).parent();
160
163
  $row.removeClass("selected");
161
164
  this["set_to_" + action]($row[0]);
162
165
  }
163
166
 
164
- this.selected_images.length = 0;
167
+ this.selected_assets.length = 0;
165
168
  this.check_edit_and_destroy_buttons();
166
169
  };
167
170
 
@@ -190,16 +193,16 @@ Grid = (function() {
190
193
  $(ui.unselecting).removeClass("selected");
191
194
  },
192
195
  stop: function(e, ui) {
193
- var new_selected_images = [];
194
- grid.$el.find(".images > li").each(function() {
196
+ var new_selected_assets = [];
197
+ grid.$el.find(".assets > li").each(function() {
195
198
  var $t = $(this), id;
196
199
  if ($t.hasClass("selected")) {
197
200
  id = $t.children('input[type="hidden"]:first').attr("id");
198
- new_selected_images.push(id + "");
201
+ new_selected_assets.push(id + "");
199
202
  id = null;
200
203
  }
201
204
  });
202
- grid.selected_images = new_selected_images;
205
+ grid.selected_assets = new_selected_assets;
203
206
  grid.check_edit_and_destroy_buttons();
204
207
  }
205
208
  });
@@ -226,7 +229,7 @@ Grid = (function() {
226
229
 
227
230
  G.prototype.set_to_not_edit = function(row) {
228
231
  $(row).removeClass("edit-block");
229
- }
232
+ };
230
233
 
231
234
 
232
235
 
@@ -11,12 +11,12 @@
11
11
 
12
12
  @include border-radius(5px);
13
13
 
14
- .images,
14
+ .assets,
15
15
  .actions {
16
16
  overflow: hidden;
17
17
  }
18
18
 
19
- .images {
19
+ .assets {
20
20
  padding-top: 10px - 3px;
21
21
  }
22
22
 
@@ -26,7 +26,7 @@
26
26
  margin: 0 11px 11px 0;
27
27
  position: relative;
28
28
 
29
- &, .image, .overlay {
29
+ &, .thumbnail, .overlay {
30
30
  height: 100px;
31
31
  width: 100px;
32
32
  }
@@ -50,15 +50,15 @@
50
50
  .asset.will-destroy .overlay,
51
51
  .asset.selected.will-destroy .overlay { background: rgba($red, .5); }
52
52
 
53
- // image + overlay
54
- .asset .image,
53
+ // thumbnail + overlay
54
+ .asset .thumbnail,
55
55
  .asset .overlay {
56
56
  left: 0;
57
57
  position: absolute;
58
58
  top: 0;
59
59
  }
60
60
 
61
- .asset .image {
61
+ .asset .thumbnail {
62
62
  z-index: 0;
63
63
  }
64
64
 
@@ -13,7 +13,7 @@ class Lalala::AbstractAsset < ActiveRecord::Base
13
13
 
14
14
  def self.extension_white_list
15
15
  list = if self.uploaders and self.uploaders[:asset]
16
- self.uploaders[:asset].new.extension_white_list
16
+ self.uploaders[:asset].new.try(:extension_white_list)
17
17
  end
18
18
 
19
19
  list = list || []
@@ -55,7 +55,7 @@ class Formtastic::Inputs::GridInput
55
55
  end
56
56
  end
57
57
 
58
- html += template.content_tag :li do
58
+ html += template.content_tag :li, class: "actions" do
59
59
  builder.fields_for(method, assets.build) do |f|
60
60
  f.file_field :asset, multiple: true, accept: asset_model_class.extension_white_list
61
61
  end
@@ -30,8 +30,10 @@ class Lalala::ExtRack::MultipleFileUploadSupport
30
30
  return unless Array === assets
31
31
 
32
32
  assets.each do |file|
33
- params[last_id] = { "asset" => file }.with_indifferent_access
34
- last_id.succ!
33
+ if file.present?
34
+ params[last_id] = { "asset" => file }.with_indifferent_access
35
+ last_id.succ!
36
+ end
35
37
  end
36
38
 
37
39
  else
@@ -1,6 +1,6 @@
1
1
  module Lalala
2
2
  VERSION = "4.0.0"
3
- BUILD = "133"
3
+ BUILD = "134"
4
4
 
5
5
  if BUILD != ("{{BUILD_NUMBER" + "}}") # prevent sed replacement (see script/ci)
6
6
  BUILD_VERSION = "#{VERSION}.dev.#{BUILD}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lalala
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.dev.133
4
+ version: 4.0.0.dev.134
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Menke