angular-cn/public/resources/js/directives/bio.js

47 lines
1.9 KiB
JavaScript
Raw Normal View History

2015-05-01 10:40:25 -04:00
angularIO.directive('biocard', function($rootScope, $timeout, $mdDialog) {
2015-05-01 09:48:52 -04:00
return {
restrict: 'A',
scope: {},
link: function (scope, element, attrs) {
2015-05-01 10:40:25 -04:00
scope.name = element.attr('data-name');
scope.bio = element.attr('data-bio');
scope.pic = element.attr('data-pic');
scope.twitter = element.attr('data-twitter');
scope.website = element.attr('data-website');
scope.$twitter = scope.twitter !== 'undefined' ? '<a class="button button-subtle button-small" href="https://twitter.com/' + element.attr('data-twitter') + '" md-button>Twitter</a>' : '';
scope.$website = scope.website !== 'undefined' ? '<a class="button button-subtle button-small" href="' + element.attr('data-website') + '" md-button>Website</a>' : '';
2015-05-01 09:48:52 -04:00
2015-05-01 10:40:25 -04:00
element.on('click', function($event) {
2015-05-01 09:48:52 -04:00
$mdDialog.show({
parent: angular.element(document.body),
targetEvent: $event,
template:
'<md-dialog class="modal" aria-label="List dialog">' +
' <md-content>' +
2015-05-01 10:40:25 -04:00
' <img class="left" src="' + scope.pic + '" />' +
' <h3 class="text-headline">' + scope.name + '</h3>' +
' <div class="modal-social">' + scope.$twitter + scope.$website + '</div>' +
' <p class="text-body">' + scope.bio + '</p>' +
2015-05-01 09:48:52 -04:00
' </md-content>' +
' <div class="md-actions">' +
' <md-button ng-click="closeDialog()">' +
' Close Bio' +
' </md-button>' +
' </div>' +
'</md-dialog>',
locals: {
2015-05-01 10:40:25 -04:00
items: scope.items
2015-05-01 09:48:52 -04:00
},
controller: DialogController
});
2015-05-01 10:40:25 -04:00
});
2015-05-01 09:48:52 -04:00
function DialogController(scope, $mdDialog, items) {
scope.items = items;
scope.closeDialog = function() {
$mdDialog.hide();
};
}
}
};
});