refinerycms-portfolio 0.9.8.rc2 → 0.9.8.rc3
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/admin/portfolio_controller.rb +4 -1
- data/app/models/images_portfolio_entry.rb +10 -0
- data/app/models/portfolio_entry.rb +11 -5
- data/app/views/admin/portfolio/_form.html.erb +41 -30
- data/app/views/admin/portfolio/index.html.erb +1 -1
- data/config/locales/lv.yml +1 -1
- data/lib/gemspec.rb +1 -1
- data/lib/generators/portfolio/portfolio_generator.rb +1 -1
- data/lib/generators/portfolio/templates/db/seeds/portfolio.rb +1 -1
- data/lib/portfolio/version.rb +2 -2
- data/lib/portfolio.rb +1 -1
- data/lib/refinerycms-portfolio.rb +1 -1
- data/public/javascripts/portfolio.js +70 -9
- data/public/stylesheets/portfolio.css +7 -0
- metadata +5 -4
@@ -1,6 +1,9 @@
|
|
1
1
|
class Admin::PortfolioController < Admin::BaseController
|
2
2
|
|
3
|
-
crudify :portfolio_entry,
|
3
|
+
crudify :portfolio_entry,
|
4
|
+
:order => 'lft ASC',
|
5
|
+
:conditions => {:parent_id => nil},
|
6
|
+
:sortable => true
|
4
7
|
|
5
8
|
def emancipate
|
6
9
|
if (entry = PortfolioEntry.find(params[:id])).present?
|
@@ -7,14 +7,20 @@ class PortfolioEntry < ActiveRecord::Base
|
|
7
7
|
acts_as_nested_set
|
8
8
|
default_scope :order => 'lft ASC'
|
9
9
|
|
10
|
-
|
10
|
+
has_many :images_portfolio_entries
|
11
|
+
has_many :images, :through => :images_portfolio_entries, :order => 'images_portfolio_entries.position ASC'
|
12
|
+
accepts_nested_attributes_for :images, :allow_destroy => false
|
11
13
|
|
12
|
-
|
14
|
+
def images_attributes=(data)
|
15
|
+
self.images.clear
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
self.images = (0..(data.length-1)).collect { |i|
|
18
|
+
unless (image_id = data[i.to_s]['id'].to_i) == 0
|
19
|
+
Image.find(image_id) rescue nil
|
20
|
+
end
|
17
21
|
}.compact
|
18
22
|
end
|
19
23
|
|
24
|
+
alias_attribute :content, :body
|
25
|
+
|
20
26
|
end
|
@@ -9,40 +9,51 @@
|
|
9
9
|
:object => f.object,
|
10
10
|
:include_object_name => true
|
11
11
|
} %>
|
12
|
-
<div class='field'>
|
12
|
+
<div id='portfolio_body' class='field clearfix'>
|
13
13
|
<%= f.required_label t('.title') %>
|
14
14
|
<%= f.text_field :title, :class => "larger widest" %>
|
15
15
|
</div>
|
16
|
-
<div class='field
|
17
|
-
<
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
:dialog => true,
|
22
|
-
:width => 866,
|
23
|
-
:height => 510,
|
24
|
-
:callback => "image_added"
|
25
|
-
),
|
26
|
-
:name => t('.add_another_image'),
|
27
|
-
:id => "add_image_link" %>
|
28
|
-
</span>
|
29
|
-
<ul id='portfolio_images' class='clearfix portfolio_entry_images'>
|
30
|
-
<% @portfolio_entry.images.each do |image| %>
|
31
|
-
<li id='image_<%= image.id %>'>
|
32
|
-
<%= image_fu image, '135x135#c' %>
|
33
|
-
<%= hidden_field_tag 'portfolio_entry[image_ids][]', image.id,
|
34
|
-
:id => "portfolio_entry_image_id_#{image.id}" %>
|
16
|
+
<div class='field clearfix'>
|
17
|
+
<div id='page-tabs' class='clearfix ui-tabs ui-widget ui-widget-content'>
|
18
|
+
<ul id='page_parts'>
|
19
|
+
<li class='ui-state-default ui-state-active'>
|
20
|
+
<%= link_to t('.content'), '#page_part_content'%>
|
35
21
|
</li>
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
22
|
+
<li class='ui-state-default'>
|
23
|
+
<%= link_to t('.images'), '#portfolio_image_picker'%>
|
24
|
+
</li>
|
25
|
+
</ul>
|
26
|
+
</div>
|
27
|
+
<div id='page_part_editors'>
|
28
|
+
<div id='page_part_content' class='page_part'>
|
29
|
+
<%= f.text_area :body, :class => "wymeditor widest", :rows => 7 %>
|
30
|
+
</div>
|
31
|
+
<div class='page_part wym_skin_refinery' id='portfolio_image_picker'>
|
32
|
+
<div class='wym_area_top'>
|
33
|
+
<span class='clearfix label_inline_with_link'>
|
34
|
+
<%= link_to t('.add_another_image').html_safe,
|
35
|
+
insert_admin_images_url(:dialog => true,
|
36
|
+
:width => 866,
|
37
|
+
:height => 510,
|
38
|
+
:callback => "image_added"),
|
39
|
+
:id => "add_image_link" %>
|
40
|
+
</span>
|
41
|
+
</div>
|
42
|
+
<div class='wym_box field images_field'>
|
43
|
+
<ul id='portfolio_images' class='clearfix portfolio_entry_images'>
|
44
|
+
<%= f.fields_for :images do |image_form| %>
|
45
|
+
<li id='image_<%= image_form.object.id %>'>
|
46
|
+
<%= image_form.hidden_field :id %>
|
47
|
+
<%= image_fu image_form.object, '135x135#c' %>
|
48
|
+
</li>
|
49
|
+
<% end %>
|
50
|
+
<li class='empty'>
|
51
|
+
<%= hidden_field_tag "portfolio_entry[images_attributes][#{@portfolio_entry.images.size}][id]" %>
|
52
|
+
</li>
|
53
|
+
</ul>
|
54
|
+
</div>
|
55
|
+
</div>
|
56
|
+
</div>
|
46
57
|
</div>
|
47
58
|
<% if (nested_portfolios = nested_set_options(PortfolioEntry, @portfolio_entry) {|i| "#{'-' * i.level} #{i.title}" }).present? %>
|
48
59
|
<div class='field'>
|
data/config/locales/lv.yml
CHANGED
data/lib/gemspec.rb
CHANGED
data/lib/portfolio/version.rb
CHANGED
data/lib/portfolio.rb
CHANGED
@@ -6,6 +6,7 @@ reset_functionality = function() {
|
|
6
6
|
, 'placeholder': 'placeholder'
|
7
7
|
, 'cursor': 'drag'
|
8
8
|
, 'items': 'li'
|
9
|
+
, stop: reindex_images
|
9
10
|
});
|
10
11
|
|
11
12
|
$('#content #portfolio_images li:not(.empty)').each(function(index, li) {
|
@@ -16,6 +17,7 @@ reset_functionality = function() {
|
|
16
17
|
img_delete.appendTo(image_actions);
|
17
18
|
img_delete.click(function() {
|
18
19
|
$(this).parents('li[id*=image_]').remove();
|
20
|
+
reindex_images();
|
19
21
|
});
|
20
22
|
|
21
23
|
image_actions.appendTo($(li));
|
@@ -26,19 +28,56 @@ reset_functionality = function() {
|
|
26
28
|
$(this).find('.image_actions').hide();
|
27
29
|
});
|
28
30
|
});
|
31
|
+
|
32
|
+
reindex_images();
|
33
|
+
}
|
34
|
+
|
35
|
+
reindex_images = function() {
|
36
|
+
$('#portfolio_images li input:hidden').each(function(i, input){
|
37
|
+
// make the image's name consistent with its position.
|
38
|
+
parts = $(input).attr('name').split(']');
|
39
|
+
parts[1] = ('[' + i)
|
40
|
+
$(input).attr('name', parts.join(']'));
|
41
|
+
|
42
|
+
// make the image's id consistent with its position.
|
43
|
+
$(input).attr('id', $(input).attr('id').replace(/_\d_/, '_'+i+'_').replace(/_\d/, '_'+i));
|
44
|
+
});
|
29
45
|
}
|
30
46
|
|
31
47
|
image_added = function(image) {
|
32
48
|
last_portfolio_entry_image_id = "";
|
49
|
+
new_list_item = (current_list_item = $('li.empty')).clone();
|
33
50
|
image_id = $(image).attr('id').replace('image_', '');
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
51
|
+
current_list_item.find('input:hidden').val(image_id);
|
52
|
+
$.ajax({
|
53
|
+
async: false,
|
54
|
+
url: '/refinery/images/'+image_id+'/url',
|
55
|
+
data: {size: '135x135#c'},
|
56
|
+
success: function (result, status, xhr) {
|
57
|
+
if (result.error) {
|
58
|
+
if (console && console.log) {
|
59
|
+
console.log("Something went wrong with the image insertion!");
|
60
|
+
console.log(result);
|
61
|
+
}
|
62
|
+
} else {
|
63
|
+
(img = $("<img />")).attr({
|
64
|
+
title: $(image).attr('title')
|
65
|
+
, alt: $(image).attr('alt')
|
66
|
+
, src: result.url
|
67
|
+
}).appendTo(current_list_item);
|
68
|
+
}
|
69
|
+
},
|
70
|
+
error: function(xhr, txt, status) {
|
71
|
+
if (console && console.log) {
|
72
|
+
console.log("Something went wrong with the image insertion!");
|
73
|
+
console.log(xhr);
|
74
|
+
console.log(txt);
|
75
|
+
console.log(status);
|
76
|
+
}
|
77
|
+
}
|
78
|
+
});
|
38
79
|
|
39
|
-
|
40
|
-
$("<img id='current_portfolio_entry_image' src='' alt='' style='display:none;' />").appendTo(new_list_item);
|
41
|
-
$("<input type='hidden' id='portfolio_entry_image_id' name='portfolio_entry[image_ids][]' />").appendTo(new_list_item);
|
80
|
+
current_list_item.attr('id', 'image_' + image_id).removeClass('empty');
|
42
81
|
|
43
82
|
new_list_item.appendTo($('#portfolio_images'));
|
44
83
|
reset_functionality();
|
@@ -54,8 +93,30 @@ $(document).ready(function() {
|
|
54
93
|
window.location = portfolio_entry_url + this.value;
|
55
94
|
});
|
56
95
|
|
96
|
+
if ((tabs = $('.edit_portfolio_entry #page-tabs, .new_portfolio_entry #page-tabs')).length > 0) {
|
97
|
+
page_options.init(false, '', '');
|
98
|
+
$('a[href*=portfolio_image_picker]').click(function(){
|
99
|
+
if (!(picker = $('#portfolio_image_picker')).data('size-applied')){
|
100
|
+
wym_box = $('.page_part:first .wym_box');
|
101
|
+
iframe = $('.page_part:first iframe');
|
102
|
+
picker.css({
|
103
|
+
height: wym_box.height()
|
104
|
+
, width: wym_box.width()
|
105
|
+
}).data('size-applied', true).corner('tr 5px').corner('bottom 5px').find('.wym_box').css({
|
106
|
+
backgroundColor: 'white'
|
107
|
+
, height: iframe.height() + $('.page_part:first .wym_area_top').height() - parseInt($('.wym_area_top .label_inline_with_link a').css('lineHeight'))
|
108
|
+
, width: iframe.width() - 20
|
109
|
+
, 'border-color': iframe.css('border-top-color')
|
110
|
+
, 'border-style': iframe.css('border-top-style')
|
111
|
+
, 'border-width': iframe.css('border-top-width')
|
112
|
+
, padding: '0px 10px 0px 10px'
|
113
|
+
});
|
114
|
+
}
|
115
|
+
});
|
116
|
+
}
|
117
|
+
|
57
118
|
var clicked_on = null;
|
58
|
-
$("ul#portfolio_images li a").click(function(
|
119
|
+
$("ul#portfolio_images li a").click(function(e) {
|
59
120
|
if (!$(this).hasClass('selected')) {
|
60
121
|
clicked_on = $(this);
|
61
122
|
$.get($(this).attr('href'), function(data, textStatus) {
|
@@ -72,6 +133,6 @@ $(document).ready(function() {
|
|
72
133
|
});
|
73
134
|
}
|
74
135
|
|
75
|
-
|
136
|
+
e.preventDefault();
|
76
137
|
});
|
77
138
|
});
|
@@ -72,4 +72,11 @@
|
|
72
72
|
#content #portfolio_images.ui-sortable li.placeholder {
|
73
73
|
width: 135px;
|
74
74
|
height: 135px;
|
75
|
+
}
|
76
|
+
.wym_area_top .label_inline_with_link a, #content .wym_area_top .label_inline_with_link a {
|
77
|
+
margin-top: 0px;
|
78
|
+
line-height: 29px;
|
79
|
+
background: url('/images/refinery/icons/add.png') no-repeat 0px 6px;
|
80
|
+
padding-left: 20px;
|
81
|
+
border-bottom: 0px none;
|
75
82
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: refinerycms-portfolio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 977940516
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
9
|
- 8
|
10
|
-
-
|
11
|
-
version: 0.9.8.
|
10
|
+
- rc3
|
11
|
+
version: 0.9.8.rc3
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Resolve Digital
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-09-
|
19
|
+
date: 2010-09-27 00:00:00 +13:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- app/controllers/admin/portfolio_controller.rb
|
50
50
|
- app/controllers/portfolio_controller.rb
|
51
51
|
- app/helpers/portfolio_helper.rb
|
52
|
+
- app/models/images_portfolio_entry.rb
|
52
53
|
- app/models/portfolio_entry.rb
|
53
54
|
- app/views/admin/portfolio/_form.html.erb
|
54
55
|
- app/views/admin/portfolio/_list.html.erb
|