• R/O
  • HTTP
  • SSH
  • HTTPS

clientJs: コミット

クライアント側 js 開発用


コミットメタ情報

リビジョン066d5d49b3e4d37eac0b417efdb06aa1fc16ccdf (tree)
日時2014-09-22 13:04:37
作者itozyun <itozyun@user...>
コミッターitozyun

ログメッセージ

Version 0.6.83, fix X.Type.isImage & X.Util.NinjaIframe.

変更サマリ

差分

--- a/0.6.x/js/00_core/02_XType.js
+++ b/0.6.x/js/00_core/02_XType.js
@@ -63,7 +63,7 @@ X.Type = {
6363 isImage :
6464 function( v ){
6565 if( v && v.constructor === window.Image ) return true;
66- if( v && v.constructor === window.HTMLImageElement ) return true;
66+ if( v && window.HTMLImageElement && v.constructor === window.HTMLImageElement ) return true; // ie6- は constructor が undef、HTMLImageElement が undef なので、HTMLElement の存在確認が必要
6767 if( X.UA.WebKit < 525.13 ){ // Safari3-
6868 if( v && v.src !== undefined && v.onload !== undefined && X.Type.isNumber( v.height ) && X.Type.isNumber( v.width ) && X.Type.isBoolean( v.complete ) ){
6969 return true;
--- a/0.6.x/js/00_core/05_XTimer.js
+++ b/0.6.x/js/00_core/05_XTimer.js
@@ -279,7 +279,7 @@ if( X.UA.iOS ){
279279 window.addEventListener( 'scroll', function(){
280280 var last;
281281 if( X_Timer_timerId ){
282- X_Timer_CLEAR_TIMEOUT( X_Timer_timerId );
282+ window.clearTimeout( X_Timer_timerId );
283283 last = X_Timer_endTime - X.getTime();
284284 X_Timer_timerId = X_Timer_SET_TIMEOUT( X_Timer_onTimeout, 0 < last ? last : 0 );
285285 };
--- a/0.6.x/js/01_dom/10_XDom.js
+++ b/0.6.x/js/01_dom/10_XDom.js
@@ -114,8 +114,8 @@ X.Dom = X.Class._override(
114114 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 =
115115 r.appendTo = r.appendToRoot = r.before = r.after = r.clone = r.remove = r.destroy = r.prevNode = r.nextNode = new Function( 'return this' );
116116
117- r._root = h._root = r;
118- r.parent = h;
117+ r._root = h._root = r;
118+ r.parent = h;
119119 h._xnodes = [ r ];
120120
121121 X.Dom.listenOnce( X.Dom.Event.DOM_PRE_INIT, function(){
--- a/0.6.x/js/01_dom/11_XDomDTD.js
+++ b/0.6.x/js/01_dom/11_XDomDTD.js
@@ -16,7 +16,7 @@ X.Dom.DTD = {
1616 META : true,
1717 PARAM : true,
1818 EMBED : true
19- },//,
19+ },
2020
2121 TAG_FIX :
2222 X.UA.IE && 4 <= X.UA.IE && X.UA.IE < 5 ?
--- a/0.6.x/js/01_dom/11_XDomNode.js
+++ b/0.6.x/js/01_dom/11_XDomNode.js
@@ -181,11 +181,11 @@ Node._getType = function( v ){
181181 if( !v ) return 0;
182182 if( v === window ) return Node.IS_WINDOW;
183183 if( v === document ) return Node.IS_DOCUMENT;
184- if( X.Type.isImage( v ) ) return Node.IS_IMAGE;
185184 if( v.constructor === Node ) return Node.IS_XNODE;
186185 if( v.constructor === X.Dom.NodeList ) return Node.IS_XNODE_LIST;
187186 if( X.Type.isHTMLElement( v ) ) return Node.IS_RAW_HTML;
188187 if( v.nodeType === 3 ) return Node.IS_RAW_TEXT;
188+ if( X.Type.isImage( v ) ) return Node.IS_IMAGE;
189189 if( typeof v === 'string' ){
190190 return '<' === v.charAt( 0 ) && v.charAt( v.length - 1 ) === '>' ? Node.IS_HTML_STRING : Node.IS_STRING;
191191 };
--- a/0.6.x/js/03_util/01_XNinjaIframe.js
+++ b/0.6.x/js/03_util/01_XNinjaIframe.js
@@ -5,10 +5,10 @@ X.Util.NinjaIframe = X.EventDispatcher.inherits(
55
66 xnodeIframe : null,
77
8- _iwin : null,
8+ _iwin : null,
99
10- _html : null,
11- _name : null,
10+ _html : '',
11+ _name : '',
1212 _ready : false,
1313
1414 Constructor : function( html ){
@@ -95,7 +95,11 @@ X.Util.NinjaIframe = X.EventDispatcher.inherits(
9595 return this;
9696 };
9797
98- this._iwin.location.reload();
98+ if( X.UA.IE5 || X.UA.IE55 ){
99+ this._iwin.location.href = 'about:blank'; // reload() では、IE5.5(IETester)で2回目移行の操作でerrorが出る(doc取得やopen,writeで)
100+ } else {
101+ this._iwin.location.reload();
102+ };
99103
100104 if( !opt_html ) return this;
101105
@@ -120,17 +124,15 @@ X.Util.NinjaIframe = X.EventDispatcher.inherits(
120124 );
121125
122126 function X_Util_NinjaIframe_writeToIframe( that ){
123-var raw = that.xnodeIframe._rawObject,
124- idoc = raw.contentDocument || that._iwin.document,
125- html = that._html;
126-
127+ var raw = that.xnodeIframe._rawObject,
128+ idoc = raw.contentDocument || that._iwin.document,
129+ html = that._html;
130+
127131 delete that._html;
128132 that._ready = true;
129-
130- console.log( 'iframe import. ' + html );
131-
133+
132134 idoc.open();
133- idoc.writeln( html ); // ここで script を書き出すので2度呼ばれる?
135+ idoc.writeln( html );
134136 idoc.close();
135137 };
136138
--- a/0.6.x/js/04_net/00_XNet.js
+++ b/0.6.x/js/04_net/00_XNet.js
@@ -19,12 +19,13 @@ X.Net = {
1919
2020 // TODO chashe
2121 // TODO iframe useful or not.
22+ // TODO file: では http: は使えない
2223 jsonp : function( url, useIframe ){
2324 return new X_NET_Queue( X_NET_TYPE_JSONP, url );
2425 },
2526
2627 image : function( url, useIframe ){
27-
28+ return new X_NET_Queue( X_NET_TYPE_IMAGE, url );
2829 },
2930
3031 amountQueue : function(){
@@ -43,12 +44,14 @@ var X_NET_IWrapper = function(){};
4344 var X_NET_TYPE_XHR = 1,
4445 X_NET_TYPE_JSONP = 2,
4546 X_NET_TYPE_FORM = 3,
47+ X_NET_TYPE_IMAGE = 4,
4648
4749 X_NET_QUEUE_LIST = [],
4850
4951 X_NET_XHRWrapper,
5052 X_NET_JSONPWrapper,
51- X_NET_FORMWrapper,
53+ X_NET_FormWrapper,
54+ X_NET_ImageWrapper,
5255
5356 X_NET_currentWrapper,
5457 X_NET_currentQueue,
@@ -137,7 +140,10 @@ function X_NET_shiftQueue(){
137140 X_NET_currentWrapper = X_NET_JSONPWrapper;
138141 break;
139142 case X_NET_TYPE_FORM :
140- X_NET_currentWrapper = X_NET_FORMWrapper;
143+ X_NET_currentWrapper = X_NET_FormWrapper;
144+ break;
145+ case X_NET_TYPE_IMAGE :
146+ X_NET_currentWrapper = X_NET_ImageWrapper;
141147 break;
142148 };
143149
--- a/0.6.x/js/04_net/01_XNetXHR.js
+++ b/0.6.x/js/04_net/01_XNetXHR.js
@@ -1,22 +1,43 @@
11 // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest
22 // https://web.archive.org/web/20071101021832/http://web.paulownia.jp/script/ajax/xmlhttp4.html
3+// https://web.archive.org/web/20091029170015/http://wiki.paulownia.jp/ajax/xmlhttprequest
4+/*
5+ * http://ponpon-village.net/ajax/xmlhttp.htm
6+ * IE のバージョンによっては、ActiveXObject("Msxml2.XMLHTTP.5.0") , ActiveXObject("Msxml2.XMLHTTP.4.0") ,
7+ActiveXObject("Msxml2.XMLHTTP.3.0") , ActiveXObject("Msxml2.XMLHTTP") なども使用出来る。
38
9+http://vird2002.s8.xrea.com/javascript/XMLHttpRequest.html
10+// --- 使うべきオブジェクト
11+new ActiveXObject( 'Msxml2.XMLHTTP.3.0' ); // バージョン3.0 広範に利用されているので、今後も bugfix を行う
12+new ActiveXObject( 'Msxml2.XMLHTTP.6.0' ); // バージョン6.0 は最新版なので bugfix を続ける
13+
14+// --- 使うべきではないオブジェクト
15+new ActiveXObject( 'Microsoft.XMLHTTP' ); // Microsoft接頭辞は古いので指定すべきではない
16+new ActiveXObject( 'Msxml.XMLHTTP' ); // Msxml2接頭辞を指定すべき
17+new ActiveXObject( 'Msxml2.XMLHTTP' ); // バージョンを省略すると 3.0 として扱われるので、バージョンは明記すべき
18+new ActiveXObject( 'Msxml2.XMLHTTP.4.0' ); // バージョン4.0 は bugfix が行われないので、3.0 か 6.0 を指定すべき
19+new ActiveXObject( 'Msxml2.XMLHTTP.5.0' ); // バージョン5.0 は bugfix が行われないので、3.0 か 6.0 を指定すべき
20+
21+ */
422 var X_Net_XHR_W3C = window[ 'XMLHttpRequest' ] && new XMLHttpRequest(),
523 X_Net_XHR_X_DOMAIN = window[ 'XDomainRequest' ] && new XDomainRequest(),
624 X_Net_XHR_VERSION = 0,
725 X_Net_XHR_ACTIVE_X = 5 <= X.UA.IE && X.UA.IE < 8 && X.UA.ActiveX && ( new Function( [
826 'var x=".XMLHTTP",',
927 'm="MSXML2"+x,',
10- 'v=[m+".6.0",m+".3.0",m,"Microsoft"+x,m+".4.0"],',
28+ 'v=[m+".6.0",m+".3.0",m+".5.0",m+".4.0",m,"Microsoft"+x],',
1129 'i=-1;',
12- 'for(;i<3;){',
30+ 'for(;i<5;){',
1331 'try{',
14- 'return new ActiveXObject(v[++i]);',
32+ 'return[++i,new ActiveXObject(v[i])];',
1533 '}catch(e){}',
1634 '}'
1735 ].join( '' ) ) )();
1836
19-
37+if( X_Net_XHR_ACTIVE_X ){
38+ X_Net_XHR_VERSION = [ 6, 3, 5, 4, 2, 1 ][ X_Net_XHR_ACTIVE_X[ 0 ] ];
39+ X_Net_XHR_ACTIVE_X = X_Net_XHR_ACTIVE_X[ 1 ];
40+};
2041
2142 X.Net.XHR = {
2243 // Opera7.6+, Safari1.2+, khtml3.?+, Gecko0.9.7+
@@ -89,15 +110,15 @@ if( X.Net.XHR.W3C || X_Net_XHR_ACTIVE_X ){
89110 if( X_Net_XHR_X_DOMAIN ){
90111 if( false /* isXDomain( url ) */ ){ // isXDomain
91112 //if( raw !== X_Net_XHR_X_DOMAIN ){
92- X_NET_XHRWrapper._migrateEvent();
113+ X_EventDispatcher_migrateEvent( this );
93114 X_NET_XHRWrapper._rawObject = X_Net_XHR_X_DOMAIN;
94- X_NET_XHRWrapper._restoreEvent();
115+ X_EventDispatcher_restoreEvent( this );
95116 //};
96117 } else {
97118 //if( raw === X_Net_XHR_X_DOMAIN ){
98- X_NET_XHRWrapper._migrateEvent();
119+ X_EventDispatcher_migrateEvent( this );
99120 X_NET_XHRWrapper._rawObject = X_Net_XHR_W3C || X_Net_XHR_ACTIVE_X;
100- X_NET_XHRWrapper._restoreEvent();
121+ X_EventDispatcher_restoreEvent( this);
101122 //};
102123 };
103124 };
@@ -213,6 +234,7 @@ if( X.Net.XHR.W3C || X_Net_XHR_ACTIVE_X ){
213234 break;
214235 case 'json' :
215236 case 'moz-json' :
237+ data = raw[ 'response' ] || raw[ 'responseText' ]; // とりあえず
216238 break;
217239 case 'document' :
218240 case 'xml' :
@@ -222,6 +244,7 @@ if( X.Net.XHR.W3C || X_Net_XHR_ACTIVE_X ){
222244 break;
223245 case 'blob' :
224246 case 'arraybuffer' :
247+ data = raw[ 'response' ] || raw[ 'responseText' ]; // とりあえず
225248 break;
226249 };
227250
--- a/0.6.x/js/04_net/02_XNetJSONP.js
+++ b/0.6.x/js/04_net/02_XNetJSONP.js
@@ -6,6 +6,10 @@
66 * http://kozo002.blogspot.jp/2012/07/ie9iframewindowparent.html
77 */
88
9+/*
10+ * IE6(IETester) で動かない,localhost
11+ */
12+
913 X.Net.JSONP = {
1014 cb : function( accessKey, jsonString, time, opt_json2FileSize ){
1115 if( accessKey !== X_NET_JSONP_ACCESS_KEY ) return;
@@ -62,6 +66,7 @@ function X_NET_JSONP_loadScriptInNinjaIframe( url ){
6266 '<script src="', url, '"></script>' */
6367 '<script id="jp"></script>',
6468 '<script>',
69+ 'nw=0;',
6570 'function cb(o){nw-=+new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',parent.JSON.stringify(o),-nw)}',
6671 'function tm(){jp.src="', url ,'";nw=+new Date}',
6772 'setTimeout(tm,16);',
--- /dev/null
+++ b/0.6.x/js/04_net/04_XNetImage.js
@@ -0,0 +1,116 @@
1+/*
2+ * original
3+ * LICENSE: MIT?
4+ * URL: http://d.hatena.ne.jp/uupaa/20080413/1208067631
5+ * AUTHOR: uupaa.js@gmail.com
6+ *
7+ */
8+
9+var X_Net_Image_hasImage = !!window[ 'Image' ];
10+
11+if( !X_Net_Image_hasImage ){
12+ alert( 'no Image!' );
13+};
14+
15+/*
16+ * TODO
17+ * new Image() のときに Image オブジェクトを作るもの(IE8-)と、HTMLImageElement を作るものがある。
18+ * Image は、X.EventDispatcher で、<img> は X.Dom.Node で。
19+ */
20+X_NET_ImageWrapper = ( X_Net_Image_hasImage ? X.EventDispatcher : X.Dom.Node ).inherits(
21+ 'X.Net.Image',
22+ X.Class.POOL_OBJECT,
23+ {
24+ _rawObject : X_Net_Image_hasImage && new Image,
25+
26+ tick : 0,
27+ timerID : 0,
28+ finish : false,
29+ abspath : null,
30+ delay : null,
31+ timeout : 0,
32+
33+ Constructor : X_Net_Image_hasImage ?
34+ (function(){
35+ this.listen( [ 'load', 'error', 'abort', X.Event.SUCCESS, X.Event.ERROR, X.Event.KILL_INSTANCE ] );
36+ }) :
37+ (function(){
38+ this.SuperConstructor( document.createElement( 'img' ) )
39+ .appendTo( X.Dom.Node._systemNode )
40+ .listen( [ 'load', 'error', 'abort', X.Event.SUCCESS, X.Event.ERROR, X.Event.KILL_INSTANCE ] );
41+ }),
42+
43+ load : function( abspath, opt_delay, opt_timeout ){
44+ this.abspath = abspath;
45+ this.delay = opt_delay || 100;
46+ this.timeout = opt_timeout || 10000;
47+ this.timerID = X.Timer.add( this.delay, 0, this, this._detect );
48+
49+ X_Net_Image_hasImage ? ( this._rawObject.src = abspath ) : this.attr( 'src', abspath );
50+ },
51+
52+ handleEvent : function( e ){
53+ var size;
54+ switch( e.type ){
55+ case 'error' :
56+ case 'abort' : // TODO ??
57+ if( this.finish ) return;
58+ this.finish = true;
59+ this.timerID && X.Timer.remove( this.timerID );
60+ this.timerID = this.asyncDispatch( 0, { type : X.Event.ERROR } );
61+ break;
62+ case 'load' :
63+ // if( finish === true ) return; // これがあると firefox3.6 で駄目、、、
64+ // if( timer ) return; // これがあると safari3.2 で駄目、、、
65+ this.finish = true;
66+ this.timerID && X.Timer.remove( this.timerID );
67+ if( X.UA.Opera && !this._rawObject.complete ){
68+ this.timerID = this.asyncDispatch( 0, { type : X.Event.ERROR } );
69+ return;
70+ };
71+ size = X.Dom.Image.getActualDimension( X.UA.IE < 9 && X_Net_Image_hasImage ? this.abspath : this );
72+ this.timerID = this.asyncDispatch( 0, {
73+ type : X.Event.SUCCESS,
74+ src : this.abspath,
75+ w : size[ 0 ],
76+ h : size[ 1 ]
77+ } );
78+ break;
79+ case X.Event.SUCCESS :
80+ case X.Event.ERROR :
81+ this.timerID && X.Timer.remove( this.timerID );
82+ this.timerID = this.asyncDispatch( 0, X.Event.COMPLETE );
83+ break;
84+ case X.Event.KILL_INSTANCE :
85+ this.timerID && X.Timer.remove( this.timerID );
86+ !X_Net_Image_hasImage && this.destroy(); // if xnode
87+ this.unlisten();
88+ break;
89+ };
90+ },
91+ _detect : function(){
92+ if( this.finish ) return;
93+ if( this._rawObject && this._rawObject.complete ){
94+ this.finish = true;
95+ if( this._rawObject.width ) return;
96+ X.Timer.remove( this.timerID );
97+ this.timerID = this.asyncDispatch( 0, X.Event.ERROR );
98+ } else
99+ if( this.timeout < ( this.tick += this.delay ) ){
100+ this.finish = true;
101+ X.Timer.remove( this.timerID );
102+ this.timerID = this.asyncDispatch( 0, X.Event.TIMEOUT );
103+ };
104+ },
105+ cancel : function(){
106+ this._rawObject && this._rawObject.abort();
107+ },
108+
109+ reset : function(){
110+ this.timerID && X.Timer.remove( this.timerID );
111+ this.timerID = 0;
112+ this.finished = false;
113+ this.abspath = null;
114+ }
115+ }
116+);
旧リポジトリブラウザで表示