Skip to content

Commit

Permalink
Change client hints behavior. Fixes #107. Remove dependency on 'jquer…
Browse files Browse the repository at this point in the history
…y.ui' Fixes #104.

* `responsive()` and `cloudinary_update()` will update `<img>` that have `data-src` and `cld-responsive` class even if using client hints. Fixes #107
* Remove dependency on 'jquery.ui' from bower.json, add config to amd test file. Fixes #104
  • Loading branch information
Amir Tocker committed Oct 26, 2016
1 parent 6a8f2db commit 1df0e88
Show file tree
Hide file tree
Showing 24 changed files with 78 additions and 437 deletions.
5 changes: 3 additions & 2 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,13 @@ module.exports = (grunt)->
browsers: grunt.option("browsers")?.toString().split(",") || ['Chrome' , 'Firefox', 'Safari', 'PhantomJS']
browserDisconnectTolerance: 3
files: [
{ pattern: 'build/*', watched: false, included: false, served: true, nocache: false}
{ pattern: 'test/docRoot/*', watched: false, included: false, served: true, nocache: false}
{ pattern: 'test/docRoot/css/*', watched: false, included: false, served: true, nocache: false}
{ pattern: 'bower_components/bootstrap/dist/css/*', watched: false, included: false, served: true, nocache: false}
{ pattern: 'bower_components/bootstrap/dist/js/*', watched: false, included: false, served: true, nocache: false}
{ pattern: 'bower_components/blueimp-file-upload/js/*', watched: false, included: false, served: true, nocache: false}
{ pattern: 'bower_components/jquery.ui/ui/*', watched: false, included: false, served: true, nocache: false}
{ pattern: 'bower_components/jquery/dist/jquery.js', watched: false, included: false, served: true, nocache: false}
]

'cloudinary-core':
Expand Down Expand Up @@ -101,7 +102,7 @@ module.exports = (grunt)->
files:
src: [
"bower_components/jquery/dist/jquery.js"
"bower_components/jquery.ui/ui/widget.js"
"bower_components/blueimp-file-upload/js/vendor/jquery.ui.widget.js"
"bower_components/blueimp-file-upload/js/jquery.fileupload.js"
"bower_components/blueimp-file-upload/js/jquery.fileupload-process.js"
"bower_components/blueimp-file-upload/js/jquery.iframe-transport.js"
Expand Down
301 changes: 0 additions & 301 deletions Gruntfile.js

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ For installation instructions of the core library which is not dependent on jQue

```html
<script src="bower_components/jquery/dist/jquery.js" type="text/javascript"></script>
<script src="bower_components/jquery.ui/ui/widget.js" type="text/javascript"></script>
<script src="bower_components/blueimp-file-upload/js/vendor/jquery.ui.widget.js" type="text/javascript"></script>
<script src="bower_components/blueimp-file-upload/js/jquery.iframe-transport.js" type="text/javascript"></script>
<script src="bower_components/blueimp-file-upload/js/jquery.fileupload.js" type="text/javascript"></script>
<script src="bower_components/blueimp-file-upload/js/jquery.fileupload-image.js" type="text/javascript"></script>
Expand Down
3 changes: 1 addition & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
"dependencies": {
"jquery": ">=1.6",
"blueimp-file-upload": ">=7.2.1",
"lodash": "3.10.x",
"jquery.ui": "1.11.4"
"lodash": "3.10.x"
},
"devDependencies": {
"jasmine": "~2.3.x",
Expand Down
16 changes: 7 additions & 9 deletions js/jquery.cloudinary.js
Original file line number Diff line number Diff line change
Expand Up @@ -3608,16 +3608,14 @@ var slice = [].slice,
*/

Cloudinary.prototype.cloudinary_update = function(elements, options) {
var client_hints, containerWidth, dataSrc, j, len, match, ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, requiredWidth, responsive, responsiveClass, roundDpr, setUrl, tag;
var containerWidth, dataSrc, j, len, match, ref, ref1, ref2, ref3, ref4, ref5, requiredWidth, responsive, responsiveClass, roundDpr, setUrl, tag;
if (options == null) {
options = {};
}
client_hints = (ref = (ref1 = options.client_hints) != null ? ref1 : this.config('client_hints')) != null ? ref : false;
client_hints = client_hints || (typeof document !== "undefined" && document !== null ? document.querySelector('meta[http-equiv="Accept-CH"]') : void 0);
if (client_hints || elements === null) {
if (elements === null) {
return this;
}
responsive = (ref2 = (ref3 = options.responsive) != null ? ref3 : this.config('responsive')) != null ? ref2 : false;
responsive = (ref = (ref1 = options.responsive) != null ? ref1 : this.config('responsive')) != null ? ref : false;
elements = (function() {
switch (false) {
case !Util.isArray(elements):
Expand All @@ -3630,15 +3628,15 @@ var slice = [].slice,
return [elements];
}
})();
responsiveClass = (ref4 = (ref5 = this.responsiveConfig['responsive_class']) != null ? ref5 : options['responsive_class']) != null ? ref4 : this.config('responsive_class');
roundDpr = (ref6 = options['round_dpr']) != null ? ref6 : this.config('round_dpr');
responsiveClass = (ref2 = (ref3 = this.responsiveConfig['responsive_class']) != null ? ref3 : options['responsive_class']) != null ? ref2 : this.config('responsive_class');
roundDpr = (ref4 = options['round_dpr']) != null ? ref4 : this.config('round_dpr');
for (j = 0, len = elements.length; j < len; j++) {
tag = elements[j];
if (!((ref7 = tag.tagName) != null ? ref7.match(/img/i) : void 0)) {
if (!((ref5 = tag.tagName) != null ? ref5.match(/img/i) : void 0)) {
continue;
}
setUrl = true;
if (responsive && !client_hints) {
if (responsive) {
Util.addClass(tag, responsiveClass);
}
dataSrc = Util.getData(tag, 'src-cache') || Util.getData(tag, 'src');
Expand Down
Loading

0 comments on commit 1df0e88

Please sign in to comment.