From 676e159445b4c9e79a8d668c717643be06f8e8ba Mon Sep 17 00:00:00 2001 From: RaymondLim Date: Thu, 26 Jun 2014 11:04:06 -0700 Subject: [PATCH 1/8] Implement checkbox option for individual file in search result panel. --- src/htmlContent/search-results.html | 1 + src/search/SearchResultsView.js | 45 ++++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/htmlContent/search-results.html b/src/htmlContent/search-results.html index 7c5a671b9cf..b003aa104b3 100644 --- a/src/htmlContent/search-results.html +++ b/src/htmlContent/search-results.html @@ -2,6 +2,7 @@ {{#searchList}} + {{{filename}}} diff --git a/src/search/SearchResultsView.js b/src/search/SearchResultsView.js index 75de81f266f..6657dd19644 100644 --- a/src/search/SearchResultsView.js +++ b/src/search/SearchResultsView.js @@ -249,17 +249,40 @@ define(function (require, exports, module) { }); }); self._$table.find(".check-one").prop("checked", isChecked); + self._$table.find(".check-one-file").prop("checked", isChecked); self._allChecked = isChecked; }) + .on("click.searchResults", ".check-one-file", function (e) { + var isChecked = $(this).is(":checked"), + $row = $(e.target).closest("tr"), + item = self._searchList[$row.data("file-index")], + $matchRows = $row.nextUntil(".file-section"); + + if (item) { + self._model.results[item.fullPath].matches.forEach(function (match) { + match.isChecked = isChecked; + }); + } + $matchRows.find(".check-one").prop("checked", isChecked); + e.stopPropagation(); + }) .on("click.searchResults", ".check-one", function (e) { var $row = $(e.target).closest("tr"), + $firstMatch = ($row.data("item-index") === 0) ? $row : $row.prevUntil(".file-section").last(), + $fileRow = $firstMatch.prev(), + $fileCheckbox = $fileRow.find(".check-one-file"), item = self._searchList[$row.data("file-index")], match = self._model.results[item.fullPath].matches[$row.data("match-index")], $checkAll = self._panel.$panel.find(".check-all"); match.isChecked = $(this).is(":checked"); - if (!match.isChecked && $checkAll.is(":checked")) { - $checkAll.prop("checked", false); + if (!match.isChecked) { + if ($checkAll.is(":checked")) { + $checkAll.prop("checked", false); + } + if ($fileCheckbox.is(":checked")) { + $fileCheckbox.prop("checked", false); + } } e.stopPropagation(); }) @@ -318,12 +341,13 @@ define(function (require, exports, module) { */ SearchResultsView.prototype._render = function () { var searchItems, match, i, item, multiLine, - count = this._model.countFilesMatches(), - searchFiles = this._model.getSortedFiles(this._initialFilePath), - lastIndex = this._getLastIndex(count.matches), - matchesCounter = 0, - showMatches = false, - self = this; + count = this._model.countFilesMatches(), + searchFiles = this._model.getSortedFiles(this._initialFilePath), + lastIndex = this._getLastIndex(count.matches), + matchesCounter = 0, + showMatches = false, + allInFileChecked = true, + self = this; this._showSummary(); this._searchList = []; @@ -361,6 +385,7 @@ define(function (require, exports, module) { // Add a row for each match in the file searchItems = []; + allInFileChecked = true; // Add matches until we get to the last match of this item, or filling the page while (i < item.matches.length && matchesCounter < lastIndex) { match = item.matches[i]; @@ -378,6 +403,9 @@ define(function (require, exports, module) { end: match.end, isChecked: match.isChecked }); + if (!match.isChecked) { + allInFileChecked = false; + } matchesCounter++; i++; } @@ -396,6 +424,7 @@ define(function (require, exports, module) { fileIndex: self._searchList.length, filename: displayFileName, fullPath: fullPath, + isChecked: allInFileChecked, items: searchItems }); } From e6563d8fd0076f8dc82cafc399315ea32add26b0 Mon Sep 17 00:00:00 2001 From: RaymondLim Date: Thu, 26 Jun 2014 12:43:24 -0700 Subject: [PATCH 2/8] Don't show checkboxes in file-sections for the Find Result panel. --- src/htmlContent/search-results.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/htmlContent/search-results.html b/src/htmlContent/search-results.html index b003aa104b3..7f36ae927e7 100644 --- a/src/htmlContent/search-results.html +++ b/src/htmlContent/search-results.html @@ -2,7 +2,7 @@ {{#searchList}} - + {{#replace}}{{/replace}} {{{filename}}} From d6117476bb7806b08e325e2b642893166cff5004 Mon Sep 17 00:00:00 2001 From: Lawrence Hsu Date: Thu, 26 Jun 2014 12:58:47 -0700 Subject: [PATCH 3/8] Tweaked spacing. --- src/styles/brackets.less | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/styles/brackets.less b/src/styles/brackets.less index 7337af5b76f..291110935e2 100644 --- a/src/styles/brackets.less +++ b/src/styles/brackets.less @@ -444,7 +444,11 @@ a, img { } .file-section > td { - padding-left: 5px; + padding-left: 10px; + } + + .file-section > .checkbox-column { + padding-left: 15px; } .line-number { From b3e0a0e53ba7a99061dd73d8d6e79be9cbd1c3f7 Mon Sep 17 00:00:00 2001 From: RaymondLim Date: Thu, 26 Jun 2014 21:51:24 -0700 Subject: [PATCH 4/8] Adjust colspan attribute for file-section to the correct value. --- src/htmlContent/search-results.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/htmlContent/search-results.html b/src/htmlContent/search-results.html index 7f36ae927e7..a335cabbcbb 100644 --- a/src/htmlContent/search-results.html +++ b/src/htmlContent/search-results.html @@ -3,7 +3,7 @@ {{#searchList}} {{#replace}}{{/replace}} - + {{{filename}}} From 5077ce438c5d0b6e26c2d00cc6d4df9d1cd8eecf Mon Sep 17 00:00:00 2001 From: RaymondLim Date: Fri, 18 Jul 2014 10:03:16 -0700 Subject: [PATCH 5/8] Update file and header checkboxes when the last not-yet-checked item is checked. --- src/search/SearchResultsView.js | 64 +++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 14 deletions(-) diff --git a/src/search/SearchResultsView.js b/src/search/SearchResultsView.js index 6657dd19644..1c996005745 100644 --- a/src/search/SearchResultsView.js +++ b/src/search/SearchResultsView.js @@ -237,6 +237,45 @@ define(function (require, exports, module) { } }); + function updateHeaderCheckbox($checkAll) { + var $allFileRows = self._panel.$panel.find(".file-section"), + $checkedFileRows = $allFileRows.filter(function (index) { + return $(this).find(".check-one-file").is(":checked"); + }); + if ($checkedFileRows.length === $allFileRows.length) { + $checkAll.prop("checked", true); + } + } + + function updateFileAndHeaderCheckboxes($clickedRow, isChecked) { + var $firstMatch = ($clickedRow.data("item-index") === 0) + ? $clickedRow : $clickedRow.prevUntil(".file-section").last(), + $fileRow = $firstMatch.prev(), + $siblingRows = $fileRow.nextUntil(".file-section"), + $fileCheckbox = $fileRow.find(".check-one-file"), + $checkAll = self._panel.$panel.find(".check-all"); + + if (isChecked) { + if (!$fileCheckbox.is(":checked")) { + var $checkedSibilings = $siblingRows.filter(function (index) { + return $(this).find(".check-one").is(":checked"); + }); + if ($checkedSibilings.length === $siblingRows.length) { + $fileCheckbox.prop("checked", true); + if (!$checkAll.is(":checked")) { + updateHeaderCheckbox($checkAll); + } + } + } + } else { + if ($checkAll.is(":checked")) { + $checkAll.prop("checked", false); + } + if ($fileCheckbox.is(":checked")) { + $fileCheckbox.prop("checked", false); + } + } + } // Add the Click handlers for replace functionality if required if (this._model.isReplace) { @@ -256,7 +295,8 @@ define(function (require, exports, module) { var isChecked = $(this).is(":checked"), $row = $(e.target).closest("tr"), item = self._searchList[$row.data("file-index")], - $matchRows = $row.nextUntil(".file-section"); + $matchRows = $row.nextUntil(".file-section"), + $checkAll = self._panel.$panel.find(".check-all"); if (item) { self._model.results[item.fullPath].matches.forEach(function (match) { @@ -264,26 +304,22 @@ define(function (require, exports, module) { }); } $matchRows.find(".check-one").prop("checked", isChecked); + if (!isChecked) { + if ($checkAll.is(":checked")) { + $checkAll.prop("checked", false); + } + } else if (!$checkAll.is(":checked")) { + updateHeaderCheckbox($checkAll); + } e.stopPropagation(); }) .on("click.searchResults", ".check-one", function (e) { var $row = $(e.target).closest("tr"), - $firstMatch = ($row.data("item-index") === 0) ? $row : $row.prevUntil(".file-section").last(), - $fileRow = $firstMatch.prev(), - $fileCheckbox = $fileRow.find(".check-one-file"), item = self._searchList[$row.data("file-index")], - match = self._model.results[item.fullPath].matches[$row.data("match-index")], - $checkAll = self._panel.$panel.find(".check-all"); + match = self._model.results[item.fullPath].matches[$row.data("match-index")]; match.isChecked = $(this).is(":checked"); - if (!match.isChecked) { - if ($checkAll.is(":checked")) { - $checkAll.prop("checked", false); - } - if ($fileCheckbox.is(":checked")) { - $fileCheckbox.prop("checked", false); - } - } + updateFileAndHeaderCheckboxes($row, match.isChecked); e.stopPropagation(); }) .on("click.searchResults", ".replace-checked", function (e) { From b1be221d48bccf871d97840be20a57d191bd2a9a Mon Sep 17 00:00:00 2001 From: RaymondLim Date: Fri, 18 Jul 2014 10:55:57 -0700 Subject: [PATCH 6/8] Fix some JSLint errors. --- src/search/SearchResultsView.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/search/SearchResultsView.js b/src/search/SearchResultsView.js index 1c996005745..c1c36e4f86a 100644 --- a/src/search/SearchResultsView.js +++ b/src/search/SearchResultsView.js @@ -240,8 +240,8 @@ define(function (require, exports, module) { function updateHeaderCheckbox($checkAll) { var $allFileRows = self._panel.$panel.find(".file-section"), $checkedFileRows = $allFileRows.filter(function (index) { - return $(this).find(".check-one-file").is(":checked"); - }); + return $(this).find(".check-one-file").is(":checked"); + }); if ($checkedFileRows.length === $allFileRows.length) { $checkAll.prop("checked", true); } @@ -249,7 +249,8 @@ define(function (require, exports, module) { function updateFileAndHeaderCheckboxes($clickedRow, isChecked) { var $firstMatch = ($clickedRow.data("item-index") === 0) - ? $clickedRow : $clickedRow.prevUntil(".file-section").last(), + ? $clickedRow + : $clickedRow.prevUntil(".file-section").last(), $fileRow = $firstMatch.prev(), $siblingRows = $fileRow.nextUntil(".file-section"), $fileCheckbox = $fileRow.find(".check-one-file"), @@ -258,8 +259,8 @@ define(function (require, exports, module) { if (isChecked) { if (!$fileCheckbox.is(":checked")) { var $checkedSibilings = $siblingRows.filter(function (index) { - return $(this).find(".check-one").is(":checked"); - }); + return $(this).find(".check-one").is(":checked"); + }); if ($checkedSibilings.length === $siblingRows.length) { $fileCheckbox.prop("checked", true); if (!$checkAll.is(":checked")) { From b8ab5756e0ab90fff0a646440dfff8940b76696d Mon Sep 17 00:00:00 2001 From: RaymondLim Date: Fri, 18 Jul 2014 11:16:23 -0700 Subject: [PATCH 7/8] Another try to fix the jshint error. --- src/search/SearchResultsView.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/search/SearchResultsView.js b/src/search/SearchResultsView.js index c1c36e4f86a..8b07a9065ba 100644 --- a/src/search/SearchResultsView.js +++ b/src/search/SearchResultsView.js @@ -248,9 +248,8 @@ define(function (require, exports, module) { } function updateFileAndHeaderCheckboxes($clickedRow, isChecked) { - var $firstMatch = ($clickedRow.data("item-index") === 0) - ? $clickedRow - : $clickedRow.prevUntil(".file-section").last(), + var $firstMatch = ($clickedRow.data("item-index") === 0) ? $clickedRow : + $clickedRow.prevUntil(".file-section").last(), $fileRow = $firstMatch.prev(), $siblingRows = $fileRow.nextUntil(".file-section"), $fileCheckbox = $fileRow.find(".check-one-file"), From 0f8f92304664bed1c43db849fe5f6728027c9f77 Mon Sep 17 00:00:00 2001 From: RaymondLim Date: Fri, 18 Jul 2014 14:18:28 -0700 Subject: [PATCH 8/8] Fix the checkbox column width issue for file rows in search panel. --- src/styles/brackets.less | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/styles/brackets.less b/src/styles/brackets.less index 291110935e2..fe0faaa3af0 100644 --- a/src/styles/brackets.less +++ b/src/styles/brackets.less @@ -443,12 +443,8 @@ a, img { vertical-align: baseline; } - .file-section > td { - padding-left: 10px; - } - .file-section > .checkbox-column { - padding-left: 15px; + width: 15px; } .line-number {