Esempio n. 1
0
CmmnEditor.prototype.triggerEditorActions = function(action, options) {
  var opts = options || {};

  var modeler = this.getModeler();

  var editorActions = modeler.get('editorActions', false);

  if (!editorActions) {
    return;
  }

  if ('moveCanvas' === action) {
    opts = assign({ speed: 20 }, options);
  }

  if ('zoomIn' === action) {
    action = 'stepZoom';

    opts = {
      value: 1
    };
  }

  if ('zoomOut' === action) {
    action = 'stepZoom';

    opts = {
      value: -1
    };
  }

  if ('zoom' === action) {
    opts = assign({
      value: 1
    }, options);
  }


  if ('zoomFit' === action) {
    action = 'zoom';

    opts = assign({
      value: 'fit-viewport'
    }, options);
  }

  // ignore all editor actions (besides the following three)
  // if there's a current active input or textarea
  if ([ 'removeSelection', 'stepZoom', 'zoom' ].indexOf(action) === -1 && isInputActive()) {
    return;
  }

  debug('editor-actions', action, opts);

  // forward other actions to editor actions
  editorActions.trigger(action, opts);
};
export default function video_lectures(state = {
  transcode_formats: ['mp4', 'webm'],
  list: [],
  aws: {},
  is_fetching: false,
  need_request: true
}, action) {
  switch (action.type) {
    case VIDEO_LECTURES_REQUEST:
      return assign({}, state, { 
        is_fetching: true,
        need_request: false
      });
    case VIDEO_LECTURES_SUCCESS:
      return assign({}, state, { 
        list: action.response.video_lectures,
        aws: action.response.aws,
        is_fetching: false,
        need_request: false
      });
    case VIDEO_LECTURES_FAILURE:
      return assign({}, state, { 
        is_fetching: false,
        need_request: true
      });
    case APPEND_VIDEO_LECTURE:
      return Object.assign({}, state, { 
        list: [...state.list, action.videoLecture]
      });
    case REMOVE_VL:
      if (action.response) {
        let _state = Object.assign({}, state);
        remove(_state.list, {id: action.vlId});
        return _state;
      } else {
        return state;
      }
    case UPDATE_VL:
    case REPLACE_VIDEO_LECTURE:
      return Object.assign({}, state, { 
        list: map(state.list, (vl) => {
          if (action.video_lecture.id === vl.id) {
            return vl;
          }
        })
      });
    default:
      return state;
  }
}
  this.executed([ 'label.create' ], function(e) {

    var element = e.context.shape,
        businessObject,
        di;

    // we want to trigger on real labels only
    if (!element.labelTarget) {
      return;
    }

    // we want to trigger on BPMN elements only
    if (!is(element.labelTarget || element, 'bpmn:BaseElement')) {
      return;
    }

    businessObject = element.businessObject,
    di = businessObject.di;


    if (!di.label) {
      di.label = bpmnFactory.create('bpmndi:BPMNLabel', {
        bounds: bpmnFactory.create('dc:Bounds')
      });
    }

    assign(di.label.bounds, {
      x: element.x,
      y: element.y,
      width: element.width,
      height: element.height
    });
  });
Esempio n. 4
0
TextBox.prototype.create = function(bounds, style, value) {

  var textarea = this.textarea,
      container = this.container;

  assign(textarea.style, {
    width: bounds.width + 'px',
    height: bounds.height + 'px',
    left: bounds.x + 'px',
    top: bounds.y + 'px',
    position: 'absolute',
    textAlign: 'center',
    boxSizing: 'border-box'
  }, style || {});

  textarea.value = value;
  textarea.title = 'Press SHIFT+Enter for line feed';

  domEvent.bind(textarea, 'keydown', this.keyHandler);
  domEvent.bind(textarea, 'mousedown', stopPropagation);

  container.appendChild(textarea);

  setTimeout(function() {
    if (textarea.parent) {
      textarea.select();
    }
    textarea.focus();
  }, 100);
};
Esempio n. 5
0
    function copyRangeOfSequenceData(sequenceData, rangeToCopy, allowPartialAnnotationsOnCopy) {
        var newSequenceData = {};
        newSequenceData.sequence = getSubstringByRange(sequenceData.sequence, rangeToCopy);
        newSequenceData.features = copyAnnotationsByRange(sequenceData.features, rangeToCopy, sequenceData.sequence.length);
        newSequenceData.parts = copyAnnotationsByRange(sequenceData.parts, rangeToCopy, sequenceData.sequence.length);

        function copyAnnotationsByRange(annotations, rangeToCopy, sequenceLength) {
            var copiedAnnotations = [];
            annotations.forEach(function(annotation) {
                var overlaps = getOverlapsOfPotentiallyCircularRanges(annotation, rangeToCopy, sequenceLength);
                var collapsedOverlaps = collapseOverlapsGeneratedFromRangeComparisonIfPossible(overlaps, sequenceLength);
                if (!allowPartialAnnotationsOnCopy) {
                    //filter out any annotations that aren't whole
                    collapsedOverlaps = collapsedOverlaps.filter(function(overlap) {
                        return (overlap.start === annotation.start && overlap.end === annotation.end);
                    });
                }
                if (collapsedOverlaps.length > 1) {
                    //tnrtodo: add a new bson id for the 2nd annotation!
                    console.log('splitting annotation on copy!');
                }
                collapsedOverlaps.forEach(function(collapsedOverlap) {
                    //shift the collapsedOverlaps by the rangeToCopy start if necessary
                    var collapsedAndShiftedOverlap = shiftCopiedOverlapByRange(collapsedOverlap, rangeToCopy, sequenceLength);
                    copiedAnnotations.push(assign({}, annotation, collapsedAndShiftedOverlap));
                });
            });
            return copiedAnnotations;
        }
        return assign({}, sequenceData, newSequenceData); //merge any other properties that exist in sequenceData into newSequenceData
    }
