Files
febbweiss.github.io/demo/filebrowser-durandal-widget/app/widgets/filebrowser/newItemModal.js
ECAILLE Fabrice (externe) 2e64cb961e Initial commit
2017-05-03 16:46:01 +02:00

34 lines
1000 B
JavaScript

define(['plugins/dialog', 'knockout', 'knockout.validation'], function (dialog, ko, ko_validation) {
ko.validation = ko_validation;
var NewItemModal = function() {
var self = this;
self.input = ko.observable('').extend({
required: true,
pattern: {
message : 'The name must not contain a \'/\'',
params : '^[^/]+$'
}
});
self.typeItem = ko.observable('file');
self.form = ko.validatedObservable( {input: self.input} );
self.isValid = ko.computed(function() {
return self.form.isValid();
});
};
NewItemModal.prototype.ok = function() {
dialog.close(this, { name: this.input(), type: this.typeItem()});
};
NewItemModal.prototype.close = function() {
dialog.close(this);
};
NewItemModal.show = function(defaultValue){
return dialog.show(new NewItemModal(defaultValue));
};
return NewItemModal;
});