@@ -17,9 +17,11 @@ function popupWithSizes(url, width, height) {
1717}
1818function openHelp ( tag ) {
1919 var url = '/treebase-web/help.html?helpTag=' + tag ;
20- var req = new Ajax . Request ( url , {
21- 'method' :'get' ,
22- 'onSuccess' :function ( response ) {
20+ $ . ajax ( {
21+ url : url ,
22+ method : 'GET' ,
23+ dataType : 'text' ,
24+ success : function ( response ) {
2325 top . consoleRef = window . open ( '' , 'help' ,
2426 'width=400,height=350'
2527 + ',menubar=no'
@@ -33,7 +35,7 @@ function openHelp(tag) {
3335 if ( top . consoleRef == null || top . consoleRef . closed ) {
3436 alert ( "Couldn't open window! The help system requires that popups are allowed for the TreeBASE site." ) ;
3537 }
36- top . consoleRef . document . writeln ( response . responseText ) ;
38+ top . consoleRef . document . writeln ( response ) ;
3739 top . consoleRef . document . close ( ) ;
3840 }
3941 } ) ;
@@ -95,81 +97,58 @@ TreeBASE.register(
9597
9698TreeBASE . register (
9799 function ( ) {
98- var inputs = $$ ( '.textCell' ) ;
99- for ( var i = 0 ; i < inputs . length ; i ++ ) {
100- if ( inputs [ i ] ) {
101- var currentColor = inputs [ i ] . style . borderColor ;
102- inputs [ i ] . onfocus = function ( ) {
103- this . style . borderColor = '#3863A4' ;
104- this . select ( ) ;
105- }
106- inputs [ i ] . onblur = function ( ) {
107- this . style . borderColor = currentColor ;
108- }
109- }
110- }
100+ $ ( '.textCell' ) . each ( function ( ) {
101+ var currentColor = $ ( this ) . css ( 'borderColor' ) ;
102+ $ ( this ) . on ( 'focus' , function ( ) {
103+ $ ( this ) . css ( 'borderColor' , '#3863A4' ) ;
104+ this . select ( ) ;
105+ } ) ;
106+ $ ( this ) . on ( 'blur' , function ( ) {
107+ $ ( this ) . css ( 'borderColor' , currentColor ) ;
108+ } ) ;
109+ } ) ;
111110 }
112111) ;
113112
114113TreeBASE . register (
115114 function ( ) {
116115 if ( document . getElementsByClassName ) {
117- var checkBoxCells = $$ ( '.checkBoxColumn' ) ;
118- var buttonContainer = $ ( 'buttonContainer' ) ;
119- if ( checkBoxCells . length > 0 && buttonContainer ) {
120- var checkButton = new Element ( 'input' , { 'type' :'button' , 'value' :'Check all' } ) ;
121- checkButton . observe ( 'click' , function ( ) {
122- for ( var i = 0 ; i < checkBoxCells . length ; i ++ ) {
123- if ( checkBoxCells [ i ] ) {
124- var checkBoxes = $ ( checkBoxCells [ i ] ) . select ( 'input' ) ;
125- for ( var j = 0 ; j < checkBoxes . length ; j ++ ) {
126- if ( checkBoxes [ j ] && checkBoxes [ j ] . type == 'checkbox' || checkBoxes [ j ] . type == 'radio' ) {
127- if ( ! checkBoxes [ j ] . disabled ) {
128- checkBoxes [ j ] . checked = 'checked' ;
129- }
130- }
131- }
132- }
133- }
116+ var $checkBoxCells = $ ( '.checkBoxColumn' ) ;
117+ var $buttonContainer = $ ( '#buttonContainer' ) ;
118+ if ( $checkBoxCells . length > 0 && $buttonContainer . length > 0 ) {
119+ var $checkButton = $ ( '<input>' , { type : 'button' , value : 'Check all' } ) ;
120+ $checkButton . on ( 'click' , function ( ) {
121+ $checkBoxCells . each ( function ( ) {
122+ $ ( this ) . find ( 'input' ) . each ( function ( ) {
123+ if ( ( this . type == 'checkbox' || this . type == 'radio' ) && ! this . disabled ) {
124+ $ ( this ) . prop ( 'checked' , true ) ;
125+ }
126+ } ) ;
127+ } ) ;
134128 } ) ;
135- var uncheckButton = new Element ( 'input' , { 'type' :'button' , 'value' :'Uncheck all' } ) ;
136- uncheckButton . observe ( 'click' , function ( ) {
137- for ( var i = 0 ; i < checkBoxCells . length ; i ++ ) {
138- if ( checkBoxCells [ i ] ) {
139- var checkBoxes = $ ( checkBoxCells [ i ] ) . select ( 'input' ) ;
140- for ( var j = 0 ; j < checkBoxes . length ; j ++ ) {
141- if ( checkBoxes [ j ] && checkBoxes [ j ] . type == 'checkbox' || checkBoxes [ j ] . type == 'radio' ) {
142- if ( ! checkBoxes [ j ] . disabled ) {
143- checkBoxes [ j ] . checked = null ;
144- }
145- }
146- }
147- }
148- }
129+ var $uncheckButton = $ ( '<input>' , { type : 'button' , value : 'Uncheck all' } ) ;
130+ $uncheckButton . on ( 'click' , function ( ) {
131+ $checkBoxCells . each ( function ( ) {
132+ $ ( this ) . find ( 'input' ) . each ( function ( ) {
133+ if ( ( this . type == 'checkbox' || this . type == 'radio' ) && ! this . disabled ) {
134+ $ ( this ) . prop ( 'checked' , false ) ;
135+ }
136+ } ) ;
137+ } ) ;
149138 } ) ;
150- var invertButton = new Element ( 'input' , { 'type' :'button' , 'value' :'Invert' } ) ;
151- invertButton . observe ( 'click' , function ( ) {
152- for ( var i = 0 ; i < checkBoxCells . length ; i ++ ) {
153- if ( checkBoxCells [ i ] ) {
154- var checkBoxes = $ ( checkBoxCells [ i ] ) . select ( 'input' ) ;
155- for ( var j = 0 ; j < checkBoxes . length ; j ++ ) {
156- if ( checkBoxes [ j ] && checkBoxes [ j ] . type == 'checkbox' || checkBoxes [ j ] . type == 'radio' ) {
157- if ( ! checkBoxes [ j ] . disabled ) {
158- if ( checkBoxes [ j ] . checked ) {
159- checkBoxes [ j ] . checked = null ;
160- }
161- else {
162- checkBoxes [ j ] . checked = 'checked' ;
163- }
164- }
165- }
166- }
167- }
168- }
139+ var $invertButton = $ ( '<input>' , { type : 'button' , value : 'Invert' } ) ;
140+ $invertButton . on ( 'click' , function ( ) {
141+ $checkBoxCells . each ( function ( ) {
142+ $ ( this ) . find ( 'input' ) . each ( function ( ) {
143+ if ( ( this . type == 'checkbox' || this . type == 'radio' ) && ! this . disabled ) {
144+ $ ( this ) . prop ( 'checked' , ! $ ( this ) . prop ( 'checked' ) ) ;
145+ }
146+ } ) ;
147+ } ) ;
169148 } ) ;
170- buttonContainer . insertBefore ( invertButton , buttonContainer . firstChild ) ;
171- buttonContainer . insertBefore ( uncheckButton , buttonContainer . firstChild ) ;
172- buttonContainer . insertBefore ( checkButton , buttonContainer . firstChild ) ;
149+ $ buttonContainer. prepend ( $ invertButton) ;
150+ $ buttonContainer. prepend ( $ uncheckButton) ;
151+ $ buttonContainer. prepend ( $ checkButton) ;
173152 }
174153 }
175154 }
@@ -178,15 +157,11 @@ TreeBASE.register(
178157/* add a tooltip for the help buttons */
179158TreeBASE . register (
180159 function ( ) {
181- var links = document . getElementsByTagName ( 'a' ) ;
182- for ( var i = 0 ; i < links . length ; i ++ ) {
183- var link = $ ( links [ i ] ) ;
184- if ( link . hasClassName ( 'openHelp' ) ) {
185- if ( link . title == null || link . title == '' ) {
186- link . title = 'Open help popup' ;
187- }
160+ $ ( 'a.openHelp' ) . each ( function ( ) {
161+ if ( ! this . title || this . title == '' ) {
162+ this . title = 'Open help popup' ;
188163 }
189- }
164+ } ) ;
190165 }
191166) ;
192167
@@ -203,28 +178,28 @@ TreeBASE.register(
203178 </div>
204179*/
205180TreeBASE . collapseExpand = function ( id , displayAs , link ) {
206- var objToExpand = $ ( id ) ;
207- var img = $ ( link ) . firstDescendant ( ) ;
208- if ( img == null ) {
209- img = document . createElement ( img ) ;
210- link . appendChild ( img ) ;
181+ var $ objToExpand = $ ( '#' + id ) ;
182+ var $ img = $ ( link ) . children ( ) . first ( ) ;
183+ if ( $ img. length == 0 ) {
184+ $ img = $ ( '< img>' ) ;
185+ $ ( link ) . append ( $ img) ;
211186 }
212- if ( objToExpand . style . display == 'none' ) {
213- objToExpand . style . display = displayAs ;
214- img . src = ' /treebase-web/images/minus.gif';
215- img . alt = ' collapse'
187+ if ( $ objToExpand. css ( ' display' ) == 'none' ) {
188+ $ objToExpand. css ( ' display' , displayAs ) ;
189+ $ img. attr ( ' src' , ' /treebase-web/images/minus.gif') ;
190+ $ img. attr ( ' alt' , ' collapse') ;
216191 link . title = 'collapse' ;
217192 }
218193 else {
219- objToExpand . style . display = 'none' ;
220- img . src = ' /treebase-web/images/plus.gif';
221- img . alt = ' expand';
194+ $ objToExpand. css ( ' display' , 'none' ) ;
195+ $ img. attr ( ' src' , ' /treebase-web/images/plus.gif') ;
196+ $ img. attr ( ' alt' , ' expand') ;
222197 link . title = 'expand' ;
223198 }
224199}
225200//expands what a user types in the text box into a PhyloWS query
226201TreeBASE . expandQuery = function ( ) {
227- var query = $ ( 'query' ) . value ;
202+ var query = $ ( '# query' ) . val ( ) ;
228203 var split = TreeBASE . splitWords ( query ) ;
229204 var terms = new Array ( ) ;
230205 for ( var i = 0 ; i < split . length ; i ++ ) {
@@ -235,10 +210,10 @@ TreeBASE.expandQuery = function () {
235210 }
236211 }
237212 var joiner = ' or ' ;
238- if ( $ ( 'all' ) . checked ) {
213+ if ( $ ( '# all' ) . prop ( ' checked' ) ) {
239214 joiner = ' and ' ;
240215 }
241- $ ( 'expanded' ) . value = terms . join ( joiner ) ;
216+ $ ( '# expanded' ) . val ( terms . join ( joiner ) ) ;
242217 return false ;
243218} ;
244219
0 commit comments