Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop-downs and Created Date #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions app/views/projects/_table.html.erb
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
<table class="list projects">

<table class="list projects tree sortable">
<thead>
<tr>
<th><%= t :field_name %></th>
<th><%= t :field_description %></th>
<th><%= t :field_created_on %></th>
</tr>
</thead>
<tbody>
<% project_tree(projects) do |project, level| %>
<tr class="<%= cycle('odd', 'even') %> <%= project.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
<tr class="<%= cycle('odd', 'even') %> <%= level > 0 ? "treegrid-#{project.id} treegrid-parent-#{project.parent.id}" : "treegrid-#{project.id}" %>">
<td class="name">
<span>
<%= link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}") %>
</span>
</td>
<td class="wiki description">
<%= textilizable(project.short_description, :project => project) if project.description.present? %>
<td class="projcreated">
<%= format_date(project.created_on) %>
</td>
</tr>
<% end %>
</tbody>
</table>

<% content_for :header_tags do %>
<%= stylesheet_link_tag 'projects', :plugin => 'projects_table' %>
<% end %>
<%= stylesheet_link_tag 'jquery.treegrid.css', :plugin => 'projects_table' %>

<%= javascript_include_tag 'sorttable.js', :plugin => 'projects_table' %>

<%= javascript_include_tag 'jquery.treegrid.js', :plugin => 'projects_table' %>
<%= javascript_include_tag 'jquery.cookie.js', :plugin => 'projects_table' %>
<%= javascript_include_tag 'createTree.js', :plugin => 'projects_table' %>
<% end %>
Binary file added assets/images/collapse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/expand.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions assets/javascripts/createTree.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

console.log("Hello from doc!");
$(document).ready(function() {
$('.tree').treegrid({
'initialState': 'collapsed',
'saveState': true
});
console.log("Hello from tree!");
});
96 changes: 96 additions & 0 deletions assets/javascripts/jquery.cookie.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*!
* jQuery Cookie Plugin v1.3.1
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2013 Klaus Hartl
* Released under the MIT license
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as anonymous module.
define(['jquery'], factory);
} else {
// Browser globals.
factory(jQuery);
}
}(function ($) {

var pluses = /\+/g;

function decode(s) {
if (config.raw) {
return s;
}
return decodeURIComponent(s.replace(pluses, ' '));
}

function decodeAndParse(s) {
if (s.indexOf('"') === 0) {
// This is a quoted cookie as according to RFC2068, unescape...
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
}

s = decode(s);

try {
return config.json ? JSON.parse(s) : s;
} catch(e) {}
}

var config = $.cookie = function (key, value, options) {

// Write
if (value !== undefined) {
options = $.extend({}, config.defaults, options);

if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
t.setDate(t.getDate() + days);
}

value = config.json ? JSON.stringify(value) : String(value);

return (document.cookie = [
config.raw ? key : encodeURIComponent(key),
'=',
config.raw ? value : encodeURIComponent(value),
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
options.path ? '; path=' + options.path : '',
options.domain ? '; domain=' + options.domain : '',
options.secure ? '; secure' : ''
].join(''));
}

// Read
var cookies = document.cookie.split('; ');
var result = key ? undefined : {};
for (var i = 0, l = cookies.length; i < l; i++) {
var parts = cookies[i].split('=');
var name = decode(parts.shift());
var cookie = parts.join('=');

if (key && key === name) {
result = decodeAndParse(cookie);
break;
}

if (!key) {
result[name] = decodeAndParse(cookie);
}
}

return result;
};

config.defaults = {};

$.removeCookie = function (key, options) {
if ($.cookie(key) !== undefined) {
// Must not alter options, thus extending a fresh object...
$.cookie(key, '', $.extend({}, options, { expires: -1 }));
return true;
}
return false;
};

}));
Loading