refinerycms-image-gallery 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -11,4 +11,5 @@ group :development do
11
11
  gem "jeweler", "~> 1.6.4"
12
12
  gem "rcov", ">= 0"
13
13
  gem "rdoc", ">= 0"
14
+ gem "rake", "0.9.2"
14
15
  end
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', :git => 'git://github.com/ginga/refinerycms-image-gallery.git'
19
+ gem 'refinerycms-image-gallery', "~> 0.1.3"
20
20
 
21
21
  Run:
22
22
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -87,9 +87,17 @@ open_edit_image = (items, image_id) ->
87
87
  resizable: false,
88
88
  autoOpen: true,
89
89
  width: 800,
90
- height: 500
90
+ height: 500,
91
+ close: ->
92
+ setTimeout ->
93
+ fields.remove();
94
+ , 500; # This remove cloned fields after close
91
95
  })
92
96
 
97
+ # Close in x button without save changes
98
+ $('a.ui-dialog-titlebar-close').click ->
99
+ fields.dialog('close');
100
+
93
101
  # Insert click function
94
102
  $('a#insert_fields').click ->
95
103
  # For each input get the textarea value and change input value
@@ -134,9 +142,6 @@ open_edit_image = (items, image_id) ->
134
142
 
135
143
  fields.dialog('close')
136
144
 
137
- # Remove cloned div after close
138
- fields.remove()
139
-
140
145
  # Create Fields for each type of element
141
146
  create_fields = (type, value) ->
142
147
  switch type
