diff options
| author | Arjun Roychowdhury <pliablepixels@gmail.com> | 2015-12-06 17:23:02 -0500 |
|---|---|---|
| committer | Arjun Roychowdhury <pliablepixels@gmail.com> | 2015-12-06 17:23:02 -0500 |
| commit | 65cb2f860470f8303c341201dc892e289597507b (patch) | |
| tree | e5fa83651f9cfbc205679ce059a126587affe6b5 | |
| parent | 8fff74273ef27a98c04fb73139a90cf017bf0be6 (diff) | |
#106 - first step towards a lot of required cleanup - still very very messy
Former-commit-id: 340545e91b29552f68cb03398401668ef479d3de
| -rw-r--r-- | www/external/angular-carousel.js | 65 | ||||
| -rw-r--r-- | www/js/EventCtrl.js | 3 | ||||
| -rw-r--r-- | www/js/ModalCtrl.js | 38 | ||||
| -rw-r--r-- | www/templates/events-modal.html | 1 | ||||
| -rw-r--r-- | www/templates/events.html | 2 |
5 files changed, 88 insertions, 21 deletions
diff --git a/www/external/angular-carousel.js b/www/external/angular-carousel.js index 5705688c..8e143164 100644 --- a/www/external/angular-carousel.js +++ b/www/external/angular-carousel.js @@ -29,7 +29,7 @@ angular.module('angular-carousel') // so slide does not progress if image is not loaded or gets an error // imageLoadingDataShare is the factory that has a value // of 0 if no image is being loaded, -1 if there was an error and 1 if an image is currently being loaded -.directive('rnCarouselAutoSlide', ['$interval','$timeout', 'imageLoadingDataShare', function($interval,$timeout, imageLoadingDataShare ) { +.directive('rnCarouselAutoSlide', ['$interval','$timeout', 'imageLoadingDataShare', 'stopOrPlay', function($interval,$timeout, imageLoadingDataShare, stopOrPlay ) { return { restrict: 'A', link: function (scope, element, attrs) { @@ -37,33 +37,45 @@ angular.module('angular-carousel') var stopAutoPlay = function() { if (scope.autoSlider) { - console.log ("Cancelling timer"); + //console.log ("Cancelling timer"); $interval.cancel(scope.autoSlider); scope.autoSlider = null; } }; var restartTimer = function() { - scope.autoSlide(); + if (stopOrPlay.isStopped() == false) + { + //console.log ("Timer restart rnForceStop "+ stopOrPlay.get()); + scope.autoSlide(); + } + else {console.log ("Not sliding as stop=true");} }; //PP - don't auto play if user taps var toggleAutoPlay = function() { + //scope.rnForceStop = !scope.rnForceStop; + stopOrPlay.set(!stopOrPlay.get()); + //console.log ("Autoplay is " + stopOrPlay.get()); if (scope.autoSlider) { // PP - If autoslide was on and we tapped, stop auto slide - scope.rnForceStop = true; //PP - console.log ("***RN: Stopping Play"); + //scope.rnForceStop = true; //PP + stopOrPlay.set (true); + console.log ("***RN: Stopping Play rnForceStop is "+stopOrPlay.get()); stopAutoPlay(); } else { - scope.rnForceStop = false; //PP - console.log ("***RN: Starting Play"); + //scope.rnForceStop = false; //PP + stopOrPlay.set (false); + console.log ("***RN: Starting Play rnForceStop is "+stopOrPlay.get()); restartTimer(); } }; // start with autoplay and require tap to stop - scope.rnForceStop = false; // PP + console.log ("*** Setting rnForceStop to false and watching"); + //scope.rnForceStop = false; // PP + stopOrPlay.set (false); scope.$watch('carouselIndex', restartTimer); if (attrs.hasOwnProperty('rnCarouselPauseOnHover') && attrs.rnCarouselPauseOnHover !== 'false'){ @@ -237,6 +249,30 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach }; }]) + //PP + .factory ('stopOrPlay', function() { + var stoporplay = false; + return { + set: function(val) + { + stoporplay = val; + }, + get: function() + { + return stoporplay; + }, + isStopped: function() + { + return stoporplay; + }, + hello: function() + { + console.log ("Hello from stopOrPlay"); + } + + } + }) + .service('createStyleString', function() { return function(object) { var styles = []; @@ -247,8 +283,8 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach }; }) - .directive('rnCarousel', ['$swipe', '$window', '$document', '$parse', '$compile', '$timeout', '$interval', 'computeCarouselSlideStyle', 'createStyleString', 'Tweenable', 'imageLoadingDataShare', - function($swipe, $window, $document, $parse, $compile, $timeout, $interval, computeCarouselSlideStyle, createStyleString, Tweenable, imageLoadingDataShare) { + .directive('rnCarousel', ['$swipe', '$window', '$document', '$parse', '$compile', '$timeout', '$interval', 'computeCarouselSlideStyle', 'createStyleString', 'Tweenable', 'imageLoadingDataShare', 'stopOrPlay', + function($swipe, $window, $document, $parse, $compile, $timeout, $interval, computeCarouselSlideStyle, createStyleString, Tweenable, imageLoadingDataShare, stopOrPlay) { // internal ids to allow multiple instances var carouselId = 0, // in absolute pixels, at which distance the slide stick to the edge on release @@ -380,6 +416,8 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach } scope.nextSlide = function(slideOptions) { + if (stopOrPlay.isStopped()==true) + return; if (imageLoadingDataShare.get() == 1) // PP- If the image is still being loaded, hold on, don't change { //console.log ("Image is still loading, not skipping slides"); @@ -527,8 +565,9 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach $interval.cancel(scope.autoSlider); scope.autoSlider = null; } - if (!scope.rnForceStop) //PP - don't move slide if this variable is set + if (stopOrPlay.isStopped() == false) //PP - don't move slide if this variable is set { + //console.log ("Setting next slide duration at " + duration *1000); scope.autoSlider = $interval(function() { if (!locked && !pressed ) { scope.nextSlide(); @@ -550,13 +589,15 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach if (value < 0) { return; } + //console.log ("Still indexing"); indexModel.assign(scope.$parent, value); }; var indexModel = $parse(iAttributes.rnCarouselIndex); if (angular.isFunction(indexModel.assign)) { /* check if this property is assignable then watch it */ scope.$watch('carouselIndex', function(newValue) { - updateParentIndex(newValue); + if (stopOrPlay.isStopped() == false) + updateParentIndex(newValue); }); scope.$parent.$watch(function () { return indexModel(scope.$parent); diff --git a/www/js/EventCtrl.js b/www/js/EventCtrl.js index d0f42975..5102c321 100644 --- a/www/js/EventCtrl.js +++ b/www/js/EventCtrl.js @@ -660,6 +660,7 @@ angular.module('zmApp.controllers') { ZMDataModel.zmDebug("EventCtrl: Scrubbing will turn on now"); $scope.currentEvent = ""; + $scope.event = event; //$ionicScrollDelegate.freezeScroll(true); $ionicSideMenuDelegate.canDragContent(false); $scope.slider_options = { @@ -1204,7 +1205,7 @@ angular.module('zmApp.controllers') $scope.openModal = function (event) { //ZMDataModel.zmDebug("EventCtrl: Open Modal with Base path " + relativepath); - + $scope.event = event; ZMDataModel.setAwake(ZMDataModel.getKeepAwake()); $scope.currentEvent = event; diff --git a/www/js/ModalCtrl.js b/www/js/ModalCtrl.js index 6a8a9ccf..c9ed3f88 100644 --- a/www/js/ModalCtrl.js +++ b/www/js/ModalCtrl.js @@ -4,7 +4,7 @@ /* global saveAs, cordova,StatusBar,angular,console,ionic, moment */ -angular.module('zmApp.controllers').controller('ModalCtrl', ['$scope', '$rootScope', 'zm', 'ZMDataModel', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$q', '$sce',function ($scope, $rootScope, zm, ZMDataModel, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $q, $sce) { +angular.module('zmApp.controllers').controller('ModalCtrl', ['$scope', '$rootScope', 'zm', 'ZMDataModel', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$q', '$sce', 'stopOrPlay', function ($scope, $rootScope, zm, ZMDataModel, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $q, $sce, stopOrPlay) { // from parent scope @@ -994,22 +994,46 @@ angular.module('zmApp.controllers').controller('ModalCtrl', ['$scope', '$rootSco if (typeof $scope.ionRange !== 'undefined') { $scope.$watch('ionRange.index', function () { - // console.log ("***ION RANGE CHANGED"); - + // + if (stopOrPlay.get() == true) + return; $scope.mycarousel.index = parseInt($scope.ionRange.index) - 1; + console.log ("***ION RANGE CHANGED TO " + $scope.mycarousel.index); }); } if (typeof $scope.mycarousel !== 'undefined') { $scope.$watch('mycarousel.index', function () { - - $scope.ionRange.index = ($scope.mycarousel.index + 1).toString(); - + + console.log ("***ION MYCAROUSEL CHANGED"); + if (currentEvent && $scope.ionRange.index == parseInt(currentEvent.Event.Frames)) + { + playbackFinished(); + } + // end of playback from quick scrub + // so ignore gapless + + + + if ($scope.event && $scope.ionRange.index == parseInt($scope.event.Event.Frames)-1 ) { - playbackFinished(); + if (!$scope.modal || $scope.modal.isShown()==false) + { + console.log ("quick scrub playback over"); + stopOrPlay.set(true); + $scope.ionRange.index = 0; + $scope.mycarousel.index = 1; + } + } + if (stopOrPlay.get() == true) + return; + $scope.ionRange.index = ($scope.mycarousel.index + 1).toString(); + // console.log ("***IONRANGE RANGE CHANGED TO " + $scope.ionRange.index); + + }); } diff --git a/www/templates/events-modal.html b/www/templates/events-modal.html index 1d785f72..0a74e0b5 100644 --- a/www/templates/events-modal.html +++ b/www/templates/events-modal.html @@ -9,6 +9,7 @@ <div ng-if="defaultVideo=='' || loginData.enableh264==false"> + <ul rn-carousel rn-carousel-buffered rn-carousel-transition="none" rn-swipe-disabled="true" rn-carousel-index="mycarousel.index" rn-carousel-auto-slide="{{event.Event.Length/event.Event.Frames}}" rn-carousel-pause-on-hover rn-platform="{{$root.platformOS}}"> <li ng-repeat="slide in slides"> diff --git a/www/templates/events.html b/www/templates/events.html index 147be16b..ae9bd5d3 100644 --- a/www/templates/events.html +++ b/www/templates/events.html @@ -144,7 +144,7 @@ <div style="height:190px"> - {{event.Event.Length/event.Event.Frames}} + <ul rn-carousel rn-carousel-buffered rn-carousel-transition="none" rn-swipe-disabled="true" rn-carousel-index="mycarousel.index" rn-carousel-auto-slide="{{event.Event.Length/event.Event.Frames}}" rn-carousel-pause-on-hover rn-platform="{{$root.platformOS}}"> <li ng-repeat="slide in slides"> <!-- Linwood scaling --> |
