Пример #1
0
  update: function(handler) {
    if (typeof handler !== 'function') {
      if (process.env.NODE_ENV !== 'production') {
        vue.util.warn(
          this.name + '="' +
          this.expression + '" expects a function value, ' +
          'got ' + handler
        );
      }
      return;
    }

    this.reset();

    var self = this;
    var scope = this._scope || this.vm;

    this.handler = function(ev) {
      // @NOTE: IE 5.0+
      // @REFERENCE: https://developer.mozilla.org/en/docs/Web/API/Node/contains
      if (!self.el.contains(ev.target)) {
        scope.$event = ev;
        var res = handler(ev);
        scope.$event = null;
        return res;
      }
    };

    vue.util.on(document.documentElement, 'click', this.handler);
  },
Пример #2
0
Browser.prototype.init = function(){
    var components = Vue.util.extend({
        "webview": componentWebview(this),
        "navgation": this._navcomponent,
        "middle": uiMiddle
    }, this.components);

    var directives = Vue.util.extend({
        "href": directiveHref(this),
        "url": directiveURL(this)
    }, this.directives);


    var options = this._options;

    options.el = this.$el;
    options.name = options.browserName || 'browser';
    options.data = this.$data;
    options.components = Vue.util.extend(options.components || {}, components);
    options.directives = Vue.util.extend(options.directives || {}, directives);
    options.filters = Vue.util.extend(options.filters || {}, this.filters);
    options.events = Vue.util.extend(options.events || {}, this.Aevents);
    options.computed = Vue.util.extend(options.computed || {}, this.computeds);
    options.methods = Vue.util.extend(options.methods || {}, this.methods);
    options.watch = Vue.util.extend(options.watch || {}, this.watches);

    options.filters.webTitle = directiveURL.webTitle;

    this.Vue = new Vue(options);
    this.Vue.$browser = this;
}
Пример #3
0
const _determineName = () => {
  if (!$el.name) {
    throw new Error('Form field must have a name.')
  }

  name = Vue.util.camelize($el.name)
}
Пример #4
0
  return new Promise((resolve, reject) => {
    let result = Vue.util.isArray(value)
      ? !!value.length
      : !!value

    (result === true ? resolve : reject)()
  })
Пример #5
0
  created: function () {
    var vm = this;
    this._trackerHandles = [];

    /**
     * Wrap all queries in Tracker.autorun
     * Usage example:
     *     reactiveData: {
     *       tasks: function (component) {
     *         this.subscribe('myPubliation');
     *         return Tasks.find().fetch()
     *       }
     *     }
     */
    var reactiveData = this.$options.reactiveData
    if (reactiveData) {
      for (var key in reactiveData) {
        var reactiveFunction = reactiveData[ key ].bind(vm);
        Vue.util.defineReactive(vm, key, null)
        vm.autorun(function () {
          vm[ key ] = reactiveFunction(vm);
        })
      }
    }
  },
Пример #6
0
function Browser(context, options){
    var that = this;
    this._options = options || {};
    this.uid = _uid++;
    this._soyie = context;
    this._navcomponent =
    this.url =
    this.cb = null;
    this.$data = Vue.util.extend({}, this._options.data || {});
    this.$head = {};
    this.webviews = {};
    this.components = {};
    this.directives = {};
    this.filters = {};
    this.Aevents = {};
    this.computeds = {};
    this.methods = {};
    this.watches = {};
    this.current = null;
    this.next = new next(function(){
        typeof that.cb === 'function' &&
        that.cb();
    }, this);
    defineGetBrowserName(this);
    defineBrowserActiveStatus(this);
    defineToolbar(this);
    this.$nav(componentNavgation);
}
Пример #7
0
const _determineParentForm = () => {
  formName = Vue.util.camelize($el.form.name)
  $form = $vm[formName]

  if (typeof $form === 'undefined') {
    throw new Error('Could not determine parent form.')
  }
}
    validator: value => {
      if (options.includes(value)) {
        return true
      }

      Vue.util.warn(`The ${name} prop is invalid. Given value: ${value}. Available options: ${options.join(', ')}.`, this)

      return false
    }
