diff --git a/controllers/profile/comment_paragraph_plugin_profile_controller.rb b/controllers/profile/comment_paragraph_plugin_profile_controller.rb index 2e37ebd..42133c7 100644 --- a/controllers/profile/comment_paragraph_plugin_profile_controller.rb +++ b/controllers/profile/comment_paragraph_plugin_profile_controller.rb @@ -4,7 +4,7 @@ class CommentParagraphPluginProfileController < ProfileController def view_comments @article_id = params[:article_id] @paragraph_id = params[:paragraph_id] - + article = profile.articles.find(@article_id) @paragraph_comment_page = (params[:paragraph_comment_page] || 1).to_i diff --git a/lib/ext/comment.rb b/lib/ext/comment.rb index 78cc278..d37d3ca 100644 --- a/lib/ext/comment.rb +++ b/lib/ext/comment.rb @@ -3,12 +3,14 @@ require_dependency 'comment' class Comment scope :without_paragraph, :conditions => {:paragraph_id => nil } - + + settings_items :comment_paragraph_selected_area, :type => :string + scope :in_paragraph, proc { |paragraph_id| { :conditions => ['paragraph_id = ?', paragraph_id] } } - attr_accessible :paragraph_id + attr_accessible :paragraph_id, :comment_paragraph_selected_area end diff --git a/public/comment_paragraph_macro.js b/public/comment_paragraph_macro.js index 3814002..a7e4c9f 100644 --- a/public/comment_paragraph_macro.js +++ b/public/comment_paragraph_macro.js @@ -1,5 +1,8 @@ var comment_paragraph_anchor; jQuery(document).ready(function($) { + + jQuery('.autoexpand-text-area').autosize(); + var anchor = window.location.hash; if(anchor.length==0) return; @@ -8,7 +11,7 @@ jQuery(document).ready(function($) { if($('div[data-macro=comment_paragraph_plugin/allow_comment]').length==0) return; //comment_paragraph_plugin/allow_comment div must exists var comment_id = val[1]; if(!/^\d+$/.test(comment_id)) return; //test for integer - + comment_paragraph_anchor = anchor; var url = '/plugin/comment_paragraph/public/comment_paragraph/'+comment_id; $.getJSON(url, function(data) { @@ -37,3 +40,291 @@ function loadCompleted(paragraph) { comment_paragraph_anchor = null; } } + +//Return a string with the beggining and the end of the selection of a text area separated by colon +function getSelectionBounderies(textareaId){ + + var textarea = document.getElementById(textareaId); + if ('selectionStart' in textarea) { + // check whether some text is selected in the textarea + if (textarea.selectionStart != textarea.selectionEnd) { + alert(textarea.selectionStart + ":" + textarea.selectionEnd) + return textarea.selectionStart + ":" + textarea.selectionEnd; + } + } + + return false +} + +/*! + Autosize v1.18.9 - 2014-05-27 + Automatically adjust textarea height based on user input. + (c) 2014 Jack Moore - http://www.jacklmoore.com/autosize + license: http://www.opensource.org/licenses/mit-license.php +*/ +(function ($) { + var + defaults = { + className: 'autosizejs', + id: 'autosizejs', + append: '\n', + callback: false, + resizeDelay: 10, + placeholder: true + }, + + // border:0 is unnecessary, but avoids a bug in Firefox on OSX + copy = ' + +
<%= link_to_remote(image_tag("/plugins/comment_paragraph/images/comments.gif"), :url => { :profile => profile_identifier, :controller => 'comment_paragraph_plugin_profile', :action => 'view_comments', :paragraph_id => paragraph_id, :article_id => article_id}, :method => :post, :condition => "!toggleParagraph(#{paragraph_id})", :complete => "loadCompleted(#{paragraph_id})")%> -
- -
<%= count %>
- - -
- <%= inner_html %> + +
<%= count %>
+

-- libgit2 0.21.2