Esempio n. 6
0
  render() {
    let qs = querystring.stringify(assign({}, this.state.qs, {
      tuid: this.props.uid,
      title: this.props.name
    }));

    let userPostUrl = this.state.qs.tuid
      ? 'javascript:void(0)'
      : ('./user-posts.html?' + qs);

    let avatarClassNames = classNames('avatar', this.props.size || 's40');

    if (this.props.url) {
      let style = {
        backgroundImage: `url(${this.props.url}!small)`,
        backgroundSize: 'cover',
        backgroundPosition: 'center center'
      };

      return (
        <a href={userPostUrl} className={avatarClassNames} style={style}></a>
      );
    } else {
      return <a href={userPostUrl} className={avatarClassNames}><i className="icon icon-avatar"></i></a>
    }

  }
Esempio n. 7
0
Addon.lookup = function(addon) {
  var Constructor, addonModule, modulePath, moduleDir;

  modulePath = Addon.resolvePath(addon);
  moduleDir  = path.dirname(modulePath);

  if (existsSync(modulePath)) {
    addonModule = require(modulePath);

    if (typeof addonModule === 'function') {
      Constructor = addonModule;
      Constructor.prototype.root = Constructor.prototype.root || moduleDir;
      Constructor.prototype.pkg  = Constructor.prototype.pkg || addon.pkg;
    } else {
      Constructor = Addon.extend(assign({
        root: moduleDir,
        pkg: addon.pkg
      }, addonModule));
    }
  }

  if (!Constructor) {
    throw new SilentError('The `' + addon.pkg.name + '` addon could not be found at `' + addon.path + '`.');
  }

  return Constructor;
};
Esempio n. 8
0
    return Promise.all([liveReloadPort, port]).then(function(values) {
      var liveReloadPort = values[0];
      var port = values[1];
      commandOptions = assign({}, commandOptions, {
        port: port,
        liveReloadPort: liveReloadPort,
        liveReloadHost: liveReloadHost,
        baseURL: this.project.config(commandOptions.environment).baseURL || '/'
      });

      if (commandOptions.proxy) {
        if (!commandOptions.proxy.match(/^(http:|https:)/)) {
          var message = 'You need to include a protocol with the proxy URL.' + EOL + 'Try --proxy http://' + commandOptions.proxy;

          return Promise.reject(new SilentError(message));
        }
      }

      var ServeTask = this.tasks.Serve;
      var serve = new ServeTask({
        ui: this.ui,
        analytics: this.analytics,
        project: this.project
      });

      return win.checkWindowsElevation(this.ui).then(function() {
        return serve.run(commandOptions);
      });
    }.bind(this));
Esempio n. 9
0
export var SendVerifyCode = (tel) => {
  return fetch('/mvc/loginJsonNew', assign({
    body: querystring.stringify({
      accountNo: tel
    })
  }, POST_OPT));
}
Esempio n. 10
0
File: layout.js Progetto: rhsnv/dayz
    constructor(options) {
        assign(this, options);
        this.cache = Object.create(null);

        let multiDayCount = 0;
        const cacheMethod = (
            ('day' === this.display) ? 'addtoDaysCache' : 'calculateSpanningLayout'
        );
        if (! this.events){ return; }
        const range = this.range;

        this.events.each( (event) => {
            // we only care about events that are in the range we were provided
            if (range.overlaps(event.range())){
                this[cacheMethod](event);
                if (!event.isSingleDay()){
                    multiDayCount += 1;
                }
            }
        });
        this.multiDayCount = multiDayCount;
        this.calculateStacking();
        if (!this.isDisplayingAsMonth() && !this.displayHours){
            this.displayHours = this.hourRange();
        } else {
            this.displayHours = this.displayHours || [0, 24];
        }
    }
