DrupalBin
Submit Code
About
Recent Posts
TwitterFeed for D4D review
text
rewrite
Module to overrule the save settings of the "new node" form
Code
apidoc
Empty DateTime Object
Fix for listcars_manufacturer.module
listcars_manufacturer.info
listcars_manufacturer.module
more
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Log in using OpenID
Cancel OpenID login
Create new account
Request new password
Tags
CCK
drupal
fapi
jquery
menu
module
php
simpletest
test
theme
user
views
more tags
Home
›
jQuery.Disqus.js
Fix for jQuery.Disqus.js
View
Fix
Fixes are not saved to the database until you submit.
Summary:
Tags:
Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Show summary in full view
// $Id$ /** * Disqus jQuery plugin * Applies Disqus comments to a page using a simple jQuery call. * $.Disqus({domain: "myusername"}); * * Copyright (c) 2008 Rob Loach (http://www.robloach.net) * Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses. */ /** * Disqus Global Variables */ var disqus_developer = 1; var disqus_container_id = 'disqus_container_id'; var disqus_message = ''; var disqus_title = ''; var disqus_url = ''; /** * Apply Disqus comments to the page. * * Usage: * $(document).ready(function(){ * $.Disqus({ * domain: "", // REQUIRED -- Your Disqus username/domain * fragment: "disqus_thread", // Optional -- The fragment to associate with number of comment links * title: "", // Optional -- The title of the current thread * url: top.location.href, // Optional -- The url of the current thread * message: "", // Optional -- A description of the current thread * developer: 0, // Optional -- Determines whether or not we're working in a development environment * container_id: "disqus_thread" // The container ID for the thread * }); * ); * <div id="disqus_thread"></div> * <a href="http://example.com/my/page#disqus_thread">Add a comment</a> * * This will create the Disqus comment thread, stick it into #disqus_thread, and * replace "Add a comment" with the number of comments in that thread. */ jQuery.Disqus = function(options) { // Load the settings with defaults var settings = jQuery.extend({ fragment: "disqus_thread", domain: "", title: "", url: top.location.href, message: "", developer: 0, container_id: "disqus_thread" }, options); if (settings.domain != "") { // Set the global Disqus variables disqus_developer = settings.developer; disqus_container_id = settings.container_id; disqus_message = settings.message; disqus_title = settings.title; disqus_url = settings.url; // Construct the query that will be sent to change the number of comments in links var query = '?'; $("a").each(function(i, obj){ if (obj.href.split("#")[1] == settings.fragment) { query += 'url' + i + '=' + encodeURIComponent(obj.href) + '&'; } }); // Call the Disqus script to get the number of replies per link $.getScript('http://disqus.com/forums/' + settings.domain + '/get_num_replies.js' + query); // Call the Disqus script to create the Disqus comment thread alert('Attempting to create the comment thread!'); //$('#' + disqus_container_id).load('http://disqus.com/forums/' + settings.domain + '/embed.js'); //$('#' + disqus_container_id).text('').append('<script type="text/javascript" src="http://disqus.com/forums/' + settings.domain + '/get_num_replies.js"/>'); //$.getScript('http://disqus.com/forums/' + settings.domain + '/embed.js'); $('#' + disqus_container_id).appendDom([{ tagName :'script', type : 'text/javascript', src : 'http://disqus.com/forums/' + settings.domain + '/embed.js' }]); alert('Done creating thread, ready for the white screen?!'); } } /** * appendDom - Extremely flexible tool for dynamic dom creation. * http://byron-adams.com/projects/jquery/appendDom * * Copyright (c) 2007 Byron Adams (http://byron-adams.com) * Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses. * */ jQuery.fn.appendDom = function(template) { return this.each(function() { for (element in template) { var el = (typeof(template[element].tagName) === 'string') ? document.createElement(template[element].tagName): document.createTextNode(''); delete template[element].tagName; for (attrib in template[element]) { switch ( typeof(template[element][attrib]) ) { case 'string' : if ( typeof(el[attrib]) === 'string' ) { el[attrib] = template[element][attrib]; } else { el.setAttribute(attrib, template[element][attrib]); } break; case 'function': el[attrib] = template[element][attrib]; break; case 'object' : if (attrib === 'childNodes') {$(el).appendDom(template[element][attrib]);} break; } } this.appendChild(el); } }); };
Syntax highlighting mode:
ActionScript
ColdFusion
Diff
Drupal 5
Drupal 6
HTML
INI
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.
See Also:
Order
Title:
URL:
-1
0
1
Title:
URL:
-1
0
1
Any links you'd like to have associated with the post (Drupal.org issue, Wikipedia article, etc).
File attachments
Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.
Attach new file:
The maximum upload size is
1 MB
. Only files with the following extensions may be uploaded:
jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp
.