Ejemplo n.º 1
0
    function load_component() {
      var cmpClass = _packages[component].class;
      if (!cmpClass) {
        cmpClass = _packages[component].class = Component.extend(exports);
        cmpClass.helpers = {};
      }

      var cmpInstance = new cmpClass(_.extend({ id: id }, options));

      render_component(cmpInstance);

      cmpInstance.helpers = {};
      _.each(_packages[component].helpers, function(helper, name) {

        if (cmpClass.helpers[name]) {
          cmpInstance.helpers[name] = cmpClass.helpers[name];
        } else {
          var helper_instance = bootloader.raw_import(helper);
          cmpClass.helpers[name] = helper_instance || true;

          if (helper_instance) {
            name = helper_instance.name || name;
          }

          cmpInstance.helpers[name] = helper_instance;
        }
      });

      // instantiate client callbacks for component
      if (cmpInstance.client && !options.skip_client_init) {
        var cl = options.client_options || {};
        _.extend(cl, options);
        cmpInstance.client(cl);
      }

      install_handlers(cmpInstance);

      if (cb) {
        cb(cmpInstance);
      }
    }
Ejemplo n.º 2
0
import Component from 'Components/component'
// var Component = require('Components/component')
import template from './index.rgl';

const App = Component.extend({
	name: 'app',
	template,
	config() {
	},
});

export default App;
Ejemplo n.º 3
0
const NavBar = Component.extend({
	name: 'nav-bar',
	template,
	config: function() {
		this.data = Object.assign({
			minHeight: 70,
			maxHeight: 120,
			shrink: false,
			threshold: 50,
			height: 120,
			tabs: [
				{name: 'sales', url: '#'},
				{name: 'wants', url: '#'},
			]
		}, this.data);
		this.supr();
		this.data.threshold = (this.data.maxHeight - this.data.minHeight);
		this.data.height = this.data.maxHeight;

		Regular.dom.on(document, 'scroll', function(e){
			var t = this.data;
			if(window.scrollY > t.threshold){
				this.data.shrink = true;
				this._setHeight(t.minHeight);
				return;
			}
			this._setHeight(t.maxHeight - window.scrollY);
		}.bind(this));
	},

	/**
	 * @method _setHeight			设置高度并更新到view
	 * @param {number}				height
	 */
	_setHeight: function(height) {
		this.data.height = height;
		this.$update();
	},

	/**
	 * @method toggle					翻转组件高度收缩状态
	 * @param {boolean}				shrink
	 */
	toggle: function(shrink) {
			this.data.shrink = shrink === undefined ? shrink = !this.data.shrink : shrink;
			this._setHeight(shrink ? this.data.minHeight : this.data.maxHeight);
			this.$emit('toggle', {

			});
	},
	/**
	 * @method _option				触发option事件
	 */
	_option: function() {
		this.$emite('option', {

		});
	},
	/**
	 * @method _tab						触发tab事件
	 */
	_tab: function(e) {
		this.$emit('tab', e);
	}
 })