Changeset 493

Show
Ignore:
Timestamp:
2007-07-08 20:59:15 (2 years ago)
Author:
StefanoVerna
Message:

- joined remove() and restore() Filter methods code
- fixed UI refresh probles on filters preferences

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/chrome/content/preferences/filtersPane.js

    r489 r493  
    4545FilterTree.prototype = { 
    4646        reloadFilters: function() { 
    47                 Debug.dump("reloadFilters"); 
    4847                 
    4948                // something has changed.. 
     
    9594        selectFilter : function(filter) { 
    9695                // this is the reference to our filter 
    97                 Debug.dump("we wanna select " + filter.id); 
    9896                var selectedFilter = this._filters.filter(function(f){return f.id==filter.id});  
    9997                // if that old selected filter still exists.. 
     
    10199                        // let's select it 
    102100                        this._table.view.selection.select(this._filters.indexOf(selectedFilter[0])); 
    103                         Debug.dump("Let's select row "+ this._filters.indexOf(selectedFilter[0])); 
    104101                } 
    105102        }, 
     
    230227                this._filterTree = new FilterTree(this._table); 
    231228                this._table.view = this._filterTree; 
    232                  
    233                 this._table.view.selection.select(-1); 
     229                if (this._filterTree.rowCount >= 1) 
     230                       this._table.view.selection.select(0); 
    234231        }, 
    235232        getSelectedRow: function() { 
     
    244241        onTableSelectionChange: function() { 
    245242                var idx = this.getSelectedRow(); 
    246                 Debug.dump("onTableSelectionChange: " + idx); 
    247243                 
    248244                if (idx==-1) { 
     
    250246                        $("filterLabel", "filterTest").forEach(function(a){a.value=""}); 
    251247                        $("filterText", "filterImage", "filterIsRegex").forEach(function(a){a.checked=false}); 
    252                         $("restoreremovebutton").label = _('removebutton'); 
    253248                        return; 
    254249                } 
     
    271266        }, 
    272267        doCheckboxValidation : function() { 
    273                 Debug.dump("doCheckboxValidation"); 
    274268                 
    275269                var idx = this.getSelectedRow(); 
     
    311305        }, 
    312306        onIsRegexClick: function() { 
    313                 Debug.dump("onIsRegexClick"); 
    314307                 
    315308                var test = $("filterTest").value; 
     
    327320        }, 
    328321        onCheckboxChange : function() { 
    329                 Debug.dump("onCheckboxChange"); 
    330322                 
    331323                this.onFilterEdit(); 
     
    333325        }, 
    334326        isValidFilter : function() { 
    335                 Debug.dump("isValidFilter"); 
    336327                 
    337328                var filter = $("filterTest").value; 
     
    346337        }, 
    347338        onFilterEdit: function() { 
    348                 Debug.dump("onFilterEdit"); 
    349339                 
    350340                var idx = this.getSelectedRow(); 
     
    372362                        currentFilter.test = $("filterTest").value; 
    373363                         
    374                         Debug.dump("invalido riga e setto come filtro da salvare"); 
    375364                        this._table.treeBoxObject.invalidateRow(idx); 
    376365                        this._lastRowEdited = idx; 
     
    378367        }, 
    379368        onFinishedFilterEdit : function() { 
    380                 Debug.dump("onFinishedFilterEdit"); 
    381369                 
    382370                if (this._lastRowEdited != -1) { 
    383                         Debug.dump("salvo"); 
    384371                        this.getFilter(this._lastRowEdited).save(); 
    385372                        this._lastRowEdited = -1; 
     
    387374        }, 
    388375        createFilter: function() { 
    389                 Debug.dump("createFilter"); 
    390376                 
    391377                var id = DTA_FilterManager.create( 
     
    398384        }, 
    399385        removeFilter: function() { 
    400                 Debug.dump("remove"); 
    401386                var currentFilter = this.getFilter(this.getSelectedRow()); 
    402387                this._table.view.selection.select(-1); 
  • trunk/components/filterManager.js

    r489 r493  
    5858        LINK_FILTER: (1 << 0), 
    5959        IMAGE_FILTER: (1 << 1), 
    60          
    61         defaultFilters: { 
    62                 deffilter0: { 
    63                         test: "/.*/i", 
    64                         regex: true, 
    65                         type: this.LINK_FILTER + this.IMAGE_FILTER 
    66                 }, 
    67                 deffilter1: { 
    68                         test: "/\\.(?:z(?:ip|[0-9]{2})|r(?:ar|[0-9]{2})|jar|bz2|gz|tar|rpm)$/i", 
    69                         regex: true, 
    70                         type: this.LINK_FILTER 
    71                 }, 
    72                 deffilter2: { 
    73                         test: "/\\.(?:mpeg|rm|mpe|avi|mpg|mp4|mov|divx|asf|qt|wmv|ram|m1v|m2v|rv|vob|asx)$/i", 
    74                         regex: true, 
    75                         type: this.LINK_FILTER + this.IMAGE_FILTER 
    76                 }, 
    77                 deffilter3: { 
    78                         test: "/\\.(?:jp(?:e?g|e|2)|gif|png|tif|tiff|bmp|ico)$/i", 
    79                         regex: true, 
    80                         type: this.LINK_FILTER + this.IMAGE_FILTER 
    81                 }, 
    82                 deffilter4: { 
    83                         test: "/\\.(?:exe|msi|dmg|bin|xpi)$/i", 
    84                         regex: true, 
    85                         type: this.LINK_FILTER 
    86                 }, 
    87                 deffilter5: { 
    88                         test: "/\\.jp(e?g|e|2)$/i", 
    89                         regex: true, 
    90                         type: this.LINK_FILTER + this.IMAGE_FILTER 
    91                 } 
    92         }, 
    9360 
    9461        _modified: false, 
     
    230197                        this._label = localizedLabel; 
    231198                } 
     199                 
    232200                this._test = this.getMultiBytePref(this.pref('test')); 
    233201                this._active = this._prefs.getBoolPref(this.pref('active')); 
     
    256224        }, 
    257225 
     226        _reset: function F_reset() { 
     227                // BEWARE: 1.8, no implementation for resetBranch 
     228                var c = {value: 0}; 
     229                var prefs = this._prefs.getChildList(this._id, c); 
     230                for (var i = 0; i < c.value; ++i) { 
     231                        if (this._prefs.prefHasUserValue(prefs[i])) { 
     232                                this._prefs.clearUserPref(prefs[i]); 
     233                        } 
     234                } 
     235        }, 
     236 
    258237        // exported 
    259238        restore: function F_restore() { 
     
    261240                        throw new Components.Exception("only default filters can be restored!"); 
    262241                } 
    263                 this._label = this._localizedLabel; 
    264                 this._test = defaultFilters[this._id].test; 
    265                 this._type = defaultFilters[this._id].type; 
    266                 this._isRegex = defaultFilters[this._id].regex; 
    267                  
    268                 this.save(); 
     242                this._reset(); 
    269243        }, 
    270244 
    271245        // exported 
    272246        remove: function F_remove() { 
    273                 // BEWARE: 1.8, no implementation for resetBranch 
    274247                if (this._defFilter) { 
    275248                        throw new Components.Exception("default filters cannot be deleted!"); 
    276249                } 
    277                 var c = {value: 0}; 
    278                 var prefs = this._prefs.getChildList(this._id, c); 
    279                 for (var i = 0; i < c.value; ++i) { 
    280                         this._prefs.clearUserPref(prefs[i]); 
    281                 } 
     250                this._reset(); 
    282251        }, 
    283252