shadowsocks-manager
Version:
A shadowsocks manager tool for multi user and traffic control.
63 lines (61 loc) • 1.61 kB
JavaScript
const app = angular.module('app');
const window = require('window');
const cdn = window.cdn || '';
app.factory('autopopDialog', [ '$mdDialog', ($mdDialog) => {
const publicInfo = {};
const hide = () => {
return $mdDialog.hide()
.then(success => {
dialogPromise = null;
return;
}).catch(err => {
dialogPromise = null;
return;
});
};
publicInfo.hide = hide;
const next = () => {
if(publicInfo.index < publicInfo.notices.length - 1) {
publicInfo.index += 1;
} else {
hide();
}
};
publicInfo.next = next;
let dialogPromise = null;
const isDialogShow = () => {
if(dialogPromise && !dialogPromise.$$state.status) {
return true;
}
return false;
};
const dialog = {
templateUrl: `${ cdn }/public/views/dialog/autopop.html`,
escapeToClose: false,
locals: { bind: publicInfo },
bindToController: true,
controller: ['$scope', '$mdMedia', '$mdDialog', 'bind', function($scope, $mdMedia, $mdDialog, bind) {
$scope.publicInfo = bind;
$scope.publicInfo.index = 0;
$scope.setDialogWidth = () => {
if($mdMedia('xs') || $mdMedia('sm')) {
return {};
}
return { 'min-width': '400px' };
};
}],
fullscreen: true,
clickOutsideToClose: true,
};
const show = notices => {
if(isDialogShow()) {
return dialogPromise;
}
publicInfo.notices = notices;
dialogPromise = $mdDialog.show(dialog);
return dialogPromise;
};
return {
show,
};
}]);