lalala 4.0.0.dev.50 → 4.0.0.dev.56
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/lalala/modules/grid.module.js +137 -0
- data/app/assets/javascripts/lalala/modules/init.module.js +2 -0
- data/app/assets/stylesheets/lalala/_base.css.scss +1 -0
- data/app/assets/stylesheets/lalala/base/_variables.css.scss +9 -9
- data/app/assets/stylesheets/lalala/modules/_grids.css.scss +12 -6
- data/lib/formtastic/inputs/grid_input.rb +31 -0
- data/lib/lalala/uploaders/image.rb +17 -0
- data/lib/lalala/uploaders.rb +5 -0
- data/lib/lalala/version.rb +1 -1
- data/lib/lalala.rb +1 -0
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f367f7a3bcd2371400cc57d75b9337e898f265a5
|
4
|
+
data.tar.gz: e97f450415b1b69cb47ee903bb77440ba7c05886
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6a812f89f955058a5d50db7fd2a535519e277c670fe32d5f460c8b32b4b05650fc19fb691e702754bfc339524acb811dba7538b4032079610fa30f9c7b15664
|
7
|
+
data.tar.gz: f16f2434a2d803444150b7f609cb210ca1309e89ea28b8d3798dcb5ff341d1593b66cf44fed7891e3495995fbd260caddb77ac94fbc371d369cd6409e42b84f3
|
@@ -0,0 +1,137 @@
|
|
1
|
+
var Grid;
|
2
|
+
|
3
|
+
|
4
|
+
exports.init = function() {
|
5
|
+
var instances = [];
|
6
|
+
this.$el = $(".grid");
|
7
|
+
this.$el.each(function() { instances.push(new Grid(this)); });
|
8
|
+
};
|
9
|
+
|
10
|
+
|
11
|
+
Grid = (function() {
|
12
|
+
var __bind = function(fn, me) {
|
13
|
+
return function() { return fn.apply(me, arguments); };
|
14
|
+
};
|
15
|
+
|
16
|
+
|
17
|
+
function G(grid_element) {
|
18
|
+
this.transform_html(grid_element);
|
19
|
+
this.bind_mouse_events();
|
20
|
+
}
|
21
|
+
|
22
|
+
|
23
|
+
G.prototype.transform_html = function(grid_element) {
|
24
|
+
var fragment, el, el_images, el_input, $grid;
|
25
|
+
|
26
|
+
// document fragment for the images
|
27
|
+
fragment = document.createDocumentFragment();
|
28
|
+
|
29
|
+
// transform images html
|
30
|
+
$grid = $(grid_element);
|
31
|
+
$grid.find("li").not(":last-child").each(function() {
|
32
|
+
var grid_piece = document.createElement("li");
|
33
|
+
grid_piece.innerHTML = this.innerHTML.replace("<a", "<a class=\"image\"");
|
34
|
+
var overlay = document.createElement("div");
|
35
|
+
overlay.className = "overlay";
|
36
|
+
grid_piece.appendChild(overlay);
|
37
|
+
fragment.appendChild(grid_piece);
|
38
|
+
});
|
39
|
+
|
40
|
+
// create new container elements
|
41
|
+
el = document.createElement("div");
|
42
|
+
el.className = "mod-grid";
|
43
|
+
el_images = document.createElement("ul");
|
44
|
+
el_images.className = "images";
|
45
|
+
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();
|
49
|
+
|
50
|
+
// merge
|
51
|
+
el.appendChild(el_images);
|
52
|
+
el.appendChild(el_input);
|
53
|
+
|
54
|
+
// replace original with new
|
55
|
+
$grid.children("ul:first-child").replaceWith(el);
|
56
|
+
|
57
|
+
// bind to instance
|
58
|
+
this.$el = $(el);
|
59
|
+
};
|
60
|
+
|
61
|
+
|
62
|
+
//
|
63
|
+
// Events
|
64
|
+
//
|
65
|
+
G.prototype.bind_mouse_events = function() {
|
66
|
+
this.$el.children(".images")
|
67
|
+
.on("mouseleave", "li", this.row_mouseleave)
|
68
|
+
.on("mouseleave", "li label", this.row_label_mouseleave)
|
69
|
+
.on("mouseenter", "li label", this.row_label_mouseenter)
|
70
|
+
.on("mouseenter", "li .image", this.row_image_mouseenter)
|
71
|
+
.on("click", "li .overlay", __bind(this.row_overlay_click, this));
|
72
|
+
};
|
73
|
+
|
74
|
+
G.prototype.row_mouseleave = function(e) {
|
75
|
+
$(this).removeClass("properties");
|
76
|
+
};
|
77
|
+
|
78
|
+
G.prototype.row_label_mouseenter = function(e) {
|
79
|
+
$(this).parent().addClass("move");
|
80
|
+
};
|
81
|
+
|
82
|
+
G.prototype.row_label_mouseleave = function(e) {
|
83
|
+
$(this).parent().addClass("properties").removeClass("move");
|
84
|
+
};
|
85
|
+
|
86
|
+
G.prototype.row_image_mouseenter = function(e) {
|
87
|
+
$(this).parent().addClass("properties");
|
88
|
+
};
|
89
|
+
|
90
|
+
G.prototype.row_overlay_click = function(e) {
|
91
|
+
// $(this).parent().toggleClass("selected");
|
92
|
+
this.toggle_destroy( $(e.currentTarget).parent()[0] );
|
93
|
+
};
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
//
|
98
|
+
// Destroy
|
99
|
+
//
|
100
|
+
G.prototype.toggle_destroy = function(row) {
|
101
|
+
if ($(row).find('input[name$="[_destroy]"]').length) {
|
102
|
+
this.set_to_not_destroy(row);
|
103
|
+
} else {
|
104
|
+
this.set_to_destroy(row);
|
105
|
+
}
|
106
|
+
};
|
107
|
+
|
108
|
+
|
109
|
+
G.prototype.set_to_destroy = function(row) {
|
110
|
+
var $row = $(row);
|
111
|
+
var input_id_name = $row.find('input[name$="[id]"]')[0].name;
|
112
|
+
var input_destroy = document.createElement("input");
|
113
|
+
|
114
|
+
$(input_destroy).attr({
|
115
|
+
name: input_id_name.replace("[id]", "[_destroy]"),
|
116
|
+
type: "hidden",
|
117
|
+
value: "1"
|
118
|
+
});
|
119
|
+
|
120
|
+
$row.append(input_destroy);
|
121
|
+
$row.addClass("will-destroy");
|
122
|
+
};
|
123
|
+
|
124
|
+
|
125
|
+
G.prototype.set_to_not_destroy = function(row) {
|
126
|
+
$(row).find('input[name$="[_destroy]"]').remove();
|
127
|
+
$(row).removeClass("will-destroy");
|
128
|
+
};
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
//
|
133
|
+
// The end
|
134
|
+
//
|
135
|
+
return G;
|
136
|
+
|
137
|
+
})();
|
@@ -1,12 +1,14 @@
|
|
1
1
|
var console = require('browser/console'),
|
2
2
|
calendar = require('lalala/modules/calendar'),
|
3
3
|
editor = require('lalala/modules/editor'),
|
4
|
+
grid = require('lalala/modules/grid'),
|
4
5
|
locale_chooser = require("lalala/modules/locale_chooser");
|
5
6
|
|
6
7
|
$(function(){
|
7
8
|
locale_chooser.init();
|
8
9
|
editor.init();
|
9
10
|
calendar.init();
|
11
|
+
grid.init();
|
10
12
|
|
11
13
|
$('select').chosen();
|
12
14
|
});
|
@@ -1,14 +1,14 @@
|
|
1
1
|
// colors
|
2
|
-
$white:
|
3
|
-
$black:
|
4
|
-
$gray_lighter:
|
5
|
-
$yellow:
|
6
|
-
$blue:
|
7
|
-
$red:
|
2
|
+
$white: rgb(255,255,255);
|
3
|
+
$black: rgb(35,31,32);
|
4
|
+
$gray_lighter: rgb(211,211,211);
|
5
|
+
$yellow: rgb(255,204,100);
|
6
|
+
$blue: rgb(31,115,255);
|
7
|
+
$red: rgb(225,70,62);
|
8
8
|
|
9
|
-
$button_green:
|
10
|
-
$button_blue:
|
11
|
-
$button_red:
|
9
|
+
$button_green: rgb(162,218,137);
|
10
|
+
$button_blue: rgb(159,220,248);
|
11
|
+
$button_red: rgb(245,92,92);
|
12
12
|
|
13
13
|
|
14
14
|
// fonts
|
@@ -1,12 +1,15 @@
|
|
1
1
|
/*
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
GRIDS
|
4
|
+
--------
|
5
5
|
|
6
6
|
*/
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
|
8
|
+
.mod-grid {
|
9
|
+
.images,
|
10
|
+
.input-fields {
|
11
|
+
overflow: hidden;
|
12
|
+
}
|
10
13
|
|
11
14
|
// [row]
|
12
15
|
li {
|
@@ -21,13 +24,16 @@
|
|
21
24
|
|
22
25
|
&.move,
|
23
26
|
&.properties,
|
24
|
-
&.selected
|
27
|
+
&.selected,
|
28
|
+
&.will-destroy { .overlay { display: block; }}
|
25
29
|
}
|
26
30
|
|
27
31
|
// [row]:types
|
28
32
|
li.move label { cursor: move; }
|
29
33
|
li.properties { cursor: pointer; }
|
30
34
|
li.selected .overlay { background: rgba($yellow, .5); }
|
35
|
+
li.will-destroy .overlay,
|
36
|
+
li.selected.will-destroy .overlay { background: rgba($red, .5); }
|
31
37
|
|
32
38
|
// image + overlay
|
33
39
|
li .image,
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class Formtastic::Inputs::GridInput
|
2
|
+
include Formtastic::Inputs::Base
|
3
|
+
|
4
|
+
def to_html
|
5
|
+
object = builder.object
|
6
|
+
assets = object.send(method)
|
7
|
+
|
8
|
+
ul = template.content_tag :ul do
|
9
|
+
html = template.raw("")
|
10
|
+
|
11
|
+
assets.each do |asset|
|
12
|
+
html += template.content_tag :li do
|
13
|
+
builder.fields_for(method, asset) do |f|
|
14
|
+
thumbnail_html = template.image_tag f.object.asset.thumb.url
|
15
|
+
template.link_to thumbnail_html, f.object.asset.url
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
html += template.content_tag :li do
|
21
|
+
builder.fields_for(method, assets.build) do |f|
|
22
|
+
f.file_field :asset
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
html
|
27
|
+
end
|
28
|
+
|
29
|
+
input_wrapping { ul }
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Lalala::Uploaders::Image < CarrierWave::Uploader::Base
|
2
|
+
|
3
|
+
include CarrierWave::MiniMagick
|
4
|
+
include Sprockets::Helpers::RailsHelper
|
5
|
+
include Sprockets::Helpers::IsolatedHelper
|
6
|
+
|
7
|
+
storage :file
|
8
|
+
|
9
|
+
def store_dir
|
10
|
+
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def extension_white_list
|
14
|
+
%w(jpg jpeg gif png)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
data/lib/lalala/version.rb
CHANGED
data/lib/lalala.rb
CHANGED
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.
|
4
|
+
version: 4.0.0.dev.56
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Menke
|
@@ -1368,6 +1368,7 @@ files:
|
|
1368
1368
|
- app/assets/javascripts/lalala/lib/pikaday.js
|
1369
1369
|
- app/assets/javascripts/lalala/modules/calendar.module.js
|
1370
1370
|
- app/assets/javascripts/lalala/modules/editor.module.js
|
1371
|
+
- app/assets/javascripts/lalala/modules/grid.module.js
|
1371
1372
|
- app/assets/javascripts/lalala/modules/init.module.js
|
1372
1373
|
- app/assets/javascripts/lalala/modules/locale_chooser.module.js
|
1373
1374
|
- app/assets/javascripts/lalala/modules/storage.module.js
|
@@ -1421,6 +1422,7 @@ files:
|
|
1421
1422
|
- lalala-development.gemspec
|
1422
1423
|
- lalala-test.gemspec
|
1423
1424
|
- lalala.gemspec
|
1425
|
+
- lib/formtastic/inputs/grid_input.rb
|
1424
1426
|
- lib/generators/lalala/assets/assets_generator.rb
|
1425
1427
|
- lib/generators/lalala/assets/templates/active_admin.css.scss
|
1426
1428
|
- lib/generators/lalala/assets/templates/active_admin.js
|
@@ -1474,6 +1476,8 @@ files:
|
|
1474
1476
|
- lib/lalala/pages/path_handler.rb
|
1475
1477
|
- lib/lalala/pages/route_mapper.rb
|
1476
1478
|
- lib/lalala/test.rb
|
1479
|
+
- lib/lalala/uploaders.rb
|
1480
|
+
- lib/lalala/uploaders/image.rb
|
1477
1481
|
- lib/lalala/utils/intall_template.rb
|
1478
1482
|
- lib/lalala/vendor.rb
|
1479
1483
|
- lib/lalala/version.rb
|