cloudinary 1.2.3 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 334dc407a90f5a0d121718d87976528ec216786c
4
- data.tar.gz: e326b4b46e3a18c3bbe3367ad460d208f169972e
3
+ metadata.gz: 842df6412b0805f7245faa594974cd1f154be04c
4
+ data.tar.gz: 017cad0657d0f86f6ee178409a598666a2308d7b
5
5
  SHA512:
6
- metadata.gz: e163279980d8a009331cf45d5f946e8ac7579c4c2086ff15311ccd872eef6e9a19e43e66996de42b5a6a6a719b52e0b1e3f59d5d8a9fa54c18141f931b6608c0
7
- data.tar.gz: 5a0cabe2f96432e09427c89e8b790bb3d68f345f34658867d991f8784cbda8a0bd76b04c9e92f4501a46ead871bfd53b54a7206a597ae5b424d59f054c0b8034
6
+ metadata.gz: 2f3ee72559c228f8eeed1903894b1d285438939d4a1186a62e10ba1972480ad3c44f707240a52c2d1862b4b1eb2b69fd1e3f7b6a06cdb9b66523e192a40eebff
7
+ data.tar.gz: cfc2d22221ab303377dd80230ec72b8886c69c099c175811ab70ce140e9155149d787a67a69b5c3524ea05e149052450b51e69cc20ebb1701b6a8bfdbc19a531
@@ -1,4 +1,16 @@
1
1
 
2
+ 1.2.4 / 2016-10-30
3
+ ==================
4
+
5
+ New functionality and features
6
+ ------------------------------
7
+
8
+ * Add `Api.update_streaming_profile`
9
+ * Add `Api.get_streaming_profile`
10
+ * Add `Api.delete_streaming_profile`
11
+ * Add `Api.list_streaming_profiles`
12
+ * Add `Api.create_streaming_profile`
13
+
2
14
  1.2.3 / 2016-08-21
3
15
  ==================
4
16
 
@@ -229,6 +229,35 @@ class Cloudinary::Api
229
229
  call_api(:post, 'upload_mappings', params, options)
230
230
  end
231
231
 
232
+ def self.create_streaming_profile(name, options={})
233
+ params = only(options, :display_name, :representations)
234
+ params[:representations] = params[:representations].map do |r|
235
+ {:transformation => Cloudinary::Utils.generate_transformation_string(r[:transformation])}
236
+ end.to_json
237
+ params[:name] = name
238
+ call_api(:post, 'streaming_profiles', params, options)
239
+ end
240
+
241
+ def self.list_streaming_profiles
242
+ call_api(:get, 'streaming_profiles', {}, {})
243
+ end
244
+
245
+ def self.delete_streaming_profile(name, options={})
246
+ call_api(:delete, "streaming_profiles/#{name}", {}, options)
247
+ end
248
+
249
+ def self.get_streaming_profile(name, options={})
250
+ call_api(:get, "streaming_profiles/#{name}", {}, options)
251
+ end
252
+
253
+ def self.update_streaming_profile(name, options={})
254
+ params = only(options, :display_name, :representations)
255
+ params[:representations] = params[:representations].map do |r|
256
+ {:transformation => Cloudinary::Utils.generate_transformation_string(r[:transformation])}
257
+ end.to_json
258
+ call_api(:put, "streaming_profiles/#{name}", params, options)
259
+ end
260
+
232
261
  protected
233
262
 
234
263
  def self.call_api(method, uri, params, options)
@@ -1,4 +1,4 @@
1
1
  # Copyright Cloudinary
2
2
  module Cloudinary
3
- VERSION = "1.2.3"
3
+ VERSION = "1.2.4"
4
4
  end
@@ -281,10 +281,11 @@ describe Cloudinary::Api do
281
281
  end
282
282
 
283
283
  it "should allow deleting upload_presets", :upload_preset => true do
284
- @api.create_upload_preset(:name => "api_test_upload_preset4", :folder => "folder", :tags => [TEST_TAG, TIMESTAMP_TAG])
285
- preset = @api.upload_preset("api_test_upload_preset4")
286
- @api.delete_upload_preset("api_test_upload_preset4")
287
- expect{preset = @api.upload_preset("api_test_upload_preset4")}.to raise_error(Cloudinary::Api::NotFound)
284
+ id = "#{prefix}_upload_preset"
285
+ @api.create_upload_preset(:name => id, :folder => "folder", :tags => [TEST_TAG, TIMESTAMP_TAG])
286
+ preset = @api.upload_preset(id)
287
+ @api.delete_upload_preset(id)
288
+ expect{preset = @api.upload_preset(id)}.to raise_error(Cloudinary::Api::NotFound)
288
289
  end
289
290
 
290
291
  it "should allow updating upload_presets", :upload_preset => true do
@@ -0,0 +1,74 @@
1
+ require 'spec_helper'
2
+ require 'cloudinary'
3
+
4
+ describe Cloudinary::Api do
5
+ PREDEFINED_PROFILES = %w(4k full_hd hd sd full_hd_wifi full_hd_lean hd_lean)
6
+ break puts('Please setup environment for api test to run') if Cloudinary.config.api_secret.blank?
7
+ include_context 'cleanup', TIMESTAMP_TAG
8
+
9
+ prefix = TEST_TAG + "_#{Time.now.to_i}"
10
+ test_id_1 = "#{prefix}_1"
11
+ test_id_2 = "#{prefix}_2"
12
+ test_id_3 = "#{prefix}_3"
13
+ before(:all) do
14
+
15
+ @api = Cloudinary::Api
16
+ end
17
+
18
+ describe 'create_streaming_profile' do
19
+ it 'should create a streaming profile with representations' do
20
+ result = @api.create_streaming_profile test_id_1, :representations =>
21
+ [{:transformation => {:crop => 'scale', :width => '1200', :height => '1200', :bit_rate => '5m'}}]
22
+ expect(result).not_to be_blank
23
+ end
24
+ it 'should create a streaming profile with an array of transformation' do
25
+ result = @api.create_streaming_profile test_id_1 + 'a', :representations =>
26
+ [{:transformation => [{:crop => 'scale', :width => '1200', :height => '1200', :bit_rate => '5m'}]}]
27
+ expect(result).not_to be_blank
28
+ end
29
+ end
30
+
31
+ describe 'list_streaming_profile' do
32
+ it 'should list streaming profile' do
33
+ result = @api.list_streaming_profiles
34
+ expect(result).to have_key('data')
35
+ expect(result['data'].map{|p| p['name']}).to include(*PREDEFINED_PROFILES)
36
+ end
37
+ end
38
+
39
+ describe 'delete_streaming_profile' do
40
+ it 'should delete a streaming profile' do
41
+ result = @api.create_streaming_profile test_id_2, :representations =>
42
+ [{:transformation => {:crop => 'scale', :width => '1200', :height => '1200', :bit_rate => '5m'}}]
43
+ expect(result).not_to be_blank
44
+ result = @api.delete_streaming_profile test_id_2
45
+ expect(result).to have_key('message')
46
+ expect(result['message']).to eq('deleted')
47
+ result = @api.list_streaming_profiles
48
+ expect(result['data'].map{|p| p['name']}).not_to include(test_id_2)
49
+ end
50
+ end
51
+
52
+ describe 'get_streaming_profile' do
53
+ it 'should get a specific streaming profile' do
54
+ result = @api.get_streaming_profile(PREDEFINED_PROFILES[1])
55
+ expect(result['data'].keys).to include('name', 'display_name', 'representations')
56
+ end
57
+ end
58
+
59
+ describe 'update_streaming_profile' do
60
+ it 'should create a streaming profile with representations' do
61
+ result = @api.create_streaming_profile test_id_3, :representations =>
62
+ [{:transformation => {:crop => 'scale', :width => '1200', :height => '1200', :bit_rate => '5m'}}]
63
+ expect(result).not_to be_blank
64
+ result = @api.update_streaming_profile test_id_3, :representations =>
65
+ [{:transformation => {:crop => 'scale', :width => '1000', :height => '1000', :bit_rate => '4m'}}]
66
+ expect(result).not_to be_blank
67
+ result = @api.get_streaming_profile(test_id_3)
68
+ result = result['data']
69
+ expect(result['representations'].length).to eq(1)
70
+ # Notice transformation is always returned as an array; numeric values represented as numbers, not strings
71
+ expect(result['representations'][0]).to eq({'transformation' => ['crop' => 'scale', 'width' => 1000, 'height' => 1000, 'bit_rate' => '4m']})
72
+ end
73
+ end
74
+ end
@@ -1,11 +1,12 @@
1
1
 
2
2
  /**
3
- * Cloudinary's JavaScript library - Version 2.1.2
3
+ * Cloudinary's JavaScript library - Version 2.1.5
4
4
  * Copyright Cloudinary
5
5
  * see https://github.com/cloudinary/cloudinary_js
6
6
  *
7
7
  */
8
- var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
8
+ var slice = [].slice,
9
+ extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
9
10
  hasProp = {}.hasOwnProperty;
10
11
 
