thredded 0.12.4 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +30 -33
  3. data/app/assets/javascripts/thredded/components/currently_online.es6 +28 -21
  4. data/app/assets/javascripts/thredded/components/flash_messages.es6 +5 -7
  5. data/app/assets/javascripts/thredded/components/mention_autocompletion.es6 +39 -0
  6. data/app/assets/javascripts/thredded/components/post_form.es6 +28 -33
  7. data/app/assets/javascripts/thredded/components/preview_area.es6 +27 -23
  8. data/app/assets/javascripts/thredded/components/quote_post.es6 +5 -1
  9. data/app/assets/javascripts/thredded/components/time_stamps.es6 +24 -9
  10. data/app/assets/javascripts/thredded/components/topic_form.es6 +72 -54
  11. data/app/assets/javascripts/thredded/components/topics.es6 +28 -19
  12. data/app/assets/javascripts/thredded/components/turboforms.es6 +23 -13
  13. data/app/assets/javascripts/thredded/components/user_preferences_form.es6 +33 -31
  14. data/app/assets/javascripts/thredded/components/user_textcomplete.es6 +47 -0
  15. data/app/assets/javascripts/thredded/components/users_select.es6 +102 -52
  16. data/app/assets/javascripts/thredded/core/debounce.es6 +1 -1
  17. data/app/assets/javascripts/thredded/core/escape_html.es6 +7 -0
  18. data/app/assets/javascripts/thredded/core/hide_soft_keyboard.es6 +1 -1
  19. data/app/assets/javascripts/thredded/core/on_page_load.es6 +1 -1
  20. data/app/assets/javascripts/thredded/core/serialize_form.es6 +9 -0
  21. data/app/assets/javascripts/thredded/dependencies.js +2 -5
  22. data/app/assets/javascripts/thredded/dependencies/textcomplete.js +1 -0
  23. data/app/assets/javascripts/thredded/dependencies/timeago.js +1 -0
  24. data/app/assets/javascripts/thredded/dependencies/ujs.js +1 -1
  25. data/app/assets/stylesheets/thredded/_dependencies.scss +0 -1
  26. data/app/assets/stylesheets/thredded/_thredded.scss +0 -1
  27. data/app/assets/stylesheets/thredded/components/_mention-autocomplete.scss +15 -2
  28. data/app/controllers/concerns/thredded/new_private_topic_params.rb +2 -2
  29. data/app/controllers/thredded/autocomplete_users_controller.rb +0 -1
  30. data/app/forms/thredded/private_topic_form.rb +46 -2
  31. data/app/helpers/thredded/application_helper.rb +12 -14
  32. data/app/views/thredded/private_topics/_form.html.erb +7 -6
  33. data/app/views/thredded/topics/_topic.html.erb +2 -2
  34. data/config/locales/pl.yml +1 -1
  35. data/lib/thredded.rb +1 -3
  36. data/lib/thredded/version.rb +1 -1
  37. data/vendor/assets/javascripts/textcomplete.min.js +1 -0
  38. metadata +12 -37
  39. data/app/assets/javascripts/thredded/core/mention_autocompletion.es6 +0 -54
  40. data/app/assets/javascripts/thredded/dependencies/jquery.js +0 -1
  41. data/app/assets/stylesheets/thredded/components/_select2.scss +0 -112
  42. data/vendor/assets/javascripts/jquery.textcomplete.js +0 -1488
@@ -1,10 +1,7 @@
1
- //= require thredded/dependencies/jquery
2
- // Require jquery.timeago instead of rails-timeago so that we can control the initialization.
3
- //= require jquery.timeago
1
+ //= require thredded/dependencies/timeago
4
2
  //= require thredded/dependencies/ujs
5
3
  //= require autosize
6
- //= require jquery.textcomplete
7
- //= require select2
4
+ //= require thredded/dependencies/textcomplete
8
5
 
9
6
  // We are not currently using any features that require the Babel polyfill
10
7
  // Enable this if we do:
@@ -0,0 +1 @@
1
+ //= require textcomplete.min
@@ -0,0 +1 @@
1
+ //= require timeago
@@ -1 +1 @@
1
- //= require jquery_ujs
1
+ //= require rails-ujs
@@ -1 +0,0 @@
1
- @import "select2";
@@ -26,7 +26,6 @@
26
26
  @import "components/post";
27
27
  @import "components/post-form";
28
28
  @import "components/preferences";
29
- @import "components/select2";
30
29
  @import "components/topic-delete";
31
30
  @import "components/topic-header";
32
31
  @import "components/topics";
