Merge branch 'master' of github.com:Connoropolous/metamaps_gen002

This commit is contained in:
Connor Turland 2012-12-31 16:16:19 -05:00
commit 0d4e694a4c
11 changed files with 259 additions and 11 deletions

View file

@ -12,7 +12,7 @@ gem 'formula'
gem 'formtastic'
gem 'json'
gem 'rails3-jquery-autocomplete'
gem 'best_in_place'
# Gems used only for assets and not required
# in production environments by default.

View file

@ -32,6 +32,9 @@ GEM
authlogic (3.1.0)
activerecord (>= 3.0.7)
activerecord (>= 3.0.7)
best_in_place (2.0.2)
jquery-rails
rails (~> 3.1)
builder (3.0.3)
cancan (1.6.7)
coffee-rails (3.2.2)
@ -118,6 +121,7 @@ PLATFORMS
DEPENDENCIES
authlogic
best_in_place
cancan
coffee-rails (~> 3.2.1)
formtastic

View file

@ -12,6 +12,8 @@
//
//= require jquery
//= require jquery-ui
//= require jquery.purr
//= require best_in_place
//= require autocomplete-rails-uncompressed
//= require jquery_ujs
//= require_tree .

View file

@ -1,3 +1,6 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
jQuery ->
$('.best_in_place').best_in_place()

View file

@ -0,0 +1,180 @@
/**
* jquery.purr.js
* Copyright (c) 2008 Net Perspective (net-perspective.com)
* Licensed under the MIT License (http://www.opensource.org/licenses/mit-license.php)
*
* @author R.A. Ray
* @projectDescription jQuery plugin for dynamically displaying unobtrusive messages in the browser. Mimics the behavior of the MacOS program "Growl."
* @version 0.1.0
*
* @requires jquery.js (tested with 1.2.6)
*
* @param fadeInSpeed int - Duration of fade in animation in miliseconds
* default: 500
* @param fadeOutSpeed int - Duration of fade out animationin miliseconds
default: 500
* @param removeTimer int - Timeout, in miliseconds, before notice is removed once it is the top non-sticky notice in the list
default: 4000
* @param isSticky bool - Whether the notice should fade out on its own or wait to be manually closed
default: false
* @param usingTransparentPNG bool - Whether or not the notice is using transparent .png images in its styling
default: false
*/
( function( $ ) {
$.purr = function ( notice, options )
{
// Convert notice to a jQuery object
notice = $( notice );
// Add a class to denote the notice as not sticky
if ( !options.isSticky )
{
notice.addClass( 'not-sticky' );
};
// Get the container element from the page
var cont = document.getElementById( 'purr-container' );
// If the container doesn't yet exist, we need to create it
if ( !cont )
{
cont = '<div id="purr-container"></div>';
}
// Convert cont to a jQuery object
cont = $( cont );
// Add the container to the page
$( 'body' ).append( cont );
notify();
function notify ()
{
// Set up the close button
var close = document.createElement( 'a' );
$( close ).attr(
{
className: 'close',
href: '#close',
innerHTML: 'Close'
}
)
.appendTo( notice )
.click( function ()
{
removeNotice();
return false;
}
);
// Add the notice to the page and keep it hidden initially
notice.appendTo( cont )
.hide();
if ( jQuery.browser.msie && options.usingTransparentPNG )
{
// IE7 and earlier can't handle the combination of opacity and transparent pngs, so if we're using transparent pngs in our
// notice style, we'll just skip the fading in.
notice.show();
}
else
{
//Fade in the notice we just added
notice.fadeIn( options.fadeInSpeed );
}
// Set up the removal interval for the added notice if that notice is not a sticky
if ( !options.isSticky )
{
var topSpotInt = setInterval( function ()
{
// Check to see if our notice is the first non-sticky notice in the list
if ( notice.prevAll( '.not-sticky' ).length == 0 )
{
// Stop checking once the condition is met
clearInterval( topSpotInt );
// Call the close action after the timeout set in options
setTimeout( function ()
{
removeNotice();
}, options.removeTimer
);
}
}, 200 );
}
}
function removeNotice ()
{
// IE7 and earlier can't handle the combination of opacity and transparent pngs, so if we're using transparent pngs in our
// notice style, we'll just skip the fading out.
if ( jQuery.browser.msie && options.usingTransparentPNG )
{
notice.css( { opacity: 0 } )
.animate(
{
height: '0px'
},
{
duration: options.fadeOutSpeed,
complete: function ()
{
notice.remove();
}
}
);
}
else
{
// Fade the object out before reducing its height to produce the sliding effect
notice.animate(
{
opacity: '0'
},
{
duration: options.fadeOutSpeed,
complete: function ()
{
notice.animate(
{
height: '0px'
},
{
duration: options.fadeOutSpeed,
complete: function ()
{
notice.remove();
}
}
);
}
}
);
}
};
};
$.fn.purr = function ( options )
{
options = options || {};
options.fadeInSpeed = options.fadeInSpeed || 500;
options.fadeOutSpeed = options.fadeOutSpeed || 500;
options.removeTimer = options.removeTimer || 4000;
options.isSticky = options.isSticky || false;
options.usingTransparentPNG = options.usingTransparentPNG || false;
this.each( function()
{
new $.purr( this, options );
}
);
return this;
};
})( jQuery );

View file

@ -73,10 +73,22 @@ a {
text-decoration:none;
}
/*
* Utility
*/
.clearfloat {
clear:both;
}
.hidden {
display: none;
}
/*
* Layout stuffs
*/
.new_session,
.new_user,
.new_map,

View file

@ -33,19 +33,29 @@ class ItemsController < ApplicationController
# GET items/:id
def show
@current = current_user
@item = Item.find(params[:id]).authorize_to_show(@current)
@item = Item.find(params[:id]).authorize_to_show(@current)
if @item
@relatives = @item.network_as_json(@current).html_safe
else
redirect_to root_url and return
end
if @item
@relatives = @item.network_as_json(@current).html_safe
else
redirect_to root_url and return
end
respond_to do |format|
respond_to do |format|
format.html { respond_with(@item, @user) }
format.json { respond_with(@relatives) }
end
end
# GET showcard/:id
def showcard
@user = current_user
@item = Item.find(params[:id]).authorize_to_show(@user)
respond_to do |format|
format.html { respond_with(@item, @user) }
end
end
# POST items
def create

View file

@ -0,0 +1,29 @@
<div class="showcard item_<%= @item.id %>">
<div class="CardOnGraph" title="Click to Hide" id="item_' + node.id + '">
<p class="type">
<%= @item.item_category.name %>
</p>
<img alt="<%= @item.item_category.name %>"
src="/assets/<%= @item.item_category.name %>.png"
class="icon" height="50" width="50" />
<div class="scroll">
<a href="/items/<%=@item.id%>" class="title">
<%= @item.name %>
</a>
<div class="contributor">
Added by:
<a href="/users/<%= @user.id %>">
<%= @user.name %>
</a>
</div>
<div class="desc">
<p>
<%= @item.desc %>
</p>
</div>
</div><!-- div.scroll -->
<a href="<%= @item.link %>" class="link" target="_blank">
<%= @item.link %>
</a>
</div>
</div>

View file

@ -0,0 +1,5 @@
<script type="text/javascript">
//create a global array we can fill with id's of loaded nodes
var loaded_nodes = new Array();
</script>
<div id="loaded_nodes" class="hidden"></div>

View file

@ -60,5 +60,6 @@
<% end %>
<%= render :partial => 'layouts/ga' if Rails.env.production? %>
<%= render :partial => 'layouts/nodeinfo' %>
</body>
</html>
</html>

View file

@ -9,7 +9,9 @@ ISSAD::Application.routes.draw do
match 'search', to: 'main#search', via: :get, as: :search
match 'maps/:id/savelayout', to: 'maps#savelayout', via: :put, as: :savelayout
match 'showcard/:id', to: 'items#showcard', via: :get, as: :showcard
resource :session
resources :items do