svnno****@sourc*****
svnno****@sourc*****
2009年 12月 7日 (月) 22:58:52 JST
Revision: 1450 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1450 Author: dhrname Date: 2009-12-07 22:58:52 +0900 (Mon, 07 Dec 2009) Log Message: ----------- firefoxにもset要素を適用できるようにした Modified Paths: -------------- branches/05x/055/sie.js Modified: branches/05x/055/sie.js =================================================================== --- branches/05x/055/sie.js 2009-12-07 12:51:00 UTC (rev 1449) +++ branches/05x/055/sie.js 2009-12-07 13:58:52 UTC (rev 1450) @@ -351,6 +351,7 @@ } } catch(e) {stlog.add(e,293);this.onumber++;this.next();} }; +NAIBU.svgNameSpace = "http://www.w3.org/2000/svg"; //embed要素をobject要素に変える(Firefoxのみ) Objectembeds.prototype.ffnext = function(){ try{ @@ -364,6 +365,28 @@ tep.removeChild(tei); teli--; } + for (var i=0;i<this.obj.length;++i) { + var doc = (this.obj[i].getSVGDocument === void 0) ? this.obj[i].contentDocument : this.obj[i].getSVGDocument(); + var sets = doc.getElementsByTagNameNS(NAIBU.svgNameSpace, "set"), s; + for (var j=0;j<sets.length;++j) { + s = new _noie_STSetElement(sets[j]); + s.set(); + } + } + if (NAIBU.Clip.length > 0) { + NAIBU.stop = setInterval( (function(){ + var ntc = NAIBU.Time.currentFrame++; + var nc = NAIBU.Clip; + for (var i=0,ncli=nc.length;i<ncli;++i) { + nc[i]._frame(ntc); + } + if (ntc > 7000) { + clearInterval(NAIBU.stop); + } + }), + 41 + ); + } } catch(e) {stlog.add(e,294);} }; @@ -1966,7 +1989,6 @@ } } catch (e) {stlog.add(e,1847);} }; -NAIBU.svgNameSpace = "http://www.w3.org/2000/svg"; function _ie_font(data) { if (data.success) { //responsXMLはDTD処理を行う可能性があるため、ここでは使わない @@ -2048,7 +2070,7 @@ ti.style.visibility = "hidden"; data = isTategaki = horizOrVert = em = advX = dx = dy = fontSize = fe = null; }; -//IE以外、Firefox用 +//IE以外 function _noie_svgfont() { var obj = document.getElementsByTagName("object"); for (var i=0;i<obj.length;++i) { @@ -2186,6 +2208,7 @@ }; NAIBU.Clip = []; function STSetElement(/*Element*/ ele, /*Matrix*/ matrix, /*float*/w, h) { + if (ele) { var parent = ele.parentNode, s = {}; if (parent.nodeName === "shape") { switch (parent.getAttribute("tag")) { @@ -2232,6 +2255,7 @@ this.h = h; this._begin = this._end = this.simpleDuration = null; NAIBU.Clip[NAIBU.Clip.length] = this; + } return this; }; STSetElement.prototype.set = function (w,h){ @@ -2243,12 +2267,13 @@ if ( /(mouse|activ|click)/.test(this.begin) ) { //イベントがある場合 var tar; if ( /\.\D/.test(this.begin) ) { - tar = document.getElementById( this.begin.substring(0, this.begin.indexOf(".")) ); + tar = this.tar.ownerDocument.getElementById( this.begin.substring(0, this.begin.indexOf(".")) ); } else { - tar = this.tarrget.tar; + tar = this.target.tar; } var tea = this.beginElementAt; - tar.attachEvent( "on" + this.begin.match(/(mouse|activ|clic)[a-z]+/), (function(){tea(offset)}) ); + tar.attachEvent( "on" + this.begin.match(/(mouse|activ|clic)[a-z]+/), + (function(){tea(offset)}) ); } else { this.beginElementAt(offset); beginOffset = offset; @@ -2263,12 +2288,13 @@ if ( /(mouse|activ|click)/.test(this.end) ) { //イベントがある場合 var tar; if ( /\.\D/.test(this.end) ) { - tar = document.getElementById( this.end.substring(0, this.end.indexOf(".")) ); + tar = this.tar.ownerDocument.getElementById( this.end.substring(0,this.end.indexOf(".")) ); } else { - tar = this.tarrget.tar; + tar = this.target.tar; } var tea = this.endElementAt; - tar.attachEvent( "on" + this.end.match(/(mouse|activ|clic)[a-z]+/), (function(){tea(offset)}) ); + tar.attachEvent( "on" + this.end.match(/(mouse|activ|clic)[a-z]+/), + (function(){tea(offset)}) ); } else { this.endElementAt(offset); } @@ -2362,6 +2388,86 @@ this._end = Math.ceil(offset * 0.8 / 24 + NAIBU.Time.currentFrame); }; +function _noie_STSetElement(/*Element*/ ele) { + if (ele) { + this.target = ele.parentNode; + this.tar = ele; + this.currentFrame = 0; + this.attributeName = ele.getAttributeNS(null, "attributeName"); + this.begin = ele.getAttributeNS(null, "begin") || "0ms"; + this.end = ele.getAttributeNS(null, "end"); + this.dur = ele.getAttributeNS(null, "dur"); + this.fill = ele.getAttributeNS(null, "fill"); + this._begin = this._end = this.simpleDuration = null; + NAIBU.Clip[NAIBU.Clip.length] = this; + } + return this; +}; +//プロトタイプチェーンで省略化を行う +_noie_STSetElement.prototype = new STSetElement(); +_noie_STSetElement.prototype.set = function (){ + this.to = this.tar.getAttributeNS(null, "to"); + var offset, beginOffset = 0; + try { + var n = parseFloat(this.begin.match(/[\-\d\.]+(h|min|s|ms)/)); + offset = (!isNaN(n)) ? n * this._unit[RegExp.$1] : 0; + if ( /(mouse|activ|click)/.test(this.begin) ) { //イベントがある場合 + var tar; + if ( /\.\D/.test(this.begin) ) { + tar = this.tar.ownerDocument.getElementById( this.begin.substring(0, this.begin.indexOf(".")) ); + } else { + tar = this.target.tar; + } + var tea = this.beginElementAt; + tar.addEventListener( this.begin.match(/(mouse|activ|clic)[a-z]+/), + (function(){tea(offset)}), false ); + } else { + this.beginElementAt(offset); + beginOffset = offset; + } + if (this.dur) { + var n = parseFloat(this.dur.match(/[\-\d\.]+(h|min|s|ms)/)); + this.simpleDuration = (!isNaN(n)) ? n * this._unit[RegExp.$1] : 0; + } + if (this.end) { + var n = parseFloat(this.end.match(/[\-\d\.]+(h|min|s|ms)/)); + offset = (!isNaN(n)) ? n * this._unit[RegExp.$1] : 0; + if ( /(mouse|activ|click)/.test(this.end) ) { //イベントがある場合 + var tar; + if ( /\.\D/.test(this.end) ) { + tar = this.tar.ownerDocument.getElementById( this.end.substring(0, this.end.indexOf(".")) ); + } else { + tar = this.target.tar; + } + var tea = this.endElementAt; + tar.addEventListener( this.end.match(/(mouse|activ|clic)[a-z]+/), + (function(){tea(offset)}), false ); + } else { + this.endElementAt(offset); + } + } + } catch(e) {stlog.add(e, 2239);} +}; +_noie_STSetElement.prototype.beginElement = function (){ + try { + var target = this.target, base = target.getAttributeNS(null, this.attributeName) || target.style.getPropertyValue(this.attributeName); + target.setAttributeNS(null, this.attributeName, this.to); + target.style.setProperty(this.attributeName, this.to, ""); //第三引数に関しては、W3CやMDCを参照 + this.base = base; + if (this.simpleDuration) { + if (this._end) { + var offset = (this.simpleDuration > this._end - this._begin) ? this._end - this._begin : this.simpleDuration; + this.endElementAt(offset); + } else { + this.endElementAt(this.simpleDuration); + } + } + } catch(e) { + stlog.add(e, 24370); + } + return; +}; + function utf16( /*string*/ s) { return unescape(s); }