"Milicevic01"
]
},
- "ooui-dialog-action-close": "Zatvori",
"ooui-outline-control-move-down": "Premesti stavku na dole",
"ooui-outline-control-move-up": "Premesti stavku na gore",
"ooui-outline-control-remove": "Ukloni stavku",
"ooui-toolbar-more": "Više",
- "ooui-dialog-confirm-default-prompt": "Jeste li sigurni?"
+ "ooui-dialog-message-accept": "U redu",
+ "ooui-dialog-message-reject": "Otkaži",
+ "ooui-dialog-process-error": "Nešto je pošlo naopako",
+ "ooui-dialog-process-dismiss": "Odbaci",
+ "ooui-dialog-process-retry": "Pokušaj ponovo"
}
/*!
- * OOjs UI v0.1.0-pre (f2c3f12959)
+ * OOjs UI v0.1.0-pre (4ea8e2cba9)
* https://www.mediawiki.org/wiki/OOjs_UI
*
* Copyright 2011–2014 OOjs Team and other contributors.
* Released under the MIT license
* http://oojs.mit-license.org
*
- * Date: 2014-09-18T23:22:20Z
+ * Date: 2014-09-23T20:24:02Z
*/
( function ( OO ) {
* @param {Object} [config] Configuration options
* @cfg {string} [action] Symbolic action name
* @cfg {string[]} [modes] Symbolic mode names
+ * @cfg {boolean} [framed=false] Render button with a frame
*/
OO.ui.ActionWidget = function OoUiActionWidget( config ) {
// Config intialization
* @abstract
* @class
* @extends OO.ui.Widget
+ * @mixins OO.ui.FlaggedElement
*
* @constructor
* @param {Object} [config] Configuration options
// Parent constructor
OO.ui.InputWidget.super.call( this, config );
+ // Mixin constructors
+ OO.ui.FlaggedElement.call( this, config );
+
// Properties
this.$input = this.getInputElement( config );
this.value = '';
/* Setup */
OO.inheritClass( OO.ui.InputWidget, OO.ui.Widget );
+OO.mixinClass( OO.ui.InputWidget, OO.ui.FlaggedElement );
/* Events */
* @cfg {boolean} [multiline=false] Allow multiple lines of text
* @cfg {boolean} [autosize=false] Automatically resize to fit content
* @cfg {boolean} [maxRows=10] Maximum number of rows to make visible when autosizing
+ * @cfg {RegExp|string} [validate] Regular expression (or symbolic name referencing
+ * one, see #static-validationPatterns)
*/
OO.ui.TextInputWidget = function OoUiTextInputWidget( config ) {
// Configuration initialization
this.multiline = !!config.multiline;
this.autosize = !!config.autosize;
this.maxRows = config.maxRows !== undefined ? config.maxRows : 10;
+ this.validate = config.validate || null;
// Events
- this.$input.on( 'keypress', OO.ui.bind( this.onKeyPress, this ) );
+ this.$input.on( {
+ keypress: OO.ui.bind( this.onKeyPress, this ),
+ blur: OO.ui.bind( this.setValidityFlag, this )
+ } );
this.$element.on( 'DOMNodeInsertedIntoDocument', OO.ui.bind( this.onElementAttach, this ) );
this.$icon.on( 'mousedown', OO.ui.bind( this.onIconMouseDown, this ) );
this.$indicator.on( 'mousedown', OO.ui.bind( this.onIndicatorMouseDown, this ) );
OO.mixinClass( OO.ui.TextInputWidget, OO.ui.IndicatorElement );
OO.mixinClass( OO.ui.TextInputWidget, OO.ui.PendingElement );
+/* Static properties */
+
+OO.ui.TextInputWidget.static.validationPatterns = {
+ 'non-empty': /.+/,
+ integer: /^\d+$/
+};
+
/* Events */
/**
// Parent method
OO.ui.TextInputWidget.super.prototype.setValue.call( this, value );
+ this.setValidityFlag();
this.adjustSize();
return this;
};
return this;
};
+/**
+ * Sets the 'invalid' flag appropriately.
+ */
+OO.ui.TextInputWidget.prototype.setValidityFlag = function () {
+ this.isValid().done( OO.ui.bind( function ( valid ) {
+ this.setFlags( { invalid: !valid } );
+ }, this ) );
+};
+
+/**
+ * Returns whether or not the current value is considered valid, according to the
+ * supplied validation pattern.
+ *
+ * @return {jQuery.Deferred}
+ */
+OO.ui.TextInputWidget.prototype.isValid = function () {
+ var validationRegexp;
+ if ( this.validate instanceof RegExp ) {
+ validationRegexp = this.validate;
+ } else {
+ validationRegexp = this.constructor.static.validationPatterns[this.validate];
+ }
+ return $.Deferred().resolve( !!this.getValue().match( validationRegexp ) ).promise();
+};
+
/**
* Text input with a menu of optional values.
*