sofa_gallery 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -2
- data/Gemfile.lock +67 -61
- data/VERSION +1 -1
- data/app/assets/images/sofa_gallery/prettyPhoto/dark_rounded/btnNext.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/dark_rounded/btnPrevious.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/dark_rounded/contentPattern.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/dark_rounded/default_thumbnail.gif +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/dark_rounded/loader.gif +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/dark_rounded/sprite.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/dark_square/btnNext.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/dark_square/btnPrevious.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/dark_square/contentPattern.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/dark_square/default_thumbnail.gif +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/dark_square/loader.gif +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/dark_square/sprite.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/default/default_thumb.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/default/loader.gif +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/default/sprite.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/default/sprite_next.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/default/sprite_prev.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/default/sprite_x.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/default/sprite_y.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/facebook/btnNext.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/facebook/btnPrevious.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/facebook/contentPatternBottom.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/facebook/contentPatternLeft.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/facebook/contentPatternRight.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/facebook/contentPatternTop.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/facebook/default_thumbnail.gif +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/facebook/loader.gif +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/facebook/sprite.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/light_rounded/btnNext.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/light_rounded/btnPrevious.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/light_rounded/default_thumbnail.gif +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/light_rounded/loader.gif +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/light_rounded/sprite.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/light_square/btnNext.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/light_square/btnPrevious.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/light_square/default_thumbnail.gif +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/light_square/loader.gif +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/light_square/sprite.png +0 -0
- data/app/assets/javascripts/sofa_gallery/admin.js +72 -0
- data/app/assets/javascripts/sofa_gallery/carousel.js +44 -0
- data/app/assets/javascripts/sofa_gallery/thumbnails.js +85 -0
- data/app/assets/stylesheets/sofa_gallery/admin.css +13 -0
- data/app/assets/stylesheets/sofa_gallery/application.css +0 -1
- data/app/assets/stylesheets/sofa_gallery/carousel.css +186 -0
- data/app/assets/stylesheets/sofa_gallery/tango/credits.txt +1 -0
- data/app/assets/stylesheets/sofa_gallery/tango/next-horizontal.png +0 -0
- data/app/assets/stylesheets/sofa_gallery/tango/next-vertical.png +0 -0
- data/app/assets/stylesheets/sofa_gallery/tango/prev-horizontal.png +0 -0
- data/app/assets/stylesheets/sofa_gallery/tango/prev-vertical.png +0 -0
- data/app/assets/stylesheets/sofa_gallery/thumbnails.css.scss +182 -0
- data/app/controllers/application_controller.rb +1 -0
- data/app/controllers/sofa_gallery/admin/base_controller.rb +3 -0
- data/app/controllers/{gallery_admin → sofa_gallery/admin}/galleries_controller.rb +4 -4
- data/app/controllers/{gallery_admin → sofa_gallery/admin}/photos_controller.rb +6 -6
- data/app/controllers/sofa_gallery/galleries_controller.rb +9 -0
- data/app/helpers/sofa_gallery_helper.rb +11 -1
- data/app/models/{sofa → sofa_gallery}/gallery.rb +2 -2
- data/app/models/{sofa → sofa_gallery}/photo.rb +18 -9
- data/app/views/layouts/gallery_admin/application.html.erb +2 -2
- data/app/views/sofa_gallery/_carousel.html.erb +17 -0
- data/app/views/sofa_gallery/_thumbnails.html.erb +19 -0
- data/app/views/sofa_gallery/admin/_html_head.html.erb +1 -0
- data/app/views/sofa_gallery/admin/_navigation.html.erb +5 -0
- data/app/views/sofa_gallery/admin/galleries/_form.html.erb +17 -0
- data/app/views/sofa_gallery/admin/galleries/edit.html.erb +5 -0
- data/app/views/sofa_gallery/admin/galleries/index.html.erb +48 -0
- data/app/views/sofa_gallery/admin/galleries/new.html.erb +5 -0
- data/app/views/sofa_gallery/admin/photos/_form.html.erb +16 -0
- data/app/views/sofa_gallery/admin/photos/crop.html.erb +64 -0
- data/app/views/sofa_gallery/admin/photos/edit.html.erb +5 -0
- data/app/views/{gallery_admin → sofa_gallery/admin}/photos/index.html.erb +4 -4
- data/app/views/sofa_gallery/admin/photos/new.html.erb +5 -0
- data/app/views/sofa_gallery/galleries/show.html.erb +1 -0
- data/config/routes.rb +12 -7
- data/db/migrate/01_create_sofa_gallery.rb +15 -12
- data/lib/paperclip_processors/cropper.rb +16 -3
- data/lib/sofa_gallery/configuration.rb +4 -4
- data/lib/sofa_gallery/engine.rb +2 -1
- data/sofa_gallery.gemspec +89 -30
- data/test/fixtures/files/default2.jpg +0 -0
- data/test/fixtures/{sofa → sofa_gallery}/galleries.yml +4 -2
- data/test/fixtures/{sofa → sofa_gallery}/photos.yml +0 -0
- data/test/functional/admin/galleries_controller_test.rb +87 -0
- data/test/functional/admin/photos_controller_test.rb +177 -0
- data/test/functional/galleries_controller_test.rb +8 -78
- data/test/test_helper.rb +4 -1
- data/test/unit/configuration_test.rb +1 -1
- data/test/unit/gallery_test.rb +6 -6
- data/test/unit/photo_test.rb +5 -5
- metadata +150 -79
- data/app/assets/javascripts/sofa_gallery/jquery.js +0 -18
- data/app/assets/javascripts/sofa_gallery/jquery_ui.js +0 -248
- data/app/assets/javascripts/sofa_gallery/rails.js +0 -315
- data/app/controllers/gallery_admin/base_controller.rb +0 -3
- data/app/views/gallery_admin/_navigation.html.erb +0 -1
- data/app/views/gallery_admin/galleries/_form.html.erb +0 -11
- data/app/views/gallery_admin/galleries/edit.html.erb +0 -5
- data/app/views/gallery_admin/galleries/index.html.erb +0 -28
- data/app/views/gallery_admin/galleries/new.html.erb +0 -5
- data/app/views/gallery_admin/photos/_form.html.erb +0 -13
- data/app/views/gallery_admin/photos/crop.html.erb +0 -32
- data/app/views/gallery_admin/photos/edit.html.erb +0 -5
- data/app/views/gallery_admin/photos/new.html.erb +0 -5
- data/test/functional/photos_controller_test.rb +0 -123
@@ -1,315 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Unobtrusive scripting adapter for jQuery
|
3
|
-
*
|
4
|
-
* Requires jQuery 1.4.4 or later.
|
5
|
-
* https://github.com/rails/jquery-ujs
|
6
|
-
|
7
|
-
* Uploading file using rails.js
|
8
|
-
* =============================
|
9
|
-
*
|
10
|
-
* By default, browsers do not allow files to be uploaded via AJAX. As a result, if there are any non-blank file fields
|
11
|
-
* in the remote form, this adapter aborts the AJAX submission and allows the form to submit through standard means.
|
12
|
-
*
|
13
|
-
* The `ajax:aborted:file` event allows you to bind your own handler to process the form submission however you wish.
|
14
|
-
*
|
15
|
-
* Ex:
|
16
|
-
* $('form').live('ajax:aborted:file', function(event, elements){
|
17
|
-
* // Implement own remote file-transfer handler here for non-blank file inputs passed in `elements`.
|
18
|
-
* // Returning false in this handler tells rails.js to disallow standard form submission
|
19
|
-
* return false;
|
20
|
-
* });
|
21
|
-
*
|
22
|
-
* The `ajax:aborted:file` event is fired when a file-type input is detected with a non-blank value.
|
23
|
-
*
|
24
|
-
* Third-party tools can use this hook to detect when an AJAX file upload is attempted, and then use
|
25
|
-
* techniques like the iframe method to upload the file instead.
|
26
|
-
*
|
27
|
-
* Required fields in rails.js
|
28
|
-
* ===========================
|
29
|
-
*
|
30
|
-
* If any blank required inputs (required="required") are detected in the remote form, the whole form submission
|
31
|
-
* is canceled. Note that this is unlike file inputs, which still allow standard (non-AJAX) form submission.
|
32
|
-
*
|
33
|
-
* The `ajax:aborted:required` event allows you to bind your own handler to inform the user of blank required inputs.
|
34
|
-
*
|
35
|
-
* !! Note that Opera does not fire the form's submit event if there are blank required inputs, so this event may never
|
36
|
-
* get fired in Opera. This event is what causes other browsers to exhibit the same submit-aborting behavior.
|
37
|
-
*
|
38
|
-
* Ex:
|
39
|
-
* $('form').live('ajax:aborted:required', function(event, elements){
|
40
|
-
* // Returning false in this handler tells rails.js to submit the form anyway.
|
41
|
-
* // The blank required inputs are passed to this function in `elements`.
|
42
|
-
* return ! confirm("Would you like to submit the form with missing info?");
|
43
|
-
* });
|
44
|
-
*/
|
45
|
-
|
46
|
-
(function($) {
|
47
|
-
// Shorthand to make it a little easier to call public rails functions from within rails.js
|
48
|
-
var rails;
|
49
|
-
|
50
|
-
$.rails = rails = {
|
51
|
-
// Link elements bound by jquery-ujs
|
52
|
-
linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote]',
|
53
|
-
|
54
|
-
// Form elements bound by jquery-ujs
|
55
|
-
formSubmitSelector: 'form',
|
56
|
-
|
57
|
-
// Form input elements bound by jquery-ujs
|
58
|
-
formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not([type])',
|
59
|
-
|
60
|
-
// Form input elements disabled during form submission
|
61
|
-
disableSelector: 'input[data-disable-with], button[data-disable-with], textarea[data-disable-with]',
|
62
|
-
|
63
|
-
// Form input elements re-enabled after form submission
|
64
|
-
enableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled',
|
65
|
-
|
66
|
-
// Form required input elements
|
67
|
-
requiredInputSelector: 'input[name][required]:not([disabled]),textarea[name][required]:not([disabled])',
|
68
|
-
|
69
|
-
// Form file input elements
|
70
|
-
fileInputSelector: 'input:file',
|
71
|
-
|
72
|
-
// Make sure that every Ajax request sends the CSRF token
|
73
|
-
CSRFProtection: function(xhr) {
|
74
|
-
var token = $('meta[name="csrf-token"]').attr('content');
|
75
|
-
if (token) xhr.setRequestHeader('X-CSRF-Token', token);
|
76
|
-
},
|
77
|
-
|
78
|
-
// Triggers an event on an element and returns false if the event result is false
|
79
|
-
fire: function(obj, name, data) {
|
80
|
-
var event = $.Event(name);
|
81
|
-
obj.trigger(event, data);
|
82
|
-
return event.result !== false;
|
83
|
-
},
|
84
|
-
|
85
|
-
// Default confirm dialog, may be overridden with custom confirm dialog in $.rails.confirm
|
86
|
-
confirm: function(message) {
|
87
|
-
return confirm(message);
|
88
|
-
},
|
89
|
-
|
90
|
-
// Default ajax function, may be overridden with custom function in $.rails.ajax
|
91
|
-
ajax: function(options) {
|
92
|
-
return $.ajax(options);
|
93
|
-
},
|
94
|
-
|
95
|
-
// Submits "remote" forms and links with ajax
|
96
|
-
handleRemote: function(element) {
|
97
|
-
var method, url, data,
|
98
|
-
dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType);
|
99
|
-
|
100
|
-
if (rails.fire(element, 'ajax:before')) {
|
101
|
-
|
102
|
-
if (element.is('form')) {
|
103
|
-
method = element.attr('method');
|
104
|
-
url = element.attr('action');
|
105
|
-
data = element.serializeArray();
|
106
|
-
// memoized value from clicked submit button
|
107
|
-
var button = element.data('ujs:submit-button');
|
108
|
-
if (button) {
|
109
|
-
data.push(button);
|
110
|
-
element.data('ujs:submit-button', null);
|
111
|
-
}
|
112
|
-
} else {
|
113
|
-
method = element.data('method');
|
114
|
-
url = element.attr('href');
|
115
|
-
data = element.data('params') || null;
|
116
|
-
}
|
117
|
-
|
118
|
-
rails.ajax({
|
119
|
-
url: url, type: method || 'GET', data: data, dataType: dataType,
|
120
|
-
// stopping the "ajax:beforeSend" event will cancel the ajax request
|
121
|
-
beforeSend: function(xhr, settings) {
|
122
|
-
if (settings.dataType === undefined) {
|
123
|
-
xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script);
|
124
|
-
}
|
125
|
-
return rails.fire(element, 'ajax:beforeSend', [xhr, settings]);
|
126
|
-
},
|
127
|
-
success: function(data, status, xhr) {
|
128
|
-
element.trigger('ajax:success', [data, status, xhr]);
|
129
|
-
},
|
130
|
-
complete: function(xhr, status) {
|
131
|
-
element.trigger('ajax:complete', [xhr, status]);
|
132
|
-
},
|
133
|
-
error: function(xhr, status, error) {
|
134
|
-
element.trigger('ajax:error', [xhr, status, error]);
|
135
|
-
}
|
136
|
-
});
|
137
|
-
}
|
138
|
-
},
|
139
|
-
|
140
|
-
// Handles "data-method" on links such as:
|
141
|
-
// <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a>
|
142
|
-
handleMethod: function(link) {
|
143
|
-
var href = link.attr('href'),
|
144
|
-
method = link.data('method'),
|
145
|
-
csrf_token = $('meta[name=csrf-token]').attr('content'),
|
146
|
-
csrf_param = $('meta[name=csrf-param]').attr('content'),
|
147
|
-
form = $('<form method="post" action="' + href + '"></form>'),
|
148
|
-
metadata_input = '<input name="_method" value="' + method + '" type="hidden" />';
|
149
|
-
|
150
|
-
if (csrf_param !== undefined && csrf_token !== undefined) {
|
151
|
-
metadata_input += '<input name="' + csrf_param + '" value="' + csrf_token + '" type="hidden" />';
|
152
|
-
}
|
153
|
-
|
154
|
-
form.hide().append(metadata_input).appendTo('body');
|
155
|
-
form.submit();
|
156
|
-
},
|
157
|
-
|
158
|
-
/* Disables form elements:
|
159
|
-
- Caches element value in 'ujs:enable-with' data store
|
160
|
-
- Replaces element text with value of 'data-disable-with' attribute
|
161
|
-
- Adds disabled=disabled attribute
|
162
|
-
*/
|
163
|
-
disableFormElements: function(form) {
|
164
|
-
form.find(rails.disableSelector).each(function() {
|
165
|
-
var element = $(this), method = element.is('button') ? 'html' : 'val';
|
166
|
-
element.data('ujs:enable-with', element[method]());
|
167
|
-
element[method](element.data('disable-with'));
|
168
|
-
element.attr('disabled', 'disabled');
|
169
|
-
});
|
170
|
-
},
|
171
|
-
|
172
|
-
/* Re-enables disabled form elements:
|
173
|
-
- Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`)
|
174
|
-
- Removes disabled attribute
|
175
|
-
*/
|
176
|
-
enableFormElements: function(form) {
|
177
|
-
form.find(rails.enableSelector).each(function() {
|
178
|
-
var element = $(this), method = element.is('button') ? 'html' : 'val';
|
179
|
-
if (element.data('ujs:enable-with')) element[method](element.data('ujs:enable-with'));
|
180
|
-
element.removeAttr('disabled');
|
181
|
-
});
|
182
|
-
},
|
183
|
-
|
184
|
-
/* For 'data-confirm' attribute:
|
185
|
-
- Fires `confirm` event
|
186
|
-
- Shows the confirmation dialog
|
187
|
-
- Fires the `confirm:complete` event
|
188
|
-
|
189
|
-
Returns `true` if no function stops the chain and user chose yes; `false` otherwise.
|
190
|
-
Attaching a handler to the element's `confirm` event that returns a `falsy` value cancels the confirmation dialog.
|
191
|
-
Attaching a handler to the element's `confirm:complete` event that returns a `falsy` value makes this function
|
192
|
-
return false. The `confirm:complete` event is fired whether or not the user answered true or false to the dialog.
|
193
|
-
*/
|
194
|
-
allowAction: function(element) {
|
195
|
-
var message = element.data('confirm'),
|
196
|
-
answer = false, callback;
|
197
|
-
if (!message) { return true; }
|
198
|
-
|
199
|
-
if (rails.fire(element, 'confirm')) {
|
200
|
-
answer = rails.confirm(message);
|
201
|
-
callback = rails.fire(element, 'confirm:complete', [answer]);
|
202
|
-
}
|
203
|
-
return answer && callback;
|
204
|
-
},
|
205
|
-
|
206
|
-
// Helper function which checks for blank inputs in a form that match the specified CSS selector
|
207
|
-
blankInputs: function(form, specifiedSelector, nonBlank) {
|
208
|
-
var inputs = $(), input,
|
209
|
-
selector = specifiedSelector || 'input,textarea';
|
210
|
-
form.find(selector).each(function() {
|
211
|
-
input = $(this);
|
212
|
-
// Collect non-blank inputs if nonBlank option is true, otherwise, collect blank inputs
|
213
|
-
if (nonBlank ? input.val() : !input.val()) {
|
214
|
-
inputs = inputs.add(input);
|
215
|
-
}
|
216
|
-
});
|
217
|
-
return inputs.length ? inputs : false;
|
218
|
-
},
|
219
|
-
|
220
|
-
// Helper function which checks for non-blank inputs in a form that match the specified CSS selector
|
221
|
-
nonBlankInputs: function(form, specifiedSelector) {
|
222
|
-
return rails.blankInputs(form, specifiedSelector, true); // true specifies nonBlank
|
223
|
-
},
|
224
|
-
|
225
|
-
// Helper function, needed to provide consistent behavior in IE
|
226
|
-
stopEverything: function(e) {
|
227
|
-
$(e.target).trigger('ujs:everythingStopped');
|
228
|
-
e.stopImmediatePropagation();
|
229
|
-
return false;
|
230
|
-
},
|
231
|
-
|
232
|
-
// find all the submit events directly bound to the form and
|
233
|
-
// manually invoke them. If anyone returns false then stop the loop
|
234
|
-
callFormSubmitBindings: function(form) {
|
235
|
-
var events = form.data('events'), continuePropagation = true;
|
236
|
-
if (events !== undefined && events['submit'] !== undefined) {
|
237
|
-
$.each(events['submit'], function(i, obj){
|
238
|
-
if (typeof obj.handler === 'function') return continuePropagation = obj.handler(obj.data);
|
239
|
-
});
|
240
|
-
}
|
241
|
-
return continuePropagation;
|
242
|
-
}
|
243
|
-
};
|
244
|
-
|
245
|
-
// ajaxPrefilter is a jQuery 1.5 feature
|
246
|
-
if ('ajaxPrefilter' in $) {
|
247
|
-
$.ajaxPrefilter(function(options, originalOptions, xhr){ rails.CSRFProtection(xhr); });
|
248
|
-
} else {
|
249
|
-
$(document).ajaxSend(function(e, xhr){ rails.CSRFProtection(xhr); });
|
250
|
-
}
|
251
|
-
|
252
|
-
$(rails.linkClickSelector).live('click.rails', function(e) {
|
253
|
-
var link = $(this);
|
254
|
-
if (!rails.allowAction(link)) return rails.stopEverything(e);
|
255
|
-
|
256
|
-
if (link.data('remote') !== undefined) {
|
257
|
-
rails.handleRemote(link);
|
258
|
-
return false;
|
259
|
-
} else if (link.data('method')) {
|
260
|
-
rails.handleMethod(link);
|
261
|
-
return false;
|
262
|
-
}
|
263
|
-
});
|
264
|
-
|
265
|
-
$(rails.formSubmitSelector).live('submit.rails', function(e) {
|
266
|
-
var form = $(this),
|
267
|
-
remote = form.data('remote') !== undefined,
|
268
|
-
blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector),
|
269
|
-
nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector);
|
270
|
-
|
271
|
-
if (!rails.allowAction(form)) return rails.stopEverything(e);
|
272
|
-
|
273
|
-
// skip other logic when required values are missing or file upload is present
|
274
|
-
if (blankRequiredInputs && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) {
|
275
|
-
return rails.stopEverything(e);
|
276
|
-
}
|
277
|
-
|
278
|
-
if (remote) {
|
279
|
-
if (nonBlankFileInputs) {
|
280
|
-
return rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);
|
281
|
-
}
|
282
|
-
|
283
|
-
// If browser does not support submit bubbling, then this live-binding will be called before direct
|
284
|
-
// bindings. Therefore, we should directly call any direct bindings before remotely submitting form.
|
285
|
-
if (!$.support.submitBubbles && rails.callFormSubmitBindings(form) === false) return rails.stopEverything(e);
|
286
|
-
|
287
|
-
rails.handleRemote(form);
|
288
|
-
return false;
|
289
|
-
} else {
|
290
|
-
// slight timeout so that the submit button gets properly serialized
|
291
|
-
setTimeout(function(){ rails.disableFormElements(form); }, 13);
|
292
|
-
}
|
293
|
-
});
|
294
|
-
|
295
|
-
$(rails.formInputClickSelector).live('click.rails', function(event) {
|
296
|
-
var button = $(this);
|
297
|
-
|
298
|
-
if (!rails.allowAction(button)) return rails.stopEverything(event);
|
299
|
-
|
300
|
-
// register the pressed submit button
|
301
|
-
var name = button.attr('name'),
|
302
|
-
data = name ? {name:name, value:button.val()} : null;
|
303
|
-
|
304
|
-
button.closest('form').data('ujs:submit-button', data);
|
305
|
-
});
|
306
|
-
|
307
|
-
$(rails.formSubmitSelector).live('ajax:beforeSend.rails', function(event) {
|
308
|
-
if (this == event.target) rails.disableFormElements($(this));
|
309
|
-
});
|
310
|
-
|
311
|
-
$(rails.formSubmitSelector).live('ajax:complete.rails', function(event) {
|
312
|
-
if (this == event.target) rails.enableFormElements($(this));
|
313
|
-
});
|
314
|
-
|
315
|
-
})( jQuery );
|
@@ -1 +0,0 @@
|
|
1
|
-
<li><%= active_link_to 'Galleries', gallery_admin_galleries_path %></li>
|
@@ -1,11 +0,0 @@
|
|
1
|
-
<%= form.text_field :title, :id => (@gallery.new_record?? 'slugify' : nil)%>
|
2
|
-
<%= form.text_field :slug, :id => 'slug' %>
|
3
|
-
<%= form.text_area :description%>
|
4
|
-
|
5
|
-
<%= form.text_field :full_width %>
|
6
|
-
<%= form.text_field :full_height %>
|
7
|
-
<%= form.text_field :thumb_width %>
|
8
|
-
<%= form.text_field :thumb_height %>
|
9
|
-
<%= form.check_box :force_ratio %>
|
10
|
-
|
11
|
-
<%= form.submit 'Save'%>
|
@@ -1,28 +0,0 @@
|
|
1
|
-
<%= link_to 'Add new gallery', new_gallery_admin_gallery_path, :class => 'big button' %>
|
2
|
-
|
3
|
-
<h1>Galleries</h1>
|
4
|
-
|
5
|
-
<table class='formatted'>
|
6
|
-
<% @galleries.each do |gallery| %>
|
7
|
-
<tr>
|
8
|
-
<td>
|
9
|
-
<div class='title'>
|
10
|
-
<%= link_to gallery.title, gallery_admin_gallery_photos_path(gallery) %>
|
11
|
-
</div>
|
12
|
-
<div class='sublabel'>
|
13
|
-
<%= gallery.slug %>
|
14
|
-
</div>
|
15
|
-
</td>
|
16
|
-
<td class='main'>
|
17
|
-
<% gallery.photos.limit(5).each do |photo| %>
|
18
|
-
<%= image_tag(photo.image.url(:admin_thumb)) %>
|
19
|
-
<% end %>
|
20
|
-
</td>
|
21
|
-
<td class='action_links'>
|
22
|
-
<%= link_to 'Show Photos', gallery_admin_gallery_photos_path(gallery) %>
|
23
|
-
<%= link_to 'Edit', edit_gallery_admin_gallery_path(gallery) %>
|
24
|
-
<%= link_to 'Delete', gallery_admin_gallery_path(gallery), :method => :delete, :confirm => 'Are you sure?' %>
|
25
|
-
</td>
|
26
|
-
</tr>
|
27
|
-
<% end %>
|
28
|
-
</table>
|
@@ -1,13 +0,0 @@
|
|
1
|
-
<%= form.text_field :title, :id => (@photo.new_record?? 'slugify' : nil) %>
|
2
|
-
<%= form.text_field :slug, :id => 'slug' %>
|
3
|
-
<% if @photo.image? %>
|
4
|
-
<%= form.simple_field 'Current Image' do %>
|
5
|
-
<%= image_tag(@photo.image.url(:thumb)) %>
|
6
|
-
<br/>
|
7
|
-
<%= link_to 'Crop Image', crop_gallery_admin_gallery_photo_path(@gallery, @photo) %>
|
8
|
-
<% end %>
|
9
|
-
<% end %>
|
10
|
-
<%= form.file_field :image %>
|
11
|
-
<%= form.text_area :description %>
|
12
|
-
|
13
|
-
<%= form.submit 'Save'%>
|
@@ -1,32 +0,0 @@
|
|
1
|
-
<% content_for :head do %>
|
2
|
-
<%= stylesheet_link_tag 'sofa_gallery/jquery.jcrop.css' %>
|
3
|
-
<%= javascript_include_tag 'sofa_gallery/jquery.jcrop.js' %>
|
4
|
-
<script type="text/javascript" charset="utf-8">
|
5
|
-
$(function(){
|
6
|
-
$('#cropbox').Jcrop({
|
7
|
-
onChange: update_crop,
|
8
|
-
onSelect: update_crop,
|
9
|
-
aspectRatio: <%= @photo.gallery.force_ratio?? (@photo.gallery.full_width.to_f / @photo.gallery.full_height) : 'null' %>
|
10
|
-
});
|
11
|
-
});
|
12
|
-
|
13
|
-
function update_crop(coords) {
|
14
|
-
var ratio = <%= @photo.image_geometry(:original).width %> / <%= @photo.image_geometry(:admin_full).width %>;
|
15
|
-
$('#crop_x').val(coords.x * ratio);
|
16
|
-
$('#crop_y').val(coords.y * ratio);
|
17
|
-
$('#crop_w').val(coords.w * ratio);
|
18
|
-
$('#crop_h').val(coords.h * ratio);
|
19
|
-
}
|
20
|
-
</script>
|
21
|
-
<% end %>
|
22
|
-
|
23
|
-
<h1> Crop Photo </h1>
|
24
|
-
|
25
|
-
<%= image_tag @photo.image.url(:admin_full), :id => 'cropbox' %>
|
26
|
-
|
27
|
-
<%= gallery_form_for @photo, :as => :photo, :url => { :action => :update } do |form| %>
|
28
|
-
<% [:crop_x, :crop_y, :crop_w, :crop_h].each do |attr| %>
|
29
|
-
<%= form.hidden_field attr, :id => attr %>
|
30
|
-
<% end %>
|
31
|
-
<%= form.submit 'Crop' %>
|
32
|
-
<% end %>
|
@@ -1,123 +0,0 @@
|
|
1
|
-
require File.expand_path('../test_helper', File.dirname(__FILE__))
|
2
|
-
|
3
|
-
class GalleryAdmin::PhotosControllerTest < ActionController::TestCase
|
4
|
-
|
5
|
-
def test_get_index
|
6
|
-
get :index, :gallery_id => sofa_galleries(:default)
|
7
|
-
assert_response :success
|
8
|
-
assert_template 'index'
|
9
|
-
assert assigns(:photos)
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_get_index_failure
|
13
|
-
get :index, :gallery_id => 'invalid'
|
14
|
-
assert_response :redirect
|
15
|
-
assert_redirected_to gallery_admin_galleries_path
|
16
|
-
assert_equal 'Gallery not found', flash[:error]
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_new
|
20
|
-
gallery = sofa_galleries(:default)
|
21
|
-
get :new, :gallery_id => gallery
|
22
|
-
assert_response :success
|
23
|
-
assert_template 'new'
|
24
|
-
assert assigns(:photo)
|
25
|
-
assert_select "form[action='/cms-admin/galleries/#{gallery.id}/photos']"
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_creation
|
29
|
-
assert_difference 'Sofa::Photo.count' do
|
30
|
-
post :create, :gallery_id => sofa_galleries(:default), :photo => {
|
31
|
-
:title => 'Test Photo',
|
32
|
-
:slug => 'test-photo',
|
33
|
-
:image => fixture_file_upload('/files/default.jpg', 'image/jpeg')
|
34
|
-
}
|
35
|
-
assert_response :redirect
|
36
|
-
assert_redirected_to :action => :index
|
37
|
-
assert_equal 'Photo created', flash[:notice]
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_creation_fail
|
42
|
-
assert_no_difference 'Sofa::Photo.count' do
|
43
|
-
post :create, :gallery_id => sofa_galleries(:default), :photo => { }
|
44
|
-
assert_response :success
|
45
|
-
assert_template 'new'
|
46
|
-
assert_equal 'Failed to create Photo', flash[:error]
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_get_edit
|
51
|
-
photo = sofa_photos(:default)
|
52
|
-
get :edit, :gallery_id => photo.gallery, :id => photo
|
53
|
-
assert_response :success
|
54
|
-
assert_template 'edit'
|
55
|
-
assert_select "form[action='/cms-admin/galleries/#{photo.gallery.id}/photos/#{photo.id}']"
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_get_edit_failure
|
59
|
-
get :edit, :gallery_id => sofa_galleries(:default), :id => 'invalid'
|
60
|
-
assert_response :redirect
|
61
|
-
assert_redirected_to :action => :index
|
62
|
-
assert_equal 'Photo not found', flash[:error]
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_update
|
66
|
-
photo = sofa_photos(:default)
|
67
|
-
put :update, :gallery_id => photo.gallery, :id => photo, :photo => {
|
68
|
-
:title => 'Updated Title'
|
69
|
-
}
|
70
|
-
assert_response :redirect
|
71
|
-
assert_redirected_to :action => :index
|
72
|
-
assert_equal 'Photo updated', flash[:notice]
|
73
|
-
|
74
|
-
photo.reload
|
75
|
-
assert_equal 'Updated Title', photo.title
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_update_failure
|
79
|
-
photo = sofa_photos(:default)
|
80
|
-
put :update, :gallery_id => photo.gallery, :id => photo, :photo => {
|
81
|
-
:title => 'Updated Title',
|
82
|
-
:image => fixture_file_upload('/files/default.txt', 'text/plain')
|
83
|
-
}
|
84
|
-
assert_response :success
|
85
|
-
assert_template :edit
|
86
|
-
assert_equal 'Failed to updated Photo', flash[:error]
|
87
|
-
|
88
|
-
photo.reload
|
89
|
-
assert_not_equal 'Updated Title', photo.description
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_destroy
|
93
|
-
photo = sofa_photos(:default)
|
94
|
-
assert_difference 'Sofa::Photo.count', -1 do
|
95
|
-
delete :destroy, :gallery_id => photo.gallery, :id => photo
|
96
|
-
assert_response :redirect
|
97
|
-
assert_redirected_to :action => :index
|
98
|
-
assert_equal 'Photo deleted', flash[:notice]
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_reorder
|
103
|
-
photo = sofa_photos(:default)
|
104
|
-
assert_equal 0, photo.position
|
105
|
-
xhr :post, :reorder, :gallery_id => photo.gallery, :sofa_photo => ['dummy', photo.id]
|
106
|
-
assert_response :success
|
107
|
-
|
108
|
-
photo.reload
|
109
|
-
assert_equal 1, photo.position
|
110
|
-
end
|
111
|
-
|
112
|
-
def test_get_crop
|
113
|
-
photo = sofa_photos(:default)
|
114
|
-
photo.image = fixture_file_upload('/files/default.jpg', 'image/jpeg')
|
115
|
-
photo.save!
|
116
|
-
|
117
|
-
get :crop, :gallery_id => photo.gallery, :id => photo
|
118
|
-
assert_response :success
|
119
|
-
assert_template 'crop'
|
120
|
-
assert assigns(:photo)
|
121
|
-
end
|
122
|
-
|
123
|
-
end
|