attachinary 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -63,7 +63,10 @@ If you're using [SimpleForm](https://github.com/plataformatec/simple_form), you
63
63
 
64
64
  Finally, you have to include `attachinary` into your asset pipeline. In your `application.js`, add following line:
65
65
 
66
+ ...
67
+ //= require cloudinary
66
68
  //= require attachinary
69
+ ...
67
70
 
68
71
  And, add this code on document ready:
69
72
 
@@ -19,8 +19,16 @@ module Attachinary
19
19
  # attr_accessible :photo_id, :photo_file
20
20
  attr_accessible :"#{scope}_id", :"#{scope}_file" if options[:accessible]
21
21
 
22
- # attr_accessor :photo
23
- attr_accessor :"#{scope}"
22
+ # attr_writer :photo
23
+ attr_writer :"#{scope}"
24
+
25
+ # def photo
26
+ # @photo ||= photo_attachment_file
27
+ # end
28
+ define_method :"#{scope}" do
29
+ instance_variable_set :"@#{scope}",
30
+ (instance_variable_get(:"@#{scope}") || send(:"#{scope}_attachment_file"))
31
+ end
24
32
 
25
33
  # def photo_id=(id)
26
34
  # photo = ::Attachinary::File.find_by_id(id)
@@ -50,18 +58,6 @@ module Attachinary
50
58
  send(:"#{scope}").present?
51
59
  end
52
60
 
53
-
54
- # after_initialize do
55
- # unless photo?
56
- # photo = photo_attachment_file
57
- # end
58
- # end
59
- after_initialize do
60
- unless send(:"#{scope}?")
61
- send(:"#{scope}=", send(:"#{scope}_attachment_file"))
62
- end
63
- end
64
-
65
61
  # before_save do
66
62
  # photo_attachment_file = photo
67
63
  # end
@@ -104,8 +100,16 @@ module Attachinary
104
100
  # attr_accessible :image_ids, :image_files
105
101
  attr_accessible :"#{singular}_ids", :"#{singular}_files" if options[:accessible]
106
102
 
107
- # attr_accessor :images
108
- attr_accessor :"#{scope}"
103
+ # attr_writer :images
104
+ attr_writer :"#{scope}"
105
+
106
+ # def images
107
+ # @images ||= image_attachment_files
108
+ # end
109
+ define_method :"#{scope}" do
110
+ instance_variable_set :"@#{scope}",
111
+ (instance_variable_get(:"@#{scope}") || send(:"#{singular}_attachment_files"))
112
+ end
109
113
 
110
114
  # def image_ids=(ids)
111
115
  # files = [ids].flatten.compact.uniq.reject(&:blank?) do |id|
@@ -143,18 +147,6 @@ module Attachinary
143
147
  send(:"#{scope}").present?
144
148
  end
145
149
 
146
-
147
- # after_initialize do
148
- # unless images?
149
- # images = image_attachment_files
150
- # end
151
- # end
152
- after_initialize do
153
- unless send(:"#{scope}?")
154
- send(:"#{scope}=", send(:"#{singular}_attachment_files"))
155
- end
156
- end
157
-
158
150
  # before_save do
159
151
  # image_attachment_files = images
160
152
  # end
