| LEFT | RIGHT | 
|    1 /* |    1 /* | 
|    2  * This file is part of Adblock Plus <https://adblockplus.org/>, |    2  * This file is part of Adblock Plus <https://adblockplus.org/>, | 
|    3  * Copyright (C) 2006-2016 Eyeo GmbH |    3  * Copyright (C) 2006-2016 Eyeo GmbH | 
|    4  * |    4  * | 
|    5  * Adblock Plus is free software: you can redistribute it and/or modify |    5  * Adblock Plus is free software: you can redistribute it and/or modify | 
|    6  * it under the terms of the GNU General Public License version 3 as |    6  * it under the terms of the GNU General Public License version 3 as | 
|    7  * published by the Free Software Foundation. |    7  * published by the Free Software Foundation. | 
|    8  * |    8  * | 
|    9  * Adblock Plus is distributed in the hope that it will be useful, |    9  * Adblock Plus is distributed in the hope that it will be useful, | 
|   10  * but WITHOUT ANY WARRANTY; without even the implied warranty of |   10  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   69   /** |   69   /** | 
|   70    * Closes the find bar. |   70    * Closes the find bar. | 
|   71    */ |   71    */ | 
|   72   close: function() |   72   close: function() | 
|   73   { |   73   { | 
|   74     E("findbar").hidden = true; |   74     E("findbar").hidden = true; | 
|   75   }, |   75   }, | 
|   76  |   76  | 
|   77   /** |   77   /** | 
|   78    * Performs a filter search. |   78    * Performs a filter search. | 
|   79    * @param {Integer} [direction]  search direction: -1 (backwards), 0 (forwards |   79    * @param {Integer} [direction] | 
|   80    *                  starting with current), 1 (forwards starting with next) |   80    *   See @link{FilterSearch#search} | 
 |   81    * @return {String} | 
 |   82    *   result status, one of "" (success), "notFound", "wrappedEnd", | 
 |   83    *   "wrappedStart" | 
|   81    */ |   84    */ | 
|   82   search: function(direction) |   85   _search: function(direction) | 
|   83   { |   86   { | 
|   84     let text = E("findbar-textbox").value.trim(); |   87     let text = E("findbar-textbox").value.trim(); | 
 |   88     if (!text) | 
 |   89       return ""; | 
 |   90  | 
|   85     let caseSensitive = E("findbar-case-sensitive").checked; |   91     let caseSensitive = E("findbar-case-sensitive").checked; | 
|   86  |   92  | 
|   87     if (typeof direction == "undefined") |   93     if (typeof direction == "undefined") | 
|   88       direction = (text == this.lastSearchString ? 1 : 0); |   94       direction = (text == this.lastSearchString ? 1 : 0); | 
|   89     this.lastSearchString = text; |   95     this.lastSearchString = text; | 
|   90  |   96  | 
|   91     function normalizeString(string) |   97     function normalizeString(string) | 
|   92     { |   98     { | 
|   93       return caseSensitive ? string : string.toLowerCase(); |   99       return caseSensitive ? string : string.toLowerCase(); | 
|   94     } |  100     } | 
|   95  |  101  | 
|   96     function findText(startIndex) |  102     function findText(startIndex) | 
|   97     { |  103     { | 
|   98       let list = E("filtersTree"); |  104       let list = E("filtersTree"); | 
|   99       let col = list.columns.getNamedColumn("col-filter"); |  105       let col = list.columns.getNamedColumn("col-filter"); | 
|  100       let count = list.view.rowCount; |  106       let count = list.view.rowCount; | 
|  101       for (let i = startIndex + direction; i >= 0 && i < count; i += (direction 
     || 1)) |  107       for (let i = startIndex + direction; i >= 0 && i < count; i += (direction 
     || 1)) | 
|  102       { |  108       { | 
|  103         let filter = normalizeString(list.view.getCellText(i, col)); |  109         let filter = normalizeString(list.view.getCellText(i, col)); | 
|  104         if (filter.indexOf(text) >= 0) |  110         if (filter.indexOf(text) >= 0) | 
|  105         { |  111         { | 
|  106           FilterView.selectRow(i); |  112           FilterView.selectRow(i); | 
|  107           return true; |  113           return true; | 
|  108         } |  114         } | 
|  109       } |  115       } | 
|  110       return false; |  116       return false; | 
|  111     } |  117     } | 
|  112  |  118  | 
|  113     function setStatus(currentStatus) |  | 
|  114     { |  | 
|  115       for (let status of ["wrappedStart", "wrappedEnd", "notFound"]) |  | 
|  116         E("findbar-status-" + status).hidden = status != currentStatus; |  | 
|  117       E("findbar-textbox").setAttribute("status", currentStatus); |  | 
|  118     } |  | 
|  119  |  | 
|  120     if (!text) |  | 
|  121       return setStatus(""); |  | 
|  122  |  | 
|  123     text = normalizeString(text); |  119     text = normalizeString(text); | 
|  124  |  120  | 
|  125     // First try to find the entry in the current list |  121     // First try to find the entry in the current list | 
|  126     if (findText(E("filtersTree").currentIndex)) |  122     if (findText(E("filtersTree").currentIndex)) | 
|  127       return setStatus(""); |  123       return ""; | 
|  128  |  124  | 
|  129     // Now go through the other subscriptions |  125     // Now go through the other subscriptions | 
|  130     let result = ""; |  126     let result = ""; | 
|  131     let subscriptions = FilterStorage.subscriptions.slice(); |  127     let subscriptions = FilterStorage.subscriptions.slice(); | 
|  132     subscriptions.sort((s1, s2) => (s1 instanceof SpecialSubscription) - (s2 ins
     tanceof SpecialSubscription)); |  128     subscriptions.sort((s1, s2) => (s1 instanceof SpecialSubscription) - (s2 ins
     tanceof SpecialSubscription)); | 
|  133     let current = subscriptions.indexOf(FilterView.subscription); |  129     let current = subscriptions.indexOf(FilterView.subscription); | 
|  134     direction = direction || 1; |  130     direction = direction || 1; | 
|  135     for (let i = current + direction; ; i+= direction) |  131     for (let i = current + direction; ; i+= direction) | 
|  136     { |  132     { | 
|  137       if (i < 0) |  133       if (i < 0) | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
|  163           E("tabs").selectedIndex = (subscription instanceof SpecialSubscription
      ? 1 : 0); |  159           E("tabs").selectedIndex = (subscription instanceof SpecialSubscription
      ? 1 : 0); | 
|  164           list.ensureElementIsVisible(node); |  160           list.ensureElementIsVisible(node); | 
|  165           list.selectItem(node); |  161           list.selectItem(node); | 
|  166           if (oldFocus) |  162           if (oldFocus) | 
|  167           { |  163           { | 
|  168             oldFocus.focus(); |  164             oldFocus.focus(); | 
|  169             Utils.runAsync(() => oldFocus.focus()); |  165             Utils.runAsync(() => oldFocus.focus()); | 
|  170           } |  166           } | 
|  171  |  167  | 
|  172           Utils.runAsync(() => findText(direction == 1 ? -1 :  subscription.filt
     ers.length)); |  168           Utils.runAsync(() => findText(direction == 1 ? -1 :  subscription.filt
     ers.length)); | 
|  173           return setStatus(result); |  169           return result; | 
|  174         } |  170         } | 
|  175       } |  171       } | 
|  176     } |  172     } | 
|  177  |  173  | 
|  178     return setStatus("notFound"); |  174     return "notFound"; | 
 |  175   }, | 
 |  176  | 
 |  177   /** | 
 |  178    * Performs a filter search and displays the resulting search status. | 
 |  179    * @param {Integer} [direction] | 
 |  180    *   search direction: -1 (backwards), 0 (forwards starting with current), | 
 |  181    *   1 (forwards starting with next) | 
 |  182    */ | 
 |  183   search: function(direction) | 
 |  184   { | 
 |  185     E("findbar").setAttribute("data-status", this._search(direction)); | 
|  179   } |  186   } | 
|  180 }; |  187 }; | 
|  181  |  188  | 
|  182 window.addEventListener("load", event => |  189 window.addEventListener("load", event => | 
|  183 { |  190 { | 
|  184   E("findbar").setAttribute("data-os", Services.appinfo.OS.toLowerCase()); |  191   E("findbar").setAttribute("data-os", Services.appinfo.OS.toLowerCase()); | 
|  185 }); |  192 }); | 
| LEFT | RIGHT |