6 new, 4 modified for 1.3.5
[webos-internals:djcin7s-modifications.git] / app-catalog / app-catalog-hide-app-vendors.patch
1 Index: /usr/palm/applications/com.palm.app.findapps/app/controllers/app-assistant.js
2 ===================================================================
3 --- .orig/usr/palm/applications/com.palm.app.findapps/app/controllers/app-assistant.js
4 +++ /usr/palm/applications/com.palm.app.findapps/app/controllers/app-assistant.js
5 @@ -107,6 +107,10 @@
6                 var self = this;
7                 var menu = new Weave.Utilities.AppMenu()
8                         .addEdit()
9 +                       .addItem($L("Hide App Vendors"),
10 +                                function () {
11 +                                        self.controller.pushScene("hide");
12 +                                })
13                         .addItem($L('Preferences & Accounts'), 
14                                 function()
15                                 {
16 Index: /usr/palm/applications/com.palm.app.findapps/app/controllers/hide-assistant.js
17 ===================================================================
18 --- .orig/usr/palm/applications/com.palm.app.findapps/app/controllers/hide-assistant.js
19 +++ /usr/palm/applications/com.palm.app.findapps/app/controllers/hide-assistant.js
20 @@ -0,0 +1,46 @@
21 +/*jslint browser: true, eqeqeq: true, undef: true */
22 +/******************************************************************************
23 +Lines above are for jslint, the JavaScript verifier.
24 +http://www.jslint.com/
25 +******************************************************************************/
26 +
27 +var HideAssistant = Class.create({
28 +       setup: function () {
29 +               this._addedPrefs = 
30 +                       this.controller.document.body.hasClassName("prefs") || 
31 +                       this.controller.document.body.addClassName("prefs");
32 +               this.hideListAttributes = {
33 +                       multiline: true,
34 +                       autoFocus: true,
35 +                       changeOnKeyPress: true,
36 +                       textCase: Mojo.Widget.steModeLowerCase
37 +               };
38 +               this.hideListModel = {
39 +                       value: HideList.items.join("\n")
40 +               };
41 +               this.controller.setupWidget("hide-list-text-field",
42 +                                           this.hideListAttributes,
43 +                                           this.hideListModel);
44 +
45 +               this.updateHandler = this.update.bindAsEventListener(this);
46 +               this.controller.listen("hide-list-text-field",
47 +                                      Mojo.Event.propertyChange,
48 +                                      this.updateHandler);
49 +
50 +       },
51 +       update: function () {
52 +               HideList.setFromString(this.hideListModel.value);
53 +       },
54 +       cleanup: function () {
55 +               Mojo.Log.error("CLEANUP");
56 +               this._addedPrefs !== true &&
57 +                       this.controller.document.body.removeClassName("prefs");
58 +               this.controller.stopListening("hide-list-text-field",
59 +                                             Mojo.Event.propertyChange,
60 +                                             this.updateHandler);
61 +       },
62 +       deactivate: function () {
63 +               Mojo.Log.error("DEACTIVATE");
64 +               this.update();
65 +       },
66 +});
67 Index: /usr/palm/applications/com.palm.app.findapps/app/controllers/search-assistant.js
68 ===================================================================
69 --- .orig/usr/palm/applications/com.palm.app.findapps/app/controllers/search-assistant.js
70 +++ /usr/palm/applications/com.palm.app.findapps/app/controllers/search-assistant.js
71 @@ -29,6 +29,8 @@
72                 this._searchApps = this._searchApps.bindAsEventListener(this);
73                 this._formatAppDivider = this._formatAppDivider.bind(this);
74  
75 +               HideList.updateTests();
76 +
77                 // Set up the attributes & prepare this widget for lazy loading of data
78                 this._searchListAttr =
79                 {
80 @@ -183,6 +185,8 @@
81                 this._appsSearch.button.addEventListener(Mojo.Event.tap, this._searchApps);
82                 // Refocus search field
83                 this._appsSearch.widget.mojo.focus();
84 +
85 +               HideList.updateTests();
86         },
87  
88         deactivate: function() 
89 @@ -339,6 +343,24 @@
90                 model.formattedUpdate = (this._getApplicationInstalledState(model) == 'update' ? 'has-update' : '');
91                 // HACK - author fixup
92                 model.author = (model.author ? model.author : ' ');
93 +
94 +               var id = model.publicApplicationId;
95 +               var author = model.author;
96 +
97 +               model.unwanted = false;
98 +               if (HideList.test(id) || HideList.test(author)) {
99 +                       model.unwanted = true;
100 +               }
101 +               model.unwantedCSSClass = model.unwanted ? 
102 +                       (HideList.turdMode ? "turd" : "unwanted") : "";
103 +               if (model.unwanted) {
104 +                       if (HideList.turdMode) {
105 +                               model.appIcon = "http://webonastick.com/webos/images/turd-48x48.png";
106 +                       }
107 +                       else {
108 +                               model.appIcon = null;
109 +                       }
110 +               }
111         },
112         
113         _formatAppDivider: function(model)
114 Index: /usr/palm/applications/com.palm.app.findapps/app/model/hide-list.js
115 ===================================================================
116 --- .orig/usr/palm/applications/com.palm.app.findapps/app/model/hide-list.js
117 +++ /usr/palm/applications/com.palm.app.findapps/app/model/hide-list.js
118 @@ -0,0 +1,101 @@
119 +/*jslint browser: true, eqeqeq: true, undef: true */
120 +/*global Mojo */
121 +/******************************************************************************
122 +Lines above are for jslint, the JavaScript verifier.
123 +http://www.jslint.com/
124 +******************************************************************************/
125 +
126 +if (!String.prototype.isNotBlank) {
127 +       String.prototype.isNotBlank = function () {
128 +               return (/\S/).test(this);
129 +       };
130 +}
131 +if (!String.prototype.trim) {
132 +       String.prototype.trim = function () {
133 +               return this.replace(/^\s+/, "").replace(/\s+$/, "");
134 +       };
135 +}
136 +if (!String.prototype.normalizeSpace) {
137 +       String.prototype.normalizeSpace = function () {
138 +               return this.trim().replace(/\s+/g, " ");
139 +       };
140 +}
141 +
142 +var HideList = {
143 +       isNotBlank: function (s) {
144 +               return s.isNotBlank();
145 +       },
146 +       normalizeSpace: function (s) {
147 +               return s.normalizeSpace();
148 +       },
149 +       
150 +       initialize: function () {
151 +               this.cookie = new Mojo.Model.Cookie("appCatalogHideList");
152 +               this.items = this.cookie.get() || [];
153 +       },
154 +       update: function () {
155 +               this.cookie.put(this.items);
156 +       },
157 +       setFromString: function (s) {
158 +               this.items = (s.split("\n").
159 +                             filter(this.isNotBlank, this).
160 +                             map(this.normalizeSpace, this));
161 +               this.update();
162 +       },
163 +       updateTests: function () {
164 +               var i;
165 +               this.tests = [];
166 +               this.turdMode = false;
167 +               for (i = 0; i < this.items.length; ++i) {
168 +                       var item = this.items[i];
169 +                       if (item === "*turd*") {
170 +                               this.turdMode = true;
171 +                       }
172 +                       else {
173 +                               this.tests.push(this.stringToTest(item));
174 +                       }
175 +               }
176 +       },
177 +       stringToTest: function (s) {
178 +               var f;
179 +               s = s.trim();
180 +               if (/^\/(.*)\/$/.test(s)) {
181 +                       s = RegExp.$1;
182 +                       var rx = new RegExp(s, 'i');
183 +                       f = function (vendorName) {
184 +                               if (vendorName === undefined ||
185 +                                   vendorName === null) {
186 +                                       return false;
187 +                               }
188 +                               return rx.test(vendorName);
189 +                       };
190 +                       return f;
191 +               }
192 +               else {
193 +                       s = s.normalizeSpace().toLowerCase();
194 +                       f = function (vendorName) {
195 +                               if (vendorName === undefined || 
196 +                                   vendorName === null) {
197 +                                       return false;
198 +                               }
199 +                               return (vendorName.
200 +                                       normalizeSpace().toLowerCase().
201 +                                       indexOf(s) !== -1);
202 +                       };
203 +                       return f;
204 +               }
205 +       },
206 +       test: function (vendorName) {
207 +               var i;
208 +               for (i = 0; i < this.tests.length; ++i) {
209 +                       var test = this.tests[i];
210 +                       if (test && test(vendorName)) {
211 +                               return true;
212 +                       }
213 +               }
214 +               return false;
215 +       }
216 +};
217 +
218 +HideList.initialize();
219 +
220 Index: /usr/palm/applications/com.palm.app.findapps/app/views/hide/hide-scene.html
221 ===================================================================
222 --- .orig/usr/palm/applications/com.palm.app.findapps/app/views/hide/hide-scene.html
223 +++ /usr/palm/applications/com.palm.app.findapps/app/views/hide/hide-scene.html
224 @@ -0,0 +1,19 @@
225 +<div class="palm-scene hide-scene">
226 +       <div class="palm-page-header multi-line">
227 +               <div class="palm-page-header-wrapper">
228 +                       <div class="title left">Hide App Vendors</div>
229 +               </div>
230 +       </div>
231 +
232 +       <p>Type the partial or complete names of app vendors whose
233 +       applications you do not wish to see, each on a separate line.</p>
234 +
235 +       <p>To use a regular expression, start and end with a slash.</p>
236 +
237 +       <p><b>To effect your changes, you will need to perform a new
238 +       search.</b></p>
239 +
240 +       <div class="hide-list-text-field" id="hide-list-text-field"
241 +                x-mojo-element="TextField"></div>
242 +
243 +</div>
244 Index: /usr/palm/applications/com.palm.app.findapps/app/views/search/search-appsummary.html
245 ===================================================================
246 --- .orig/usr/palm/applications/com.palm.app.findapps/app/views/search/search-appsummary.html
247 +++ /usr/palm/applications/com.palm.app.findapps/app/views/search/search-appsummary.html
248 @@ -1,5 +1,5 @@
249 -<div class="palm-row" x-mojo-tap-highlight='momentary'>
250 -       <div class="palm-row-wrapper padded">
251 +<div class="palm-row #{unwantedCSSClass}" x-mojo-tap-highlight='momentary'>
252 +       <div class="palm-row-wrapper padded #{unwantedCSSClass}">
253                 <div class="icon left search-result-app-icon #{formattedUpdate}">
254                         <div class="loadingicon" style='background: url(images/loading.png) center center no-repeat;width:44px;height:44px'></div>
255                         <div class="update-badge"></div>
256 Index: /usr/palm/applications/com.palm.app.findapps/sources.json
257 ===================================================================
258 --- .orig/usr/palm/applications/com.palm.app.findapps/sources.json
259 +++ /usr/palm/applications/com.palm.app.findapps/sources.json
260 @@ -66,6 +66,9 @@
261      "source": "app\/controllers\/change-email-address-assistant.js"
262    },
263    {
264 +    "source": "app\/model\/hide-list.js"
265 +  },
266 +  {
267      "source": "app\/model\/profile-model.js"
268    },
269    {
270 @@ -99,6 +102,10 @@
271         "source": "\/usr\/lib\/luna\/luna-network\/ConnectionWidget.js"
272    },
273        {
274 +    "source": "app\/controllers\/hide-assistant.js",
275 +    "scenes": "hide"
276 +  },
277 +      {
278          "source": "app\/controllers\/prefs-assistant.js",
279          "scenes": "prefs"
280      },
281 Index: /usr/palm/applications/com.palm.app.findapps/stylesheets/appcatalog.css
282 ===================================================================
283 --- .orig/usr/palm/applications/com.palm.app.findapps/stylesheets/appcatalog.css
284 +++ /usr/palm/applications/com.palm.app.findapps/stylesheets/appcatalog.css
285 @@ -1562,5 +1562,38 @@
286         border-width: 0px 7px 0px 1px;
287         -webkit-border-image: url(../images/update-progress-blue.png) 3 7 3 1;
288  /*     -webkit-box-sizing: border-box;   */
289 -}      
290 -                       
291 \ No newline at end of file
292 +}
293 +
294 +.palm-row.unwanted .palm-row-wrapper {
295 +       opacity: 0.5;
296 +}
297 +.palm-row.unwanted .palm-row-wrapper .title {
298 +       color: #224455;
299 +}
300 +.palm-row.unwanted .palm-row-wrapper .subtitle {
301 +       color: #224455;
302 +}
303 +.palm-row.unwanted .palm-row-wrapper .search-result-price {
304 +       color: #224455;
305 +}
306 +
307 +.palm-row.turd .palm-row-wrapper .title {
308 +       color: #995511; /* shade of brown matching the icon */
309 +}
310 +.palm-row.turd .palm-row-wrapper .subtitle {
311 +       color: #995511;
312 +}
313 +.palm-row.turd .palm-row-wrapper .search-result-price {
314 +       color: #995511;
315 +}
316 +.palm-row.turd .palm-row-wrapper .search-result-rating {
317 +       opacity: 0.5;
318 +}
319 +
320 +.hide-scene p {
321 +       margin: 0;
322 +       padding: 0.5em 0.5em;
323 +}
324 +.hide-scene .hide-list-text-field {
325 +       background-color: white;
326 +}