How to use the basis.event.create function in basis

To help you get started, we’ve selected a few basis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github basisjs / basisjs / src / basis / ui / calendar.js View on Github external
return 1;  // todo: fix me
      })
    }
  });

  //
  // Calendar
  //

 /**
  * @class
  */
  var Calendar = Class(Node, {
    className: namespace + '.Calendar',

    emit_change: createEvent('change'),
    emit_childNodesModified: function(delta){
      if (delta.inserted)
        for (var i = 0, section; section = delta.inserted[i++];)
        {
          section.isPeriodEnabled = this.isPeriodEnabled;
          section.childNodes.forEach(function(child){
            child.isPeriodEnabled = this.isPeriodEnabled;
          }, this);
          section.setViewDate(this.date.value);
          this.selectedDate.link(section, section.setSelectedDate);
          section.rebuild();
        }

      if (delta.deleted)
        for (var i = 0, section; section = delta.deleted[i++];)
          this.selectedDate.unlink(section, section.setSelectedDate);
github basisjs / basisjs / src / basis / ui / chart.js View on Github external
},

    destroy: function(){
      this.setSource(null);
      AbstractNode.prototype.destroy.call(this);
    }
  });


 /**
  * @class
  */
  var ChartSeriesList = Node.subclass({
    className: namespace + '.ChartSeriesList',

    emit_valuesChanged: createEvent('valuesChanged', 'delta'),

    childClass: ChartSeria,
    childFactory: function(config){
      return new this.childClass(config);
    },

    listen: {
      childNode: { // seria
        valuesChanged: function(seria, delta){
          this.emit_valuesChanged(seria, delta);
        }
      }
    },

    init: function(){
      this.colorPicker = new ColorPicker(extend({ owner: this }, this.colorPicker));
github basisjs / basisjs / src / basis / ui.js View on Github external
tmpl: 'templateChanged',
        element: false,
        childNodesElement: false
      },

     /**
      * Template for object.
      * @type {basis.template.html.Template}
      */
      template: TEMPLATE,         // NOTE: explicit template constructor here;
                                  // it could be ommited in subclasses
     /**
      * Fires when template had changed.
      * @event
      */
      emit_templateChanged: createEvent('templateChanged'),

     /**
      * @type {basis.template.TemplateSwitcher}
      */
      templateSwitcher_: null,

     /**
      * @type {Object}
      */
      binding: TEMPLATE_BINDING,

     /**
      * Handlers for template actions.
      * @type {Object}
      */
      action: TEMPLATE_ACTION,
github basisjs / basisjs / src / basis / data / dataset / SourceDataset.js View on Github external
active: basis.PROXY,
  subscribeTo: SUBSCRIPTION.SOURCE,

 /**
  * Data source.
  * @type {basis.data.ReadOnlyDataset}
  */
  source: null,

 /**
  * Fires when source changed.
  * @param {basis.data.ReadOnlyDataset} oldSource Previous value for source property.
  * @event
  */
  emit_sourceChanged: createEvent('sourceChanged', 'oldSource'),

 /**
  * Source wrapper
  * @type {basis.data.ResolveAdapter}
  */
  sourceRA_: null,

 /**
  * Map of source objects.
  * @type {object}
  * @private
  */
  sourceMap_: null,

 /**
  * @inheritDoc
github basisjs / basisjs / src / basis / ui / chart.js View on Github external
{
          color = generateColor();
        }
        while (this.usedColors[color]);
      }
      return color;
    }
  });


 /**
  * @class
  */
  var ChartNode = Node.subclass({
    className: namespace + '.ChartNode',
    emit_requestRedraw: createEvent('requestRedraw'),
    emit_disable: createEvent('disable'),
    emit_enable: createEvent('enable')
  });

 /**
  * @class
  */
  var Chart = Canvas.subclass({
    className: namespace + '.Chart',

    childClass: ChartNode,

    template: templates.Chart,
    binding: {
      chartSelection: 'satellite:',
      chartViewer: 'satellite:'
github basisjs / basisjs / src / basis / ui / window.js View on Github external
var DD_HANDLER = {
    start: function(){
      this.autocenter = false;
    }
  };

 /**
  * @class
  */
  var Window = Class(Node, {
    className: namespace + '.Window',

    emit_beforeShow: createEvent('beforeShow'),
    emit_open: createEvent('open'),
    emit_close: createEvent('close'),
    emit_active: createEvent('active'),

    closeOnEscape: true,

    autocenter: true,
    autocenter_: false,
    modal: false,
    closed: true,
    moveable: true,
    zIndex: 0,

    dde: null,

    title: dict.token('emptyTitle'),

    template: templates.Window,
    binding: {
github basisjs / basisjs / src / basis / ui / tree.js View on Github external
* @class
  */
  var Node = Class(UINode, ExpandCollapseMixin, {
    className: namespace + '.Node',

   /**
    * @inheritDoc
    */
    childClass: null,

   /**
    * @inheritDoc
    */
    childFactory: null,

    emit_collapse: createEvent('collapse'),
    emit_expand: createEvent('expand'),

   /**
    * @inheritDoc
    */
    template: templates.Node,

    binding: {
      title: {
        events: 'update',
        getter: function(node){
          return node.data.title || '[no title]';
        }
      },
      collapsed: {
        events: 'expand collapse',
github basisjs / basisjs / src / basis / data / object.js View on Github external
/**
  * @class
  * TODO:
  *   - subscription for sources
  */
  var Merge = DataObject.subclass({
    className: namespace + '.Merge',

   /**
    * Emit when one of source reference changes.
    * @param {string} name Name of source.
    * @param {DataObject} oldSource Value of source reference before changes.
    * @event
    */
    emit_sourceChanged: createEvent('sourceChanged', 'name', 'oldSource'),

   /**
    * Field source association map. Key is field name, and value is source name.
    * Based on this map, instance build list of possible sources. This property could
    * be set on subclass definition or instance creation, but not during instance
    * life cycle.
    *
    * If star used for field name, it means that all non-specified field names should
    * map on specified source. If dash ('-') used as source name, it means this field
    * is own instance data property.
    *
    * By default, all fields are own instance data properties, and instance behave as
    * regular `DataObject` instance.
    */
    fields: fieldsExtend({
      '*': '-'
github basisjs / basisjs / src / basis / data / dataset / Merge.js View on Github external
sourceValues_: null,
  sourcesMap_: null,
  sourceDelta_: null,

 /**
  * @type {function(count:number, sourceCount:number):boolean}
  */
  rule: UNION,

 /**
  * Fires when rule is changed.
  * @param {function(count:number, sourceCount:number): boolean} oldRule
  * @event
  */
  emit_ruleChanged: createEvent('ruleChanged', 'oldRule'),

 /**
  * @inheritDoc
  */
  listen: {
    source: MERGE_DATASET_HANDLER,
    sourceValue: {
      destroy: function(sender){
        this.removeSource(sender);
      }
    }
  },

 /**
  * @config {Array.} sources Set of source datasets for aggregate.
  * @constructor
github basisjs / basisjs / src / basis / ui / chart.js View on Github external
},

    legendGetter: getter('legend'),
    getLegend: function(){
      return this.legendGetter(this);
    },

    colorGetter: getter('color'),
    getColor: function(){
      return this.colorGetter(this);
    },

    //events
    emit_valuesChanged: createEvent('valuesChanged', 'delta'),
    emit_sourceChanged: createEvent('sourceChanged', 'oldSource'),
    emit_disable: createEvent('disable'),
    emit_enable: createEvent('enable'),

    init: function(){
      this.valuesMap = {};

      AbstractNode.prototype.init.call(this);

      this.source = this.sourceGetter(this);

      if (this.source)
      {
        var source = this.source;
        this.source = null;
        this.setSource(source);
      }
    },