Esempio n. 11
0
(function () {
  // add custom browserify options here
  var customOpts = {
    entries: ['./demo/src/index.jsx'],
    debug: true,
  };
  var opts = assign({}, watchify.args, customOpts);
  var b = watchify(browserify(opts).transform(babelify));

  gulp.task('js', ['copy-demo-statics', 'build'], bundle); // so you can run `gulp js` to build the file
  b.on('update', bundle); // on any dep update, runs the bundler
  b.on('log', gutil.log); // output build logs to terminal

  function bundle() {
    return b.bundle()
      // log errors if they happen
      .on('error', gutil.log.bind(gutil, 'Browserify Error'))
      .pipe(source('index.js'))
      // optional, remove if you don't need to buffer file contents
      .pipe(buffer())
      // optional, remove if you dont want sourcemaps
      .pipe(sourcemaps.init({loadMaps: true})) // loads map from browserify file
         // Add transformation tasks to the pipeline here.
      .pipe(sourcemaps.write('./')) // writes .map file
      .pipe(size())
      .pipe(gulp.dest('./demo/build'))
      .pipe(reload({stream: true}));
  }
})();
Esempio n. 12
0
function elementData(semantic, attrs) {
  return assign({
    id: semantic.id,
    type: semantic.$type,
    businessObject: semantic
  }, attrs);
}
Esempio n. 13
0
CmmnEditor.prototype.updateState = function() {

  var modeler = this.getModeler(),
      initialState = this.initialState,
      commandStack,
      inputActive;

  // ignore change events during import
  if (initialState.importing) {
    return;
  }

  var elementsSelected,
      elements,
      dirty;

  var stateContext = {
    cmmn: true,
    copy: false,
    paste: false,
    save: true,
    undo: !!initialState.undo,
    redo: !!initialState.redo,
    dirty: initialState.dirty,
    exportAs: [ 'png', 'jpeg', 'svg' ]
  };

  if (isImported(modeler)) {
    commandStack = modeler.get('commandStack');

    dirty = (
      initialState.dirty ||
      initialState.reimported ||
      initialState.stackIndex !== commandStack._stackIdx
    );

    // direct editing function
    elements = modeler.get('selection').get();
    elementsSelected = false;

    if (elements.length >= 1) {
      elementsSelected = true;
    }

    inputActive = isInputActive();

    stateContext = assign(stateContext, {
      undo: commandStack.canUndo(),
      redo: commandStack.canRedo(),
      elementsSelected: elementsSelected && !inputActive,
      dirty: dirty,
      zoom: true,
      editable: true,
      inactiveInput: !inputActive
    });
  }

  this.emit('state-updated', stateContext);
};
Esempio n. 14
0
  each(metadata(contents), function(val, key) {

    if( val.desc || Object.keys(val.props).length ){
      var doclets = metadata.parseDoclets(val.desc || '') || {};

      markdown = apiFile(assign({ name: doclets.alias || key }, val))
    }
  }, this)
  this.computeStyle = function(custom, traits, defaultStyles) {
    if (!isArray(traits)) {
      defaultStyles = traits;
      traits = [];
    }

    return self.style(traits || [], assign({}, defaultStyles, custom || {}));
  };
Esempio n. 16
0
function removeUserStepFromFlow( flow ) {
	if ( ! flow ) {
		return;
	}

	return assign( {}, flow, {
		steps: reject( flow.steps, stepName => stepConfig[ stepName ].providesToken )
	} );
}
Esempio n. 17
0
 query: function(connection, obj) {
   if (typeof obj === 'string') obj = {sql: obj}
   this.emit('query', assign({__knexUid: connection.__knexUid}, obj))
   debugQuery(obj.sql)
   return this._query.call(this, connection, obj).catch(function(err) {
     err.message = SqlString.format(obj.sql, obj.bindings) + ' - ' + err.message
     throw err
   })
 },
