spud_photos 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,19 +14,26 @@ Spud.Admin.Photos = new function(){
14
14
  $('body').on('submit', '#spud_admin_photo_album_form', self.submittedPhotoAlbumForm);
15
15
  $('body').on('submit', '#spud_admin_photo_gallery_form', self.submittedPhotoGalleryForm);
16
16
  $('body').on('submit', '#spud_admin_photo_form', self.submittedPhotoForm);
17
- $('body').on('click', '.spud_admin_photos_btn_remove', self.clickedPhotoRemoveFromLibrary)
17
+ $('body').on('click', '.spud_admin_photos_btn_remove', self.clickedPhotoRemoveFromAlbum)
18
18
  $('body').on('click', '.spud_admin_photo_ui_thumbs_selectable .spud_admin_photo_ui_thumb', self.selectedPhotoUiThumb);
19
19
  $('body').on('click', '#spud_admin_photo_album_action_library', self.clickedPhotoLibrary);
20
+ $('body').on('click', '#spud_admin_photo_album_action_upload, .spud_admin_photo .spud_admin_photos_btn_edit', self.clickedPhotoAddOrEdit);
20
21
 
21
22
  // html5 drag and drop file
22
- if(typeof(FormData) != 'undefined' && typeof(XMLHttpRequest) != 'undefined'){
23
+ if(typeof(FormData) != 'undefined' && typeof(XMLHttpRequest) != 'undefined' && (droparea = document.getElementById('spud_admin_photo_upload_queue'))){
23
24
  html5upload = true;
24
25
  $('#spud_admin_photo_upload_queue').show();
25
- var droparea = document.getElementById('spud_admin_photo_upload_queue');
26
26
  droparea.addEventListener('dragenter', self.stopDndPropagation, false);
27
27
  droparea.addEventListener('dragexit', self.stopDndPropagation, false);
28
28
  droparea.addEventListener('dragover', self.stopDndPropagation, false);
29
29
  droparea.addEventListener('drop', self.droppedFile, false);
30
+
31
+ // prevent accidental drops outside the queue
32
+ var body = document.getElementsByTagName("body")[0];
33
+ body.addEventListener('dragenter', self.stopDndPropagation, false);
34
+ body.addEventListener('dragexit', self.stopDndPropagation, false);
35
+ body.addEventListener('dragover', self.stopDndPropagation, false);
36
+ body.addEventListener('drop', self.stopDndPropagation, false);
30
37
  }
31
38
  };
32
39
 
@@ -38,10 +45,11 @@ Spud.Admin.Photos = new function(){
38
45
  $('#spud_admin_photo_albums_available .spud_admin_photo_ui_thumb').remove();
39
46
  }
40
47
 
41
- this.clickedPhotoRemoveFromLibrary = function(e){
48
+ this.clickedPhotoRemoveFromAlbum = function(e){
42
49
  $(this).parents('.spud_admin_photo_ui_thumb').fadeOut(200, function(){
43
50
  $(this).remove();
44
51
  });
52
+ return false;
45
53
  };
46
54
 
47
55
  /* Handle file uploads passed via iframe (legacy support)
@@ -54,10 +62,10 @@ Spud.Admin.Photos = new function(){
54
62
  this.photoLegacyUploadComplete = function(id, html){
55
63
  var element = $('#spud_admin_photo_' + id);
56
64
  if(element.length > 0){
57
- element.replaceWith(htmlhtml);
65
+ element.replaceWith(html);
58
66
  }
59
67
  else{
60
- var target = $('#spud_admin_photos_selected .spud_admin_photo_ui_thumbs, #spud_admin_photos');
68
+ var target = $('#spud_admin_photos_selected, #spud_admin_photos');
61
69
  target.prepend(html).fadeIn(200);
62
70
  }
63
71
  $('#dialog').dialog('close');
@@ -99,6 +107,10 @@ Spud.Admin.Photos = new function(){
99
107
  -------------------------------- */
100
108
 
101
109
  this.submittedPhotoForm = function(e){
110
+ // disable submit button
111
+ var submit = $(this).find('input[type=submit]');
112
+ submit.attr('disabled', 'disabled').val(submit.attr('data-loading-text'));
113
+
102
114
  if(html5upload){
103
115
  // create a FormData object and attach form values
104
116
  var fd = new FormData();
@@ -189,6 +201,33 @@ Spud.Admin.Photos = new function(){
189
201
  progressBar.find('.progress').addClass('progress-danger');
190
202
  };
191
203
 
204
+ /*
205
+ * Photo Upload/Edit Form
206
+ ------------------------------- */
207
+ this.clickedPhotoAddOrEdit = function(e){
208
+ var url = this.href;
209
+ $.ajax({
210
+ url:url,
211
+ success:self.photoUploadFormLoaded
212
+ });
213
+ return false;
214
+ };
215
+
216
+ this.photoUploadFormLoaded = function(html){
217
+ var dialog = $("#dialog");
218
+ if(dialog.length == 0){
219
+ dialog = $('<div id="dialog" style="display:hidden;"></div>').appendTo('body');
220
+ }
221
+ dialog.html(html);
222
+ dialog.dialog({
223
+ width: 500,
224
+ modal: true,
225
+ height: 'auto',
226
+ title: 'Upload Photo',
227
+ buttons: {}
228
+ });
229
+ };
230
+
192
231
  /*
193
232
  * Add From Photo Library
194
233
  ------------------------------- */
@@ -19,7 +19,7 @@ class SpudPhoto < ActiveRecord::Base
19
19
  def dynamic_styles
20
20
  admin_styles = {
21
21
  :spud_admin_small => '125x125#',
22
- :spud_admin_medium => '300x300'
22
+ :spud_admin_medium => '300x200'
23
23
  }
24
24
  return admin_styles.merge(Spud::Photos.config.photo_styles)
25
25
  end
@@ -16,7 +16,7 @@
16
16
  <legend>Selected Photos</legend>
17
17
  <div id="spud_admin_photo_album_actions" class="control-group">
18
18
  <%= link_to "Photo Library", spud_admin_photos_path, :class => "btn btn-primary", :id => 'spud_admin_photo_album_action_library' %>
19
- <%= link_to "Upload Photo", new_spud_admin_photo_path, :class => "ajax btn btn-success", :title => "New Photo" %>
19
+ <%= link_to "Upload Photo", new_spud_admin_photo_path, :class => "btn btn-success", :id => 'spud_admin_photo_album_action_upload' %>
20
20
  </div>
21
21
  <div id="spud_admin_photo_upload_queue">
22
22
  <p>Drag and drop photos here to upload</p>
@@ -2,12 +2,12 @@
2
2
  :rel => photo.id,
3
3
  :id => "spud_admin_photo_#{photo.id}",
4
4
  :style => "background-image:url('#{photo.photo.url(:spud_admin_small)}')",
5
- :class => "spud_admin_photo_ui_thumb spud_admin_photo_ui_thumb_small" do %>
5
+ :class => "spud_admin_photo_ui_thumb spud_admin_photo_ui_thumb_small spud_admin_photo" do %>
6
6
  <div style="display:none;">
7
7
  <%= hidden_field_tag 'spud_photo_album[photo_ids][]', photo.id %>
8
8
  </div>
9
9
  <div class="spud_admin_photo_ui_thumb_controls">
10
- <%= link_to 'Edit', edit_spud_admin_photo_path(photo), :class => 'ajax spud_admin_photos_btn_edit' %>
10
+ <%= link_to 'Edit', edit_spud_admin_photo_path(photo), :class => 'spud_admin_photos_btn_edit' %>
11
11
  <%= link_to 'Delete', '#', :class => 'spud_admin_photos_btn_remove' %>
12
12
  </div>
13
13
  <% end %>
@@ -1,5 +1,5 @@
1
1
  module Spud
2
2
  module Photos
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spud_photos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-04-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70246767895340 !ruby/object:Gem::Requirement
16
+ requirement: &70132753170220 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.2.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70246767895340
24
+ version_requirements: *70132753170220
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: spud_core
27
- requirement: &70246767894420 !ruby/object:Gem::Requirement
27
+ requirement: &70132753162720 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -35,10 +35,10 @@ dependencies:
35
35
  version: 0.9.0
36
36
  type: :runtime
37
37
  prerelease: false
38
- version_requirements: *70246767894420
38
+ version_requirements: *70132753162720
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: paperclip
41
- requirement: &70246767893080 !ruby/object:Gem::Requirement
41
+ requirement: &70132753161700 !ruby/object:Gem::Requirement
42
42
  none: false
43
43
  requirements:
44
44
  - - ! '>='
@@ -46,10 +46,10 @@ dependencies:
46
46
  version: '0'
47
47
  type: :runtime
48
48
  prerelease: false
49
- version_requirements: *70246767893080
49
+ version_requirements: *70132753161700
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: mysql2
52
- requirement: &70246767891900 !ruby/object:Gem::Requirement
52
+ requirement: &70132753160860 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
55
55
  - - ! '>='
@@ -57,7 +57,7 @@ dependencies:
57
57
  version: '0'
58
58
  type: :development
59
59
  prerelease: false
60
- version_requirements: *70246767891900
60
+ version_requirements: *70132753160860
61
61
  description: Spud Photos is a feature complete photo management/gallery for the spud
62
62
  engine. Manage multiple galleries, albums, and photos. Use HTML 5 to drag and drop
63
63
  many images at once.
@@ -72,9 +72,7 @@ files:
72
72
  - app/assets/images/spud/photos/photo_albums_thumb.png
73
73
  - app/assets/images/spud/photos/photo_albums_thumb@2x.png
74
74
  - app/assets/javascripts/spud/admin/photos.js
75
- - app/assets/javascripts/spud_photos.js
76
75
  - app/assets/stylesheets/spud/admin/photos.css
77
- - app/assets/stylesheets/spud_photos.css
78
76
  - app/controllers/photo_albums_controller.rb
79
77
  - app/controllers/photo_galleries_controller.rb
80
78
  - app/controllers/spud/admin/photo_albums_controller.rb
@@ -169,7 +167,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
169
167
  version: '0'
170
168
  segments:
171
169
  - 0
172
- hash: -1394536087294010782
170
+ hash: -1093842542963525914
173
171
  required_rubygems_version: !ruby/object:Gem::Requirement
174
172
  none: false
175
173
  requirements:
@@ -178,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
176
  version: '0'
179
177
  segments:
180
178
  - 0
181
- hash: -1394536087294010782
179
+ hash: -1093842542963525914
182
180
  requirements: []
183
181
  rubyforge_project:
184
182
  rubygems_version: 1.8.10
@@ -1,74 +0,0 @@
1
- spud_photos = new function(){
2
-
3
- var self = this;
4
- var transition;
5
-
6
- this.init = function(){
7
- transition = new spud_photos.transitions.slide('#spud_photo_showcase');
8
- $('#spud_photo_album_photos').on('click', 'a', self.clickedPhoto);
9
- };
10
-
11
- this.clickedPhoto = function(e){
12
- e.preventDefault();
13
- transition.transition($(this).attr('href'));
14
- };
15
- };
16
-
17
- spud_photos.transitions = {};
18
-
19
- spud_photos.transitions.fade = function(_container, _firstPhoto){
20
-
21
- var self = this;
22
- var z_index = 100;
23
- var container = $(_container);
24
-
25
- this.transition = function(photo){
26
- z_index++;
27
- var image = $('<img/>', {
28
- src:photo,
29
- style:'position:absolute;left:0;top:0;z-index:'+z_index
30
- });
31
- container.trigger('spud:photos:transitionStart');
32
- container.append(image);
33
- image.hide().fadeIn(200, self.fadeCompleted);
34
- };
35
-
36
- this.fadeCompleted = function(e){
37
- var imgs = container.find('img');
38
- if(imgs.length > 1){
39
- $(imgs[0]).remove();
40
- }
41
- container.trigger('spud:photos:transitionComplete');
42
- };
43
- };
44
-
45
- spud_photos.transitions.slide = function(_container, _firstPhoto){
46
-
47
- var self = this;
48
- var container = $(_container);
49
- var slider = $('<div/>', {
50
- id:'spud_photos_transition_slider',
51
- style:'position:absolute;left:0;top:0;width:400px;height:800px'
52
- });
53
- container.append(slider);
54
-
55
- this.transition = function(photo){
56
- console.log('transition slider');
57
- var image = $('<img/>', {
58
- src:photo,
59
- style:'display:block'
60
- });
61
- container.trigger('spud:photos:transitionStart');
62
- slider.append(image);
63
- slider.animate({top:-400}, 500, self.slideCompleted);
64
- };
65
-
66
- this.slideCompleted = function(e){
67
- var imgs = container.find('img');
68
- if(imgs.length > 1){
69
- $(imgs[0]).remove();
70
- }
71
- slider.css('top', 0);
72
- container.trigger('spud:photos:transitionComplete');
73
- };
74
- }
File without changes