PageRenderTime 73ms CodeModel.GetById 9ms app.highlight 58ms RepoModel.GetById 1ms app.codeStats 1ms

/bin/std/js/Dom.hx

http://github.com/Yoomee/clippy
Haxe | 631 lines | 454 code | 85 blank | 92 comment | 0 complexity | d4e81d042f40f884574c59226c200da1 MD5 | raw file
  1/*
  2 * Copyright (c) 2005, The haXe Project Contributors
  3 * All rights reserved.
  4 * Redistribution and use in source and binary forms, with or without
  5 * modification, are permitted provided that the following conditions are met:
  6 *
  7 *   - Redistributions of source code must retain the above copyright
  8 *     notice, this list of conditions and the following disclaimer.
  9 *   - Redistributions in binary form must reproduce the above copyright
 10 *     notice, this list of conditions and the following disclaimer in the
 11 *     documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 16 * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
 17 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 20 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 23 * DAMAGE.
 24 */
 25package js;
 26
 27// allow both indexed and dot accessses
 28extern class HtmlCollection<T> implements ArrayAccess<T>, implements Dynamic<T> {
 29	var length(default,null) : Int;
 30}
 31
 32// the base typedef for every DOM element
 33typedef MetaDom<T> = {
 34	var nodeName : String;
 35	var nodeType : Int;
 36	var nodeValue : String;
 37
 38	var parentNode : T;
 39	var childNodes : HtmlCollection<T>;
 40	var firstChild : T;
 41	var lastChild : T;
 42	var nextSibling : T;
 43	var previousSibling : T;
 44
 45	function appendChild( child : T ) : Void;
 46	function cloneNode( deep : Bool ) : T;
 47	function hasChildNodes() : Bool;
 48	function insertBefore( newChild : T, refChild : T ) : Void;
 49	function removeChild( child : T ) : T;
 50	function replaceChild( child : T, oldChild : T ) : Void;
 51	function getAttribute( attr : String ) : String;
 52	function setAttribute( attr : String, val : String ) : Void;
 53}
 54
 55typedef Dom = MetaDom<Dom>
 56
 57typedef HtmlDom = {> MetaDom<HtmlDom>,
 58	var id : String;
 59	var title : String;
 60	var lang : String;
 61	var dir : String;
 62	var innerHTML : String;
 63	var className : String;
 64
 65	var style : Style;
 66
 67	function getElementsByTagName( tag : String ) : HtmlCollection<HtmlDom>;
 68
 69	var scrollTop : Int;
 70	var scrollLeft : Int;
 71	var scrollHeight(default,null) : Int;
 72	var scrollWidth(default,null) : Int;
 73	var clientHeight(default,null) : Int;
 74	var clientWidth(default,null) : Int;
 75	var offsetParent : HtmlDom;
 76	var offsetLeft : Int;
 77	var offsetTop : Int;
 78	var offsetWidth : Int;
 79	var offsetHeight : Int;
 80
 81	function blur() : Void;
 82	function click() : Void;
 83	function focus() : Void;
 84
 85	var onscroll : Event -> Void;
 86	var onblur : Event -> Void;
 87	var onclick : Event -> Void;
 88	var ondblclick : Event -> Void;
 89	var onfocus : Event -> Void;
 90	var onkeydown : Event -> Void;
 91	var onkeypress : Event -> Void;
 92	var onkeyup : Event -> Void;
 93	var onmousedown : Event -> Void;
 94	var onmousemove : Event -> Void;
 95	var onmouseout : Event -> Void;
 96	var onmouseover : Event -> Void;
 97	var onmouseup : Event -> Void;
 98	var onresize : Event -> Void;
 99}
