(function () {
'use strict';
var bootstrapModule = angular.module('common.bootstrap', ['ui.bootstrap']);
bootstrapModule.factory('bootstrap.dialog', ['$modal', '$templateCache', modalDialog]);
function modalDialog($modal, $templateCache) {
var service = {
deleteDialog: deleteDialog,
confirmationDialog: confirmationDialog
};
$templateCache.put('modalDialog.tpl.html',
'
');
return service;
function deleteDialog(itemName) {
var title = 'Confirm Delete';
itemName = itemName || 'item';
var msg = 'Delete ' + itemName + '?';
return confirmationDialog(title, msg);
}
function confirmationDialog(title, msg, okText, cancelText) {
var modalOptions = {
templateUrl: 'modalDialog.tpl.html',
controller: ModalInstance,
keyboard: true,
resolve: {
options: function () {
return {
title: title,
message: msg,
okText: okText,
cancelText: cancelText
};
}
}
};
return $modal.open(modalOptions).result;
}
}
var ModalInstance = ['$scope', '$modalInstance', 'options',
function ($scope, $modalInstance, options) {
$scope.title = options.title || 'Title';
$scope.message = options.message || '';
$scope.okText = options.okText || 'OK';
$scope.cancelText = options.cancelText || 'Cancel';
$scope.ok = function () { $modalInstance.close('ok'); };
$scope.cancel = function () { $modalInstance.dismiss('cancel'); };
}];
})();