@@ -41,6 +41,9 @@ require.config({
4141
4242// Return an object for consts/methods used by most views
4343define ( [ 'jquery' , 'jqueryui' ] , function ( $ , jqueryui ) {
44+ // Terabyte cutoffs for download button tooltips and enabling
45+ let DOWNLOAD_SIZE_LIMIT = 3 ;
46+ let DOWNLOAD_SIZE_WARN = 2 ;
4447
4548 // Download block poll with cookie via StackOverflow:
4649 // https://stackoverflow.com/questions/1106377/detect-when-browser-receives-file-download
@@ -142,8 +145,10 @@ define(['jquery', 'jqueryui'], function($, jqueryui) {
142145 _hideFloatingMessage ( true ) ;
143146 } ) ;
144147
145-
146- // Enabled is equivalent to 'is there a filter' or 'is something in the cart'
148+ // type - string, ID selector subtype for the buttons and tooltips to adjust
149+ // enabled - bool, sets if the button is to be disabled or enabled
150+ // disk_size - size for determining size limit enabling and tooltip message, is assumed to be in TB
151+ // requires setting DOWNLOAD_SIZE_LIMIT and DOWNLOAD_SIZE_WARN
147152 function _updateDownloadBtns ( type , enabled , disk_size ) {
148153 let btn = $ ( `#download-${ type } -images` ) ;
149154 let btn_tip = $ ( `#download-${ type } -images-tooltips` ) ;
@@ -156,14 +161,14 @@ define(['jquery', 'jqueryui'], function($, jqueryui) {
156161 }
157162 if ( "showDirectoryPicker" in window ) {
158163 btn_and_tips . removeClass ( 'is-disabled download-all-instances download-size-warning' ) ;
159- if ( disk_size > 3 ) {
164+ if ( disk_size > DOWNLOAD_SIZE_LIMIT ) {
160165 btn_tip . addClass ( 'is-disabled' ) ;
161166 btn_tip . attr ( 'data-disabled-type' , "download-size-disabled" ) ;
162167 btn . attr ( "disabled" , "disabled" ) ;
163168 } else {
164169 btn . removeAttr ( "disabled" ) ;
165170 btn_tip . attr ( 'data-disabled-type' , "" ) ;
166- ( disk_size > 2 ) ? btn . addClass ( 'download-size-warning' ) : btn . addClass ( 'download-all-instances' ) ;
171+ ( disk_size > DOWNLOAD_SIZE_WARN ) ? btn . addClass ( 'download-size-warning' ) : btn . addClass ( 'download-all-instances' ) ;
167172 }
168173 } else {
169174 btn_tip . addClass ( 'is-disabled' ) ;
0 commit comments