diff options
author | Jed Foster <jed@jedfoster.com> | 2014-02-09 21:08:25 -0800 |
---|---|---|
committer | Jed Foster <jed@jedfoster.com> | 2014-02-09 21:08:25 -0800 |
commit | b42e95cae66752b0f46e88a3bc405079f36d7240 (patch) | |
tree | 6cc1116d7e51b00640c9cfc09ff7db1fe0c74118 | |
parent | 06757e21af453c8d3fdf140e6fee9f6d4b219dc4 (diff) | |
download | Readmore.js-b42e95cae66752b0f46e88a3bc405079f36d7240.zip Readmore.js-b42e95cae66752b0f46e88a3bc405079f36d7240.tar.gz Readmore.js-b42e95cae66752b0f46e88a3bc405079f36d7240.tar.bz2 |
Urgh, remove errant console.log()
-rw-r--r-- | demo.html | 2 | ||||
-rw-r--r-- | readmore.js | 2 | ||||
-rw-r--r-- | readmore.min.js | 6 |
3 files changed, 4 insertions, 6 deletions
@@ -41,7 +41,7 @@ <h2 id="example">Example</h2> - <pre><code>$('article').readmore();</code></pre> + <pre><code class="javascript">$('article').readmore();</code></pre> <p>Yes, it’s that simple. You can change the speed of the animation, the height of the collapsed block, and the open and close elements.</p> diff --git a/readmore.js b/readmore.js index 974d9f7..dbb448f 100644 --- a/readmore.js +++ b/readmore.js @@ -139,8 +139,6 @@ el.remove(); - console.log(height); - element.data('boxHeight', height); }, diff --git a/readmore.min.js b/readmore.min.js index b7c2f63..9188b7f 100644 --- a/readmore.min.js +++ b/readmore.min.js @@ -1,7 +1,7 @@ (function(c){function g(b,a){this.element=b;this.options=c.extend({},h,a);c(this.element).data("max-height",this.options.maxHeight);c(this.element).data("height-margin",this.options.heightMargin);delete this.options.maxHeight;if(this.options.embedCSS&&!k){var d=".readmore-js-toggle, .readmore-js-section { "+this.options.sectionCSS+" } .readmore-js-section { overflow: hidden; }",e=document.createElement("style");e.type="text/css";e.styleSheet?e.styleSheet.cssText=d:e.appendChild(document.createTextNode(d)); document.getElementsByTagName("head")[0].appendChild(e);k=!0}this._defaults=h;this._name=f;this.init()}var f="readmore",h={speed:100,maxHeight:200,heightMargin:16,moreLink:'<a href="#">Read More</a>',lessLink:'<a href="#">Close</a>',embedCSS:!0,sectionCSS:"display: block; width: 100%;",startOpen:!1,expandedClass:"readmore-js-expanded",collapsedClass:"readmore-js-collapsed",beforeToggle:function(){},afterToggle:function(){}},k=!1;g.prototype={init:function(){var b=this;c(this.element).each(function(){var a= -c(this),d=a.css("max-height").replace(/[^-\d\.]/g,"")>a.data("max-height")?a.css("max-height").replace(/[^-\d\.]/g,""):a.data("max-height"),e=a.data("height-margin");"none"!=a.css("max-height")&&a.css("max-height","none");b.setBoxHeight(a);if(a.outerHeight(!0)<=d+e)return!0;a.addClass("readmore-js-section "+b.options.collapsedClass).data("sliderHeight",d);a.after(c(b.options.startOpen?b.options.lessLink:b.options.moreLink).on("click",function(d){b.toggleSlider(this,a,d)}).addClass("readmore-js-toggle")); +c(this),d=a.css("max-height").replace(/[^-\d\.]/g,"")>a.data("max-height")?a.css("max-height").replace(/[^-\d\.]/g,""):a.data("max-height"),e=a.data("height-margin");"none"!=a.css("max-height")&&a.css("max-height","none");b.setBoxHeight(a);if(a.outerHeight(!0)<=d+e)return!0;a.addClass("readmore-js-section "+b.options.collapsedClass).data("sliderHeight",d);a.after(c(b.options.startOpen?b.options.lessLink:b.options.moreLink).on("click",function(c){b.toggleSlider(this,a,c)}).addClass("readmore-js-toggle")); b.options.startOpen||a.css({height:d})});c(window).on("resize",function(a){b.resizeBoxes()})},toggleSlider:function(b,a,d){d.preventDefault();var e=this;d=newLink=sectionClass="";var f=!1;d=c(a).data("sliderHeight");c(a).height()==d?(d=c(a).data().boxHeight+"px",newLink="lessLink",f=!0,sectionClass=e.options.expandedClass):(newLink="moreLink",sectionClass=e.options.collapsedClass);e.options.beforeToggle(b,a,f);c(a).animate({height:d},{duration:e.options.speed,complete:function(){e.options.afterToggle(b, -a,f);c(b).replaceWith(c(e.options[newLink]).on("click",function(b){e.toggleSlider(this,a,b)}).addClass("readmore-js-toggle"));c(this).removeClass(e.options.collapsedClass+" "+e.options.expandedClass).addClass(sectionClass)}})},setBoxHeight:function(b){var a=b.clone().css({height:"auto",width:b.width(),overflow:"hidden"}).insertAfter(b),d=a.outerHeight(!0);a.remove();console.log(d);b.data("boxHeight",d)},resizeBoxes:function(){var b=this;c(".readmore-js-section").each(function(){var a=c(this);b.setBoxHeight(a); -(a.height()>a.data("boxHeight")||a.hasClass(b.options.expandedClass)&&a.height()<a.data("boxHeight"))&&a.css("height",a.data("boxHeight"))})},destroy:function(){var b=this;c(this.element).each(function(){var a=c(this);a.removeClass("readmore-js-section "+b.options.collapsedClass+" "+b.options.expandedClass).css({"max-height":"",height:"auto"}).next(".readmore-js-toggle").remove();a.removeData()})}};c.fn[f]=function(b){var a=arguments;if(void 0===b||"object"===typeof b)return this.each(function(){if(c.data(this, +a,f);c(b).replaceWith(c(e.options[newLink]).on("click",function(b){e.toggleSlider(this,a,b)}).addClass("readmore-js-toggle"));c(this).removeClass(e.options.collapsedClass+" "+e.options.expandedClass).addClass(sectionClass)}})},setBoxHeight:function(b){var a=b.clone().css({height:"auto",width:b.width(),overflow:"hidden"}).insertAfter(b),c=a.outerHeight(!0);a.remove();b.data("boxHeight",c)},resizeBoxes:function(){var b=this;c(".readmore-js-section").each(function(){var a=c(this);b.setBoxHeight(a);(a.height()> +a.data("boxHeight")||a.hasClass(b.options.expandedClass)&&a.height()<a.data("boxHeight"))&&a.css("height",a.data("boxHeight"))})},destroy:function(){var b=this;c(this.element).each(function(){var a=c(this);a.removeClass("readmore-js-section "+b.options.collapsedClass+" "+b.options.expandedClass).css({"max-height":"",height:"auto"}).next(".readmore-js-toggle").remove();a.removeData()})}};c.fn[f]=function(b){var a=arguments;if(void 0===b||"object"===typeof b)return this.each(function(){if(c.data(this, "plugin_"+f)){var a=c.data(this,"plugin_"+f);a.destroy.apply(a)}c.data(this,"plugin_"+f,new g(this,b))});if("string"===typeof b&&"_"!==b[0]&&"init"!==b)return this.each(function(){var d=c.data(this,"plugin_"+f);d instanceof g&&"function"===typeof d[b]&&d[b].apply(d,Array.prototype.slice.call(a,1))})}})(jQuery); |