@@ -58,62 +58,44 @@ require([
5858
5959// Return an object for consts/methods used by most views
6060define ( [ 'jquery' , 'base' ] , function ( $ , base ) {
61-
62-
6361 var ANONYMOUS_FILTERS = { } ;
6462 var showFilters = [ ] ;
6563 var first_filter_load = true ;
6664
67- const update_bq_filters = function ( ) {
68- let filters = parseFilterObj ( ) ;
69- if ( Object . keys ( filters ) . length <= 0 ) {
70- $ ( '#export-manifest' ) . attr ( "disabled" , "disabled" ) ;
71- $ ( '.bq-string-copy' ) . attr ( "disabled" , "disabled" ) ;
72- $ ( '.bq-string-display' ) . attr ( "disabled" , "disabled" ) ;
73- $ ( '.bq-string-display' ) . attr ( "title" , "Select a filter to enable this feature." ) ;
74- $ ( '.bq-string' ) . html ( "" ) ;
75- $ ( '#export-manifest-form input[name="filters"]' ) . val ( "" ) ;
76- } else {
77- $ ( '#export-manifest' ) . removeAttr ( "disabled" ) ;
78- $ ( '.bq-string-copy' ) . removeAttr ( "disabled" ) ;
79- $ ( '.bq-string-display' ) . removeAttr ( "disabled" ) ;
80- $ ( '.bq-string-display' ) . attr ( "title" , "Click to display this filter as a BQ string." ) ;
81- $ ( '.bq-string-display' ) . attr ( 'filter-params' , JSON . stringify ( filters ) ) ;
82- $ ( '.bq-string-copy' ) . attr ( 'filter-params' , JSON . stringify ( filters ) ) ;
83- $ ( '#export-manifest-form input[name="filters"]' ) . val ( JSON . stringify ( filters ) ) ;
84- }
85- } ;
86-
87- var update_filter_url = function ( ) {
65+ const update_filter_controls = function ( ) {
8866 let filters = parseFilterObj ( ) ;
8967 if ( Object . keys ( filters ) . length <= 0 ) {
9068 $ ( '.filter-placeholder' ) . show ( ) ;
91- $ ( '.get-filter-uri' ) . attr ( "disabled" , "disabled" ) ;
92- $ ( '#export-manifest' ) . attr ( "disabled" , "disabled" ) ;
93- $ ( '#export-manifest' ) . attr ( "data-no-filters" , "true" ) ;
94- if ( ! $ ( '#export-manifest' ) . attr ( 'data-pending-manifest' ) ) {
95- $ ( '#export-manifest' ) . attr ( "title" , "Select a filter to enable this feature." ) ;
96- }
97- $ ( '.get-filter-uri' ) . attr ( "title" , "Select a filter to enable this feature." ) ;
98- $ ( '.filter-url' ) . html ( "" ) ;
99- $ ( '.copy-url' ) . removeAttr ( "content" ) ;
100- $ ( '.copy-url' ) . attr ( "disabled" , "disabled" ) ;
69+ $ ( '.filter-activated-controls' ) . each ( function ( ) {
70+ if ( ! $ ( this ) . attr ( 'data-pending-manifest' ) ) {
71+ $ ( this ) . attr ( "disabled" , "disabled" ) ;
72+ $ ( this ) . attr ( "title" , "Select a filter to enable this feature." ) ;
73+ }
74+ } )
75+ $ ( '.bq-string, .citations-list' ) . html ( "" ) ;
76+ $ ( '.bq-string-copy, .citations-button' ) . attr ( 'filter-params' , "" ) ;
10177 $ ( '.hide-filter-uri' ) . triggerHandler ( 'click' ) ;
10278 $ ( '.url-too-long' ) . hide ( ) ;
10379 $ ( '#export-manifest-form' ) . attr (
10480 'action' ,
10581 $ ( '#export-manifest-form' ) . data ( 'uri-base' )
10682 ) ;
83+ $ ( '.filter-url' ) . html ( "" ) ;
84+ $ ( '.copy-url' ) . removeAttr ( "content" ) ;
85+ $ ( '#export-manifest' ) . attr ( "data-no-filters" , "true" ) ;
86+ $ ( '#export-manifest-form input[name="filters"]' ) . val ( "" ) ;
10787 } else {
10888 $ ( '.filter-placeholder' ) . hide ( ) ;
109- $ ( '.get-filter-uri' ) . removeAttr ( "disabled" ) ;
89+ $ ( '.filter-activated-controls' ) . each ( ( function ( ) {
90+ if ( ! $ ( this ) . attr ( 'data-pending-manifest' ) ) {
91+ $ ( this ) . attr ( "title" , $ ( this ) . attr ( "data-default-title" ) ) ;
92+ $ ( this ) . removeAttr ( "disabled" ) ;
93+ }
94+ } ) ) ;
95+ $ ( '.bq-string-display' ) . attr ( 'filter-params' , JSON . stringify ( filters ) ) ;
96+ $ ( '.bq-string-copy, .citations-button' ) . attr ( 'filter-params' , JSON . stringify ( filters ) ) ;
97+ $ ( '#export-manifest-form input[name="filters"]' ) . val ( JSON . stringify ( filters ) ) ;
11098 $ ( '#export-manifest' ) . removeAttr ( "data-no-filters" ) ;
111- if ( ! $ ( '#export-manifest' ) . attr ( 'data-pending-manifest' ) ) {
112- $ ( '#export-manifest' ) . removeAttr ( "disabled" ) ;
113- $ ( '#export-manifest' ) . attr ( "title" , "Export these search results as a manifest for downloading." ) ;
114- }
115- $ ( '.copy-url' ) . removeAttr ( "disabled" ) ;
116- $ ( '.get-filter-uri' ) . attr ( "title" , "Click to display this filter set's query URL." ) ;
11799 let url = BASE_URL + "/explore/filters/?" ;
118100 let encoded_filters = [ ]
119101 for ( let i in filters ) {
@@ -675,8 +657,7 @@ define(['jquery', 'base'], function($, base) {
675657
676658 if ( mkFilt ) {
677659 isFiltered = mkFiltText ( ) ;
678- update_filter_url ( ) ;
679- update_bq_filters ( ) ;
660+ update_filter_controls ( ) ;
680661 if ( window . location . href . search ( / \/ f i l t e r s \/ / g) >= 0 ) {
681662 if ( ! first_filter_load ) {
682663 window . history . pushState ( { } , '' , window . location . origin + "/explore/" )
@@ -1230,8 +1211,7 @@ define(['jquery', 'base'], function($, base) {
12301211
12311212
12321213 return {
1233- update_bq_filters : update_bq_filters ,
1234- update_filter_url : update_filter_url ,
1214+ update_filter_controls : update_filter_controls ,
12351215 updateCollectionTotals : updateCollectionTotals ,
12361216 parseFilterObj : parseFilterObj ,
12371217 findFilterCats : findFilterCats ,
0 commit comments