OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var Galore = Galore || {}; | 5 var Galore = Galore || {}; |
6 | 6 |
7 Galore.controller = { | 7 Galore.controller = { |
8 | 8 |
9 BUTTON_IMAGE_SIZE: 64, | 9 BUTTON_IMAGE_SIZE: 64, |
10 NOTIFICATION_ICON_SIZE: 80, | 10 NOTIFICATION_ICON_SIZE: 80, |
(...skipping 15 matching lines...) Expand all Loading... | |
26 listen_: function(event) { | 26 listen_: function(event) { |
27 var listener = this.event_.bind(this, event); | 27 var listener = this.event_.bind(this, event); |
28 chrome.experimental.notification[event].addListener(listener); | 28 chrome.experimental.notification[event].addListener(listener); |
29 }, | 29 }, |
30 | 30 |
31 /** @private */ | 31 /** @private */ |
32 prepare_: function() { | 32 prepare_: function() { |
33 Galore.NOTIFICATIONS.forEach(function (type) { | 33 Galore.NOTIFICATIONS.forEach(function (type) { |
34 type.notifications.forEach(function (options) { | 34 type.notifications.forEach(function (options) { |
35 this.view.addNotificationButton( | 35 this.view.addNotificationButton( |
36 type.type, | 36 type.templateType, |
miket_OOO
2013/02/06 18:42:34
I seem to have broken the @ replacement scheme you
dharcourt
2013/02/06 21:34:20
The icons shouldn't be broken, but the button imag
| |
37 type.name, | 37 type.name, |
38 this.replace_(options.iconUrl, this.BUTTON_IMAGE_SIZE), | 38 this.replace_(options.iconUrl, this.BUTTON_IMAGE_SIZE), |
39 this.notify_.bind(this, type.type, options)); | 39 this.notify_.bind(this, type.templateType, options)); |
40 }, this); | 40 }, this); |
41 }, this); | 41 }, this); |
42 }, | 42 }, |
43 | 43 |
44 /** @private */ | 44 /** @private */ |
45 id_: function() { | 45 id_: function() { |
46 this.counter += 1; | 46 this.counter += 1; |
47 return String(this.counter); | 47 return String(this.counter); |
48 }, | 48 }, |
49 | 49 |
(...skipping 10 matching lines...) Expand all Loading... | |
60 delete expanded.buttonOneTitle; | 60 delete expanded.buttonOneTitle; |
61 delete expanded.buttonTwoIconUrl; | 61 delete expanded.buttonTwoIconUrl; |
62 delete expanded.buttonTwoTitle; | 62 delete expanded.buttonTwoTitle; |
63 chrome.experimental.notification.show(expanded, function() {}); | 63 chrome.experimental.notification.show(expanded, function() {}); |
64 } | 64 } |
65 this.event_('create', id, 'priority: ' + priority); | 65 this.event_('create', id, 'priority: ' + priority); |
66 }, | 66 }, |
67 | 67 |
68 /** @private */ | 68 /** @private */ |
69 expand_: function(options, type, priority) { | 69 expand_: function(options, type, priority) { |
70 var expanded = {type: type, priority: priority}; | 70 var expanded = {templateType: type, priority: priority}; |
71 Object.keys(options).forEach(function (key) { | 71 Object.keys(options).forEach(function (key) { |
72 expanded[key] = this.replace_(options[key], this.NOTIFICATION_ICON_SIZE); | 72 expanded[key] = this.replace_(options[key], this.NOTIFICATION_ICON_SIZE); |
73 }, this); | 73 }, this); |
74 return expanded; | 74 return expanded; |
75 }, | 75 }, |
76 | 76 |
77 /** @private */ | 77 /** @private */ |
78 replace_: function(option, size) { | 78 replace_: function(option, size) { |
79 var replaced = option; | 79 var replaced = option; |
80 if (typeof replaced === 'string') { | 80 if (typeof replaced === 'string') { |
81 replaced = replaced.replace(/\$#/g, this.counter); | 81 replaced = replaced.replace(/\$#/g, this.counter); |
82 replaced = replaced.replace(/\$@/g, this.prefix); | 82 replaced = replaced.replace(/\$@/g, this.prefix); |
83 replaced = replaced.replace(/\$%/g, size); | 83 replaced = replaced.replace(/\$%/g, size); |
84 } | 84 } |
85 return replaced; | 85 return replaced; |
86 }, | 86 }, |
dharcourt
2013/02/06 21:34:20
replace_: function(option, size) {
var replace
| |
87 | 87 |
88 /** @private */ | 88 /** @private */ |
89 event_: function(event, id, var_args) { | 89 event_: function(event, id, var_args) { |
90 this.view.logEvent('Notification #' + id + ': ' + event + '(' + | 90 this.view.logEvent('Notification #' + id + ': ' + event + '(' + |
91 Array.prototype.slice.call(arguments, 2).join(', ') + | 91 Array.prototype.slice.call(arguments, 2).join(', ') + |
92 ')'); | 92 ')'); |
93 } | 93 } |
94 | 94 |
95 }; | 95 }; |
OLD | NEW |