File tree Expand file tree Collapse file tree 8 files changed +123
-86
lines changed Expand file tree Collapse file tree 8 files changed +123
-86
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ body {
2
+ background-color : # EAEFF2 ;
3
+ padding : 0 ;
4
+ margin : 0 ;
5
+ }
6
+
7
+ # input {
8
+ width : 100% ;
9
+ background-color : white;
10
+ padding : 1em 1em 0 1em ;
11
+ box-sizing : border-box;
12
+ }
13
+
14
+ # buttons {
15
+ margin : 0.5em ;
16
+ }
17
+
18
+ # output {
19
+ width : 100% ;
20
+ height : 200px ;
21
+ background-color : white;
22
+ padding : 1em ;
23
+ box-sizing : border-box;
24
+ }
Original file line number Diff line number Diff line change
1
+ var element = document . getElementById ( "example-element" ) ;
2
+ var input = document . getElementById ( "input" ) ;
3
+ var reset = document . getElementById ( "reset" ) ;
4
+ var edit = document . getElementById ( "edit" ) ;
5
+ var code = input . value ;
6
+
7
+ function applyCode ( ) {
8
+ element . style . cssText = input . value ;
9
+ }
10
+
11
+ reset . addEventListener ( "click" , function ( ) {
12
+ input . value = code ;
13
+ applyCode ( ) ;
14
+ } ) ;
15
+
16
+ function setSelection ( ) {
17
+ var start = input . value . indexOf ( ":" ) + 1 ;
18
+ if ( ( input . value . length > start ) && ( input . value [ start ] === " " ) ) {
19
+ start ++ ;
20
+ }
21
+
22
+ var end = input . value . length - 1 ;
23
+ if ( ( input . value . length > 0 ) && ( input . value [ end - 1 ] === ";" ) ) {
24
+ end -- ;
25
+ }
26
+
27
+ input . setSelectionRange ( start , end ) ;
28
+ }
29
+
30
+ edit . addEventListener ( "click" , function ( ) {
31
+ input . focus ( ) ;
32
+ setSelection ( ) ;
33
+ } ) ;
34
+
35
+ input . addEventListener ( "input" , applyCode ) ;
36
+ window . addEventListener ( "load" , applyCode ) ;
Original file line number Diff line number Diff line change
1
+ # example-element {
2
+ border : solid 0.3em gold;
3
+ }
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+ < head >
4
+ < meta charset ="utf-8 ">
5
+ < link href ="../../css/editable.css " rel ="stylesheet "> </ link >
6
+ < link href ="css/element.css " rel ="stylesheet "> </ link >
7
+ </ head >
8
+
9
+ < body >
10
+ < div id ="output ">
11
+ < div id ="example-element ">
12
+ < p > This is a box with a border around it.
13
+ Note which side of the box is
14
+ red.</ p >
15
+ </ div >
16
+ </ div >
17
+
18
+ < div id ="buttons ">
19
+ < input id ="edit " type ="button " value ="Edit CSS " />
20
+ < input id ="reset " type ="button " value ="Reset " />
21
+ </ div >
22
+
23
+ < textarea id ="input " rows ="2 "> border-top-color: red;</ textarea >
24
+
25
+ < script type ="text/javascript " src ="../../js/editable.js "> </ script >
26
+
27
+ </ body >
28
+
29
+ </ html >
Original file line number Diff line number Diff line change
1
+ # example-element {
2
+ max-width : 80% ;
3
+ max-height : 80% ;
4
+ display : block;
5
+ margin : 1em auto 0 auto;
6
+ }
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+ < head >
4
+ < meta charset ="utf-8 ">
5
+ < link href ="../../css/editable.css " rel ="stylesheet "> </ link >
6
+ < link href ="css/element.css " rel ="stylesheet "> </ link >
7
+ </ head >
8
+
9
+ < body >
10
+ < div id ="output ">
11
+ < img id ="example-element " src ="img/firefox.png "/>
12
+ </ div >
13
+
14
+ < div id ="buttons ">
15
+ < input id ="edit " type ="button " value ="Edit CSS " />
16
+ < input id ="reset " type ="button " value ="Reset " />
17
+ </ div >
18
+
19
+ < textarea id ="input " rows ="2 "> filter: hue-rotate(180deg);</ textarea >
20
+
21
+ < script type ="text/javascript " src ="../../js/editable.js "> </ script >
22
+
23
+ </ body >
24
+
25
+ </ html >
You can’t perform that action at this time.
0 commit comments