Permalink
Browse files

No commit message

  • Loading branch information...
1 parent 538bdf1 commit 22a3232b17ada7896ad58c6b974f13d573c943a0 @karacas committed Oct 5, 2012
Showing with 79 additions and 19 deletions.
  1. +43 −0 README.md
  2. +2 −2 dev/imgLiquidDev.html
  3. +20 −0 license.txt
  4. +1 −2 src/css/imgLiquid.js.css
  5. +5 −6 src/js/imgLiquid-min.js
  6. +8 −9 src/js/imgLiquid.js
View
@@ -0,0 +1,43 @@
+#jQuery Plugin: imgLiquid v0.6
+05-10-12
+Copyright (c) 2012 Alejandro Emparan (karacas), @krc_ale
+Licensed under the MIT
+
+#A jQuery Plugin to resize images to fit in a container
+
+##Ej:
+```
+ HTML:
+ <div id="container" class="imgLiquid" style="width:300px; height:200px;">
+ <img alt="" src="http://www.juegostoystory.net/files/image/2010_Toy_Story_3_USLC12_Woody.jpg"/>
+ </div>
+
+ JS:
+ $(".imgLiquid").imgLiquid()
+
+ //+ Options:
+ $(".imgLiquid").imgLiquid({fill : true, fadeInTime: 300, verticalAlign: 'center', horizontalAlign: 'center'})
+```
+view in action: http://goo.gl/py2Is
+or play with it: http://jsfiddle.net/karacas/CrhSz/1/
+
+
+##Fatures:
+```
+ - Align
+ - Crop/Fill
+ - FadeIn
+ - All browsers (Incl. ie6)
+```
+
+
+##Options:
+```
+fill: true,
+verticalAlign: 'center', //'top' // 'bottom'
+horizontalAlign: 'center', // 'left' // 'right'
+fadeInTime: 0,
+responsive: false,
+delay: 0
+```
+
View
@@ -17,7 +17,7 @@
<!-- EXAMPLE ====================================-->
<script type="text/javascript">
$(document).ready(function () {
- $(".imgLiquidFill").imgLiquid({fill:true});
+ $(".imgLiquidFill").imgLiquid({fill:true, fadeInTime:500});
$(".imgLiquidNoFill").imgLiquid({fill:false});
});
</script>
@@ -35,7 +35,7 @@
}
.boxSep{
background-color:#f7f7f7;
- border: 2px solid #ccc;
+ border: 1px solid #ddd;
margin:10px;
float:left;
margin-right:30px;
View
@@ -0,0 +1,20 @@
+Copyright (c) 2012 Alejandro Emparan (karacas), @krc_ale
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -5,5 +5,4 @@
}
.imgLiquid img{
visibility:hidden;
-}
-
+}
View
@@ -1,6 +1,5 @@
/*
- jQuery Plugnin: imgLiquid v0.6
- http://www.proyectiva.com
+ jQuery Plugin: imgLiquid v0.6
@krc_ale
ex:
@@ -10,12 +9,12 @@
fill: true,
verticalAlign: 'center', //'top' // 'bottom'
horizontalAlign: 'center', // 'left' // 'right'
- fadeTime: 0,
+ fadeInTime: 0,
responsive: false,
delay: 0,
- Copyright (c) 2012 Alejandro Emparan (karacas), http://www.proyectiva.com
+ Copyright (c) 2012 Alejandro Emparan (karacas), @krc_ale
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@@ -35,7 +34,7 @@
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
+*/
//
/*
* jQuery resize event - v1.1 - 3/14/2010
@@ -44,4 +43,4 @@
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
-(function($){$.fn.extend({imgLiquid:function(options){var isIE=/*@cc_on!@*/false;this.defaultOptions={};var settings=$.extend({fill:true,fadeTime:0,verticalAlign:"center",horizontalAlign:"center",delay:0,removeBoxBackground:true,ieFadeOff:true,imageRendering:"auto",responsive:false},this.defaultOptions,options);if(isIE&&settings.ieFadeOff){settings.fadeTime=0}if(settings.responsive){responsiveOn()}return this.each(function($i){var $imgBox=$(this);var $img=$("img:first",$imgBox);$img.fadeTo(0,0);$img.css("visibility","visible");$img.css("display","block");$img.css("image-rendering",settings.imageRendering);if(settings.imageRendering=="optimizeQuality"){$img.css("-ms-interpolation-mode","bicubic")}$imgBox.css("display","block");$imgBox.css("overflow","hidden");$img.ILrunned=false;$img.ILprocessed=false;$img.ILerror=false;$img.ILloaded=false;if(settings.responsive){$imgBox.resize(function(e){var $$imgBox=$imgBox;var $$img=$("img:first",$$imgBox);process($$imgBox,$$img)})}$img.load(function(){if(!Boolean($img.width()===0&&$img.height()===0)){$img.ILloaded=true;setTimeout(function(){process($imgBox,$img);$img.ILrunned=true},$i*settings.delay)}}).each(function(){if(this.complete){$img.trigger("load")}});$img.error(function(){$img.ILerror=true;$img.ILrunned=true;$imgBox.css("visibility","hidden");return null});function process($imgBox,$img){var imgBoxProp=$imgBox.width()/$imgBox.height();var imgProp=$img.width()/$img.height();if(settings.fill){if(imgBoxProp>=imgProp){$img.css("width","100%");$img.css("height","auto")}else{$img.css("width","auto");$img.css("height","100%")}}else{if(imgBoxProp<=imgProp){$img.css("width","100%");$img.css("height","auto")}else{$img.css("width","auto");$img.css("height","100%")}}settings.horizontalAlign=settings.horizontalAlign.toLowerCase();var hdif=$imgBox.width()-$img.width();var margL=0;if(settings.horizontalAlign=="center"||settings.verticalAlign=="middle"){margL=hdif/2}else{if(settings.horizontalAlign=="right"){margL=hdif}}$img.css("margin-left",Math.round(margL));settings.verticalAlign=settings.verticalAlign.toLowerCase();var vdif=$imgBox.height()-$img.height();var margT=0;if(settings.verticalAlign=="center"||settings.verticalAlign=="middle"){margT=vdif/2}else{if(settings.verticalAlign=="bottom"){margT=vdif}}$img.css("margin-top",Math.round(margT));if(!$img.ILprocessed){if(settings.removeBoxBackground){$imgBox.css("background-image","none")}$img.fadeTo(settings.fadeTime,1);$img.ILprocessed=true}}})}})})(jQuery);var responPluginInit=false;function responsiveOn(){if(responPluginInit){return}responPluginInit=true;(function(n,p,u){var w=n([]),s=n.resize=n.extend(n.resize,{}),o,l="setTimeout",m="resize",t=m+"-special-event",v="delay",r="throttleWindow";s[v]=250;s[r]=true;n.event.special[m]={setup:function(){if(!s[r]&&this[l]){return false}var a=n(this);w=w.add(a);n.data(this,t,{w:a.width(),h:a.height()});if(w.length===1){q()}},teardown:function(){if(!s[r]&&this[l]){return false}var a=n(this);w=w.not(a);a.removeData(t);if(!w.length){clearTimeout(o)}},add:function(b){if(!s[r]&&this[l]){return false}var c;function a(d,h,g){var f=n(this),e=n.data(this,t);e.w=h!==u?h:f.width();e.h=g!==u?g:f.height();c.apply(this,arguments)}if(n.isFunction(b)){c=b;return a}else{c=b.handler;b.handler=a}}};function q(){o=p[l](function(){w.each(function(){var d=n(this),a=d.width(),b=d.height(),c=n.data(this,t);if(a!==c.w||b!==c.h){d.trigger(m,[c.w=a,c.h=b])}});q()},s[v])}})(jQuery,this)};
+(function($){$.fn.extend({imgLiquid:function(options){var isIE=/*@cc_on!@*/false;this.defaultOptions={};var settings=$.extend({fill:true,fadeInTime:0,verticalAlign:"center",horizontalAlign:"center",delay:0,removeBoxBackground:true,ieFadeOff:true,imageRendering:"auto",responsive:false},this.defaultOptions,options);if(isIE&&settings.ieFadeOff){settings.fadeInTime=0}if(settings.responsive){responsiveOn()}return this.each(function($i){var $imgBox=$(this);var $img=$("img:first",$imgBox);$img.fadeTo(0,0);$img.css("visibility","visible");$img.css("display","block");$img.css("image-rendering",settings.imageRendering);if(settings.imageRendering=="optimizeQuality"){$img.css("-ms-interpolation-mode","bicubic")}$imgBox.css("display","block");$imgBox.css("overflow","hidden");$img.ILrunned=false;$img.ILprocessed=false;$img.ILerror=false;$img.ILloaded=false;if(settings.responsive){$imgBox.resize(function(e){var $$imgBox=$imgBox;var $$img=$("img:first",$$imgBox);process($$imgBox,$$img)})}$img.load(function(){if(!Boolean($img.width()===0&&$img.height()===0)){$img.ILloaded=true;setTimeout(function(){process($imgBox,$img);$img.ILrunned=true},$i*settings.delay)}}).each(function(){if(this.complete){$img.trigger("load")}});$img.error(function(){$img.ILerror=true;$img.ILrunned=true;$imgBox.css("visibility","hidden");return null});function process($imgBox,$img){var imgBoxProp=$imgBox.width()/$imgBox.height();var imgProp=$img.width()/$img.height();if(settings.fill){if(imgBoxProp>=imgProp){$img.css("width","100%");$img.css("height","auto")}else{$img.css("width","auto");$img.css("height","100%")}}else{if(imgBoxProp<=imgProp){$img.css("width","100%");$img.css("height","auto")}else{$img.css("width","auto");$img.css("height","100%")}}settings.horizontalAlign=settings.horizontalAlign.toLowerCase();var hdif=$imgBox.width()-$img.width();var margL=0;if(settings.horizontalAlign=="center"||settings.verticalAlign=="middle"){margL=hdif/2}else{if(settings.horizontalAlign=="right"){margL=hdif}}$img.css("margin-left",Math.round(margL));settings.verticalAlign=settings.verticalAlign.toLowerCase();var vdif=$imgBox.height()-$img.height();var margT=0;if(settings.verticalAlign=="center"||settings.verticalAlign=="middle"){margT=vdif/2}else{if(settings.verticalAlign=="bottom"){margT=vdif}}$img.css("margin-top",Math.round(margT));if(!$img.ILprocessed){if(settings.removeBoxBackground){$imgBox.css("background-image","none")}$img.fadeTo(settings.fadeInTime,1);$img.ILprocessed=true}}})}})})(jQuery);var responPluginInit=false;function responsiveOn(){if(responPluginInit){return}responPluginInit=true;(function(n,p,u){var w=n([]),s=n.resize=n.extend(n.resize,{}),o,l="setTimeout",m="resize",t=m+"-special-event",v="delay",r="throttleWindow";s[v]=250;s[r]=true;n.event.special[m]={setup:function(){if(!s[r]&&this[l]){return false}var a=n(this);w=w.add(a);n.data(this,t,{w:a.width(),h:a.height()});if(w.length===1){q()}},teardown:function(){if(!s[r]&&this[l]){return false}var a=n(this);w=w.not(a);a.removeData(t);if(!w.length){clearTimeout(o)}},add:function(b){if(!s[r]&&this[l]){return false}var c;function a(d,h,g){var f=n(this),e=n.data(this,t);e.w=h!==u?h:f.width();e.h=g!==u?g:f.height();c.apply(this,arguments)}if(n.isFunction(b)){c=b;return a}else{c=b.handler;b.handler=a}}};function q(){o=p[l](function(){w.each(function(){var d=n(this),a=d.width(),b=d.height(),c=n.data(this,t);if(a!==c.w||b!==c.h){d.trigger(m,[c.w=a,c.h=b])}});q()},s[v])}})(jQuery,this)};
View
@@ -1,6 +1,5 @@
/*
- jQuery Plugnin: imgLiquid v0.6
- http://www.proyectiva.com
+ jQuery Plugin: imgLiquid v0.6
@krc_ale
ex:
@@ -10,12 +9,12 @@
fill: true,
verticalAlign: 'center', //'top' // 'bottom'
horizontalAlign: 'center', // 'left' // 'right'
- fadeTime: 0,
+ fadeInTime: 0,
responsive: false,
- delay: 0,
+ delay: 0
- Copyright (c) 2012 Alejandro Emparan (karacas), http://www.proyectiva.com
+ Copyright (c) 2012 Alejandro Emparan (karacas), @krc_ale
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@@ -35,7 +34,7 @@
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
+*/
//
;(function($){
$.fn.extend({
@@ -52,7 +51,7 @@
fill: true,
verticalAlign: 'center', //'top' // 'bottom'
horizontalAlign: 'center', // 'left' // 'right'
- fadeTime: 0,
+ fadeInTime: 0,
responsive: false,
delay: 0,
/**/
@@ -63,7 +62,7 @@
//ie OffAnims
if (isIE && settings.ieFadeInDisabled){
- settings.fadeTime = 0;
+ settings.fadeInTime = 0;
}
if (settings.responsive) {
responsiveOn();
@@ -185,7 +184,7 @@
//FadeIn
if (!$img.ILprocessed){
if (settings.removeBoxBackground) $imgBox.css('background-image', 'none');
- $img.fadeTo(settings.fadeTime, 1);
+ $img.fadeTo(settings.fadeInTime, 1);
$img.ILprocessed = true;
}
}

0 comments on commit 22a3232

Please sign in to comment.