Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 cr.define('options', function() { | |
| 6 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; | |
| 7 /** @const */ var DeletableItem = options.DeletableItem; | |
| 8 /** @const */ var DeletableItemList = options.DeletableItemList; | |
| 9 | |
| 10 /** | |
| 11 * @constructor | |
| 12 * @extends {DeletableItem} | |
| 13 */ | |
| 14 function ServiceListItem(service) { | |
| 15 var el = cr.doc.createElement('div'); | |
| 16 el.service_ = service; | |
| 17 el.__proto__ = ServiceListItem.prototype; | |
| 18 el.decorate(); | |
| 19 return el; | |
| 20 } | |
| 21 | |
| 22 function createChildDiv(parent, clazz, value) { | |
| 23 var element = document.createElement('div'); | |
| 24 parent.appendChild(element); | |
| 25 element.className = clazz; | |
| 26 if (value) { | |
| 27 element.textContent = value; | |
| 28 } | |
| 29 return element; | |
| 30 } | |
| 31 | |
| 32 ServiceListItem.prototype = { | |
| 33 __proto__: DeletableItem.prototype, | |
| 34 | |
| 35 decorate: function() { | |
| 36 DeletableItem.prototype.decorate.call(this); | |
| 37 | |
| 38 var rowElement = createChildDiv(this.contentElement_, 'intents-row', ''); | |
| 39 | |
| 40 // add favicon for the service URL | |
|
csilv
2012/08/09 18:18:04
this this a TODO...?
| |
| 41 createChildDiv(rowElement, 'intents-preferred-service', | |
| 42 this.service_[0]); | |
| 43 createChildDiv(rowElement, 'intents-service-matching-criteria', | |
| 44 this.service_[1]); | |
| 45 }, | |
| 46 }; | |
| 47 | |
| 48 var ServiceList = cr.ui.define('list'); | |
| 49 | |
| 50 ServiceList.prototype = { | |
| 51 __proto__: DeletableItemList.prototype, | |
| 52 | |
| 53 /** @inheritDoc */ | |
| 54 decorate: function() { | |
| 55 DeletableItemList.prototype.decorate.call(this); | |
| 56 this.autoExpands_ = true; | |
| 57 }, | |
| 58 | |
| 59 /** @inheritDoc */ | |
| 60 createItem: function(service) { | |
| 61 return new ServiceListItem(service); | |
| 62 }, | |
| 63 | |
| 64 /** @inheritDoc */ | |
| 65 deleteItemAtIndex: function(index) { | |
| 66 var service = this.dataModel.item(index); | |
| 67 chrome.send('removeServiceDefaults', service); | |
| 68 }, | |
| 69 | |
| 70 setServices: function(services) { | |
| 71 this.dataModel = new ArrayDataModel(services); | |
| 72 } | |
| 73 }; | |
| 74 | |
| 75 return { | |
| 76 ServiceList: ServiceList | |
| 77 }; | |
| 78 }); | |
| OLD | NEW |