Пример #9
0
 bind: function(){
     var that = this;
     this._cb = function(){
         browser._soyie.$frame.status = true;
         browser._soyie.$frame.center.value = that._title;
         browser._soyie.$frame.src = that._url;
     };
     Vue.util.on(this.el, 'click', this._cb);
 },
Пример #10
0
Browser.prototype.plugin = function(plugin){
    if ( typeof plugin === 'function' ){
        plugin.call(this, this._soyie, this._soyie.constructor);
    }
    else{
        this._options = Vue.util.extend(this._options, plugin || {});
    }
    return this;
}
        jQuery(el).on("select2:select", (e) => {

            if (!vnode.context.onChange) {
                util.warn('You need to implement the `onChange` method', vnode.context);
            }

            vnode.context.onChange(e.params.data, e);

            //$(el).trigger('change.select2');

        });
Пример #12
0
export const updateStratrunner = (state, update) => {
  let index = state.stratrunners.findIndex(i => i.id === update.gekko_id);
  let item = state.stratrunners[index];
  if(!item)
    return state;

  let updated = Vue.util.extend(item, update.updates);
  Vue.set(state.stratrunners, index, updated);

  return state;
}
Пример #13
0
 bind: function(){
     var that = this;
     if ( !this.el._hrefNexts ){
         this.el._hrefNexts = new next(function(){
             that._url && browser.res.redirect(that._url);
         });
         this.el._hrefNexts.om = this;
     }
     this._cb = function(){ that.el._hrefNexts.run(); };
     Vue.util.on(this.el, 'click', this._cb);
 },
Пример #14
0
export const addRoundtripToStratrunner = (state, update) => {
  let index = state.stratrunners.findIndex(i => i.id === update.gekko_id);
  let item = state.stratrunners[index];
  if(!item)
    return state;

  let updated = Vue.util.extend({}, item);
  updated.roundtrips.push(update.roundtrip);
  Vue.set(state.stratrunners, index, updated);

  return state;
}
Пример #15
0
export default function (component, changes, propsData) {
  return new Vue(Vue.util.extend({
    router,
    propsData,
    store: new Vuex.Store({
      state: {
        ...state,
        ...changes
      },
      mutations,
      actions,
      getters
    })
  }, component)).$mount()
}
Пример #16
0
 this.next.use(function(next){
     that.req.$scope = null;
     that.req.$head = null;
     if ( Layer.match(that.url) ){
         var done = next;
         if ( Layer.method === 'active' ) done = undefined;
         Vue.util.extend(that.req.params, Layer.params || {});
         that.req.$scope = that.Vue;
         that.req.$head = that.navgation;
         that._soyie.$current = that;
         that.toolbarDigest();
         return Layer.handle(that.req, that.res, done);
     }
     next();
 });
Пример #17
0
export function createVueField(type, schema = {}, model = null, disabled = false, options) {
	let elName = Vue.util.hyphenate(type);
	let el = document.createElement("div");		
	el.innerHTML = `<${elName} :schema.sync="schema" :model.sync="model" :disabled="disabled" v-ref:field></${elName}>`;
	let vm = new Vue({
		el: el,
		data: {
			schema,
			model,
			disabled,
			options
		}
	});
	let field = vm.$refs.field;
	
	return [ el, vm, field ] 
}
const Plugin = (Vue, options = {}) => {

    if (!jQuery().droppable) {
        util.warn('jQueryUI Droppable not installed or found globally to use `vue-ui-droppable` directive..', this);
    }

    // Install once example:
    // If you plugin need to load only once :)
    if (Plugin.installed) {
        return;
    }

    // Install Multi example:
    // If you plugin need to load multiple time :)
    /*if (Plugin.installed) {
     Plugin.installed = false;
     }*/

    Vue.directive('ui-droppable', Directive)

};
Пример #19
0
 beforeEach((done) => {
   el.innerHTML = `
     <validator name="validator1">
       <form novalidate>
         <input type="text" v-pickadate="'date'" v-validate:name="['required']">
       </form>
     </validator>
   `
   vm = new Vue({
     el,
     directives: {
       pickadate: {
         bind () {
           const elm = document.createElement('div')
           elm.innerHTML = '<p>hello world</p>'
           Vue.util.after(elm, this.el)
         }
       }
     }
   })
   vm.$nextTick(done)
 })
