Reorganized everything into new structure
[webos-internals:adamrmcd-modifications.git] / browser / browser-swipe-delete-history.patch
1 diff --git a/usr/palm/applications/com.palm.app.browser/app/controllers/global_code.js b/usr/palm/applications/com.palm.app.browser/app/controllers/global_code.js
2 index b2c8848..133bc7a 100644
3 --- a/usr/palm/applications/com.palm.app.browser/app/controllers/global_code.js
4 +++ b/usr/palm/applications/com.palm.app.browser/app/controllers/global_code.js
5 @@ -1101,10 +1101,13 @@ HistoryAssistant.prototype.setup = function() {
6                 this.controller.setupWidget('historyList', {
7                         itemTemplate:'history/history-entry',
8                         listTemplate:'history/history-container',
9 -                       itemsCallback:this._itemsCallback.bind(this)
10 +                       itemsCallback:this._itemsCallback.bind(this),
11 +      swipeToDelete:true,
12 +      autoconfirmDelete:false
13                 });
14  
15                 this._onListSelectionHandler = this._onListSelection.bindAsEventListener(this);
16 +    this._onListDeleteHandler = this._onListDelete.bindAsEventListener(this);
17                 this._historyListWidget = this.controller.get('historyList');
18  
19                 var appMenuModel = {
20 @@ -1130,6 +1133,7 @@ HistoryAssistant.prototype.cleanup = function() {
21  HistoryAssistant.prototype.activate = function() {
22  
23         this._historyListWidget.addEventListener(Mojo.Event.listTap, this._onListSelectionHandler);
24 +       this._historyListWidget.addEventListener(Mojo.Event.listDelete, this._onListDeleteHandler);
25  
26         // On an activation for a re-render of the contents.
27         var len = this._historyListWidget.mojo.getLength();     
28 @@ -1139,6 +1143,7 @@ HistoryAssistant.prototype.activate = function() {
29  HistoryAssistant.prototype.deactivate = function() {
30  
31         Mojo.Event.stopListening(this._historyListWidget, Mojo.Event.listTap, this._onListSelectionHandler);
32 +       Mojo.Event.stopListening(this._historyListWidget, Mojo.Event.listDelete, this._onListDeleteHandler);
33  };
34  
35  /**
36 @@ -1218,6 +1223,10 @@ HistoryAssistant.prototype._onListSelection = function(event) {
37         });
38  };
39  
40 +HistoryAssistant.prototype._onListDelete = function(event) {
41 +       this.historyStore.deleteHistoryEntry(event.item.url, function() {}, function() {});
42 +};
43 +
44  /**
45   * handle a menu command.
46   */
47 @@ -7349,6 +7358,15 @@ function HistoryStore(options, onSuccess, onFailure) {
48         }
49  }
50  
51 +HistoryStore.prototype._deleteHistoryEntry = function(url, onSuccess, onFailure, transaction) {
52 +       this._executeSql(transaction, onSuccess, onFailure,
53 +               "DELETE FROM 'history' WHERE url = ?", [url] );
54 +};
55 +
56 +HistoryStore.prototype.deleteHistoryEntry = function(url, onSuccess, onFailure) {
57 +        this.database.transaction(this._deleteHistoryEntry.bind(this, url, onSuccess, onFailure));
58 +};
59 +
60  /** @private */
61  HistoryStore.prototype._addHistoryEntry = function(url, title, date, onSuccess, onFailure, transaction) {
62