-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCaseStudy.Superposition.htm
160 lines (155 loc) · 4.79 KB
/
CaseStudy.Superposition.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<!DOCTYPE HTML>
<html>
<head>
<title>Superposition d'éléments</title>
<style>
.zindex1 { /* PRE BACKGROUND */
background: #000;
color: lightskyblue;
border: 2px solid lightskyblue;
z-index: 1;
}
.zindex2 { /* TEXTAREA + ... */
background: transparent !important;
color: #000;
border: 2px solid #000;
height: 180px !important;
width: 600px !important;
z-index: 2;
}
.test {
position: relative;
height: 300px;
width: 400px;
}
.test PRE,
.test TEXTAREA {
font: normal 16px/20px 'Monaco',Menlo,'Ubuntu Mono',Consolas,'source-code-pro',monospace;
margin: 0;
padding: 0;
position: absolute;
left: 0;
top: 0;
}
.test B {
font-weight: normal !important;
background: yellow;
color: red;
font: inherit;
}
.test PRE {
background: #000;
width: 500px;
}
.test PRE.editable {
overflow: scroll;
white-space:pre !important;
color: #000;
z-index: 2;
width: auto;
}
</style>
</head>
<body spellcheck="false">
<a href="./index.htm">index</a>
<div><h1> Superposition d'éléments</h1>
<p>
L'idée constiste à éditer le texte en dessus, et mettre à jour la coloration syntaxique en dessous.
Pour visualiser la coloration il suffirait juste de décaler le texte en dessous.
</p>
<p>
Elle a pour but l'utilisation des zones déditions natives des navigateurs cibles.
</p>
<div><h2> Superposition d'un <span class="zindex2">TEXTAREA</span> sur un <span class="zindex1">PRE</span></h2>
<ul>
<li>Les navigateurs laissent tous apparaître un décalage (différent selon les navigateurs).</li>
<li>La taille des tabulations varie sur IE (entre un élément TEXTAREA et un PRE). </li>
</ul>
<div class="test">
<pre class="zindex1">
/* 1 - JavaScript syntax */
var n = nInt1/4 + 4/nInt1 + 10
var oEditor = new EditorSample ( eContent ,{
// a single line comment ( a single quote ' )
aArray : [ true , false , null , undefined , Infinity , NaN ],
<b>sDoubleQuoteString</b> : "/* a multi line comment */ // a single line comment " ,
sSingleQuoteString : '/* a multi line comment */ // a single line comment '
sBracketsTest1_1 : "{[(",
sBracketsTest1_2 : "}])",
/*
a multi line comment ( a double quote " )
*/
})
</pre>
<textarea class="zindex2" wrap="off">
/* 1 - JavaScript syntax */
var n = nInt1/4 + 4/nInt1 + 10
var oEditor = new EditorSample ( eContent ,{
// a single line comment ( a single quote ' )
aArray : [ true , false , null , undefined , Infinity , NaN ],
sDoubleQuoteString : "/* a multi line comment */ // a single line comment " ,
sSingleQuoteString : '/* a multi line comment */ // a single line comment '
sBracketsTest1_1 : "{[(",
sBracketsTest1_2 : "}])",
/*
a multi line comment ( a double quote " )
*/
})
</textarea>
</div>
</div>
<div><h2> Superposition d'un <span class="zindex2">PRE</span> (contenteditable="true") sur un <span class="zindex1">PRE</span></h2>
<ul>
<li>Ils laissent tous apparaître un petit décalage similaire.</li>
<li>Pour Chrome et Safari les lignes sont cassées si la largeur du PRE (contenteditable="true") est fixé.</li>
</ul>
<div class="test">
<pre class="zindex1">
/* 1 - JavaScript syntax */
var n = nInt1/4 + 4/nInt1 + 10
var oEditor = new EditorSample ( eContent ,{
// a single line comment ( a single quote ' )
aArray : [ true , false , null , undefined , Infinity , NaN ],
<b>sDoubleQuoteString</b> : "/* a multi line comment */ // a single line comment " ,
sSingleQuoteString : '/* a multi line comment */ // a single line comment '
sBracketsTest1_1 : "{[(",
sBracketsTest1_2 : "}])",
/*
a multi line comment ( a double quote " )
*/
})
</pre>
<pre class="editable zindex2" contenteditable="true">
/* 1 - JavaScript syntax */
var n = nInt1/4 + 4/nInt1 + 10
var oEditor = new EditorSample ( eContent ,{
// a single line comment ( a single quote ' )
aArray : [ true , false , null , undefined , Infinity , NaN ],
sDoubleQuoteString : "/* a multi line comment */ // a single line comment " ,
sSingleQuoteString : '/* a multi line comment */ // a single line comment '
sBracketsTest1_1 : "{[(",
sBracketsTest1_2 : "}])",
/*
a multi line comment ( a double quote " )
*/
})
</pre>
</div>
</div>
<div><h2> Conclusion</h2>
<p>Il est impossible de superposer 2 textes sans laisser apparaître en dessous le second texte (sauf cas exceptionnel : Opera,..).</p>
<p>Il faut rechercher une autre solution !</p>
<ul>
<li>
Pour ajouter des couleurs au texte (coloration syntaxique, surlignage, ...),
il faut créer son propre éditeur : la source doit-être affichée en html brut.
</li>
</ul>
</div>
</div>
<script src="shared.js"></script>
<link rel="stylesheet" type="text/css" href="src/toc.css">
<script src="src/toc.js"></script>
<script> setTOC( "CaseStudy.Superposition.htm" ) </script>
</body>
</html>