Sha256: a6561eba6830df5935a2d5f227122df68012fd7a08ac01d0d6010389402ec2cf

Contents?: true

Size: 1.76 KB

Versions: 2

Compression:

Stored size: 1.76 KB

Contents

//= require jquery
//= require turbolinks
//= require d3
//= require jsrender
//= require dist/mapexplorer-core

document.addEventListener('turbolinks:load', function() {

  var segmentTemplate = $.templates("#segment-template");

  $('.mapexplorer').each(function() {
    var map = $(this);
    var helpers = {
      json: function(val) {
        return JSON.stringify(val, undefined, 2);
      },
      merklePathTree: function(merklePath) {
        setTimeout(function(){
          var tree = new mapexplorerCore.MerklePathTree(map.find('.merkle-path-tree')[0]);
          tree.display(merklePath);
        });
        return '<div class="merkle-path-tree"></div>';
      },
      argsFmt: function(args) {
        return args.map(function(arg) {
          return JSON.stringify(args, undefined, 2);;
        }).join(', ');
      }
    };

    var builder = new mapexplorerCore.ChainTreeBuilder(this);

    builder.build({
      id: map.data('mapId'),
      applicationUrl: map.data('applicationUrl'),
      chainscript: map.data('chainscript')
    }, {
      onclick: function(d, onHide) {
        var segment = d.data;

        var refresh = function() {
          map.find('.segment').html(segmentTemplate.render({ segment: segment }, helpers));

          map.find('.nav-link').on('click', function() {
            segment.currentSection = $(this).data('target');
            refresh();
          });

          map.find('a.close').on('click', function(){
            map.find('.segment').html(null);
            onHide();
            return false;
          });
        };

        segment.show = function(target) {
          return this.currentSection === target;
        };

        segment.currentSection = 'state';
        refresh();
      },
      onTag: function(){}
    });
  });
});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mapexplorer-rails-1.0.0.pre.alpha.1 app/assets/javascripts/mapexplorer-rails.js
mapexplorer-rails-1.0.0.pre.alpha app/assets/javascripts/mapexplorer-rails.js