All Downloads are FREE. Search and download functionalities are using the official Maven repository.

public.javascript.rexster.template.template.js Maven / Gradle / Ivy

The newest version!
define(
    [
        "dust"
    ],
    function () {
        var templater = {};

        templater.templateNameMainMenuItem = "mainMenuItem";
        templater.templateNameMenuGraph = "menuGraph";
        templater.templateNameListVertices = "listVertices";
        templater.templateNameListVertexViewInEdgeList = "listVertexViewInEdgeList";
        templater.templateNameListVertexViewOutEdgeList = "listVertexViewOutEdgeList";
        templater.templateNameListExtensionList = "listExtensionList";

        templater.init = function() {
            // expects {id, menuName, [checked], [disabled]}
            var templateMainMenuMarkup = '{#menuItems}{/menuItems}';
            var dustMainMenuItemCompiled = dust.compile(templateMainMenuMarkup, templater.templateNameMainMenuItem);
            dust.loadSource(dustMainMenuItemCompiled);

            // expects {menuName, panel}
            var templateMenuGraph = '{#menuItems}{/menuItems}';
            var dustMenuGraphCompiled = dust.compile(templateMenuGraph, templater.templateNameMenuGraph);
            dust.loadSource(dustMenuGraphCompiled);

            // expects {_id}
            var templateListVertices = '{#vertices}
  • {_id}
  • {/vertices}'; var dustListVerticesCompiled = dust.compile(templateListVertices, templater.templateNameListVertices); dust.loadSource(dustListVerticesCompiled); // expects {_label, _inV, _outV, _id, currentGraphName} var templateListVertexViewInEdgeList = '{#edges}
  • {_outV} - {_label} - {_inV}
  • {/edges}'; var dustListVertexViewInEdgeListCompiled = dust.compile(templateListVertexViewInEdgeList, templater.templateNameListVertexViewInEdgeList); dust.loadSource(dustListVertexViewInEdgeListCompiled); // expects {_label, _outV, _inV, _id, currentGraphName} var templateListVertexViewOutEdgeList = '{#edges}
  • {_outV} - {_label} - {_inV}
  • {/edges}'; var dustListVertexViewOutEdgeListCompiled = dust.compile(templateListVertexViewOutEdgeList, templater.templateNameListVertexViewOutEdgeList); dust.loadSource(dustListVertexViewOutEdgeListCompiled); // expects {href, title, parameters[]} var templateListExtensionList = '{#extensions}

    {title}

    {#parameters}{/parameters}
    Execute
    {/extensions}'; var dustListExtensionListCompiled = dust.compile(templateListExtensionList, templater.templateNameListExtensionList); dust.loadSource(dustListExtensionListCompiled); } // public methods return { /** * Constructs
  • values for an array of vertices. * * @param data {Array} The list of vertex objects to render. * @param selector {Object} A jQuery selector or element to append the template to. */ applyListVerticesTemplate : function(data, selector) { if (data.length > 0) { dust.render(templater.templateNameListVertices, {vertices :data}, function(err, out) { $(out).appendTo(selector); }); } else { dust.render(templater.templateNameListVertices, {vertices :[{ "_id":"No vertices in this graph"}]}, function(err, out) { $(out).appendTo(selector); }); } }, /** * Constructs graph menu values for an array of graphs. * * @param data {Array} The list of graph objects to render. * @param selector {String} A jQuery selector or element to append the template to. */ applyMenuGraphTemplate : function(data, selector) { if (data.length > 0) { dust.render(templater.templateNameMenuGraph, {menuItems :data}, function(err, out) { $(out).appendTo(selector); }); } else { // TODO: need something here if nothing is configured ??? } }, /** * Constructs main menu. * * @param data {Array} The list of menu item objects to render. * @param selector {String} A jQuery selector or element to append the template to. */ applyMainMenuTemplate : function(data, selector) { dust.render(templater.templateNameMainMenuItem, {menuItems :data}, function(err, out) { $(out).appendTo(selector); }); }, applyListVertexViewOutEdgeListTempate : function(data, selector) { dust.render(templater.templateNameListVertexViewOutEdgeList, {edges :data}, function(err, out) { $(out).appendTo(selector); }); }, applyListVertexViewInEdgeListTempate : function(data, selector) { dust.render(templater.templateNameListVertexViewInEdgeList, {edges :data}, function(err, out) { $(out).appendTo(selector); }); }, applyListExtensionList : function(data, selector) { dust.render(templater.templateNameListExtensionList, {extensions :data.filter(function(extension){ return extension.op === "GET" })}, function(err, out) { $(out).appendTo(selector); }); }, initTemplates : templater.init } });




  • © 2015 - 2025 Weber Informatics LLC | Privacy Policy