123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320 |
- define("dojo/dom-style", ["./_base/sniff", "./dom"], function(has, dom){
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var getComputedStyle, style = {};
- if(has("webkit")){
- getComputedStyle = function(/*DomNode*/node){
- var s;
- if(node.nodeType == 1){
- var dv = node.ownerDocument.defaultView;
- s = dv.getComputedStyle(node, null);
- if(!s && node.style){
- node.style.display = "";
- s = dv.getComputedStyle(node, null);
- }
- }
- return s || {};
- };
- }else if(has("ie") && (has("ie") < 9 || has("quirks"))){
- getComputedStyle = function(node){
-
- return node.nodeType == 1 ? node.currentStyle : {};
- };
- }else{
- getComputedStyle = function(node){
- return node.nodeType == 1 ?
- node.ownerDocument.defaultView.getComputedStyle(node, null) : {};
- };
- }
- style.getComputedStyle = getComputedStyle;
- var toPixel;
- if(!has("ie")){
- toPixel = function(element, value){
-
-
- return parseFloat(value) || 0;
- };
- }else{
- toPixel = function(element, avalue){
- if(!avalue){ return 0; }
-
- if(avalue == "medium"){ return 4; }
-
-
- if(avalue.slice && avalue.slice(-2) == 'px'){ return parseFloat(avalue); }
- var s = element.style, rs = element.runtimeStyle, cs = element.currentStyle,
- sLeft = s.left, rsLeft = rs.left;
- rs.left = cs.left;
- try{
-
-
-
-
- s.left = avalue;
- avalue = s.pixelLeft;
- }catch(e){
- avalue = 0;
- }
- s.left = sLeft;
- rs.left = rsLeft;
- return avalue;
- }
- }
- style.toPixelValue = toPixel;
-
- var astr = "DXImageTransform.Microsoft.Alpha";
- var af = function(n, f){
- try{
- return n.filters.item(astr);
- }catch(e){
- return f ? {} : null;
- }
- };
- var _getOpacity =
- has("ie") < 9 || (has("ie") < 10 && has("quirks")) ? function(node){
- try{
- return af(node).Opacity / 100;
- }catch(e){
- return 1;
- }
- } :
- function(node){
- return getComputedStyle(node).opacity;
- };
- var _setOpacity =
- has("ie") < 9 || (has("ie") < 10 && has("quirks")) ? function(/*DomNode*/node, /*Number*/opacity){
- var ov = opacity * 100, opaque = opacity == 1;
- node.style.zoom = opaque ? "" : 1;
- if(!af(node)){
- if(opaque){
- return opacity;
- }
- node.style.filter += " progid:" + astr + "(Opacity=" + ov + ")";
- }else{
- af(node, 1).Opacity = ov;
- }
-
-
- af(node, 1).Enabled = !opaque;
- if(node.tagName.toLowerCase() == "tr"){
- for(var td = node.firstChild; td; td = td.nextSibling){
- if(td.tagName.toLowerCase() == "td"){
- _setOpacity(td, opacity);
- }
- }
- }
- return opacity;
- } :
- function(node, opacity){
- return node.style.opacity = opacity;
- };
- var _pixelNamesCache = {
- left: true, top: true
- };
- var _pixelRegExp = /margin|padding|width|height|max|min|offset/;
- function _toStyleValue(node, type, value){
-
- type = type.toLowerCase();
- if(has("ie")){
- if(value == "auto"){
- if(type == "height"){ return node.offsetHeight; }
- if(type == "width"){ return node.offsetWidth; }
- }
- if(type == "fontweight"){
- switch(value){
- case 700: return "bold";
- case 400:
- default: return "normal";
- }
- }
- }
- if(!(type in _pixelNamesCache)){
- _pixelNamesCache[type] = _pixelRegExp.test(type);
- }
- return _pixelNamesCache[type] ? toPixel(node, value) : value;
- }
- var _floatAliases = {cssFloat: 1, styleFloat: 1, "float": 1};
-
- style.get = function getStyle(/*DOMNode|String*/ node, /*String?*/ name){
- var n = dom.byId(node), l = arguments.length, op = (name == "opacity");
- if(l == 2 && op){
- return _getOpacity(n);
- }
- name = _floatAliases[name] ? "cssFloat" in n.style ? "cssFloat" : "styleFloat" : name;
- var s = style.getComputedStyle(n);
- return (l == 1) ? s : _toStyleValue(n, name, s[name] || n.style[name]);
- };
- style.set = function setStyle(/*DOMNode|String*/ node, /*String|Object*/ name, /*String?*/ value){
- var n = dom.byId(node), l = arguments.length, op = (name == "opacity");
- name = _floatAliases[name] ? "cssFloat" in n.style ? "cssFloat" : "styleFloat" : name;
- if(l == 3){
- return op ? _setOpacity(n, value) : n.style[name] = value;
- }
- for(var x in name){
- style.set(node, x, name[x]);
- }
- return style.getComputedStyle(n);
- };
- return style;
- });
|