diff options
| author | Pliable Pixels <pliablepixels@gmail.com> | 2017-12-21 15:54:36 -0500 |
|---|---|---|
| committer | Pliable Pixels <pliablepixels@gmail.com> | 2017-12-21 15:54:36 -0500 |
| commit | 3a731c5d48218e403e025f3b91c69ffbb66a0203 (patch) | |
| tree | a1ebd0383fc1d1503e76398381025d871fd4b373 /www | |
| parent | 1139ef589c666e80534177b4d6f0ab50c14b6c3d (diff) | |
#570 initial code for expand all and collapse all
Diffstat (limited to 'www')
| -rw-r--r-- | www/js/MomentCtrl.js | 105 | ||||
| -rw-r--r-- | www/templates/moment.html | 10 |
2 files changed, 90 insertions, 25 deletions
diff --git a/www/js/MomentCtrl.js b/www/js/MomentCtrl.js index 1851dca7..64631f89 100644 --- a/www/js/MomentCtrl.js +++ b/www/js/MomentCtrl.js @@ -41,6 +41,26 @@ angular.module('zmApp.controllers').controller('zmApp.MomentCtrl', ['$scope', '$ } }; + + function jiggleAway() { + $timeout(function () { + masonry.reloadItems(); + + }, 100); + + masonry.once('layoutComplete', function (laidOutItems) { + $timeout(function () { + masonry.layout(); + }, 300); + }); + + $timeout(function () { + masonry.layout(); + // $ionicScrollDelegate.$getByHandle("moment-delegate").scrollTop(); + + }, 600); + } + //---------------------------------------------------------------- // Given a set of monitor IDs, constructs a string that can // be directly passed to the cake PHP API (/MonitorId != X/...) @@ -123,7 +143,6 @@ angular.module('zmApp.controllers').controller('zmApp.MomentCtrl', ['$scope', '$ data.events[i].Event.order = i; // likely not needed if I stop force sorting data.events[i].Event.pinned = false; - data.events[i].Event.pinnedIcon = "ion-pin"; moments.push(data.events[i]); @@ -249,16 +268,63 @@ angular.module('zmApp.controllers').controller('zmApp.MomentCtrl', ['$scope', '$ return; } $scope.moments[ndx].Event.pinned = !$scope.moments[ndx].Event.pinned; - if ($scope.moments[ndx].Event.pinned) { - $scope.moments[ndx].Event.pinnedIcon = " ion-pin assertive"; - } else { - $scope.moments[ndx].Event.pinnedIcon = "ion-pin"; - } + }; + $scope.toggleExpandOrCollapse = function() { + + if ($scope.expand) expandAll(); + else collapseAll(); + $scope.expand = !$scope.expand; }; + function expandAll() { + for (var i=0; i < $scope.moments.length; i++) { + $scope.moments[i].Event.hide = false; + $scope.moments[i].Event.icon = 'ion-code-working'; + $scope.moments[i].Event.collapseCount = ''; + } + jiggleAway(); + } + + function collapseAll() { + + for (var i=0; i < monitors.length; i++) { + var firstFound = false; + var firstIndex = -1; + var collapseCount = 0; + for (var j=0; j < $scope.moments.length; j++) { + if ($scope.moments[j].Event.MonitorId == monitors[i].Monitor.Id) { + + if (!firstFound) { + firstIndex = j; // remember this to create a collapsecount + $scope.moments[j].Event.hide = false; + $scope.moments[j].Event.icon = 'ion-images'; + firstFound = true; + } + else if (!$scope.moments[j].Event.pinned) { + // mid matches, but not first, and not pinned so collapse + $scope.moments[j].Event.hide = true; + $scope.moments[j].Event.icon = 'ion-code-working'; + collapseCount++; + } + } // if same mid + } // moment for j + if (firstIndex !=-1) { + if (collapseCount>0) { + $scope.moments[firstIndex].Event.collapseCount = collapseCount; + } + else { // nothing to group + $scope.moments[firstIndex].Event.icon = 'ion-code-working'; + $scope.moments[firstIndex].Event.collapseCount = ""; + } + + } // firstIndex + } // monitor for i + jiggleAway(); + } + //---------------------------------------------------------------- // fold/unfold monitor groups //---------------------------------------------------------------- @@ -300,26 +366,18 @@ angular.module('zmApp.controllers').controller('zmApp.MomentCtrl', ['$scope', '$ } //for if (hide) { // +1 for the marked frame which doesn't get counted - $scope.moments[ndx].Event.collapseCount = collapseCount + 1; + if (collapseCount >0) { + $scope.moments[ndx].Event.collapseCount = collapseCount + 1; + } + else { // nothing to collapse + $scope.moments[ndx].Event.collapseCount = ""; + $scope.moments[ndx].Event.icon = 'ion-code-working'; + + } } else { $scope.moments[ndx].Event.collapseCount = ""; } - $timeout(function () { - masonry.reloadItems(); - - }, 100); - - masonry.once('layoutComplete', function (laidOutItems) { - $timeout(function () { - masonry.layout(); - }, 300); - }); - - $timeout(function () { - masonry.layout(); - // $ionicScrollDelegate.$getByHandle("moment-delegate").scrollTop(); - - }, 600); + jiggleAway(); }; @@ -710,6 +768,7 @@ angular.module('zmApp.controllers').controller('zmApp.MomentCtrl', ['$scope', '$ $scope.$on('$ionicView.beforeEnter', function () { $scope.showIcons = true; + $scope.expand = false; var ld = NVRDataModel.getLogin(); $scope.loadingStatus = $translate.instant('kLoading'); diff --git a/www/templates/moment.html b/www/templates/moment.html index 081885b5..da321f16 100644 --- a/www/templates/moment.html +++ b/www/templates/moment.html @@ -44,6 +44,11 @@ </a> </li> <li> + <a href="" ng-click="toggleExpandOrCollapse()"> + <i ng-class="expand ? 'ion-arrow-expand':'ion-arrow-shrink'"></i> + </a> + </li> + <li> <a href="" ng-click="toggleIcons()"> <i ng-class="showIcons? 'ion-eye':'ion-eye-disabled'"></i> </a> @@ -95,8 +100,9 @@ <figcaption ng-if="showIcons" class="normal-subfigcaption"> <span style="float:right"> - <button class="button button-small button-icon icon {{moment.Event.pinnedIcon}}" ng-click="togglePin(moment.Event.Id)"></button> - </span> + + + <button ng-class="moment.Event.pinned? 'button button-small button-icon icon ion-pin assertive': 'button button-small button-icon icon ion-pin'" ng-click="togglePin(moment.Event.Id)"></button> </figcaption> <!--on-tap="showThumbnail(moment.Event.baseURL,moment.Event.MaxScoreFrameId)"--> <figcaption ng-if="showIcons" class="normal-figcaption"> {{moment.Event.humanizeTime}} |
