summaryrefslogtreecommitdiff
path: root/www/js/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js/app.js')
-rw-r--r--www/js/app.js109
1 files changed, 108 insertions, 1 deletions
diff --git a/www/js/app.js b/www/js/app.js
index b699d627..f4c2f819 100644
--- a/www/js/app.js
+++ b/www/js/app.js
@@ -41,7 +41,7 @@ angular.module('zmApp', [
authoremail: 'pliablepixels+zmNinja@gmail.com',
logFileMaxSize: 20000, // after this limit log gets reset
loginInterval: 300000, //5m*60s*1000 - ZM auto login after 5 mins
- //loginInterval: 60000,
+ //loginInterval: 30000,
updateCheckInterval: 86400000, // 24 hrs
loadingTimeout: 15000,
safeMontageLimit: 10,
@@ -71,6 +71,7 @@ angular.module('zmApp', [
blogUrl:"http://pliablepixels.github.io/feed.json",
nphSwitchTimer:6000,
eventHistoryTimer:10000,
+ eventPlaybackQuery:3000,
})
@@ -168,6 +169,112 @@ angular.module('zmApp', [
};
})
+//-------------------------------------------------------
+// Ability to share controllers with modals
+// Credit: http://codepen.io/julianpaulozzi/pen/wBgpjM
+//-------------------------------------------------------
+
+.factory('appModalService',
+['$ionicModal', '$rootScope', '$q', '$injector', '$controller', function($ionicModal, $rootScope, $q, $injector, $controller) {
+
+ return {
+ show: show
+ };
+
+ function show(templateUrl, controller, parameters, options) {
+ // Grab the injector and create a new scope
+ var deferred = $q.defer(),
+ ctrlInstance,
+ modalScope = $rootScope.$new(),
+ thisScopeId = modalScope.$id,
+ defaultOptions = {
+ animation: 'slide-in-up',
+ focusFirstInput: false,
+ backdropClickToClose: true,
+ hardwareBackButtonClose: true,
+ modalCallback: null
+ };
+
+ options = angular.extend({}, defaultOptions, options);
+
+ $ionicModal.fromTemplateUrl(templateUrl, {
+ scope: modalScope,
+ animation: options.animation,
+ focusFirstInput: options.focusFirstInput,
+ backdropClickToClose: options.backdropClickToClose,
+ hardwareBackButtonClose: options.hardwareBackButtonClose
+ }).then(function (modal) {
+ modalScope.modal = modal;
+
+ modalScope.openModal = function () {
+ modalScope.modal.show();
+ };
+ modalScope.closeModal = function (result) {
+ deferred.resolve(result);
+ modalScope.modal.hide();
+ };
+ modalScope.$on('modal.hidden', function (thisModal) {
+ if (thisModal.currentScope) {
+ var modalScopeId = thisModal.currentScope.$id;
+ if (thisScopeId === modalScopeId) {
+ deferred.resolve(null);
+ _cleanup(thisModal.currentScope);
+ }
+ }
+ });
+
+ // Invoke the controller
+ var locals = { '$scope': modalScope, 'parameters': parameters };
+ var ctrlEval = _evalController(controller);
+ ctrlInstance = $controller(controller, locals);
+ if (ctrlEval.isControllerAs) {
+ ctrlInstance.openModal = modalScope.openModal;
+ ctrlInstance.closeModal = modalScope.closeModal;
+ }
+
+ modalScope.modal.show()
+ .then(function () {
+ modalScope.$broadcast('modal.afterShow', modalScope.modal);
+ });
+
+ if (angular.isFunction(options.modalCallback)) {
+ options.modalCallback(modal);
+ }
+
+ }, function (err) {
+ deferred.reject(err);
+ });
+
+ return deferred.promise;
+ }
+
+ function _cleanup(scope) {
+ scope.$destroy();
+ if (scope.modal) {
+ scope.modal.remove();
+ }
+ }
+
+ function _evalController(ctrlName) {
+ var result = {
+ isControllerAs: false,
+ controllerName: '',
+ propName: ''
+ };
+ var fragments = (ctrlName || '').trim().split(/\s+/);
+ result.isControllerAs = fragments.length === 3 && (fragments[1] || '').toLowerCase() === 'as';
+ if (result.isControllerAs) {
+ result.controllerName = fragments[0];
+ result.propName = fragments[2];
+ } else {
+ result.controllerName = ctrlName;
+ }
+
+ return result;
+ }
+
+}])
+
//------------------------------------------------------------------
// this directive will be called any time an image completes loading
// via img tags where this directive is added (I am using this in