Changeset 493
- Timestamp:
- 2007-07-08 20:59:15 (2 years ago)
- Files:
-
- trunk/chrome/content/preferences/filtersPane.js (modified) (15 diffs)
- trunk/components/filterManager.js (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/chrome/content/preferences/filtersPane.js
r489 r493 45 45 FilterTree.prototype = { 46 46 reloadFilters: function() { 47 Debug.dump("reloadFilters");48 47 49 48 // something has changed.. … … 95 94 selectFilter : function(filter) { 96 95 // this is the reference to our filter 97 Debug.dump("we wanna select " + filter.id);98 96 var selectedFilter = this._filters.filter(function(f){return f.id==filter.id}); 99 97 // if that old selected filter still exists.. … … 101 99 // let's select it 102 100 this._table.view.selection.select(this._filters.indexOf(selectedFilter[0])); 103 Debug.dump("Let's select row "+ this._filters.indexOf(selectedFilter[0]));104 101 } 105 102 }, … … 230 227 this._filterTree = new FilterTree(this._table); 231 228 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); 234 231 }, 235 232 getSelectedRow: function() { … … 244 241 onTableSelectionChange: function() { 245 242 var idx = this.getSelectedRow(); 246 Debug.dump("onTableSelectionChange: " + idx);247 243 248 244 if (idx==-1) { … … 250 246 $("filterLabel", "filterTest").forEach(function(a){a.value=""}); 251 247 $("filterText", "filterImage", "filterIsRegex").forEach(function(a){a.checked=false}); 252 $("restoreremovebutton").label = _('removebutton');253 248 return; 254 249 } … … 271 266 }, 272 267 doCheckboxValidation : function() { 273 Debug.dump("doCheckboxValidation");274 268 275 269 var idx = this.getSelectedRow(); … … 311 305 }, 312 306 onIsRegexClick: function() { 313 Debug.dump("onIsRegexClick");314 307 315 308 var test = $("filterTest").value; … … 327 320 }, 328 321 onCheckboxChange : function() { 329 Debug.dump("onCheckboxChange");330 322 331 323 this.onFilterEdit(); … … 333 325 }, 334 326 isValidFilter : function() { 335 Debug.dump("isValidFilter");336 327 337 328 var filter = $("filterTest").value; … … 346 337 }, 347 338 onFilterEdit: function() { 348 Debug.dump("onFilterEdit");349 339 350 340 var idx = this.getSelectedRow(); … … 372 362 currentFilter.test = $("filterTest").value; 373 363 374 Debug.dump("invalido riga e setto come filtro da salvare");375 364 this._table.treeBoxObject.invalidateRow(idx); 376 365 this._lastRowEdited = idx; … … 378 367 }, 379 368 onFinishedFilterEdit : function() { 380 Debug.dump("onFinishedFilterEdit");381 369 382 370 if (this._lastRowEdited != -1) { 383 Debug.dump("salvo");384 371 this.getFilter(this._lastRowEdited).save(); 385 372 this._lastRowEdited = -1; … … 387 374 }, 388 375 createFilter: function() { 389 Debug.dump("createFilter");390 376 391 377 var id = DTA_FilterManager.create( … … 398 384 }, 399 385 removeFilter: function() { 400 Debug.dump("remove");401 386 var currentFilter = this.getFilter(this.getSelectedRow()); 402 387 this._table.view.selection.select(-1); trunk/components/filterManager.js
r489 r493 58 58 LINK_FILTER: (1 << 0), 59 59 IMAGE_FILTER: (1 << 1), 60 61 defaultFilters: {62 deffilter0: {63 test: "/.*/i",64 regex: true,65 type: this.LINK_FILTER + this.IMAGE_FILTER66 },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_FILTER71 },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_FILTER76 },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_FILTER81 },82 deffilter4: {83 test: "/\\.(?:exe|msi|dmg|bin|xpi)$/i",84 regex: true,85 type: this.LINK_FILTER86 },87 deffilter5: {88 test: "/\\.jp(e?g|e|2)$/i",89 regex: true,90 type: this.LINK_FILTER + this.IMAGE_FILTER91 }92 },93 60 94 61 _modified: false, … … 230 197 this._label = localizedLabel; 231 198 } 199 232 200 this._test = this.getMultiBytePref(this.pref('test')); 233 201 this._active = this._prefs.getBoolPref(this.pref('active')); … … 256 224 }, 257 225 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 258 237 // exported 259 238 restore: function F_restore() { … … 261 240 throw new Components.Exception("only default filters can be restored!"); 262 241 } 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(); 269 243 }, 270 244 271 245 // exported 272 246 remove: function F_remove() { 273 // BEWARE: 1.8, no implementation for resetBranch274 247 if (this._defFilter) { 275 248 throw new Components.Exception("default filters cannot be deleted!"); 276 249 } 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(); 282 251 }, 283 252