11
12
  (function(root, factory) {
@@ -26,6 +27,175 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
26
27
  }
27
28
  })(this, function(jQuery) {
28
29
 
30
+ /*
31
+ * Includes common utility methods and shims
32
+ */
33
+ var ArrayParam, BaseUtil, Cloudinary, CloudinaryJQuery, Condition, Configuration, HtmlTag, ImageTag, Layer, LayerParam, Param, RangeParam, RawParam, SubtitlesLayer, TextLayer, Transformation, TransformationBase, TransformationParam, Util, VideoTag, addClass, allStrings, camelCase, cloneDeep, cloudinary, compact, contains, convertKeys, crc32, defaults, difference, functions, getAttribute, getData, hasClass, identity, isEmpty, isNumberLike, isString, m, merge, parameters, reWords, removeAttribute, setAttribute, setAttributes, setData, smartEscape, snakeCase, utf8_encode, webp, width, withCamelCaseKeys, withSnakeCaseKeys, without;
34
+ allStrings = function(list) {
35
+ var item, j, len;
36
+ for (j = 0, len = list.length; j < len; j++) {
37
+ item = list[j];
38
+ if (!Util.isString(item)) {
39
+ return false;
40
+ }
41
+ }
42
+ return true;
43
+ };
44
+ without = function(array, item) {
45
+ var i, length, newArray;
46
+ newArray = [];
47
+ i = -1;
48
+ length = array.length;
49
+ while (++i < length) {
50
+ if (array[i] !== item) {
51
+ newArray.push(array[i]);
52
+ }
53
+ }
54
+ return newArray;
55
+ };
56
+ isNumberLike = function(value) {
57
+ return (value != null) && !isNaN(parseFloat(value));
58
+ };
59
+ smartEscape = function(string, unsafe) {
60
+ if (unsafe == null) {
61
+ unsafe = /([^a-zA-Z0-9_.\-\/:]+)/g;
62
+ }
63
+ return string.replace(unsafe, function(match) {
64
+ return match.split("").map(function(c) {
65
+ return "%" + c.charCodeAt(0).toString(16).toUpperCase();
66
+ }).join("");
67
+ });
68
+ };
69
+ defaults = function() {
70
+ var destination, sources;
71
+ destination = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : [];
72
+ return sources.reduce(function(dest, source) {
73
+ var key, value;
74
+ for (key in source) {
75
+ value = source[key];
76
+ if (dest[key] === void 0) {
77
+ dest[key] = value;
78
+ }
79
+ }
80
+ return dest;
81
+ }, destination);
82
+ };
83
+
84
+ /** Used to match words to create compound words. */
85
+ reWords = (function() {
86
+ var lower, upper;
87
+ upper = '[A-Z]';
88
+ lower = '[a-z]+';
89
+ return RegExp(upper + '+(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|[0-9]+', 'g');
90
+ })();
91
+ camelCase = function(source) {
92
+ var i, word, words;
93
+ words = source.match(reWords);
94
+ words = (function() {
95
+ var j, len, results;
96
+ results = [];
97
+ for (i = j = 0, len = words.length; j < len; i = ++j) {
98
+ word = words[i];
99
+ word = word.toLocaleLowerCase();
100
+ if (i) {
101
+ results.push(word.charAt(0).toLocaleUpperCase() + word.slice(1));
102
+ } else {
103
+ results.push(word);
104
+ }
105
+ }
106
+ return results;
107
+ })();
108
+ return words.join('');
109
+ };
110
+ snakeCase = function(source) {
111
+ var i, word, words;
112
+ words = source.match(reWords);
113
+ words = (function() {
114
+ var j, len, results;
115
+ results = [];
116
+ for (i = j = 0, len = words.length; j < len; i = ++j) {
117
+ word = words[i];
118
+ results.push(word.toLocaleLowerCase());
119
+ }
120
+ return results;
121
+ })();
122
+ return words.join('_');
123
+ };
124
+ convertKeys = function(source, converter) {
125
+ var key, result, value;
126
+ if (converter == null) {
127
+ converter = Util.identity;
128
+ }
129
+ result = {};
130
+ for (key in source) {
131
+ value = source[key];
132
+ key = converter(key);
133
+ if (!Util.isEmpty(key)) {
134
+ result[key] = value;
135
+ }
136
+ }
137
+ return result;
138
+ };
139
+ withCamelCaseKeys = function(source) {
140
+ return convertKeys(source, Util.camelCase);
141
+ };
142
+ withSnakeCaseKeys = function(source) {
143
+ return convertKeys(source, Util.snakeCase);
144
+ };
145
+ BaseUtil = {
146
+
147
+ /**
148
+ * Return true if all items in list are strings
149
+ * @param {Array} list - an array of items
150
+ */
151
+ allStrings: allStrings,
152
+
153
+ /**
154
+ * Convert string to camelCase
155
+ * @param {string} string - the string to convert
156
+ * @return {string} in camelCase format
157
+ */
158
+ camelCase: camelCase,
159
+ convertKeys: convertKeys,
160
+
161
+ /**
162
+ * Assign values from sources if they are not defined in the destination.
163
+ * Once a value is set it does not change
164
+ * @param {Object} destination - the object to assign defaults to
165
+ * @param {...Object} source - the source object(s) to assign defaults from
166
+ * @return {Object} destination after it was modified
167
+ */
168
+ defaults: defaults,
169
+
170
+ /**
171
+ * Convert string to snake_case
172
+ * @param {string} string - the string to convert
173
+ * @return {string} in snake_case format
174
+ */
175
+ snakeCase: snakeCase,
176
+
177
+ /**
178
+ * Creates a new array without the given item.
179
+ * @param {Array} array - original array
180
+ * @param {*} item - the item to exclude from the new array
181
+ * @return {Array} a new array made of the original array's items except for `item`
182
+ */
183
+ without: without,
184
+
185
+ /**
186
+ * Return true is value is a number or a string representation of a number.
187
+ * @example
188
+ * Util.isNumber(0) // true
189
+ * Util.isNumber("1.3") // true
190
+ * Util.isNumber("") // false
191
+ * Util.isNumber(undefined) // false
192
+ */
193
+ isNumberLike: isNumberLike,
194
+ smartEscape: smartEscape,
195
+ withCamelCaseKeys: withCamelCaseKeys,
196
+ withSnakeCaseKeys: withSnakeCaseKeys
197
+ };
198
+
29
199
  /**
30
200
  * Includes utility methods and lodash / jQuery shims
31
201
  */
@@ -39,7 +209,6 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
39
209
  * @returns the value associated with the `name`
40
210
  * @function Util.getData
41
211
  */
42
- var ArrayParam, Cloudinary, CloudinaryJQuery, Condition, Configuration, HtmlTag, ImageTag, Layer, LayerParam, Param, RangeParam, RawParam, SubtitlesLayer, TextLayer, Transformation, TransformationBase, TransformationParam, Util, VideoTag, addClass, allStrings, camelCase, cloneDeep, cloudinary, compact, contains, crc32, defaults, difference, functions, getAttribute, getData, hasClass, identity, isEmpty, isString, merge, parameters, reWords, removeAttribute, setAttribute, setAttributes, setData, snakeCase, utf8_encode, webp, width, without;
43
212
  getData = function(element, name) {
44
213
  return jQuery(element).data(name);
45
214
  };
@@ -100,16 +269,6 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
100
269
  isEmpty = function(item) {
101
270
  return (item == null) || (jQuery.isArray(item) || Util.isString(item)) && item.length === 0 || (jQuery.isPlainObject(item) && jQuery.isEmptyObject(item));
102
271
  };
103
- allStrings = function(list) {
104
- var item, j, len;
105
- for (j = 0, len = list.length; j < len; j++) {
106
- item = list[j];
107
- if (!Util.isString(item)) {
108
- return false;
109
- }
110
- }
111
- return true;
112
- };
113
272
  isString = function(item) {
114
273
  return typeof item === 'string' || (item != null ? item.toString() : void 0) === '[object String]';
115
274
  };
@@ -127,47 +286,6 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
127
286
  args.unshift(true);
128
287
  return jQuery.extend.apply(this, args);
129
288
  };
130
-
131
- /** Used to match words to create compound words. */
132
- reWords = (function() {
133
- var lower, upper;
134
- upper = '[A-Z\\xc0-\\xd6\\xd8-\\xde]';
135
- lower = '[a-z\\xdf-\\xf6\\xf8-\\xff]+';
136
- return RegExp(upper + '+(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|[0-9]+', 'g');
137
- })();
138
- camelCase = function(source) {
139
- var i, word, words;
140
- words = source.match(reWords);
141
- words = (function() {
142
- var j, len, results;
143
- results = [];
144
- for (i = j = 0, len = words.length; j < len; i = ++j) {
145
- word = words[i];
146
- word = word.toLocaleLowerCase();
147
- if (i) {
148
- results.push(word.charAt(0).toLocaleUpperCase() + word.slice(1));
149
- } else {
150
- results.push(word);
151
- }
152
- }
153
- return results;
154
- })();
155
- return words.join('');
156
- };
157
- snakeCase = function(source) {
158
- var i, word, words;
159
- words = source.match(reWords);
160
- words = (function() {
161
- var j, len, results;
162
- results = [];
163
- for (i = j = 0, len = words.length; j < len; i = ++j) {
164
- word = words[i];
165
- results.push(word.toLocaleLowerCase());
166
- }
167
- return results;
168
- })();
169
- return words.join('_');
170
- };
171
289
  compact = function(arr) {
172
290
  var item, j, len, results;
173
291
  results = [];
@@ -196,20 +314,6 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
196
314
  }
197
315
  return false;
198
316
  };