@@ -11,11 +11,11 @@ ul.thredded--textcomplete-dropdown {
11
11
  ul.thredded--textcomplete-dropdown {
12
12
 
13
13
  background: $thredded-form-background;
14
- padding: 4px;
14
+ list-style: none;
15
15
  margin: 0;
16
+ padding: 4px;
16
17
 
17
18
  li.textcomplete-item {
18
- list-style: none;
19
19
  a {
20
20
  color: $thredded-text-color;
21
21
  }
@@ -33,3 +33,16 @@ ul.thredded--textcomplete-dropdown {
33
33
  }
34
34
 
35
35
 
36
+ .thredded--textcomplete-user-result {
37
+ &__avatar {
38
+ width: 2rem;
39
+ min-height: 2rem;
40
+ height: auto;
41
+ display: inline-block;
42
+ vertical-align: middle;
43
+ }
44
+ &__name {
45
+ display: inline-block;
46
+ margin-left: 0.6rem
47
+ }
48
+ }
@@ -8,7 +8,7 @@ module Thredded
8
8
  def new_private_topic_params
9
9
  params
10
10
  .require(:private_topic)
11
- .permit(:title, :content, :user_ids, user_ids: [])
11
+ .permit(:title, :content, :user_names, user_ids: [])
12
12
  .merge(
13
13
  user: thredded_current_user,
14
14
  ip: request.remote_ip
@@ -17,7 +17,7 @@ module Thredded
17
17
 
18
18
  private
19
19
 
20
- # select2 returns a string of IDs joined with commas.
20
+ # Allow a string of IDs joined with commas.
21
21
  def adapt_user_ids!(p)
22
22
  p[:user_ids] = p[:user_ids].split(',') if p[:user_ids].is_a?(String)
23
23
  end
@@ -29,7 +29,6 @@ module Thredded
29
29
  end
30
30
  end
31
31
 
32
- # This method is used by select2 do fetch users by ids, e.g. in case of a browser-prefilled field.
33
32
  def users_by_ids
34
33
  ids = params[:ids].to_s.split(',')
35
34
  if ids.present?
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Thredded
4
- class PrivateTopicForm
4
+ class PrivateTopicForm # rubocop:disable Metrics/ClassLength
5
5
  include ActiveModel::Model
6
6
 
7
7
  delegate :id,
@@ -17,6 +17,7 @@ module Thredded
17
17
  :private_topic
18
18
 
19
19
  attr_reader :user, :params
20
+ attr_writer :user_names
20
21
 
21
22
  validate :validate_children
22
23
 
@@ -29,6 +30,7 @@ module Thredded
29
30
  @locked = params[:locked]
30
31
  @sticky = params[:sticky]
31
32
  @content = params[:content]
33
+ @user_names = params[:user_names]
32
34
  end
33
35
 
34
36
  def self.model_name
@@ -36,6 +38,9 @@ module Thredded
36
38
  end
37
39
 
38
40
  def save
41
+ @user_ids ||= []
42
+ @user_ids += Thredded.user_class.where(Thredded.user_name_column => parse_names(user_names)).pluck(:id)
43
+
39
44
  return false unless valid?
40
45
 
41
46
  ActiveRecord::Base.transaction do
@@ -69,6 +74,16 @@ module Thredded
69
74
  Thredded::UrlsHelper.preview_new_private_topic_path
70
75
  end
71
76
 
77
+ def user_names
78
+ @user_names ||= Thredded.user_class.where(id: user_ids).pluck(Thredded.user_name_column).map do |name|
79
+ if name.include?(',')
80
+ "\"#{name}\""
81
+ else
82
+ name
83
+ end
84
+ end.join(', ')
85
+ end
86
+
72
87
  private
73
88
 
74
89
  def topic_categories
@@ -90,8 +105,8 @@ module Thredded
90
105
 
91
106
  def normalized_user_ids
92
107
  user_ids
93
- .reject(&:empty?)
94
108
  .map(&:to_s)
109
+ .reject(&:empty?)
95
110
  .push(user.id.to_s)
96
111
  .uniq
97
112
  end
@@ -112,5 +127,34 @@ module Thredded
112
127
  errors.add(attribute, message)
113
128
  end
114
129
  end
130
+
131
+ def parse_names(text) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength
132
+ result = []
133
+ current = String.new
134
+ in_name = in_quoted = false
135
+ text.each_char do |char|
136
+ case char
137
+ when '"'
138
+ in_quoted = !in_quoted
139
+ when ' '
140
+ current << char if in_name
141
+ when ','
142
+ if in_quoted
143
+ current << char
144
+ else
145
+ in_name = false
146
+ unless current.empty?
147
+ result << current.dup
148
+ current.clear
149
+ end
150
+ end
151
+ else
152
+ in_name = true
153
+ current << char
154
+ end
155
+ end
156
+ result << current unless current.empty?
157
+ result
158
+ end
115
159
  end
116
160
  end
@@ -13,6 +13,7 @@ module Thredded
13
13
 
14
14
  def thredded_container_data
15
15
  {
16
+ 'thredded-locale' => I18n.locale,
16
17
  'thredded-page-id' => content_for(:thredded_page_id),
17
18
  'thredded-root-url' => thredded.root_path
18
19
  }
@@ -52,22 +53,19 @@ module Thredded
52
53
  # @param datetime [DateTime]
53
54
  # @param default [String] a string to return if time is nil.
54
55
  # @return [String] html_safe datetime presentation
55
- def time_ago(datetime, default: '-')
56
- timeago_tag datetime,
57
- lang: I18n.locale.to_s.downcase,
58
- format: ->(t, _opts) { t.year == Time.current.year ? :short : :long },
59
- nojs: true,
60
- date_only: false,
61
- default: default
62
- end
63
-
64
- # Override the default timeago_tag_content from rails-timeago
65
- def timeago_tag_content(time, time_options = {})
66
- if time_options[:nojs] && (time_options[:limit].nil? || time_options[:limit] < time)
67
- t 'thredded.time_ago', time: time_ago_in_words(time)
56
+ def time_ago(datetime, default: '-', html_options: {})
57
+ return content_tag :time, default if datetime.nil?
58
+ html_options = html_options.dup
59
+ is_current_year = datetime.year == Time.current.year
60
+ if datetime > 4.days.ago
61
+ content = t 'thredded.time_ago', time: time_ago_in_words(datetime)
62
+ html_options['data-time-ago'] = true unless html_options.key?('data-time-ago')
68
63
  else
69
- I18n.l time.to_date, format: time_options[:format]
64
+ content = I18n.l(datetime.to_date,
65
+ format: (is_current_year ? :short : :long))
70
66
  end
67
+ html_options[:title] = I18n.l(datetime) unless html_options.key?(:title)
68
+ time_tag datetime, content, html_options
71
69
  end
72
70
 
73
71
  # @param posts [Thredded::PostsPageView, Array<Thredded::PostView>]
@@ -14,12 +14,13 @@
14
14
  <%= form.text_field :title, placeholder: placeholder, required: true %>
15
15
  </li>
16
16
  <li>
17
- <%= form.label :user_ids, t('thredded.private_topics.form.users_label') %>
18
- <%= form.text_field :user_ids,
19
- placeholder: t('thredded.private_topics.form.users_placeholder'),
20
- 'data-thredded-users-select' => true,
21
- 'data-autocomplete-url' => autocomplete_users_path,
22
- 'data-autocomplete-min-length' => Thredded.autocomplete_min_length %>
17
+ <%= form.label :user_names, t('thredded.private_topics.form.users_label') %>
18
+ <%= form.text_area :user_names,
19
+ placeholder: t('thredded.private_topics.form.users_placeholder'),
20
+ 'data-thredded-users-select' => true,
21
+ 'data-autocomplete-url' => autocomplete_users_path,
22
+ 'data-autocomplete-min-length' => Thredded.autocomplete_min_length,
23
+ rows: 1 %>
23
24
  </li>
24
25
 
25
26
  <%= render 'thredded/posts_common/form/content',
@@ -7,9 +7,9 @@
7
7
  <div class="thredded--topics--follow-info" title="<%= topic_follow_reason_text topic.follow_reason %>">
8
8
  <svg class="thredded--topics--follow-icon" viewBox="0 0 116 121" role="img">
9
9
  <% if topic.followed? %>
10
- <use xlink:href="#thredded-follow-icon"/>
10
+ <use xlink:href="#thredded-follow-icon"></use>
11
11
  <% else %>
12
- <use xlink:href="#thredded-unfollow-icon"/>
12
+ <use xlink:href="#thredded-unfollow-icon"></use>
13
13
  <% end %>
14
14
  </svg>
15
15
  </div>
@@ -144,7 +144,7 @@ pl:
144
144
  btn_submit: :thredded.search.form.label
145
145
  label: Wyszukaj
146
146
  placeholder: Wyszukaj tematy i posty.
147
- time_ago: "%{time} ago"
147
+ time_ago: "%{time} temu"
148
148
  topics:
149
149
  delete_confirm: Jesteś pewien, że chcesz usunąć ten temat? Tej operacji nie można cofnąć.
150
150
  delete_topic: Usuń temat
@@ -24,9 +24,7 @@ require 'thredded/html_pipeline/wrap_iframes_filter'
24
24
 
25
25
  # Asset compilation
26
26
  require 'autoprefixer-rails'
27
- require 'jquery/rails'
28
- require 'rails-timeago'
29
- require 'select2-rails'
27
+ require 'timeago_js'
30
28
  require 'sprockets/es6'
31
29
 
32
30
  require 'thredded/version'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Thredded
4
- VERSION = '0.12.4'
4
+ VERSION = '0.13.0'
5
5
  end
@@ -0,0 +1 @@
1
+ !function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=11)}([function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=function(){function e(t,r,i){n(this,e),this.data=t,this.term=r,this.strategy=i}return r(e,[{key:"replace",value:function(e,t){var n=this.strategy.replace(this.data);if(null!==n){Array.isArray(n)&&(t=n[1]+t,n=n[0]);var r=this.strategy.matchText(e);return n=n.replace(/\$&/g,r[0]).replace(/\$(\d+)/g,function(e,t){return r[parseInt(t,10)]}),[[e.slice(0,r.index),n,e.slice(r.index+r[0].length)].join(""),t]}}},{key:"render",value:function(){return this.strategy.template(this.data,this.term)}}]),e}();t.default=i},function(e){"use strict";function t(){}function n(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function r(){this._events=new t,this._eventsCount=0}var i=Object.prototype.hasOwnProperty,o="~";Object.create&&(t.prototype=Object.create(null),(new t).__proto__||(o=!1)),r.prototype.eventNames=function(){var e,t,n=[];if(0===this._eventsCount)return n;for(t in e=this._events)i.call(e,t)&&n.push(o?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},r.prototype.listeners=function(e,t){var n=o?o+e:e,r=this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var i=0,s=r.length,u=new Array(s);i<s;i++)u[i]=r[i].fn;return u},r.prototype.emit=function(e,t,n,r,i,s){var u=o?o+e:e;if(!this._events[u])return!1;var a,l,c=this._events[u],h=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),h){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,i),!0;case 6:return c.fn.call(c.context,t,n,r,i,s),!0}for(l=1,a=new Array(h-1);l<h;l++)a[l-1]=arguments[l];c.fn.apply(c.context,a)}else{var f,d=c.length;for(l=0;l<d;l++)switch(c[l].once&&this.removeListener(e,c[l].fn,void 0,!0),h){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,t);break;case 3:c[l].fn.call(c[l].context,t,n);break;case 4:c[l].fn.call(c[l].context,t,n,r);break;default:if(!a)for(f=1,a=new Array(h-1);f<h;f++)a[f-1]=arguments[f];c[l].fn.apply(c[l].context,a)}}return!0},r.prototype.on=function(e,t,r){var i=new n(t,r||this),s=o?o+e:e;return this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],i]:this._events[s].push(i):(this._events[s]=i,this._eventsCount++),this},r.prototype.once=function(e,t,r){var i=new n(t,r||this,!0),s=o?o+e:e;return this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],i]:this._events[s].push(i):(this._events[s]=i,this._eventsCount++),this},r.prototype.removeListener=function(e,n,r,i){var s=o?o+e:e;if(!this._events[s])return this;if(!n)return 0==--this._eventsCount?this._events=new t:delete this._events[s],this;var u=this._events[s];if(u.fn)u.fn!==n||i&&!u.once||r&&u.context!==r||(0==--this._eventsCount?this._events=new t:delete this._events[s]);else{for(var a=0,l=[],c=u.length;a<c;a++)(u[a].fn!==n||i&&!u[a].once||r&&u[a].context!==r)&&l.push(u[a]);l.length?this._events[s]=1===l.length?l[0]:l:0==--this._eventsCount?this._events=new t:delete this._events[s]}return this},r.prototype.removeAllListeners=function(e){var n;return e?(n=o?o+e:e,this._events[n]&&(0==--this._eventsCount?this._events=new t:delete this._events[n])):(this._events=new t,this._eventsCount=0),this},r.prototype.off=r.prototype.removeListener,r.prototype.addListener=r.prototype.on,r.prototype.setMaxListeners=function(){return this},r.prefixed=o,r.EventEmitter=r,e.exports=r},function(e,t){"use strict";function n(e){var t=e.getBoundingClientRect(),n=e.ownerDocument,r=n.defaultView,i=n.documentElement,o={top:t.top+r.pageYOffset,left:t.left+r.pageXOffset};return i&&(o.top-=i.clientTop,o.left-=i.clientLeft),o}function r(e){return e>=o&&e<=s}function i(e){var t=window.getComputedStyle(e);if(r(t.lineHeight.charCodeAt(0)))return r(t.lineHeight.charCodeAt(t.lineHeight.length-1))?parseFloat(t.lineHeight,10)*parseFloat(t.fontSize,10):parseFloat(t.lineHeight,10);var n=document.body;if(!n)return 0;var i=document.createElement(e.nodeName);i.innerHTML="&nbsp;",i.style.fontSize=t.fontSize,i.style.fontFamily=t.fontFamily,n.appendChild(i);var o=i.offsetHeight;return n.removeChild(i),o}Object.defineProperty(t,"__esModule",{value:!0}),t.calculateElementOffset=n,t.getLineHeightPx=i;var o=(t.createCustomEvent=function(){return"function"==typeof window.CustomEvent?function(e,t){return new document.defaultView.CustomEvent(e,{cancelable:t&&t.cancelable||!1,detail:t&&t.detail||void 0})}:function(e,t){var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,!1,t&&t.cancelable||!1,t&&t.detail||void 0),n}}(),"0".charCodeAt(0)),s="9".charCodeAt(0)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(2),l=n(0),c=(r(l),n(1)),h=r(c),f=function(e){function t(){return i(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return s(t,e),u(t,[{key:"destroy",value:function(){return this}},{key:"applySearchResult",value:function(){throw new Error("Not implemented.")}},{key:"getCursorOffset",value:function(){throw new Error("Not implemented.")}},{key:"getBeforeCursor",value:function(){throw new Error("Not implemented.")}},{key:"getAfterCursor",value:function(){throw new Error("Not implemented.")}},{key:"emitMoveEvent",value:function(e){var t=(0,a.createCustomEvent)("move",{cancelable:!0,detail:{code:e}});return this.emit("move",t),t}},{key:"emitEnterEvent",value:function(){var e=(0,a.createCustomEvent)("enter",{cancelable:!0});return this.emit("enter",e),e}},{key:"emitChangeEvent",value:function(){var e=(0,a.createCustomEvent)("change",{detail:{beforeCursor:this.getBeforeCursor()}});return this.emit("change",e),e}},{key:"emitEscEvent",value:function(){var e=(0,a.createCustomEvent)("esc",{cancelable:!0});return this.emit("esc",e),e}},{key:"getCode",value:function(e){return 8===e.keyCode?"BS":9===e.keyCode?"ENTER":13===e.keyCode?"ENTER":27===e.keyCode?"ESC":38===e.keyCode?"UP":40===e.keyCode?"DOWN":78===e.keyCode&&e.ctrlKey?"DOWN":80===e.keyCode&&e.ctrlKey?"UP":"OTHER"}}]),t}(h.default);t.default=f},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e){return e}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=n(12),u=function(e){return e&&e.__esModule?e:{default:e}}(s),a=function(){function e(t){r(this,e),this.props=t,this.cache=t.cache?{}:null}return o(e,[{key:"destroy",value:function(){return this.cache=null,this}},{key:"buildQuery",value:function(e){if("function"==typeof this.props.context){var t=this.props.context(e);if("string"==typeof t)e=t;else if(!t)return null}var n=this.matchText(e);return n?new u.default(this,n[this.index],n):null}},{key:"search",value:function(e,t,n){this.cache?this.searchWithCache(e,t,n):this.props.search(e,t,n)}},{key:"replace",value:function(e){return this.props.replace(e)}},{key:"searchWithCache",value:function(e,t,n){var r=this;this.cache&&this.cache[e]?t(this.cache[e]):this.props.search(e,function(n){r.cache&&(r.cache[e]=n),t(n)},n)}},{key:"matchText",value:function(e){return"function"==typeof this.match?this.match(e):e.match(this.match)}},{key:"match",get:function(){return this.props.match}},{key:"index",get:function(){return"number"==typeof this.props.index?this.props.index:2}},{key:"template",get:function(){return this.props.template||i}}]),e}();t.default=a},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function e(t,n,r){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(void 0===i){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,n,r)}if("value"in i)return i.value;var s=i.get;if(void 0!==s)return s.call(r)},l=n(3),c=r(l),h=n(2),f=n(0),d=(r(f),n(13)),p=["onInput","onKeydown"],v=function(e){function t(e){i(this,t);var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.el=e,p.forEach(function(e){n[e]=n[e].bind(n)}),n.startListening(),n}return s(t,e),u(t,[{key:"destroy",value:function(){return a(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"destroy",this).call(this),this.stopListening(),this.el=null,this}},{key:"applySearchResult",value:function(e){var t=e.replace(this.getBeforeCursor(),this.getAfterCursor());Array.isArray(t)&&(this.el.value=t[0]+t[1],this.el.selectionStart=this.el.selectionEnd=t[0].length,this.el.dispatchEvent(new Event("input"))),this.el.focus()}},{key:"getCursorOffset",value:function(){var e=(0,h.calculateElementOffset)(this.el),t=this.getElScroll(),n=this.getCursorPosition(),r=(0,h.getLineHeightPx)(this.el),i=e.top-t.top+n.top+r,o=e.left-t.left+n.left;if("rtl"!==this.el.dir)return{top:i,left:o,lineHeight:r};if(document.documentElement){return{top:i,right:document.documentElement.clientWidth-o,lineHeight:r}}}},{key:"getBeforeCursor",value:function(){return this.el.value.substring(0,this.el.selectionEnd)}},{key:"getAfterCursor",value:function(){return this.el.value.substring(this.el.selectionEnd)}},{key:"getElScroll",value:function(){return{top:this.el.scrollTop,left:this.el.scrollLeft}}},{key:"getCursorPosition",value:function(){return d(this.el,this.el.selectionEnd)}},{key:"onInput",value:function(){this.emitChangeEvent()}},{key:"onKeydown",value:function(e){var t=this.getCode(e),n=void 0;"UP"===t||"DOWN"===t?n=this.emitMoveEvent(t):"ENTER"===t?n=this.emitEnterEvent():"ESC"===t&&(n=this.emitEscEvent()),n&&n.defaultPrevented&&e.preventDefault()}},{key:"startListening",value:function(){this.el.addEventListener("input",this.onInput),this.el.addEventListener("keydown",this.onKeydown)}},{key:"stopListening",value:function(){this.el.removeEventListener("input",this.onInput),this.el.removeEventListener("keydown",this.onKeydown)}}]),t}(c.default);t.default=v},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(8),l=r(a),c=n(3),h=(r(c),n(9)),f=r(h),d=n(4),p=r(d),v=n(0),y=(r(v),n(1)),m=r(y),g=["handleChange","handleEnter","handleEsc","handleHit","handleMove","handleSelect"],b=function(e){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};i(this,t);var r=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return r.completer=new l.default,r.isQueryInFlight=!1,r.nextPendingQuery=null,r.dropdown=new f.default(n.dropdown||{}),r.editor=e,r.options=n,g.forEach(function(e){r[e]=r[e].bind(r)}),r.startListening(),r}return s(t,e),u(t,[{key:"destroy",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.completer.destroy(),this.dropdown.destroy(),e&&this.editor.destroy(),this.stopListening(),this}},{key:"register",value:function(e){var t=this;return e.forEach(function(e){t.completer.registerStrategy(new p.default(e))}),this}},{key:"trigger",value:function(e){return this.isQueryInFlight?this.nextPendingQuery=e:(this.isQueryInFlight=!0,this.nextPendingQuery=null,this.completer.run(e)),this}},{key:"handleHit",value:function(e){var t=e.searchResults;t.length?this.dropdown.render(t,this.editor.getCursorOffset()):this.dropdown.deactivate(),this.isQueryInFlight=!1,null!==this.nextPendingQuery&&this.trigger(this.nextPendingQuery)}},{key:"handleMove",value:function(e){"UP"===e.detail.code?this.dropdown.up(e):this.dropdown.down(e)}},{key:"handleEnter",value:function(e){var t=this.dropdown.getActiveItem();t&&(this.dropdown.select(t),e.preventDefault())}},{key:"handleEsc",value:function(e){this.dropdown.shown&&(this.dropdown.deactivate(),e.preventDefault())}},{key:"handleChange",value:function(e){this.trigger(e.detail.beforeCursor)}},{key:"handleSelect",value:function(e){this.emit("select",e),e.defaultPrevented||this.editor.applySearchResult(e.detail.searchResult)}},{key:"startListening",value:function(){var e=this;this.editor.on("move",this.handleMove).on("enter",this.handleEnter).on("esc",this.handleEsc).on("change",this.handleChange),this.dropdown.on("select",this.handleSelect),["show","shown","render","rendered","selected","hidden","hide"].forEach(function(t){e.dropdown.on(t,function(){return e.emit(t)})}),this.completer.on("hit",this.handleHit)}},{key:"stopListening",value:function(){this.completer.removeAllListeners(),this.dropdown.removeAllListeners(),this.editor.removeListener("move",this.handleMove).removeListener("enter",this.handleEnter).removeListener("esc",this.handleEsc).removeListener("change",this.handleChange)}}]),t}(m.default);t.default=b},function(e){var t;t=function(){return this}();try{t=t||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(t=window)}e.exports=t},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(1),l=r(a),c=n(4),h=(r(c),n(0)),f=(r(h),["handleQueryResult"]),d=function(e){function t(){i(this,t);var e=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.strategies=[],f.forEach(function(t){e[t]=e[t].bind(e)}),e}return s(t,e),u(t,[{key:"destroy",value:function(){return this.strategies.forEach(function(e){return e.destroy()}),this}},{key:"registerStrategy",value:function(e){return this.strategies.push(e),this}},{key:"run",value:function(e){var t=this.extractQuery(e);t?t.execute(this.handleQueryResult):this.handleQueryResult([])}},{key:"extractQuery",value:function(e){for(var t=0;t<this.strategies.length;t++){var n=this.strategies[t].buildQuery(e);if(n)return n}return null}},{key:"handleQueryResult",value:function(e){this.emit("hit",{searchResults:e})}}]),t}(l.default);t.default=d},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(10),l=r(a),c=n(0),h=(r(c),n(2)),f=n(1),d=r(f),p="dropdown-menu textcomplete-dropdown",v=function(e){function t(e){var n=e.className,r=void 0===n?p:n,s=e.footer,u=e.header,a=e.maxCount,l=void 0===a?10:a,c=e.placement,h=e.rotate,f=void 0===h||h,d=e.style;i(this,t);var v=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return v.shown=!1,v.items=[],v.footer=s,v.header=u,v.maxCount=l,v.el.className=r,v.rotate=f,v.placement=c,d&&Object.keys(d).forEach(function(e){v.el.style[e]=d[e]}),v}return s(t,e),u(t,null,[{key:"createElement",value:function(){var e=document.createElement("ul"),t=e.style;t.display="none",t.position="absolute",t.zIndex="10000";var n=document.body;return n&&n.appendChild(e),e}}]),u(t,[{key:"destroy",value:function(){var e=this.el.parentNode;return e&&e.removeChild(this.el),this.clear()._el=null,this}},{key:"render",value:function(e,t){var n=(0,h.createCustomEvent)("render",{cancelable:!0});if(this.emit("render",n),n.defaultPrevented)return this;var r=e.map(function(e){return e.data}),i=e.slice(0,this.maxCount||e.length).map(function(e){return new l.default(e)});return this.clear().setStrategyId(e[0]).renderEdge(r,"header").append(i).renderEdge(r,"footer").setOffset(t).show(),this.emit("rendered",(0,h.createCustomEvent)("rendered")),this}},{key:"deactivate",value:function(){return this.hide().clear()}},{key:"select",value:function(e){var t={searchResult:e.searchResult},n=(0,h.createCustomEvent)("select",{cancelable:!0,detail:t});return this.emit("select",n),n.defaultPrevented?this:(this.deactivate(),this.emit("selected",(0,h.createCustomEvent)("selected",{detail:t})),this)}},{key:"up",value:function(e){return this.shown?this.moveActiveItem("prev",e):this}},{key:"down",value:function(e){return this.shown?this.moveActiveItem("next",e):this}},{key:"getActiveItem",value:function(){return this.items.find(function(e){return e.active})}},{key:"append",value:function(e){var t=this,n=document.createDocumentFragment();return e.forEach(function(e){t.items.push(e),e.appended(t),n.appendChild(e.el)}),this.el.appendChild(n),this}},{key:"setOffset",value:function(e){if(e.left?this.el.style.left=e.left+"px":e.right&&(this.el.style.right=e.right+"px"),this.isPlacementTop()){var t=document.documentElement;t&&(this.el.style.bottom=t.clientHeight-e.top+e.lineHeight+"px")}else this.el.style.top=e.top+"px";return this}},{key:"show",value:function(){if(!this.shown){var e=(0,h.createCustomEvent)("show",{cancelable:!0});if(this.emit("show",e),e.defaultPrevented)return this;this.el.style.display="block",this.shown=!0,this.emit("shown",(0,h.createCustomEvent)("shown"))}return this}},{key:"hide",value:function(){if(this.shown){var e=(0,h.createCustomEvent)("hide",{cancelable:!0});if(this.emit("hide",e),e.defaultPrevented)return this;this.el.style.display="none",this.shown=!1,this.emit("hidden",(0,h.createCustomEvent)("hidden"))}return this}},{key:"clear",value:function(){return this.el.innerHTML="",this.items.forEach(function(e){return e.destroy()}),this.items=[],this}},{key:"moveActiveItem",value:function(e,t){var n=this.getActiveItem(),r=void 0;return r=n?n[e]:"next"===e?this.items[0]:this.items[this.items.length-1],r&&(r.activate(),t.preventDefault()),this}},{key:"setStrategyId",value:function(e){var t=e&&e.strategy.props.id;return t?this.el.setAttribute("data-strategy",t):this.el.removeAttribute("data-strategy"),this}},{key:"renderEdge",value:function(e,t){var n=("header"===t?this.header:this.footer)||"",r="function"==typeof n?n(e):n,i=document.createElement("li");return i.classList.add("textcomplete-"+t),i.innerHTML=r,this.el.appendChild(i),this}},{key:"isPlacementTop",value:function(){return"top"===this.placement}},{key:"el",get:function(){return this._el||(this._el=t.createElement()),this._el}}]),t}(d.default);t.default=v},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.CLASS_NAME=void 0;var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(0),s=(function(e){e&&e.__esModule}(o),t.CLASS_NAME="textcomplete-item"),u=s+" active",a=["onClick","onMouseover"],l=function(){function e(t){var n=this;r(this,e),this.searchResult=t,this.active=!1,a.forEach(function(e){n[e]=n[e].bind(n)})}return i(e,[{key:"destroy",value:function(){this.el.removeEventListener("mousedown",this.onClick,!1),this.el.removeEventListener("mouseover",this.onMouseover,!1),this.el.removeEventListener("touchstart",this.onClick,!1),this._el=null}},{key:"appended",value:function(e){this.dropdown=e,this.siblings=e.items,this.index=this.siblings.length-1}},{key:"activate",value:function(){if(!this.active){var e=this.dropdown.getActiveItem();e&&e.deactivate(),this.active=!0,this.el.className=u}return this}},{key:"deactivate",value:function(){return this.active&&(this.active=!1,this.el.className=s),this}},{key:"onClick",value:function(e){e.preventDefault(),this.dropdown.select(this)}},{key:"onMouseover",value:function(){this.activate()}},{key:"el",get:function(){if(this._el)return this._el;var e=document.createElement("li");e.className=this.active?u:s;var t=document.createElement("a");return t.innerHTML=this.searchResult.render(),e.appendChild(t),this._el=e,e.addEventListener("mousedown",this.onClick),e.addEventListener("mouseover",this.onMouseover),e.addEventListener("touchstart",this.onClick),e}},{key:"next",get:function(){var e=void 0;if(this.index===this.siblings.length-1){if(!this.dropdown.rotate)return null;e=0}else e=this.index+1;return this.siblings[e]}},{key:"prev",get:function(){var e=void 0;if(0===this.index){if(!this.dropdown.rotate)return null;e=this.siblings.length-1}else e=this.index-1;return this.siblings[e]}}]),e}();t.default=l},function(e,t,n){"use strict";(function(e){function t(e){return e&&e.__esModule?e:{default:e}}var r=n(6),i=t(r),o=n(5),s=t(o),u=void 0;u=e.Textcomplete&&e.Textcomplete.editors?e.Textcomplete.editors:{},u.Textarea=s.default,e.Textcomplete=i.default,e.Textcomplete.editors=u}).call(t,n(7))},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(0),s=function(e){return e&&e.__esModule?e:{default:e}}(o),u=function(){function e(t,n,i){r(this,e),this.strategy=t,this.term=n,this.match=i}return i(e,[{key:"execute",value:function(e){var t=this;this.strategy.search(this.term,function(n){e(n.map(function(e){return new s.default(e,t.term,t.strategy)}))},this.match)}}]),e}();t.default=u},function(e){!function(){function t(e,t,o){if(!r)throw new Error("textarea-caret-position#getCaretCoordinates should only be called in a browser");var s=o&&o.debug||!1;if(s){var u=document.querySelector("#input-textarea-caret-position-mirror-div");u&&u.parentNode.removeChild(u)}var a=document.createElement("div");a.id="input-textarea-caret-position-mirror-div",document.body.appendChild(a);var l=a.style,c=window.getComputedStyle?getComputedStyle(e):e.currentStyle;l.whiteSpace="pre-wrap","INPUT"!==e.nodeName&&(l.wordWrap="break-word"),l.position="absolute",s||(l.visibility="hidden"),n.forEach(function(e){l[e]=c[e]}),i?e.scrollHeight>parseInt(c.height)&&(l.overflowY="scroll"):l.overflow="hidden",a.textContent=e.value.substring(0,t),"INPUT"===e.nodeName&&(a.textContent=a.textContent.replace(/\s/g," "));var h=document.createElement("span");h.textContent=e.value.substring(t)||".",a.appendChild(h);var f={top:h.offsetTop+parseInt(c.borderTopWidth),left:h.offsetLeft+parseInt(c.borderLeftWidth)};return s?h.style.backgroundColor="#aaa":document.body.removeChild(a),f}var n=["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize","MozTabSize"],r="undefined"!=typeof window,i=r&&null!=window.mozInnerScreenX;void 0!==e&&void 0!==e.exports?e.exports=t:r&&(window.getCaretCoordinates=t)}()}]);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thredded
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.4
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Oliveira
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-05-29 00:00:00.000000000 Z
12
+ date: 2017-06-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pundit
@@ -270,7 +270,7 @@ dependencies:
270
270
  - !ruby/object:Gem::Version