100
101typedef FormElement = {> HtmlDom,
102
103	var disabled : Bool;
104	var form : Form;
105	var name : String;
106	var type : String;
107	var value : String;
108
109	function select() : Void;
110	var onselect : Event -> Void;
111	var onchange : Event -> Void;
112}
113
114typedef Anchor = {> HtmlDom,
115
116	var accessKey : String;
117	var href : String;
118	var name: String;
119	var rel : String;
120	var rev : String;
121	var tabIndex : Int;
122	var target : String;
123
124#if ie5
125	var charset : String;
126	var coords : String;
127	var hreflang : String;
128	var shape : String;
129	var type : String;
130#end
131
132}
133
134typedef Body = {> HtmlDom,
135	// IE only, NO W3C var accessKey : String;
136	var aLink : String;
137	var background : String;
138	var bgColor : String;
139	var link : String;
140	var text : String;
141	var vLink : String;
142}
143
144typedef Button = {> FormElement,
145}
146
147typedef Checkbox = {> FormElement,
148	var checked : Bool;
149	var defaultChecked : Bool;
150}
151
152typedef Document = {> HtmlDom,
153	var anchors : HtmlCollection<Anchor>;
154	// applets : Applet is deprecated in Dom2
155	var forms : HtmlCollection<Form>;
156	var images : HtmlCollection<Image>;
157	var links : HtmlCollection<Link>;
158	// plugins : Not in IE, not in W3C
159
160	/* deprecated in Dom2 , use body
161	var alinkColor;
162	var background;
163	var bgColor;
164	var fgColor;
165	var linkColor;
166	var vlinkColor;
167	*/
168
169	var body : Body;
170	var cookie : String;
171	var domain : String;
172	var referrer : String;
173
174	// TODO : var URL : String;
175
176	// not W3C , need infos : var embeds : HtmlCollection<Embed>;
177	// var lastModified : Date; // commented : does not include date by default
178	var styleSheets : HtmlCollection<StyleSheet>;
179	function getElementsByTag( tag : String ) : HtmlCollection<HtmlDom>;
180
181	function open() : Void;
182	function write( str : String ) : Void;
183	function writeln( str : String ) : Void;
184	function close() : Void;
185	function getElementById( id : String ) : HtmlDom;
186	function getElementsByName( name : String ) : HtmlCollection<HtmlDom>;
187	function createElement( name : String ) : HtmlDom;
188}
189
190typedef Event = {
191	var target : HtmlDom;
192	var type : String;
193
194	// TO COMPLETE... (need infos)
195	var clientX : Int;
196	var clientY : Int;
197	var screenX : Int;
198	var screenY : Int;
199	var button : Int;
200	var keyCode : Int;
201	var shiftKey : Bool;
202	var ctrlKey : Bool;
203	var altKey : Bool;
204	var cancelBubble : Bool;
205}
206
207typedef FileUpload = {> FormElement,
208	var defaultValue : String;
209}
210
211typedef Form = {> HtmlDom,
212
213	var elements : HtmlCollection<FormElement>;
214
215	var acceptCharset : String;
216	var action : String;
217	var encoding : String;
218	var enctype : String;
219	var length : Int;
220	var method : String;
221	var name : String;
222	var tabIndex : Int;
223	var target : String;
224
225	function reset() : Void;
226	function submit() : Void;
227
228	var onreset : Event -> Void;
229	var onsubmit : Event -> Bool;
230}
231
232typedef Frame = {> HtmlDom,
233
234	var contentDocument : Document;
235	var frameBorder : String;
236	// IE6 only ? var longDesc : String
237	var marginHeight : String;
238	var marginWidth : String;
239	var name : String;
240	var noResize : Bool;
241	var scrolling : String;
242	var src : String;
243}
244
245typedef Frameset = {> HtmlDom,
246	var cols : Int;
247	var rows : Int;
248}
249
250typedef Hidden = {> FormElement,
251	var defaultValue : String;
252}
253
254typedef History = {
255	var length : Int;
256	function back() : Void;
257	function forward() : Void;
258	function go( p : Dynamic ) : Void;
259}
260
261typedef IFrame = {> HtmlDom,
262	var contentDocument : Document;
263	var frameBorder : String;
264	var height : Int;
265	var width : Int;
266	// IE6 only ? var longDesc : String
267	var marginHeight : String;
268	var marginWidth : String;
269	var name : String;
270	var scrolling : String;
271	var src : String;
272}
273
274typedef Image = {> HtmlDom,
275	var align : String;
276	var alt : String;
277	var border : String;
278	var height : Int;
279	var hspace : Int;
280	var isMap : Bool;
281	// IE only : var longDesc : String;
282	var name : String;
283	var src : String;
284	var useMap : String;
285	var vspace : Int;
286	var width : Int;
287
288	var complete : Bool;
289	var lowsrc : String;
290
291	var onabort : Event -> Void;
292	var onerror : Event -> Void;
293	var onload : Event -> Void;
294}
295
296typedef Link = {> HtmlDom,
297	var charset : String;
298	var disabled : Bool;
299	var href : String;
300	var hreflang : String;
301	var media : String;
302	var rel : String;
303	var rev : String;
304	var target : String;
305	var type : String;
306	var name : String;
307	var onload : Event -> Void;
308}
309
310typedef Location = {
311	var hash : String;
312	var host : String;
313	var hostname : String;
314	var href : String;
315	var pathname : String;
316	var port : Int;
317	var protocol : String;
318	var search : String;
319
320	function assign( url : String ) : Void;
321	function reload( ?forceReload : Bool ) : Void;
322	function replace( url : String ) : Void;
323}
324
325typedef Navigator = {
326	// var plugins : HtmlCollection<???>
327
328	var appCodeName : String;
329	var appName : String;
330	var appVersion : String;
331	var cookieEnabled : Bool;
332	var platform : String;
333	var userAgent : String;
334
335	/* IE only ?
336	var appMinorVersion : String
337	var browserLanguage : String
338	var cpuClass : String;
339	var onLine : Bool;
340	var systemLanguage : String;
341	var userLanguage : String;
342	*/
343
344	function javaEnabled() : Bool;
345	function taintEnabled() : Bool;
346}
347
348typedef Option = {> FormElement,
349	var defaultSelected : Bool;
350	var selected : Bool;
351	var text : String;
352}
353
354typedef Password = {> FormElement,
355	var defaultValue : String;
356	var maxLength : Int;
357	var readOnly : Bool;
358	var size : Int;
359}
360
361typedef Radio = {> FormElement,
362	var checked : Bool;
363	var defaultChecked : Bool;
364	var size : Int;
365}
366
367typedef Reset = {> FormElement,
368}
369
370typedef Screen = {
371	var availHeight : Int;
372	var availWidth : Int;
373	var colorDepth : Int;
374	var height : Int;
375	var width : Int;
376
377	// FF only ? var pixelDepth : Int;
378
379	/* IE only ?
380	var bufferDepth : Int;
381	var deviceXDPI : Int;
382	var deviceYDPI : Int;
383	var logicalXDPI : Int;
384	var logicalYDPI : Int;
385	var updateInterval : Int;
386	*/
387}
388
389typedef Select = {> FormElement,
390	var options : HtmlCollection<Option>;
391	var length : Int;
392	var multiple : Bool;
393	var selectedIndex : Int;
394	var size : Int;
395
396	function remove( o : Int ) : Void;
397}
398
399typedef Style = {
400	// Position
401	var left : String;
402	var bottom : String;
403	var height : String;
404	var width : String;
405	var top : String;
406	var right : String;
407	var zIndex : Int;
408	var position : Dynamic;
409
410	// BG
411	var background : Dynamic;
412	var backgroundAttachment : Dynamic;
413	var backgroundColor : Dynamic;
414	var backgroundImage : Dynamic;
415	var backgroundPosition : Dynamic;
416	var backgroundRepeat : Dynamic;
417
418	// Border
419	var border : Dynamic;
420	var borderBottom : Dynamic;
421	var borderLeft : Dynamic;
422	var borderRight : Dynamic;
423	var borderTop : Dynamic;
424	var borderBottomColor : Dynamic;
425	var borderLeftColor : Dynamic;
426	var borderRightColor : Dynamic;
427	var borderTopColor : Dynamic;
428	var borderBottomStyle : Dynamic;
429	var borderLeftStyle : Dynamic;
430	var borderRightStyle : Dynamic;
431	var borderTopStyle : Dynamic;
432	var borderBottomWidth : Dynamic;
433	var borderLeftWidth : Dynamic;
434	var borderRightWidth : Dynamic;
435	var borderTopWidth : Dynamic;
436	var borderColor : Dynamic;
437	var borderStyle : String;
438	var borderWidth : Dynamic;
439
440
441	var margin : Dynamic;
442	var marginBottom : Dynamic;
443	var marginLeft : Dynamic;
444	var marginRight : Dynamic;
445	var marginTop : Dynamic;
446
447	var outline : Dynamic;
448	var outlineColor : Dynamic;
449	var outlineStyle : Dynamic;
450	var outlineWidth : Dynamic;
451	var padding : Dynamic;
452	var paddingBottom : Dynamic;
453	var paddingLeft : Dynamic;
454	var paddingRight : Dynamic;
455	var paddingTop : Dynamic;
456
457	var clear : String;
458	var clip : Dynamic;
459	var clipBottom : Dynamic;
460	var clipLeft : Dynamic;
461	var clipRight : Dynamic;
462	var clipTop : Dynamic;
463
464	var content : Dynamic;
465	var counterIncrement : Dynamic;
466	var counterReset : Dynamic;
467	var cssFloat : Dynamic;
468	var cursor : Dynamic;
469	var direction : Dynamic;
470	var display : Dynamic;
471
472	var markerOffset : Dynamic;
473	var marks : Dynamic;
474	var maxHeight : Dynamic;
475	var maxWidth : Dynamic;
476	var minHeight : Dynamic;
477	var minWidth : Dynamic;
478	var overflow : Dynamic;
479	var overflowX : Dynamic;
480	var overflowY : Dynamic;
481	var styleFloat : Dynamic;
482	var verticalAlign : Dynamic;
483	var visibility : Dynamic;
484	var zoom : Dynamic;
485
486	var listStyle : Dynamic;
487	var listStyleImage : Dynamic;
488	var listStylePosition : Dynamic;
489	var listStyleType : String;
490
491	var cssText : Dynamic;
492
493	var color : Dynamic;
494	var font : Dynamic;
495	var fontFamily : Dynamic;
496	var fontSize : Dynamic;
497	var fontSizeAdjust : Dynamic;
498	var fontStretch : Dynamic;
499	var fontStyle : Dynamic;
500	var fontVariant : Dynamic;
501	var fontWeight : Dynamic;
502	var letterSpacing : Dynamic;
503	var lineBreak : Dynamic;
504	var lineHeight : Dynamic;
505	var quotes : Dynamic;
506	var rubyAlign : Dynamic;
507	var rubyOverhang : Dynamic;
508	var rubyPosition : Dynamic;
509	var textAlign : Dynamic;
510	var textAlignLast : Dynamic;
511	var textAutospace : Dynamic;
512	var textDecoration : Dynamic;
513	var textDecorationBlink : Dynamic;
514	var textDecorationLineThrough : Dynamic;
515	var textDecorationLineNone : Dynamic;
516	var textDecorationLineOverline : Dynamic;
517	var textDecorationLineUnderline : Dynamic;
518	var textIndent : Dynamic;
519	var textJustify : Dynamic;
520	var textJustifyTrim : Dynamic;
521	var textKashidaSpace : Dynamic;
522	var textOverflow : Dynamic;
523	var textShadow : Dynamic;
524	var textTransform : Dynamic;
525	var textUnderlinePosition : Dynamic;
526	var unicodeBidi : Dynamic;
527	var whiteSpace : Dynamic;
528	var wordBreak : Dynamic;
529	var wordSpacing : Dynamic;
530	var wordWrap : Dynamic;
531	var writingMode : Dynamic;
532}
533
534typedef StyleSheet = {
535	var type : String;
536	var disabled : Bool;
537	var href : String;
538	var title : String;
539	// ??? more ???
540}
541
542typedef Submit = {> FormElement,
543	var onselectstart : Event -> Void;
544}
545
546typedef Text = {> FormElement,
547	var defaultValue : String;
548	var maxLength : Int;
549	var readOnly : Bool;
550	var size : Int;
551}
552
553typedef Textarea = {> FormElement,
554	var cols : Int;
555	var rows : Int;
556	var defaultValue : String;
557	var readOnly : Bool;
558}
559
560typedef Window = {
561
562	var history : History;
563	var location : Location;
564	var document : Document;
565	var navigator : Navigator;
566	var screen : Screen;
567
568	var frames : HtmlCollection<Frame>;
569	var closed : Bool;
570	var defaultStatus : String;
571	var length : Int;
572	var name : String;
573	var opener : Window;
574	var parent : Window;
575
576	var self : Window;
577	var status : String;
578	var top : Window;
579
580	function alert( msg : String ) : Void;
581	function blur() : Void;
582	// clearInterval
583	// clearTimeout
584	function close() : Void;
585	function confirm( msg : String ) : Bool;
586	function focus() : Void;
587	function moveBy( dx : Int, dy : Int ) : Void;
588	function moveTo( x : Int, y : Int ) : Void;
589	function print() : Void;
590	function prompt( msg : String, ?def : String ) : String;
591	// FF1.5 resizeTo
592	function scrollBy( dx : Int, dy : Int ) : Void;
593	function scrollTo( x : Int, y : Int ) : Void;
594	function open( url : String, ?name : String, ?features : String ) : Window;
595	// setInterval
596	// setTimeout
597
598	var innerWidth : Int;
599	var innerHeight : Int;
600	var outerWidth : Int;
601	var outerHeight : Int;
602
603	/* IE only ?
604	clientInformation
605	clipboardData
606	event
607	external
608	dialogArguments
609	dialog....
610	frameElement
611	offscreenBuffering
612	returnValue
613	screenTop
614	createPopup()
615	execScript()
616	navigate(url)
617	resizeBy()
618	scroll();
619	setActive()
620	showHelp()
621	show...()
622	*/
623
624 	// events
625	var onload : Event -> Void;
626	var onresize : Event -> Void;
627	var onscroll : Event -> Void;
628	var onunload : Event -> Void;
629	var onerror : Event -> Void;
630
631}