diff options
author | Chad Kieffer <chad@2tbsp.com> | 2008-11-28 22:02:46 +0000 |
---|---|---|
committer | Chad Kieffer <chad@2tbsp.com> | 2008-11-28 22:02:46 +0000 |
commit | bb8fa3c4171d18c0ebe85920aefab09cc6e7f474 (patch) | |
tree | bc92e90cbc462761763483d655b4aa3610d3c539 | |
parent | 4c2d4abb1cf349f4e58c9c8dd7d74284d7bba6c7 (diff) |
Dynamically reset the dimensions of resized photos to fit if they're too wide.
-rw-r--r-- | themes/default/jquery/jquery.dimensions.min.js | 12 | ||||
-rw-r--r-- | themes/default/jquery/jquery.ui.init.js | 27 | ||||
-rw-r--r-- | themes/default/views/page.html.php | 3 |
3 files changed, 31 insertions, 11 deletions
diff --git a/themes/default/jquery/jquery.dimensions.min.js b/themes/default/jquery/jquery.dimensions.min.js new file mode 100644 index 00000000..34c06dee --- /dev/null +++ b/themes/default/jquery/jquery.dimensions.min.js @@ -0,0 +1,12 @@ +/* Copyright (c) 2007 Paul Bakaus (paul.bakaus@googlemail.com) and Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net) + * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) + * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. + * + * $LastChangedDate: 2007-12-20 08:43:48 -0600 (Thu, 20 Dec 2007) $ + * $Rev: 4257 $ + * + * Version: 1.2 + * + * Requires: jQuery 1.2+ + */ +(function($){$.dimensions={version:'1.2'};$.each(['Height','Width'],function(i,name){$.fn['inner'+name]=function(){if(!this[0])return;var torl=name=='Height'?'Top':'Left',borr=name=='Height'?'Bottom':'Right';return this.is(':visible')?this[0]['client'+name]:num(this,name.toLowerCase())+num(this,'padding'+torl)+num(this,'padding'+borr);};$.fn['outer'+name]=function(options){if(!this[0])return;var torl=name=='Height'?'Top':'Left',borr=name=='Height'?'Bottom':'Right';options=$.extend({margin:false},options||{});var val=this.is(':visible')?this[0]['offset'+name]:num(this,name.toLowerCase())+num(this,'border'+torl+'Width')+num(this,'border'+borr+'Width')+num(this,'padding'+torl)+num(this,'padding'+borr);return val+(options.margin?(num(this,'margin'+torl)+num(this,'margin'+borr)):0);};});$.each(['Left','Top'],function(i,name){$.fn['scroll'+name]=function(val){if(!this[0])return;return val!=undefined?this.each(function(){this==window||this==document?window.scrollTo(name=='Left'?val:$(window)['scrollLeft'](),name=='Top'?val:$(window)['scrollTop']()):this['scroll'+name]=val;}):this[0]==window||this[0]==document?self[(name=='Left'?'pageXOffset':'pageYOffset')]||$.boxModel&&document.documentElement['scroll'+name]||document.body['scroll'+name]:this[0]['scroll'+name];};});$.fn.extend({position:function(){var left=0,top=0,elem=this[0],offset,parentOffset,offsetParent,results;if(elem){offsetParent=this.offsetParent();offset=this.offset();parentOffset=offsetParent.offset();offset.top-=num(elem,'marginTop');offset.left-=num(elem,'marginLeft');parentOffset.top+=num(offsetParent,'borderTopWidth');parentOffset.left+=num(offsetParent,'borderLeftWidth');results={top:offset.top-parentOffset.top,left:offset.left-parentOffset.left};}return results;},offsetParent:function(){var offsetParent=this[0].offsetParent;while(offsetParent&&(!/^body|html$/i.test(offsetParent.tagName)&&$.css(offsetParent,'position')=='static'))offsetParent=offsetParent.offsetParent;return $(offsetParent);}});function num(el,prop){return parseInt($.curCSS(el.jquery?el[0]:el,prop,true))||0;};})(jQuery);
\ No newline at end of file diff --git a/themes/default/jquery/jquery.ui.init.js b/themes/default/jquery/jquery.ui.init.js index e9da2203..5c159137 100644 --- a/themes/default/jquery/jquery.ui.init.js +++ b/themes/default/jquery/jquery.ui.init.js @@ -1,18 +1,25 @@ /** - * Apply jQuery UI components + * Initialize UI elements * * @todo Write helpers to grab all jQuery UI components by class and initialize */ -$(function(){ +$("document").ready(function() { - //accordion - $('#gSettingsGroup-1').accordion({ - header: ".ui-accordion-header", - clearStyle: true - }); - - //tabs - $('#gSettings ul').tabs(); + /** + * Reset width of sized photos wider than their + * parent container so that they fit + */ + if ($("#gItem").innerWidth()) { + var containerWidth = $("#gItem").innerWidth(); + var oPhoto = $("#gItem img").filter(function() { + return this.id.match(/gPhotoID-/); + }) + if (containerWidth < oPhoto.width()) { + var proportion = containerWidth / oPhoto.width(); + oPhoto.width(containerWidth); + oPhoto.height(proportion * oPhoto.height()); + } + } }); diff --git a/themes/default/views/page.html.php b/themes/default/views/page.html.php index e3da147c..facca070 100644 --- a/themes/default/views/page.html.php +++ b/themes/default/views/page.html.php @@ -23,7 +23,8 @@ <script src="<?= $theme->url("jquery/jquery.ui.js") ?>" type="text/javascript"></script> <script src="<?= $theme->url("jquery/jquery.ui.tabs.js") ?>" type="text/javascript"></script> <!--script src="<?= $theme->url("jquery/jquery.ui.accordion.js") ?>" type="text/javascript"></script--> - <!--script src="<?= $theme->url("jquery/jquery.ui.init.js") ?>" type="text/javascript"></script--> + <script src="<?= $theme->url("jquery/jquery.dimensions.min.js") ?>" type="text/javascript"></script> + <script src="<?= $theme->url("jquery/jquery.ui.init.js") ?>" type="text/javascript"></script> <?= $theme->head() ?> </head> |