/*exported UIPRTL */
/*global koObservableController, Utils, UIProvider */
/**
 * @param {ProviderData} data
 * @constructor
 */
var UIPRTL = function (data) {
    'use strict';

    UIPRTL.superclass.constructor.call(this, data);

    this.value = ko.computed({
        read: function () {
            if (!this._valueChangeNotifier) {
                this._valueChangeNotifier = koObservableController.koBind(this.control(), 'direction', function (direction) {
                    return direction === 'rtl';
                });
            }
            return this._valueChangeNotifier();
        },
        write: function (value) {
            this.control().direction = value ? 'rtl' : 'ltr';
        },
        owner: this
    });
};

Utils.extend(UIPRTL, UIProvider);