271
271
  version: '0'
272
272
  - !ruby/object:Gem::Dependency
273
- name: rails-timeago
273
+ name: timeago_js
274
274
  requirement: !ruby/object:Gem::Requirement
275
275
  requirements:
276
276
  - - ">="
@@ -283,20 +283,6 @@ dependencies:
283
283
  - - ">="
284
284
  - !ruby/object:Gem::Version
285
285
  version: '0'
286
- - !ruby/object:Gem::Dependency
287
- name: select2-rails
288
- requirement: !ruby/object:Gem::Requirement
289
- requirements:
290
- - - "~>"
291
- - !ruby/object:Gem::Version
292
- version: '3.5'
293
- type: :runtime
294
- prerelease: false
295
- version_requirements: !ruby/object:Gem::Requirement
296
- requirements:
297
- - - "~>"
298
- - !ruby/object:Gem::Version
299
- version: '3.5'
300
286
  - !ruby/object:Gem::Dependency
301
287
  name: sprockets-es6
302
288
  requirement: !ruby/object:Gem::Requirement
@@ -311,20 +297,6 @@ dependencies:
311
297
  - - ">="
312
298
  - !ruby/object:Gem::Version
313
299
  version: '0'
314
- - !ruby/object:Gem::Dependency
315
- name: jquery-rails
316
- requirement: !ruby/object:Gem::Requirement
317
- requirements:
318
- - - ">="
319
- - !ruby/object:Gem::Version
320
- version: 4.2.1
321
- type: :runtime
322
- prerelease: false
323
- version_requirements: !ruby/object:Gem::Requirement
324
- requirements:
325
- - - ">="
326
- - !ruby/object:Gem::Version
327
- version: 4.2.1
328
300
  - !ruby/object:Gem::Dependency
