OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
688 * @extends {WebInspector.Object} | 688 * @extends {WebInspector.Object} |
689 * @param {!Array.<{id: string, placeholder: (string|undefined), options: (!Arra y.<string>|undefined)}>} columns | 689 * @param {!Array.<{id: string, placeholder: (string|undefined), options: (!Arra y.<string>|undefined)}>} columns |
690 * @param {function(!Element, {id: string, placeholder: (string|undefined), opti ons: (!Array.<string>|undefined)}, ?string)} itemRenderer | 690 * @param {function(!Element, {id: string, placeholder: (string|undefined), opti ons: (!Array.<string>|undefined)}, ?string)} itemRenderer |
691 */ | 691 */ |
692 WebInspector.SettingsList = function(columns, itemRenderer) | 692 WebInspector.SettingsList = function(columns, itemRenderer) |
693 { | 693 { |
694 this.element = document.createElementWithClass("div", "settings-list"); | 694 this.element = document.createElementWithClass("div", "settings-list"); |
695 this.element.tabIndex = -1; | 695 this.element.tabIndex = -1; |
696 this._itemRenderer = itemRenderer; | 696 this._itemRenderer = itemRenderer; |
697 /** @type {!Object.<?string, !Element>} */ | 697 /** @type {!Object.<?string, !Element>} */ |
698 this._listItems = {}; | 698 this._listItems = { __proto__: null }; |
vsevik
2014/07/28 08:27:57
StringMap?
aandrey
2014/07/28 12:42:38
StringMap doesn't accept null as a key.
Also itemI
| |
699 /** @type {!Array.<?string>} */ | 699 /** @type {!Array.<?string>} */ |
700 this._ids = []; | 700 this._ids = []; |
701 this._columns = columns; | 701 this._columns = columns; |
702 } | 702 } |
703 | 703 |
704 WebInspector.SettingsList.Events = { | 704 WebInspector.SettingsList.Events = { |
705 Selected: "Selected", | 705 Selected: "Selected", |
706 Removed: "Removed", | 706 Removed: "Removed", |
707 DoubleClicked: "DoubleClicked", | 707 DoubleClicked: "DoubleClicked", |
708 } | 708 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
756 } | 756 } |
757 | 757 |
758 return listItem; | 758 return listItem; |
759 }, | 759 }, |
760 | 760 |
761 /** | 761 /** |
762 * @param {?string} id | 762 * @param {?string} id |
763 */ | 763 */ |
764 removeItem: function(id) | 764 removeItem: function(id) |
765 { | 765 { |
766 this._listItems[id].remove(); | 766 if (this._listItems[id]) |
767 this._listItems[id].remove(); | |
767 delete this._listItems[id]; | 768 delete this._listItems[id]; |
768 this._ids.remove(id); | 769 this._ids.remove(id); |
769 if (id === this._selectedId) { | 770 if (id === this._selectedId) { |
770 delete this._selectedId; | 771 delete this._selectedId; |
771 if (this._ids.length) | 772 if (this._ids.length) |
772 this.selectItem(this._ids[0]); | 773 this.selectItem(this._ids[0]); |
773 } | 774 } |
774 }, | 775 }, |
775 | 776 |
776 /** | 777 /** |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
888 * @return {!Element} | 889 * @return {!Element} |
889 */ | 890 */ |
890 addItem: function(itemId, beforeId) | 891 addItem: function(itemId, beforeId) |
891 { | 892 { |
892 var listItem = WebInspector.SettingsList.prototype.addItem.call(this, it emId, beforeId); | 893 var listItem = WebInspector.SettingsList.prototype.addItem.call(this, it emId, beforeId); |
893 listItem.classList.add("editable"); | 894 listItem.classList.add("editable"); |
894 return listItem; | 895 return listItem; |
895 }, | 896 }, |
896 | 897 |
897 /** | 898 /** |
899 * @param {?string} itemId | |
900 */ | |
901 refreshItem: function(itemId) | |
902 { | |
903 if (!itemId) | |
904 return; | |
905 var listItem = this._listItems[itemId]; | |
906 if (!listItem) | |
907 return; | |
908 for (var i = 0; i < this._columns.length; ++i) { | |
909 var column = this._columns[i]; | |
910 var columnId = column.id; | |
911 | |
912 var value = this._valuesProvider(itemId, columnId); | |
913 var textElement = this._textElements[itemId][columnId]; | |
914 textElement.textContent = value; | |
915 textElement.title = value; | |
916 | |
917 var editElement = this._editInputElements[itemId][columnId]; | |
918 this._setEditElementValue(editElement, value || ""); | |
919 } | |
920 }, | |
921 | |
922 /** | |
898 * @param {!Element} columnElement | 923 * @param {!Element} columnElement |
899 * @param {{id: string, placeholder: (string|undefined), options: (!Array.<s tring>|undefined)}} column | 924 * @param {{id: string, placeholder: (string|undefined), options: (!Array.<s tring>|undefined)}} column |
900 * @param {?string} itemId | 925 * @param {?string} itemId |
901 */ | 926 */ |
902 _renderColumn: function(columnElement, column, itemId) | 927 _renderColumn: function(columnElement, column, itemId) |
903 { | 928 { |
904 var columnId = column.id; | 929 var columnId = column.id; |
905 if (itemId === null) { | 930 if (itemId === null) { |
906 this._createEditElement(columnElement, column, itemId); | 931 this._createEditElement(columnElement, column, itemId); |
907 return; | 932 return; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1113 var columnId = columns[i]; | 1138 var columnId = columns[i]; |
1114 var editElement = this._addInputElements[columnId]; | 1139 var editElement = this._addInputElements[columnId]; |
1115 this._setEditElementValue(editElement, ""); | 1140 this._setEditElementValue(editElement, ""); |
1116 } | 1141 } |
1117 }, | 1142 }, |
1118 | 1143 |
1119 __proto__: WebInspector.SettingsList.prototype | 1144 __proto__: WebInspector.SettingsList.prototype |
1120 } | 1145 } |
1121 | 1146 |
1122 WebInspector._settingsController = new WebInspector.SettingsController(); | 1147 WebInspector._settingsController = new WebInspector.SettingsController(); |
OLD | NEW |