@@ -30,6 +30,14 @@ angular.module('patternfly.filters', ['patternfly.select', 'ui.bootstrap']);
3030 * Module for formting related functionality, primarily filters.
3131 */
3232angular . module ( 'patternfly.form' , [ ] ) ;
33+ ; /**
34+ * @name patternfly
35+ *
36+ * @description
37+ * Modal module for patternfly.
38+ *
39+ */
40+ angular . module ( 'patternfly.modals' , [ 'ui.bootstrap.modal' , 'ui.bootstrap.tpls' ] ) ;
3341; /**
3442 * @name patternfly navigation
3543 *
@@ -57,6 +65,7 @@ angular.module('patternfly', [
5765 'patternfly.card' ,
5866 'patternfly.filters' ,
5967 'patternfly.form' ,
68+ 'patternfly.modals' ,
6069 'patternfly.navigation' ,
6170 'patternfly.notification' ,
6271 'patternfly.select' ,
@@ -3692,6 +3701,149 @@ angular.module('patternfly.form').directive('pfRemainingCharsCount', ["$timeout"
36923701 }
36933702 } ;
36943703} ] ) ;
3704+ ; /**
3705+ * @ngdoc directive
3706+ * @name patternfly.modals.directive:pfAboutModal
3707+ *
3708+ * @description
3709+ * Directive for rendering modal windows.
3710+ *
3711+ * @param {string= } additionalInfo Text explaining the version or copyright
3712+ * @param {string= } copyright Product copyright information
3713+ * @param {string= } imgAlt The alt text for the corner grahpic
3714+ * @param {string= } imgSrc The source for the corner grahpic
3715+ * @param {boolean= } isOpen Flag indicating that the modal should be opened
3716+ * @param {function= } onClose Function to call when modal is closed
3717+ * @param {object= } productInfo data for the modal:<br/>
3718+ * <ul style='list-style-type: none'>
3719+ * <li>.product - the product label
3720+ * <li>.version - the product version
3721+ * </ul>
3722+ * @param {string= } title The product title for the modal
3723+ *
3724+ * @example
3725+ <example module="patternfly.modals">
3726+ <file name="index.html">
3727+ <div ng-controller="ModalCtrl">
3728+ <button ng-click="open()" class="btn btn-default">Launch About Modal</button>
3729+ <div pf-about-modal is-open="isOpen" on-close="onClose()" additional-info="additionalInfo"
3730+ product-info="productInfo" title="title" copyright="copyright" img-alt="imgAlt" img-src="imgSrc"></div>
3731+ </div>
3732+ </file>
3733+ <file name="script.js">
3734+ angular.module('patternfly.modals').controller('ModalCtrl', function ($scope) {
3735+ $scope.additionalInfo = "Donec consequat dignissim neque, sed suscipit quam egestas in. Fusce bibendum " +
3736+ "laoreet lectus commodo interdum. Vestibulum odio ipsum, tristique et ante vel, iaculis placerat nulla. " +
3737+ "Suspendisse iaculis urna feugiat lorem semper, ut iaculis risus tempus.";
3738+ $scope.copyright = "Trademark and Copyright Information";
3739+ $scope.imgAlt = "Patternfly Symbol";
3740+ $scope.imgSrc = "img/logo-alt.svg";
3741+ $scope.title = "Product Title";
3742+ $scope.productInfo = [
3743+ { name: 'Version', value: '1.0.0.0.20160819142038_51be77c' },
3744+ { name: 'Server Name', value: 'Localhost' },
3745+ { name: 'User Name', value: 'admin' },
3746+ { name: 'User Role', value: 'Administrator' }];
3747+ $scope.open = function () {
3748+ $scope.isOpen = true;
3749+ }
3750+ $scope.onClose = function() {
3751+ $scope.isOpen = false;
3752+ }
3753+ });
3754+ </file>
3755+ </example>
3756+ */
3757+ angular . module ( 'patternfly.modals' )
3758+
3759+ . directive ( "pfAboutModalTransclude" , [ "$parse" , function ( $parse ) {
3760+ 'use strict' ;
3761+ return {
3762+ link : function ( scope , element , attrs ) {
3763+ element . append ( $parse ( attrs . pfAboutModalTransclude ) ( scope ) ) ;
3764+ }
3765+ } ;
3766+ } ] )
3767+
3768+ . directive ( 'pfAboutModal' , function ( ) {
3769+ 'use strict' ;
3770+ return {
3771+ restrict : 'A' ,
3772+ scope : {
3773+ additionalInfo : '=?' ,
3774+ copyright : '=?' ,
3775+ close : "&onClose" ,
3776+ imgAlt : '=?' ,
3777+ imgSrc : '=?' ,
3778+ isOpen : '=?' ,
3779+ productInfo : '=' ,
3780+ title : '=?'
3781+ } ,
3782+ templateUrl : 'modals/about-modal.html' ,
3783+ transclude : true ,
3784+ controller : [ '$scope' , '$modal' , '$transclude' , function ( $scope , $modal , $transclude ) {
3785+ if ( $scope . isOpen === undefined ) {
3786+ $scope . isOpen = false ;
3787+ }
3788+
3789+ // The ui-bootstrap modal only supports either template or templateUrl as a way to specify the content.
3790+ // When the content is retrieved, it is compiled and linked against the provided scope by the $modal service.
3791+ // Unfortunately, there is no way to provide transclusion there.
3792+ //
3793+ // The solution below embeds a placeholder directive (i.e., pfAboutModalTransclude) to append the transcluded DOM.
3794+ // The transcluded DOM is from a different location than the modal, so it needs to be handed over to the
3795+ // placeholder directive. Thus, we're passing the actual DOM, not the parsed HTML.
3796+ $scope . openModal = function ( ) {
3797+ $modal . open ( {
3798+ controller : [ '$scope' , '$modalInstance' , 'content' , function ( $scope , $modalInstance , content ) {
3799+ $scope . template = content ;
3800+ $scope . close = function ( ) {
3801+ $modalInstance . close ( ) ;
3802+ } ;
3803+ $scope . $watch (
3804+ function ( ) {
3805+ return $scope . isOpen ;
3806+ } ,
3807+ function ( newValue ) {
3808+ if ( newValue === false ) {
3809+ $modalInstance . close ( ) ;
3810+ }
3811+ }
3812+ ) ;
3813+ } ] ,
3814+ resolve : {
3815+ content : function ( ) {
3816+ var transcludedContent ;
3817+ $transclude ( function ( clone ) {
3818+ transcludedContent = clone ;
3819+ } ) ;
3820+ return transcludedContent ;
3821+ }
3822+ } ,
3823+ scope : $scope ,
3824+ templateUrl : "about-modal-template.html"
3825+ } )
3826+ . result . then (
3827+ function ( ) {
3828+ $scope . close ( ) ; // closed
3829+ } ,
3830+ function ( ) {
3831+ $scope . close ( ) ; // dismissed
3832+ }
3833+ ) ;
3834+ } ;
3835+ } ] ,
3836+ link : function ( scope , element , attrs ) {
3837+ // watching isOpen attribute to dispay modal when needed
3838+ var isOpenListener = scope . $watch ( 'isOpen' , function ( newVal , oldVal ) {
3839+ if ( newVal === true ) {
3840+ scope . openModal ( ) ;
3841+ }
3842+ } ) ;
3843+ scope . $on ( '$destroy' , isOpenListener ) ;
3844+ }
3845+ } ;
3846+ } ) ;
36953847; /**
36963848 * @ngdoc directive
36973849 * @name patternfly.navigation.directive:pfVerticalNavigation
@@ -8321,6 +8473,34 @@ angular.module('patternfly.views').directive('pfListView', ["$timeout", "$window
83218473 "<div class=form-group ng-class=\"{ 'has-error' : hasErrors() }\"><label for=\"{{ pfField }}\" class=\"control-label {{ pfLabelClass }}\">{{ pfLabel }}</label><div class=\"{{ pfInputClass }}\"><span ng-transclude></span> <span class=help-block ng-show=error.messages><ul><li ng-repeat=\"message in error.messages\">{{ message }}</li></ul></span></div></div>"
83228474 ) ;
83238475
8476+ } ] ) ;
8477+ ; angular . module ( 'patternfly.modals' ) . run ( [ '$templateCache' , function ( $templateCache ) {
8478+ 'use strict' ;
8479+
8480+ $templateCache . put ( 'modals/about-modal.html' ,
8481+ "<script type=text/ng-template id=about-modal-template.html><div class=\"about-modal-pf\">\n" +
8482+ " <div class=\"modal-header\">\n" +
8483+ " <button type=\"button\" class=\"close\" ng-click=\"close()\" aria-hidden=\"true\">\n" +
8484+ " <span class=\"pficon pficon-close\"></span>\n" +
8485+ " </button>\n" +
8486+ " </div>\n" +
8487+ " <div class=\"modal-body\">\n" +
8488+ " <h1 ng-if=\"title\">{{title}}</h1>\n" +
8489+ " <div ng-if=\"productInfo && productInfo.length > 0\" class=\"product-versions-pf\">\n" +
8490+ " <ul class=\"list-unstyled\">\n" +
8491+ " <li ng-repeat=\"info in productInfo\"><strong>{{info.name}}</strong> {{info.value}}</li>\n" +
8492+ " </ul>\n" +
8493+ " </div>\n" +
8494+ " <div pf-about-modal-transclude=\"template\" class=\"product-versions-pf\"></div>\n" +
8495+ " <div ng-if=\"additionalInfo\" class=\"product-versions-pf\">{{additionalInfo}}</div>\n" +
8496+ " <div ng-if=\"copyright\" class=\"trademark-pf\">{{copyright}}</div>\n" +
8497+ " </div>\n" +
8498+ " <div class=\"modal-footer\">\n" +
8499+ " <img ng-if=\"imgSrc\" ng-src=\"{{imgSrc}}\" alt=\"{{imgAlt}}\"/>\n" +
8500+ " </div>\n" +
8501+ " </div></script>"
8502+ ) ;
8503+
83248504} ] ) ;
83258505; angular . module ( 'patternfly.navigation' ) . run ( [ '$templateCache' , function ( $templateCache ) {
83268506 'use strict' ;
0 commit comments