Changeset 510

Show
Ignore:
Timestamp:
01/15/06 13:35:19 (3 years ago)
Author:
therve@gmail.com
Message:

Make tagify and multiple work.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • mochikit/branches/scriptaculous/MochiKit/Effects.js

    r509 r510  
    1313 
    1414var Effect = { 
    15     tagifyText: function (element) { 
    16         // XXX: what's this function for ? Doesn't work 
    17         var tagifyStyle = 'position:relative'; 
     15    tagifyText: function (element, /* optional */tagifyStyle) { 
     16        /*** 
     17 
     18        Change a node text to character in tags. 
     19 
     20        @param tagifyStyle: the style to apply to character nodes, default to 
     21        'position: relative'. 
     22 
     23        ***/ 
     24        var tagifyStyle = tagifyStyle || 'position:relative'; 
    1825        if (MochiKit.Base.isIE()) { 
    1926            tagifyStyle += ';zoom:1'; 
     
    2229        MochiKit.Iter.forEach(element.childNodes, function (child) { 
    2330            if (child.nodeType == 3) { 
    24                 MochiKit.Iter.forEach(child.split(''), function (character) { 
     31                MochiKit.Iter.forEach(child.nodeValue.split(''), function (character) { 
    2532                    element.insertBefore( 
    26                         Builder.node('span', {style: tagifyStyle}, 
    27                             character == ' ' ? String.fromCharCode(160) : character), 
    28                             child); 
     33                        MochiKit.DOM.SPAN({style: tagifyStyle}, 
     34                            character == ' ' ? String.fromCharCode(160) : character), child); 
    2935                }); 
    3036                MochiKit.DOM.removeElement(child); 
     
    3339    }, 
    3440 
    35     multiple: function (element, effect, options) { 
    36         // XXX: what's this function for ? Doesn't work 
    37         var elements; 
    38         if (((typeof(element) == 'object') || 
    39              (typeof(element) == 'function')) && 
    40             (element.length)) { 
    41             elements = element; 
    42         } else { 
    43             elements = MochiKit.DOM.getElement(element).childNodes; 
    44         } 
     41    multiple: function (elements, effect, /* optional */options) { 
     42        /*** 
     43 
     44        Launch the same effect subsequently on given elements. 
     45 
     46        ***/ 
    4547        options = MochiKit.Base.update({ 
    4648            speed: 0.1, 
     
    4850        }, options || {}); 
    4951        var masterDelay = options.delay; 
    50  
    51         MochiKit.Iter.forEach(elements, function (element, index) { 
     52        var index = 0; 
     53        MochiKit.Iter.forEach(elements, function (element) { 
    5254            options.delay = index * options.speed + masterDelay; 
    5355            new effect(element, options); 
     56            index += 1; 
    5457        }); 
    5558    },