199
- defaults = function() {
200
- var a, args, first, j, len;
201
- args = [];
202
- if (arguments.length === 1) {
203
- return arguments[0];
204
- }
205
- for (j = 0, len = arguments.length; j < len; j++) {
206
- a = arguments[j];
207
- args.unshift(a);
208
- }
209
- first = args.pop();
210
- args.unshift(first);
211
- return jQuery.extend.apply(this, args);
212
- };
213
317
  difference = function(arr, values) {
214
318
  var item, j, len, results;
215
319
  results = [];
@@ -234,19 +338,11 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
234
338
  identity = function(value) {
235
339
  return value;
236
340
  };
237
- without = function(array, item) {
238
- var i, length, newArray;
239
- newArray = [];
240
- i = -1;
241
- length = array.length;
242
- while (++i < length) {
243
- if (array[i] !== item) {
244
- newArray.push(array[i]);
245
- }
246
- }
247
- return newArray;
248
- };
249
- Util = {
341
+
342
+ /**
343
+ * @class Util
344
+ */
345
+ Util = $.extend(BaseUtil, {
250
346
  hasClass: hasClass,
251
347
  addClass: addClass,
252
348
  getAttribute: getAttribute,
@@ -256,12 +352,6 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
256
352
  getData: getData,
257
353
  setData: setData,
258
354
  width: width,
259
-
260
- /**
261
- * Return true if all items in list are strings
262
- * @param {Array} list - an array of items
263
- */
264
- allStrings: allStrings,
265
355
  isString: isString,
266
356
  isArray: jQuery.isArray,
267
357
  isEmpty: isEmpty,
@@ -280,20 +370,6 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
280
370
  */
281
371
  merge: merge,
282
372
 
283
- /**
284
- * Convert string to camelCase
285
- * @param {string} string - the string to convert
286
- * @return {string} in camelCase format
287
- */
288
- camelCase: camelCase,
289
-
290
- /**
291
- * Convert string to snake_case
292
- * @param {string} string - the string to convert
293
- * @return {string} in snake_case format
294
- */
295
- snakeCase: snakeCase,
296
-
297
373
  /**
298
374
  * Create a new copy of the given object, including all internal objects.
299
375
  * @param {Object} value - the object to clone
@@ -316,15 +392,6 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
316
392
  */
317
393
  contains: contains,
318
394
 
319
- /**
320
- * Assign values from sources if they are not defined in the destination.
321
- * Once a value is set it does not change
322
- * @param {Object} destination - the object to assign defaults to
323
- * @param {...Object} source - the source object(s) to assign defaults from
324
- * @return {Object} destination after it was modified
325
- */
326
- defaults: defaults,
327
-
328
395
  /**
329
396
  * Returns values in the given array that are not included in the other array
330
397
  * @param {Array} arr - the array to select from
@@ -360,16 +427,8 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
360
427
  * @param {string} text
361
428
  * @return {string} the `text` without leading or trailing spaces
362
429
  */
363
- trim: jQuery.trim,
364
-
365
- /**
366
- * Creates a new array without the given item.
367
- * @param {Array} array - original array
368
- * @param {*} item - the item to exclude from the new array
369
- * @return {Array} a new array made of the original array's items except for `item`
370
- */
371
- without: without
372
- };
430
+ trim: jQuery.trim
431
+ });
373
432
 
374
433
  /**
375
434
  * UTF8 encoder
@@ -398,47 +457,305 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
398
457
  } else {
399
458
  enc = String.fromCharCode(c1 >> 12 | 224, c1 >> 6 & 63 | 128, c1 & 63 | 128);
400
459
  }
401
- if (enc !== null) {
402
- if (end > start) {
403
- utftext += string.slice(start, end);
460
+ if (enc !== null) {
461
+ if (end > start) {
462
+ utftext += string.slice(start, end);
463
+ }
464
+ utftext += enc;
465
+ start = end = n + 1;
466
+ }
467
+ n++;
468
+ }
469
+ if (end > start) {
470
+ utftext += string.slice(start, stringl);
471
+ }
472
+ return utftext;
473
+ };
474
+
475
+ /**
476
+ * CRC32 calculator
477
+ * Depends on 'utf8_encode'
478
+ */
479
+ crc32 = function(str) {
480
+ var crc, i, iTop, table, x, y;
481
+ str = utf8_encode(str);
482
+ 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';
483
+ crc = 0;
484
+ x = 0;
485
+ y = 0;
486
+ crc = crc ^ -1;
487
+ i = 0;
488
+ iTop = str.length;
489
+ while (i < iTop) {
490
+ y = (crc ^ str.charCodeAt(i)) & 0xFF;
491
+ x = '0x' + table.substr(y * 9, 8);
492
+ crc = crc >>> 8 ^ x;
493
+ i++;
494
+ }
495
+ crc = crc ^ -1;
496
+ if (crc < 0) {
497
+ crc += 4294967296;
498
+ }
499
+ return crc;
500
+ };
501
+ Layer = (function() {
502
+
503
+ /**
504
+ * Layer
505
+ * @constructor Layer
506
+ * @param {Object} options - layer parameters
507
+ */
508
+ function Layer(options) {
509
+ this.options = {};
510
+ if (options != null) {
511
+ ["resourceType", "type", "publicId", "format"].forEach((function(_this) {
512
+ return function(key) {
513
+ var ref;
514
+ return _this.options[key] = (ref = options[key]) != null ? ref : options[Util.snakeCase(key)];
515
+ };
516
+ })(this));
517
+ }
518
+ }
519
+
520
+ Layer.prototype.resourceType = function(value) {
521
+ this.options.resourceType = value;
522
+ return this;
523
+ };
524
+
525
+ Layer.prototype.type = function(value) {
526
+ this.options.type = value;
527
+ return this;
528
+ };
529
+
530
+ Layer.prototype.publicId = function(value) {
531
+ this.options.publicId = value;
532
+ return this;
533
+ };
534
+
535
+
536
+ /**
537
+ * Get the public ID, formatted for layer parameter
538
+ * @function Layer#getPublicId
539
+ * @return {String} public ID
540
+ */
541
+
542
+ Layer.prototype.getPublicId = function() {
543
+ var ref;
544
+ return (ref = this.options.publicId) != null ? ref.replace(/\//g, ":") : void 0;
545
+ };
546
+
547
+
548
+ /**
549
+ * Get the public ID, with format if present
550
+ * @function Layer#getFullPublicId
551
+ * @return {String} public ID
552
+ */
553
+
554
+ Layer.prototype.getFullPublicId = function() {
555
+ if (this.options.format != null) {
556
+ return this.getPublicId() + "." + this.options.format;
557
+ } else {
558
+ return this.getPublicId();
559
+ }
560
+ };
561
+
562
+ Layer.prototype.format = function(value) {
563
+ this.options.format = value;
564
+ return this;
565
+ };
566
+
567
+
568
+ /**
569
+ * generate the string representation of the layer
570
+ * @function Layer#toString
571
+ */
572
+
573
+ Layer.prototype.toString = function() {
574
+ var components;
575
+ components = [];
576
+ if (this.options.publicId == null) {
577
+ throw "Must supply publicId";
578
+ }
579
+ if (!(this.options.resourceType === "image")) {
580
+ components.push(this.options.resourceType);
581
+ }
582
+ if (!(this.options.type === "upload")) {
583
+ components.push(this.options.type);
584
+ }
585
+ components.push(this.getFullPublicId());
586
+ return Util.compact(components).join(":");
587
+ };
588
+
589
+ return Layer;
590
+
591
+ })();
592
+ TextLayer = (function(superClass) {
593
+ extend(TextLayer, superClass);
594
+
595
+
596
+ /**
597
+ * @constructor TextLayer
598
+ * @param {Object} options - layer parameters
599
+ */
600
+
601
+ function TextLayer(options) {
602
+ var keys;
603
+ TextLayer.__super__.constructor.call(this, options);
604
+ keys = ["resourceType", "resourceType", "fontFamily", "fontSize", "fontWeight", "fontStyle", "textDecoration", "textAlign", "stroke", "letterSpacing", "lineSpacing", "text"];
605
+ if (options != null) {
606
+ keys.forEach((function(_this) {
607
+ return function(key) {
608
+ var ref;
609
+ return _this.options[key] = (ref = options[key]) != null ? ref : options[Util.snakeCase(key)];
610
+ };
611
+ })(this));
612
+ }
613
+ this.options.resourceType = "text";
614
+ }
615
+
616
+ TextLayer.prototype.resourceType = function(resourceType) {
617
+ throw "Cannot modify resourceType for text layers";
618
+ };
619
+
620
+ TextLayer.prototype.type = function(type) {
621
+ throw "Cannot modify type for text layers";
622
+ };
623
+
624
+ TextLayer.prototype.format = function(format) {
625
+ throw "Cannot modify format for text layers";
626
+ };
627
+
628
+ TextLayer.prototype.fontFamily = function(fontFamily) {
629
+ this.options.fontFamily = fontFamily;
630
+ return this;
631
+ };
632
+
633
+ TextLayer.prototype.fontSize = function(fontSize) {
634
+ this.options.fontSize = fontSize;
635
+ return this;
636
+ };
637
+
638
+ TextLayer.prototype.fontWeight = function(fontWeight) {
639
+ this.options.fontWeight = fontWeight;
640
+ return this;
641
+ };
642
+
643
+ TextLayer.prototype.fontStyle = function(fontStyle) {
644
+ this.options.fontStyle = fontStyle;
645
+ return this;
646
+ };
647
+
648
+ TextLayer.prototype.textDecoration = function(textDecoration) {
649
+ this.options.textDecoration = textDecoration;
650
+ return this;
651
+ };
652
+
653
+ TextLayer.prototype.textAlign = function(textAlign) {
654
+ this.options.textAlign = textAlign;
655
+ return this;
656
+ };
657
+
658
+ TextLayer.prototype.stroke = function(stroke) {
659
+ this.options.stroke = stroke;
660
+ return this;
661
+ };
662
+
663
+ TextLayer.prototype.letterSpacing = function(letterSpacing) {
664
+ this.options.letterSpacing = letterSpacing;
665
+ return this;
666
+ };
667
+
668
+ TextLayer.prototype.lineSpacing = function(lineSpacing) {
669
+ this.options.lineSpacing = lineSpacing;
670
+ return this;
671
+ };
672
+
673
+ TextLayer.prototype.text = function(text) {
674
+ this.options.text = text;
675
+ return this;
676
+ };
677
+
678
+
679
+ /**
680
+ * generate the string representation of the layer
681
+ * @function TextLayer#toString
682
+ * @return {String}
683
+ */
684
+
685
+ TextLayer.prototype.toString = function() {
686
+ var components, hasPublicId, hasStyle, publicId, style, text;
687
+ style = this.textStyleIdentifier();
688
+ if (this.options.publicId != null) {
689
+ publicId = this.getFullPublicId();
690
+ }
691
+ if (this.options.text != null) {
692
+ hasPublicId = !Util.isEmpty(publicId);
693
+ hasStyle = !Util.isEmpty(style);
694
+ if (hasPublicId && hasStyle || !hasPublicId && !hasStyle) {
695
+ throw "Must supply either style parameters or a public_id when providing text parameter in a text overlay/underlay, but not both!";
696
+ }
697
+ text = Util.smartEscape(Util.smartEscape(this.options.text, /[,\/]/g));
698
+ }
699
+ components = [this.options.resourceType, style, publicId, text];
700
+ return Util.compact(components).join(":");
701
+ };
702
+
703
+ TextLayer.prototype.textStyleIdentifier = function() {
704
+ var components;
705
+ components = [];
706
+ if (this.options.fontWeight !== "normal") {
707
+ components.push(this.options.fontWeight);
708
+ }
709
+ if (this.options.fontStyle !== "normal") {
710
+ components.push(this.options.fontStyle);
711
+ }
712
+ if (this.options.textDecoration !== "none") {
713
+ components.push(this.options.textDecoration);
714
+ }
715
+ components.push(this.options.textAlign);
716
+ if (this.options.stroke !== "none") {
717
+ components.push(this.options.stroke);
718
+ }
719
+ if (!(Util.isEmpty(this.options.letterSpacing) && !Util.isNumberLike(this.options.letterSpacing))) {
720
+ components.push("letter_spacing_" + this.options.letterSpacing);
721
+ }
722
+ if (!(Util.isEmpty(this.options.lineSpacing) && !Util.isNumberLike(this.options.lineSpacing))) {
723
+ components.push("line_spacing_" + this.options.lineSpacing);
724
+ }
725
+ if (!Util.isEmpty(Util.compact(components))) {
726
+ if (Util.isEmpty(this.options.fontFamily)) {
727
+ throw "Must supply fontFamily. " + components;
728
+ }
729
+ if (Util.isEmpty(this.options.fontSize) && !Util.isNumberLike(this.options.fontSize)) {
730
+ throw "Must supply fontSize.";
404
731
  }
405
- utftext += enc;
406
- start = end = n + 1;
407
732
  }
408
- n++;
409
- }
410
- if (end > start) {
411
- utftext += string.slice(start, stringl);
412
- }
413
- return utftext;
414
- };
733
+ components.unshift(this.options.fontFamily, this.options.fontSize);
734
+ components = Util.compact(components).join("_");
735
+ return components;
736
+ };
415
737
 
416
- /**
417
- * CRC32 calculator
418
- * Depends on 'utf8_encode'
419
- */
420
- crc32 = function(str) {
421
- var crc, i, iTop, table, x, y;
422
- str = utf8_encode(str);
423
- 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';
424
- crc = 0;
425
- x = 0;
426
- y = 0;
427
- crc = crc ^ -1;
428
- i = 0;
429
- iTop = str.length;
430
- while (i < iTop) {
431
- y = (crc ^ str.charCodeAt(i)) & 0xFF;
432
- x = '0x' + table.substr(y * 9, 8);
433
- crc = crc >>> 8 ^ x;
434
- i++;
435
- }
436
- crc = crc ^ -1;
437
- if (crc < 0) {
438
- crc += 4294967296;
738
+ return TextLayer;
739
+
740
+ })(Layer);
741
+ SubtitlesLayer = (function(superClass) {
742
+ extend(SubtitlesLayer, superClass);
743
+
744
+
745
+ /**
746
+ * Represent a subtitles layer
747
+ * @constructor SubtitlesLayer
748
+ * @param {Object} options - layer parameters
749
+ */
750
+
751
+ function SubtitlesLayer(options) {
752
+ SubtitlesLayer.__super__.constructor.call(this, options);
753
+ this.options.resourceType = "subtitles";
439
754
  }
440
- return crc;
441
- };
755
+
756
+ return SubtitlesLayer;
757
+
758
+ })(TextLayer);
442
759
 
443
760
  /**
444
761
  * Transformation parameters
@@ -773,90 +1090,26 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
773
1090
  }
774
1091
 
775
1092
  LayerParam.prototype.value = function() {
776
- var components, format, layer, publicId, resourceType, text, textStyle, type;
777
- layer = this.origValue;
778
- if (cloudinary.Util.isPlainObject(layer)) {
779
- publicId = layer.public_id;
780
- format = layer.format;
781
- resourceType = layer.resource_type || "image";
782
- type = layer.type || "upload";
783
- text = layer.text;
784
- textStyle = null;
785
- components = [];
786
- if (publicId != null) {
787
- publicId = publicId.replace(/\//g, ":");
788
- if (format != null) {
789
- publicId = publicId + "." + format;
790
- }
791
- }
792
- if ((text == null) && resourceType !== "text") {
793
- if (cloudinary.Util.isEmpty(publicId)) {
794
- throw "Must supply public_id for resource_type layer_parameter";
795
- }
796
- if (resourceType === "subtitles") {
797
- textStyle = this.textStyle(layer);
798
- }
1093
+ var layerOptions, result;
1094
+ layerOptions = this.origValue;
1095
+ if (cloudinary.Util.isPlainObject(layerOptions)) {
1096
+ if (layerOptions.resource_type === "text" || (layerOptions.text != null)) {
1097
+ result = new cloudinary.TextLayer(layerOptions).toString();
1098
+ } else if (layerOptions.resource_type === "subtitles") {
1099
+ result = new cloudinary.SubtitlesLayer(layerOptions).toString();
799
1100
  } else {
800
- resourceType = "text";
801
- type = null;
802
- textStyle = this.textStyle(layer);
803
- if (text != null) {
804
- if (!((publicId != null) ^ (textStyle != null))) {
805
- throw "Must supply either style parameters or a public_id when providing text parameter in a text overlay/underlay";
806
- }
807
- text = cloudinary.Util.smart_escape(cloudinary.Util.smart_escape(text, /([,\/])/));
808
- }
809
- }
810
- if (resourceType !== "image") {
811
- components.push(resourceType);
812
- }
813
- if (type !== "upload") {
814
- components.push(type);
1101
+ result = new cloudinary.Layer(layerOptions).toString();
815
1102
  }
816
- components.push(textStyle);
817
- components.push(publicId);
818
- components.push(text);
819
- layer = cloudinary.Util.compact(components).join(":");
1103
+ } else {
1104
+ result = layerOptions;
820
1105
  }
821
- return layer;
1106
+ return result;
822
1107
  };
823
1108
 
824
- LAYER_KEYWORD_PARAMS = [["font_weight", "normal"], ["font_style", "normal"], ["text_decoration", "none"], ["text_align", null], ["stroke", "none"]];
1109
+ LAYER_KEYWORD_PARAMS = [["font_weight", "normal"], ["font_style", "normal"], ["text_decoration", "none"], ["text_align", null], ["stroke", "none"], ["letter_spacing", null], ["line_spacing", null]];
825
1110
 
826
1111
  LayerParam.prototype.textStyle = function(layer) {
827
- var attr, defaultValue, fontFamily, fontSize, keywords, letterSpacing, lineSpacing;
828
- fontFamily = layer.font_family;
829
- fontSize = layer.font_size;
830
- keywords = (function() {
831
- var j, len, ref, results;
832
- results = [];
833
- for (j = 0, len = LAYER_KEYWORD_PARAMS.length; j < len; j++) {
834
- ref = LAYER_KEYWORD_PARAMS[j], attr = ref[0], defaultValue = ref[1];
835
- if (layer[attr] !== defaultValue) {
836
- results.push(layer[attr]);
837
- }
838
- }
839
- return results;
840
- })();
841
- letterSpacing = layer.letter_spacing;
842
- if (!cloudinary.Util.isEmpty(letterSpacing)) {
843
- keywords.push("letter_spacing_" + letterSpacing);
844
- }
845
- lineSpacing = layer.line_spacing;
846
- if (!cloudinary.Util.isEmpty(lineSpacing)) {
847
- keywords.push("line_spacing_" + lineSpacing);
848
- }
849
- if (!cloudinary.Util.isEmpty(fontSize) || !cloudinary.Util.isEmpty(fontFamily) || !cloudinary.Util.isEmpty(keywords)) {
850
- if (cloudinary.Util.isEmpty(fontFamily)) {
851
- throw "Must supply font_family for text in overlay/underlay";
852
- }
853
- if (cloudinary.Util.isEmpty(fontSize)) {
854
- throw "Must supply font_size for text in overlay/underlay";
855
- }
856
- keywords.unshift(fontSize);
857
- keywords.unshift(fontFamily);
858
- return cloudinary.Util.compact(keywords).join("_");
859
- }
1112
+ return (new cloudinary.TextLayer(layer)).textStyleIdentifier();
860
1113
  };
861
1114
 
862
1115
  return LayerParam;
@@ -1079,23 +1332,209 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
1079
1332
  * @return {Condition} this condition
1080
1333
  */
1081
1334
 
1082
- Condition.prototype.pageCount = function(operator, value) {
1083
- return this.predicate("pc", operator, value);
1335
+ Condition.prototype.pageCount = function(operator, value) {
1336
+ return this.predicate("pc", operator, value);
1337
+ };
1338
+
1339
+
1340
+ /**
1341
+ * @function Condition#faces
1342
+ * @param {string} operator the comparison operator (e.g. "<", "lt")
1343
+ * @param {string|number} value the right hand side value
1344
+ * @return {Condition} this condition
1345
+ */
1346
+
1347
+ Condition.prototype.faceCount = function(operator, value) {
1348
+ return this.predicate("fc", operator, value);
1349
+ };
1350
+
1351
+ return Condition;
1352
+
1353
+ })();
1354
+
1355
+ /**
1356
+ * Cloudinary configuration class
1357
+ * Depends on 'utils'
1358
+ */
1359
+ Configuration = (function() {
1360
+
1361
+ /**
1362
+ * Defaults configuration.
1363
+ * @const {Object} Configuration.DEFAULT_CONFIGURATION_PARAMS
1364
+ */
1365
+ var DEFAULT_CONFIGURATION_PARAMS, ref;
1366
+
1367
+ DEFAULT_CONFIGURATION_PARAMS = {
1368
+ responsive_class: 'cld-responsive',
1369
+ responsive_use_breakpoints: true,
1370
+ round_dpr: true,
1371
+ secure: (typeof window !== "undefined" && window !== null ? (ref = window.location) != null ? ref.protocol : void 0 : void 0) === 'https:'
1372
+ };
1373
+
1374
+ Configuration.CONFIG_PARAMS = ["api_key", "api_secret", "cdn_subdomain", "cloud_name", "cname", "private_cdn", "protocol", "resource_type", "responsive_class", "responsive_use_breakpoints", "responsive_width", "round_dpr", "secure", "secure_cdn_subdomain", "secure_distribution", "shorten", "type", "url_suffix", "use_root_path", "version"];
1375
+
1376
+
1377
+ /**
1378
+ * Cloudinary configuration class
1379
+ * @constructor Configuration
1380
+ * @param {Object} options - configuration parameters
1381
+ */
1382
+
1383
+ function Configuration(options) {
1384
+ if (options == null) {
1385
+ options = {};
1386
+ }
1387
+ this.configuration = Util.cloneDeep(options);
1388
+ Util.defaults(this.configuration, DEFAULT_CONFIGURATION_PARAMS);
1389
+ }
1390
+
1391
+
1392
+ /**
1393
+ * Initialize the configuration.
1394
+ * The function first tries to retrieve the configuration form the environment and then from the document.
1395
+ * @function Configuration#init
1396
+ * @return {Configuration} returns this for chaining
1397
+ * @see fromDocument
1398
+ * @see fromEnvironment
1399
+ */
1400
+
1401
+ Configuration.prototype.init = function() {
1402
+ this.fromEnvironment();
1403
+ this.fromDocument();
1404
+ return this;
1405
+ };
1406
+
1407
+
1408
+ /**
1409
+ * Set a new configuration item
1410
+ * @function Configuration#set
1411
+ * @param {string} name - the name of the item to set
1412
+ * @param {*} value - the value to be set
1413
+ * @return {Configuration}
1414
+ *
1415
+ */
1416
+
1417
+ Configuration.prototype.set = function(name, value) {
1418
+ this.configuration[name] = value;
1419
+ return this;
1420
+ };
1421
+
1422
+
1423
+ /**
1424
+ * Get the value of a configuration item
1425
+ * @function Configuration#get
1426
+ * @param {string} name - the name of the item to set
1427
+ * @return {*} the configuration item
1428
+ */
1429
+
1430
+ Configuration.prototype.get = function(name) {
1431
+ return this.configuration[name];
1432
+ };
1433
+
1434
+ Configuration.prototype.merge = function(config) {
1435
+ if (config == null) {
1436
+ config = {};
1437
+ }
1438
+ Util.assign(this.configuration, Util.cloneDeep(config));
1439
+ return this;
1440
+ };
1441
+
1442
+
1443
+ /**
1444
+ * Initialize Cloudinary from HTML meta tags.
1445
+ * @function Configuration#fromDocument
1446
+ * @return {Configuration}
1447
+ * @example <meta name="cloudinary_cloud_name" content="mycloud">
1448
+ *
1449
+ */
1450
+
1451
+ Configuration.prototype.fromDocument = function() {
1452
+ var el, j, len, meta_elements;
1453
+ meta_elements = typeof document !== "undefined" && document !== null ? document.querySelectorAll('meta[name^="cloudinary_"]') : void 0;
1454
+ if (meta_elements) {
1455
+ for (j = 0, len = meta_elements.length; j < len; j++) {
1456
+ el = meta_elements[j];
1457
+ this.configuration[el.getAttribute('name').replace('cloudinary_', '')] = el.getAttribute('content');
1458
+ }
1459
+ }
1460
+ return this;
1461
+ };
1462
+
1463
+
1464
+ /**
1465
+ * Initialize Cloudinary from the `CLOUDINARY_URL` environment variable.
1466
+ *
1467
+ * This function will only run under Node.js environment.
1468
+ * @function Configuration#fromEnvironment
1469
+ * @requires Node.js
1470
+ */
1471
+
1472
+ Configuration.prototype.fromEnvironment = function() {
1473
+ var cloudinary_url, k, ref1, ref2, uri, v;
1474
+ cloudinary_url = typeof process !== "undefined" && process !== null ? (ref1 = process.env) != null ? ref1.CLOUDINARY_URL : void 0 : void 0;
1475
+ if (cloudinary_url != null) {
1476
+ uri = require('url').parse(cloudinary_url, true);
1477
+ this.configuration = {
1478
+ cloud_name: uri.host,
1479
+ api_key: uri.auth && uri.auth.split(":")[0],
1480
+ api_secret: uri.auth && uri.auth.split(":")[1],
1481
+ private_cdn: uri.pathname != null,
1482
+ secure_distribution: uri.pathname && uri.pathname.substring(1)
1483
+ };
1484
+ if (uri.query != null) {
1485
+ ref2 = uri.query;
1486
+ for (k in ref2) {
1487
+ v = ref2[k];
1488
+ this.configuration[k] = v;
1489
+ }
1490
+ }
1491
+ }
1492
+ return this;
1493
+ };
1494
+
1495
+
1496
+ /**
1497
+ * Create or modify the Cloudinary client configuration
1498
+ *
1499
+ * Warning: `config()` returns the actual internal configuration object. modifying it will change the configuration.
1500
+ *
1501
+ * This is a backward compatibility method. For new code, use get(), merge() etc.
1502
+ * @function Configuration#config
1503
+ * @param {hash|string|boolean} new_config
1504
+ * @param {string} new_value
1505
+ * @returns {*} configuration, or value
1506
+ *
1507
+ * @see {@link fromEnvironment} for initialization using environment variables
1508
+ * @see {@link fromDocument} for initialization using HTML meta tags
1509
+ */
1510
+
1511
+ Configuration.prototype.config = function(new_config, new_value) {
1512
+ switch (false) {
1513
+ case new_value === void 0:
1514
+ this.set(new_config, new_value);
1515
+ return this.configuration;
1516
+ case !Util.isString(new_config):
1517
+ return this.get(new_config);
1518
+ case !Util.isPlainObject(new_config):
1519
+ this.merge(new_config);
1520
+ return this.configuration;
1521
+ default:
1522
+ return this.configuration;
1523
+ }
1084
1524
  };
1085
1525
 
1086
1526
 
1087
1527
  /**
1088
- * @function Condition#faces
1089
- * @param {string} operator the comparison operator (e.g. "<", "lt")
1090
- * @param {string|number} value the right hand side value
1091
- * @return {Condition} this condition
1528
+ * Returns a copy of the configuration parameters
1529
+ * @function Configuration#toOptions
1530
+ * @returns {Object} a key:value collection of the configuration parameters
1092
1531
  */
1093
1532
 
1094
- Condition.prototype.faceCount = function(operator, value) {
1095
- return this.predicate("fc", operator, value);
1533
+ Configuration.prototype.toOptions = function() {
1534
+ return Util.cloneDeep(this.configuration);
1096
1535
  };
1097
1536
 
1098
- return Condition;
1537
+ return Configuration;
1099
1538
 
1100
1539
  })();
1101
1540
 
@@ -1129,7 +1568,7 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
1129
1568
  */
1130
1569
 
1131
1570
  function TransformationBase(options) {
1132
- var m, parent, trans;
1571
+ var parent, trans;
1133
1572
  if (options == null) {
1134
1573
  options = {};
1135
1574
  }
@@ -1391,36 +1830,6 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
1391
1830
  return this;
1392
1831
  });
