refinerycms-tags 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,4 +3,9 @@ class Admin::TagsController < Admin::BaseController
3
3
  @tags = ActsAsTaggableOn::Tag.named_like(params[:term]).all
4
4
  render :json => @tags.map(&:name) if request.xhr?
5
5
  end
6
+
7
+ def destroy
8
+ ActsAsTaggableOn::Tag.find(params[:id]).destroy
9
+ render :nothing => true
10
+ end
6
11
  end
@@ -1,8 +1,12 @@
1
- <span class="label_with_help">
2
- <%= f.label field -%>
3
- <%= refinery_help_tag t('.tag_help') %>
4
- </span>
5
- <%= f.text_area field %>
1
+ <% field_id = "#{f.object_name}_#{field}" %>
2
+ <div class="clearfix">
3
+ <span class="label_with_help">
4
+ <%= f.label field -%>
5
+ <%= refinery_help_tag t('.tag_help') %>
6
+ </span>
7
+ <%= f.text_area field %>
8
+ <%= render :partial => '/shared/admin/tag_list', :locals => {:field_id => field_id, :tags => local_assigns[:tags]} if local_assigns[:show_tag_list] %>
9
+ </div>
6
10
  <%
7
11
  unless @tag_editor_included
8
12
  @tag_editor_included = true
@@ -12,5 +16,5 @@ end
12
16
 
13
17
  autocomplete_url ||= admin_tags_path if autocomplete
14
18
  default_text ||= '.default_text'
15
- content_for :javascripts, javascript_tag("$(document).ready(function() { $('##{f.object_name}_#{field}').tagsInput({defaultText: '#{t default_text}'#{', autocomplete_url: ' + autocomplete_url.to_json if autocomplete}}); })")
19
+ content_for :javascripts, javascript_tag("$(document).ready(function() { $('##{field_id}').tagsInput({defaultText: '#{t default_text}'#{', autocomplete_url: ' + autocomplete_url.to_json if autocomplete}}); })")
16
20
  %>
@@ -0,0 +1,18 @@
1
+ <% tags ||= ActsAsTaggableOn::Tag.order(:name).all %>
2
+ <%= content_tag :ul, :class => 'tagsinput tag_list' do %>
3
+ <% tags.each do |tag| %>
4
+ <li><span class="tag">
5
+ <%= content_tag :span, tag.name %>
6
+ <%= link_to 'x', admin_tag_path(tag) %>
7
+ </span></li>
8
+ <% end %>
9
+ <% end %>
10
+
11
+ <%
12
+ unless @taglist_included
13
+ @taglist_included = true
14
+ content_for :after_javascript_libraries, javascript_include_tag("taglist.js")
15
+ end
16
+
17
+ content_for :javascripts, javascript_tag("$(document).ready(function() { $('##{field_id} ~ .tag_list').tagList($('##{field_id}'), {confirm: '#{t '.delete_tag_confirm'}'}); });")
18
+ %>
@@ -4,3 +4,5 @@ en:
4
4
  tag_editor:
5
5
  tag_help: Write a tag and press enter
6
6
  default_text: add a tag
7
+ tag_list:
8
+ delete_tag_confirm: You are going to delete a tag. This change is permanent. Are you sure?
@@ -4,3 +4,5 @@ es:
4
4
  tag_editor:
5
5
  tag_help: Escribe una etiqueta y pulsa intro para añadirla
6
6
  default_text: añade una etiqueta
7
+ tag_list:
8
+ delete_tag_confirm: Vas a borrar una etiqueta, esto no se puede deshacer. ¿Estás seguro?
@@ -4,3 +4,5 @@ lolcat:
4
4
  tag_editor:
5
5
  tag_help: WRITE A TAG AND PRESS ENTER
6
6
  default_text: ADD A TAG
7
+ tag_list:
8
+ delete_tag_confirm: YOU ARE GOING TO DELETE A TAG. THIS CHANGE IS PERMANENT. ARE YOU SURE?
@@ -1,5 +1,5 @@
1
1
  ::Refinery::Application.routes.draw do
2
2
  scope(:path => 'refinery', :as => 'admin', :module => 'admin') do
3
- resources :tags, :only => :index
3
+ resources :tags, :only => [:index, :destroy]
4
4
  end
5
5
  end
@@ -20,6 +20,7 @@ module Refinery
20
20
  plugin.name = "tags"
21
21
  plugin.pathname = root
22
22
  plugin.hide_from_menu = true
23
+ plugin.always_allow_access = true
23
24
  end
24
25
  end
25
26
  end
