チェンジセット 2269

差分発生行の前後
無視リスト:
コミット日時:
2009/02/16 02:05:32 (3 年前)
コミッタ:
nobu
ログメッセージ:

SWFWheel:

  • !AC_RunContent 使用時の挙動を修正。
    • AC_RunContent を使うと、 embed タグの場合には id 属性がつかない。
  • SWFWheel.force の IE での不具合を修正。
    • IE の場合、 getElementsByTagName が document 全体を検索してしまう。
ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • as3/SWFWheel/trunk/src/org/libspark/ui/SWFWheel.as

    r2222 r2269  
    2323        public static const EXECUTE_LIBRARY_FUNCTION:String = "SWFWheel.join"; 
    2424        public static const CHECK_FORCE_EXTERNAL_FUNCTION:String = "SWFWheel.force"; 
    25         public static const DEFINE_LIBRARY_FUNCTION:String = "function(){if(window.SWFWheel)return;var win=window,doc=document,nav=navigator;var SWFWheel=window.SWFWheel=function(id){this.setUp(id);if(SWFWheel.browser.msie)this.bind4msie();else this.bind();};SWFWheel.prototype={setUp:function(id){var el=doc.getElementById(id);if(el.nodeName.toLowerCase()=='embed'||SWFWheel.browser.safari)el=el.parentNode;this.target=el;this.eventType=SWFWheel.browser.mozilla?'DOMMouseScroll':'mousewheel';},bind:function(){this.target.addEventListener(this.eventType,function(evt){var target,name,delta=0;if(/XPCNativeWrapper/.test(evt.toString())){if(!evt.target.id)return;target=doc.getElementById(evt.target.id);}else{target=evt.target;}name=target.nodeName.toLowerCase();if(name!='object'&&name!='embed')return;evt.preventDefault();evt.returnValue=false;if(!target.externalMouseEvent)return;switch(true){case SWFWheel.browser.mozilla:delta=-evt.detail;break;default:delta=evt.wheelDelta/80;break;}target.externalMouseEvent(delta);},false);},bind4msie:function(){var _wheel,_unload,target=this.target;_wheel=function(){var evt=win.event,delta=0,name=evt.srcElement.nodeName.toLowerCase();if(name!='object'&&name!='embed')return;evt.returnValue=false;if(!target.externalMouseEvent)return;delta=evt.wheelDelta/80;target.externalMouseEvent(delta);};_unload=function(){target.detachEvent('onmousewheel',_wheel);win.detachEvent('onunload',_unload);};target.attachEvent('onmousewheel',_wheel);win.attachEvent('onunload',_unload);}};SWFWheel.browser=(function(ua){return{chrome:/chrome/.test(ua),stainless:/stainless/.test(ua),safari:/webkit/.test(ua)&&!/(chrome|stainless)/.test(ua),opera:/opera/.test(ua),msie:/msie/.test(ua)&&!/opera/.test(ua),mozilla:/mozilla/.test(ua)&&!/(compatible|webkit)/.test(ua)}})(nav.userAgent.toLowerCase());SWFWheel.join=function(id){var t=setInterval(function(){if(doc.getElementById(id)){clearInterval(t);new SWFWheel(id);}},0);};SWFWheel.force=function(id){if(SWFWheel.browser.safari||SWFWheel.browser.stainless)return true;var el=doc.getElementById(id),name=el.nodeName.toLowerCase();if(name=='object'){var k,v,param,params=el.getElementsByTagName('param');for(var i=0;i<params.length;i++){param=params[i];k=param.getAttribute('name');v=param.getAttribute('value')||'';if(/wmode/i.test(k)&&/(opaque|transparent)/i.test(v))return true;}}else if(name=='embed'){return/(opaque|transparent)/i.test(el.getAttribute('wmode'));}return false;};}"; 
     25        public static const DEFINE_LIBRARY_FUNCTION:String = "function(){if(window.SWFWheel)return;var win=window,doc=document,nav=navigator;var SWFWheel=window.SWFWheel=function(id){this.setUp(id);if(SWFWheel.browser.msie)this.bind4msie();else this.bind();};SWFWheel.prototype={setUp:function(id){var el=SWFWheel.retrieveObject(id);if(el.nodeName.toLowerCase()=='embed'||SWFWheel.browser.safari)el=el.parentNode;this.target=el;this.eventType=SWFWheel.browser.mozilla?'DOMMouseScroll':'mousewheel';},bind:function(){this.target.addEventListener(this.eventType,function(evt){var target,name,delta=0;if(/XPCNativeWrapper/.test(evt.toString())){var k=evt.target.id||evt.target.name;if(!k)return;target=SWFWheel.retrieveObject(k);}else{target=evt.target;}name=target.nodeName.toLowerCase();if(name!='object'&&name!='embed')return;evt.preventDefault();evt.returnValue=false;if(!target.externalMouseEvent)return;switch(true){case SWFWheel.browser.mozilla:delta=-evt.detail;break;default:delta=evt.wheelDelta/80;break;}target.externalMouseEvent(delta);},false);},bind4msie:function(){var _wheel,_unload,target=this.target;_wheel=function(){var evt=win.event,delta=0,name=evt.srcElement.nodeName.toLowerCase();if(name!='object'&&name!='embed')return;evt.returnValue=false;if(!target.externalMouseEvent)return;delta=evt.wheelDelta/40;target.externalMouseEvent(delta);};_unload=function(){target.detachEvent('onmousewheel',_wheel);win.detachEvent('onunload',_unload);};target.attachEvent('onmousewheel',_wheel);win.attachEvent('onunload',_unload);}};SWFWheel.browser=(function(ua){return{chrome:/chrome/.test(ua),stainless:/stainless/.test(ua),safari:/webkit/.test(ua)&&!/(chrome|stainless)/.test(ua),opera:/opera/.test(ua),msie:/msie/.test(ua)&&!/opera/.test(ua),mozilla:/mozilla/.test(ua)&&!/(compatible|webkit)/.test(ua)}})(nav.userAgent.toLowerCase());SWFWheel.join=function(id){var t=setInterval(function(){if(SWFWheel.retrieveObject(id)){clearInterval(t);new SWFWheel(id);}},0);};SWFWheel.force=function(id){if(SWFWheel.browser.safari||SWFWheel.browser.stainless)return true;var el=SWFWheel.retrieveObject(id),name=el.nodeName.toLowerCase();if(name=='object'){var k,v,param,params=el.getElementsByTagName('param');for(var i=0;i<params.length;i++){param=params[i];if(param.parentNode!=el)continue;k=param.getAttribute('name');v=param.getAttribute('value')||'';if(/wmode/i.test(k)&&/(opaque|transparent)/i.test(v))return true;}}else if(name=='embed'){return/(opaque|transparent)/i.test(el.getAttribute('wmode'));}return false;};SWFWheel.retrieveObject=function(id){var el=doc.getElementById(id);if(!el){var nodes=doc.getElementsByTagName('embed'),len=nodes.length;for(i=0;i<len;i++){el=nodes[i];if(el.name==id)break;}}return el;};}"; 
    2626 
    2727        private static var _stage:Stage; 
     
    5555            // ignore no mac, no safari. 
    5656            if(!mac && !force) return; 
     57            trace(mac, force); 
    5758 
    5859            //  start deep hack. 
  • as3/SWFWheel/trunk/zoo/swfwheel.js

    r2086 r2269  
    2828        setUp: function (id) 
    2929        { 
    30             var el = doc.getElementById(id); 
     30            var el = SWFWheel.retrieveObject(id); 
    3131            if (el.nodeName.toLowerCase() == 'embed' || SWFWheel.browser.safari) 
    3232                el = el.parentNode; 
     
    4545                if (/XPCNativeWrapper/.test(evt.toString())) 
    4646                { 
    47                     if (!evt.target.id) return; 
    48                     target = doc.getElementById(evt.target.id); 
     47                    // FIXME: embed element has no id attributes on `AC_RunContent`. 
     48                    var k = evt.target.id || evt.target.name; 
     49                    if (!k) return; 
     50                    target = SWFWheel.retrieveObject(k); 
    4951                } 
    5052                else 
     
    9294                //  will trigger when wmode is `opaque` or `transparent`. 
    9395                if (!target.externalMouseEvent) return; 
    94                 delta = evt.wheelDelta / 80; 
     96                delta = evt.wheelDelta / 40; 
    9597                target.externalMouseEvent(delta); 
    9698            }; 
     
    122124        var t = setInterval(function () 
    123125        { 
    124             if (doc.getElementById(id)) 
     126            if (SWFWheel.retrieveObject(id)) 
    125127            { 
    126128                clearInterval(t); 
     
    134136        if (SWFWheel.browser.safari||SWFWheel.browser.stainless) return true; 
    135137 
    136         var el = doc.getElementById(id), 
     138        var el = SWFWheel.retrieveObject(id), 
    137139            name = el.nodeName.toLowerCase(); 
    138140 
     
    146148            { 
    147149                param = params[i]; 
     150                //  FIXME: getElementsByTagName is broken on IE? 
     151                if (param.parentNode!=el) continue; 
     152 
    148153                k = param.getAttribute('name'); 
    149154                v = param.getAttribute('value') || ''; 
     
    158163    }; 
    159164 
     165    SWFWheel.retrieveObject = function (id) 
     166    { 
     167        var el = doc.getElementById(id); 
     168        //  FIXME: fallback for `AC_FL_RunContent`. 
     169        if (!el) 
     170        { 
     171            var nodes = doc.getElementsByTagName('embed'), 
     172                len = nodes.length; 
     173 
     174            for (i=0; i<len; i++) 
     175            { 
     176                el = nodes[i]; 
     177                if (el.name == id) break; 
     178            } 
     179        } 
     180        return el; 
     181    }; 
     182 
    160183})();