refinerycms-image-gallery 0.1.0 → 0.1.2
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.
- data/README.md +2 -3
- data/VERSION +1 -1
- data/lib/refinerycms-image-gallery.rb +17 -9
- data/lib/templates/javascripts/coffeescripts/gallery.coffee +134 -6
- data/lib/templates/javascripts/gallery.js +130 -14
- data/lib/templates/stylesheets/gallery.css +32 -1
- data/lib/templates/views/image.html.erb +4 -4
- data/lib/templates/views/images_field.html.erb +4 -3
- data/refinerycms-image-gallery.gemspec +2 -2
- metadata +13 -13
data/README.md
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
Add this line to your applications `Gemfile`
|
|
18
18
|
|
|
19
|
-
gem 'refinerycms-image-gallery'
|
|
19
|
+
gem 'refinerycms-image-gallery', :git => 'git://github.com/ginga/refinerycms-image-gallery.git'
|
|
20
20
|
|
|
21
21
|
Run:
|
|
22
22
|
|
|
@@ -45,5 +45,4 @@
|
|
|
45
45
|
|
|
46
46
|
## TODO
|
|
47
47
|
|
|
48
|
-
*
|
|
49
|
-
* Implement refinery Modules in generator
|
|
48
|
+
* Implement refinery Modules in generator
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1.
|
|
1
|
+
0.1.2
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'refinery'
|
|
2
|
+
|
|
1
3
|
class RefinerycmsImageGalleryGenerator < ::Refinery::Generators::EngineInstaller
|
|
2
4
|
attr_accessor :attributes, :name, :plural_class_name, :plural_name, :file_path
|
|
3
5
|
|
|
@@ -28,6 +30,12 @@ class RefinerycmsImageGalleryGenerator < ::Refinery::Generators::EngineInstaller
|
|
|
28
30
|
@plural_name = @name.pluralize
|
|
29
31
|
@plural_class_name = @name.pluralize.camelize
|
|
30
32
|
|
|
33
|
+
# Check if engine exists
|
|
34
|
+
unless File.directory?("vendor/engines/#{@plural_name}")
|
|
35
|
+
puts "Engine '#{@name}' doesn't exists. Create this engine first."
|
|
36
|
+
exit
|
|
37
|
+
end
|
|
38
|
+
|
|
31
39
|
# Check if migration already exists
|
|
32
40
|
@check_migration = ActiveRecord::Base.connection.table_exists?("#{@plural_name}_images")
|
|
33
41
|
|
|
@@ -57,7 +65,7 @@ class RefinerycmsImageGalleryGenerator < ::Refinery::Generators::EngineInstaller
|
|
|
57
65
|
|
|
58
66
|
def generate_migration
|
|
59
67
|
unless @check_migration
|
|
60
|
-
migration_template 'migration.rb', "db/migrate/create_#{plural_name}_images"
|
|
68
|
+
migration_template 'migration.rb', "db/migrate/create_#{@plural_name}_images"
|
|
61
69
|
run "rake db:migrate"
|
|
62
70
|
end
|
|
63
71
|
end
|
|
@@ -81,7 +89,7 @@ class RefinerycmsImageGalleryGenerator < ::Refinery::Generators::EngineInstaller
|
|
|
81
89
|
######### Override your class admin/_form item if not exists #########
|
|
82
90
|
def override_class_form
|
|
83
91
|
unless File.exists?("app/views/admin/#{@plural_name}/_form.html.erb")
|
|
84
|
-
run "rake refinery:override view=admin/#{plural_name}/_form"
|
|
92
|
+
run "rake refinery:override view=admin/#{@plural_name}/_form"
|
|
85
93
|
end
|
|
86
94
|
end
|
|
87
95
|
|
|
@@ -102,7 +110,7 @@ class RefinerycmsImageGalleryGenerator < ::Refinery::Generators::EngineInstaller
|
|
|
102
110
|
######### Create relationsheep model #########
|
|
103
111
|
def create_model
|
|
104
112
|
unless @check_migration
|
|
105
|
-
template 'models/model.rb', File.join('app/models', "#{plural_name}_image.rb")
|
|
113
|
+
template 'models/model.rb', File.join('app/models', "#{@plural_name}_image.rb")
|
|
106
114
|
end
|
|
107
115
|
end
|
|
108
116
|
|
|
@@ -116,25 +124,25 @@ class RefinerycmsImageGalleryGenerator < ::Refinery::Generators::EngineInstaller
|
|
|
116
124
|
|
|
117
125
|
# Insert into image model
|
|
118
126
|
insert_into_file "app/models/image.rb", :after => "image_accessor :image\n" do
|
|
119
|
-
"\thas_many :#{plural_name}_images\n" +
|
|
120
|
-
"\thas_many :#{plural_name}, :through => :#{plural_name}_images\n"
|
|
127
|
+
"\thas_many :#{@plural_name}_images\n" +
|
|
128
|
+
"\thas_many :#{@plural_name}, :through => :#{@plural_name}_images\n"
|
|
121
129
|
end
|
|
122
130
|
|
|
123
131
|
# Insert into object model
|
|
124
132
|
insert_into_file "app/models/#{@name}.rb", :after => "ActiveRecord::Base\n" do
|
|
125
|
-
"\n\thas_many :#{plural_name}_images\n" +
|
|
126
|
-
"\thas_many :images, :through => :#{plural_name}_images\n" +
|
|
133
|
+
"\n\thas_many :#{@plural_name}_images\n" +
|
|
134
|
+
"\thas_many :images, :through => :#{@plural_name}_images\n" +
|
|
127
135
|
"\n\tdef images_attributes=(data)
|
|
128
136
|
#{plural_class_name}Image.delete_all(:#{@name}_id => self.id)
|
|
129
137
|
data.each_with_index do | ( k, image_data ), i |
|
|
130
138
|
if image_data['id'].present?
|
|
131
|
-
image_gallery = self.#{plural_name}_images.new(
|
|
139
|
+
image_gallery = self.#{@plural_name}_images.new(
|
|
132
140
|
:image_id => image_data['id'].to_i,
|
|
133
141
|
:position => i,
|
|
134
142
|
:chunk => image_data['chunk'],
|
|
135
143
|
#{@columns.join(', ')}
|
|
136
144
|
)
|
|
137
|
-
self.#{plural_name}_images << image_gallery
|
|
145
|
+
self.#{@plural_name}_images << image_gallery
|
|
138
146
|
end
|
|
139
147
|
self.touch
|
|
140
148
|
end
|
|
@@ -54,6 +54,12 @@ jQuery ->
|
|
|
54
54
|
chunk = $(this).find('input').first().val()
|
|
55
55
|
$("#page_images_#{chunk}").sortable()
|
|
56
56
|
|
|
57
|
+
# Call function to change days of month
|
|
58
|
+
$("#month, #year").live 'change', ->
|
|
59
|
+
year = $("#year").find(":selected").val()
|
|
60
|
+
month = $("#month").find(":selected").val()
|
|
61
|
+
days_in_month year, month
|
|
62
|
+
|
|
57
63
|
# Dialog dynamic items
|
|
58
64
|
open_edit_image = (items, image_id) ->
|
|
59
65
|
# Clone dynamic fields for modal
|
|
@@ -62,9 +68,14 @@ open_edit_image = (items, image_id) ->
|
|
|
62
68
|
|
|
63
69
|
# For each input create a textarea for edit
|
|
64
70
|
input.each (i, inp) ->
|
|
65
|
-
title = $(inp).attr('
|
|
71
|
+
title = $(inp).attr('data-name')
|
|
72
|
+
type = $(inp).attr('data-type')
|
|
66
73
|
value = $(inp).val()
|
|
67
|
-
|
|
74
|
+
|
|
75
|
+
# Call function to create dynamic fields type
|
|
76
|
+
field = create_fields(type, value)
|
|
77
|
+
|
|
78
|
+
$(inp).after $("<div id='image#{image_id}_title_#{title}'><span class= 'image-fields-edit'>#{title}</span>#{field}</div>")
|
|
68
79
|
|
|
69
80
|
# Input a submit button
|
|
70
81
|
input.after($("<div class='form-actions'><div class='form-actions-left'><a class='button' id='insert_fields'>Insert<a></div></div>"))
|
|
@@ -75,17 +86,134 @@ open_edit_image = (items, image_id) ->
|
|
|
75
86
|
modal: true,
|
|
76
87
|
resizable: false,
|
|
77
88
|
autoOpen: true,
|
|
78
|
-
|
|
89
|
+
width: 800,
|
|
90
|
+
height: 500
|
|
79
91
|
})
|
|
80
92
|
|
|
81
93
|
# Insert click function
|
|
82
94
|
$('a#insert_fields').click ->
|
|
83
95
|
# For each input get the textarea value and change input value
|
|
84
96
|
input.each (i, inp) ->
|
|
85
|
-
title = $(inp).attr('
|
|
86
|
-
|
|
87
|
-
|
|
97
|
+
title = $(inp).attr('data-name')
|
|
98
|
+
type = $(inp).attr('data-type')
|
|
99
|
+
if type == "string" || type == "integer" || type == "float" || type == "decimal"
|
|
100
|
+
field = "input"
|
|
101
|
+
else if type == "boolean"
|
|
102
|
+
field = "input-checkbox"
|
|
103
|
+
else if type == "text"
|
|
104
|
+
field = "textarea"
|
|
105
|
+
else if type == "date" || type == "datetime"
|
|
106
|
+
field = "select"
|
|
107
|
+
|
|
108
|
+
input_val = $(items).find("input[data-name='#{title}']")
|
|
109
|
+
|
|
110
|
+
# Make data for select
|
|
111
|
+
if field == "select"
|
|
112
|
+
date_value = []
|
|
113
|
+
|
|
114
|
+
$("div#image#{image_id}_title_#{title}").find("#{field}").each ->
|
|
115
|
+
date_value.push $(this).val()
|
|
116
|
+
|
|
117
|
+
date = "#{date_value[0]}-#{date_value[1]}-#{date_value[2]}"
|
|
118
|
+
hour = date_value[3]
|
|
119
|
+
minute = date_value[4]
|
|
120
|
+
if hour
|
|
121
|
+
date = "#{date} #{hour}:#{minute}"
|
|
122
|
+
|
|
123
|
+
input_val.val(date)
|
|
124
|
+
# Check if checkbox is selected
|
|
125
|
+
else if field == "input-checkbox"
|
|
126
|
+
field = field.split("-")
|
|
127
|
+
if $("div#image#{image_id}_title_#{title}").find("#{field[0]}").is(":checked")
|
|
128
|
+
input_val.val("true")
|
|
129
|
+
else
|
|
130
|
+
input_val.val("false")
|
|
131
|
+
# Input value for input text fields
|
|
132
|
+
else
|
|
133
|
+
input_val.val $("div#image#{image_id}_title_#{title}").find("#{field}").val()
|
|
134
|
+
|
|
88
135
|
fields.dialog('close')
|
|
89
136
|
|
|
90
137
|
# Remove cloned div after close
|
|
91
138
|
fields.remove()
|
|
139
|
+
|
|
140
|
+
# Create Fields for each type of element
|
|
141
|
+
create_fields = (type, value) ->
|
|
142
|
+
switch type
|
|
143
|
+
when "string", "integer", "float", "decimal"
|
|
144
|
+
field = "<input class='image-edit' type='text' value='#{value}' />"
|
|
145
|
+
when "boolean"
|
|
146
|
+
checked = ''
|
|
147
|
+
if value == "true"
|
|
148
|
+
checked = "checked"
|
|
149
|
+
field = "<input class='image-edit-checkbox' type='checkbox' #{checked} />"
|
|
150
|
+
when "text"
|
|
151
|
+
field = "<textarea class='image-edit'>#{value}</textarea>"
|
|
152
|
+
when "date"
|
|
153
|
+
if value
|
|
154
|
+
value = value.split("-")
|
|
155
|
+
field = "<select id='year'><option></option>#{create_date(2010, 2030, 'year', value[0])}</select>
|
|
156
|
+
<select id='month'><option></option>#{create_date(1, 12, 'month', value[1])}</select>
|
|
157
|
+
<select id='day'><option></option>#{create_date(1,'', 'day', value)}</select>"
|
|
158
|
+
else
|
|
159
|
+
field = "<select id='year'><option></option>#{create_date(2010, 2030,'year')}</select>
|
|
160
|
+
<select id='month'><option></option>#{create_date(1, 12,'month')}</select>
|
|
161
|
+
<select id='day'><option></option>#{create_date(1,'','day')}</select>"
|
|
162
|
+
when "datetime"
|
|
163
|
+
if value
|
|
164
|
+
value = value.split("-")
|
|
165
|
+
field = "<select id='year'><option></option>#{create_date(2010, 2030, 'year', value[0])}</select>
|
|
166
|
+
<select id='month'><option></option>#{create_date(1, 12, 'month', value[1])}</select>
|
|
167
|
+
<select id='day'><option></option>#{create_date(1,'', 'day', value)}</select>
|
|
168
|
+
<select id='hour'><option></option>#{create_date(00, 23, 'hour', value.join("-"))}</select>
|
|
169
|
+
<select id='minute'><option></option>#{create_date(00,59, 'minute', value.join("-"))}</select>"
|
|
170
|
+
else
|
|
171
|
+
field = "<select name='date[0]' id='year'><option></option>#{create_date(2010, 2030,'year')}</select>
|
|
172
|
+
<select name='date[1]' id='month'><option></option>#{create_date(1, 12,'month')}</select>
|
|
173
|
+
<select name='date[2]' id='day'><option></option>#{create_date(1,'','day')}</select>
|
|
174
|
+
<select name='date[3]' id='hour'><option></option>#{create_date(00, 23, 'hour')}</select>
|
|
175
|
+
<select name='date[4]' id='minute'><option></option>#{create_date(00, 59, 'minute')}</select>"
|
|
176
|
+
|
|
177
|
+
# Create options for date select
|
|
178
|
+
create_date = (init, end, obj_id, value) ->
|
|
179
|
+
# Set days in month
|
|
180
|
+
if obj_id == 'day' && !value
|
|
181
|
+
year = new Date().getFullYear()
|
|
182
|
+
month = new Date().getMonth()
|
|
183
|
+
end = new Date( year, month + 1, 0 ).getDate()
|
|
184
|
+
else if obj_id == 'day' && value
|
|
185
|
+
year = new Date(value).getFullYear()
|
|
186
|
+
month = (new Date(value).getMonth() + 1)
|
|
187
|
+
day = new Date(value).getDate()
|
|
188
|
+
end = new Date( year, month, 0 ).getDate();
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
for init in [(init)..(end)]
|
|
192
|
+
selected = ''
|
|
193
|
+
|
|
194
|
+
if value
|
|
195
|
+
# Selected Year
|
|
196
|
+
if obj_id == 'year' && init == new Date(value,1).getFullYear()
|
|
197
|
+
selected = 'selected'
|
|
198
|
+
# Selected Month
|
|
199
|
+
if obj_id == 'month' && init == new Date(0,value).getMonth()
|
|
200
|
+
selected = 'selected'
|
|
201
|
+
# Selected Day
|
|
202
|
+
if obj_id == 'day' && init == new Date(year, month, day).getDate()
|
|
203
|
+
selected = 'selected'
|
|
204
|
+
# Selected Hour
|
|
205
|
+
if obj_id == 'hour' && init == new Date(value).getUTCHours()
|
|
206
|
+
selected = 'selected'
|
|
207
|
+
# Selected Minute
|
|
208
|
+
if obj_id == 'minute' && init == new Date(value).getUTCMinutes()
|
|
209
|
+
selected = 'selected'
|
|
210
|
+
|
|
211
|
+
"<option value='#{init}' #{selected} >#{init}</option>"
|
|
212
|
+
|
|
213
|
+
# Get max days in month
|
|
214
|
+
days_in_month = (year, month) ->
|
|
215
|
+
$("#day").empty()
|
|
216
|
+
init = 1
|
|
217
|
+
end = new Date(year,month,0).getDate()
|
|
218
|
+
for init in [(init)..(end)]
|
|
219
|
+
$("#day").append "<option value='#{init}'>#{init}</option>"
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* /Users/vinicius/workspace/gem-gallery-image/app/coffeescripts/gallery.coffee
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
var image_added, open_edit_image;
|
|
1
|
+
var create_date, create_fields, days_in_month, image_added, open_edit_image;
|
|
6
2
|
image_added = function(image, chunk) {
|
|
7
3
|
var dynamic_items, id, image_id, img, new_list, target;
|
|
8
4
|
image_id = $(image).attr('id').replace('image_', '');
|
|
@@ -45,21 +41,29 @@ jQuery(function() {
|
|
|
45
41
|
return false;
|
|
46
42
|
}
|
|
47
43
|
});
|
|
48
|
-
|
|
44
|
+
$('li.image_field').live('hover', function() {
|
|
49
45
|
var chunk;
|
|
50
46
|
chunk = $(this).find('input').first().val();
|
|
51
47
|
return $("#page_images_" + chunk).sortable();
|
|
52
48
|
});
|
|
49
|
+
return $("#month, #year").live('change', function() {
|
|
50
|
+
var month, year;
|
|
51
|
+
year = $("#year").find(":selected").val();
|
|
52
|
+
month = $("#month").find(":selected").val();
|
|
53
|
+
return days_in_month(year, month);
|
|
54
|
+
});
|
|
53
55
|
});
|
|
54
56
|
open_edit_image = function(items, image_id) {
|
|
55
57
|
var fields, input;
|
|
56
58
|
fields = $(items).clone();
|
|
57
59
|
input = fields.find('input');
|
|
58
60
|
input.each(function(i, inp) {
|
|
59
|
-
var title, value;
|
|
60
|
-
title = $(inp).attr('
|
|
61
|
+
var field, title, type, value;
|
|
62
|
+
title = $(inp).attr('data-name');
|
|
63
|
+
type = $(inp).attr('data-type');
|
|
61
64
|
value = $(inp).val();
|
|
62
|
-
|
|
65
|
+
field = create_fields(type, value);
|
|
66
|
+
return $(inp).after($("<div id='image" + image_id + "_title_" + title + "'><span class= 'image-fields-edit'>" + title + "</span>" + field + "</div>"));
|
|
63
67
|
});
|
|
64
68
|
input.after($("<div class='form-actions'><div class='form-actions-left'><a class='button' id='insert_fields'>Insert<a></div></div>"));
|
|
65
69
|
fields.dialog({
|
|
@@ -67,16 +71,128 @@ open_edit_image = function(items, image_id) {
|
|
|
67
71
|
modal: true,
|
|
68
72
|
resizable: false,
|
|
69
73
|
autoOpen: true,
|
|
70
|
-
|
|
74
|
+
width: 800,
|
|
75
|
+
height: 500
|
|
71
76
|
});
|
|
72
77
|
return $('a#insert_fields').click(function() {
|
|
73
78
|
input.each(function(i, inp) {
|
|
74
|
-
var input_val, title;
|
|
75
|
-
title = $(inp).attr('
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
var date, date_value, field, hour, input_val, minute, title, type;
|
|
80
|
+
title = $(inp).attr('data-name');
|
|
81
|
+
type = $(inp).attr('data-type');
|
|
82
|
+
if (type === "string" || type === "integer" || type === "float" || type === "decimal") {
|
|
83
|
+
field = "input";
|
|
84
|
+
} else if (type === "boolean") {
|
|
85
|
+
field = "input-checkbox";
|
|
86
|
+
} else if (type === "text") {
|
|
87
|
+
field = "textarea";
|
|
88
|
+
} else if (type === "date" || type === "datetime") {
|
|
89
|
+
field = "select";
|
|
90
|
+
}
|
|
91
|
+
input_val = $(items).find("input[data-name='" + title + "']");
|
|
92
|
+
if (field === "select") {
|
|
93
|
+
date_value = [];
|
|
94
|
+
$("div#image" + image_id + "_title_" + title).find("" + field).each(function() {
|
|
95
|
+
return date_value.push($(this).val());
|
|
96
|
+
});
|
|
97
|
+
date = "" + date_value[0] + "-" + date_value[1] + "-" + date_value[2];
|
|
98
|
+
hour = date_value[3];
|
|
99
|
+
minute = date_value[4];
|
|
100
|
+
if (hour) {
|
|
101
|
+
date = "" + date + " " + hour + ":" + minute;
|
|
102
|
+
}
|
|
103
|
+
input_val.val(date);
|
|
104
|
+
} else if (field === "input-checkbox") {
|
|
105
|
+
field = field.split("-");
|
|
106
|
+
if ($("div#image" + image_id + "_title_" + title).find("" + field[0]).is(":checked")) {
|
|
107
|
+
input_val.val("true");
|
|
108
|
+
} else {
|
|
109
|
+
input_val.val("false");
|
|
110
|
+
}
|
|
111
|
+
} else {
|
|
112
|
+
input_val.val($("div#image" + image_id + "_title_" + title).find("" + field).val());
|
|
113
|
+
}
|
|
78
114
|
return fields.dialog('close');
|
|
79
115
|
});
|
|
80
116
|
return fields.remove();
|
|
81
117
|
});
|
|
118
|
+
};
|
|
119
|
+
create_fields = function(type, value) {
|
|
120
|
+
var checked, field;
|
|
121
|
+
switch (type) {
|
|
122
|
+
case "string":
|
|
123
|
+
case "integer":
|
|
124
|
+
case "float":
|
|
125
|
+
case "decimal":
|
|
126
|
+
return field = "<input class='image-edit' type='text' value='" + value + "' />";
|
|
127
|
+
case "boolean":
|
|
128
|
+
checked = '';
|
|
129
|
+
if (value === "true") {
|
|
130
|
+
checked = "checked";
|
|
131
|
+
}
|
|
132
|
+
return field = "<input class='image-edit-checkbox' type='checkbox' " + checked + " />";
|
|
133
|
+
case "text":
|
|
134
|
+
return field = "<textarea class='image-edit'>" + value + "</textarea>";
|
|
135
|
+
case "date":
|
|
136
|
+
if (value) {
|
|
137
|
+
value = value.split("-");
|
|
138
|
+
return field = "<select id='year'><option></option>" + (create_date(2010, 2030, 'year', value[0])) + "</select> <select id='month'><option></option>" + (create_date(1, 12, 'month', value[1])) + "</select> <select id='day'><option></option>" + (create_date(1, '', 'day', value)) + "</select>";
|
|
139
|
+
} else {
|
|
140
|
+
return field = "<select id='year'><option></option>" + (create_date(2010, 2030, 'year')) + "</select> <select id='month'><option></option>" + (create_date(1, 12, 'month')) + "</select> <select id='day'><option></option>" + (create_date(1, '', 'day')) + "</select>";
|
|
141
|
+
}
|
|
142
|
+
break;
|
|
143
|
+
case "datetime":
|
|
144
|
+
if (value) {
|
|
145
|
+
value = value.split("-");
|
|
146
|
+
return field = "<select id='year'><option></option>" + (create_date(2010, 2030, 'year', value[0])) + "</select> <select id='month'><option></option>" + (create_date(1, 12, 'month', value[1])) + "</select> <select id='day'><option></option>" + (create_date(1, '', 'day', value)) + "</select> <select id='hour'><option></option>" + (create_date(00, 23, 'hour', value.join("-"))) + "</select> <select id='minute'><option></option>" + (create_date(00, 59, 'minute', value.join("-"))) + "</select>";
|
|
147
|
+
} else {
|
|
148
|
+
return field = "<select name='date[0]' id='year'><option></option>" + (create_date(2010, 2030, 'year')) + "</select> <select name='date[1]' id='month'><option></option>" + (create_date(1, 12, 'month')) + "</select> <select name='date[2]' id='day'><option></option>" + (create_date(1, '', 'day')) + "</select> <select name='date[3]' id='hour'><option></option>" + (create_date(00, 23, 'hour')) + "</select> <select name='date[4]' id='minute'><option></option>" + (create_date(00, 59, 'minute')) + "</select>";
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
create_date = function(init, end, obj_id, value) {
|
|
153
|
+
var day, month, selected, year, _ref, _ref2, _results;
|
|
154
|
+
if (obj_id === 'day' && !value) {
|
|
155
|
+
year = new Date().getFullYear();
|
|
156
|
+
month = new Date().getMonth();
|
|
157
|
+
end = new Date(year, month + 1, 0).getDate();
|
|
158
|
+
} else if (obj_id === 'day' && value) {
|
|
159
|
+
year = new Date(value).getFullYear();
|
|
160
|
+
month = new Date(value).getMonth() + 1;
|
|
161
|
+
day = new Date(value).getDate();
|
|
162
|
+
end = new Date(year, month, 0).getDate();
|
|
163
|
+
}
|
|
164
|
+
_results = [];
|
|
165
|
+
for (init = _ref = init, _ref2 = end; _ref <= _ref2 ? init <= _ref2 : init >= _ref2; _ref <= _ref2 ? init++ : init--) {
|
|
166
|
+
selected = '';
|
|
167
|
+
if (value) {
|
|
168
|
+
if (obj_id === 'year' && init === new Date(value, 1).getFullYear()) {
|
|
169
|
+
selected = 'selected';
|
|
170
|
+
}
|
|
171
|
+
if (obj_id === 'month' && init === new Date(0, value).getMonth()) {
|
|
172
|
+
selected = 'selected';
|
|
173
|
+
}
|
|
174
|
+
if (obj_id === 'day' && init === new Date(year, month, day).getDate()) {
|
|
175
|
+
selected = 'selected';
|
|
176
|
+
}
|
|
177
|
+
if (obj_id === 'hour' && init === new Date(value).getUTCHours()) {
|
|
178
|
+
selected = 'selected';
|
|
179
|
+
}
|
|
180
|
+
if (obj_id === 'minute' && init === new Date(value).getUTCMinutes()) {
|
|
181
|
+
selected = 'selected';
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
_results.push("<option value='" + init + "' " + selected + " >" + init + "</option>");
|
|
185
|
+
}
|
|
186
|
+
return _results;
|
|
187
|
+
};
|
|
188
|
+
days_in_month = function(year, month) {
|
|
189
|
+
var end, init, _ref, _ref2, _results;
|
|
190
|
+
$("#day").empty();
|
|
191
|
+
init = 1;
|
|
192
|
+
end = new Date(year, month, 0).getDate();
|
|
193
|
+
_results = [];
|
|
194
|
+
for (init = _ref = init, _ref2 = end; _ref <= _ref2 ? init <= _ref2 : init >= _ref2; _ref <= _ref2 ? init++ : init--) {
|
|
195
|
+
_results.push($("#day").append("<option value='" + init + "'>" + init + "</option>"));
|
|
196
|
+
}
|
|
197
|
+
return _results;
|
|
82
198
|
};
|
|
@@ -28,7 +28,38 @@ div.image_actions img{
|
|
|
28
28
|
cursor: pointer;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
div.dynamic_items{
|
|
32
|
+
overflow:auto;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
div.ui-dialog-content{
|
|
36
|
+
margin-bottom:50px;
|
|
37
|
+
}
|
|
38
|
+
|
|
31
39
|
div.wym_skin_refinery{
|
|
32
|
-
|
|
40
|
+
opacity: 1 !important;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
span.image-fields-edit{
|
|
44
|
+
width: 98%;
|
|
45
|
+
float:left;
|
|
46
|
+
padding: 5px;
|
|
47
|
+
margin: 3px 0 0 0 ;
|
|
48
|
+
text-align: left;
|
|
49
|
+
color: #41403C;
|
|
50
|
+
font-weight: bold;
|
|
51
|
+
font-family: Arial;
|
|
52
|
+
font-size: 13px;
|
|
53
|
+
text-transform: capitalize;
|
|
54
|
+
}
|
|
55
|
+
.image-edit{
|
|
56
|
+
width: 97%;
|
|
57
|
+
margin-left: 3px;
|
|
58
|
+
border: 1px solid #7F9DB9;
|
|
59
|
+
padding: 0.4% 0.5%;
|
|
60
|
+
line-height: 20px;
|
|
33
61
|
}
|
|
34
62
|
|
|
63
|
+
.image-edit-checkbox{
|
|
64
|
+
width: auto;
|
|
65
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<%% random_data = ActiveSupport::SecureRandom.base64(6) %>
|
|
2
2
|
<%%
|
|
3
3
|
# Img Dynamic Items
|
|
4
|
-
item = f.object.<%= @plural_name %>_images.where("position" =>
|
|
4
|
+
item = f.object.<%= @plural_name %>_images.where("position" => position)
|
|
5
5
|
<%- for attribute in attributes -%>
|
|
6
6
|
<%= attribute.name %> = item[0].<%= attribute.name %> unless item[0].nil?
|
|
7
7
|
<%- end -%>
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
<img alt="delete" height="16" src="/images/refinery/icons/delete.png" width="16" class="delete_image" style="float:right;" />
|
|
18
18
|
</div>
|
|
19
19
|
<%%= image_fu image, '135x135#c' %>
|
|
20
|
-
<div id="dynamic_items_<%%= image.id %>"
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
<div id="dynamic_items_<%%= image.id %>" class="dynamic_items">
|
|
21
|
+
<%- for attribute in attributes -%>
|
|
22
|
+
<%%= hidden_field_tag "#{f.object_name}[images_attributes][#{random_data}][<%= attribute.name %>]", <%= attribute.name %>, :"data-name" => '<%= attribute.name %>' , :"data-type" => '<%= attribute.type %>' %>
|
|
23
23
|
<%- end -%>
|
|
24
24
|
</div>
|
|
25
25
|
</li>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<div class='wym_box field images_field'>
|
|
2
2
|
<ul id='page_images_<%%= chunk_name %>' class='clearfix'>
|
|
3
3
|
<%% f.object.images.where("<%= plural_name %>_images.chunk" => chunk_name ).order("position").each_with_index do |image, i| %>
|
|
4
|
-
|
|
4
|
+
<%% position = image.<%= plural_name %>_images[0].position unless image.<%= plural_name %>_images[0].nil? %>
|
|
5
|
+
<%%= render :partial => "image", :object => image, :locals => { :f => f, :chunk_name => chunk_name, :position => position } %>
|
|
5
6
|
<%% end %>
|
|
6
7
|
|
|
7
8
|
<li class='empty_<%= @chunk %> image_field empty'>
|
|
@@ -14,9 +15,9 @@
|
|
|
14
15
|
</div>
|
|
15
16
|
<%%= hidden_field_tag "#{f.object.class.name.underscore}[images_attributes][#{f.object.images.size}][chunk]", chunk_name %>
|
|
16
17
|
<%%= hidden_field_tag "#{f.object.class.name.underscore}[images_attributes][#{f.object.images.size}][id]", "" %>
|
|
17
|
-
<div id="dynamic_items"
|
|
18
|
+
<div id="dynamic_items" class="dynamic_items">
|
|
18
19
|
<%- for attribute in attributes -%>
|
|
19
|
-
<%%= hidden_field_tag "#{f.object.class.name.underscore}[images_attributes][#{f.object.images.size}][<%= attribute.name %>]", "", :
|
|
20
|
+
<%%= hidden_field_tag "#{f.object.class.name.underscore}[images_attributes][#{f.object.images.size}][<%= attribute.name %>]", "", :"data-name" => '<%= attribute.name %>' , :"data-type" => '<%= attribute.type %>' %>
|
|
20
21
|
<%- end -%>
|
|
21
22
|
</div>
|
|
22
23
|
</li>
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = "refinerycms-image-gallery"
|
|
8
|
-
s.version = "0.1.
|
|
8
|
+
s.version = "0.1.2"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Vinicius Zago"]
|
|
12
|
-
s.date = "
|
|
12
|
+
s.date = "2012-01-06"
|
|
13
13
|
s.description = "Image Gallery for RefineryCMS that supports another fields like author, subtitles etc."
|
|
14
14
|
s.email = "mvinicius.zago@gmail.com"
|
|
15
15
|
s.executables = ["refinerycms_image_gallery"]
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: refinerycms-image-gallery
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,11 +9,11 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2012-01-06 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: shoulda
|
|
16
|
-
requirement: &
|
|
16
|
+
requirement: &2158990960 !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ! '>='
|
|
@@ -21,10 +21,10 @@ dependencies:
|
|
|
21
21
|
version: '0'
|
|
22
22
|
type: :development
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements: *
|
|
24
|
+
version_requirements: *2158990960
|
|
25
25
|
- !ruby/object:Gem::Dependency
|
|
26
26
|
name: bundler
|
|
27
|
-
requirement: &
|
|
27
|
+
requirement: &2158990360 !ruby/object:Gem::Requirement
|
|
28
28
|
none: false
|
|
29
29
|
requirements:
|
|
30
30
|
- - ~>
|
|
@@ -32,10 +32,10 @@ dependencies:
|
|
|
32
32
|
version: 1.0.0
|
|
33
33
|
type: :development
|
|
34
34
|
prerelease: false
|
|
35
|
-
version_requirements: *
|
|
35
|
+
version_requirements: *2158990360
|
|
36
36
|
- !ruby/object:Gem::Dependency
|
|
37
37
|
name: jeweler
|
|
38
|
-
requirement: &
|
|
38
|
+
requirement: &2158989720 !ruby/object:Gem::Requirement
|
|
39
39
|
none: false
|
|
40
40
|
requirements:
|
|
41
41
|
- - ~>
|
|
@@ -43,10 +43,10 @@ dependencies:
|
|
|
43
43
|
version: 1.6.4
|
|
44
44
|
type: :development
|
|
45
45
|
prerelease: false
|
|
46
|
-
version_requirements: *
|
|
46
|
+
version_requirements: *2158989720
|
|
47
47
|
- !ruby/object:Gem::Dependency
|
|
48
48
|
name: rcov
|
|
49
|
-
requirement: &
|
|
49
|
+
requirement: &2158989220 !ruby/object:Gem::Requirement
|
|
50
50
|
none: false
|
|
51
51
|
requirements:
|
|
52
52
|
- - ! '>='
|
|
@@ -54,10 +54,10 @@ dependencies:
|
|
|
54
54
|
version: '0'
|
|
55
55
|
type: :development
|
|
56
56
|
prerelease: false
|
|
57
|
-
version_requirements: *
|
|
57
|
+
version_requirements: *2158989220
|
|
58
58
|
- !ruby/object:Gem::Dependency
|
|
59
59
|
name: rdoc
|
|
60
|
-
requirement: &
|
|
60
|
+
requirement: &2158988700 !ruby/object:Gem::Requirement
|
|
61
61
|
none: false
|
|
62
62
|
requirements:
|
|
63
63
|
- - ! '>='
|
|
@@ -65,7 +65,7 @@ dependencies:
|
|
|
65
65
|
version: '0'
|
|
66
66
|
type: :development
|
|
67
67
|
prerelease: false
|
|
68
|
-
version_requirements: *
|
|
68
|
+
version_requirements: *2158988700
|
|
69
69
|
description: Image Gallery for RefineryCMS that supports another fields like author,
|
|
70
70
|
subtitles etc.
|
|
71
71
|
email: mvinicius.zago@gmail.com
|
|
@@ -109,7 +109,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
109
109
|
version: '0'
|
|
110
110
|
segments:
|
|
111
111
|
- 0
|
|
112
|
-
hash:
|
|
112
|
+
hash: 2990383486132011348
|
|
113
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
none: false
|
|
115
115
|
requirements:
|