manage: show "x" icon after #filters-stats to reset active filters
implements #286
This commit is contained in:
		
							parent
							
								
									579ffcc68d
								
							
						
					
					
						commit
						31941110e8
					
				| 
						 | 
				
			
			@ -166,7 +166,14 @@
 | 
			
		|||
  <h1 id="manage-heading" i18n-text="manageHeading"></h1>
 | 
			
		||||
 | 
			
		||||
  <details id="filters" data-pref="manage.filters.expanded">
 | 
			
		||||
    <summary><h2 i18n-text="manageFilters">: <span id="filters-stats"></span></h2></summary>
 | 
			
		||||
    <summary>
 | 
			
		||||
      <h2 i18n-text="manageFilters">: <span id="filters-stats"></span></h2>
 | 
			
		||||
      <svg id="reset-filters" class="svg-icon" viewBox="0 0 20 20">
 | 
			
		||||
        <title i18n-text="genericResetLabel"></title>
 | 
			
		||||
        <polygon points="16.2,5.5 14.5,3.8 10,8.3 5.5,3.8 3.8,5.5 8.3,10 3.8,14.5
 | 
			
		||||
                         5.5,16.2 10,11.7 14.5,16.2 16.2,14.5 11.7,10 "/>
 | 
			
		||||
      </svg>
 | 
			
		||||
    </summary>
 | 
			
		||||
 | 
			
		||||
    <div class="filter-selection">
 | 
			
		||||
      <label>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -76,6 +76,28 @@ onDOMready().then(onBackgroundReady).then(() => {
 | 
			
		|||
    }
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  $('#reset-filters').onclick = event => {
 | 
			
		||||
    event.preventDefault();
 | 
			
		||||
    if (!filtersSelector.hide) {
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
    for (const el of $$('#filters [data-filter]')) {
 | 
			
		||||
      let value;
 | 
			
		||||
      if (el.type === 'checkbox' && el.checked) {
 | 
			
		||||
        value = el.checked = false;
 | 
			
		||||
      } else if (el.value) {
 | 
			
		||||
        value = el.value = '';
 | 
			
		||||
      }
 | 
			
		||||
      if (value !== undefined) {
 | 
			
		||||
        el.lastValue = value;
 | 
			
		||||
        if (el.id in prefs.readOnlyValues) {
 | 
			
		||||
          prefs.set(el.id, false);
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    filterOnChange({forceRefilter: true});
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  // Adjust width after selects are visible
 | 
			
		||||
  prefs.subscribe(['manage.filters.expanded'], () => {
 | 
			
		||||
    const el = $('#filters');
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -793,6 +793,25 @@ input[id^="manage.newUI"] {
 | 
			
		|||
  top: -2px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#reset-filters {
 | 
			
		||||
  position: absolute;
 | 
			
		||||
  margin-top: 2px;
 | 
			
		||||
  fill: hsla(180, 50%, 27%, .5);
 | 
			
		||||
  width: 24px; /* widen the click area a bit */
 | 
			
		||||
  height: 20px;
 | 
			
		||||
  padding: 2px;
 | 
			
		||||
  box-sizing: border-box;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#reset-filters:hover {
 | 
			
		||||
  fill: hsla(180, 50%, 27%, 1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.firefox #reset-filters {
 | 
			
		||||
  margin-top: 4px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#filters:not(.active) #reset-filters,
 | 
			
		||||
#filters:not(.active) #filters-stats {
 | 
			
		||||
  display: none;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user