From: Tim Otten Date: Thu, 12 Feb 2015 19:41:19 +0000 (-0800) Subject: crmUiAlert - Add wrapper for embedding Angular content in an alert. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=69a65adc0d1f828ab03cc9e31aaeae33e22b538d;p=civicrm-core.git crmUiAlert - Add wrapper for embedding Angular content in an alert. --- diff --git a/js/angular-crm-ui.js b/js/angular-crm-ui.js index 0527396f20..436b6e2c42 100644 --- a/js/angular-crm-ui.js +++ b/js/angular-crm-ui.js @@ -23,6 +23,37 @@ }; }) + // Examples: + // crmUiAlert({text: 'My text', title: 'My title', type: 'error'}); + // crmUiAlert({template: 'Hello', scope: $scope.$new()}); + // var h = crmUiAlert({templateUrl: '~/crmFoo/alert.html', scope: $scope.$new()}); + // ... h.close(); ... + .service('crmUiAlert', function($compile, $rootScope, $templateRequest, $q) { + var count = 0; + return function crmUiAlert(params) { + var id = 'crmUiAlert_' + (++count); + var tpl = null; + if (params.templateUrl) { + tpl = $templateRequest(params.templateUrl); + } + else if (params.template) { + tpl = params.template; + } + if (tpl) { + params.text = '
'; // temporary stub + } + var result = CRM.alert(params.text, params.title, params.type, params.options); + if (tpl) { + $q.when(tpl, function(html) { + var scope = params.scope || $rootScope.$new(); + var linker = $compile(html); + $('#' + id).append($(linker(scope))); + }); + } + return result; + }; + }) + // Display a date widget. // example: // example: