From 96a0654620101635ece5deefd1591bf15e53348e Mon Sep 17 00:00:00 2001 From: popallo Date: Tue, 22 Oct 2013 12:15:35 +0200 Subject: [PATCH] v0.9 lot of change, ... --- jquery.enlargeable.js | 129 +++++++++++++++++++++++------------ jquery.enlargeable.packed.js | 4 +- 2 files changed, 88 insertions(+), 45 deletions(-) diff --git a/jquery.enlargeable.js b/jquery.enlargeable.js index f7f5a10..a77ae58 100644 --- a/jquery.enlargeable.js +++ b/jquery.enlargeable.js @@ -1,8 +1,10 @@ /* - * Jquery Enlargeable plugin - v0.7 - https://github.com/popallo/enlargeable + * Jquery Enlargeable plugin - https://github.com/popallo/enlargeable * Creation => 16-10-2013 * Update => 17-10-2013 - * © 2013, Aurélien Dazy, Licensed MIT (https://github.com/popallo/enlargeable/blob/master/LICENSE) + * © 2013, Licensed MIT (https://github.com/popallo/enlargeable/blob/master/LICENSE) + * @author popallo + * @version 0.9 * * DEPENDS : jquery >= 1.10.x, jquery ui >= 1.10.x (optional) * @@ -17,60 +19,50 @@ *
* * - * TODO add callbacks + * TODO add more callbacks * TODO make enlargeable fullscreenable... ^^ + * TODO make enlargeable skinnable... ^^ + * TODO make it works for "enlarge" or "reduce" size first * TODO make the plugin more flexible * TODO more and more and more ... * */ -(function ( $ ) { +;(function ( $ ) { + 'use strict'; var Enlargeable = function( options ) { - var $settings = $.extend({}, Enlargeable.settings, options); - this.each(function(){ - var $element = $(this); //the enlargeable element - var $elementWidth = $element.width(); //element's width - var $elementHasMaxHeight = $element.css('max-height').length; //useful if element has a max-height defined - var $parentWidth = ''; - var $tooltipMsg=''; + var $self = this; + return this.each(function(){ + var $oSettings = $.extend({}, Enlargeable.settings, options), + $element = $(this), + $enlargeBT = $('
').addClass('enlargeBT').attr('title',''), + $tooltipTitle=$oSettings.enlargeTitle; + /* set options */ + $oSettings.fnInit($oSettings); /* in case of "tooltip" option is true, test if jquery ui is in da place ! */ - if($settings.tooltip && !$.ui){ + if($oSettings.tooltip && !$.ui){ throw new Error('jquery.enlargeable requires jQuery ui 1.10.x OR make "tooltip" option to FALSE'); } /* make the enlarge button */ - $element.parent().prepend('
'); + $element.parent().prepend($enlargeBT); /* tooltip init if "tooltip" option is true */ - $settings.tooltip?$('.enlargeBT').tooltip({position: { my: "center bottom-20", at: "right top" }, content: $settings.enlargeMsg }):''; + $oSettings.tooltip?$('.enlargeBT').tooltip({position: { my: "center bottom-20", at: "right top" }, content: $tooltipTitle }):''; /* click */ $('.enlargeBT',$element.parent()).on('click',function(){ - var $this = $(this); - var $parents = $this.parents('.enlargeablePrison'); + var $bt = $(this), + $element = $bt.next(); + /* after click callback */ + $oSettings.fnAfterClick($oSettings); /* enlarge bt action */ - if(!$this.hasClass('reduce')){ - $tooltipMsg=$settings.reduceMsg; - $parents.each(function(){ - $parentWidth = $parents.width(); - $(this).animate({width:$settings.enlargeWidth+'px'},$settings.speed); - }); - $element.animate({height:'100%', width:($settings.enlargeWidth)+'px'},$settings.speed); - if($elementHasMaxHeight>0){ //verify if element has a define max-height - $elementMaxHeight=$element.css('max-height'); - $element.css('max-height','100%'); - } + if(!$element.hasClass('reduce')){ + $self.originalSize = Enlargeable.enlarge($oSettings, $element); + $tooltipTitle=$oSettings.reduceTitle; /* reduce bt action */ }else{ - $tooltipMsg=$settings.enlargeMsg; - $parents.each(function(){ - $(this).animate({width:$parentWidth+'px'},$settings.speed); - }); - $element.animate({width:$elementWidth+'px'},$settings.speed); - if($elementHasMaxHeight>0){ //verify if element has a define max-height - $element.css('max-height',$elementMaxHeight); - } - - + Enlargeable.reduce($oSettings, $self.originalSize); + $tooltipTitle=$oSettings.enlargeTitle; } - $this.toggleClass('reduce'); //add or remove .reduce class - $settings.tooltip?$this.tooltip({position: { my: "center bottom-20", at: "right top" }, content: $tooltipMsg }):''; + $element.toggleClass('reduce'); //add or remove .reduce class + $oSettings.tooltip?$bt.tooltip({position: { my: "center bottom-20", at: "right top" }, content: $tooltipTitle }):''; }); }); }; @@ -78,11 +70,62 @@ Enlargeable.settings = { tooltip:false, enlargeWidth:'958', //target width - enlargeMsg:'', - reduceMsg:'', - speed:'500' + enlargeTitle:'', + reduceTitle:'', + speed:'500', + fnInit: function($oSettings){}, + fnAfterClick: function($oSettings){}, + fnEnlarge: function($oSettings){}, + fnReduce: function($oSettings){} + }; + /* + * Function enlarge + * + */ + Enlargeable.enlarge = function($oSettings, $element) { + var $oElement = { //the enlargeable element + element:$element, + width:$element.width(), + height:$element.height() + }, + $elementMaxHeight = $element.css('max-height').length, //useful if element has a max-height defined + $parents = $element.parents('.enlargeablePrison'), + $aParents = [], + $o = {}; + $parents.each(function(){ + var $this = $(this); + $aParents.push({ + element:$this, + width:$this.width(), + height:$this.height() + }); + $this.animate({width:$oSettings.enlargeWidth+'px',height:'100%'},$oSettings.speed); + }); + $element.animate({height:'100%', width:($oSettings.enlargeWidth)+'px'},$oSettings.speed, function(){ + $oSettings.fnEnlarge($oSettings); + }); + if($elementMaxHeight>0){ + $element.css('max-height','100%'); + } + return $o = { + oElement:$oElement, + aParents:$aParents + }; + }; + /* + * Function reduce + * + */ + Enlargeable.reduce = function($oSettings, $oSize) { + var $element = $oSize.oElement.element; + $.each($oSize.aParents, function(){ + this.element.animate({width:this.width+'px',height:this.height+'px'},$oSettings.speed); + }); + $element.animate({width:$oSize.oElement.width+'px',height:$oSize.oElement.height+'px'},$oSettings.speed, function(){ + $oSettings.fnReduce($oSettings); + }); }; /* jQuery aliases */ $.fn.enlargeable = Enlargeable; -}( $ )); +}( $ )); \ No newline at end of file diff --git a/jquery.enlargeable.packed.js b/jquery.enlargeable.packed.js index c671850..e431439 100644 --- a/jquery.enlargeable.packed.js +++ b/jquery.enlargeable.packed.js @@ -1,2 +1,2 @@ -/* v0.7 */ -eval(function(p,a,c,k,e,d){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(7($){5 h=7(E){5 $2=$.J({},h.2,E);3.j(7(){5 $4=$(3);5 $s=$4.8();5 $l=$4.c(\'d-a\').R;5 $m=\'\';5 $g=\'\';e($2.6&&!$.t){Q T V(\'U.w P W t 1.10.x O K "6" N M L\')}$4.y().S(\'\');$2.6?$(\'.k\').6({u:{r:"B G-I",D:"H C"},z:$2.o}):\'\';$(\'.k\',$4.y()).X(\'17\',7(){5 $3=$(3);5 $b=$3.b(\'.11\');e(!$3.Z(\'q\')){$g=$2.A;$b.j(7(){$m=$b.8();$(3).i({8:$2.n+\'f\'},$2.9)});$4.i({a:\'p%\',8:($2.n)+\'f\'},$2.9);e($l>0){$F=$4.c(\'d-a\');$4.c(\'d-a\',\'p%\')}}Y{$g=$2.o;$b.j(7(){$(3).i({8:$m+\'f\'},$2.9)});$4.i({8:$s+\'f\'},$2.9);e($l>0){$4.c(\'d-a\',$F)}}$3.14(\'q\');$2.6?$3.6({u:{r:"B G-I",D:"H C"},z:$g}):\'\'})})};h.2={6:15,n:\'13\',o:\'\',A:\'\',9:\'12\'};$.16.w=h}($));',62,75,'||settings|this|element|var|tooltip|function|width|speed|height|parents|css|max|if|px|tooltipMsg|Enlargeable|animate|each|enlargeBT|elementHasMaxHeight|parentWidth|enlargeWidth|enlargeMsg|100|reduce|my|elementWidth|ui|position|div|enlargeable||parent|content|reduceMsg|center|top|at|options|elementMaxHeight|bottom|right|20|extend|make|FALSE|to|option|OR|requires|throw|length|prepend|new|jquery|Error|jQuery|on|else|hasClass||enlargeablePrison|500|958|toggleClass|false|fn|click|le|Agrandir|title|class|tableau'.split('|'),0,{})) \ No newline at end of file +/* v0.9 */ +eval(function(p,a,c,k,e,d){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}(';(4($){\'13 12\';9 8=4(B){9 $p=5;S 5.r(4(){9 $2=$.11({},8.y,B),$3=$(5),$d=$(\'<14/>\').15(\'d\').18(\'Z\',\'\'),$f=$2.n;$2.Q($2);k($2.a&&!$.H){16 19 X(\'U.C V W H 1.10.x Y T "a" 17 1j 1m\')}$3.I().1a($d);$2.a?$(\'.d\').a({F:{G:"J z-u",t:"v w"},A:$f}):\'\';$(\'.d\',$3.I()).1n(\'1p\',4(){9 $q=$(5),$3=$q.1l();$2.O($2);k(!$3.1k(\'j\')){$p.D=8.P($2,$3);$f=$2.R}1d{8.j($2,$p.D);$f=$2.n}$3.1c(\'j\');$2.a?$q.a({F:{G:"J z-u",t:"v w"},A:$f}):\'\'})})};8.y={a:1o,l:\'1h\',n:\'\',R:\'\',g:\'1i\',Q:4($2){},O:4($2){},M:4($2){},E:4($2){}};8.P=4($2,$3){9 $c={3:$3,7:$3.7(),6:$3.6()},$N=$3.L(\'K-6\').1f,$m=$3.m(\'.1e\'),$e=[],$o={};$m.r(4(){9 $5=$(5);$e.1b({3:$5,7:$5.7(),6:$5.6()});$5.i({7:$2.l+\'b\',6:\'s%\'},$2.g)});$3.i({6:\'s%\',7:($2.l)+\'b\'},$2.g,4(){$2.M($2)});k($N>0){$3.L(\'K-6\',\'s%\')}S $o={c:$c,e:$e}};8.j=4($2,$h){9 $3=$h.c.3;$.r($h.e,4(){5.3.i({7:5.7+\'b\',6:5.6+\'b\'},$2.g)});$3.i({7:$h.c.7+\'b\',6:$h.c.6+\'b\'},$2.g,4(){$2.E($2)})};$.1g.C=8}($));',62,88,'||oSettings|element|function|this|height|width|Enlargeable|var|tooltip|px|oElement|enlargeBT|aParents|tooltipTitle|speed|oSize|animate|reduce|if|enlargeWidth|parents|enlargeTitle||self|bt|each|100|at|20|right|top||settings|bottom|content|options|enlargeable|originalSize|fnReduce|position|my|ui|parent|center|max|css|fnEnlarge|elementMaxHeight|fnAfterClick|enlarge|fnInit|reduceTitle|return|make|jquery|requires|jQuery|Error|OR|title||extend|strict|use|div|addClass|throw|option|attr|new|prepend|push|toggleClass|else|enlargeablePrison|length|fn|958|500|to|hasClass|next|FALSE|on|false|click'.split('|'),0,{})) \ No newline at end of file