mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 15:07:13 +08:00
Working modal stuff
This commit is contained in:
@ -18,11 +18,7 @@ module.exports = function(grunt) {
|
|||||||
'js/utils/**/*.js',
|
'js/utils/**/*.js',
|
||||||
|
|
||||||
// Views
|
// Views
|
||||||
'js/views/navBarView.js',
|
'js/views/**/*.js',
|
||||||
'js/views/headerBarView.js',
|
|
||||||
'js/views/sideMenuView.js',
|
|
||||||
'js/views/tabBarView.js',
|
|
||||||
'js/views/toggleView.js',
|
|
||||||
|
|
||||||
// Controllers
|
// Controllers
|
||||||
'js/controllers/**/*.js'
|
'js/controllers/**/*.js'
|
||||||
|
|||||||
38
dist/ionic-angular.js
vendored
38
dist/ionic-angular.js
vendored
@ -2,6 +2,44 @@ angular.module('ionic.ui', ['ionic.ui.content', 'ionic.ui.tabs', 'ionic.ui.nav',
|
|||||||
;
|
;
|
||||||
;
|
;
|
||||||
;
|
;
|
||||||
|
angular.module('ionic.service.modal', ['ionic.service'])
|
||||||
|
|
||||||
|
|
||||||
|
.factory('Modal', ['$rootScope', '$document', '$compile', 'TemplateLoader', function($rootScope, $document, $compile, TemplateLoader) {
|
||||||
|
return {
|
||||||
|
/**
|
||||||
|
* Load a modal with the given template string.
|
||||||
|
*
|
||||||
|
* A new isolated scope will be created for the
|
||||||
|
* modal and the new element will be appended into the body.
|
||||||
|
*/
|
||||||
|
fromTemplate: function(templateString) {
|
||||||
|
// Create a new isolated scope for the modal
|
||||||
|
var scope = $rootScope.$new(true);
|
||||||
|
|
||||||
|
// Compile the template
|
||||||
|
var element = $compile(templateString)(scope);
|
||||||
|
$document[0].body.appendChild(element[0]);
|
||||||
|
|
||||||
|
return new ionic.views.Modal({el: element[0] });
|
||||||
|
},
|
||||||
|
fromTemplateUrl: function(url, cb) {
|
||||||
|
TemplateLoader.load(url).then(function(templateString) {
|
||||||
|
// Create a new isolated scope for the modal
|
||||||
|
var scope = $rootScope.$new(true);
|
||||||
|
|
||||||
|
// Compile the template
|
||||||
|
var element = $compile(templateString)(scope);
|
||||||
|
$document[0].body.appendChild(element[0]);
|
||||||
|
|
||||||
|
var modal = new ionic.views.Modal({ el: element[0] });
|
||||||
|
|
||||||
|
cb(modal);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}]);
|
||||||
|
;
|
||||||
angular.module('ionic.service', [])
|
angular.module('ionic.service', [])
|
||||||
|
|
||||||
.factory('TemplateLoader', ['$q', '$http', '$templateCache', function($q, $http, $templateCache) {
|
.factory('TemplateLoader', ['$q', '$http', '$templateCache', function($q, $http, $templateCache) {
|
||||||
|
|||||||
26
dist/ionic-ios7.css
vendored
26
dist/ionic-ios7.css
vendored
@ -2271,22 +2271,22 @@ a.button {
|
|||||||
transition: transform .25s ease-in-out, opacity 1ms .25s;
|
transition: transform .25s ease-in-out, opacity 1ms .25s;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
.slide-in-up.enter {
|
@-webkit-keyframes slide-in-up {
|
||||||
-webkit-transition: -webkit-transform 0.4s, opacity 0.4s;
|
0% {
|
||||||
transition: transform 0.4s, opacity 0.4s;
|
opacity: 0;
|
||||||
-webkit-transform: translate3d(0, 100%, 0);
|
|
||||||
transform: translate3d(0, 100%, 0);
|
|
||||||
-webkit-transition-timing-function: cubic-bezier(0.1, 0.7, 0.1, 1); }
|
|
||||||
.slide-in-up.enter-active {
|
|
||||||
-webkit-transform: translate3d(0, 0, 0);
|
|
||||||
transform: translate3d(0, 0, 0); }
|
|
||||||
.slide-in-up.leave {
|
|
||||||
-webkit-transition: -webkit-transform 0.25s, opacity 0.25s;
|
|
||||||
transition: transform 0.25s, opacity 0.25s; }
|
|
||||||
.slide-in-up.leave-active {
|
|
||||||
-webkit-transform: translate3d(0, 100%, 0);
|
-webkit-transform: translate3d(0, 100%, 0);
|
||||||
transform: translate3d(0, 100%, 0); }
|
transform: translate3d(0, 100%, 0); }
|
||||||
|
|
||||||
|
100% {
|
||||||
|
opacity: 1;
|
||||||
|
-webkit-transform: translate3d(0, 0, 0);
|
||||||
|
transform: translate3d(0, 0, 0); } }
|
||||||
|
|
||||||
|
.slide-in-up.active {
|
||||||
|
animation: slide-in-up 0.5s;
|
||||||
|
-webkit-animation: slide-in-up 0.5s;
|
||||||
|
-webkit-animation-timing-function: cubic-bezier(0.1, 0.7, 0.1, 1); }
|
||||||
|
|
||||||
@keyframes fadein {
|
@keyframes fadein {
|
||||||
from {
|
from {
|
||||||
opacity: 0; }
|
opacity: 0; }
|
||||||
|
|||||||
26
dist/ionic.css
vendored
26
dist/ionic.css
vendored
@ -2323,22 +2323,22 @@ a.button {
|
|||||||
transition: transform .25s ease-in-out, opacity 1ms .25s;
|
transition: transform .25s ease-in-out, opacity 1ms .25s;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
.slide-in-up.enter {
|
@-webkit-keyframes slide-in-up {
|
||||||
-webkit-transition: -webkit-transform 0.4s, opacity 0.4s;
|
0% {
|
||||||
transition: transform 0.4s, opacity 0.4s;
|
opacity: 0;
|
||||||
-webkit-transform: translate3d(0, 100%, 0);
|
|
||||||
transform: translate3d(0, 100%, 0);
|
|
||||||
-webkit-transition-timing-function: cubic-bezier(0.1, 0.7, 0.1, 1); }
|
|
||||||
.slide-in-up.enter-active {
|
|
||||||
-webkit-transform: translate3d(0, 0, 0);
|
|
||||||
transform: translate3d(0, 0, 0); }
|
|
||||||
.slide-in-up.leave {
|
|
||||||
-webkit-transition: -webkit-transform 0.25s, opacity 0.25s;
|
|
||||||
transition: transform 0.25s, opacity 0.25s; }
|
|
||||||
.slide-in-up.leave-active {
|
|
||||||
-webkit-transform: translate3d(0, 100%, 0);
|
-webkit-transform: translate3d(0, 100%, 0);
|
||||||
transform: translate3d(0, 100%, 0); }
|
transform: translate3d(0, 100%, 0); }
|
||||||
|
|
||||||
|
100% {
|
||||||
|
opacity: 1;
|
||||||
|
-webkit-transform: translate3d(0, 0, 0);
|
||||||
|
transform: translate3d(0, 0, 0); } }
|
||||||
|
|
||||||
|
.slide-in-up.active {
|
||||||
|
animation: slide-in-up 0.5s;
|
||||||
|
-webkit-animation: slide-in-up 0.5s;
|
||||||
|
-webkit-animation-timing-function: cubic-bezier(0.1, 0.7, 0.1, 1); }
|
||||||
|
|
||||||
@keyframes fadein {
|
@keyframes fadein {
|
||||||
from {
|
from {
|
||||||
opacity: 0; }
|
opacity: 0; }
|
||||||
|
|||||||
74
dist/ionic.js
vendored
74
dist/ionic.js
vendored
@ -1731,6 +1731,51 @@ window.ionic = {
|
|||||||
})(window.ionic);
|
})(window.ionic);
|
||||||
;
|
;
|
||||||
|
|
||||||
|
(function(ionic) {
|
||||||
|
|
||||||
|
ionic.views.HeaderBar = function(opts) {
|
||||||
|
this.el = opts.el;
|
||||||
|
|
||||||
|
this._titleEl = this.el.querySelector('.title');
|
||||||
|
};
|
||||||
|
|
||||||
|
ionic.views.HeaderBar.prototype = {
|
||||||
|
resizeTitle: function() {
|
||||||
|
var e, j, i,
|
||||||
|
title,
|
||||||
|
titleWidth,
|
||||||
|
children = this.el.children;
|
||||||
|
|
||||||
|
for(i = 0, j = children.length; i < j; i++) {
|
||||||
|
e = children[i];
|
||||||
|
if(/h\d/.test(e.nodeName.toLowerCase())) {
|
||||||
|
title = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
titleWidth = title.offsetWidth;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
})(ionic);
|
||||||
|
;
|
||||||
|
(function(ionic) {
|
||||||
|
ionic.views.Modal = function(opts) {
|
||||||
|
this.el = opts.el;
|
||||||
|
};
|
||||||
|
|
||||||
|
ionic.views.Modal.prototype = {
|
||||||
|
show: function() {
|
||||||
|
this.el.classList.add('active');
|
||||||
|
},
|
||||||
|
hide: function() {
|
||||||
|
this.el.classList.remove('active');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
})(ionic);
|
||||||
|
;
|
||||||
|
|
||||||
(function(ionic) {
|
(function(ionic) {
|
||||||
|
|
||||||
ionic.views.NavBar = function(opts) {
|
ionic.views.NavBar = function(opts) {
|
||||||
@ -1786,35 +1831,6 @@ window.ionic = {
|
|||||||
})(ionic);
|
})(ionic);
|
||||||
;
|
;
|
||||||
|
|
||||||
(function(ionic) {
|
|
||||||
|
|
||||||
ionic.views.HeaderBar = function(opts) {
|
|
||||||
this.el = opts.el;
|
|
||||||
|
|
||||||
this._titleEl = this.el.querySelector('.title');
|
|
||||||
};
|
|
||||||
|
|
||||||
ionic.views.HeaderBar.prototype = {
|
|
||||||
resizeTitle: function() {
|
|
||||||
var e, j, i,
|
|
||||||
title,
|
|
||||||
titleWidth,
|
|
||||||
children = this.el.children;
|
|
||||||
|
|
||||||
for(i = 0, j = children.length; i < j; i++) {
|
|
||||||
e = children[i];
|
|
||||||
if(/h\d/.test(e.nodeName.toLowerCase())) {
|
|
||||||
title = e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
titleWidth = title.offsetWidth;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
})(ionic);
|
|
||||||
;
|
|
||||||
|
|
||||||
(function(ionic) {
|
(function(ionic) {
|
||||||
|
|
||||||
ionic.views.SideMenu = function(opts) {
|
ionic.views.SideMenu = function(opts) {
|
||||||
|
|||||||
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#splash-view, #signup-view {
|
#splash-view, #signup-view {
|
||||||
background: url('../img/splash.png') no-repeat transparent;
|
background: url('../img/splash.png') no-repeat transparent;
|
||||||
background-size: contain;
|
background-size: cover;
|
||||||
}
|
}
|
||||||
|
|
||||||
#signup-bottom {
|
#signup-bottom {
|
||||||
|
|||||||
@ -38,7 +38,6 @@
|
|||||||
<!-- Splash -->
|
<!-- Splash -->
|
||||||
<script id="splash.html" type="text/ng-template">
|
<script id="splash.html" type="text/ng-template">
|
||||||
<div id="splash-view" class="view fade-in" nav-content nav-bar="false">
|
<div id="splash-view" class="view fade-in" nav-content nav-bar="false">
|
||||||
<img src="img/logo.svg" class="ionic-logo">
|
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -52,26 +51,26 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<label class="input-wrapper row">
|
<label class="input-wrapper row">
|
||||||
<span class="input-label col-xs-4">Full name</span>
|
<span class="input-label col-xs-3">Full name</span>
|
||||||
<input class="col-xs-8" type="text" placeholder="" ng-model="signupForm.name" required>
|
<input class="col-xs-8" type="text" placeholder="" ng-model="signupForm.name" required>
|
||||||
</label>
|
</label>
|
||||||
<label class="input-wrapper row">
|
<label class="input-wrapper row">
|
||||||
<span class="input-label col-xs-4">Email</span>
|
<span class="input-label col-xs-3">Email</span>
|
||||||
<input class="col-xs-8" type="email" placeholder="" ng-model="signupForm.email" required>
|
<input class="col-xs-8" type="email" placeholder="" ng-model="signupForm.email" required>
|
||||||
</label>
|
</label>
|
||||||
<label class="input-wrapper row">
|
<label class="input-wrapper row">
|
||||||
<span class="input-label col-xs-4">Password</span>
|
<span class="input-label col-xs-3">Password</span>
|
||||||
<input class="col-xs-8" type="password" placeholder="" ng-model="signupForm.password" required>
|
<input class="col-xs-8" type="password" placeholder="" ng-model="signupForm.password" required>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<button type="submit" class="button button-primary button-block">Get derp</button>
|
<button type="submit" class="button button-primary button-block">Get derp'n</button>
|
||||||
<div id="signup-error" ng-show="signupError">Unable to signup, please try again.</div>
|
<div id="signup-error" ng-show="signupError">Unable to signup, please try again.</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<div id="signup-bottom">
|
<div id="signup-bottom">
|
||||||
<h3>Already have an account?</h3>
|
<h3>Already have an account?</h3>
|
||||||
<button class="button button-clear button-block">Sign in</button>
|
<button ng-click="showLogin()" class="button button-clear button-block">Sign in</button>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
@ -79,8 +78,12 @@
|
|||||||
|
|
||||||
<!-- Login -->
|
<!-- Login -->
|
||||||
<script id="login.html" type="text/ng-template">
|
<script id="login.html" type="text/ng-template">
|
||||||
<div title="Login" id="login-view" class="view" nav-content ng-controller="LoginCtrl">
|
<div id="login-view" class="modal slide-in-up" ng-controller="LoginCtrl">
|
||||||
<main class="content padded">
|
<header class="bar bar-header bar-success">
|
||||||
|
<h1 class="title">Log in</h1>
|
||||||
|
<button class="button">Close</a>
|
||||||
|
</header>
|
||||||
|
<main class="content padded has-header">
|
||||||
<form class="form-horizontal" ng-submit="tryLogin(loginForm)">
|
<form class="form-horizontal" ng-submit="tryLogin(loginForm)">
|
||||||
<div class="input-group inset">
|
<div class="input-group inset">
|
||||||
<label class="input-wrapper row">
|
<label class="input-wrapper row">
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
angular.module('ionic.todo.controllers', ['ionic.todo', 'firebase'])
|
angular.module('ionic.todo.controllers', ['ionic.todo', 'ionic.service.modal', 'firebase'])
|
||||||
|
|
||||||
// The main controller for the application
|
// The main controller for the application
|
||||||
.controller('TodoCtrl', function($scope, $rootScope, AuthService) {
|
.controller('TodoCtrl', function($scope, $rootScope, AuthService) {
|
||||||
@ -45,12 +45,19 @@ angular.module('ionic.todo.controllers', ['ionic.todo', 'firebase'])
|
|||||||
})
|
})
|
||||||
|
|
||||||
// The signup form controller
|
// The signup form controller
|
||||||
.controller('SignupCtrl', function($scope, AuthService) {
|
.controller('SignupCtrl', function($scope, AuthService, Modal) {
|
||||||
$scope.signupForm = {};
|
$scope.signupForm = {};
|
||||||
|
|
||||||
|
Modal.fromTemplateUrl('login.html', function(modal) {
|
||||||
|
$scope.loginModal = modal;
|
||||||
|
});
|
||||||
|
|
||||||
$scope.trySignup = function(data) {
|
$scope.trySignup = function(data) {
|
||||||
AuthService.signup(data.email, data.password);
|
AuthService.signup(data.email, data.password);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.showLogin = function() {
|
||||||
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
.controller('ProjectsCtrl', function($scope, angularFire, FIREBASE_URL) {
|
.controller('ProjectsCtrl', function($scope, angularFire, FIREBASE_URL) {
|
||||||
|
|||||||
37
js/ext/angular/src/service/ionicModal.js
vendored
Normal file
37
js/ext/angular/src/service/ionicModal.js
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
angular.module('ionic.service.modal', ['ionic.service'])
|
||||||
|
|
||||||
|
|
||||||
|
.factory('Modal', ['$rootScope', '$document', '$compile', 'TemplateLoader', function($rootScope, $document, $compile, TemplateLoader) {
|
||||||
|
return {
|
||||||
|
/**
|
||||||
|
* Load a modal with the given template string.
|
||||||
|
*
|
||||||
|
* A new isolated scope will be created for the
|
||||||
|
* modal and the new element will be appended into the body.
|
||||||
|
*/
|
||||||
|
fromTemplate: function(templateString) {
|
||||||
|
// Create a new isolated scope for the modal
|
||||||
|
var scope = $rootScope.$new(true);
|
||||||
|
|
||||||
|
// Compile the template
|
||||||
|
var element = $compile(templateString)(scope);
|
||||||
|
$document[0].body.appendChild(element[0]);
|
||||||
|
|
||||||
|
return new ionic.views.Modal({el: element[0] });
|
||||||
|
},
|
||||||
|
fromTemplateUrl: function(url, cb) {
|
||||||
|
TemplateLoader.load(url).then(function(templateString) {
|
||||||
|
// Create a new isolated scope for the modal
|
||||||
|
var scope = $rootScope.$new(true);
|
||||||
|
|
||||||
|
// Compile the template
|
||||||
|
var element = $compile(templateString)(scope);
|
||||||
|
$document[0].body.appendChild(element[0]);
|
||||||
|
|
||||||
|
var modal = new ionic.views.Modal({ el: element[0] });
|
||||||
|
|
||||||
|
cb(modal);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}]);
|
||||||
17
js/ext/angular/test/service/ionicModal.unit.js
Normal file
17
js/ext/angular/test/service/ionicModal.unit.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
describe('Ionic Modal', function() {
|
||||||
|
var modal, q;
|
||||||
|
|
||||||
|
beforeEach(module('ionic.ui.modal'));
|
||||||
|
|
||||||
|
beforeEach(inject(function(Modal, $q) {
|
||||||
|
q = $q;
|
||||||
|
modal = Modal;
|
||||||
|
}));
|
||||||
|
|
||||||
|
iit('Should show', function() {
|
||||||
|
var template = '<div class="modal"></div>';
|
||||||
|
var deferred = q.defer();
|
||||||
|
modal.fromTemplate(template);
|
||||||
|
deferred.resolve(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
15
js/views/modalView.js
Normal file
15
js/views/modalView.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
(function(ionic) {
|
||||||
|
ionic.views.Modal = function(opts) {
|
||||||
|
this.el = opts.el;
|
||||||
|
};
|
||||||
|
|
||||||
|
ionic.views.Modal.prototype = {
|
||||||
|
show: function() {
|
||||||
|
this.el.classList.add('active');
|
||||||
|
},
|
||||||
|
hide: function() {
|
||||||
|
this.el.classList.remove('active');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
})(ionic);
|
||||||
@ -9,33 +9,23 @@ $bezier-function: cubic-bezier(.1, .7, .1, 1);
|
|||||||
transition: transform .25s ease-in-out, opacity 1ms .25s;
|
transition: transform .25s ease-in-out, opacity 1ms .25s;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
@-webkit-keyframes slide-in-up {
|
||||||
.slide-in-up {
|
0% {
|
||||||
&.enter {
|
opacity: 0;
|
||||||
-webkit-transition: -webkit-transform .4s, opacity .4s;
|
|
||||||
transition: transform .4s, opacity .4s;
|
|
||||||
|
|
||||||
-webkit-transform: translate3d(0, 100%, 0);
|
-webkit-transform: translate3d(0, 100%, 0);
|
||||||
transform: translate3d(0, 100%, 0);
|
transform: translate3d(0, 100%, 0);
|
||||||
|
|
||||||
-webkit-transition-timing-function: $bezier-function;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
100% {
|
||||||
&.enter-active {
|
opacity: 1;
|
||||||
-webkit-transform: translate3d(0, 0, 0);
|
-webkit-transform: translate3d(0, 0, 0);
|
||||||
transform: translate3d(0, 0, 0);
|
transform: translate3d(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
&.leave {
|
|
||||||
-webkit-transition: -webkit-transform .25s, opacity .25s;
|
|
||||||
transition: transform .25s, opacity .25s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&.leave-active {
|
.slide-in-up.active {
|
||||||
-webkit-transform: translate3d(0, 100%, 0);
|
animation: slide-in-up 0.5s;
|
||||||
transform: translate3d(0, 100%, 0);
|
-webkit-animation: slide-in-up 0.5s;
|
||||||
}
|
-webkit-animation-timing-function: $bezier-function;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes fadein {
|
@keyframes fadein {
|
||||||
|
|||||||
Reference in New Issue
Block a user