diff options
author | Jed Foster <jed@jedfoster.com> | 2013-09-21 22:03:12 -0700 |
---|---|---|
committer | Jed Foster <jed@jedfoster.com> | 2013-09-21 22:03:12 -0700 |
commit | 05130608c3c9fb8a16e1048a5e92a5204231e715 (patch) | |
tree | d56e797f6fe686e9e1074eb58ffc74c3ea226efa /readmore.js | |
parent | a94c7743f8607639fe72dab2eb2dbf23cb4583cf (diff) | |
download | Readmore.js-05130608c3c9fb8a16e1048a5e92a5204231e715.zip Readmore.js-05130608c3c9fb8a16e1048a5e92a5204231e715.tar.gz Readmore.js-05130608c3c9fb8a16e1048a5e92a5204231e715.tar.bz2 |
Expose an option to disable the embedded CSS altogether
Diffstat (limited to 'readmore.js')
-rw-r--r-- | readmore.js | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/readmore.js b/readmore.js index c8d6873..8edfa48 100644 --- a/readmore.js +++ b/readmore.js @@ -13,12 +13,14 @@ maxHeight: 200, moreLink: '<a href="#">Read More</a>', lessLink: '<a href="#">Close</a>', + embedCSS: true, sectionCSS: 'display: block; width: 100%;', // callbacks beforeToggle: function(){}, afterToggle: function(){} - }; + }, + cssEmbedded = false; function Readmore( element, options ) { this.element = element; @@ -29,14 +31,18 @@ delete(this.options.maxHeight); - var styles = '.readmore-js-toggle, .readmore-js-section { ' + this.options.sectionCSS + ' } .readmore-js-section { overflow: hidden; }'; + if(this.options.embedCSS && ! cssEmbedded) { + var styles = '.readmore-js-toggle, .readmore-js-section { ' + this.options.sectionCSS + ' } .readmore-js-section { overflow: hidden; }'; - (function(d,u) { - var css=d.createElement('style'); - css.type = 'text/css'; - css.appendChild(d.createTextNode(u)); - d.getElementsByTagName("head")[0].appendChild(css); - }(document, styles)); + (function(d,u) { + var css=d.createElement('style'); + css.type = 'text/css'; + css.appendChild(d.createTextNode(u)); + d.getElementsByTagName("head")[0].appendChild(css); + }(document, styles)); + + cssEmbedded = true; + } this._defaults = defaults; this._name = readmore; |