/[drupal]/contributions/modules/fasttoggle/fasttoggle.js
ViewVC logotype

Diff of /contributions/modules/fasttoggle/fasttoggle.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.5, Sun Oct 7 12:27:53 2007 UTC revision 1.5.2.1, Sat Nov 8 11:09:20 2008 UTC
# Line 1  Line 1 
1  // $Id: fasttoggle.js,v 1.4 2007/10/07 10:37:38 timcn Exp $  // $Id: fasttoggle.js,v 1.5 2007/10/07 12:27:53 timcn Exp $
2    
3  Drupal.fasttoggle = {  Drupal.fasttoggle = {
4      'className': function(data) {
5         $(this)
6           .attr('class', $(this).attr('class').replace(/\bfasttoggle-status-[^\s]+/, ''))
7           .addClass(data.className);
8      },
9    
10    'comment': function(data) {    'comment': function(data) {
11      if (data.option == 'status') {      if (data.option == 'status') {
12        $(this).parents('.comment')[data.status ? 'addClass' : 'removeClass']('comment-unpublished');        $(this).parents('.comment')[data.status ? 'addClass' : 'removeClass']('comment-unpublished');
# Line 20  Drupal.fasttoggle = { Line 26  Drupal.fasttoggle = {
26  };  };
27    
28  Drupal.behaviors.fasttoggle = function(context) {  Drupal.behaviors.fasttoggle = function(context) {
29      // Unbind is used to prevent dblclick module from interfering.
30    $('a.fasttoggle', context).unbind('click').click(function() {    $('a.fasttoggle', context).unbind('click').click(function() {
31      // Add the throbber      // Add the throbber
32      var link = $(this).addClass('throbbing');      var link = $(this).addClass('throbbing');
# Line 33  Drupal.behaviors.fasttoggle = function(c Line 40  Drupal.behaviors.fasttoggle = function(c
40        'dataType': 'json',        'dataType': 'json',
41        'success': function(data) {        'success': function(data) {
42          // Remove the throbber          // Remove the throbber
43          link.html(data.text).removeClass('throbbing');          link.text(data.text).removeClass('throbbing');
44    
45            // Change the class name of the link after toggling it.
46            if (data.className) {
47              Drupal.fasttoggle.className.call(link[0], data);
48            }
49    
50          // Call the callback function for altering the display of other elements          // Call the callback function for altering the display of other elements
51          if (data.callback && Drupal.fasttoggle[data.callback]) {          if (data.callback && Drupal.fasttoggle[data.callback]) {
52            Drupal.fasttoggle[data.callback].call(link[0], data);            Drupal.fasttoggle[data.callback].call(link[0], data);

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.5.2.1

  ViewVC Help
Powered by ViewVC 1.1.2