lalala 4.0.0.dev.94 → 4.0.0.dev.107

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/lalala/modules/grid.module.js +146 -13
  3. data/app/assets/stylesheets/lalala/base/_variables.css.scss +1 -0
  4. data/app/assets/stylesheets/lalala/components/_buttons.css.scss +3 -3
  5. data/app/assets/stylesheets/lalala/components/_forms.css.scss +27 -2
  6. data/app/assets/stylesheets/lalala/lib/_jquery-ui.css.scss +14 -629
  7. data/app/assets/stylesheets/lalala/modules/_footer.css.scss +1 -0
  8. data/app/assets/stylesheets/lalala/modules/_grid.css.scss +96 -1
  9. data/app/models/lalala/abstract_asset.rb +20 -0
  10. data/app/models/lalala/file_asset.rb +3 -0
  11. data/app/models/lalala/image_asset.rb +3 -0
  12. data/lalala-assets.gemspec +1 -1
  13. data/lib/formtastic/inputs/grid_input.rb +29 -4
  14. data/lib/formtastic/inputs/single_file_input.rb +34 -0
  15. data/lib/generators/lalala/install/install_generator.rb +12 -0
  16. data/lib/generators/lalala/install/templates/migrations/4_create_assets.rb +23 -0
  17. data/lib/generators/lalala/install/templates/models/file_asset.rb +2 -0
  18. data/lib/generators/lalala/install/templates/models/image_asset.rb +2 -0
  19. data/lib/generators/lalala/install/templates/uploaders/file_uploader.rb +2 -0
  20. data/lib/generators/lalala/install/templates/uploaders/image_uploader.rb +11 -0
  21. data/lib/lalala/engine.rb +7 -0
  22. data/lib/lalala/ext_active_record/assets.rb +25 -0
  23. data/lib/lalala/ext_active_record.rb +1 -0
  24. data/lib/lalala/ext_rack/multiple_file_upload_support.rb +46 -0
  25. data/lib/lalala/ext_rack.rb +1 -0
  26. data/lib/lalala/uploaders/file.rb +19 -0
  27. data/lib/lalala/uploaders/image.rb +5 -17
  28. data/lib/lalala/uploaders.rb +1 -0
  29. data/lib/lalala/utils/{intall_template.rb → install_template.rb} +0 -0
  30. data/lib/lalala/version.rb +1 -1
  31. data/lib/lalala.rb +1 -0
  32. data/lib/tasks/lalala_tasks.rake +12 -4
  33. data/test/dummy/app/uploaders/file_uploader.rb +2 -0
  34. data/test/dummy/app/uploaders/image_uploader.rb +2 -0
  35. metadata +19 -22
  36. data/app/assets/images/.DS_Store +0 -0
  37. data/app/assets/images/lalala/jquery-ui/animated-overlay.gif +0 -0
  38. data/app/assets/images/lalala/jquery-ui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  39. data/app/assets/images/lalala/jquery-ui/ui-bg_flat_75_ffffff_40x100.png +0 -0
  40. data/app/assets/images/lalala/jquery-ui/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  41. data/app/assets/images/lalala/jquery-ui/ui-bg_glass_65_ffffff_1x400.png +0 -0
  42. data/app/assets/images/lalala/jquery-ui/ui-bg_glass_75_dadada_1x400.png +0 -0
  43. data/app/assets/images/lalala/jquery-ui/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  44. data/app/assets/images/lalala/jquery-ui/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  45. data/app/assets/images/lalala/jquery-ui/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  46. data/app/assets/images/lalala/jquery-ui/ui-icons_222222_256x240.png +0 -0
  47. data/app/assets/images/lalala/jquery-ui/ui-icons_2e83ff_256x240.png +0 -0
  48. data/app/assets/images/lalala/jquery-ui/ui-icons_454545_256x240.png +0 -0
  49. data/app/assets/images/lalala/jquery-ui/ui-icons_888888_256x240.png +0 -0
  50. data/app/assets/images/lalala/jquery-ui/ui-icons_cd0a0a_256x240.png +0 -0
  51. data/app/assets/images/lalala/users/.DS_Store +0 -0
  52. data/app/assets/javascripts/.DS_Store +0 -0
  53. data/app/assets/stylesheets/.DS_Store +0 -0
  54. data/app/assets/stylesheets/lalala/lib/.DS_Store +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b171c22c043ef118204cdd7464e4dfea865e2b63
