Karl Swedberg's "Summarize" plugin: How can I get an external link to open a "summarize" box?
My code for the summarize plugin is located here: http://jjnursingnotes.com/DEC12/jquery.summarize.js
My page (http://jjnursingnotes.com/DEC12/ ) is a newsletter with separate articles. I would like to link to each of these articles externally from an email teaser we send out. Additionally I want the summarize box containing each article to expand automatically when its corresponding link is clicked.
I had previously used Karl Swedberg's "expander" plugin instead, and I had a solution that worked perfectly. However when I switched plugins, the solution no longer works, and I'm not sure where the difference is.
The script in my page looks like this:
- <script type="text/javascript">
- $(document).ready(function() {
- // simple example, using all default options
- /***** apply the summarize() method to the "containing" element ****/
- $('div.expandable').summarize();
-
- });
- </script>
- <script type="text/javascript">
- // Redirect to Appropriate Section
- var urlParams = {};
- (function () {
- var match,
- pl = /\+/g, // Regex for replacing addition symbol with a space
- search = /([^&=]+)=?([^&]*)/g,
- decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
- query = window.location.search.substring(1);
- while (match = search.exec(query))
- urlParams[decode(match[1])] = decode(match[2]);
- })();
- $(document).ready( function(){
- if ( urlParams['section'] != '' ) {
- $("#sect" + urlParams['section'] ).find(".read-more a").click();
- $('body,html').animate({ scrollTop: $("#sect" + urlParams['section'] ).offset().top }, 500 );
- }
- });
- </script>
The beginning of each article looks like this:
- <div class="clearfix">
- <div class="expandable" id="section01">
- <a name="01"></a><h1>TITLE</h1>
And the external links look like this:
- <a href="http://jjnursingnotes.com/DEC12?section=01" target="_blank">TITLE</a>
Please note that I am not a JS expert by any stretch; I got the original solution from StackOverflow, so I'm sure there's some piece of code here that I don't understand that's preventing this from working. Can anyone tell me what I'm doing wrong or if there is a more elegant solution?
Thanks!