2014-10-02 16:05:44 -04:00
'use strict' ;
2013-11-08 15:35:30 -05:00
2014-11-29 08:46:16 -05:00
var DialogCtrl = function ( $scope , dialog ) {
2014-11-26 11:57:14 -05:00
$scope . state . dialog = {
open : false
} ;
2014-11-20 09:14:39 -05:00
//
// Set dialog disply functions
//
dialog . displayInfo = function ( options ) {
2014-11-29 08:46:16 -05:00
setOptions ( options ) ;
2014-11-20 09:14:39 -05:00
} ;
dialog . displayError = function ( options ) {
2014-11-29 08:46:16 -05:00
if ( ! options ) {
return ;
}
setOptions ( options ) ;
$scope . title = options . title || 'Error' ;
$scope . showBugReporter = ( typeof options . showBugReporter !== 'undefined' ? options . showBugReporter : ! options . title ) ; // if title is set, presume it's not an error by default
2014-11-20 09:14:39 -05:00
} ;
dialog . displayConfirm = function ( options ) {
2014-11-29 08:46:16 -05:00
setOptions ( options ) ;
2014-11-20 09:14:39 -05:00
} ;
function setOptions ( options ) {
2014-11-26 11:57:14 -05:00
$scope . state . dialog . open = true ;
2014-11-20 09:14:39 -05:00
$scope . title = options . title ;
$scope . message = options . errMsg || options . message ;
$scope . faqLink = options . faqLink ;
$scope . positiveBtnStr = options . positiveBtnStr || 'Ok' ;
$scope . negativeBtnStr = options . negativeBtnStr || 'Cancel' ;
$scope . showNegativeBtn = options . showNegativeBtn || false ;
2014-11-21 06:13:06 -05:00
$scope . callback = options . callback ;
2014-11-20 09:14:39 -05:00
}
//
// Scope functions
//
2014-10-02 16:05:44 -04:00
$scope . confirm = function ( ok ) {
2014-11-26 11:57:14 -05:00
$scope . state . dialog . open = false ;
2013-11-08 15:35:30 -05:00
2014-11-21 06:13:06 -05:00
if ( $scope . callback ) {
$scope . callback ( ok ) ;
2014-10-02 16:05:44 -04:00
}
2014-11-21 06:13:06 -05:00
$scope . callback = undefined ;
2013-11-08 15:35:30 -05:00
} ;
2014-10-02 16:05:44 -04:00
} ;
2013-11-08 15:35:30 -05:00
2014-10-08 06:34:34 -04:00
module . exports = DialogCtrl ;