1
- if ( typeof jQuery == "undefined" ) { throw new Error ( "Documentation needs the jQuery library to function." ) } ;
1
+ if ( typeof jQuery == "undefined" ) {
2
+ throw new Error ( "Documentation needs the jQuery library to function." )
3
+ }
4
+ ;
2
5
$ ( 'body' ) . scrollspy ( {
3
6
target : '#my-nav' ,
4
7
offset : 20
5
8
} ) ;
6
- var bs = $ ( '.footer' ) . outerHeight ( ) + 10 ;
7
- $ ( "#my-nav" ) . sticky ( { topSpacing :20 , bottomSpacing : bs } ) ;
9
+ var bs = $ ( '.footer' ) . outerHeight ( ) + 10 ;
10
+ $ ( "#my-nav" ) . sticky ( { topSpacing : 20 , bottomSpacing : bs } ) ;
8
11
$ ( "span.version" ) . html ( version || "" ) ;
12
+ $ . fn . getCursorPosition = function ( ) {
13
+ var input = this . get ( 0 ) ;
14
+ if ( ! input ) return ; // No (input) element found
15
+ if ( 'selectionStart' in input ) {
16
+ // Standard-compliant browsers
17
+ return input . selectionStart ;
18
+ } else if ( document . selection ) {
19
+ // IE
20
+ input . focus ( ) ;
21
+ var sel = document . selection . createRange ( ) ;
22
+ var selLen = document . selection . createRange ( ) . text . length ;
23
+ sel . moveStart ( 'character' , - input . value . length ) ;
24
+ return sel . text . length - selLen ;
25
+ }
26
+ }
27
+ function getCaretPosition ( editableDiv ) {
28
+ var caretPos = 0 ,
29
+ sel , range ;
30
+ if ( window . getSelection ) {
31
+ sel = window . getSelection ( ) ;
32
+ if ( sel . rangeCount ) {
33
+ range = sel . getRangeAt ( 0 ) ;
34
+ if ( range . commonAncestorContainer . parentNode == editableDiv ) {
35
+ caretPos = range . endOffset ;
36
+ }
37
+ }
38
+ } else if ( document . selection && document . selection . createRange ) {
39
+ range = document . selection . createRange ( ) ;
40
+ if ( range . parentElement ( ) == editableDiv ) {
41
+ var tempEl = document . createElement ( "span" ) ;
42
+ editableDiv . insertBefore ( tempEl , editableDiv . firstChild ) ;
43
+ var tempRange = range . duplicate ( ) ;
44
+ tempRange . moveToElementText ( tempEl ) ;
45
+ tempRange . setEndPoint ( "EndToEnd" , range ) ;
46
+ caretPos = tempRange . text . length ;
47
+ }
48
+ }
49
+ return caretPos ;
50
+ }
51
+
9
52
$ ( document ) . ready ( function ( ) {
10
53
prettyPrint ( ) ;
11
- setTimeout ( function ( ) {
54
+ setTimeout ( function ( ) {
12
55
return ;
13
56
$ . confirm ( {
14
57
title : 'Ahh, ad blockers' ,
@@ -21,16 +64,31 @@ $(document).ready(function () {
21
64
}
22
65
}
23
66
} )
24
- } , 1000 )
67
+ } , 1000 ) ;
68
+
69
+ $ ( '.change-format-css' ) . click ( function ( ) {
70
+ $ ( '.change-format-css' ) . addClass ( 'active' ) ;
71
+ $ ( '.change-format-less' ) . removeClass ( 'active' ) ;
72
+ $ ( '.format-less' ) . hide ( ) ;
73
+ $ ( '.format-css' ) . show ( ) ;
74
+ } ) ;
75
+ $ ( '.change-format-less' ) . click ( function ( ) {
76
+ $ ( '.change-format-less' ) . addClass ( 'active' ) ;
77
+ $ ( '.change-format-css' ) . removeClass ( 'active' ) ;
78
+ $ ( '.format-css' ) . hide ( ) ;
79
+ $ ( '.format-less' ) . show ( ) ;
80
+ } ) ;
25
81
} ) ;
26
- function rs ( ) {
27
- if ( $ ( window ) . width ( ) > 992 ) {
82
+ $ ( '.format-css' ) . hide ( ) ;
83
+
84
+ function rs ( ) {
85
+ if ( $ ( window ) . width ( ) > 992 ) {
28
86
$ ( '#my-nav' ) . show ( ) ;
29
- } else {
87
+ } else {
30
88
$ ( '#my-nav' ) . hide ( ) ;
31
89
}
32
90
}
33
- $ ( window ) . resize ( function ( ) {
91
+ $ ( window ) . resize ( function ( ) {
34
92
rs ( ) ;
35
93
} )
36
- rs ( ) ;
94
+ rs ( ) ;
0 commit comments