refactor(profilePage): use ui-bootrap for modal

pull/3/head
alex 2016-01-21 14:31:53 +03:00
parent 59adfd15a3
commit 8695b7a30b
5 changed files with 49 additions and 54 deletions

View File

@ -0,0 +1,19 @@
/**
* @author a.demeshko
* created on 21.01.2016
*/
(function () {
'use strict';
angular.module('BlurAdmin.pages.profile')
.controller('ProfileModalCtrl', ProfileModalCtrl);
/** @ngInject */
function ProfileModalCtrl($scope, $uibModalInstance) {
$scope.link = '';
$scope.ok = function () {
$uibModalInstance.close($scope.link);
};
}
})();

View File

@ -9,7 +9,7 @@
.controller('ProfilePageCtrl', ProfilePageCtrl); .controller('ProfilePageCtrl', ProfilePageCtrl);
/** @ngInject */ /** @ngInject */
function ProfilePageCtrl($scope, fileReader, $filter) { function ProfilePageCtrl($scope, fileReader, $filter, $uibModal) {
$scope.picture = $filter('profilePicture')('Nasta'); $scope.picture = $filter('profilePicture')('Nasta');
$scope.removePicture = function () { $scope.removePicture = function () {
@ -65,8 +65,14 @@
item.href = undefined; item.href = undefined;
}; };
$scope.showModal = function () { $scope.showModal = function (item) {
$('#profileModal').modal('show'); $uibModal.open({
animation: false,
controller: 'ProfileModalCtrl',
templateUrl: 'app/pages/profile/profileModal.html'
}).result.then(function (link) {
item.href = link;
});
}; };
$scope.getFile = function () { $scope.getFile = function () {

View File

@ -143,7 +143,7 @@
<div class="social-profiles row clearfix"> <div class="social-profiles row clearfix">
<div class="col-md-3 col-sm-4" ng-repeat="item in socialProfiles"> <div class="col-md-3 col-sm-4" ng-repeat="item in socialProfiles">
<a class="sn-link" href ng-click="showModal()" ng-if="!item.href"> <a class="sn-link" href ng-click="showModal(item)" ng-if="!item.href">
<i class="socicon {{ item.icon }}"></i> <i class="socicon {{ item.icon }}"></i>
<span>{{ item.name }}</span> <span>{{ item.name }}</span>
</a> </a>
@ -215,4 +215,3 @@
</div> </div>
</div> </div>
</div> </div>
<profile-modal></profile-modal>

View File

@ -1,26 +0,0 @@
/**
* @author v.lugovsky
* created on 16.12.2015
*/
(function () {
'use strict';
angular.module('BlurAdmin.pages.profile')
.service('profileModal', profileModal);
/** @ngInject */
function profileModal() {
return {
restrict: 'EA',
replace: true,
link: function ($scope) {
$scope.link = "";
$scope.bindProfile = function(){
$scope.link = "";
};
},
templateUrl: 'app/pages/profile/profileModal.html'
};
}
})();

View File

@ -1,8 +1,6 @@
<div class="modal profile-modal fade" id="profileModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-content">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> <button type="button" class="close" ng-click="$dismiss()" aria-label="Close">
<em class="ion-ios-close-empty sn-link-close"></em> <em class="ion-ios-close-empty sn-link-close"></em>
</button> </button>
<h4 class="modal-title" id="myModalLabel">Add Account</h4> <h4 class="modal-title" id="myModalLabel">Add Account</h4>
@ -10,14 +8,13 @@
<form name="linkForm"> <form name="linkForm">
<div class="modal-body"> <div class="modal-body">
<p>Paste a link to your profile into the box below</p> <p>Paste a link to your profile into the box below</p>
<div class="form-group"> <div class="form-group">
<input type="text" class="form-control" placeholder="Link to Profile" ng-model="link"> <input type="text" class="form-control" placeholder="Link to Profile" ng-model="link">
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal" ng-click="bindProfile()">Save changes</button> <button type="button" class="btn btn-primary" ng-click="ok(link)">Save changes</button>
</div> </div>
</form> </form>
</div>
</div>
</div> </div>