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

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

    this.value.dispose();
    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().prop('direction', value ? 'rtl' : 'ltr');
        },
        owner: this,
        deferEvaluation: true
    });
}

Utils.extend(UIPRTL, UIProvider);