329
301
  name: capybara
330
302
  requirement: !ruby/object:Gem::Requirement
@@ -457,14 +429,14 @@ dependencies:
457
429
  requirements:
458
430
  - - '='
459
431
  - !ruby/object:Gem::Version
460
- version: 0.48.1
432
+ version: 0.49.1
461
433
  type: :development
462
434
  prerelease: false
463
435
  version_requirements: !ruby/object:Gem::Requirement
464
436
  requirements:
465
437
  - - '='
466
438
  - !ruby/object:Gem::Version
467
- version: 0.48.1
439
+ version: 0.49.1
468
440
  - !ruby/object:Gem::Dependency
469
441
  name: rails-i18n
470
442
  requirement: !ruby/object:Gem::Requirement
@@ -709,6 +681,7 @@ files:
709
681
  - app/assets/javascripts/thredded.es6
710
682
  - app/assets/javascripts/thredded/components/currently_online.es6
711
683
  - app/assets/javascripts/thredded/components/flash_messages.es6
684
+ - app/assets/javascripts/thredded/components/mention_autocompletion.es6
712
685
  - app/assets/javascripts/thredded/components/post_form.es6
713
686
  - app/assets/javascripts/thredded/components/preview_area.es6
714
687
  - app/assets/javascripts/thredded/components/quote_post.es6
