Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                .container{:'ng-app' => 'modalTest',:'ng-controller' => 'dialogServiceTest'}
  .row
    .col-md-12
      %h1
        Dialog Service Demo 
        %small (with i18n capabilities)
      %p.text-muted 
        %small (Bootstrap 3.1.1, AngularJS 1.2.16, Angular UI Bootstrap 0.11.0, Angular-Translate)
      %p Demo of Angular dialog service using Bootstrap 3.1.1 with Angular &amp; Angular UI Bootstrap's modal service (0.11.0).
      %p
        As well as the use of 
        %a{:href => 'https://github.com/angular-translate'} Angular-Translate (https://github.com/angular-translate)
      %p
        This demo shows the ability to use different languages with your dialogs as well as switch lanugages on the fly (This works for the preset dialogs only, for the custom ones you need to set that up yourself - for obvious reasons).  You can also now set the size of the modal/dialog either small (sm) or large (lg), requires Bootstrap 3.1.1 and Angular-UI-Bootstrap 0.11.0.  In previous versions of the  "angular-dialog-service"
        %a{:href=>'https://github.com/m-e-conroy/angular-dialog-service'} (https://github.com/m-e-conroy/angular-dialog-service)
        the two way "binding" between a custom dialog and its calling controller was always decoupled, now the two way  "binding" can be retained by using the "dialogsProvider.useCopy(false)."
  .row
    .col-md-12
      %button.btn.btn-danger{:'ng-click'=>"launch('error')"} Error Dialog
      %button.btn.btn-primary{:'ng-click'=>"launch('wait')"} Wait Dialog
      %button.btn.btn-default{:'ng-click'=>"launch('notify')"} Notify Dialog
      %button.btn.btn-success{:'ng-click'=>"launch('confirm')"} Confirm Dialog
      %button.btn.btn-warning{:'ng-click'=>"launch('custom')"} Custom Dialog
      %button.btn.btn-warning{:'ng-click'=>"launch('custom2')"} Custom Dialog 2
  .row
    .col-md-12
      %br
      %p
        %strong Confirmation:
        {{confirmed}}
      %p
        %strong Name Enter(From Custom):
        {{name}}
      %p
        %strong Custom 2 Value:
        {{custom.val}}
      %p
        %strong Current Language:
        {{language}}
  .row
    .col-md-12
      %button.btn.btn-default{:'ng-click'=>"setLanguage('en-US')"} English
      %button.btn.btn-default{:'ng-click'=>"setLanguage('es')"} Spanish
              
            
!

CSS

              
                
              
            
!

JS

              
                angular.module('modalTest',['ui.bootstrap','dialogs.main','pascalprecht.translate'])
	.controller('dialogServiceTest',function($scope,$rootScope,$timeout,$translate,dialogs){
		
		//-- Variables --//
		
		$scope.lang = 'en-US';
		$scope.language = 'English';

		var _progress = 33;
		
		$scope.name = '';
		$scope.confirmed = 'No confirmation yet!';
		
		$scope.custom = {
			val: 'Initial Value'
		};
		
		//-- Listeners & Watchers --//

		$scope.$watch('lang',function(val,old){
			switch(val){
				case 'en-US':
					$scope.language = 'English';
					break;
				case 'es':
					$scope.language = 'Spanish';
					break;
			}
		});

		//-- Methods --//

		$scope.setLanguage = function(lang){
			$scope.lang = lang;
			$translate.use(lang);
		};

		$scope.launch = function(which){
			switch(which){
				case 'error':
					dialogs.error();
					break;
				case 'wait':
					var dlg = dialogs.wait(undefined,undefined,_progress);
					_fakeWaitProgress();
					break;
				case 'notify':
					dialogs.notify();
					break;
				case 'confirm':
					var dlg = dialogs.confirm();
					dlg.result.then(function(btn){
						$scope.confirmed = 'You confirmed "Yes."';
					},function(btn){
						$scope.confirmed = 'You confirmed "No."';
					});
					break;
				case 'custom':
					var dlg = dialogs.create('/dialogs/custom.html','customDialogCtrl',{},'lg');
					dlg.result.then(function(name){
						$scope.name = name;
					},function(){
						if(angular.equals($scope.name,''))
							$scope.name = 'You did not enter in your name!';
					});
					break;
				case 'custom2':
					var dlg = dialogs.create('/dialogs/custom2.html','customDialogCtrl2',$scope.custom,'lg');
					break;
			}
		}; // end launch
		
		var _fakeWaitProgress = function(){
			$timeout(function(){
				if(_progress < 100){
					_progress += 33;
					$rootScope.$broadcast('dialogs.wait.progress',{'progress' : _progress});
					_fakeWaitProgress();
				}else{
					$rootScope.$broadcast('dialogs.wait.complete');
				}
			},1000);
		};
	}) // end controller(dialogsServiceTest)
	
	.controller('customDialogCtrl',function($scope,$modalInstance,data){
		//-- Variables --//

		$scope.user = {name : ''};

		//-- Methods --//
		
		$scope.cancel = function(){
			$modalInstance.dismiss('Canceled');
		}; // end cancel
		
		$scope.save = function(){
			$modalInstance.close($scope.user.name);
		}; // end save
		
		$scope.hitEnter = function(evt){
			if(angular.equals(evt.keyCode,13) && !(angular.equals($scope.user.name,null) || angular.equals($scope.user.name,'')))
				$scope.save();
		};
	}) // end controller(customDialogCtrl)
	
	.controller('customDialogCtrl2',function($scope,$modalInstance,data){
		
		$scope.data = data;
		
		//-- Methods --//
		
		$scope.done = function(){
			$modalInstance.close($scope.data);
		}; // end done
		
	})
	
	.config(['dialogsProvider','$translateProvider',function(dialogsProvider,$translateProvider){
		dialogsProvider.useBackdrop('static');
		dialogsProvider.useEscClose(false);
		dialogsProvider.useCopy(false);
		dialogsProvider.setSize('sm');

		$translateProvider.translations('es',{
			DIALOGS_ERROR: "Error",
			DIALOGS_ERROR_MSG: "Se ha producido un error desconocido.",
			DIALOGS_CLOSE: "Cerca",
			DIALOGS_PLEASE_WAIT: "Espere por favor",
			DIALOGS_PLEASE_WAIT_ELIPS: "Espere por favor...",
			DIALOGS_PLEASE_WAIT_MSG: "Esperando en la operacion para completar.",
			DIALOGS_PERCENT_COMPLETE: "% Completado",
			DIALOGS_NOTIFICATION: "Notificacion",
			DIALOGS_NOTIFICATION_MSG: "Notificacion de aplicacion Desconocido.",
			DIALOGS_CONFIRMATION: "Confirmacion",
			DIALOGS_CONFIRMATION_MSG: "Se requiere confirmacion.",
			DIALOGS_OK: "Bueno",
			DIALOGS_YES: "Si",
			DIALOGS_NO: "No"
		});

		$translateProvider.preferredLanguage('en-US');
	}])

	.run(['$templateCache',function($templateCache){
  		$templateCache.put('/dialogs/custom.html','<div class="modal-header"><h4 class="modal-title"><span class="glyphicon glyphicon-star"></span> User\'s Name</h4></div><div class="modal-body"><ng-form name="nameDialog" novalidate role="form"><div class="form-group input-group-lg" ng-class="{true: \'has-error\'}[nameDialog.username.$dirty && nameDialog.username.$invalid]"><label class="control-label" for="course">Name:</label><input type="text" class="form-control" name="username" id="username" ng-model="user.name" ng-keyup="hitEnter($event)" required><span class="help-block">Enter your full name, first &amp; last.</span></div></ng-form></div><div class="modal-footer"><button type="button" class="btn btn-default" ng-click="cancel()">Cancel</button><button type="button" class="btn btn-primary" ng-click="save()" ng-disabled="(nameDialog.$dirty && nameDialog.$invalid) || nameDialog.$pristine">Save</button></div>');
  		$templateCache.put('/dialogs/custom2.html','<div class="modal-header"><h4 class="modal-title"><span class="glyphicon glyphicon-star"></span> Custom Dialog 2</h4></div><div class="modal-body"><label class="control-label" for="customValue">Custom Value:</label><input type="text" class="form-control" id="customValue" ng-model="data.val" ng-keyup="hitEnter($event)"><span class="help-block">Using "dialogsProvider.useCopy(false)" in your applications config function will allow data passed to a custom dialog to retain its two-way binding with the scope of the calling controller.</span></div><div class="modal-footer"><button type="button" class="btn btn-default" ng-click="done()">Done</button></div>')
	}]); 

              
            
!
999px

Console