mirror of
https://github.com/Febbweiss/febbweiss.github.io.git
synced 2026-03-04 22:25:43 +00:00
Initial commit
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
define(['plugins/dialog', 'knockout', , 'knockout.validation'], function (dialog, ko, ko_validation) {
|
||||
|
||||
ko.validation = ko_validation;
|
||||
|
||||
var RenameModal = function(defaultValue) {
|
||||
var self = this;
|
||||
self.previousName = defaultValue;
|
||||
self.input = ko.observable(defaultValue).extend({
|
||||
required: true,
|
||||
pattern: {
|
||||
message : 'The name must not contain a \'/\'',
|
||||
params : '^[^/]+$'
|
||||
}
|
||||
});
|
||||
self.form = ko.validatedObservable( {input: self.input} );
|
||||
self.isValid = ko.computed(function() {
|
||||
return self.form.isValid() && self.input() != self.previousName;
|
||||
});
|
||||
};
|
||||
|
||||
RenameModal.prototype.ok = function() {
|
||||
dialog.close(this, this.input());
|
||||
};
|
||||
|
||||
RenameModal.prototype.close = function() {
|
||||
dialog.close(this);
|
||||
};
|
||||
|
||||
RenameModal.show = function(defaultValue){
|
||||
return dialog.show(new RenameModal(defaultValue));
|
||||
};
|
||||
|
||||
return RenameModal;
|
||||
});
|
||||
Reference in New Issue
Block a user