| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * | 10 * |
| (...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 return this._uiSourceCode; | 936 return this._uiSourceCode; |
| 937 } | 937 } |
| 938 | 938 |
| 939 /** | 939 /** |
| 940 * @override | 940 * @override |
| 941 */ | 941 */ |
| 942 onattach() { | 942 onattach() { |
| 943 this.listItemElement.draggable = true; | 943 this.listItemElement.draggable = true; |
| 944 this.listItemElement.addEventListener('click', this._onclick.bind(this), fal
se); | 944 this.listItemElement.addEventListener('click', this._onclick.bind(this), fal
se); |
| 945 this.listItemElement.addEventListener('contextmenu', this._handleContextMenu
Event.bind(this), false); | 945 this.listItemElement.addEventListener('contextmenu', this._handleContextMenu
Event.bind(this), false); |
| 946 this.listItemElement.addEventListener('mousedown', this._onmousedown.bind(th
is), false); | |
| 947 this.listItemElement.addEventListener('dragstart', this._ondragstart.bind(th
is), false); | 946 this.listItemElement.addEventListener('dragstart', this._ondragstart.bind(th
is), false); |
| 948 } | 947 } |
| 949 | 948 |
| 950 _onmousedown(event) { | |
| 951 if (event.which === 1) // Warm-up data for drag'n'drop | |
| 952 this._uiSourceCode.requestContent().then(callback.bind(this)); | |
| 953 /** | |
| 954 * @param {?string} content | |
| 955 * @this {Sources.NavigatorSourceTreeElement} | |
| 956 */ | |
| 957 function callback(content) { | |
| 958 this._warmedUpContent = content; | |
| 959 } | |
| 960 } | |
| 961 | |
| 962 _shouldRenameOnMouseDown() { | 949 _shouldRenameOnMouseDown() { |
| 963 if (!this._uiSourceCode.canRename()) | 950 if (!this._uiSourceCode.canRename()) |
| 964 return false; | 951 return false; |
| 965 var isSelected = this === this.treeOutline.selectedTreeElement; | 952 var isSelected = this === this.treeOutline.selectedTreeElement; |
| 966 return isSelected && this.treeOutline.element.hasFocus() && !UI.isBeingEdite
d(this.treeOutline.element); | 953 return isSelected && this.treeOutline.element.hasFocus() && !UI.isBeingEdite
d(this.treeOutline.element); |
| 967 } | 954 } |
| 968 | 955 |
| 969 /** | 956 /** |
| 970 * @override | 957 * @override |
| 971 */ | 958 */ |
| 972 selectOnMouseDown(event) { | 959 selectOnMouseDown(event) { |
| 973 if (event.which !== 1 || !this._shouldRenameOnMouseDown()) { | 960 if (event.which !== 1 || !this._shouldRenameOnMouseDown()) { |
| 974 super.selectOnMouseDown(event); | 961 super.selectOnMouseDown(event); |
| 975 return; | 962 return; |
| 976 } | 963 } |
| 977 setTimeout(rename.bind(this), 300); | 964 setTimeout(rename.bind(this), 300); |
| 978 | 965 |
| 979 /** | 966 /** |
| 980 * @this {Sources.NavigatorSourceTreeElement} | 967 * @this {Sources.NavigatorSourceTreeElement} |
| 981 */ | 968 */ |
| 982 function rename() { | 969 function rename() { |
| 983 if (this._shouldRenameOnMouseDown()) | 970 if (this._shouldRenameOnMouseDown()) |
| 984 this._navigatorView.rename(this.uiSourceCode, false); | 971 this._navigatorView.rename(this.uiSourceCode, false); |
| 985 } | 972 } |
| 986 } | 973 } |
| 987 | 974 |
| 975 /** |
| 976 * @param {!DragEvent} event |
| 977 */ |
| 988 _ondragstart(event) { | 978 _ondragstart(event) { |
| 989 event.dataTransfer.setData('text/plain', this._warmedUpContent); | 979 event.dataTransfer.setData('text/plain', this._uiSourceCode.url()); |
| 990 event.dataTransfer.effectAllowed = 'copy'; | 980 event.dataTransfer.effectAllowed = 'copy'; |
| 991 return true; | |
| 992 } | 981 } |
| 993 | 982 |
| 994 /** | 983 /** |
| 995 * @override | 984 * @override |
| 996 * @return {boolean} | 985 * @return {boolean} |
| 997 */ | 986 */ |
| 998 onspace() { | 987 onspace() { |
| 999 this._navigatorView._sourceSelected(this.uiSourceCode, true); | 988 this._navigatorView._sourceSelected(this.uiSourceCode, true); |
| 1000 return true; | 989 return true; |
| 1001 } | 990 } |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1594 /** | 1583 /** |
| 1595 * @param {string} title | 1584 * @param {string} title |
| 1596 * @override | 1585 * @override |
| 1597 */ | 1586 */ |
| 1598 setTitle(title) { | 1587 setTitle(title) { |
| 1599 this._title = title; | 1588 this._title = title; |
| 1600 if (this._treeElement) | 1589 if (this._treeElement) |
| 1601 this._treeElement.title = this._title; | 1590 this._treeElement.title = this._title; |
| 1602 } | 1591 } |
| 1603 }; | 1592 }; |
| OLD | NEW |