4
- data.tar.gz: 7945db4cb93ef5fba5fc7ebce23e2c48a2813445
3
+ metadata.gz: 9fe4870ded2cb186ece61a08491d8b046372cffd
4
+ data.tar.gz: 913c9d5ac334a19502db455822f510fc68ba262f
5
5
  SHA512:
6
- metadata.gz: 2565e8749477a034ea8f823f8394570154f99ca8d780d533ba20cf944c9e995932460452f4ff58c9b0d6c9d5de455bd0d0dac27b2b3ef284a5d8bd2b188ff85f
7
- data.tar.gz: 15572346f387cb324bb08812ef21fca0d4a197d28c9a17aef78dd854a2be352a15b2e7520535ac3017de08adbeb6564f50483d94e6d5e7a60103d29ef7109dc6
6
+ metadata.gz: d64647316d7f1866f3ce130846ddec5c61ae26c639cad037b7b6ebab2d3eeb10a96db44c15583e3c377598394d8e990b70e0cbceb1e6efec16db522450ce9438
7
+ data.tar.gz: 827eb682a5061fb19bc6bb53f49f880eb051715883f7470cd5ef0c80ad0c499d0bf48d1f10f3e305c0a607a26f41a33cafb44c9318151f9451e393cc0a147c82
@@ -15,19 +15,30 @@ Grid = (function() {
15
15
 
16
16
 
17
17
  function G(grid_element) {
18
+ this.selected_images = [];
19
+
18
20
  this.transform_html(grid_element);
19
21
  this.bind_mouse_events();
22
+ this.setup_mouse_selection();
20
23
  }
21
24
 
22
25
 
23
26
  G.prototype.transform_html = function(grid_element) {
24
- var fragment, el, el_images, el_input, $grid;
27
+ var fragment, el, el_images, el_input, data_attr, $grid, $original_list;
28
+
29
+ // elements
30
+ $grid = $(grid_element);
31
+ $original_list = $grid.children("ul:first-child");
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(",") : [];
25
37
 
26
38
  // document fragment for the images
27
39
  fragment = document.createDocumentFragment();
28
40
 
29
41
  // transform images html
30
- $grid = $(grid_element);
31
42
  $grid.find("li").not(":last-child").each(function() {
32
43
  var grid_piece = document.createElement("li");
33
44
  grid_piece.innerHTML = this.innerHTML.replace("<a", "<a class=\"image\"");
@@ -40,22 +51,47 @@ Grid = (function() {
40
51
  // create new container elements
41
52
  el = document.createElement("div");
42
53
  el.className = "mod-grid";
54
+
43
55
  el_images = document.createElement("ul");
44
56
  el_images.className = "images";
45
57
  el_images.appendChild(fragment);
46
- el_input = document.createElement("div");
47
- el_input.className = "input-fields";
48
- el_input.innerHTML = $grid.find("li:last-child").html();
58
+
59
+ el_actions = document.createElement("div");
60
+ el_actions.className = "actions";
61
+ el_actions.innerHTML = "" +
62
+ $grid.find("li:last-child").html() +
63
+ '<a class="button" rel="choose-files">Choose files</a>' +
64
+ '<div class="files-description"></div>' +
65
+ '<a class="button unavailable" rel="edit">Edit selected</a>' +
66
+ '<a class="button unavailable" rel="destroy">destroy selected</a>';
49
67
 
50
68
  // merge
69
+ el.appendChild(el_actions);
51
70
  el.appendChild(el_images);
52
- el.appendChild(el_input);
53
71
 
54
72
  // replace original with new
55
- $grid.children("ul:first-child").replaceWith(el);
73
+ $original_list.replaceWith(el);
56
74
 
57
75
  // bind to instance
58
76
  this.$el = $(el);
77
+
78
+ // other layout stuff
79
+ this.$el.closest(".inputs").addClass("next");
80
+ };
81
+
82
+
83
+ G.prototype.check_edit_and_destroy_buttons = function() {
84
+ var grid = this;
85
+
86
+ this.$el.children(".actions").find('[rel="edit"], [rel="destroy"]').each(function() {
87
+ var $btn = $(this);
88
+
89
+ if (grid.selected_images.length === 0) {
90
+ $btn.addClass("unavailable");
91
+ } else {
92
+ $btn.removeClass("unavailable");
93
+ }
94
+ });
59
95
  };
60
96
 
61
97
 
@@ -68,7 +104,14 @@ Grid = (function() {
68
104
  .on("mouseleave", "li label", this.row_label_mouseleave)
69
105
  .on("mouseenter", "li label", this.row_label_mouseenter)
70
106
  .on("mouseenter", "li .image", this.row_image_mouseenter)
71
- .on("click", "li .overlay", __bind(this.row_overlay_click, this));
107
+ .on("click", "li a", function(e) { e.preventDefault(); })
108
+ .on("click", "li .attributes .close-button", this.close_button_click);
109
+
110
+ this.$el.children(".actions")
111
+ .children("a[rel=\"choose-files\"]").on("click", this.choose_files_button_click).end()
112
+ .children("input[type=\"file\"]").on("change", this.file_input_change).trigger("change").end()
113
+ .children("a[rel=\"edit\"]").on("click", __bind(this.edit_or_destroy_selected_button_click, this)).end()
114
+ .children("a[rel=\"destroy\"]").on("click", __bind(this.edit_or_destroy_selected_button_click, this));
72
115
  };
73
116
 
74
117
  G.prototype.row_mouseleave = function(e) {
@@ -84,18 +127,108 @@ Grid = (function() {
84
127
  };
85
128
 
86
129
  G.prototype.row_image_mouseenter = function(e) {
87
- $(this).parent().addClass("properties");
130
+ var $p = $(this).parent();
131
+ if ($p.hasClass("edit-block")) return;
132
+ $p.addClass("properties");
133
+ };
134
+
135
+ G.prototype.choose_files_button_click = function(e) {
136
+ $(this).parent().children("input[type=\"file\"]").trigger("click");
137
+ };
138
+
139
+ G.prototype.file_input_change = function(e) {
140
+ var val = this.files || $(this).val();
141
+ var $fd = $(this).parent().children(".files-description");
142
+
143
+ if (typeof val === "object") {
144
+ val = val.length;
145
+ $fd[0].innerHTML = val + " file" + (val === 1 ? "" : "s") + " chosen";
146
+ $fd.show();
147
+ }
148
+ };
149
+
150
+ G.prototype.edit_or_destroy_selected_button_click = function(e) {
151
+ var i = 0, j = this.selected_images.length,
152
+ $e = $(e.currentTarget), action = $e.attr("rel");
153
+
154
+ if ($e.hasClass("unavailable")) return;
155
+
156
+ for (; i<j; ++i) {
157
+ var id = this.selected_images[i];
158
+ var $row = $("#" + id).parent();
159
+ $row.removeClass("selected");
160
+ this["set_to_" + action]($row[0]);
161
+ }
162
+
163
+ this.selected_images.length = 0;
164
+ this.check_edit_and_destroy_buttons();
88
165
  };
89
166
 
90
- G.prototype.row_overlay_click = function(e) {
91
- e.preventDefault();
167
+ G.prototype.close_button_click = function(e) {
168
+ $(this).closest("li").removeClass("edit-block");
169
+ };
170
+
171
+
92
172
 
93
- // $(this).parent().toggleClass("selected");
94
- this.toggle_destroy( $(e.currentTarget).parent()[0] );
173
+ //
174
+ // Mouse selection
175
+ //
176
+ G.prototype.setup_mouse_selection = function() {
177
+ var grid = this;
178
+
179
+ this.$el.selectable({
180
+ filter: "li",
181
+ cancel: ".actions,.button,input,textarea,button",
182
+ selecting: function(e, ui) {
183
+ $row = $(ui.selecting);
184
+ if (!$row.hasClass("will-destroy") && !$row.hasClass("edit-block")) {
185
+ $row.addClass("selected");
186
+ }
187
+ },
188
+ unselecting: function(e, ui) {
189
+ $(ui.unselecting).removeClass("selected");
190
+ },
191
+ stop: function(e, ui) {
192
+ var new_selected_images = [];
193
+ grid.$el.find(".images > li").each(function() {
194
+ var $t = $(this), id;
195
+ if ($t.hasClass("selected")) {
196
+ id = $t.children('input[type="hidden"]:first').attr("id");
197
+ new_selected_images.push(id + "");
198
+ id = null;
199
+ }
200
+ });
201
+ grid.selected_images = new_selected_images;
202
+ grid.check_edit_and_destroy_buttons();
203
+ }
204
+ });
95
205
  };
96
206
 
97
207
 
98
208
 
209
+ //
210
+ // Edit
211
+ //
212
+ G.prototype.toggle_edit = function(row) {
213
+ if ($(row).hasClass("edit-block")) {
214
+ this.set_to_not_edit(row);
215
+ } else {
216
+ this.set_to_edit(row);
217
+ }
218
+ };
219
+
220
+
221
+ G.prototype.set_to_edit = function(row) {
222
+ $(row).addClass("edit-block");
223
+ };
224
+
225
+
226
+ G.prototype.set_to_not_edit = function(row) {
227
+ $(row).removeClass("edit-block");
228
+ }
229
+
230
+
231
+
99
232
  //
100
233
  // Destroy
101
234
  //
@@ -9,6 +9,7 @@ $red: rgb(225,70,62);
9
9
  $button_green: rgb(162,218,137);
10
10
  $button_blue: rgb(159,220,248);
11
11
  $button_red: rgb(245,92,92);
12
+ $button_yellow: $yellow;
12
13
 
13
14
 
14
15
  // fonts
@@ -12,7 +12,7 @@
12
12
  $padding_btm: 10px;
13
13
 
14
14
  @include border-radius(4px);
15
- @include single-text-shadow(rgba(0,0,0, .25), 1px, 1px, 0);
15
+ @include single-text-shadow(rgba(black, .25), 1px, 1px, 0);
16
16
  @include transition(background-color 300ms);
17
17
  @include user-select(none);
18
18
 
@@ -31,7 +31,7 @@
31
31
  text-transform: uppercase;
32
32
 
33
33
  &:active {
34
- @include single-text-shadow(rgba(0,0,0, 0.1), 0, 0, 0);
34
+ @include single-text-shadow(rgba(black, 0.1), 0, 0, 0);
35
35
  color: white;
36
36
  text-decoration: none;
37
37
  padding-bottom: $padding_btm - 1;
@@ -39,7 +39,7 @@
39
39
  }
40
40
 
41
41
  &.disabled {
42
- @include single-text-shadow(rgba(0,0,0, 0.1), 0, 0, 0);
42
+ @include single-text-shadow(rgba(black, 0.1), 0, 0, 0);
43
43
  color: white;
44
44
  text-decoration: none;
45
45
  padding-bottom: $padding_btm - 1;
@@ -7,6 +7,9 @@
7
7
 
8
8
  */
9
9
 
10
+ $label_width: 20%;
11
+ $input_width: 80%;
12
+
10
13
  form {
11
14
  margin: 0 0 1em 0;
12
15
  }
@@ -25,6 +28,11 @@ form > fieldset > legend {
25
28
  margin: 0 0 1em 0;
26
29
  }
27
30
 
31
+ form > fieldset.next {
32
+ & > legend { float: left; width: $label_width; }
33
+ & > ol { float: right; width: $input_width; }
34
+ }
35
+
28
36
  select {
29
37
  @include appearance(none);
30
38
  }
@@ -114,8 +122,6 @@ select:focus {
114
122
 
115
123
  // input line
116
124
  .input {
117
- $label_width: 20%;
118
- $input_width: 80%;
119
125
  position: relative;
120
126
 
121
127
  .label {
@@ -194,6 +200,25 @@ select:focus {
194
200
  clear: both;
195
201
  }
196
202
 
203
+ // single file
204
+ .input.single_file .file-description {
205
+ font-size: 12px;
206
+ margin-left: $label_width;
207
+ margin-top: 7px;
208
+ width: $input_width;
209
+
210
+ img {
211
+ display: inline-block;
212
+ }
213
+
214
+ span {
215
+ display: inline-block;
216
+ font-size: 13px;
217
+ margin-left: 8px;
218
+ vertical-align: top;
219
+ }
220
+ }
221
+
197
222
 
198
223
 
199
224
  /*