isImage :\r
function( v ){\r
if( v && v.constructor === window.Image ) return true;\r
- if( v && v.constructor === window.HTMLImageElement ) return true;\r
+ if( v && window.HTMLImageElement && v.constructor === window.HTMLImageElement ) return true; // ie6- は constructor が undef、HTMLImageElement が undef なので、HTMLElement の存在確認が必要\r
if( X.UA.WebKit < 525.13 ){ // Safari3-\r
if( v && v.src !== undefined && v.onload !== undefined && X.Type.isNumber( v.height ) && X.Type.isNumber( v.width ) && X.Type.isBoolean( v.complete ) ){\r
return true;\r
window.addEventListener( 'scroll', function(){\r
var last;\r
if( X_Timer_timerId ){\r
- X_Timer_CLEAR_TIMEOUT( X_Timer_timerId );\r
+ window.clearTimeout( X_Timer_timerId );\r
last = X_Timer_endTime - X.getTime();\r
X_Timer_timerId = X_Timer_SET_TIMEOUT( X_Timer_onTimeout, 0 < last ? last : 0 );\r
};\r
h.appendTo = h.appendToRoot = h.before = h.after = h.clone = h.remove = h.destroy = h.prevNode = h.nextNode = h.createText = h.append = h.appendAt = h.empty = h.html = h.text =\r
r.appendTo = r.appendToRoot = r.before = r.after = r.clone = r.remove = r.destroy = r.prevNode = r.nextNode = new Function( 'return this' );\r
\r
- r._root = h._root = r;\r
- r.parent = h;\r
+ r._root = h._root = r;\r
+ r.parent = h;\r
h._xnodes = [ r ];\r
\r
X.Dom.listenOnce( X.Dom.Event.DOM_PRE_INIT, function(){\r
META : true,\r
PARAM : true,\r
EMBED : true\r
- },//,\r
+ },\r
\r
TAG_FIX :\r
X.UA.IE && 4 <= X.UA.IE && X.UA.IE < 5 ?\r
if( !v ) return 0;\r
if( v === window ) return Node.IS_WINDOW;\r
if( v === document ) return Node.IS_DOCUMENT;\r
- if( X.Type.isImage( v ) ) return Node.IS_IMAGE;\r
if( v.constructor === Node ) return Node.IS_XNODE;\r
if( v.constructor === X.Dom.NodeList ) return Node.IS_XNODE_LIST;\r
if( X.Type.isHTMLElement( v ) ) return Node.IS_RAW_HTML;\r
if( v.nodeType === 3 ) return Node.IS_RAW_TEXT;\r
+ if( X.Type.isImage( v ) ) return Node.IS_IMAGE;\r
if( typeof v === 'string' ){\r
return '<' === v.charAt( 0 ) && v.charAt( v.length - 1 ) === '>' ? Node.IS_HTML_STRING : Node.IS_STRING;\r
};\r
\r
xnodeIframe : null,\r
\r
- _iwin : null,\r
+ _iwin : null,\r
\r
- _html : null,\r
- _name : null,\r
+ _html : '',\r
+ _name : '',\r
_ready : false,\r
\r
Constructor : function( html ){\r
return this;\r
};\r
\r
- this._iwin.location.reload();\r
+ if( X.UA.IE5 || X.UA.IE55 ){\r
+ this._iwin.location.href = 'about:blank'; // reload() では、IE5.5(IETester)で2回目移行の操作でerrorが出る(doc取得やopen,writeで)\r
+ } else {\r
+ this._iwin.location.reload();\r
+ };\r
\r
if( !opt_html ) return this;\r
\r
);\r
\r
function X_Util_NinjaIframe_writeToIframe( that ){\r
-var raw = that.xnodeIframe._rawObject,\r
- idoc = raw.contentDocument || that._iwin.document,\r
- html = that._html;\r
- \r
+ var raw = that.xnodeIframe._rawObject,\r
+ idoc = raw.contentDocument || that._iwin.document,\r
+ html = that._html;\r
+ \r
delete that._html;\r
that._ready = true;\r
- \r
- console.log( 'iframe import. ' + html );\r
- \r
+\r
idoc.open();\r
- idoc.writeln( html ); // ここで script を書き出すので2度呼ばれる?\r
+ idoc.writeln( html );\r
idoc.close();\r
};\r
\r
\r
// TODO chashe\r
// TODO iframe useful or not.\r
+ // TODO file: では http: は使えない\r
jsonp : function( url, useIframe ){\r
return new X_NET_Queue( X_NET_TYPE_JSONP, url );\r
},\r
\r
image : function( url, useIframe ){\r
- \r
+ return new X_NET_Queue( X_NET_TYPE_IMAGE, url );\r
},\r
\r
amountQueue : function(){\r
var X_NET_TYPE_XHR = 1,\r
X_NET_TYPE_JSONP = 2,\r
X_NET_TYPE_FORM = 3,\r
+ X_NET_TYPE_IMAGE = 4,\r
\r
X_NET_QUEUE_LIST = [],\r
\r
X_NET_XHRWrapper,\r
X_NET_JSONPWrapper,\r
- X_NET_FORMWrapper,\r
+ X_NET_FormWrapper,\r
+ X_NET_ImageWrapper,\r
\r
X_NET_currentWrapper,\r
X_NET_currentQueue,\r
X_NET_currentWrapper = X_NET_JSONPWrapper;\r
break;\r
case X_NET_TYPE_FORM :\r
- X_NET_currentWrapper = X_NET_FORMWrapper;\r
+ X_NET_currentWrapper = X_NET_FormWrapper;\r
+ break;\r
+ case X_NET_TYPE_IMAGE :\r
+ X_NET_currentWrapper = X_NET_ImageWrapper;\r
break;\r
};\r
\r
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest\r
// https://web.archive.org/web/20071101021832/http://web.paulownia.jp/script/ajax/xmlhttp4.html\r
+// https://web.archive.org/web/20091029170015/http://wiki.paulownia.jp/ajax/xmlhttprequest\r
+/* \r
+ * http://ponpon-village.net/ajax/xmlhttp.htm\r
+ * IE のバージョンによっては、ActiveXObject("Msxml2.XMLHTTP.5.0") , ActiveXObject("Msxml2.XMLHTTP.4.0") ,\r
+ActiveXObject("Msxml2.XMLHTTP.3.0") , ActiveXObject("Msxml2.XMLHTTP") なども使用出来る。\r
\r
+http://vird2002.s8.xrea.com/javascript/XMLHttpRequest.html\r
+// --- 使うべきオブジェクト\r
+new ActiveXObject( 'Msxml2.XMLHTTP.3.0' ); // バージョン3.0 広範に利用されているので、今後も bugfix を行う\r
+new ActiveXObject( 'Msxml2.XMLHTTP.6.0' ); // バージョン6.0 は最新版なので bugfix を続ける\r
+\r
+// --- 使うべきではないオブジェクト\r
+new ActiveXObject( 'Microsoft.XMLHTTP' ); // Microsoft接頭辞は古いので指定すべきではない\r
+new ActiveXObject( 'Msxml.XMLHTTP' ); // Msxml2接頭辞を指定すべき\r
+new ActiveXObject( 'Msxml2.XMLHTTP' ); // バージョンを省略すると 3.0 として扱われるので、バージョンは明記すべき\r
+new ActiveXObject( 'Msxml2.XMLHTTP.4.0' ); // バージョン4.0 は bugfix が行われないので、3.0 か 6.0 を指定すべき\r
+new ActiveXObject( 'Msxml2.XMLHTTP.5.0' ); // バージョン5.0 は bugfix が行われないので、3.0 か 6.0 を指定すべき\r
+\r
+ */\r
var X_Net_XHR_W3C = window[ 'XMLHttpRequest' ] && new XMLHttpRequest(),\r
X_Net_XHR_X_DOMAIN = window[ 'XDomainRequest' ] && new XDomainRequest(),\r
X_Net_XHR_VERSION = 0,\r
X_Net_XHR_ACTIVE_X = 5 <= X.UA.IE && X.UA.IE < 8 && X.UA.ActiveX && ( new Function( [\r
'var x=".XMLHTTP",',\r
'm="MSXML2"+x,',\r
- 'v=[m+".6.0",m+".3.0",m,"Microsoft"+x,m+".4.0"],',\r
+ 'v=[m+".6.0",m+".3.0",m+".5.0",m+".4.0",m,"Microsoft"+x],',\r
'i=-1;',\r
- 'for(;i<3;){',\r
+ 'for(;i<5;){',\r
'try{',\r
- 'return new ActiveXObject(v[++i]);',\r
+ 'return[++i,new ActiveXObject(v[i])];',\r
'}catch(e){}',\r
'}'\r
].join( '' ) ) )();\r
\r
-\r
+if( X_Net_XHR_ACTIVE_X ){\r
+ X_Net_XHR_VERSION = [ 6, 3, 5, 4, 2, 1 ][ X_Net_XHR_ACTIVE_X[ 0 ] ];\r
+ X_Net_XHR_ACTIVE_X = X_Net_XHR_ACTIVE_X[ 1 ];\r
+};\r
\r
X.Net.XHR = {\r
// Opera7.6+, Safari1.2+, khtml3.?+, Gecko0.9.7+\r
if( X_Net_XHR_X_DOMAIN ){\r
if( false /* isXDomain( url ) */ ){ // isXDomain\r
//if( raw !== X_Net_XHR_X_DOMAIN ){\r
- X_NET_XHRWrapper._migrateEvent();\r
+ X_EventDispatcher_migrateEvent( this );\r
X_NET_XHRWrapper._rawObject = X_Net_XHR_X_DOMAIN;\r
- X_NET_XHRWrapper._restoreEvent();\r
+ X_EventDispatcher_restoreEvent( this );\r
//};\r
} else {\r
//if( raw === X_Net_XHR_X_DOMAIN ){\r
- X_NET_XHRWrapper._migrateEvent();\r
+ X_EventDispatcher_migrateEvent( this );\r
X_NET_XHRWrapper._rawObject = X_Net_XHR_W3C || X_Net_XHR_ACTIVE_X;\r
- X_NET_XHRWrapper._restoreEvent();\r
+ X_EventDispatcher_restoreEvent( this);\r
//};\r
};\r
};\r
break;\r
case 'json' :\r
case 'moz-json' :\r
+ data = raw[ 'response' ] || raw[ 'responseText' ]; // とりあえず\r
break;\r
case 'document' :\r
case 'xml' :\r
break;\r
case 'blob' :\r
case 'arraybuffer' :\r
+ data = raw[ 'response' ] || raw[ 'responseText' ]; // とりあえず\r
break;\r
};\r
\r
* http://kozo002.blogspot.jp/2012/07/ie9iframewindowparent.html
*/
+/*
+ * IE6(IETester) で動かない,localhost
+ */
+
X.Net.JSONP = {
cb : function( accessKey, jsonString, time, opt_json2FileSize ){
if( accessKey !== X_NET_JSONP_ACCESS_KEY ) return;
'<script src="', url, '"></script>' */
'<script id="jp"></script>',
'<script>',
+ 'nw=0;',
'function cb(o){nw-=+new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',parent.JSON.stringify(o),-nw)}',
'function tm(){jp.src="', url ,'";nw=+new Date}',
'setTimeout(tm,16);',
--- /dev/null
+/* \r
+ * original\r
+ * LICENSE: MIT?\r
+ * URL: http://d.hatena.ne.jp/uupaa/20080413/1208067631\r
+ * AUTHOR: uupaa.js@gmail.com\r
+ * \r
+ */\r
+\r
+var X_Net_Image_hasImage = !!window[ 'Image' ];\r
+\r
+if( !X_Net_Image_hasImage ){\r
+ alert( 'no Image!' );\r
+};\r
+\r
+/*\r
+ * TODO\r
+ * new Image() のときに Image オブジェクトを作るもの(IE8-)と、HTMLImageElement を作るものがある。\r
+ * Image は、X.EventDispatcher で、<img> は X.Dom.Node で。\r
+ */\r
+X_NET_ImageWrapper = ( X_Net_Image_hasImage ? X.EventDispatcher : X.Dom.Node ).inherits(\r
+ 'X.Net.Image',\r
+ X.Class.POOL_OBJECT,\r
+ {\r
+ _rawObject : X_Net_Image_hasImage && new Image,\r
+ \r
+ tick : 0,\r
+ timerID : 0,\r
+ finish : false,\r
+ abspath : null,\r
+ delay : null,\r
+ timeout : 0,\r
+ \r
+ Constructor : X_Net_Image_hasImage ?\r
+ (function(){\r
+ this.listen( [ 'load', 'error', 'abort', X.Event.SUCCESS, X.Event.ERROR, X.Event.KILL_INSTANCE ] );\r
+ }) :\r
+ (function(){\r
+ this.SuperConstructor( document.createElement( 'img' ) )\r
+ .appendTo( X.Dom.Node._systemNode )\r
+ .listen( [ 'load', 'error', 'abort', X.Event.SUCCESS, X.Event.ERROR, X.Event.KILL_INSTANCE ] );\r
+ }),\r
+ \r
+ load : function( abspath, opt_delay, opt_timeout ){\r
+ this.abspath = abspath;\r
+ this.delay = opt_delay || 100;\r
+ this.timeout = opt_timeout || 10000;\r
+ this.timerID = X.Timer.add( this.delay, 0, this, this._detect );\r
+ \r
+ X_Net_Image_hasImage ? ( this._rawObject.src = abspath ) : this.attr( 'src', abspath );\r
+ },\r
+ \r
+ handleEvent : function( e ){\r
+ var size;\r
+ switch( e.type ){\r
+ case 'error' :\r
+ case 'abort' : // TODO ??\r
+ if( this.finish ) return;\r
+ this.finish = true;\r
+ this.timerID && X.Timer.remove( this.timerID );\r
+ this.timerID = this.asyncDispatch( 0, { type : X.Event.ERROR } );\r
+ break;\r
+ case 'load' :\r
+ // if( finish === true ) return; // これがあると firefox3.6 で駄目、、、\r
+ // if( timer ) return; // これがあると safari3.2 で駄目、、、\r
+ this.finish = true;\r
+ this.timerID && X.Timer.remove( this.timerID );\r
+ if( X.UA.Opera && !this._rawObject.complete ){\r
+ this.timerID = this.asyncDispatch( 0, { type : X.Event.ERROR } );\r
+ return;\r
+ };\r
+ size = X.Dom.Image.getActualDimension( X.UA.IE < 9 && X_Net_Image_hasImage ? this.abspath : this );\r
+ this.timerID = this.asyncDispatch( 0, {\r
+ type : X.Event.SUCCESS,\r
+ src : this.abspath,\r
+ w : size[ 0 ],\r
+ h : size[ 1 ]\r
+ } );\r
+ break;\r
+ case X.Event.SUCCESS :\r
+ case X.Event.ERROR :\r
+ this.timerID && X.Timer.remove( this.timerID );\r
+ this.timerID = this.asyncDispatch( 0, X.Event.COMPLETE );\r
+ break;\r
+ case X.Event.KILL_INSTANCE :\r
+ this.timerID && X.Timer.remove( this.timerID );\r
+ !X_Net_Image_hasImage && this.destroy(); // if xnode\r
+ this.unlisten();\r
+ break;\r
+ };\r
+ }, \r
+ _detect : function(){\r
+ if( this.finish ) return;\r
+ if( this._rawObject && this._rawObject.complete ){\r
+ this.finish = true;\r
+ if( this._rawObject.width ) return;\r
+ X.Timer.remove( this.timerID );\r
+ this.timerID = this.asyncDispatch( 0, X.Event.ERROR );\r
+ } else\r
+ if( this.timeout < ( this.tick += this.delay ) ){\r
+ this.finish = true;\r
+ X.Timer.remove( this.timerID );\r
+ this.timerID = this.asyncDispatch( 0, X.Event.TIMEOUT );\r
+ };\r
+ },\r
+ cancel : function(){\r
+ this._rawObject && this._rawObject.abort();\r
+ },\r
+ \r
+ reset : function(){\r
+ this.timerID && X.Timer.remove( this.timerID );\r
+ this.timerID = 0;\r
+ this.finished = false;\r
+ this.abspath = null; \r
+ }\r
+ }\r
+);\r