From a289d28acfb57936634f441727eedb3d1e7ca60f Mon Sep 17 00:00:00 2001 From: Fabio Teixeira Date: Fri, 28 Mar 2014 09:17:01 -0300 Subject: [PATCH] Link_List_Block_Improvements: Merge request corrections --- app/controllers/box_organizer_controller.rb | 2 +- app/views/box_organizer/_link_list_block.rhtml | 4 ++-- public/javascripts/edit-link-list.js | 11 +---------- public/stylesheets/application.css | 30 ++++++++---------------------- test/functional/profile_design_controller_test.rb | 9 ++++++--- 5 files changed, 18 insertions(+), 38 deletions(-) diff --git a/app/controllers/box_organizer_controller.rb b/app/controllers/box_organizer_controller.rb index 7735890..ce54361 100644 --- a/app/controllers/box_organizer_controller.rb +++ b/app/controllers/box_organizer_controller.rb @@ -84,7 +84,7 @@ class BoxOrganizerController < ApplicationController if request.xhr? and params[:query] search = params[:query] articles = @profile.articles.find(:all, :conditions=>"name ILIKE '%#{search}%' or path ILIKE '%#{search}%'", :limit=>20) - path_list = articles.map { |content| content.path } + path_list = articles.map { |content| "/{profile}/"+content.path } render :json => path_list.to_json else diff --git a/app/views/box_organizer/_link_list_block.rhtml b/app/views/box_organizer/_link_list_block.rhtml index 14c5b3d..cf4a996 100644 --- a/app/views/box_organizer/_link_list_block.rhtml +++ b/app/views/box_organizer/_link_list_block.rhtml @@ -25,7 +25,7 @@ <%= select_tag('block[links][][target]', options_for_select(LinkListBlock::TARGET_OPTIONS, link[:target])) %>
  • - <%= button_without_text("", _('Delete'), "#" , :class=>"icon-delete delete-link-list-row") %> + <%= button_without_text(:delete, _('Delete'), "#" , :class=>"delete-link-list-row") %>
  • @@ -42,7 +42,7 @@ content_tag('li', text_field_tag('block[links][][address]', nil, :class => 'link-address')) + content_tag('li', select_tag('block[links][][target]', options_for_select(LinkListBlock::TARGET_OPTIONS, '_self'))) + - content_tag('li', button_without_text("", _('Delete'), "#" , :class=>"icon-delete delete-link-list-row")), + content_tag('li', button_without_text(:delete, _('Delete'), "#" , :class=>"delete-link-list-row")), :class=>"link-list-row new_link_row") ) + javascript_tag("new_link_action()") diff --git a/public/javascripts/edit-link-list.js b/public/javascripts/edit-link-list.js index 18e69de..18e6760 100644 --- a/public/javascripts/edit-link-list.js +++ b/public/javascripts/edit-link-list.js @@ -23,16 +23,7 @@ function new_link_action(){ jQuery(".delete-link-list-row").click(function(){ jQuery(this).parent().parent().remove(); - }); - - jQuery(".link-address").blur(function(){ - var value = jQuery(this).val(); - var search = /(^$)|(^\/$)|(http|www).*|.*\{profile\}.*|.*(\.com|\.org|\.net|\.edu|\.gov|\.info|\.eu)/; - - if( !search.test(value) ) { - value = "/{profile}/"+value; - jQuery(this).val(value); - } + return false; }); jQuery(document).scrollTop(jQuery('#dropable-link-list').scrollTop()); diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 17a424d..5905840 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -1864,7 +1864,6 @@ a.button.disabled, input.disabled { position: relative; left: -24px; } - .link-list-header { width: 98%; height: 25px; @@ -1872,16 +1871,20 @@ a.button.disabled, input.disabled { margin-bottom: 5px; cursor: pointer; } - +.link-list-header li { + list-style-type: none; + display: inline; + font-weight: bold; + font-size: 14px; + text-align: center; +} #dropable-link-list { padding-left: 23px; margin-top: -12px; } - #dropable-link-list li { list-style-type: none; } - .link-list-row { line-height: 25px; margin-bottom: 5px; @@ -1890,54 +1893,37 @@ a.button.disabled, input.disabled { width: 90%; } .link-list-row:hover { - background: #aaa url(/images/drag-and-drop.png) no-repeat; + background: #ddd url(/images/drag-and-drop.png) no-repeat; background-position: 98% 15px; } - .link-list-row li { list-style-type: none; display: inline; margin-left: 5px; } - .link-list-row li div { float: left; margin-top: 4px; } - .link-list-row li a { line-height: 27px !important; padding-right: 5px; } - -.link-list-header li { - list-style-type: none; - display: inline; - font-weight: bold; - font-size: 14px; - text-align: center; -} - .link-list-icon { margin-left: 14px; } - .link-list-name { margin-left: 40px; } - .link-list-address { margin-left: 90px; } - .link-list-target { margin-left: 77px; } - .new_link_row li { margin-left: 7px; } - #content .link-list-block { padding: 10px 0px 10px 10px; } diff --git a/test/functional/profile_design_controller_test.rb b/test/functional/profile_design_controller_test.rb index 641c014..c9b2bc4 100644 --- a/test/functional/profile_design_controller_test.rb +++ b/test/functional/profile_design_controller_test.rb @@ -326,10 +326,13 @@ class ProfileDesignControllerTest < ActionController::TestCase article3 = fast_create(Article, :profile_id => @profile.id, :name => "Not an article") xhr :get, :search_autocomplete, :profile => 'designtestuser' , :query => 'Some' + + json_response = ActiveSupport::JSON.decode(@response.body) + assert_response :success - assert_equal @response.body.include?(article1.path), true - assert_equal @response.body.include?(article2.path), true - assert_equal @response.body.include?(article3.path), false + assert_equal json_response.include?("/{profile}/"+article1.path), true + assert_equal json_response.include?("/{profile}/"+article2.path), true + assert_equal json_response.include?("/{profile}/"+article3.path), false end ###################################################### -- libgit2 0.21.2