Commit 229c90ff
Changed files (10)
app
assets
stylesheets
controllers
views
creations
config
spec
routing
app/assets/javascripts/application.js
@@ -7,7 +7,6 @@
//= require jquery
//= require jquery_ujs
//= require jquery-ui
-//= require jquery.Jcrop
//= require jquery.color
//= require jquery.colorbox
//= require jquery.validate
app/assets/javascripts/creations.js
@@ -1,32 +1,4 @@
var Creations = Creations || {};
-Creations.Crop = {
- initialize:function(){
- $('#cropbox').Jcrop({
- onChange: update_crop,
- onSelect: update_crop,
- setSelect: [100, 100, 260, 180],
- aspectRatio: 1.4
- });
- function update_crop(coords) {
- var rx = 260/coords.w;
- var ry = 180/coords.h;
- var lw = $('#cropbox').width();
- var lh = $('#cropbox').height();
-
- $('#preview').css({
- width: Math.round(rx * lw) + 'px',
- height: Math.round(ry * lh) + 'px',
- marginLeft: '-' + Math.round(rx * coords.x) + 'px',
- marginTop: '-' + Math.round(ry * coords.y) + 'px'
- });
-
- $("#crop_x").val(coords.x);
- $("#crop_y").val(coords.y);
- $("#crop_w").val(coords.w);
- $("#crop_h").val(coords.h);
- }
- }
-};
Creations.Show = {
initialize: function(){
$('.gallery').colorbox({
app/assets/javascripts/favorites.js.coffee
@@ -1,3 +0,0 @@
-# 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/
app/assets/javascripts/photos.js.coffee
app/assets/javascripts/tutorials.js.coffee
@@ -1,3 +0,0 @@
-# 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/
app/assets/stylesheets/application.css
@@ -2,7 +2,6 @@
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
* the top of the compiled file, but it's generally better to create a new file per style scope.
- *= require jquery.Jcrop
*= require colorbox
*= require_self
*= require_tree .
app/controllers/creations_controller.rb
@@ -55,23 +55,4 @@ class CreationsController < ApplicationController
current_user.creations.find(params[:id]).destroy
redirect_to(creations_url)
end
-
- # GET /creations/crop/1
- def crop
- @creation = current_user.creations.find(params[:id])
- end
-
- def crop_update
- @creation = current_user.creations.find(params[:id])
- @creation.crop_x = params[:creation]["crop_x"]
- @creation.crop_y = params[:creation]["crop_y"]
- @creation.crop_h = params[:creation]["crop_h"]
- @creation.crop_w = params[:creation]["crop_w"]
- @creation.reprocess_image
- if @creation.save
- redirect_to(@creation, :notice => 'Creation was successfully cropped.')
- else
- render :action => "new"
- end
- end
end
app/views/creations/crop.html.erb
@@ -1,44 +0,0 @@
-<% content_for :javascript do %>
- <style type="text/css">
- .preview { width:260px; height:180px; overflow:hidden; }
- .jcrop img { max-width:none; }
- </style>
- <script type="text/javascript" charset="utf-8">
- $(function() { Creations.Crop.initialize(); });
- </script>
-<% end %>
-<div class="row">
- <div class="page-header">
- <h1> <%= @creation.name %> <small> submitted by <%= link_to @creation.user.name, profile_path(@creation.user) %> </small> </h1>
- <% @creation.categories.each do |category| %>
- <span class="label notice"><a href="/categories/<%= category.slug %>"><%= category.name %></a></span>
- <% end %>
- </div>
-</div>
-<div class="row">
- <div class="span9 jcrop">
- <h3>Do you want to crop the image as well?</h3>
- <%= image_tag @creation.image_url(:large), :id => "cropbox" %>
- </div>
- <div class="span3 jcrop">
- <h3>Crop Preview</h3>
- <div class="preview">
- <%= image_tag @creation.image_url, :id => "preview" %>
- </div>
- </div>
-</div>
-<div class="row">
- <div class="span12">
- <%= form_for @creation, :url => creations_crop_update_path(@creation) do |f| %>
- <% for attribute in [:crop_x, :crop_y, :crop_h, :crop_w] %>
- <%= f.hidden_field attribute, :id => attribute %>
- <% end %>
- <div class="form-actions">
- <%= f.submit "Crop and Publish", :class => "btn btn-large btn-primary" %>
- <a class="btn btn-large" href="<%= url_for creation_path(@creation) %>">Skip</a>
- </div>
- <% end %>
- </div>
-</div>
-
-
config/routes.rb
@@ -18,8 +18,6 @@ Cake::Application.routes.draw do
resources :favorites, :only => [:index, :create]
resources :comments, :only => [:index, :new, :create]
end
- match 'creations/crop/:id' => 'creations#crop', :method => 'GET'
- match 'creations/crop_update/:id' => 'creations#crop_update', :as => 'creations_crop_update', :method => 'POST'
# /profiles
resources :profiles, :only => [:index, :show]
spec/routing/creations_routing_spec.rb
@@ -34,11 +34,5 @@ describe CreationsController do
{ :delete => "/creations/1" }.should route_to(:controller => "creations", :action => "destroy", :id => "1")
end
- it "routes to crop" do
- get('/creations/crop/1').should route_to("creations#crop", :id => "1", :method => "GET")
- end
- it "routes to crop update" do
- post('/creations/crop_update/1').should route_to("creations#crop_update", :id => "1", :method => "POST")
- end
end
end