From dcebf9be02179c8ab1d5da95744e7c3fff8ff18c Mon Sep 17 00:00:00 2001 From: Andrew Joslin Date: Thu, 22 May 2014 11:22:32 -0600 Subject: [PATCH] demos(): add demos for sideMenu and popup --- js/angular/directive/sideMenus.js | 154 ++++++++++++++++++++++++++++++ js/angular/service/popup.js | 110 +++++++++++++++++++++ 2 files changed, 264 insertions(+) diff --git a/js/angular/directive/sideMenus.js b/js/angular/directive/sideMenus.js index 68db8f5485..152eef1d7d 100644 --- a/js/angular/directive/sideMenus.js +++ b/js/angular/directive/sideMenus.js @@ -94,6 +94,160 @@ app.controller('SideMenusSimpleCtrl', function($scope, $ionicSideMenuDelegate) { */ +/** + * @ngdoc demo + * @name ionSideMenus#navWithMenu + * @module sideMenuWithNav + * @javascript +angular.module('sideMenuWithNav', ['ionic']) +.config(function($stateProvider, $urlRouterProvider) { + $stateProvider + + .state('app', { + url: "/app", + abstract: true, + templateUrl: "templates/menu.html", + controller: 'AppCtrl' + }) + + .state('app.search', { + url: "/search", + views: { + 'menuContent' :{ + templateUrl: "templates/search.html" + } + } + }) + + .state('app.browse', { + url: "/browse", + views: { + 'menuContent' :{ + templateUrl: "templates/browse.html" + } + } + }) + .state('app.playlists', { + url: "/playlists", + views: { + 'menuContent' :{ + templateUrl: "templates/playlists.html", + controller: 'PlaylistsCtrl' + } + } + }) + + .state('app.single', { + url: "/playlists/:playlistId", + views: { + 'menuContent' :{ + templateUrl: "templates/playlist.html", + controller: 'PlaylistCtrl' + } + } + }); + // if none of the above states are matched, use this as the fallback + $urlRouterProvider.otherwise('/app/playlists'); +}) + +.controller('AppCtrl', function($scope) { +}) + +.controller('PlaylistsCtrl', function($scope) { + $scope.playlists = [ + { title: 'Reggae', id: 1 }, + { title: 'Chill', id: 2 }, + { title: 'Dubstep', id: 3 }, + { title: 'Indie', id: 4 }, + { title: 'Rap', id: 5 }, + { title: 'Cowbell', id: 6 } + ]; +}) + +.controller('PlaylistCtrl', function($scope, $stateParams) { +}) + * + * @html + + + + + + + + + + + + + */ .directive('ionSideMenus', [function() { return { diff --git a/js/angular/service/popup.js b/js/angular/service/popup.js index 9558193f7a..68e8a05af6 100644 --- a/js/angular/service/popup.js +++ b/js/angular/service/popup.js @@ -96,6 +96,116 @@ var POPUP_TPL = *}); *``` */ + +/** + * @ngdoc demo + * @name $ionicPopup#simple + * @module popupSimple + * @javascript +angular.module('popupSimple', ['ionic']) +.controller('PopupCtrl', function($scope, $timeout, $q, $ionicPopup) { + $scope.showPopup = function() { + $scope.data = {} + + $ionicPopup.show({ + templateUrl: 'popup-template.html', + title: 'Enter Wi-Fi Password', + subTitle: 'Please use normal things', + scope: $scope, + buttons: [ + { text: 'Cancel', onTap: function(e) { return true; } }, + { + text: 'Save', + type: 'button-positive', + onTap: function(e) { + return $scope.data.wifi; + } + }, + ] + }).then(function(res) { + console.log('Tapped!', res); + }, function(err) { + console.log('Err:', err); + }, function(msg) { + console.log('message:', msg); + }); + + $timeout(function() { + $ionicPopup.confirm({ + title: 'Do you like ice cream?', + cancelText: 'No', + okText: 'Yes, of course' + }).then(function(res) { + console.log('Your love for ice cream:', res); + }); + }, 1000); + }; + + $scope.showConfirm = function() { + $ionicPopup.confirm({ + title: 'Consume Ice Cream', + content: 'Are you sure you want to eat this ice cream?' + }).then(function(res) { + if(res) { + console.log('You are sure'); + } else { + console.log('You are not sure'); + } + }); + }; + $scope.showPrompt = function() { + $ionicPopup.prompt({ + title: 'ID Check', + subTitle: 'What is your name?' + }).then(function(res) { + console.log('Your name is', res); + }); + }; + $scope.showPasswordPrompt = function() { + $ionicPopup.prompt({ + title: 'Password Check', + subTitle: 'Enter your secret password', + inputType: 'password', + inputPlaceholder: 'Your password' + }).then(function(res) { + console.log('Your name is', res); + }); + }; + $scope.showAlert = function() { + $ionicPopup.alert({ + title: 'Draft Saved', + content: 'Your Data has been saved!' + }).then(function(res) { + console.log('Your Data has been saved!'); + }, function(err) {}, + function(popup) { + console.log('Got popup', popup); + $timeout(function() { + popup.close(); + }, 1000); + }); + }; +}); + * @html + + + + + + + + + + + * + */ IonicModule .factory('$ionicPopup', [ '$ionicTemplateLoader',