Sha256: d14c8738dc7e86a93a0fe98af8298cfbfa74a8a73cc8467e1b403a06b78b7404

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

<% javascript_tag do %>
    if (typeof Prototype != 'object') {
       //load up prototype... it's needed here
       var s = document.createElement('script');
       s.setAttribute('src','http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js');
       document.getElementsByTagName('body')[0].appendChild(s);
    }

    function show_graph (privilege, context, user_ids) {
        var params = {
          privilege_hierarchy: 1,
          highlight_privilege: privilege,
          filter_contexts: context
        };
        if (user_ids)
          params['user_ids[]'] = user_ids;
        show_graph_with_params('graph', params);
    }

    var graph_params = {};
    function show_graph_with_params (graph_id, params) {
        graph_params[graph_id] = params;
        base_url = "<%= graph_authorization_rules_path('svg') %>";
        $(graph_id).data = base_url + '?' + Object.toQueryString(params);
        $(graph_id).up().show();
    }

    function update_graph_params (graph_id, params) {
        show_graph_with_params(graph_id,
            $H(graph_params[graph_id] || {}).merge(params).toObject());
    }

    function toggle_graph_params (graph_id) {
        var opts = {}
        $A(arguments).slice(1).each(function (param) {
          opts[param] = graph_params[graph_id][param] ? null : '1';
        });
        update_graph_params(graph_id, opts)
    }
<% end %>
<div id="graph-container" style="display:none">
<%= link_to '#', "Hide", onclick: "$('graph-container').hide()", :class => 'important' %><br/>
<object id="graph" data="" type="image/svg+xml" style="max-width:100%;margin-top: 0.5em"/>
</div>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zeiv-declarative_authorization-1.0.0.pre app/views/authorization_rules/_show_graph.erb