{"id":246,"date":"2007-08-01T23:35:29","date_gmt":"2007-08-02T04:35:29","guid":{"rendered":"http:\/\/unitstep.net\/blog\/2007\/08\/01\/share-this-in-jquery\/"},"modified":"2007-08-07T18:04:17","modified_gmt":"2007-08-07T23:04:17","slug":"share-this-in-jquery","status":"publish","type":"post","link":"https:\/\/unitstep.net\/blog\/2007\/08\/01\/share-this-in-jquery\/","title":{"rendered":"Share This in jQuery"},"content":{"rendered":"
<\/a><\/p>\n Share This<\/a> is an excellent WordPress plugin written by Alex King<\/a>. The plugin provides a neat and customizable pop-up menu for allowing readers to easily share one of your blog posts using many of the social bookmarking or social websites out there. It’s an intelligent solution to the problem of having too many sharing icons<\/a> that may potentially distract or irritate readers.<\/p>\n Since launching, Share This has become very popular<\/a>, with many blogs using it. I recently began using the plugin for a site of mine, and was impressed by its usefulness. (And the icon project it launched<\/a>) However, I had also decided to use the jQuery<\/a> JavaScript framework (and its plugins<\/a>) for this site, and since Share This uses Prototype<\/a> for its JavaScript functionality, there were some conflicts. <\/p>\n So, I decided to do a minor re-write of Share This, altering only the JavaScript portion to use jQuery instead of Prototype.<\/p>\n <\/p>\n I wanted to stick with jQuery for a variety of reasons, but mainly because I have more experience with it than with Prototype. I won’t get into an argument over which of the frameworks is better, and will instead stick to the “Unto each his own” line of thinking.<\/p>\n While jQuery generally works well with existing JavaScript, as it doesn’t alter the global namespace, and additionally has a “no-conflict” mode, some of the plugins that I wanted to use (specifically Thickbox<\/a>) weren’t written for the no-conflict mode. The issue stems from the use of the “ Before I offer the download, I want to make it clear that this was a very minor<\/strong> change – no functionality was added or removed, as just the JavaScript portion was re-written (quickly) to support jQuery instead of Prototype. Again, it’s not better than the original Share This<\/a>, only different. Furthermore, 100% full credit still belongs to Alex King<\/a>, as this is barely a derivative work.<\/p>\n In order to use this version, you will need the jQuery framework<\/a> as well as the Dimensions plugin<\/a>. Their cumulative compressed sizes are comparable to the compressed size of the Prototype framework. You will need to link them to your site in your WordPress theme’s You can then replace the original As mentioned before, all credit still belongs to Alex King for writing Share This in the first place. I haven’t really changed anything, just adapted it to work with jQuery and thought I’d like to make it available for everyone to use. It still works exactly as before, so configuring options and so forth isn’t any different.<\/p>\n What I changed was just the part of the plugin that outputs the JavaScript necessary to make Share This work. It’s just been changed to use jQuery instead of Prototype. I also commented out the parts of the plugin that link the Prototype framework (from WordPress) into the header. As mentioned before, you’ll have to link in the requisite jQuery script files yourself. Since it looks like WordPress will be moving over to jQuery<\/a>, at least for the admin pages, this might be something worthwhile.<\/p>\n The JavaScript has been written in jQuery’s compatibility mode (using Some people have pointed out that Prototype is a lot larger than jQuery in terms of file size. This may be somewhat true, but when Prototype v 1.5.0 is packed<\/a>, it comes in at only around 27 KB. jQuery packed is about 21 KB, but with the Dimensions plugin needed to make Share This work with jQuery adds another 4-5 KB, bringing the total size close to that of Prototype. So why use jQuery? Again, it’s just because I’m more familiar with it and like how jQuery expressions are formed, particularly with the ability to chain function calls<\/a>.<\/p>\n Bennett McElwee<\/a>, author of many nice WordPress plugins (including some that I use on my own site), has already released a version of Share This in jQuery<\/a>, seemingly two days before I published this post – what a coincidence! His appears to be more polished, though, as it doesn’t use the extra Dimensions plugin and also includes some nice effects. Definitely give it a try.<\/p>","protected":false},"excerpt":{"rendered":" Share This is an excellent WordPress plugin written by Alex King. The plugin provides a neat and customizable pop-up menu for allowing readers to easily share one of your blog posts using many of the social bookmarking or social websites out there. It’s an intelligent solution to the problem of having too many sharing icons […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,167,26,25],"tags":[],"_links":{"self":[{"href":"https:\/\/unitstep.net\/wp-json\/wp\/v2\/posts\/246"}],"collection":[{"href":"https:\/\/unitstep.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unitstep.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unitstep.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unitstep.net\/wp-json\/wp\/v2\/comments?post=246"}],"version-history":[{"count":0,"href":"https:\/\/unitstep.net\/wp-json\/wp\/v2\/posts\/246\/revisions"}],"wp:attachment":[{"href":"https:\/\/unitstep.net\/wp-json\/wp\/v2\/media?parent=246"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitstep.net\/wp-json\/wp\/v2\/categories?post=246"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitstep.net\/wp-json\/wp\/v2\/tags?post=246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}jQuery?<\/h3>\n
$<\/code>” variable name. In jQuery, it’s a shortcut for the be-all-end-all function
jQuery()<\/code>, while in Prototype, it’s a shortcut for
document.getElementById()<\/code>.<\/p>\n
Share This in jQuery<\/h3>\n
header.php<\/code> file by adding lines like these, preferably between the
head<\/code> tags.<\/p>\n
<script type=\"text\/javascript\" src=\"\/path-to-jquery\/jquery.pack.js\"><\/script>\r\n<script type=\"text\/javascript\" src=\"\/path-to-jquery-dimensions\/jquery.dimensions.pack.js\"><\/script><\/code><\/pre>\n
share-this.php<\/code> with the jQuery version in the zipped download<\/a>. (You may want to backup the original file first, as always)<\/p>\n
Download<\/h3>\n
\n
Credit and Misc.<\/h3>\n
jQuery()<\/code> instead of
$<\/code>), so you can continue to use Prototype on your site if you wish. As mentioned, this was a very quick rewrite, so not much has changed. <\/p>\n
Update<\/h3>\n