|
133 | 133 | }); |
134 | 134 | }; |
135 | 135 |
|
136 | | - Diff2HtmlUI.prototype._initSelection = function () { |
137 | | - var body = $('body'), |
138 | | - that = this; |
| 136 | + Diff2HtmlUI.prototype._initSelection = function() { |
| 137 | + var body = $('body'); |
| 138 | + var that = this; |
139 | 139 |
|
140 | | - body.on('mousedown', '.d2h-diff-table', function (event) { |
141 | | - var target = $(event.target), |
142 | | - table = target.closest('.d2h-diff-table'); |
| 140 | + body.on('mousedown', '.d2h-diff-table', function(event) { |
| 141 | + var target = $(event.target); |
| 142 | + var table = target.closest('.d2h-diff-table'); |
143 | 143 |
|
144 | 144 | if (target.closest('.d2h-code-line,.d2h-code-side-line').length) { |
145 | 145 | table.removeClass('selecting-left'); |
|
152 | 152 | } |
153 | 153 | }); |
154 | 154 |
|
155 | | - body.on('copy', '.d2h-diff-table', function (event) { |
| 155 | + body.on('copy', '.d2h-diff-table', function(event) { |
156 | 156 | var clipboardData = event.originalEvent.clipboardData; |
157 | 157 | var text = that._getSelectedText(); |
158 | 158 | clipboardData.setData('text', text); |
|
161 | 161 | }; |
162 | 162 |
|
163 | 163 |
|
164 | | - Diff2HtmlUI.prototype._getSelectedText = function () { |
165 | | - var table = $('.d2h-diff-table'), |
166 | | - sel = window.getSelection(), |
167 | | - range = sel.getRangeAt(0), |
168 | | - doc = range.cloneContents(), |
169 | | - nodes = doc.querySelectorAll('tr'), |
170 | | - text = ''; |
171 | | - |
| 164 | + Diff2HtmlUI.prototype._getSelectedText = function() { |
| 165 | + var table = $('.d2h-diff-table'); |
| 166 | + var sel = window.getSelection(); |
| 167 | + var range = sel.getRangeAt(0); |
| 168 | + var doc = range.cloneContents(); |
| 169 | + var nodes = doc.querySelectorAll('tr'); |
| 170 | + var text = ''; |
172 | 171 | var idx = currentSelectionColumnId; |
173 | 172 |
|
174 | 173 | if (nodes.length === 0) { |
175 | 174 | text = doc.textContent; |
176 | 175 | } else { |
177 | | - [].forEach.call(nodes, function (tr, i) { |
| 176 | + [].forEach.call(nodes, function(tr, i) { |
178 | 177 | var td = tr.cells[tr.cells.length == 1 ? 0 : idx]; |
179 | 178 | text += (i ? '\n' : '') + td.textContent.replace(/(?:\r\n|\r|\n)/g, ''); |
180 | 179 | }); |
|
0 commit comments