Example #1
0
var Value = require('basis.data').Value;
var Popup = require('basis.ui.popup').Popup;
var getSourceFragment = require('../remote.js').getRemoteMethod('getSourceFragment');
var sourceLoc = new Value();
var source = new Value({ value: '' });

sourceLoc.as(function(loc) {
  if (loc && getSourceFragment.available) {
    getSourceFragment(loc, function(result) {
      if (loc === sourceLoc.value) {
        source.set(result);
        popup.realign();
      }
    });
  }

  source.set('');
});

var popup = new Popup({
  loc: sourceLoc,

  dir: 'top left bottom left',
  autorotate: [
    'bottom left top left'
  ],
  template: resource('./template/popup.tmpl'),
  binding: {
    isOpenFileSupported: basis.fn.$const(true), // FIXME: use real value
    loc: sourceLoc.as(function(loc) {
      return (loc || '').replace(/(:\d+){1,4}$/, '');
Example #2
0
var MoveableElement = require('basis.dragdrop').MoveableElement;
var templateInspector = resource('../picker/index.js');
var localStorage = global.localStorage || {};
var STORAGE_ID = 'component-inspector';

var currentInspector = new Value({
  handler: {
    change: function(sender, oldValue){
      if (oldValue)
        oldValue.stopInspect();
      if (this.value)
        this.value.startInspect();
    }
  }
});
var inspectMode = currentInspector.as(Boolean);
var currentInspectorName = currentInspector.as(function(inspector){
  return inspector ? inspector.name : '';
});

templateInspector.ready(function(inspector){
  inspector.inspectMode.link(null, function(value){
    if (value) {
      currentInspector.set(inspector);
    } else {
      if (currentInspector.value === inspector) {
        currentInspector.set();
      }
    }
  });
});
Example #3
0
//var fileInspector = resource('./module/fileInspector/fileInspector.js');

var inspectors = new Dataset();
var inspectMode = count(inspectors, 'update', 'data.mode').as(Boolean);
var currentInspector = new Value({
  handler: {
    change: function(sender, oldValue){
      if (oldValue)
        oldValue.stopInspect();
      if (this.value)
        this.value.startInspect();
    }
  }
});
var currentInspectorName = currentInspector.as(function(inspector){
  return inspector ? inspector.name : '';
});

[
  l10nInspector,
  templateInspector,
  heatInspector,
  gridInspector,
  rolesInspector
].forEach(function(inspectorRes){
  inspectorRes.ready(function(inspector){
    inspectors.add(inspector.inspectMode.link(new DataObject, function(value){
      if (value)
        currentInspector.set(inspector);
      else
        if (currentInspector.value === inspector)
Example #4
0
      api.openFile(loc);
      return;
    }

    selectedNode.set(target.node);
  }
}

var pickupTargetNode = new Value({ value: null });
var pickupTarget = pickupTargetNode.as(function(node) {
  if (node) {
    var instance = api.getInstanceByNode(node);
    if (instance) {
      return {
        node: node,
        instance: instance
      };
    }
  }

  return null;
});
pickupTarget.link(null, function(target) {
  if (target) {
    var rectNode = target.node;
    var rect;

    if (rectNode.nodeType == 3) {
      rectNode = document.createRange();
      rectNode.selectNodeContents(target.node);
    }