milo

'use strict';

var ComponentFacet = require('../c_facet')
    , facetsRegistry = require('./cf_registry')
    , miloCore = require('milo-core')
    , Model = miloCore.Model
    , _ = miloCore.proto;


// generic drag handler, should be overridden
var Options = _.createSubclass(ComponentFacet, 'Options');

_.extendProto(Options, {
    init: Options$init,
    destroy: Options$destroy,
    _createMessenger: Options$_createMessenger
});

facetsRegistry.add(Options);

module.exports = Options;


function Options$init() {
    this.m = new Model(this.config.options, this);
    ComponentFacet.prototype.init.apply(this, arguments);
    this.m.proxyMethods(this); // Creates model's methods directly on facet
}


function Options$_createMessenger() { // Called by inherited init
    this._messenger = this.m._messenger;
}


function Options$destroy() {
    this.m.destroy();
    ComponentFacet.prototype.destroy.apply(this, arguments);
}