Esempio n. 18
0
CustomModeler.prototype._addCustomConnection = function(customElement) {

  this._customElements.push(customElement);

  var canvas = this.get('canvas'),
      elementFactory = this.get('elementFactory'),
      elementRegistry = this.get('elementRegistry');

  var customAttrs = assign({ businessObject: customElement }, customElement);

  var connection = elementFactory.create('connection', assign(customAttrs, {
    source: elementRegistry.get(customElement.source),
    target: elementRegistry.get(customElement.target)
  }),
  elementRegistry.get(customElement.source).parent);

  return canvas.addConnection(connection);

};
Esempio n. 19
0
 return new Promise(function(resolver, rejecter) {
   var sql = obj.sql
   if (!sql) return resolver()
   if (obj.options) sql = assign({sql: sql}, obj.options)
   connection.query(sql, obj.bindings, function(err, rows, fields) {
     if (err) return rejecter(err)
     obj.response = [rows, fields]
     resolver(obj)
   })
 })
Esempio n. 20
0
  modeler.saveSVG((err, svg) => {
    var file = {};

    if (err) {
      return done(err);
    }

    if (type !== 'svg') {
      try {
        assign(file, { contents: generateImage(type, svg) });
      } catch (err) {
        return done(err);
      }
    } else {
      assign(file, { contents: svg });
    }

    done(null, file);
  });
Esempio n. 21
0
 initializePool: function(config) {
   if (this.pool) this.destroy()
   this.pool = new this.Pool(assign(this.poolDefaults(config.pool || {}), config.pool))
   this.pool.on('error', function(err) {
     helpers.error('Pool2 - ' + err)
   })
   this.pool.on('warn', function(msg) {
     helpers.warn('Pool2 - ' + msg)
   })
 },
      return response.reduce((json, collection) => {
        let serializer = this._serializerFor(collection);

        if (serializer.embed) {
          json[pluralize(collection.type)] = this._serializeModelOrCollection(collection);
        } else {
          json = _assign(json, this._serializeSideloadedModelOrCollection(collection));
        }

        return json;
      }, {});
Esempio n. 23
0
  constructor(plugin: Object) {
    super();

    this.initialized = false;
    this.raw         = assign({}, plugin);

    this.manipulateOptions = this.take("manipulateOptions");
    this.post              = this.take("post");
    this.pre               = this.take("pre");
    this.visitor           = this.normalize(clone(this.take("visitor")) || {});
  }
Esempio n. 24
0
  function write(element, options, callback) {
    if (isFunction(options)) {
      callback = options;
      options = {};
    }

    // skip preamble for tests
    options = assign({ preamble: false }, options);

    moddle.toXML(element, options, callback);
  }
Esempio n. 25
0
      this._records.forEach(function(record) {
        let oldRecord = _assign({}, record);

        for (let attr in attrs) {
          record[attr] = attrs[attr];
        }

        if (!_isEqual(oldRecord, record)) {
          changedRecords.push(record);
        }
      });
  _serializeModel(model, removeForeignKeys = true, serializeRelationships = true) {
    if (this._hasBeenSerialized(model)) {
      return;
    }

    let attrs = this._attrsForModel(model, removeForeignKeys);

    this._augmentAlreadySerialized(model);
    let relatedAttrs = serializeRelationships ? this._attrsForRelationships(model) : {};

    return _assign(attrs, relatedAttrs);
  }
Esempio n. 27
0
  function rebuildMenu(state) {
    var mainWindow = app.mainWindow,
        isDevToolsOpened = false;

    if (!state.hasOwnProperty('devtools') && mainWindow) {
      isDevToolsOpened = mainWindow.isDevToolsOpened();

      state = assign(state, { devtools: isDevToolsOpened });
    }

    new MenuBuilder({ state: state }).build();
  }
Esempio n. 28
0
  firstOrCreate(query, attributesForNew={}) {
    let queryResult = this.where(query);
    let record = queryResult[0];

    if (record) {
      return record;
    } else {
      let mergedAttributes = _assign(attributesForNew, query);
      let createdRecord = this.insert(mergedAttributes);

      return createdRecord;
    }
  }
Esempio n. 29
0
    getGfx = function(elementData) {
      assign(elementData, { x: 0, y: 0 });

      var tempShape = elementFactory.createShape(elementData);

      canvas.addShape(tempShape, rootElement);

      var gfx = elementRegistry.getGraphics(tempShape).clone();

      canvas.removeShape(tempShape);

      return gfx;
    };
  this.style = function(traits, additionalAttrs) {

    if (!isArray(traits) && !additionalAttrs) {
      additionalAttrs = traits;
      traits = [];
    }

    var attrs = reduce(traits, function(attrs, t) {
      return assign(attrs, defaultTraits[t] || {});
    }, {});

    return additionalAttrs ? assign(attrs, additionalAttrs) : attrs;
  };