@@ -0,0 +1,32 @@
1
+ /*
2
+
3
+ Tag List for jQuery Tags Input plugin
4
+
5
+ Copyright (c) 2012 Sergio Cambra
6
+
7
+ Licensed under the MIT license:
8
+ http://www.opensource.org/licenses/mit-license.php
9
+
10
+ sergio@entrecables.com
11
+
12
+ */
13
+ (function( $, undefined ) {
14
+ $.fn.tagList = function(tagsinput, options) {
15
+ var options = $.extend({}, options);
16
+ $(this).find('.tag').click(function(e) {
17
+ e.preventDefault();
18
+ if (!$(e.target).is('a')) tagsinput.addTag($(this).find('span').html());
19
+ });
20
+ $(this).find('.tag a').click(function(e) {
21
+ e.preventDefault();
22
+ var tag = $(this).closest('.tag');
23
+ if (!options.confirm || confirm(options.confirm)) {
24
+ $.post($(this).attr('href'), '_method=delete', function() {
25
+ tagsinput.removeTag(tag.find('span').html());
26
+ tag.remove();
27
+ });
28
+ }
29
+ });
30
+ };
31
+ })(jQuery);
32
+
@@ -1,12 +1,14 @@
1
- div.tagsinput { border:1px solid #CCC; background: #FFF; padding:5px; width:300px; height:100px; overflow-y: auto;}
2
- div.tagsinput span.tag { border: 1px solid #1C89C7; -moz-border-radius:2px; -webkit-border-radius:2px; display: block; float: left; padding: 5px; text-decoration:none; background: #22a7f2; color: #fff; margin-right: 5px; margin-bottom:5px;font-family: helvetica; font-size:13px;}
3
- div.tagsinput span.tag span { color: #fff; }
4
- div.tagsinput span.tag a { font-weight: bold; color: #fff; text-decoration:none; font-size: 11px; }
5
- div.tagsinput input { width:80px; margin:0px; font-family: helvetica; font-size: 13px; border:1px solid transparent; padding:5px; background: transparent; color: #000; outline:0px; margin-right:5px; margin-bottom:5px; }
1
+ div.tagsinput { border:1px solid #CCC; background: #FFF; padding:5px; width:300px; height:100px; overflow-y: auto; float: left;}
2
+ .tagsinput span.tag { border: 1px solid #1C89C7; -moz-border-radius:2px; -webkit-border-radius:2px; display: block; float: left; padding: 5px; text-decoration:none; background: #22a7f2; color: #fff; margin-right: 5px; margin-bottom:5px;font-family: helvetica; font-size:13px;}
3
+ .tagsinput span.tag span { color: #fff; }
4
+ .tagsinput span.tag a { font-weight: bold; color: #fff; text-decoration:none; font-size: 11px; }
5
+ .tagsinput input { width:80px; margin:0px; font-family: helvetica; font-size: 13px; border:1px solid transparent; padding:5px; background: transparent; color: #000; outline:0px; margin-right:5px; margin-bottom:5px; }
6
6
  div.tagsinput div { display:block; float: left; }
7
7
  .tags_clear { clear: both; width: 100%; height: 0px; }
8
8
  .not_valid {background: #FBD8DB !important; color: #90111A !important;}
9
- #content div.tagsinput span.tag a { border-bottom: none; }
9
+ #content .tagsinput span.tag a { border-bottom: none; }
10
+ ul.tag_list { list-style: none; margin-left: 300px; padding-left: 20px; }
11
+ ul.tag_list li { float: left; }
10
12
  /*
11
13
  * jQuery UI Menu 1.8.17
12
14
  *
@@ -57,7 +59,7 @@ div.tagsinput div { display:block; float: left; }
57
59
  */
58
60
  .ui-autocomplete { position: absolute; cursor: default; border: 1px solid #aaaaaa; background: #ffffff; color: #222222; }
59
61
  .ui-autocomplete a { color: #222222; }
60
- .ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #999999; background: #22a7f2 url(/images/refinery/ui-bg_glass_75_22a7f2_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #212121; }
62
+ .ui-autocomplete .ui-state-hover { border: 1px solid #999999; background: #22a7f2 url(/images/refinery/ui-bg_glass_75_22a7f2_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #212121; }
61
63
 
62
64
  /* workarounds */
63
65
  * html .ui-autocomplete { width:1px; } /* without this, the menu expands to 100% in IE6 */
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-tags
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
9
+ - 3
10
+ version: 1.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sergio Cambra
@@ -44,6 +44,7 @@ extra_rdoc_files: []
44
44
  files:
45
45
  - app/controllers/admin/tags_controller.rb
46
46
  - app/views/shared/admin/_tag_editor.html.erb
47
+ - app/views/shared/admin/_tag_list.html.erb
47
48
  - config/locales/en.yml
48
49
  - config/locales/es.yml
49
50
  - config/locales/lolcat.yml
@@ -54,6 +55,7 @@ files:
54
55
  - public/images/refinery/ui-bg_glass_75_22a7f2_1x400.png
55
56
  - public/javascripts/jquery.tagsinput.js
56
57
  - public/javascripts/jquery.tagsinput.min.js
58
+ - public/javascripts/taglist.js
57
59
  - public/stylesheets/jquery.tagsinput.css
58
60
  homepage: http://github.com/scambra/refinerycms-tags
59
61
  licenses: []