Skip to content

Commit 3b8ea85

Browse files
author
jspdown
committed
Animate modal. Fix #23
1 parent 6c1f67e commit 3b8ea85

File tree

3 files changed

+44
-33
lines changed

3 files changed

+44
-33
lines changed

src/modal/docs/controllers.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
var modalApp = angular.module('modalApp', ['angularify.semantic.modal']);
1+
angular
2+
.module('modalApp', ['angularify.semantic.modal'])
3+
.controller('RootCtrl', RootCtrl);
24

3-
function RootCtrl ($scope) {
4-
$scope.show_modal = true;
5+
function RootCtrl($scope) {
6+
$scope.show_modal = false;
57

6-
$scope.close_modal = function(){
7-
$scope.show_modal = false;
8-
}
8+
$scope.open_modal = function () {
9+
$scope.show_modal = true;
10+
};
11+
12+
$scope.close_modal = function (){
13+
$scope.show_modal = false;
14+
};
915
}

src/modal/docs/demo.html

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,38 @@
33
<head>
44
<meta charset="utf-8" />
55
<title>Semantic UI + Angular.JS</title>
6-
<link href="../../../bower_components/semantic/build/packaged/css/semantic.min.css" rel="stylesheet" type="text/css" />
6+
<link href="../../../bower_components/semantic/dist/semantic.min.css" rel="stylesheet" type="text/css" />
77
</head>
88
<body ng-controller="RootCtrl">
9+
<button class="ui primary button" ng-click="open_modal()">Open</button>
910
<modal ng-model="show_modal">
10-
<i class="close icon" ng-click="close_modal()"></i>
11+
<i class="close icon"></i>
1112
<div class="header">
12-
Change Your Homepage
13+
Profile Picture
1314
</div>
1415
<div class="content">
15-
<div class="left">
16-
<i class="home icon"></i>
16+
<div class="ui medium image">
17+
<img src="http://fakeimg.pl/250x250">
1718
</div>
18-
<div class="right">
19-
<p>Are you sure you want to change your homepage to <b>Poodle.com</b>?</p>
19+
<div class="description">
20+
<div class="ui header">We've auto-chosen a profile image for you.</div>
21+
<p>We've grabbed the following image from the <a href="https://www.gravatar.com" target="_blank">gravatar</a> image associated with your registered e-mail address.</p>
22+
<p>Is it okay to use this photo?</p>
2023
</div>
2124
</div>
2225
<div class="actions">
23-
<div class="two fluid ui buttons">
24-
<div class="ui negative labeled icon button">
25-
<i class="remove icon"></i>
26-
No
27-
</div>
28-
<div class="ui positive right labeled icon button">
29-
Yes
30-
<i class="checkmark icon"></i>
31-
</div>
26+
<div class="ui black button">
27+
Nope
28+
</div>
29+
<div class="ui positive right labeled icon button">
30+
Yep, that's me
31+
<i class="checkmark icon"></i>
3232
</div>
3333
</div>
3434
</modal>
35+
<script src="../../../bower_components/jquery/dist/jquery.min.js"></script>
3536
<script src="../../../bower_components/angular/angular.min.js" type="text/javascript"></script>
36-
<script src="../../angularify.semantic.js" type="text/javascript"></script>
37+
<script src="../../../bower_components/semantic/dist/semantic.min.js" type="text/javascript"></script>
3738
<script src="../modal.js" type="text/javascript"></script>
3839
<script src="controllers.js" type="text/javascript"></script>
3940
</body>

src/modal/modal.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,22 @@ angular.module('angularify.semantic.modal', [])
44

55
.directive('modal', function () {
66
return {
7-
restrict: "E",
7+
restrict: 'E',
88
replace: true,
99
transclude: true,
10-
scope: {
11-
model: '=ngModel'
12-
},
13-
template: "<div class=\"ui dimmer page\" ng-class=\"{ active: model }\">" +
14-
"<div class=\"ui test modal transition visible\" style=\"margin-top: -189px;\" ng-transclude>" +
15-
"</div>" +
16-
"</div>",
17-
link: function (scope, element, attrs) {
18-
10+
require: 'ngModel',
11+
template: '<div class="ui modal" ng-transclude></div>',
12+
link: function (scope, element, attrs, ngModel) {
13+
element.modal({
14+
onHide: function () {
15+
ngModel.$setViewValue(false);
16+
}
17+
});
18+
scope.$watch(function () {
19+
return ngModel.$modelValue;
20+
}, function (modelValue){
21+
element.modal(modelValue ? 'show' : 'hide');
22+
});
1923
}
2024
}
2125
});

0 commit comments

Comments
 (0)