@@ -717,15 +690,18 @@ files:
717
690
  - app/assets/javascripts/thredded/components/topics.es6
718
691
  - app/assets/javascripts/thredded/components/turboforms.es6
719
692
  - app/assets/javascripts/thredded/components/user_preferences_form.es6
693
+ - app/assets/javascripts/thredded/components/user_textcomplete.es6
720
694
  - app/assets/javascripts/thredded/components/users_select.es6
721
695
  - app/assets/javascripts/thredded/core/csrf_tokens.es6
722
696
  - app/assets/javascripts/thredded/core/debounce.es6
697
+ - app/assets/javascripts/thredded/core/escape_html.es6
723
698
  - app/assets/javascripts/thredded/core/hide_soft_keyboard.es6
724
- - app/assets/javascripts/thredded/core/mention_autocompletion.es6
725
699
  - app/assets/javascripts/thredded/core/on_page_load.es6
700
+ - app/assets/javascripts/thredded/core/serialize_form.es6
726
701
  - app/assets/javascripts/thredded/core/thredded.es6
727
702
  - app/assets/javascripts/thredded/dependencies.js
728
- - app/assets/javascripts/thredded/dependencies/jquery.js
703
+ - app/assets/javascripts/thredded/dependencies/textcomplete.js
704
+ - app/assets/javascripts/thredded/dependencies/timeago.js
729
705
  - app/assets/javascripts/thredded/dependencies/ujs.js
