uploadify_rails 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,60 @@
1
+ // переопределить SWFUpload.completeURL нужно,
2
+ // чтобы после инициализации uploadify
3
+ // не отправлялся странный и ненужный get запрос
4
+
5
+ SWFUpload.completeURL = function(a){
6
+ return a;
7
+ }
8
+
9
+ jQuery.fn.nestedAttachmentsUploader = function(options) {
10
+ var that = this;
11
+ this.parents('form').submit(function(e) {
12
+ options.uploadsContainer.each(function() {
13
+ $(this).find('.fields').each(function(index) {
14
+ $(this).find('input').each(function() {
15
+ var inputName = $(this).attr('name');
16
+ if (inputName.search(/^[_a-z]+$/) !== -1) {
17
+ // если файл был только что добавлен
18
+ $(this).attr('name', options.ownerName + '[' + options.nestedName + '_attributes][' + index + '][' + inputName + ']');
19
+ } else {
20
+ // если файл был изначально
21
+ var nameParts = inputName.split('][');
22
+ nameParts[1] = index;
23
+ $(this).attr('name', nameParts.join(']['));
24
+ }
25
+ });
26
+ });
27
+ });
28
+ });
29
+
30
+ var csrf_token = $('meta[name=csrf-token]').attr('content');
31
+
32
+ this.uploadify({
33
+ swf: '/assets/uploadify.swf',
34
+ uploader: that.data('uploader'),
35
+ formData: {
36
+ authenticity_token: csrf_token,
37
+ _session_id: session_id
38
+ },
39
+ overrideEvents: ['onUploadSuccess'],
40
+ onUploadSuccess: function(file, data, response) {
41
+ $('#' + file.id).find('.data').html(' - Загрузка завершена');
42
+ options.uploadsContainer.append(data);
43
+ },
44
+ onUploadError: function(file, errorCode, errorMsg, errorString) {
45
+ },
46
+ onInit: function(instance) {
47
+ // После инициализации padding кнопки
48
+ // зачем-то устанавливается равным 10px,
49
+ // исправляем это:
50
+ $(that.selector).find('.uploadify-button').css({
51
+ 'padding': 0,
52
+ 'padding-left': '30px'
53
+ });
54
+ },
55
+ buttonText: 'Добавить фотографии',
56
+ buttonClass: 'button',
57
+ width: 160,
58
+ height: 30
59
+ });
60
+ }
@@ -0,0 +1,25 @@
1
+ //= require jquery.uploadify.js
2
+ //= require nested_attachments_uploader.js
3
+ //= require_self
4
+
5
+ function add_nested_resources() {
6
+ $('#add-nested-resources').nestedAttachmentsUploader({
7
+ uploadsContainer: $('#nested_resources')
8
+ });
9
+ };
10
+
11
+ function delete_nested_resource() {
12
+ $("#nested_resources a.delete").live("click", function(){
13
+ var link = $(this);
14
+ var id = link.attr("id");
15
+ var url = "/" + id.replace("_", "/");
16
+ $.post(url, function(data) {
17
+ link.parents(".fields:first").remove();
18
+ });
19
+ });
20
+ };
21
+
22
+ $(document).ready(function(){
23
+ add_nested_resources();
24
+ delete_nested_resource();
25
+ });
@@ -0,0 +1,107 @@
1
+ .fields {
2
+ margin-bottom: 15px;
3
+ }
4
+
5
+ .uploaded-container {
6
+ display: inline-block;
7
+ width: 112px;
8
+ }
9
+
10
+ .uploaded-container img {
11
+ margin-bottom:0;
12
+ }
13
+
14
+ .uploaded-info {
15
+ display: inline-block;
16
+ margin-left: 10px;
17
+ vertical-align: top;
18
+ width: 400px;
19
+ }
20
+
21
+ .uploaded-info div {
22
+ margin: 0 0 10px 0;
23
+ }
24
+
25
+ .uploaded-info a.delete {
26
+ margin-left: 0;
27
+ }
28
+
29
+ .formtastic .uploadify.input .label {
30
+ display:none !important;
31
+ }
32
+
33
+ .uploadify-button {
34
+ background: url('/assets/add.gif') no-repeat left 50%;
35
+ color: #1A3DC1;
36
+ font-family: Arial, Helvetica, sans-serif;
37
+ font-size: 12px;
38
+ font-weight: normal;
39
+ height: 22px;
40
+ max-width: 350px;
41
+ padding: 10px;
42
+ cursor:pointer;
43
+ }
44
+
45
+ .uploadify:hover .uploadify-button {
46
+ cursor: pointer;
47
+ text-decoration: underline;
48
+ }
49
+
50
+ .add-nested-resources {
51
+ margin: 0 0 10px 0;
52
+ }
53
+
54
+ .swfupload {
55
+ left: 25%;
56
+ }
57
+
58
+ .formtastic li.uploadify {
59
+ padding-left:25%;
60
+ }
61
+
62
+ .formtastic li.uploadify.input .inline-hints {
63
+ margin: 0.5em 0 0 0;
64
+ }
65
+
66
+ .uploadify-queue {
67
+ margin-bottom: 1em;
68
+ }
69
+
70
+ .uploadify-queue-item {
71
+ background-color: #F5F5F5;
72
+ -webkit-border-radius: 3px;
73
+ -moz-border-radius: 3px;
74
+ border-radius: 3px;
75
+ font: 11px Verdana, Geneva, sans-serif;
76
+ margin-top: 5px;
77
+ max-width: 350px;
78
+ padding: 10px;
79
+ }
80
+
81
+ .uploadify-error {
82
+ background-color: #FDE5DD !important;
83
+ }
84
+
85
+ .uploadify-queue-item .cancel a {
86
+ background: url(/assets/remove.gif) 0 0 no-repeat;
87
+ float: right;
88
+ height: 16px;
89
+ text-indent: -9999px;
90
+ width: 16px;
91
+ }
92
+
93
+ .uploadify-queue-item.completed {
94
+ background-color: #E5E5E5;
95
+ }
96
+
97
+ .uploadify-progress {
98
+ background-color: #E5E5E5;
99
+ margin-top: 10px;
100
+ width: 100%;
101
+ }
102
+
103
+ .uploadify-progress-bar {
104
+ background-color: #0099FF;
105
+ height: 3px;
106
+ width: 1px;
107
+ }
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: uploadify_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.12
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Andrey
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: mime-types
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '1.21'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '1.21'
30
+ - !ruby/object:Gem::Dependency
31
+ name: flash_cookie_session
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 1.1.4
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.1.4
46
+ - !ruby/object:Gem::Dependency
47
+ name: nested_form
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 0.3.1
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.3.1
62
+ - !ruby/object:Gem::Dependency
63
+ name: renderer
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: 0.0.14
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 0.0.14
78
+ description: Rails 3 multi upload with flash based Uploadify and Rails assets pipeline
79
+ email:
80
+ - railscode@gmail.com
81
+ executables: []
82
+ extensions: []
83
+ extra_rdoc_files: []
84
+ files:
85
+ - .gitignore
86
+ - Gemfile
87
+ - LICENSE.txt
88
+ - README.md
89
+ - Rakefile
90
+ - app/views/shared/uploadify/photos/_fields.html.erb
91
+ - app/views/shared/uploadify/photos/_form.html.erb
92
+ - lib/uploadify_rails.rb
93
+ - lib/uploadify_rails/controllers/base.rb
94
+ - lib/uploadify_rails/engine.rb
95
+ - lib/uploadify_rails/hooks/formtastic.rb
96
+ - lib/uploadify_rails/models/parent.rb
97
+ - lib/uploadify_rails/models/resource.rb
98
+ - lib/uploadify_rails/version.rb
99
+ - uploadify_rails.gemspec
100
+ - vendor/assets/flash/uploadify.swf
101
+ - vendor/assets/images/add.gif
102
+ - vendor/assets/images/remove.gif
103
+ - vendor/assets/javascripts/jquery.uploadify.js
104
+ - vendor/assets/javascripts/nested_attachments_uploader.js
105
+ - vendor/assets/javascripts/uploadify.js
106
+ - vendor/assets/stylesheets/uploadify.css
107
+ homepage: https://github.com/vav/uploadify_rails
108
+ licenses: []
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 1.8.23
128
+ signing_key:
129
+ specification_version: 3
130
+ summary: Rails 3 multi upload with flash based Uploadify and Rails assets pipeline
131
+ test_files: []