diff --git a/CHANGELOG.md b/CHANGELOG.md index 80b8cac..e032350 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,29 +1,33 @@ #### CHANGE LOG -###### 0.0.1 -* Responsive Image +###### 2.0.1 +* DOM Jquery + * Fallback to parent element when interpolating + +###### 2.0.0 +* removed jquery (except for dom handler) * Responsive Background Image + * combined into Responsive Image -###### 0.1.0 +###### 1.0.2 * Core - * Implemented class pattern for extending - * Added interpolation for getting dom attributes for responsive values + * Interpolation accepts a scope as 2nd argument for better element selection control -###### 0.1.1 -* Bugfix and cleanup +###### 1.0.1 +* Responsive Background Image + * Passes temp image with loaded event ###### 1.0.0 * Core * Interpolation now uses css selectors instead of just an element id -###### 1.0.1 -* Responsive Background Image - * Passes temp image with loaded event +###### 0.1.1 +* Bugfix and cleanup -###### 1.0.2 +###### 0.1.0 * Core - * Interpolation accepts a scope as 2nd argument for better element selection control + * Implemented class pattern for extending + * Added interpolation for getting dom attributes for responsive values -###### 2.0.0 -* removed jquery (except for dom handler) +###### 0.0.1 +* Responsive Image * Responsive Background Image - * combined into Responsive Image diff --git a/demo/bumper_demo.js b/demo/bumper_demo.js index a255ad5..e11addc 100644 --- a/demo/bumper_demo.js +++ b/demo/bumper_demo.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 (function() { window.Bumper.Responsive.Breakpoint.setBreakpoints({ mobile: { diff --git a/lib/bumper-core.js b/lib/bumper-core.js index c1fe2ac..74c81f5 100644 --- a/lib/bumper-core.js +++ b/lib/bumper-core.js @@ -1,10 +1,10 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 /* * * bumper core * * https://github.com/brewster1134/bumper * * - * * @version 2.0.0 + * * @version 2.0.1 * * @author Ryan Brewster * * Copyright (c) 2014 * * Licensed under the MIT license. @@ -36,7 +36,8 @@ }; })(this)); return window.onresize = requestAnimationFrame(function() { - return window.Bumper.Responsive.Breakpoint.checkBreakpointChange(); + var _ref, _ref1; + return (_ref = window.Bumper.Responsive) != null ? (_ref1 = _ref.Breakpoint) != null ? _ref1.checkBreakpointChange() : void 0 : void 0; }); }; @@ -81,16 +82,15 @@ url = el.getAttribute("data-bumper-responsive-image-url-" + breakpoint) || el.getAttribute('data-bumper-responsive-image-url'); params = el.getAttribute("data-bumper-responsive-image-url-params-" + breakpoint) || el.getAttribute('data-bumper-responsive-image-url-params'); if (!url) { - console.warn("data-bumper-responsive-image-url[-" + breakpoint + "] is not set.", el); - return; + throw "data-bumper-responsive-image-url[-" + breakpoint + "] is not set."; } - fullUrl = params ? "" + url + "?" + params : url; + fullUrl = params ? url + "?" + params : url; if (fullUrl.indexOf('{') > -1) { if (window.Bumper.Dom) { fullUrl = window.Bumper.Dom.interpolateElementAttrs(fullUrl, el); } else { if (el.className.indexOf('bumper-responsive-image-delay' === -1)) { - el.className = "" + el.className + " bumper-responsive-image-delay"; + el.className = el.className + " bumper-responsive-image-delay"; } return; } diff --git a/lib/bumper-dom-jquery.js b/lib/bumper-dom-jquery.js index acfce37..42b06ea 100644 --- a/lib/bumper-dom-jquery.js +++ b/lib/bumper-dom-jquery.js @@ -1,10 +1,10 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 /* * * bumper | dom | jquery * * https://github.com/brewster1134/bumper * * - * * @version 2.0.0 + * * @version 2.0.1 * * @author Ryan Brewster * * Copyright (c) 2014 * * Licensed under the MIT license. @@ -35,12 +35,13 @@ for (_i = 0, _len = matches.length; _i < _len; _i++) { match = matches[_i]; splitArray = match.replace(/[{}]/g, '').split(':'); - if ($rootEl) { - $element = $rootEl.closest("" + splitArray[0]); - } - if (!$element || !$element.length) { + $element = $rootEl.closest("" + splitArray[0]); + if (!$element.length) { $element = $("" + splitArray[0]).first(); } + if (!$element.length) { + $element = $rootEl.parent(); + } if (!$element.length) { throw "No element for `" + splitArray[0] + "` found."; } diff --git a/lib/bumper-responsive-breakpoint.js b/lib/bumper-responsive-breakpoint.js index 354f769..1efdbf6 100644 --- a/lib/bumper-responsive-breakpoint.js +++ b/lib/bumper-responsive-breakpoint.js @@ -1,10 +1,10 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 /* * * bumper | responsive | breakpoint * * https://github.com/brewster1134/bumper * * - * * @version 2.0.0 + * * @version 2.0.1 * * @author Ryan Brewster * * Copyright (c) 2014 * * Licensed under the MIT license. @@ -27,15 +27,15 @@ BumperResponsiveBreakpoint.prototype.setBreakpoints = function(breakpoints) { var data, name; if (typeof breakpoints !== 'object') { - return console.warn('breakpoints must be an object'); + throw 'breakpoints must be an object'; } for (name in breakpoints) { data = breakpoints[name]; if (data.min === void 0) { - return console.warn("breakpoint " + name + " must have a min value"); + throw "breakpoint " + name + " must have a min value"; } if (data.max === void 0) { - return console.warn("breakpoint " + name + " must have a max value"); + throw "breakpoint " + name + " must have a max value"; } } return this.list = breakpoints; @@ -55,7 +55,7 @@ BumperResponsiveBreakpoint.prototype.setCurrentFunction = function(func) { if (typeof func !== 'function') { - return console.warn('Must be a function!'); + throw 'Must be a function!'; } return this.getCurrent = func; }; diff --git a/lib/bumper-responsive-image.js b/lib/bumper-responsive-image.js index ac422de..9886500 100644 --- a/lib/bumper-responsive-image.js +++ b/lib/bumper-responsive-image.js @@ -1,10 +1,10 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 /* * * bumper | responsive | image * * https://github.com/brewster1134/bumper * * - * * @version 2.0.0 + * * @version 2.0.1 * * @author Ryan Brewster * * Copyright (c) 2014 * * Licensed under the MIT license. diff --git a/spec/index.html b/spec/index.html index 9429775..b77aa7c 100644 --- a/spec/index.html +++ b/spec/index.html @@ -5,15 +5,32 @@ - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/bumper-core.coffee b/src/bumper-core.coffee index d0e39e8..02d5130 100644 --- a/src/bumper-core.coffee +++ b/src/bumper-core.coffee @@ -2,7 +2,7 @@ # * bumper core # * https://github.com/brewster1134/bumper # * -# * @version 2.0.0 +# * @version 2.0.1 # * @author Ryan Brewster # * Copyright (c) 2014 # * Licensed under the MIT license. @@ -27,7 +27,7 @@ # check for breakpoint changes on window resize window.onresize = requestAnimationFrame -> - window.Bumper.Responsive.Breakpoint.checkBreakpointChange() + window.Bumper.Responsive?.Breakpoint?.checkBreakpointChange() # Creates a mutation observor for bumper modules when new elements are added to the dom # Register a module into the switch statement with how to handle the new element diff --git a/src/bumper-dom-jquery.coffee b/src/bumper-dom-jquery.coffee index f2af992..a2c6d73 100644 --- a/src/bumper-dom-jquery.coffee +++ b/src/bumper-dom-jquery.coffee @@ -2,7 +2,7 @@ # * bumper | dom | jquery # * https://github.com/brewster1134/bumper # * -# * @version 2.0.0 +# * @version 2.0.1 # * @author Ryan Brewster # * Copyright (c) 2014 # * Licensed under the MIT license. @@ -31,13 +31,14 @@ # extract each interpolation declaration splitArray = match.replace(/[{}]/g, '').split ':' - # find first match within elements parents - if $rootEl - $element = $rootEl.closest("#{splitArray[0]}") + # find match within element's parent chain + $element = $rootEl.closest("#{splitArray[0]}") - # add any matching elements anywhere on the dom - if !$element || !$element.length - $element = $("#{splitArray[0]}").first() + # find first matching elemnt anywhere in the dom + $element = $("#{splitArray[0]}").first() unless $element.length + + # use the direct parent + $element = $rootEl.parent() unless $element.length throw "No element for `#{splitArray[0]}` found." unless $element.length diff --git a/src/bumper-responsive-breakpoint.coffee b/src/bumper-responsive-breakpoint.coffee index ee39a33..087debc 100644 --- a/src/bumper-responsive-breakpoint.coffee +++ b/src/bumper-responsive-breakpoint.coffee @@ -2,7 +2,7 @@ # * bumper | responsive | breakpoint # * https://github.com/brewster1134/bumper # * -# * @version 2.0.0 +# * @version 2.0.1 # * @author Ryan Brewster # * Copyright (c) 2014 # * Licensed under the MIT license. diff --git a/src/bumper-responsive-image.coffee b/src/bumper-responsive-image.coffee index 607f26e..991f06d 100644 --- a/src/bumper-responsive-image.coffee +++ b/src/bumper-responsive-image.coffee @@ -2,7 +2,7 @@ # * bumper | responsive | image # * https://github.com/brewster1134/bumper # * -# * @version 2.0.0 +# * @version 2.0.1 # * @author Ryan Brewster # * Copyright (c) 2014 # * Licensed under the MIT license.