730
706
  - app/assets/javascripts/thredded/thredded.es6
731
707
  - app/assets/stylesheets/thredded.scss
@@ -760,7 +736,6 @@ files:
760
736
  - app/assets/stylesheets/thredded/components/_post.scss
761
737
  - app/assets/stylesheets/thredded/components/_preferences.scss
762
738
  - app/assets/stylesheets/thredded/components/_preview_area.scss
763
- - app/assets/stylesheets/thredded/components/_select2.scss
764
739
  - app/assets/stylesheets/thredded/components/_topic-delete.scss
765
740
  - app/assets/stylesheets/thredded/components/_topic-header.scss
766
741
  - app/assets/stylesheets/thredded/components/_topics.scss
@@ -1036,7 +1011,7 @@ files:
1036
1011
  - lib/thredded/view_hooks/config.rb
1037
1012
  - lib/thredded/view_hooks/renderer.rb
1038
1013
  - vendor/assets/javascripts/autosize.js
1039
- - vendor/assets/javascripts/jquery.textcomplete.js
1014
+ - vendor/assets/javascripts/textcomplete.min.js
1040
1015
  homepage: https://thredded.org
1041
1016
  licenses:
1042
1017
  - MIT
@@ -1,54 +0,0 @@
1
- class ThreddedMentionAutocompletion {
2
- constructor($) {
3
- this.$ = $;
4
- this.textareaSelector = 'textarea';
5
- }
6
- init($nodes){
7
- const $textarea = $nodes.find(this.textareaSelector);
8
- this.autocompleteMinLength = parseInt($nodes.data('autocompleteMinLength'), 10);
9
- this.automentionCompletion($textarea, $nodes.data('autocompleteUrl'));
10
- }
11
-
12
- escapeHtml(text) {
13
- return this.$('<div/>').text(text).html();
14
- }
15
-
16
- formatUser({avatar_url, name, escapeHtml}) {
17
- return "<div class='thredded--select2-user-result'>" +
18
- `<img class='thredded--select2-user-result__avatar' src='${this.escapeHtml(avatar_url)}' >` +
19
- `<span class='thredded--select2-user-result__name'>${this.escapeHtml(name)}</span>` +
20
- '</div>';
21
- }
22
-
23
-
24
- automentionCompletion($textarea, autocompleteUrl) {
25
- let mentionAC = this;
26
- $textarea.textcomplete([{
27
- match: ThreddedMentionAutocompletion.MATCH_RE,
28
- search (term, callback, match) {
29
- if(term.length < this.autocompleteMinLength){
30
- return callback({});
31
- }
32
- let termsUrl = `${autocompleteUrl}?q=${term}`;
33
- $.ajax({url: termsUrl}).done(function (response) {
34
- callback($.map(response.results, function ({avatar_url, id, name}) {
35
- return {avatar_url, id, name, match};
36
- }));
37
- });
38
- },
39
- template ({avatar_url, name}) {
40
- return mentionAC.formatUser({avatar_url, name});
41
- },
42
- replace ({name, match}) {
43
- let prefix = match[1];
44
- if (/[., ()]/.test(name)) {
45
- return `${prefix}"${name}" `
46
- } else {
47
- return `${prefix}${name} `
48
- }
49
- }
50
- }], {dropdownClassName: 'thredded--textcomplete-dropdown'});
51
- }
52
- }
53
-
54
- ThreddedMentionAutocompletion.MATCH_RE = /(^@|\s@)"?([\w.,\- ()]+)$/;