@@ -1,3 +1,3 @@
1
1
  module Attachinary
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -1,3 +1,8 @@
1
+ #= require cloudinary/jquery.ui.widget
2
+ #= require cloudinary/jquery.iframe-transport
3
+ #= require cloudinary/jquery.fileupload
4
+ #= require cloudinary/jquery.cloudinary
5
+
1
6
  (($) ->
2
7
 
3
8
  $.attachinary =
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attachinary
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
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-07-01 00:00:00.000000000Z
12
+ date: 2012-07-10 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70206836403480 !ruby/object:Gem::Requirement
16
+ requirement: &70349861908400 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,21 +21,21 @@ dependencies:
21
21
  version: '3.2'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70206836403480
24
+ version_requirements: *70349861908400
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: cloudinary
27
- requirement: &70206836399800 !ruby/object:Gem::Requirement
27
+ requirement: &70349861907900 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: 1.0.24
32
+ version: 1.0.29
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70206836399800
35
+ version_requirements: *70349861907900
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sqlite3
38
- requirement: &70206836394780 !ruby/object:Gem::Requirement
38
+ requirement: &70349861907520 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70206836394780
46
+ version_requirements: *70349861907520
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec-rails
49
- requirement: &70206836390720 !ruby/object:Gem::Requirement
49
+ requirement: &70349861906980 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '2.5'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70206836390720
57
+ version_requirements: *70349861906980
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: valid_attribute
60
- requirement: &70206836389400 !ruby/object:Gem::Requirement
60
+ requirement: &70349861906560 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70206836389400
68
+ version_requirements: *70349861906560
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: capybara
71
- requirement: &70206836388560 !ruby/object:Gem::Requirement
71
+ requirement: &70349861906100 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70206836388560
79
+ version_requirements: *70349861906100
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: factory_girl_rails
82
- requirement: &70206836387000 !ruby/object:Gem::Requirement
82
+ requirement: &70349861905600 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '3.0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70206836387000
90
+ version_requirements: *70349861905600
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: webmock
93
- requirement: &70206836385300 !ruby/object:Gem::Requirement
93
+ requirement: &70349861905180 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70206836385300
101
+ version_requirements: *70349861905180
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: launchy
104
- requirement: &70206836383940 !ruby/object:Gem::Requirement
104
+ requirement: &70349861990720 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70206836383940
112
+ version_requirements: *70349861990720
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: guard-rspec
115
- requirement: &70206836382220 !ruby/object:Gem::Requirement
115
+ requirement: &70349861990300 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,7 +120,7 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70206836382220
123
+ version_requirements: *70349861990300
124
124
  description: Attachments handler for Rails that uses Cloudinary for storage.
125
125
  email:
126
126
  - milovan.zogovic@gmail.com
@@ -141,12 +141,7 @@ files:
141
141
  - lib/attachinary/version.rb
142
142
  - lib/attachinary/view_helpers.rb
143
143
  - lib/attachinary.rb
144
- - vendor/assets/javascripts/attachinary/jquery.attachinary.js.coffee
145
- - vendor/assets/javascripts/attachinary/jquery.cloudinary.js
146
- - vendor/assets/javascripts/attachinary/jquery.fileupload.js
147
- - vendor/assets/javascripts/attachinary/jquery.iframe-transport.js
148
- - vendor/assets/javascripts/attachinary/jquery.ui.widget.js
149
- - vendor/assets/javascripts/attachinary.js
144
+ - vendor/assets/javascripts/attachinary.js.coffee
150
145
  - MIT-LICENSE
151
146
  - Rakefile
152
147
  - README.md
@@ -164,7 +159,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
164
159
  version: '0'
165
160
  segments:
166
161
  - 0
167
- hash: 2034714051279982992
162
+ hash: -2112842538813240156
168
163
  required_rubygems_version: !ruby/object:Gem::Requirement
169
164
  none: false
170
165
  requirements:
@@ -173,11 +168,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
168
  version: '0'
174
169
  segments:
175
170
  - 0
176
- hash: 2034714051279982992
171
+ hash: -2112842538813240156
177
172
  requirements: []
178
173
  rubyforge_project:
179
174
  rubygems_version: 1.8.10
180
175
  signing_key:
181
176
  specification_version: 3
182
- summary: attachinary-0.0.5
177
+ summary: attachinary-0.0.6
183
178
  test_files: []
@@ -1,5 +0,0 @@
1
- //= require ./attachinary/jquery.ui.widget
2
- //= require ./attachinary/jquery.iframe-transport
3
- //= require ./attachinary/jquery.fileupload
4
- //= require ./attachinary/jquery.cloudinary
5
- //= require ./attachinary/jquery.attachinary
@@ -1,311 +0,0 @@
1
- /*
2
- * Cloudinary's jQuery library - v1.0.1
3
- * Copyright Cloudinary
4
- * see https://github.com/cloudinary/cloudinary_js
5
- */
6
-
7
- (function( $ ) {
8
- var SHARED_CDN = "d3jpl91pxevbkh.cloudfront.net";
9
- function option_consume(options, option_name, default_value) {
10
- var result = options[option_name];
11
- delete options[option_name];
12
- return typeof(result) == 'undefined' ? default_value : result;
13
- }
14
- function build_array(arg) {
15
- return $.isArray(arg) ? arg : [arg];
16
- }
17
- function present(value) {
18
- return typeof value != 'undefined' && ("" + value).length > 0;
19
- }
20
- function generate_transformation_string(options) {
21
- var width = options['width'];
22
- var height = options['height'];
23
- var size = option_consume(options, 'size');
24
- if (size) {
25
- var split_size = size.split("x");
26
- options['width'] = width = split_size[0];
27
- options['height'] = height = split_size[1];
28
- }
29
- if (width && parseFloat(width) < 1) delete options['width'];
30
- if (height && parseFloat(height) < 1) delete options['height'];
31
-
32
- var crop = option_consume(options, 'crop');
33
- if (!crop) width = height = undefined;
34
-
35
- var background = option_consume(options, 'background');
36
- background = background && background.replace(/^#/, 'rgb:');
37
-
38
- var base_transformations = build_array(option_consume(options, 'transformation', []));
39
- var named_transformation = [];
40
- if ($.grep(base_transformations, function(bs) {return typeof(bs) == 'object';}).length > 0) {
41
- base_transformations = $.map(base_transformations, function(base_transformation) {
42
- return typeof(base_transformation) == 'object' ? generate_transformation_string($.extend({}, base_transformation)) : generate_transformation_string({transformation: base_transformation});
43
- });
44
- } else {
45
- named_transformation = base_transformations.join(".");
46
- base_transformations = [];
47
- }
48
- var effect = option_consume(options, "effect");
49
- if ($.isArray(effect)) effect = effect.join(":");
50
-
51
- var params = [['c', crop], ['t', named_transformation], ['w', width], ['h', height], ['b', background], ['e', effect]];
52
- var simple_params = {
53
- x: 'x',
54
- y: 'y',
55
- radius: 'r',
56
- gravity: 'g',
57
- quality: 'q',
58
- prefix: 'p',
59
- default_image: 'd',
60
- angle: 'a',
61
- overlay: 'l',
62
- fetch_format: 'f'
63
- };
64
- for (var param in simple_params) {
65
- params.push([simple_params[param], option_consume(options, param)]);
66
- }
67
- params.sort(function(a, b){return a[0]<b[0] ? -1 : (a[0]>b[0] ? 1 : 0);});
68
- params.push([option_consume(options, 'raw_transformation')]);
69
- var transformation = $.map($.grep(params, function(param) {
70
- var value = param[param.length-1];
71
- return present(value);
72
- }), function(param) {
73
- return param.join("_");
74
- }).join(",");
75
- base_transformations.push(transformation);
76
- return $.grep(base_transformations, present).join("/");
77
- }
78
- var dummyImg = undefined;
79
- function absolutize(url) {
80
- if (!dummyImg) dummyImg = document.createElement("img");
81
- dummyImg.src = url;
82
- url = dummyImg.src;
83
- dummyImg.src = null;
84
- return url;
85
- }
86
- function cloudinary_url(public_id, options) {
87
- options = options || {};
88
- var type = option_consume(options, 'type', 'upload');
89
- if (type == 'fetch') {
90
- options.fetch_format = options.fetch_format || option_consume(options, 'format');
91
- }
92
- var transformation = generate_transformation_string(options);
93
- var resource_type = option_consume(options, 'resource_type', "image");
94
- var version = option_consume(options, 'version');
95
- var format = option_consume(options, 'format');
96
- var cloud_name = option_consume(options, 'cloud_name', $.cloudinary.config().cloud_name);
97
- if (!cloud_name) throw "Unknown cloud_name";
98
- var private_cdn = option_consume(options, 'private_cdn', $.cloudinary.config().private_cdn);
99
- var secure_distribution = option_consume(options, 'secure_distribution', $.cloudinary.config().secure_distribution);
100
- var secure = window.location.protocol == 'https:';
101
- if (secure && !secure_distribution) {
102
- if (private_cdn) {
103
- throw "secure_distribution not defined";
104
- } else {
105
- secure_distribution = SHARED_CDN;
106
- }
107
- }
108
- if (type == 'fetch') {
109
- public_id = absolutize(public_id);
110
- } else if (public_id.match(/^https?:/)) {
111
- return public_id;
112
- } else if (format) {
113
- public_id += "." + format;
114
- }
115
- if (type == 'fetch' || type == 'asset') public_id = encodeURIComponent(public_id).replace(/%3A/g, ':').replace(/%2F/g, '/');
116
-
117
- prefix = window.location.protocol + "//";
118
- var subdomain = $.cloudinary.config().cdn_subdomain ? "a" + ((crc32(public_id) % 5) + 1) + "." : "";
119
- if (private_cdn) {
120
- prefix += secure ? secure_distribution : subdomain + cloud_name + "-res.cloudinary.com";
121
- } else {
122
- prefix += (secure ? secure_distribution : subdomain + "res.cloudinary.com") + "/" + cloud_name;
123
- }
124
- var url = [prefix, resource_type, type, transformation, version ? "v" + version : "",
125
- public_id].join("/").replace(/([^:])\/+/g, '$1/');
126
- return url;
127
- }
128
- function html_only_attributes(options) {
129
- var width = option_consume(options, 'html_width');
130
- var height = option_consume(options, 'html_height');
131
- if (width) options['width'] = width;
132
- if (height) options['height'] = height;
133
- }
134
- var cloudinary_config = undefined;
135
- $.cloudinary = {
136
- config: function(new_config, new_value) {
137
- if (!cloudinary_config) {
138
- cloudinary_config = {};
139
- $('meta[name^="cloudinary_"]').each(function() {
140
- cloudinary_config[$(this).attr('name').replace("cloudinary_", '')] = $(this).attr('content');
141
- });
142
- }
143
- if (typeof(new_value) != 'undefined') {
144
- cloudinary_config[new_config] = new_value;
145
- } else if (typeof(new_config) == 'string') {
146
- return cloudinary_config[new_config];
147
- } else if (new_config) {
148
- cloudinary_config = new_config;
149
- }
150
- return cloudinary_config;
151
- },
152
- url: function(public_id, options) {
153
- options = $.extend({}, options);
154
- return cloudinary_url(public_id, options);
155
- },
156
- url_internal: cloudinary_url,
157
- image: function(public_id, options) {
158
- options = $.extend({}, options);
159
- var url = cloudinary_url(public_id, options);
160
- html_only_attributes(options);
161
- return $('<img/>').attr(options).attr('src', url);
162
- },
163
- facebook_profile_image: function(public_id, options) {
164
- return $.cloudinary.image(public_id, $.extend({type: 'facebook'}, options));
165
- },
166
- twitter_profile_image: function(public_id, options) {
167
- return $.cloudinary.image(public_id, $.extend({type: 'twitter'}, options));
168
- },
169
- twitter_name_profile_image: function(public_id, options) {
170
- return $.cloudinary.image(public_id, $.extend({type: 'twitter_name'}, options));
171
- },
172
- fetch_image: function(public_id, options) {
173
- return $.cloudinary.image(public_id, $.extend({type: 'fetch'}, options));
174
- },
175
- };
176
- $.fn.cloudinary = function(options) {
177
- this.filter('img').each(function() {
178
- var img_options = $.extend({width: $(this).attr('width'), height: $(this).attr('height'),
179
- src: $(this).attr('src')},
180
- $.extend($(this).data(), options));
181
- var public_id = option_consume(img_options, 'source', option_consume(img_options, 'src'));
182
- var url = cloudinary_url(public_id, img_options);
183
- html_only_attributes(img_options);
184
- $(this).attr({src: url, width: img_options['width'], height: img_options['height']});
185
- });
186
- return this;
187
- };
188
- $.fn.fetchify = function(options) {
189
- return this.cloudinary($.extend(options, {'type': 'fetch'}));
190
- };
191
- })( jQuery );
192
-
193
-
194
- function utf8_encode (argString) {
195
- // http://kevin.vanzonneveld.net
196
- // + original by: Webtoolkit.info (http://www.webtoolkit.info/)
197
- // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
198
- // + improved by: sowberry
199
- // + tweaked by: Jack
200
- // + bugfixed by: Onno Marsman
201
- // + improved by: Yves Sucaet
202
- // + bugfixed by: Onno Marsman
203
- // + bugfixed by: Ulrich
204
- // + bugfixed by: Rafal Kukawski
205
- // + improved by: kirilloid
206
- // * example 1: utf8_encode('Kevin van Zonneveld');
207
- // * returns 1: 'Kevin van Zonneveld'
208
-
209
- if (argString === null || typeof argString === "undefined") {
210
- return "";
211
- }
212
-
213
- var string = (argString + ''); // .replace(/\r\n/g, "\n").replace(/\r/g, "\n");
214
- var utftext = '',
215
- start, end, stringl = 0;
216
-
217
- start = end = 0;
218
- stringl = string.length;
219
- for (var n = 0; n < stringl; n++) {
220
- var c1 = string.charCodeAt(n);
221
- var enc = null;
222
-
223
- if (c1 < 128) {
224
- end++;
225
- } else if (c1 > 127 && c1 < 2048) {
226
- enc = String.fromCharCode((c1 >> 6) | 192, (c1 & 63) | 128);
227
- } else {
228
- enc = String.fromCharCode((c1 >> 12) | 224, ((c1 >> 6) & 63) | 128, (c1 & 63) | 128);
229
- }
230
- if (enc !== null) {
231
- if (end > start) {
232
- utftext += string.slice(start, end);
233
- }
234
- utftext += enc;
235
- start = end = n + 1;
236
- }
237
- }
238
-
239
- if (end > start) {
240
- utftext += string.slice(start, stringl);
241
- }
242
-
243
- return utftext;
244
- }
245
-
246
- function crc32 (str) {
247
- // http://kevin.vanzonneveld.net
248
- // + original by: Webtoolkit.info (http://www.webtoolkit.info/)
249
- // + improved by: T0bsn
250
- // + improved by: http://stackoverflow.com/questions/2647935/javascript-crc32-function-and-php-crc32-not-matching
251
- // - depends on: utf8_encode
252
- // * example 1: crc32('Kevin van Zonneveld');
253
- // * returns 1: 1249991249
254
- str = this.utf8_encode(str);
255
- var table = "00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D";
256
-
257
- var crc = 0;
258
- var x = 0;
259
- var y = 0;
260
-
261
- crc = crc ^ (-1);
262
- for (var i = 0, iTop = str.length; i < iTop; i++) {
263
- y = (crc ^ str.charCodeAt(i)) & 0xFF;
264
- x = "0x" + table.substr(y * 9, 8);
265
- crc = (crc >>> 8) ^ x;
266
- }
267
-
268
- crc = crc ^ (-1);
269
- //convert to unsigned 32-bit int if needed
270
- if (crc < 0) {crc += 4294967296}
271
- return crc;
272
- }
273
-
274
- (function( $ ) {
275
- if (!$.fn.fileupload) {
276
- return;
277
- }
278
- $.fn.cloudinary_fileupload = function(options) {
279
- options = $.extend({
280
- maxFileSize: 10000000,
281
- dataType: 'json',
282
- acceptFileTypes: /(\.|\/)(gif|jpe?g|png|bmp|ico)$/i,
283
- headers: {"X-Requested-With": "XMLHttpRequest"},
284
- }, options);
285
- this.fileupload(options).bind("fileuploaddone", function(e, data) {
286
- if (data.result.error) return;
287
- data.result.path = ["v", data.result.version, "/", data.result.public_id,
288
- data.result.format ? "." + data.result.format : ""].join("");
289
-
290
- if (data.cloudinaryField && data.form.length > 0) {
291
- var upload_info = [data.result.resource_type, "upload", data.result.path].join("/") + "#" + data.result.signature;
292
- var field = $(data.form).find('input[name="' + data.cloudinaryField + '"]');
293
- if (field.length > 0) {
294
- field.val(upload_info);
295
- } else {
296
- $('<input></input>').attr({type: "hidden", name: data.cloudinaryField}).val(upload_info).appendTo(data.form);
297
- }
298
- }
299
- $(e.target).trigger('cloudinarydone', data);
300
- });
301
- if (!this.fileupload('option').url) {
302
- var upload_url = "https://api.cloudinary.com/v1_1/" + $.cloudinary.config().cloud_name + "/upload";
303
- this.fileupload('option', 'url', upload_url);
304
- }
305
- return this;
306
- };
307
-
308
- $(function() {
309
- $("input.cloudinary-fileupload[type=file]").cloudinary_fileupload();
310
- });
311
- })( jQuery );