1393
1832
  this.otherOptions || (this.otherOptions = {});
1394
-
1395
- /**
1396
- * Transformation Class methods.
1397
- * This is a list of the parameters defined in Transformation.
1398
- * Values are camelCased.
1399
- * @private
1400
- * @ignore
1401
- * @type {Array<string>}
1402
- */
1403
- this.methods || (this.methods = Util.difference(Util.functions(Transformation.prototype), Util.functions(TransformationBase.prototype)));
1404
-
1405
- /**
1406
- * Parameters that are filtered out before passing the options to an HTML tag.
1407
- *
1408
- * The list of parameters is a combination of `Transformation::methods` and `Configuration::CONFIG_PARAMS`
1409
- * @const {Array<string>} Transformation.PARAM_NAMES
1410
- * @private
1411
- * @ignore
1412
- * @see toHtmlAttributes
1413
- */
1414
- this.PARAM_NAMES || (this.PARAM_NAMES = ((function() {
1415
- var j, len, ref, results;
1416
- ref = this.methods;
1417
- results = [];
1418
- for (j = 0, len = ref.length; j < len; j++) {
1419
- m = ref[j];
1420
- results.push(Util.snakeCase(m));
1421
- }
1422
- return results;
1423
- }).call(this)).concat(Configuration.CONFIG_PARAMS));
1424
1833
  this.chained = [];
