2013-01-29 13:47:40 +01:00
|
|
|
angular
|
|
|
|
.module('webui.ctrls.modal', [
|
2013-01-29 18:52:30 +01:00
|
|
|
'webui.services.rpc', 'webui.services.deps', 'webui.services.modals'
|
2013-01-29 13:47:40 +01:00
|
|
|
])
|
2013-01-29 18:52:30 +01:00
|
|
|
.controller('ModalCtrl', [
|
|
|
|
'$_', '$scope', '$rpc', '$modals',
|
|
|
|
function(_, scope, rpc, modals) {
|
|
|
|
|
|
|
|
scope.getUris = {
|
|
|
|
cb: null,
|
|
|
|
uris: '',
|
|
|
|
shown: false,
|
|
|
|
parse: function() {
|
|
|
|
return _
|
|
|
|
.chain(this.uris.trim().split(/\n\r?/g))
|
|
|
|
.map(function(d) { return d.trim().split(/\s+/g) })
|
|
|
|
.filter(function(d) { return d.length })
|
|
|
|
.value();
|
|
|
|
},
|
|
|
|
finish: function() {
|
|
|
|
var uris = this.parse();
|
|
|
|
this.uris = '';
|
2013-01-15 09:24:09 +01:00
|
|
|
|
2013-01-29 18:52:30 +01:00
|
|
|
if (this.cb) this.cb(uris);
|
2013-01-28 15:18:21 +01:00
|
|
|
|
2013-01-29 18:52:30 +01:00
|
|
|
this.cb = null;
|
|
|
|
this.shown = false;
|
|
|
|
}
|
2013-01-28 15:18:21 +01:00
|
|
|
};
|
2013-01-29 18:52:30 +01:00
|
|
|
modals.register('getUris', function(cb) {
|
|
|
|
if (scope.getUris.cb != null && scope.getUris.shown) {
|
|
|
|
// modal already shown, user is busy
|
|
|
|
// TODO: get a better method of passing this on
|
|
|
|
cb([]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
scope.getUris.cb = cb;
|
|
|
|
scope.getUris.shown = true;
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2013-01-15 09:24:09 +01:00
|
|
|
}]);
|