all files / app/main/components/material-docs/demo-partials/toast/demoCustomUsage/ script.js

18.75% Statements 3/16
0% Branches 0/4
12.5% Functions 1/8
21.43% Lines 3/14
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49                                                                                            
(function() {
 
  var isDlgOpen;
 
  angular
    .module('toastDemo2', ['ngMaterial'])
    .controller('AppCtrl', function($scope, $mdToast) {
      $scope.showCustomToast = function() {
        $mdToast.show({
          hideDelay   : 3000,
          position    : 'top right',
          controller  : 'ToastCtrl',
          templateUrl : 'toast-template.html'
        });
      };
    })
    .controller('ToastCtrl', function($scope, $mdToast, $mdDialog) {
 
      $scope.closeToast = function() {
        if (isDlgOpen) return;
 
        $mdToast
          .hide()
          .then(function() {
            isDlgOpen = false;
          });
      };
 
      $scope.openMoreInfo = function(e) {
        if ( isDlgOpen ) return;
        isDlgOpen = true;
 
        $mdDialog
          .show($mdDialog
            .alert()
            .title('More info goes here.')
            .textContent('Something witty.')
            .ariaLabel('More info')
            .ok('Got it')
            .targetEvent(e)
          )
          .then(function() {
            isDlgOpen = false;
          })
      };
    });
 
})();