2014-06-18 11:09:04 -04:00
|
|
|
define(function(require) {
|
2013-11-14 14:44:57 -05:00
|
|
|
'use strict';
|
|
|
|
|
2014-06-18 11:09:04 -04:00
|
|
|
var axe = require('axe');
|
|
|
|
|
2013-11-14 14:44:57 -05:00
|
|
|
var er = {};
|
|
|
|
er.attachHandler = function(scope) {
|
2014-04-23 06:20:46 -04:00
|
|
|
scope.onError = function(options) {
|
2013-11-14 14:44:57 -05:00
|
|
|
if (!options) {
|
2014-02-21 10:22:33 -05:00
|
|
|
scope.$apply();
|
2013-11-14 14:44:57 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-06-18 11:09:04 -04:00
|
|
|
axe.error((options.errMsg || options.message) + (options.stack ? ('\n' + options.stack) : ''));
|
2013-11-14 14:44:57 -05:00
|
|
|
|
|
|
|
scope.state.dialog = {
|
|
|
|
open: true,
|
|
|
|
title: options.title || 'Error',
|
2014-05-23 04:52:34 -04:00
|
|
|
message: options.errMsg || options.message,
|
2014-08-05 11:32:13 -04:00
|
|
|
showFaqLink: options.showFaqLink || false,
|
2014-05-23 04:52:34 -04:00
|
|
|
positiveBtnStr: options.positiveBtnStr || 'Ok',
|
|
|
|
negativeBtnStr: options.negativeBtnStr || 'Cancel',
|
|
|
|
showNegativeBtn: options.showNegativeBtn || false,
|
|
|
|
callback: options.callback
|
2013-11-14 14:44:57 -05:00
|
|
|
};
|
2013-11-14 17:57:06 -05:00
|
|
|
// don't call apply for synchronous calls
|
|
|
|
if (!options.sync) {
|
|
|
|
scope.$apply();
|
|
|
|
}
|
2013-11-14 14:44:57 -05:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
return er;
|
|
|
|
});
|