1
+ function createWindow ( url , name , width , height , options ) {
2
+ var x = ( screen . width - width ) / 2 , y = ( screen . height - height ) / 2 ;
3
+
4
+ //options += ',left=' + x +
5
+ // ',top=' + y +
6
+ // ',width=' + width +
7
+ // ',height=' + height;
8
+ //
9
+ options = options . replace ( / ^ , / , '' ) ;
10
+
11
+ var win = window . open ( url , name , options ) ;
12
+
13
+ win . focus ( ) ;
14
+
15
+ return win ;
16
+ }
17
+
1
18
Syntax . layouts . table = function ( options , code , container ) {
2
- var table = $ ( '<table>' ) , tr = null , td = null ;
19
+ var table = $ ( '<table>' ) , tr = null , td = null , a = null , toolbar = null
3
20
var line = 1 ;
4
21
5
22
table . addClass ( 'syntax' ) ;
6
23
24
+ // Toolbar
25
+ toolbar = document . createElement ( 'div' ) ;
26
+ toolbar . className = "toolbar" ;
27
+
28
+ a = document . createElement ( 'a' ) ;
29
+ a . href = "#" ;
30
+ a . innerHTML = "View Raw Code" ;
31
+
32
+ a . onclick = function ( ) {
33
+ var win = createWindow ( '#' , '_blank' , 700 , 500 , 'location=0, resizable=1, menubar=0, scrollbars=1, title=Raw' ) ;
34
+
35
+ win . document . write ( '<html><head></head><body><pre class="syntax">' + code . html ( ) + '</pre></body></html>' ) ;
36
+
37
+ $ ( 'link' ) . each ( function ( ) {
38
+ if ( this . rel != 'stylesheet' ) {
39
+ return ;
40
+ }
41
+
42
+ window . console . log ( this . href ) ;
43
+ var link = $ ( '<link rel="stylesheet">' , win . document ) ;
44
+
45
+ link . attr ( 'type' , this . type ) ;
46
+ link . attr ( 'href' , this . href ) ;
47
+ link . attr ( 'media' , this . media ) ;
48
+
49
+ $ ( "head" , win . document ) . append ( link ) ;
50
+ } ) ;
51
+
52
+ debugger
53
+
54
+ win . document . close ( ) ;
55
+ win . document . title = "Raw Source Code" ;
56
+ } ;
57
+
58
+ toolbar . appendChild ( a ) ;
59
+
60
+ a = document . createElement ( 'a' ) ;
61
+ a . href = "http://www.oriontransfer.co.nz/software/jquery-syntax/" ;
62
+ a . innerHTML = "?" ;
63
+ toolbar . appendChild ( a ) ;
64
+
65
+ // Source code
7
66
code . children ( ) . each ( function ( ) {
8
- tr = $ ( '<tr>' ) . addClass ( 'line' , 'line-' + line ) ;
67
+ tr = document . createElement ( 'tr' ) ;
68
+ tr . className = "line ln" + line ;
69
+
70
+ if ( line % 2 ) {
71
+ tr . className += " alt" ;
72
+ }
9
73
10
- td = $ ( '<td>' ) . addClass ( 'number' ) . text ( line ) ;
11
- tr . append ( td ) ;
74
+ td = document . createElement ( 'td' ) ;
75
+ td . className = "number" ;
76
+ td . innerHTML = line ;
77
+ tr . appendChild ( td ) ;
12
78
13
- td = $ ( '<td>' ) . addClass ( 'source' ) ;
14
- td . append ( this ) ;
15
- tr . append ( td ) ;
79
+ td = document . createElement ( 'td' ) ;
80
+ td . className = "source " + this . className ;
81
+ td . innerHTML = this . innerHTML ;
82
+ tr . appendChild ( td ) ;
16
83
17
- table . append ( tr ) ;
84
+ if ( toolbar ) {
85
+ td . appendChild ( toolbar ) ;
86
+ toolbar = null ;
87
+ }
88
+
89
+ table [ 0 ] . appendChild ( tr ) ;
18
90
line = line + 1 ;
19
91
} ) ;
20
92
93
+ $ ( '.href' , table ) . each ( function ( ) {
94
+ $ ( this ) . replaceWith ( $ ( '<a>' ) . attr ( 'href' , this . innerHTML ) . text ( this . innerHTML ) ) ;
95
+ } ) ;
96
+
21
97
return table ;
22
- }
98
+ } ;
0 commit comments