How to use the base.extend function in base

To help you get started, we’ve selected a few base 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 jonschlinkert / templates / lib / collection.js View on Github external
}

  Base.call(this, {}, options);
  this.is('Collection');
  this.items = {};

  this.use(utils.option());
  this.use(utils.plugin());
  this.init(options || {});
}

/**
 * Inherit `Base`
 */

Base.extend(Collection);

/**
 * Mixin static methods
 */

plugin.is(Collection);

/**
 * Initialize `Collection` defaults
 */

Collection.prototype.init = function(opts) {
  debug('initializing', __filename);

  // add constructors to the instance
  this.define('Item', opts.Item || Collection.Item);
github update / update / lib2 / runner / runner.js View on Github external
.set('argv', argv)

    // register middleware
    for (var fn in fns) {
      fns[fn](this.base, this.base, this);
    }

    // register tasks
    for (var key in tasks) {
      this.base.task(key, tasks[key](this.base, this.base, this));
    }

    this._listen();
  }

  Base.extend(Runner);

  Runner.prototype.updater = function(name) {
    return this.base.updater(name);
  };

  Runner.prototype.build = function() {
    this.base.build.apply(this.base, arguments);
    return this;
  };

  Runner.prototype.register = function(name, options, updater) {
    if (arguments.length === 2) {
      updater = options;
      options = {};
    }
github kissyteam / kissy / src / dd / plugin / scroll / src / scroll.js View on Github external
DD = require('dd'),
    Base = require('base');
var DDM = DD.DDM,
    win = window,
    SCROLL_EVENT = '.-ks-dd-scroll' + util.now(),
    RATE = [10, 10],
    ADJUST_DELAY = 100,
    DIFF = [20, 20],
    isWin = util.isWindow;

/**
 * @class KISSY.DD.Plugin.Scroll
 * @extends KISSY.Base
 * Scroll plugin to make parent node scroll while dragging.
 */
module.exports = Base.extend({

    pluginId: 'dd/plugin/scroll',

    /**
     * Get container node region.
     * @private
     */
    getRegion: function (node) {
        if (isWin(node[0])) {
            return {
                width: node.width(),
                height: node.height()
            };
        } else {
            return {
                width: node.outerWidth(),
github kissyteam / kissy / build / component / control.js View on Github external
KISSY.add("component/control/process", ["base"], function(S, require) {
  var Base = require("base");
  var __getHook = Base.prototype.__getHook;
  var noop = S.noop;
  var ControlProcess = Base.extend({bindInternal:noop, syncInternal:noop, renderUI:noop, syncUI:noop, bindUI:noop, create:function() {
    var self = this;
    if(!self.get("created")) {
      self.fire("beforeCreateDom");
      self.createDom();
      self.__callPluginsMethod("pluginCreateDom");
      self.fire("afterCreateDom");
      self.setInternal("created", true)
    }
    return self
  }, render:function() {
    var self = this;
    if(!self.get("rendered")) {
      self.create();
      self.fire("beforeRenderUI");
      self.renderUI();
      self.__callPluginsMethod("pluginRenderUI");
github kissyteam / kissy / build / editor / plugin / progressbar-debug.js View on Github external
], function (S, require, exports, module) {
    /**
 * @ignore
 * progressbar ui
 * @author yiminghe@gmail.com
 */
    var Base = require('base');
    var util = require('util');
    var $ = require('node');
    module.exports = Base.extend({
        destroy: function () {
            var self = this;
            self.detach();
            self.el.remove();
        },
        initializer: function () {
            var self = this, h = self.get('height'), prefixCls = self.get('prefixCls'), el = $(util.substitute('', { prefixCls: prefixCls })), container = self.get('container'), p = $(util.substitute('<div style="overflow:hidden;">' + '<div style="height:' + (parseInt(h, 10) - 4) + 'px" class="{prefixCls}editor-progressbar-inner">' + '<div class="{prefixCls}editor-progressbar-inner-bg"></div>' + '</div>' + '</div>', { prefixCls: prefixCls })).appendTo(el), title = $('<span class="' + prefixCls + 'editor-progressbar-title"></span>').appendTo(el);
            if (container) {
                el.appendTo(container);
            }
            self.el = el;
            self._title = title;
            self._p = p;
            self.on('afterProgressChange', self._progressChange, self);
            self._progressChange({ newVal: self.get('progress') });
        },
github kissyteam / kissy / build / dd / plugin / proxy.js View on Github external
KISSY.add("dd/plugin/proxy", ["node", "dd", "base"], function(S, require) {
  var Node = require("node"), DD = require("dd"), Base = require("base");
  var DDM = DD.DDM, PROXY_EVENT = ".-ks-proxy" + S.now();
  return Base.extend({pluginId:"dd/plugin/proxy", pluginInitializer:function(drag) {
    var self = this;
    function start() {
      var node = self.get("node"), dragNode = drag.get("node");
      if(!self.get("proxyNode")) {
        if(typeof node === "function") {
          node = node(drag);
          node.addClass("ks-dd-proxy");
          self.set("proxyNode", node)
        }
      }else {
        node = self.get("proxyNode")
      }
      node.show();
      dragNode.parent().append(node);
      DDM.cacheWH(node);
      node.offset(dragNode.offset());
github kissyteam / kissy / src / scroll-view / sub-modules / plugin / scrollbar / src / scrollbar.js View on Github external
if (minLength !== undefined) {
            cfg.minLength = minLength;
        }
        if (autoHideY !== undefined) {
            cfg.autoHide = autoHideY;
        }
        self.scrollBarY = new ScrollBar(cfg).render();
    }
}

/**
 * ScrollBar plugin for ScrollView.
 * @class KISSY.ScrollView.Plugin.ScrollBar
 * @extend KISSY.Base
 */
module.exports = Base.extend({
    pluginId: this.name,

    pluginBindUI: function (scrollView) {
        var self = this;
        self.scrollView = scrollView;
        scrollView.on('reflow', onScrollViewReflow, self);
    },

    pluginDestructor: function (scrollView) {
        var self = this;
        if (self.scrollBarX) {
            self.scrollBarX.destroy();
            self.scrollBarX = null;
        }
        if (self.scrollBarY) {
            self.scrollBarY.destroy();
github kissyteam / kissy / src / component / sub-modules / control / coverage / src / control / render.js View on Github external
}
  }
  _$jscoverage['/control/render.js'].lineData[92]++;
  function getBaseCssClassesCmd(_, options) {
    _$jscoverage['/control/render.js'].functionData[6]++;
    _$jscoverage['/control/render.js'].lineData[93]++;
    return this.config.view.getBaseCssClasses(visit21_93_1(options && visit22_93_2(options.params && options.params[0])));
  }
  _$jscoverage['/control/render.js'].lineData[96]++;
  function getBaseCssClassCmd() {
    _$jscoverage['/control/render.js'].functionData[7]++;
    _$jscoverage['/control/render.js'].lineData[97]++;
    return this.config.view.getBaseCssClass(arguments[1].params[0]);
  }
  _$jscoverage['/control/render.js'].lineData[105]++;
  return Base.extend({
  bindInternal: noop, 
  syncInternal: noop, 
  isRender: true, 
  create: function() {
  _$jscoverage['/control/render.js'].functionData[8]++;
  _$jscoverage['/control/render.js'].lineData[113]++;
  var self = this, srcNode = self.control.get('srcNode');
  _$jscoverage['/control/render.js'].lineData[116]++;
  if (visit23_116_1(srcNode)) {
    _$jscoverage['/control/render.js'].lineData[118]++;
    self.decorateDom(srcNode);
  } else {
    _$jscoverage['/control/render.js'].lineData[120]++;
    self.createDom();
  }
},
github kissyteam / kissy / src / component / sub-modules / control / src / control / process.js View on Github external
KISSY.add(function (S, require) {
    var Base = require('base');
    var __getHook = Base.prototype.__getHook;
    var noop = S.noop;

    /**
     * @class KISSY.Component.Process
     * @extends KISSY.Base
     */
    var ControlProcess = Base.extend({
        bindInternal: noop,

        syncInternal: noop,

        renderUI: noop,

        syncUI: noop,

        bindUI: noop,

        /**
         * create dom structure of this component
         * (control will delegate to render).
         * @chainable
         */
        create: function () {
github kissyteam / kissy / build / dd / plugin / constrain.js View on Github external
self.__constrainRegion.bottom -= dragNode.outerHeight()
      }
    }
  }
  function onDragAlign(e) {
    var self = this, info = {}, l = e.left, t = e.top, constrain = self.__constrainRegion;
    if(constrain) {
      info.left = Math.min(Math.max(constrain.left, l), constrain.right);
      info.top = Math.min(Math.max(constrain.top, t), constrain.bottom);
      e.drag.setInternal("actualPos", info)
    }
  }
  function onDragEnd() {
    this.__constrainRegion = null
  }
  module.exports = Base.extend({pluginId:"dd/plugin/constrain", __constrainRegion:null, pluginInitializer:function(drag) {
    var self = this;
    drag.on("dragstart" + CONSTRAIN_EVENT, onDragStart, self).on("dragend" + CONSTRAIN_EVENT, onDragEnd, self).on("dragalign" + CONSTRAIN_EVENT, onDragAlign, self)
  }, pluginDestructor:function(drag) {
    drag.detach(CONSTRAIN_EVENT, {context:this})
  }}, {ATTRS:{constrain:{value:$(WIN), setter:function(v) {
    if(v) {
      if(v === true) {
        return $(WIN)
      }else {
        if(v.nodeType || S.isWindow(v) || typeof v === "string") {
          return $(v)
        }
      }
    }
    return v
  }}}})