JSAPI.info

dojo.style

Dojo (1.6.1) - see full source
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
                        /*String?*/ value){
    //    summary:
    //        Accesses styles on a node. If 2 arguments are
    //        passed, acts as a getter. If 3 arguments are passed, acts
    //        as a setter.
    //    description:
    //        Getting the style value uses the computed style for the node, so the value
    //        will be a calculated value, not just the immediate node.style value.
    //        Also when getting values, use specific style names,
    //        like "borderBottomWidth" instead of "border" since compound values like
    //        "border" are not necessarily reflected as expected.
    //        If you want to get node dimensions, use `dojo.marginBox()`,
    //        `dojo.contentBox()` or `dojo.position()`.
    //    node:
    //        id or reference to node to get/set style for
    //    style:
    //        the style property to set in DOM-accessor format
    //        ("borderWidth", not "border-width") or an object with key/value
    //        pairs suitable for setting each property.
    //    value:
    //        If passed, sets value on the node for style, handling
    //        cross-browser concerns.  When setting a pixel value,
    //        be sure to include "px" in the value. For instance, top: "200px".
    //        Otherwise, in some cases, some browsers will not apply the style.
    //    example:
    //        Passing only an ID or node returns the computed style object of
    //        the node:
    //    |    dojo.style("thinger");
    //    example:
    //        Passing a node and a style property returns the current
    //        normalized, computed value for that property:
    //    |    dojo.style("thinger", "opacity"); // 1 by default
    //
    //    example:
    //        Passing a node, a style property, and a value changes the
    //        current display of the node and returns the new computed value
    //    |    dojo.style("thinger", "opacity", 0.5); // == 0.5
    //
    //    example:
    //        Passing a node, an object-style style property sets each of the values in turn and returns the computed style object of the node:
    //    |    dojo.style("thinger", {
    //    |        "opacity": 0.5,
    //    |        "border": "3px solid black",
    //    |        "height": "300px"
    //    |    });
    //
    //     example:
    //        When the CSS style property is hyphenated, the JavaScript property is camelCased.
    //        font-size becomes fontSize, and so on.
    //    |    dojo.style("thinger",{
    //    |        fontSize:"14pt",
    //    |        letterSpacing:"1.2em"
    //    |    });
    //
    //    example:
    //        dojo.NodeList implements .style() using the same syntax, omitting the "node" parameter, calling
    //        dojo.style() on every element of the list. See: `dojo.query()` and `dojo.NodeList()`
    //    |    dojo.query(".someClassName").style("visibility","hidden");
    //    |    // or
    //    |    dojo.query("#baz > div").style({
    //    |        opacity:0.75,
    //    |        fontSize:"13pt"
    //    |    });
 
    var n = byId(node), args = arguments.length, op = (style == "opacity");
    style = _floatAliases[style] || style;
    if(args == 3){
        return op ? d._setOpacity(n, value) : n.style[style] = value; /*Number*/
    }
    if(args == 2 && op){
        return d._getOpacity(n);
    }
    var s = gcs(n);
    if(args == 2 && typeof style != "string"){ // inline'd type check
        for(var x in style){
            d.style(node, x, style[x]);
        }
        return s;
    }
    return (args == 1) ? s : _toStyleValue(n, style, s[style] || n.style[style]); /* CSS2Properties||String||Number */
};