diff --git a/app/models/comment.rb b/app/models/comment.rb
index c9be027..5393557 100644
--- a/app/models/comment.rb
+++ b/app/models/comment.rb
@@ -37,6 +37,9 @@ class Comment < ActiveRecord::Base
xss_terminate :only => [ :body, :title, :name ], :on => 'validation'
+ # TODO
+ # create migration to create total_votes fields
+ # see vote_fu/README.markdown
acts_as_voteable
def comment_root
diff --git a/features/step_definitions/noosfero_steps.rb b/features/step_definitions/noosfero_steps.rb
index af6f7ba..ec1e92a 100644
--- a/features/step_definitions/noosfero_steps.rb
+++ b/features/step_definitions/noosfero_steps.rb
@@ -91,10 +91,10 @@ Given /^the following blocks$/ do |table|
owner_type = item.delete('owner')
owner = owner_type == 'environment' ? Environment.default : Profile[owner_type]
if owner.boxes.empty?
- owner.boxes<< Box.new
+ owner.boxes << Box.new
owner.boxes.first.blocks << MainBlock.new
end
- box = owner.boxes.where(:position => 3).first
+ box = owner.boxes.first
klass.constantize.create!(item.merge(:box => box))
end
end
diff --git a/public/javascripts/media-panel.js b/public/javascripts/media-panel.js
index 3777b88..a46bc55 100644
--- a/public/javascripts/media-panel.js
+++ b/public/javascripts/media-panel.js
@@ -1,137 +1,164 @@
-var file_id = 1;
-
-jQuery('.view-all-media').on('click', '.pagination a', function(event) {
- jQuery.ajax({
- url: this.href,
- beforeSend: function(){jQuery('.view-all-media').addClass('fetching')},
- complete: function() {jQuery('.view-all-media').removeClass('fetching')},
- dataType: 'script'
+(function($) {
+ "use strict";
+
+ var file_id = 1;
+
+ $('.view-all-media').on('click', '.pagination a', function(event) {
+ $.ajax({
+ url: this.href,
+ beforeSend: function(){$('.view-all-media').addClass('fetching')},
+ complete: function() {$('.view-all-media').removeClass('fetching')},
+ dataType: 'script'
+ });
+ return false;
});
- return false;
-});
-
-jQuery('#file').fileupload({
- add: function(e, data){
- data.files[0].id = file_id;
- file_id++;
- data.context = jQuery(tmpl("template-upload", data.files[0]));
- jQuery('#media-upload-form').append(data.context);
- data.submit();
- },
- progress: function (e, data) {
- if (jQuery('#hide-uploads').data('bootstraped') == false) {
- jQuery('#hide-uploads').show();
- jQuery('#hide-uploads').data('bootstraped', true);
- }
- if (data.context) {
- progress = parseInt(data.loaded / data.total * 100, 10);
- data.context.find('.bar').css('width', progress + '%');
- data.context.find('.percentage').text(progress + '%');
- }
- },
- fail: function(e, data){
- var file_id = '#file-'+data.files[0].id;
- jQuery(file_id).find('.progress .bar').addClass('error');
- jQuery(file_id).append("
" + data.jqXHR.responseText + "
")
- }
-});
-
-jQuery('#hide-uploads').click(function(){
- jQuery('#hide-uploads').hide();
- jQuery('#show-uploads').show();
- jQuery('.upload').slideUp();
- return false;
-});
-
-jQuery('#show-uploads').click(function(){
- jQuery('#hide-uploads').show();
- jQuery('#show-uploads').hide();
- jQuery('.upload').slideDown();
- return false;
-});
-
-function loadPublishedMedia() {
- var parent_id = jQuery('#published-media #parent_id').val();
- var q = jQuery('#published-media #q').val();
- var url = jQuery('#published-media').data('url');
-
- jQuery('#published-media .items').addClass('fetching');
- jQuery.ajax({
- url: url,
- data: {'parent_id': parent_id, 'q': q},
- dataType: 'html',
- success: function(response) {
- jQuery("#published-media .items").html(response);
- jQuery('#published-media .items').removeClass('fetching');
- updateViewAllLinks();
+
+
+ $('#file').fileupload({
+ add: function(e, data){
+ data.files[0].id = file_id;
+ file_id++;
+ data.context = $(tmpl("template-upload", data.files[0]));
+ $('#media-upload-form').append(data.context);
+ data.submit();
+ },
+ progress: function (e, data) {
+ if ($('#hide-uploads').data('bootstraped') == false) {
+ $('#hide-uploads').show();
+ $('#hide-uploads').data('bootstraped', true);
+ }
+ if (data.context) {
+ var progress = parseInt(data.loaded / data.total * 100, 10);
+ data.context.find('.bar').css('width', progress + '%');
+ data.context.find('.percentage').text(progress + '%');
+ }
},
- error: function(response, textStatus, xhr) {
- console.log(response);
- console.log(textStatus);
+ fail: function(e, data){
+ var file_id = '#file-'+data.files[0].id;
+ $(file_id).find('.progress .bar').addClass('error');
+ $(file_id).append("" + data.jqXHR.responseText + "
")
}
});
-}
-
-function updateViewAllLinks() {
- var parent_id = jQuery('#published-media #parent_id').val();
- var q = jQuery('#published-media #q').val();
- jQuery('#published-media .view-all').each(function(){
- var key = jQuery(this).data('key');
- var params = {parent_id: parent_id, q: q, key: key}
- var href = jQuery(this).attr('href');
- href = href.replace(/\?.*/, '?'+jQuery.param(params));
- jQuery(this).attr('href', href);
+
+
+ $('#hide-uploads').click(function(){
+ $('#hide-uploads').hide();
+ $('#show-uploads').show();
+ $('.upload').slideUp();
+ return false;
+ });
+
+
+ $('#show-uploads').click(function(){
+ $('#hide-uploads').show();
+ $('#show-uploads').hide();
+ $('.upload').slideDown();
+ return false;
});
-}
-
-jQuery('#published-media #parent_id').change(function(){ loadPublishedMedia() });
-
-jQuery("#published-media #q").typeWatch({
- callback: function (value) { loadPublishedMedia() },
- wait: 750,
- highlight: true,
- captureLength: 2
-});
-
-jQuery("#published-media #q").bind('notext', function(){ loadPublishedMedia() });
-
-jQuery("#new-folder-dialog").submit(function( event ) {
- var name = jQuery('#new_folder').val();
- var parent_id = jQuery("#new-folder-dialog #parent_id").val();
- jQuery.ajax({
- url: this.action,
- type: 'POST',
- data: {
- 'parent_id': parent_id,
- 'article': {'name': name, 'published': true},
- 'type': jQuery('input[name=folder_type]:checked').val() },
- dataType: 'json',
- beforeSend: function(){jQuery("#new-folder-dialog").addClass('fetching')},
- success: function(response) {
- var option_selected = "