Пример #20
0
//@prop annotation, takes in the property name and adds that field to the corresponding types dataFieldMap for later introspection
//this can be given either nothing or an option hash. when an option hash is given, use the keys as described in IPropDescriptor
function prop(targetPrototypeOrOptions, key) {
    if (Vue.util.isPlainObject(targetPrototypeOrOptions) && !key) {
        return function (targetPrototype, key) {
            var propOptions = targetPrototypeOrOptions;
            var type = targetPrototype.constructor;
            var propFields = propFieldMap.get(type) || {};
            var propDescriptor = propFields[key] || {};
            propDescriptor.coerce = propOptions.coerce || propDescriptor.coerce;
            propDescriptor.required = propOptions.required || propDescriptor.required;
            propDescriptor.type = propOptions.type || propDescriptor.type;
            propDescriptor.twoWay = propOptions.twoWay || propDescriptor.twoWay;
            propDescriptor.validator = propOptions.validator || propDescriptor.validator;
            propDescriptor.default = propOptions.default || propDescriptor.default;
            propFields[key] = propDescriptor;
            propFieldMap.set(type, propFields);
        };
    }
    else {
        var type = targetPrototypeOrOptions.constructor;
        var propFields = propFieldMap.get(type) || {};
        propFields[key] = { required: false };
        propFieldMap.set(type, propFields);
    }
}
Пример #21
0
    modelValue() {
      return this.value;
    },
  },
  watch: {
    extraTip() {
      this.validate();
    },
  },
  ready() {
    if (this.validateOnInit) {
      this.validate();
    }

    if (this.autoValidate) {
      this.$watch('modelValue', util.debounce(() => this.validate(), 300));
    }
  },
  methods: {
    resetValid() {
      this.valid = true;
      this.invalids.required = false;
      this.invalids.maxlength = false;
      this.invalids.pattern = false;
      this.invalids.extra = false;
    },
    validate() {
      this.valid = true;
      this.validateRequired();
      this.validateMaxlength();
      this.validatePattern();
Пример #22
0
        enableAction(id, tool){
            this.model.attributes.enable = false;
        },

        disableAction(id, tool){
            this.model.attributes.enable = true;
        },

        clickActions(id, tool){
            // console.log(`${id}Action`);

            if (this[`${id}Action`]) {
                this[`${id}Action`](id, tool)
            }
            else {
                util.warn(`You need to implement ${id}Action method.`, this);
            }
        },

        enabled(id){

            if (id == 'enable') {
                return this.model.attributes.enable;
            }

            if (id == 'disable') {
                return !this.model.attributes.enable;
            }

            return true;
        },
Пример #23
0
import Vue from 'vue';
import deepAssign from '../utils/deep-assign';
import defaultMessages from './lang/zh-CN';

const proto = Vue.prototype;
const defaultLang = 'zh-CN';
const locale = {
  init() {
    Vue.util.defineReactive(proto, '$vantLang', defaultLang);
    Vue.util.defineReactive(proto, '$vantMessages', { [defaultLang]: defaultMessages });
  },

  use(lang, messages) {
    proto.$vantLang = lang;
    this.add({ [lang]: messages });
  },

  add(messages = {}) {
    deepAssign(proto.$vantMessages, messages);
  }
};

locale.init();
export default locale;
Пример #24
0
    hasItems () {
      return this.items.length > 0
    },

    isEmpty () {
      return !this.query
    },

    isDirty () {
      return !!this.query
    }
  },

  methods: {
    warn (msg) {
      Vue.util.warn('Typeahead requires the ' + msg)
    },

    update () {
      if (! this.query) {
        this.reset()
        return
      }

      this.loading = true

      this.$http.get(this.src, Object.assign({q:this.query}, this.data))
        .then(function (response) {
          if (this.query) {
            var data = response.data
            data = this.prepareResponseData ? this.prepareResponseData(data) : data
Пример #25
0
 reset: function() {
   vue.util.off(document.documentElement, 'click', this.handler);
 },
Пример #26
0
// register global utility filters.
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

Vue.config.productionTip = false
Vue.use(iView, {locale})

Vue.use(VueClipboard)
Vue.use(highlight)
Vue.use(katex)
Vue.use(VueAnalytics, {
  id: GOOGLE_ANALYTICS_ID,
  router
})

Vue.component('ECharts', ECharts)
Vue.component(VerticalMenu.name, VerticalMenu)
Vue.component(VerticalMenuItem.name, VerticalMenuItem)
Vue.component(Panel.name, Panel)

// 注册全局消息提示
Vue.prototype.$Message.config({
  duration: 2
})
Vue.prototype.$error = (s) => Vue.prototype.$Message.error(s)
Vue.prototype.$info = (s) => Vue.prototype.$Message.info(s)
Vue.prototype.$success = (s) => Vue.prototype.$Message.success(s)

new Vue(Vue.util.extend({router, store, i18n}, App)).$mount('#app')
Пример #27
0
                widget = this.field.widget;
            } else if (this.property.type === 'boolean') {
                widget = 'checkbox';
            } else if (this.property.type === 'integer') {
                widget = 'number-input';
            } else if (this.property.type === 'string') {
                if (this.property.format === 'markdown') {
                    widget = 'markdown-editor';
                } else if (this.property.enum) {
                    widget = 'select-input';
                }
            }
            widget = widget || 'text-input';

            // Lazy load component if needed
            if (!Vue.util.resolveAsset(this.$options, 'components', widget)) {
                this.$options.components[widget] = function(resolve, reject) {
                    require(['./' + widget + '.vue'], resolve);
                };
            }
            return widget;
        }
    },
    watch: {
        value(value) {
            this.$dispatch('field:change', this, value);
        }
    }
};

export default BaseField;
Пример #28
0
    return h('div',{
      domProps: {
        id: '__nuxt'
      }
    }, [
      loadingEl,
      transitionEl
    ])
  },
  data: () => ({
    layout: null,
    layoutName: ''
  }),
  beforeCreate () {
    Vue.util.defineReactive(this, 'nuxt', this.$options.nuxt)
  },
  created () {
    // Add this.$nuxt in child instances
    Vue.prototype.$nuxt = this
    // add to window so we can listen when ready
    if (typeof window !== 'undefined') {
      window.$nuxt = this
    }
    // Add $nuxt.error()
    this.error = this.nuxt.error
  },
  
  mounted () {
    this.$loading = this.$refs.loading
  },
Пример #29
0
 unbind: function(){
     Vue.util.off(this.el, 'click', this._cb);
 }
            }
            else {
                this.$toast.info(this.l10n.layoutNotCopied);
            }
        },

        toolsActiveClass(tool){
            return (_.isString(tool.data) && store.subpanel == tool.data) ? 'active' : '';
        },

        toolsAction(tool, event = false){

            let data = _.isUndefined(tool['data']) ? false : tool.data;

            if (!this[tool.action]) {
                util.warn(`You need to implement '${tool.action}' method.`, this);
            }
            else {
                this[tool.action](data, event);
            }
        },

        addNew(content, event = false){

            let data              = extend(true, {}, content);
            data.attributes.title = sprintf(data.attributes.title, (this.model.contents.length + 1));

            this.model.contents.push(data);
            store.stateChanged();
        },