1425
1834
  if (!Util.isEmpty(options)) {
1426
1835
  this.fromOptions(options);
@@ -1482,7 +1891,7 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
1482
1891
  TransformationBase.prototype.set = function(key, value) {
1483
1892
  var camelKey;
1484
1893
  camelKey = Util.camelCase(key);
1485
- if (Util.contains(this.methods, camelKey)) {
1894
+ if (Util.contains(Transformation.methods, camelKey)) {
1486
1895
  this[camelKey](value);
1487
1896
  } else {
1488
1897
  this.otherOptions[key] = value;
@@ -1565,7 +1974,7 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
1565
1974
  */
1566
1975
 
1567
1976
  TransformationBase.prototype.listNames = function() {
1568
- return this.methods;
1977
+ return Transformation.methods;
1569
1978
  };
1570
1979
 
1571
1980
 
@@ -1581,17 +1990,17 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
1581
1990
  ref = this.otherOptions;
1582
1991
  for (key in ref) {
1583
1992
  value = ref[key];
1584
- if (!(!Util.contains(this.PARAM_NAMES, key))) {
1993
+ if (!(!Util.contains(Transformation.PARAM_NAMES, Util.snakeCase(key)))) {
1585
1994
  continue;
1586
1995
  }
1587
1996
  attrName = /^html_/.test(key) ? key.slice(5) : key;
1588
- options[attrName] = value;
1997
+ options[Util.camelCase(attrName)] = value;
1589
1998
  }
1590
1999
  ref1 = this.keys();
1591
2000
  for (j = 0, len = ref1.length; j < len; j++) {
1592
2001
  key = ref1[j];
1593
2002
  if (/^html_/.test(key)) {
1594
- options[key.slice(5)] = this.getValue(key);
2003
+ options[Util.camelCase(key.slice(5))] = this.getValue(key);
1595
2004
  }
1596
2005
  }
1597
2006
  if (!(this.hasLayer() || this.getValue("angle") || Util.contains(["fit", "limit", "lfill"], this.getValue("crop")))) {
@@ -1612,7 +2021,7 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
1612
2021
  };
1613
2022
 
1614
2023
  TransformationBase.prototype.isValidParamName = function(name) {
1615
- return this.methods.indexOf(Util.camelCase(name)) >= 0;
2024
+ return Transformation.methods.indexOf(Util.camelCase(name)) >= 0;
1616
2025
  };
1617
2026
 
1618
2027
 
@@ -1636,6 +2045,26 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
1636
2045
 
1637
2046
  TransformationBase.prototype.toString = function() {
1638
2047
  return this.serialize();
2048
+
2049
+ /**
2050
+ * Transformation Class methods.
2051
+ * This is a list of the parameters defined in Transformation.
2052
+ * Values are camelCased.
2053
+ * @const Transformation.methods
2054
+ * @private
2055
+ * @ignore
2056
+ * @type {Array<string>}
2057
+ */
2058
+
2059
+ /**
2060
+ * Parameters that are filtered out before passing the options to an HTML tag.
2061
+ *
2062
+ * The list of parameters is a combination of `Transformation::methods` and `Configuration::CONFIG_PARAMS`
2063
+ * @const {Array<string>} Transformation.PARAM_NAMES
2064
+ * @private
2065
+ * @ignore
2066
+ * @see toHtmlAttributes
2067
+ */
1639
2068
  };
1640
2069
 
1641
2070
  return TransformationBase;
@@ -1662,6 +2091,7 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
1662
2091
  options = {};
1663
2092
  }
1664
2093
  Transformation.__super__.constructor.call(this, options);
2094
+ this;
1665
2095
  }
1666
2096
 
1667
2097
 
@@ -1751,9 +2181,7 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
1751
2181
  return this.param(value, "dpr", "dpr", (function(_this) {
1752
2182
  return function(dpr) {
1753
2183
  dpr = dpr.toString();
1754
- if ((dpr === "auto") && _this.getValue("client_hints") !== true) {
1755
- return "1.0";
1756
- } else if (dpr != null ? dpr.match(/^\d+$/) : void 0) {
2184
+ if (dpr != null ? dpr.match(/^\d+$/) : void 0) {
1757
2185
  return dpr + ".0";
1758
2186
  } else {
1759
2187
  return dpr;
@@ -1957,203 +2385,40 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
1957
2385
  return this.param(value, "x", "x");
1958
2386
  };
1959
2387
 
1960
- Transformation.prototype.y = function(value) {
1961
- return this.param(value, "y", "y");
1962
- };
1963
-
1964
- Transformation.prototype.zoom = function(value) {
1965
- return this.param(value, "zoom", "z");
1966
- };
1967
-
1968
- return Transformation;
1969
-
1970
- })(TransformationBase);
1971
-
1972
- /**
1973
- * Cloudinary configuration class
1974
- * Depends on 'utils'
1975
- */
1976
- Configuration = (function() {
1977
-
1978
- /**
1979
- * Defaults configuration.
1980
- * @const {Object} Configuration.DEFAULT_CONFIGURATION_PARAMS
1981
- */
1982
- var DEFAULT_CONFIGURATION_PARAMS, ref;
1983
-
1984
- DEFAULT_CONFIGURATION_PARAMS = {
1985
- responsive_class: 'cld-responsive',
1986
- responsive_use_breakpoints: true,
1987
- round_dpr: true,
1988
- secure: (typeof window !== "undefined" && window !== null ? (ref = window.location) != null ? ref.protocol : void 0 : void 0) === 'https:'
1989
- };
1990
-
1991
- Configuration.CONFIG_PARAMS = ["api_key", "api_secret", "cdn_subdomain", "cloud_name", "cname", "private_cdn", "protocol", "resource_type", "responsive_class", "responsive_use_breakpoints", "responsive_width", "round_dpr", "secure", "secure_cdn_subdomain", "secure_distribution", "shorten", "type", "url_suffix", "use_root_path", "version"];
1992
-
1993
-
1994
- /**
1995
- * Cloudinary configuration class
1996
- * @constructor Configuration
1997
- * @param {Object} options - configuration parameters
1998
- */
1999
-
2000
- function Configuration(options) {
2001
- if (options == null) {
2002
- options = {};
2003
- }
2004
- this.configuration = Util.cloneDeep(options);
2005
- Util.defaults(this.configuration, DEFAULT_CONFIGURATION_PARAMS);
2006
- }
2007
-
2008
-
2009
- /**
2010
- * Initialize the configuration.
2011
- * The function first tries to retrieve the configuration form the environment and then from the document.
2012
- * @function Configuration#init
2013
- * @return {Configuration} returns this for chaining
2014
- * @see fromDocument
2015
- * @see fromEnvironment
2016
- */
2017
-
2018
- Configuration.prototype.init = function() {
2019
- this.fromEnvironment();
2020
- this.fromDocument();
2021
- return this;
2022
- };
2023
-
2024
-
2025
- /**
2026
- * Set a new configuration item
2027
- * @function Configuration#set
2028
- * @param {string} name - the name of the item to set
2029
- * @param {*} value - the value to be set
2030
- * @return {Configuration}
2031
- *
2032
- */
2033
-
2034
- Configuration.prototype.set = function(name, value) {
2035
- this.configuration[name] = value;
2036
- return this;
2037
- };
2038
-
2039
-
2040
- /**
2041
- * Get the value of a configuration item
2042
- * @function Configuration#get
2043
- * @param {string} name - the name of the item to set
2044
- * @return {*} the configuration item
2045
- */
2046
-
2047
- Configuration.prototype.get = function(name) {
2048
- return this.configuration[name];
2049
- };
2050
-
2051
- Configuration.prototype.merge = function(config) {
2052
- if (config == null) {
2053
- config = {};
2054
- }
2055
- Util.assign(this.configuration, Util.cloneDeep(config));
2056
- return this;
2057
- };
2058
-
2059
-
2060
- /**
2061
- * Initialize Cloudinary from HTML meta tags.
2062
- * @function Configuration#fromDocument
2063
- * @return {Configuration}
2064
- * @example <meta name="cloudinary_cloud_name" content="mycloud">
2065
- *
2066
- */
2067
-
2068
- Configuration.prototype.fromDocument = function() {
2069
- var el, j, len, meta_elements;
2070
- meta_elements = typeof document !== "undefined" && document !== null ? document.querySelectorAll('meta[name^="cloudinary_"]') : void 0;
2071
- if (meta_elements) {
2072
- for (j = 0, len = meta_elements.length; j < len; j++) {
2073
- el = meta_elements[j];
2074
- this.configuration[el.getAttribute('name').replace('cloudinary_', '')] = el.getAttribute('content');
2075
- }
2076
- }
2077
- return this;
2078
- };
2079
-
2080
-
2081
- /**
2082
- * Initialize Cloudinary from the `CLOUDINARY_URL` environment variable.
2083
- *
2084
- * This function will only run under Node.js environment.
2085
- * @function Configuration#fromEnvironment
2086
- * @requires Node.js
2087
- */
2088
-
2089
- Configuration.prototype.fromEnvironment = function() {
2090
- var cloudinary_url, k, ref1, ref2, uri, v;
2091
- cloudinary_url = typeof process !== "undefined" && process !== null ? (ref1 = process.env) != null ? ref1.CLOUDINARY_URL : void 0 : void 0;
2092
- if (cloudinary_url != null) {
2093
- uri = require('url').parse(cloudinary_url, true);
2094
- this.configuration = {
2095
- cloud_name: uri.host,
2096
- api_key: uri.auth && uri.auth.split(":")[0],
2097
- api_secret: uri.auth && uri.auth.split(":")[1],
2098
- private_cdn: uri.pathname != null,
2099
- secure_distribution: uri.pathname && uri.pathname.substring(1)
2100
- };
2101
- if (uri.query != null) {
2102
- ref2 = uri.query;
2103
- for (k in ref2) {
2104
- v = ref2[k];
2105
- this.configuration[k] = v;
2106
- }
2107
- }
2108
- }
2109
- return this;
2110
- };
2111
-
2112
-
2113
- /**
2114
- * Create or modify the Cloudinary client configuration
2115
- *
2116
- * Warning: `config()` returns the actual internal configuration object. modifying it will change the configuration.
2117
- *
2118
- * This is a backward compatibility method. For new code, use get(), merge() etc.
2119
- * @function Configuration#config
2120
- * @param {hash|string|boolean} new_config
2121
- * @param {string} new_value
2122
- * @returns {*} configuration, or value
2123
- *
2124
- * @see {@link fromEnvironment} for initialization using environment variables
2125
- * @see {@link fromDocument} for initialization using HTML meta tags
2126
- */
2127
-
2128
- Configuration.prototype.config = function(new_config, new_value) {
2129
- switch (false) {
2130
- case new_value === void 0:
2131
- this.set(new_config, new_value);
2132
- return this.configuration;
2133
- case !Util.isString(new_config):
2134
- return this.get(new_config);
2135
- case !Util.isPlainObject(new_config):
2136
- this.merge(new_config);
2137
- return this.configuration;
2138
- default:
2139
- return this.configuration;
2140
- }
2388
+ Transformation.prototype.y = function(value) {
2389
+ return this.param(value, "y", "y");
2141
2390
  };
2142
2391
 
2392
+ Transformation.prototype.zoom = function(value) {
2393
+ return this.param(value, "zoom", "z");
2394
+ };
2143
2395
 
2144
- /**
2145
- * Returns a copy of the configuration parameters
2146
- * @function Configuration#toOptions
2147
- * @returns {Object} a key:value collection of the configuration parameters
2148
- */
2396
+ return Transformation;
2149
2397
 
2150
- Configuration.prototype.toOptions = function() {
2151
- return Util.cloneDeep(this.configuration);
2152
- };
2398
+ })(TransformationBase);
2153
2399
 
2154
- return Configuration;
2400
+ /**
2401
+ * Transformation Class methods.
2402
+ * This is a list of the parameters defined in Transformation.
2403
+ * Values are camelCased.
2404
+ */
2405
+ Transformation.methods || (Transformation.methods = Util.difference(Util.functions(Transformation.prototype), Util.functions(TransformationBase.prototype)));
2155
2406
 
2156
- })();
2407
+ /**
2408
+ * Parameters that are filtered out before passing the options to an HTML tag.
2409
+ *
2410
+ * The list of parameters is a combination of `Transformation::methods` and `Configuration::CONFIG_PARAMS`
2411
+ */
2412
+ Transformation.PARAM_NAMES || (Transformation.PARAM_NAMES = ((function() {
2413
+ var j, len, ref, results;
2414
+ ref = Transformation.methods;
2415
+ results = [];
2416
+ for (j = 0, len = ref.length; j < len; j++) {
2417
+ m = ref[j];
2418
+ results.push(Util.snakeCase(m));
2419
+ }
2420
+ return results;
2421
+ })()).concat(Configuration.CONFIG_PARAMS));
2157
2422
 
2158
2423
  /**
2159
2424
  * Generic HTML tag
@@ -2598,256 +2863,10 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
2598
2863
  return VideoTag;
2599
2864
 
2600
2865
  })(HtmlTag);
2601
- Layer = (function() {
2602
-
2603
- /**
2604
- * Layer
2605
- * @constructor Layer
2606
- * @param {Object} options - layer parameters
2607
- */
2608
- function Layer(options) {
2609
- this.options = {};
2610
- if (options != null) {
2611
- this.options.resourceType = options["resource_type"];
2612
- this.options.type = options["type"];
2613
- this.options.publicId = options["public_id"];
2614
- this.options.format = options["format"];
2615
- }
2616
- }
2617
-
2618
- Layer.prototype.resourceType = function(value) {
2619
- this.options.resourceType = value;
2620
- return this;
2621
- };
2622
-
2623
- Layer.prototype.type = function(value) {
2624
- this.options.type = value;
2625
- return this;
2626
- };
2627
-
2628
- Layer.prototype.publicId = function(value) {
2629
- this.options.publicId = value;
2630
- return this;
2631
- };
2632
-
2633
-
2634
- /**
2635
- * Get the public ID, formatted for layer parameter
2636
- * @function Layer#getPublicId
2637
- * @return {String} public ID
2638
- */
2639
-
2640
- Layer.prototype.getPublicId = function() {
2641
- var ref;
2642
- return (ref = this.options.publicId) != null ? ref.replace(/\//g, ":") : void 0;
2643
- };
2644
-
2645
-
2646
- /**
2647
- * Get the public ID, with format if present
2648
- * @function Layer#getFullPublicId
2649
- * @return {String} public ID
2650
- */
2651
-
2652
- Layer.prototype.getFullPublicId = function() {
2653
- if (this.options.format != null) {
2654
- return this.getPublicId() + "." + this.options.format;
2655
- } else {
2656
- return this.getPublicId();
2657
- }
2658
- };
2659
-
2660
- Layer.prototype.format = function(value) {
2661
- this.options.format = value;
2662
- return this;
2663
- };
2664
-
2665
-
2666
- /**
2667
- * generate the string representation of the layer
2668
- * @function Layer#toString
2669
- */
2670
-
2671
- Layer.prototype.toString = function() {
2672
- var components;
2673
- components = [];
2674
- if (this.options.publicId == null) {
2675
- throw "Must supply publicId";
2676
- }
2677
- if (!(this.options.resourceType === "image")) {
2678
- components.push(this.options.resourceType);
2679
- }
2680
- if (!(this.options.type === "upload")) {
2681
- components.push(this.options.type);
2682
- }
2683
- components.push(this.getFullPublicId());
2684
- return Util.compact(components).join(":");
2685
- };
2686
-
2687
- return Layer;
2688
-
2689
- })();
2690
- TextLayer = (function(superClass) {
2691
- var textStyleIdentifier;
2692
-
2693
- extend(TextLayer, superClass);
2694
-
2695
-
2696
- /**
2697
- * @constructor TextLayer
2698
- * @param {Object} options - layer parameters
2699
- */
2700
-
2701
- function TextLayer(options) {
2702
- TextLayer.__super__.constructor.call(this, options);
2703
- this.options.resourceType = "text";
2704
- }
2705
-
2706
- TextLayer.prototype.resourceType = function(resourceType) {
2707
- throw "Cannot modify resourceType for text layers";
2708
- };
2709
-
2710
- TextLayer.prototype.type = function(type) {
2711
- throw "Cannot modify type for text layers";
2712
- };
2713
-
2714
- TextLayer.prototype.format = function(format) {
2715
- throw "Cannot modify format for text layers";
2716
- };
2717
-
2718
- TextLayer.prototype.fontFamily = function(fontFamily) {
2719
- this.options.fontFamily = fontFamily;
2720
- return this;
2721
- };
2722
-
2723
- TextLayer.prototype.fontSize = function(fontSize) {
2724
- this.options.fontSize = fontSize;
2725
- return this;
2726
- };
2727
-
2728
- TextLayer.prototype.fontWeight = function(fontWeight) {
2729
- this.options.fontWeight = fontWeight;
2730
- return this;
2731
- };
2732
-
2733
- TextLayer.prototype.fontStyle = function(fontStyle) {
2734
- this.options.fontStyle = fontStyle;
2735
- return this;
2736
- };
2737
-
2738
- TextLayer.prototype.textDecoration = function(textDecoration) {
2739
- this.options.textDecoration = textDecoration;
2740
- return this;
2741
- };
2742
-
2743
- TextLayer.prototype.textAlign = function(textAlign) {
2744
- this.options.textAlign = textAlign;
2745
- return this;
2746
- };
2747
-
2748
- TextLayer.prototype.stroke = function(stroke) {
2749
- this.options.stroke = stroke;
2750
- return this;
2751
- };
2752
-
2753
- TextLayer.prototype.letterSpacing = function(letterSpacing) {
2754
- this.options.letterSpacing = letterSpacing;
2755
- return this;
2756
- };
2757
-
2758
- TextLayer.prototype.lineSpacing = function(lineSpacing) {
2759
- this.options.lineSpacing = lineSpacing;
2760
- return this;
2761
- };
2762
-
2763
- TextLayer.prototype.text = function(text) {
2764
- this.options.text = text;
2765
- return this;
2766
- };
2767
-
2768
-
2769
- /**
2770
- * generate the string representation of the layer
2771
- * @function TextLayer#toString
2772
- * @return {String}
2773
- */
2774
-
2775
- TextLayer.prototype.toString = function() {
2776
- var components, publicId, text;
2777
- if (this.options.publicId != null) {
2778
- publicId = this.getFullPublicId();
2779
- } else if (this.options.text != null) {
2780
- text = encodeURIComponent(this.options.text).replace(/%2C/g, "%E2%80%9A").replace(/\//g, "%E2%81%84");
2781
- } else {
2782
- throw "Must supply either text or public_id.";
2783
- }
2784
- components = [this.options.resourceType, textStyleIdentifier.call(this), publicId, text];
2785
- return Util.compact(components).join(":");
2786
- };
2787
-
2788
- textStyleIdentifier = function() {
2789
- var components, fontSize;
2790
- components = [];
2791
- if (this.options.fontWeight !== "normal") {
2792
- components.push(this.options.fontWeight);
2793
- }
2794
- if (this.options.fontStyle !== "normal") {
2795
- components.push(this.options.fontStyle);
2796
- }
2797
- if (this.options.textDecoration !== "none") {
2798
- components.push(this.options.textDecoration);
2799
- }
2800
- components.push(this.options.textAlign);
2801
- if (this.options.stroke !== "none") {
2802
- components.push(this.options.stroke);
2803
- }
2804
- if (!Util.isEmpty(this.options.letterSpacing)) {
2805
- components.push("letter_spacing_" + this.options.letterSpacing);
2806
- }
2807
- if (this.options.lineSpacing != null) {
2808
- components.push("line_spacing_" + this.options.lineSpacing);
2809
- }
2810
- if (this.options.fontSize != null) {
2811
- fontSize = "" + this.options.fontSize;
2812
- }
2813
- components.unshift(this.options.fontFamily, fontSize);
2814
- components = Util.compact(components).join("_");
2815
- if (!Util.isEmpty(components)) {
2816
- if (Util.isEmpty(this.options.fontFamily)) {
2817
- throw "Must supply fontFamily.";
2818
- }
2819
- if (Util.isEmpty(fontSize)) {
2820
- throw "Must supply fontSize.";
2821
- }
2822
- }
2823
- return components;
2824
- };
2825
-
2826
- return TextLayer;
2827
-
2828
- })(Layer);
2829
- SubtitlesLayer = (function(superClass) {
2830
- extend(SubtitlesLayer, superClass);
2831
-
2832
-
2833
- /**
2834
- * Represent a subtitles layer
2835
- * @constructor SubtitlesLayer
2836
- * @param {Object} options - layer parameters
2837
- */
2838
-
2839
- function SubtitlesLayer(options) {
2840
- SubtitlesLayer.__super__.constructor.call(this, options);
2841
- this.options.resourceType = "subtitles";
2842
- }
2843
-
2844
- return SubtitlesLayer;
2845
-
2846
- })(TextLayer);
2847
2866
  Cloudinary = (function() {
2848
2867
  var AKAMAI_SHARED_CDN, CF_SHARED_CDN, DEFAULT_POSTER_OPTIONS, DEFAULT_VIDEO_SOURCE_TYPES, OLD_AKAMAI_SHARED_CDN, SHARED_CDN, VERSION, absolutize, applyBreakpoints, cdnSubdomainNumber, closestAbove, cloudinaryUrlPrefix, defaultBreakpoints, finalizeResourceType, findContainerWidth, maxWidth, updateDpr;
2849
2868
 
2850
- VERSION = "2.1.2";
2869
+ VERSION = "2.1.5";
2851
2870
 
2852
2871
  CF_SHARED_CDN = "d3jpl91pxevbkh.cloudfront.net";
2853
2872
 
@@ -3311,7 +3330,14 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
3311
3330
 
3312
3331
 
3313
3332
  /**
3333
+ * Initialize the responsive behaviour.<br>
3334
+ * Calls {@link Cloudinary#cloudinary_update} to modify image tags.
3314
3335
  * @function Cloudinary#responsive
3336
+ * @param {Object} options
3337
+ * @param {String} [options.responsive_class='cld-responsive'] - provide an alternative class used to locate img tags
3338
+ * @param {number} [options.responsive_debounce=100] - the debounce interval in milliseconds.
3339
+ * @param {boolean} [bootstrap=true] if true processes the img tags by calling cloudinary_update. When false the tags will be processed only after a resize event.
3340
+ * @see {@link Cloudinary#cloudinary_update} for additional configuration parameters
3315
3341
  */
3316
3342
 
3317
3343
  Cloudinary.prototype.responsive = function(options, bootstrap) {
@@ -3487,6 +3513,8 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
3487
3513
 
3488
3514
  /**
3489
3515
  * Finds all `img` tags under each node and sets it up to provide the image through Cloudinary
3516
+ * @param {Element[]} nodes the parent nodes to search for img under
3517
+ * @param {Object} [options={}] options and transformations params
3490
3518
  * @function Cloudinary#processImageTags
3491
3519
  */
3492
3520
 
@@ -3495,6 +3523,9 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
3495
3523
  if (options == null) {
3496
3524
  options = {};
3497
3525
  }
3526
+ if (Util.isEmpty(nodes)) {
3527
+ return this;
3528
+ }
3498
3529
  options = Util.defaults({}, options, this.config());
3499
3530
  images = (function() {
3500
3531
  var j, len, ref, results;
@@ -3557,7 +3588,7 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
3557
3588
  imageWidth = requiredWidth;
3558
3589
  Util.setData(tag, 'width', requiredWidth);
3559
3590
  }
3560
- return requiredWidth;
3591
+ return imageWidth;
3561
3592
  };
3562
3593
 
3563
3594
 
@@ -3577,16 +3608,14 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
3577
3608
  */
3578
3609
 
3579
3610
  Cloudinary.prototype.cloudinary_update = function(elements, options) {
3580
- var client_hints, containerWidth, dataSrc, j, len, match, ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, requiredWidth, responsive, responsiveClass, roundDpr, setUrl, tag;
3611
+ var containerWidth, dataSrc, j, len, match, ref, ref1, ref2, ref3, ref4, ref5, requiredWidth, responsive, responsiveClass, roundDpr, setUrl, tag;
3581
3612
  if (options == null) {
3582
3613
  options = {};
3583
3614
  }
3584
- client_hints = (ref = (ref1 = options.client_hints) != null ? ref1 : this.config('client_hints')) != null ? ref : false;
3585
- client_hints = client_hints || (typeof document !== "undefined" && document !== null ? document.querySelector('meta[http-equiv="Accept-CH"]') : void 0);
3586
- if (client_hints) {
3587
- return;
3615
+ if (elements === null) {
3616
+ return this;
3588
3617
  }
3589
- responsive = (ref2 = (ref3 = options.responsive) != null ? ref3 : this.config('responsive')) != null ? ref2 : false;
3618
+ responsive = (ref = (ref1 = options.responsive) != null ? ref1 : this.config('responsive')) != null ? ref : false;
3590
3619
  elements = (function() {
3591
3620
  switch (false) {
3592
3621
  case !Util.isArray(elements):
@@ -3599,15 +3628,15 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
3599
3628
  return [elements];
3600
3629
  }
3601
3630
  })();
3602
- responsiveClass = (ref4 = (ref5 = this.responsiveConfig['responsive_class']) != null ? ref5 : options['responsive_class']) != null ? ref4 : this.config('responsive_class');
3603
- roundDpr = (ref6 = options['round_dpr']) != null ? ref6 : this.config('round_dpr');
3631
+ responsiveClass = (ref2 = (ref3 = this.responsiveConfig['responsive_class']) != null ? ref3 : options['responsive_class']) != null ? ref2 : this.config('responsive_class');
3632
+ roundDpr = (ref4 = options['round_dpr']) != null ? ref4 : this.config('round_dpr');
3604
3633
  for (j = 0, len = elements.length; j < len; j++) {
3605
3634
  tag = elements[j];
3606
- if (!((ref7 = tag.tagName) != null ? ref7.match(/img/i) : void 0)) {
3635
+ if (!((ref5 = tag.tagName) != null ? ref5.match(/img/i) : void 0)) {
3607
3636
  continue;
3608
3637
  }
3609
3638
  setUrl = true;
3610
- if (responsive && !client_hints) {
3639
+ if (responsive) {
3611
3640
  Util.addClass(tag, responsiveClass);
3612
3641
  }
3613
3642
  dataSrc = Util.getData(tag, 'src-cache') || Util.getData(tag, 'src');
@@ -3935,7 +3964,7 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
3935
3964
  return jQuery(e.target).trigger('cloudinarydone', data);
3936
3965
  });
3937
3966
  this.bind('fileuploadsend', function(e, data) {
3938
- data.headers = $.extend({}, data.headers, {
3967
+ data.headers = jQuery.extend({}, data.headers, {
3939
3968
  'X-Unique-Upload-Id': (Math.random() * 10000000000).toString(16)
3940
3969
  });
3941
3970
  return true;
@@ -4063,7 +4092,7 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
4063
4092
  TextLayer: TextLayer,
4064
4093
  SubtitlesLayer: SubtitlesLayer,
4065
4094
  Cloudinary: Cloudinary,
4066
- VERSION: "2.1.2",
4095
+ VERSION: "2.1.5",
4067
4096
  CloudinaryJQuery: CloudinaryJQuery
4068
4097
  };
4069
4098
  return cloudinary;