@@ -0,0 +1,205 @@
1
+ var create_date, create_fields, days_in_month, image_added, open_edit_image;
2
+ image_added = function(image, chunk) {
3
+ var dynamic_items, id, image_id, img, new_list, target;
4
+ image_id = $(image).attr('id').replace('image_', '');
5
+ new_list = $("li.empty_" + chunk).clone();
6
+ new_list.find('input').next().val(image_id);
7
+ new_list.find('span').html($(image).attr('alt'));
8
+ id = parseInt(image_id + Math.random() * 101);
9
+ $('input', new_list).each(function(i, input) {
10
+ input = $(input);
11
+ input.attr('name', input.attr('name').replace(/images_attributes\]\[[\d]+/, "images_attributes][" + id));
12
+ return input.attr('id', input.attr('id').replace(/images_attributes_[\d]+/, "images_attributes_" + id));
13
+ });
14
+ img = $("<img />").attr({
15
+ title: $(image).attr('title'),
16
+ alt: $(image).attr('alt'),
17
+ src: $(image).attr('data-grid')
18
+ }).appendTo(new_list);
19
+ dynamic_items = new_list.find("#dynamic_items");
20
+ dynamic_items.attr('id', "dynamic_items_" + image_id);
21
+ dynamic_items.find("input").val("");
22
+ new_list.attr('id', "image_" + image_id).removeClass('empty');
23
+ new_list.attr('id', "image_" + image_id).removeClass("empty_" + chunk);
24
+ new_list.show();
25
+ target = "#page_images_" + chunk;
26
+ return new_list.appendTo(target);
27
+ };
28
+ jQuery(function() {
29
+ $('.edit_image').live('click', function() {
30
+ var image_id, items;
31
+ image_id = $(this).parents().parents().attr('id').replace('image_', '');
32
+ items = $(this).parents().parents().find("#dynamic_items_" + image_id)[0];
33
+ return open_edit_image(items, image_id);
34
+ });
35
+ $('.delete_image').live('click', function() {
36
+ var rm;
37
+ rm = confirm("Are you sure delete this image?");
38
+ if (rm === true) {
39
+ return $(this).parents('li').first().remove();
40
+ } else {
41
+ return false;
42
+ }
43
+ });
44
+ $('li.image_field').live('hover', function() {
45
+ var chunk;
46
+ chunk = $(this).find('input').first().val();
47
+ return $("#page_images_" + chunk).sortable();
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
+ });
55
+ });
56
+ open_edit_image = function(items, image_id) {
57
+ var fields, input;
58
+ fields = $(items).clone();
59
+ input = fields.find('input');
60
+ input.each(function(i, inp) {
61
+ var field, title, type, value;
62
+ title = $(inp).attr('data-name');
63
+ type = $(inp).attr('data-type');
64
+ value = $(inp).val();
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>"));
67
+ });
68
+ input.after($("<div class='form-actions'><div class='form-actions-left'><a class='button' id='insert_fields'>Insert<a></div></div>"));
69
+ fields.dialog({
70
+ title: "Edit Image Fields",
71
+ modal: true,
72
+ resizable: false,
73
+ autoOpen: true,
74
+ width: 800,
75
+ height: 500,
76
+ close: function() {
77
+ return setTimeout(function() {
78
+ return fields.remove();
79
+ }, 500);
80
+ }
81
+ });
82
+ $('a.ui-dialog-titlebar-close').click(function() {
83
+ return fields.dialog('close');
84
+ });
85
+ return $('a#insert_fields').click(function() {
86
+ return input.each(function(i, inp) {
87
+ var date, date_value, field, hour, input_val, minute, title, type;
88
+ title = $(inp).attr('data-name');
89
+ type = $(inp).attr('data-type');
90
+ if (type === "string" || type === "integer" || type === "float" || type === "decimal") {
91
+ field = "input";
92
+ } else if (type === "boolean") {
93
+ field = "input-checkbox";
94
+ } else if (type === "text") {
95
+ field = "textarea";
96
+ } else if (type === "date" || type === "datetime") {
97
+ field = "select";
98
+ }
99
+ input_val = $(items).find("input[data-name='" + title + "']");
100
+ if (field === "select") {
101
+ date_value = [];
102
+ $("div#image" + image_id + "_title_" + title).find("" + field).each(function() {
103
+ return date_value.push($(this).val());
104
+ });
105
+ date = "" + date_value[0] + "-" + date_value[1] + "-" + date_value[2];
106
+ hour = date_value[3];
107
+ minute = date_value[4];
108
+ if (hour) {
109
+ date = "" + date + " " + hour + ":" + minute;
110
+ }
111
+ input_val.val(date);
112
+ } else if (field === "input-checkbox") {
113
+ field = field.split("-");
114
+ if ($("div#image" + image_id + "_title_" + title).find("" + field[0]).is(":checked")) {
115
+ input_val.val("true");
116
+ } else {
117
+ input_val.val("false");
118
+ }
119
+ } else {
120
+ input_val.val($("div#image" + image_id + "_title_" + title).find("" + field).val());
121
+ }
122
+ return fields.dialog('close');
123
+ });
124
+ });
125
+ };
126
+ create_fields = function(type, value) {
127
+ var checked, field;
128
+ switch (type) {
129
+ case "string":
130
+ case "integer":
131
+ case "float":
132
+ case "decimal":
133
+ return field = "<input class='image-edit' type='text' value='" + value + "' />";
134
+ case "boolean":
135
+ checked = '';
136
+ if (value === "true") {
137
+ checked = "checked";
138
+ }
139
+ return field = "<input class='image-edit-checkbox' type='checkbox' " + checked + " />";
140
+ case "text":
141
+ return field = "<textarea class='image-edit'>" + value + "</textarea>";
142
+ case "date":
143
+ if (value) {
144
+ value = value.split("-");
145
+ 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>";
146
+ } else {
147
+ 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>";
148
+ }
149
+ break;
150
+ case "datetime":
151
+ if (value) {
152
+ value = value.split("-");
153
+ 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>";
154
+ } else {
155
+ 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>";
156
+ }
157
+ }
158
+ };
159
+ create_date = function(init, end, obj_id, value) {
160
+ var day, month, selected, year, _ref, _ref2, _results;
161
+ if (obj_id === 'day' && !value) {
162
+ year = new Date().getFullYear();
163
+ month = new Date().getMonth();
164
+ end = new Date(year, month + 1, 0).getDate();
165
+ } else if (obj_id === 'day' && value) {
166
+ year = new Date(value).getFullYear();
167
+ month = new Date(value).getMonth() + 1;
168
+ day = new Date(value).getDate();
169
+ end = new Date(year, month, 0).getDate();
170
+ }
171
+ _results = [];
172
+ for (init = _ref = init, _ref2 = end; _ref <= _ref2 ? init <= _ref2 : init >= _ref2; _ref <= _ref2 ? init++ : init--) {
173
+ selected = '';
174
+ if (value) {
175
+ if (obj_id === 'year' && init === new Date(value, 1).getFullYear()) {
176
+ selected = 'selected';
177
+ }
178
+ if (obj_id === 'month' && init === new Date(0, value).getMonth()) {
179
+ selected = 'selected';
180
+ }
181
+ if (obj_id === 'day' && init === new Date(year, month, day).getDate()) {
182
+ selected = 'selected';
183
+ }
184
+ if (obj_id === 'hour' && init === new Date(value).getUTCHours()) {
185
+ selected = 'selected';
186
+ }
187
+ if (obj_id === 'minute' && init === new Date(value).getUTCMinutes()) {
188
+ selected = 'selected';
189
+ }
190
+ }
191
+ _results.push("<option value='" + init + "' " + selected + " >" + init + "</option>");
192
+ }
193
+ return _results;
194
+ };
195
+ days_in_month = function(year, month) {
196
+ var end, init, _ref, _ref2, _results;
197
+ $("#day").empty();
198
+ init = 1;
199
+ end = new Date(year, month, 0).getDate();
200
+ _results = [];
201
+ for (init = _ref = init, _ref2 = end; _ref <= _ref2 ? init <= _ref2 : init >= _ref2; _ref <= _ref2 ? init++ : init--) {
202
+ _results.push($("#day").append("<option value='" + init + "'>" + init + "</option>"));
203
+ }
204
+ return _results;
205
+ };
@@ -1,198 +1,208 @@
1
- var create_date, create_fields, days_in_month, image_added, open_edit_image;
2
- image_added = function(image, chunk) {
3
- var dynamic_items, id, image_id, img, new_list, target;
4
- image_id = $(image).attr('id').replace('image_', '');
5
- new_list = $("li.empty_" + chunk).clone();
6
- new_list.find('input').next().val(image_id);
7
- new_list.find('span').html($(image).attr('alt'));
8
- id = parseInt(image_id + Math.random() * 101);
9
- $('input', new_list).each(function(i, input) {
10
- input = $(input);
11
- input.attr('name', input.attr('name').replace(/images_attributes\]\[[\d]+/, "images_attributes][" + id));
12
- return input.attr('id', input.attr('id').replace(/images_attributes_[\d]+/, "images_attributes_" + id));
13
- });
14
- img = $("<img />").attr({
15
- title: $(image).attr('title'),
16
- alt: $(image).attr('alt'),
17
- src: $(image).attr('data-grid')
18
- }).appendTo(new_list);
19
- dynamic_items = new_list.find("#dynamic_items");
20
- dynamic_items.attr('id', "dynamic_items_" + image_id);
21
- dynamic_items.find("input").val("");
22
- new_list.attr('id', "image_" + image_id).removeClass('empty');
23
- new_list.attr('id', "image_" + image_id).removeClass("empty_" + chunk);
24
- new_list.show();
25
- target = "#page_images_" + chunk;
26
- return new_list.appendTo(target);
27
- };
28
- jQuery(function() {
29
- $('.edit_image').live('click', function() {
30
- var image_id, items;
31
- image_id = $(this).parents().parents().attr('id').replace('image_', '');
32
- items = $(this).parents().parents().find("#dynamic_items_" + image_id)[0];
33
- return open_edit_image(items, image_id);
34
- });
35
- $('.delete_image').live('click', function() {
36
- var rm;
37
- rm = confirm("Are you sure delete this image?");
38
- if (rm === true) {
39
- return $(this).parents('li').first().remove();
40
- } else {
41
- return false;
42
- }
43
- });
44
- $('li.image_field').live('hover', function() {
45
- var chunk;
46
- chunk = $(this).find('input').first().val();
47
- return $("#page_images_" + chunk).sortable();
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
- });
55
- });
56
- open_edit_image = function(items, image_id) {
57
- var fields, input;
58
- fields = $(items).clone();
59
- input = fields.find('input');
60
- input.each(function(i, inp) {
61
- var field, title, type, value;
62
- title = $(inp).attr('data-name');
63
- type = $(inp).attr('data-type');
64
- value = $(inp).val();
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>"));
67
- });
68
- input.after($("<div class='form-actions'><div class='form-actions-left'><a class='button' id='insert_fields'>Insert<a></div></div>"));
69
- fields.dialog({
70
- title: "Edit Image Fields",
71
- modal: true,
72
- resizable: false,
73
- autoOpen: true,
74
- width: 800,
75
- height: 500
1
+ (function() {
2
+ var create_date, create_fields, days_in_month, image_added, open_edit_image;
3
+ image_added = function(image, chunk) {
4
+ var dynamic_items, id, image_id, img, new_list, target;
5
+ image_id = $(image).attr('id').replace('image_', '');
6
+ new_list = $("li.empty_" + chunk).clone();
7
+ new_list.find('input').next().val(image_id);
8
+ new_list.find('span').html($(image).attr('alt'));
9
+ id = parseInt(image_id + Math.random() * 101);
10
+ $('input', new_list).each(function(i, input) {
11
+ input = $(input);
12
+ input.attr('name', input.attr('name').replace(/images_attributes\]\[[\d]+/, "images_attributes][" + id));
13
+ return input.attr('id', input.attr('id').replace(/images_attributes_[\d]+/, "images_attributes_" + id));
14
+ });
15
+ img = $("<img />").attr({
16
+ title: $(image).attr('title'),
17
+ alt: $(image).attr('alt'),
18
+ src: $(image).attr('data-grid')
19
+ }).appendTo(new_list);
20
+ dynamic_items = new_list.find("#dynamic_items");
21
+ dynamic_items.attr('id', "dynamic_items_" + image_id);
22
+ dynamic_items.find("input").val("");
23
+ new_list.attr('id', "image_" + image_id).removeClass('empty');
24
+ new_list.attr('id', "image_" + image_id).removeClass("empty_" + chunk);
25
+ new_list.show();
26
+ target = "#page_images_" + chunk;
27
+ return new_list.appendTo(target);
28
+ };
29
+ jQuery(function() {
30
+ $('.edit_image').live('click', function() {
31
+ var image_id, items;
32
+ image_id = $(this).parents().parents().attr('id').replace('image_', '');
33
+ items = $(this).parents().parents().find("#dynamic_items_" + image_id)[0];
34
+ return open_edit_image(items, image_id);
35
+ });
36
+ $('.delete_image').live('click', function() {
37
+ var rm;
38
+ rm = confirm("Are you sure delete this image?");
39
+ if (rm === true) {
40
+ return $(this).parents('li').first().remove();
41
+ } else {
42
+ return false;
43
+ }
44
+ });
45
+ $('li.image_field').live('hover', function() {
46
+ var chunk;
47
+ chunk = $(this).find('input').first().val();
48
+ return $("#page_images_" + chunk).sortable();
49
+ });
50
+ return $("#month, #year").live('change', function() {
51
+ var month, year;
52
+ year = $("#year").find(":selected").val();
53
+ month = $("#month").find(":selected").val();
54
+ return days_in_month(year, month);
55
+ });
76
56
  });
77
- return $('a#insert_fields').click(function() {
57
+ open_edit_image = function(items, image_id) {
58
+ var fields, input;
59
+ fields = $(items).clone();
60
+ input = fields.find('input');
78
61
  input.each(function(i, inp) {
79
- var date, date_value, field, hour, input_val, minute, title, type;
62
+ var field, title, type, value;
80
63
  title = $(inp).attr('data-name');
81
64
  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";
65
+ value = $(inp).val();
66
+ field = create_fields(type, value);
67
+ return $(inp).after($("<div id='image" + image_id + "_title_" + title + "'><span class= 'image-fields-edit'>" + title + "</span>" + field + "</div>"));
68
+ });
69
+ input.after($("<div class='form-actions'><div class='form-actions-left'><a class='button' id='insert_fields'>Insert<a></div></div>"));
70
+ fields.dialog({
71
+ title: "Edit Image Fields",
72
+ modal: true,
73
+ resizable: false,
74
+ autoOpen: true,
75
+ width: 800,
76
+ height: 500,
77
+ close: function() {
78
+ return setTimeout(function() {
79
+ return fields.remove();
80
+ }, 500);
90
81
  }
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;
82
+ });
83
+ $('a.ui-dialog-titlebar-close').click(function() {
84
+ return fields.dialog('close');
85
+ });
86
+ return $('a#insert_fields').click(function() {
87
+ input.each(function(i, inp) {
88
+ var date, date_value, field, hour, input_val, minute, title, type;
89
+ title = $(inp).attr('data-name');
90
+ type = $(inp).attr('data-type');
91
+ if (type === "string" || type === "integer" || type === "float" || type === "decimal") {
92
+ field = "input";
93
+ } else if (type === "boolean") {
94
+ field = "input-checkbox";
95
+ } else if (type === "text") {
96
+ field = "textarea";
97
+ } else if (type === "date" || type === "datetime") {
98
+ field = "select";
102
99
  }
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");
100
+ input_val = $(items).find("input[data-name='" + title + "']");
101
+ if (field === "select") {
102
+ date_value = [];
103
+ $("div#image" + image_id + "_title_" + title).find("" + field).each(function() {
104
+ return date_value.push($(this).val());
105
+ });
106
+ date = "" + date_value[0] + "-" + date_value[1] + "-" + date_value[2];
107
+ hour = date_value[3];
108
+ minute = date_value[4];
109
+ if (hour) {
110
+ date = "" + date + " " + hour + ":" + minute;
111
+ }
112
+ input_val.val(date);
113
+ } else if (field === "input-checkbox") {
114
+ field = field.split("-");
115
+ if ($("div#image" + image_id + "_title_" + title).find("" + field[0]).is(":checked")) {
116
+ input_val.val("true");
117
+ } else {
118
+ input_val.val("false");
119
+ }
108
120
  } else {
109
- input_val.val("false");
121
+ input_val.val($("div#image" + image_id + "_title_" + title).find("" + field).val());
110
122
  }
111
- } else {
112
- input_val.val($("div#image" + image_id + "_title_" + title).find("" + field).val());
113
- }
114
- return fields.dialog('close');
123
+ return fields.dialog('close');
124
+ });
125
+ return fields.remove();
115
126
  });
116
- return fields.remove();
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":
127
+ };
128
+ create_fields = function(type, value) {
129
+ var checked, field;
130
+ switch (type) {
131
+ case "string":
132
+ case "integer":
133
+ case "float":
134
+ case "decimal":
135
+ return field = "<input class='image-edit' type='text' value='" + value + "' />";
136
+ case "boolean":
137
+ checked = '';
138
+ if (value === "true") {
139
+ checked = "checked";
140
+ }
141
+ return field = "<input class='image-edit-checkbox' type='checkbox' " + checked + " />";
142
+ case "text":
143
+ return field = "<textarea class='image-edit'>" + value + "</textarea>";
144
+ case "date":
145
+ if (value) {
146
+ value = value.split("-");
147
+ 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>";
148
+ } else {
149
+ 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>";
150
+ }
151
+ break;
152
+ case "datetime":
153
+ if (value) {
154
+ value = value.split("-");
155
+ 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>";
156
+ } else {
157
+ 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>";
158
+ }
159
+ }
160
+ };
161
+ create_date = function(init, end, obj_id, value) {
162
+ var day, month, selected, year, _ref, _ref2, _results;
163
+ if (obj_id === 'day' && !value) {
164
+ year = new Date().getFullYear();
165
+ month = new Date().getMonth();
166
+ end = new Date(year, month + 1, 0).getDate();
167
+ } else if (obj_id === 'day' && value) {
168
+ year = new Date(value).getFullYear();
169
+ month = new Date(value).getMonth() + 1;
170
+ day = new Date(value).getDate();
171
+ end = new Date(year, month, 0).getDate();
172
+ }
173
+ _results = [];
174
+ for (init = _ref = init, _ref2 = end; _ref <= _ref2 ? init <= _ref2 : init >= _ref2; _ref <= _ref2 ? init++ : init--) {
175
+ selected = '';
144
176
  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>";
177
+ if (obj_id === 'year' && init === new Date(value, 1).getFullYear()) {
178
+ selected = 'selected';
179
+ }
180
+ if (obj_id === 'month' && init === new Date(0, value).getMonth()) {
181
+ selected = 'selected';
182
+ }
183
+ if (obj_id === 'day' && init === new Date(year, month, day).getDate()) {
184
+ selected = 'selected';
185
+ }
186
+ if (obj_id === 'hour' && init === new Date(value).getUTCHours()) {
187
+ selected = 'selected';
188
+ }
189
+ if (obj_id === 'minute' && init === new Date(value).getUTCMinutes()) {
190
+ selected = 'selected';
191
+ }
149
192
  }
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();
193
+ _results.push("<option value='" + init + "' " + selected + " >" + init + "</option>");
194
+ }
195
+ return _results;
196
+ };
197
+ days_in_month = function(year, month) {
198
+ var end, init, _ref, _ref2, _results;
199
+ $("#day").empty();
200
+ init = 1;
162
201
  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
- }
202
+ _results = [];
203
+ for (init = _ref = init, _ref2 = end; _ref <= _ref2 ? init <= _ref2 : init >= _ref2; _ref <= _ref2 ? init++ : init--) {
204
+ _results.push($("#day").append("<option value='" + init + "'>" + init + "</option>"));
183
205
  }
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;
198
- };
206
+ return _results;
207
+ };
208
+ }).call(this);
@@ -13,7 +13,9 @@
13
13
  <%%= hidden_field_tag "#{f.object.class.name.underscore}[images_attributes][#{random_data}][chunk]", chunk_name %>
14
14
  <%%= hidden_field_tag "#{f.object.class.name.underscore}[images_attributes][#{random_data}][id]", image.id %>
15
15
  <div class="image_actions" style="position:absolute;">
16
- <img alt="edit" height="16" src="/images/refinery/icons/application_edit.png" width="16" class="edit_image" />
16
+ <%- unless attributes.empty? -%>
17
+ <img alt="edit" height="16" src="/images/refinery/icons/application_edit.png" width="16" class="edit_image" />
18
+ <%- end -%>
17
19
  <img alt="delete" height="16" src="/images/refinery/icons/delete.png" width="16" class="delete_image" style="float:right;" />
18
20
  </div>
19
21
  <%%= image_fu image, '135x135#c' %>
@@ -10,7 +10,9 @@
10
10
  <span style="font-weight: bold"></span>
11
11
  </div>
12
12
  <div class="image_actions" style="position:absolute;">
13
- <img alt="edit" height="16" src="/images/refinery/icons/application_edit.png" width="16" class="edit_image" />
13
+ <%- unless attributes.empty? -%>
14
+ <img alt="edit" height="16" src="/images/refinery/icons/application_edit.png" width="16" class="edit_image" />
15
+ <%- end -%>
14
16
  <img alt="delete" height="16" src="/images/refinery/icons/delete.png" width="16" class="delete_image" style="float:right;" />
15
17
  </div>
16
18
  <%%= hidden_field_tag "#{f.object.class.name.underscore}[images_attributes][#{f.object.images.size}][chunk]", chunk_name %>
@@ -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.2"
8
+ s.version = "0.1.3"
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 = "2012-01-06"
12
+ s.date = "2012-03-28"
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"]
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
27
27
  "bin/refinerycms_image_gallery",
28
28
  "lib/refinerycms-image-gallery.rb",
29
29
  "lib/templates/javascripts/coffeescripts/gallery.coffee",
30
+ "lib/templates/javascripts/coffeescripts/gallery.js",
30
31
  "lib/templates/javascripts/gallery.js",
31
32
  "lib/templates/javascripts/refinery/admin.js",
32
33
  "lib/templates/migration.rb",
@@ -52,12 +53,14 @@ Gem::Specification.new do |s|
52
53
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
53
54
  s.add_development_dependency(%q<rcov>, [">= 0"])
54
55
  s.add_development_dependency(%q<rdoc>, [">= 0"])
56
+ s.add_development_dependency(%q<rake>, ["= 0.9.2"])
55
57
  else
56
58
  s.add_dependency(%q<shoulda>, [">= 0"])
57
59
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
58
60
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
59
61
  s.add_dependency(%q<rcov>, [">= 0"])
60
62
  s.add_dependency(%q<rdoc>, [">= 0"])
63
+ s.add_dependency(%q<rake>, ["= 0.9.2"])
61
64
  end
62
65
  else
63
66
  s.add_dependency(%q<shoulda>, [">= 0"])
@@ -65,6 +68,7 @@ Gem::Specification.new do |s|
65
68
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
66
69
  s.add_dependency(%q<rcov>, [">= 0"])
67
70
  s.add_dependency(%q<rdoc>, [">= 0"])
71
+ s.add_dependency(%q<rake>, ["= 0.9.2"])
68
72
  end
69
73
  end
70
74
 
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.2
4
+ version: 0.1.3
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: 2012-01-06 00:00:00.000000000Z
12
+ date: 2012-03-28 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoulda
16
- requirement: &2158990960 !ruby/object:Gem::Requirement
16
+ requirement: &2158851460 !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: *2158990960
24
+ version_requirements: *2158851460
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &2158990360 !ruby/object:Gem::Requirement
27
+ requirement: &2158850160 !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: *2158990360
35
+ version_requirements: *2158850160
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: jeweler
38
- requirement: &2158989720 !ruby/object:Gem::Requirement
38
+ requirement: &2158848760 !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: *2158989720
46
+ version_requirements: *2158848760
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rcov
49
- requirement: &2158989220 !ruby/object:Gem::Requirement
49
+ requirement: &2158833240 !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: *2158989220
57
+ version_requirements: *2158833240
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rdoc
60
- requirement: &2158988700 !ruby/object:Gem::Requirement
60
+ requirement: &2158832200 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,18 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2158988700
68
+ version_requirements: *2158832200
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: &2158831140 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - =
75
+ - !ruby/object:Gem::Version
76
+ version: 0.9.2
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *2158831140
69
80
  description: Image Gallery for RefineryCMS that supports another fields like author,
70
81
  subtitles etc.
71
82
  email: mvinicius.zago@gmail.com
@@ -85,6 +96,7 @@ files:
85
96
  - bin/refinerycms_image_gallery
86
97
  - lib/refinerycms-image-gallery.rb
87
98
  - lib/templates/javascripts/coffeescripts/gallery.coffee
99
+ - lib/templates/javascripts/coffeescripts/gallery.js
88
100
  - lib/templates/javascripts/gallery.js
89
101
  - lib/templates/javascripts/refinery/admin.js
90
102
  - lib/templates/migration.rb
@@ -109,7 +121,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
109
121
  version: '0'
110
122
  segments:
111
123
  - 0
112
- hash: 2990383486132011348
124
+ hash: -2890672731372863649
113
125
  required_rubygems_version: !ruby/object:Gem::Requirement
114
126
  none: false
115
127
  requirements: