Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- Added best_in_place support.

- Using a custom uploader plugin.
  • Loading branch information...
commit c8ad5d05d213eb3398048799ba0122664dba9b77 1 parent 2b3ede3
@yortz authored
View
1  Gemfile
@@ -7,6 +7,7 @@ gem 'nifty-generators'
gem 'carrierwave'
gem 'fog'
gem 'mini_magick'
+gem "best_in_place", :git => 'git://github.com/proton/best_in_place.git'
group :assets do
gem 'sass-rails', '~> 3.1.4'
View
8 Gemfile.lock
@@ -1,3 +1,10 @@
+GIT
+ remote: git://github.com/proton/best_in_place.git
+ revision: f101f00e20230c72ee681232b6440144d1ca2448
+ specs:
+ best_in_place (0.1.9)
+ rails (~> 3.0)
+
GEM
remote: http://rubygems.org/
specs:
@@ -130,6 +137,7 @@ PLATFORMS
ruby
DEPENDENCIES
+ best_in_place!
carrierwave
coffee-rails (~> 3.1.1)
fog
View
5 app/assets/javascripts/application.js
@@ -6,7 +6,10 @@
//
//= require jquery
//= require jquery-ui
+//= require best_in_place
//= require jquery.iframe-transport
//= require jquery.fileupload
//= require jquery.fileupload-ui
-//= require_tree .
+//= require pictures/customupload
+//= require pictures/form
+//= require_tree .
View
47 app/assets/javascripts/pictures/customupload.js
@@ -0,0 +1,47 @@
+(function ($) {
+ 'use strict';
+
+ $.widget('blueimpUIX.fileupload', $.blueimpUI.fileupload, {
+
+ options: {
+ errorMessages: {
+ maxFileSize: 'File is too big',
+ minFileSize: 'File is too small',
+ acceptFileTypes: 'Filetype not allowed',
+ maxNumberOfFiles: 'Max number of files exceeded'
+ }
+ },
+
+ _renderUploadTemplate: function (files) {
+ var that = this,
+ rows = $();
+ $.each(files, function (index, file) {
+ file = that._uploadTemplateHelper(file);
+ var row = $('<tr class="template-upload">' +
+ '<td class="preview"></td>' +
+ '<td class="name"></td>' +
+ '<td class="size"></td>' +
+ (file.error ?
+ '<td class="error" colspan="2"></td>'
+ :
+ '<td class="progress"><div></div></td>' +
+ '<td class="start"><button>Start</button></td>'
+ ) +
+ '<td class="cancel"><button>Cancel</button></td>' +
+ '</tr>');
+ row.find('.name').text(file.name);
+ row.find('.size').text(file.sizef);
+ if (file.error) {
+ row.addClass('ui-state-error');
+ row.find('.error').text(
+ that.options.errorMessages[file.error] || file.error
+ );
+ }
+ rows = rows.add(row);
+ });
+ return rows;
+ }
+
+ });
+
+}(jQuery));
View
4 app/assets/javascripts/pictures/form.js
@@ -16,7 +16,7 @@ $(function () {
// Initialize the jQuery File Upload widget:
$('#fileupload').fileupload({
- maxNumberOfFiles: 3,
+ maxNumberOfFiles: 10,
acceptFileTypes: /\.(jpg|jpeg|gif|png|JPG|JPEG|GIF|PNG)$/
});
@@ -31,6 +31,8 @@ $(function () {
// Fix for IE7 and lower:
$(this).show();
});
+
+ $(".best_in_place").best_in_place();
});
// Open download dialogs via iframes,
View
1  app/assets/stylesheets/application.css
@@ -6,4 +6,5 @@
*= require_tree .
//= require jquery.fileupload-ui
//= require nifty-layout
+ //= require best_in_place
*/
View
1  app/models/picture.rb
@@ -6,6 +6,7 @@ class Picture < ActiveRecord::Base
#one convenient method to pass jq_upload the necessary information
def to_jq_upload
{
+ "id" => read_attribute(:id),
"title" => read_attribute(:title),
"description" => read_attribute(:description),
"name" => read_attribute(:file),
View
4 app/views/pictures/_form.html.erb
@@ -12,7 +12,7 @@
<br />
<div class="field">
<%= f.label :description %><br />
- <%= f.text_field :description %>
+ <%= f.text_area :description, :rows => 5 %>
</div>
<br />
<div class="fileupload-buttonbar">
@@ -32,4 +32,4 @@
</div>
<%= render :partial => "template-upload" %>
-<%= render :partial => "template-download" %>
+<%= render :partial => "template-download" %>
View
2  app/views/pictures/_template-download.html.erb
@@ -32,6 +32,8 @@
</td>
<td class="size">${sizef}</td>
<td colspan="2"></td>
+ <td><span class="best_in_place" id="best_in_place_picture_title" data-url="/pictures/${id}" data-object="picture" data-attribute="title" data-type="input"> ${title}</span></td>
+ <td><span class="best_in_place" id="best_in_place_picture_description" data-url="/pictures/${id}" data-object="picture" data-attribute="description" data-type="input"> ${description}</span></td>
{{/if}}
<td class="delete">
<button data-type="${delete_type}" data-url="${delete_url}">Delete</button>
View
BIN  vendor/assets/images/red_pen.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
19 vendor/assets/stylesheets/best_in_place.css
@@ -0,0 +1,19 @@
+.best_in_place {
+ padding-right: 1.5em;
+ padding: .1m;
+ cursor: hand;
+ cursor: pointer;
+ -moz-transition: background 0.5s linear;
+ -o-transition: background 0.5s linear;
+ -webkit-transition: background 0.5s linear;
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ -o-border-radius: 5px;
+ -ms-border-radius: 5px;
+ -khtml-border-radius: 5px;
+ border-radius: 5px;
+}
+.best_in_place:hover, #user_account .do_hover {
+ background: url(../assets/red_pen.png) no-repeat right;
+ background-color: #CCC;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.