How to use attribute - 10 common examples

To help you get started, we’ve selected a few attribute 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 kissyteam / kissy / src / combobox / - / src / combobox / remote-data-source.js View on Github external
/**
 * @ignore
 * Remote datasource for ComboBox
 * @author yiminghe@gmail.com
 */

var IO = require('io');
var Attribute = require('attribute');
/**
 * dataSource which wrap {@link KISSY.IO} utility.
 * @class KISSY.ComboBox.RemoteDataSource
 * @extends KISSY.Base
 */
module.exports = Attribute.extend({
    /**
     * Data source interface. How to get data for comboBox
     * @param {String} inputVal current active input's value
     * @param {Function} callback callback to notify comboBox when data is ready
     * @param {Object} context callback 's execution context
     */
    fetchData: function (inputVal, callback, context) {
        var self = this,
            v,
            paramName = self.get('paramName'),
            parse = self.get('parse'),
            cache = self.get('cache'),
            allowEmpty = self.get('allowEmpty');
        self.caches = self.caches || {};
        if (self.io) {
            // abort previous request
github kissyteam / kissy / lib / build / base.js View on Github external
* attributes configured
 * through the static {@link KISSY.Base#static-ATTRS} property for each class
 * in the hierarchy will be initialized by Base.
 */
    //noinspection JSValidateJSDoc
    /**
 * @class KISSY.Base
 * @mixins KISSY.Attribute
 *
 * A base class which objects requiring attributes, extension, plugin, custom event support can
 * extend.
 * attributes configured
 * through the static {@link KISSY.Base#static-ATTRS} property for each class
 * in the hierarchy will be initialized by Base.
 */
    var Base = Attribute.extend({
            constructor: function () {
                var self = this;
                self.callSuper.apply(self, arguments);    // setup listeners
                // setup listeners
                var listeners = self.get('listeners');
                if (listeners) {
                    for (var n in listeners) {
                        self.on(n, listeners[n]);
                    }
                }    // initializer
                // initializer
                self.initializer();    // call plugins
                // call plugins
                constructPlugins(self);
                callPluginsMethod.call(self, 'pluginInitializer');    // bind attr change
                // bind attr change
github kissyteam / kissy / src / base / src / base.js View on Github external
};
    };
}

//noinspection JSValidateJSDoc
/**
 * @class KISSY.Base
 * @mixins KISSY.Attribute
 *
 * A base class which objects requiring attributes, extension, plugin, custom event support can
 * extend.
 * attributes configured
 * through the static {@link KISSY.Base#static-ATTRS} property for each class
 * in the hierarchy will be initialized by Base.
 */
var Base = Attribute.extend({
    constructor: function () {
        var self = this;
        self.callSuper.apply(self, arguments);
        // setup listeners
        var listeners = self.get('listeners');
        if (listeners) {
            for (var n in listeners) {
                self.on(n, listeners[n]);
            }
        }
        // initializer
        self.initializer();
        // call plugins
        constructPlugins(self);
        callPluginsMethod.call(self, 'pluginInitializer');
        // bind attr change
github kissyteam / kissy / src / mvc / src / mvc / router.js View on Github external
}

    function _afterRoutesChange(e) {
        var self = this;
        self[ROUTER_MAP] = {};
        self.addRoutes(e.newVal);
    }

    var Router;

    /**
     * Router used to route url to responding action callbacks.
     * @class KISSY.MVC.Router
     * @extends KISSY.Attribute
     */
    Router = Attribute.extend({
        constructor: function () {
            var self = this;
            self.callSuper.apply(self, arguments);
            self.on('afterRoutesChange', _afterRoutesChange, self);
            _afterRoutesChange.call(self, {newVal: self.get('routes')});
            allRoutes.push(self);
        },
        /**
         * Add config to current router.
         * @param {Object} routes Route config.
         *
         *
         *      {
         *          '/search/:param':'callback'
         *          // or
         *          'search':{
github kissyteam / kissy / build / swf-debug.js View on Github external
//  其他控制参数
            base: EMPTY,
            swliveconnect: EMPTY,
            seamlesstabbing: EMPTY
        };
    var SWF;    /**
 * insert a new swf into container
 * @class KISSY.SWF
 * @extends KISSY.Base
 */
    /**
 * insert a new swf into container
 * @class KISSY.SWF
 * @extends KISSY.Base
 */
    SWF = Attribute.extend({
        constructor: function (config) {
            var self = this;
            self.callSuper(config);
            var expressInstall = self.get('expressInstall'), swf, html, id, htmlMode = self.get('htmlMode'), flashVars, params = self.get('params'), attrs = self.get('attrs'), doc = self.get('document'), placeHolder = Dom.create('<span>', undefined, doc), elBefore = self.get('elBefore'), installedSrc = self.get('src'), version = self.get('version');    // https://github.com/kissyteam/kissy/issues/663
                                                                                                                                                                                                                                                                                                                                                                   // must has a id
                                                                                                                                                                                                                                                                                                                                                                   // or else can not callSWF function in ie6-10
            // https://github.com/kissyteam/kissy/issues/663
            // must has a id
            // or else can not callSWF function in ie6-10
            id = attrs.id = attrs.id || util.guid('ks-swf-' + util.now() + '-');    // 2. flash 插件没有安装
            // 2. flash 插件没有安装
            if (!fpv()) {
                self.set('status', SWF.Status.NOT_INSTALLED);
                return;
            }    // 3. 已安装,但当前客户端版本低于指定版本时
            // 3. 已安装,但当前客户端版本低于指定版本时</span>
github kissyteam / kissy / src / router / demo / mvc / view.js View on Github external
var $ = require('node');
    var Attribute = require('attribute');

    function normFn(self, f) {
        if (typeof f === 'string') {
            return self[f];
        }
        return f;
    }

    /**
     * View for delegating event on root element.
     * @class KISSY.MVC.View
     * @extends KISSY.Attribute
     */
    module.exports = Attribute.extend({
        constructor: function () {
            this.callSuper.apply(this, arguments);
            var events;
            if ((events = this.get('events'))) {
                this._afterEventsChange({
                    newVal: events
                });
            }
        },

        _afterEventsChange: function (e) {
            var prevVal = e.prevVal;
            if (prevVal) {
                this._removeEvents(prevVal);
            }
            this._addEvents(e.newVal);
github kissyteam / kissy / src / router / demo / mvc / collection.js View on Github external
for (i = 0; i &lt; mods.length; i++) {
                var k2 = comparator(mods[i]);
                if (k &lt; k2) {
                    break;
                }
            }
        }
        return i;
    }

    /**
     * Collection. A list of model.
     * @class KISSY.MVC.Collection
     * @extends KISSY.Attribute
     */
    module.exports = Attribute.extend({
        /**
         * Sort model list according {@link KISSY.MVC.Collection#comparator}.
         */
        sort: function () {
            var comparator = this.get('comparator');
            if (comparator) {
                this.get('models').sort(function (a, b) {
                    return comparator(a) - comparator(b);
                });
            }
        },

        /**
         * Get json representation of this collection.
         * @return Object[]
         */
github kissyteam / kissy / src / router / demo / mvc / model.js View on Github external
'destroyed',
        'plugins',
        'listeners',
        'clientId',
        'urlRoot',
        'url',
        'parse',
        'sync'
    ];

    /**
     * Model represent a data record.
     * @class KISSY.MVC.Model
     * @extends KISSY.Attribute
     */
    module.exports = Attribute.extend({
        getCollections: function () {
            return  this.collections || (this.collections = {});
        },

        /**
         * Add current model instance to a specified collection.
         * @param {KISSY.MVC.Collection} c
         */
        addToCollection: function (c) {
            this.getCollections()[util.stamp(c)] = c;
            this.addTarget(c);
        },
        /**
         * Remove current model instance from a specified collection.
         * @param {KISSY.MVC.Collection} c
         */
github kissyteam / kissy / src / combobox / - / src / combobox / local-data-source.js View on Github external
/**
 * @ignore
 * Local dataSource for ComboBox
 * @author yiminghe@gmail.com
 */

var Attribute = require('attribute');
var util = require('util');

/**
 * Local dataSource for comboBox.
 * @extends KISSY.Base
 * @class KISSY.ComboBox.LocalDataSource
 */

module.exports = Attribute.extend({
    /**
     * Data source interface. How to get data for comboBox.
     * @param {String} inputVal current active input's value
     * @param {Function} callback callback to notify comboBox when data is ready
     * @param {Object} context callback 's execution context
     */
    fetchData: function (inputVal, callback, context) {
        var parse = this.get('parse'),
            data = this.get('data');
        data = parse(inputVal, data);
        callback.call(context, data);
    }
}, {
    ATTRS: {
        /**
         * array of static data for comboBox
github kissyteam / kissy / src / base / coverage / src / base.js View on Github external
_$jscoverage['/base.js'].lineData[32]++;
  if (visit5_32_1(reverse)) {
    _$jscoverage['/base.js'].lineData[33]++;
    self.callSuper.apply(self, arguments);
  } else {
    _$jscoverage['/base.js'].lineData[35]++;
    if (visit6_35_1(origFn !== noop)) {
      _$jscoverage['/base.js'].lineData[36]++;
      origFn.apply(self, arguments);
    }
  }
};
};
  }
  _$jscoverage['/base.js'].lineData[54]++;
  var Base = Attribute.extend({
  constructor: function() {
  _$jscoverage['/base.js'].functionData[4]++;
  _$jscoverage['/base.js'].lineData[56]++;
  var self = this;
  _$jscoverage['/base.js'].lineData[57]++;
  self.callSuper.apply(self, arguments);
  _$jscoverage['/base.js'].lineData[59]++;
  var listeners = self.get('listeners');
  _$jscoverage['/base.js'].lineData[60]++;
  if (visit7_60_1(listeners)) {
    _$jscoverage['/base.js'].lineData[61]++;
    for (var n in listeners) {
      _$jscoverage['/base.js'].lineData[62]++;
      self.on(n, listeners[n]);
    }
  }

attribute

Stream that updates attributes on elements

MIT
Latest version published 12 years ago

Package Health Score

42 / 100
Full package analysis

Popular attribute functions