thredded 0.13.0 → 0.14.0
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.
- checksums.yaml +4 -4
- data/README.md +29 -25
- data/app/assets/images/thredded/lock.svg +1 -0
- data/app/assets/javascripts/thredded/components/mention_autocompletion.es6 +2 -1
- data/app/assets/javascripts/thredded/components/post_form.es6 +1 -1
- data/app/assets/javascripts/thredded/components/time_stamps.es6 +1 -1
- data/app/assets/javascripts/thredded/components/topic_form.es6 +1 -1
- data/app/assets/javascripts/thredded/components/users_select.es6 +1 -1
- data/app/assets/javascripts/thredded/dependencies/autosize.js +1 -0
- data/app/assets/javascripts/thredded/dependencies.js +1 -1
- data/app/assets/stylesheets/thredded/base/_variables.scss +4 -0
- data/app/assets/stylesheets/thredded/components/_form-list.scss +2 -1
- data/app/assets/stylesheets/thredded/components/_messageboard.scss +10 -1
- data/app/assets/stylesheets/thredded/components/_onebox.scss +0 -9
- data/app/assets/stylesheets/thredded/components/_post.scss +7 -1
- data/app/assets/stylesheets/thredded/components/_topics.scss +12 -0
- data/app/commands/thredded/create_messageboard.rb +3 -3
- data/app/commands/thredded/mark_all_read.rb +1 -1
- data/app/commands/thredded/notify_following_users.rb +40 -22
- data/app/commands/thredded/notify_private_topic_users.rb +1 -1
- data/app/controllers/concerns/thredded/new_post_params.rb +1 -1
- data/app/controllers/concerns/thredded/new_private_post_params.rb +1 -1
- data/app/controllers/thredded/application_controller.rb +1 -1
- data/app/controllers/thredded/autocomplete_users_controller.rb +1 -1
- data/app/controllers/thredded/messageboard_groups_controller.rb +2 -2
- data/app/controllers/thredded/messageboards_controller.rb +7 -7
- data/app/controllers/thredded/moderation_controller.rb +1 -1
- data/app/controllers/thredded/post_permalinks_controller.rb +1 -1
- data/app/controllers/thredded/post_previews_controller.rb +3 -3
- data/app/controllers/thredded/posts_controller.rb +9 -5
- data/app/controllers/thredded/preferences_controller.rb +2 -2
- data/app/controllers/thredded/private_post_permalinks_controller.rb +1 -1
- data/app/controllers/thredded/private_post_previews_controller.rb +3 -3
- data/app/controllers/thredded/private_posts_controller.rb +5 -5
- data/app/controllers/thredded/private_topic_previews_controller.rb +1 -1
- data/app/controllers/thredded/read_states_controller.rb +1 -1
- data/app/controllers/thredded/theme_previews_controller.rb +23 -23
- data/app/controllers/thredded/topic_previews_controller.rb +1 -1
- data/app/forms/thredded/private_topic_form.rb +1 -1
- data/app/forms/thredded/topic_form.rb +2 -2
- data/app/forms/thredded/user_preferences_form.rb +2 -2
- data/app/helpers/thredded/render_helper.rb +1 -1
- data/app/jobs/thredded/auto_follow_and_notify_job.rb +3 -3
- data/app/mailer_previews/thredded/base_mailer_preview.rb +5 -5
- data/app/mailer_previews/thredded/private_topic_mailer_preview.rb +1 -5
- data/app/mailers/thredded/post_mailer.rb +11 -6
- data/app/mailers/thredded/private_topic_mailer.rb +12 -8
- data/app/models/concerns/thredded/content_moderation_state.rb +1 -1
- data/app/models/thredded/topic.rb +1 -1
- data/app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb +0 -11
- data/app/models/thredded/user_permissions/moderate/none.rb +0 -11
- data/app/models/thredded/user_permissions/write/all.rb +0 -11
- data/app/models/thredded/user_permissions/write/none.rb +0 -11
- data/app/models/thredded/user_topic_follow.rb +4 -2
- data/app/notifiers/thredded/email_notifier.rb +6 -2
- data/app/policies/thredded/messageboard_policy.rb +3 -1
- data/app/policies/thredded/post_policy.rb +5 -1
- data/app/view_models/thredded/private_topic_view.rb +1 -1
- data/app/view_models/thredded/topic_email_view.rb +0 -4
- data/app/views/thredded/messageboards/_form.html.erb +6 -0
- data/app/views/thredded/messageboards/_messageboard.html.erb +1 -5
- data/app/views/thredded/messageboards/_messageboard_meta.html.erb +13 -0
- data/app/views/thredded/moderation/users.html.erb +2 -2
- data/app/views/thredded/post_mailer/post_notification.html.erb +9 -6
- data/app/views/thredded/post_mailer/post_notification.text.erb +9 -5
- data/app/views/thredded/preferences/_form.html.erb +9 -9
- data/app/views/thredded/private_topic_mailer/message_notification.html.erb +10 -4
- data/app/views/thredded/private_topic_mailer/message_notification.text.erb +11 -8
- data/app/views/thredded/private_topics/new.html.erb +1 -1
- data/app/views/thredded/shared/nav/_standalone.html.erb +1 -1
- data/app/views/thredded/theme_previews/show.html.erb +6 -4
- data/app/views/thredded/topics/_topic.html.erb +2 -1
- data/app/views/thredded/topics/index.html.erb +6 -1
- data/app/views/thredded/topics/new.html.erb +1 -1
- data/app/views/thredded/topics/show.html.erb +4 -0
- data/config/locales/de.yml +249 -0
- data/config/locales/en.yml +43 -0
- data/config/locales/es.yml +45 -0
- data/config/locales/fr.yml +247 -0
- data/config/locales/pl.yml +43 -0
- data/config/locales/pt-BR.yml +45 -0
- data/config/locales/ru.yml +43 -1
- data/config/locales/zh-CN.yml +238 -0
- data/db/migrate/20160329231848_create_thredded.rb +3 -2
- data/db/upgrade_migrations/20170811090735_upgrade_thredded_v0_13_to_v_014.rb +21 -0
- data/lib/generators/thredded/install/templates/initializer.rb +3 -3
- data/lib/thredded/database_seeder.rb +12 -12
- data/lib/thredded/engine.rb +1 -1
- data/lib/thredded/html_pipeline/onebox_filter.rb +2 -1
- data/lib/thredded/version.rb +1 -1
- data/lib/thredded.rb +2 -1
- data/vendor/assets/javascripts/autosize.min.js +6 -0
- data/vendor/assets/javascripts/textcomplete.min.js +2 -1
- metadata +19 -12
- data/vendor/assets/javascripts/autosize.js +0 -290
- /data/{app/notifiers → lib}/thredded/base_notifier.rb +0 -0
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.
|
|
4
|
+
version: 0.14.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-06
|
|
12
|
+
date: 2017-12-06 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: pundit
|
|
@@ -174,7 +174,7 @@ dependencies:
|
|
|
174
174
|
version: '1.8'
|
|
175
175
|
- - ">="
|
|
176
176
|
- !ruby/object:Gem::Version
|
|
177
|
-
version: 1.8.
|
|
177
|
+
version: 1.8.13
|
|
178
178
|
type: :runtime
|
|
179
179
|
prerelease: false
|
|
180
180
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -184,7 +184,7 @@ dependencies:
|
|
|
184
184
|
version: '1.8'
|
|
185
185
|
- - ">="
|
|
186
186
|
- !ruby/object:Gem::Version
|
|
187
|
-
version: 1.8.
|
|
187
|
+
version: 1.8.13
|
|
188
188
|
- !ruby/object:Gem::Dependency
|
|
189
189
|
name: html-pipeline
|
|
190
190
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -312,19 +312,19 @@ dependencies:
|
|
|
312
312
|
- !ruby/object:Gem::Version
|
|
313
313
|
version: '2.4'
|
|
314
314
|
- !ruby/object:Gem::Dependency
|
|
315
|
-
name:
|
|
315
|
+
name: selenium-webdriver
|
|
316
316
|
requirement: !ruby/object:Gem::Requirement
|
|
317
317
|
requirements:
|
|
318
318
|
- - ">="
|
|
319
319
|
- !ruby/object:Gem::Version
|
|
320
|
-
version:
|
|
320
|
+
version: 3.5.0
|
|
321
321
|
type: :development
|
|
322
322
|
prerelease: false
|
|
323
323
|
version_requirements: !ruby/object:Gem::Requirement
|
|
324
324
|
requirements:
|
|
325
325
|
- - ">="
|
|
326
326
|
- !ruby/object:Gem::Version
|
|
327
|
-
version:
|
|
327
|
+
version: 3.5.0
|
|
328
328
|
- !ruby/object:Gem::Dependency
|
|
329
329
|
name: webmock
|
|
330
330
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -354,7 +354,7 @@ dependencies:
|
|
|
354
354
|
- !ruby/object:Gem::Version
|
|
355
355
|
version: '0'
|
|
356
356
|
- !ruby/object:Gem::Dependency
|
|
357
|
-
name:
|
|
357
|
+
name: factory_bot_rails
|
|
358
358
|
requirement: !ruby/object:Gem::Requirement
|
|
359
359
|
requirements:
|
|
360
360
|
- - ">="
|
|
@@ -569,14 +569,14 @@ dependencies:
|
|
|
569
569
|
requirements:
|
|
570
570
|
- - ">="
|
|
571
571
|
- !ruby/object:Gem::Version
|
|
572
|
-
version:
|
|
572
|
+
version: 0.9.18
|
|
573
573
|
type: :development
|
|
574
574
|
prerelease: false
|
|
575
575
|
version_requirements: !ruby/object:Gem::Requirement
|
|
576
576
|
requirements:
|
|
577
577
|
- - ">="
|
|
578
578
|
- !ruby/object:Gem::Version
|
|
579
|
-
version:
|
|
579
|
+
version: 0.9.18
|
|
580
580
|
- !ruby/object:Gem::Dependency
|
|
581
581
|
name: web-console
|
|
582
582
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -673,6 +673,7 @@ files:
|
|
|
673
673
|
- app/assets/images/favicons/wikipedia.png
|
|
674
674
|
- app/assets/images/thredded/breadcrumb-chevron.svg
|
|
675
675
|
- app/assets/images/thredded/follow.svg
|
|
676
|
+
- app/assets/images/thredded/lock.svg
|
|
676
677
|
- app/assets/images/thredded/moderation.svg
|
|
677
678
|
- app/assets/images/thredded/private-messages.svg
|
|
678
679
|
- app/assets/images/thredded/settings.svg
|
|
@@ -700,6 +701,7 @@ files:
|
|
|
700
701
|
- app/assets/javascripts/thredded/core/serialize_form.es6
|
|
701
702
|
- app/assets/javascripts/thredded/core/thredded.es6
|
|
702
703
|
- app/assets/javascripts/thredded/dependencies.js
|
|
704
|
+
- app/assets/javascripts/thredded/dependencies/autosize.js
|
|
703
705
|
- app/assets/javascripts/thredded/dependencies/textcomplete.js
|
|
704
706
|
- app/assets/javascripts/thredded/dependencies/timeago.js
|
|
705
707
|
- app/assets/javascripts/thredded/dependencies/ujs.js
|
|
@@ -839,7 +841,6 @@ files:
|
|
|
839
841
|
- app/models/thredded/user_private_topic_read_state.rb
|
|
840
842
|
- app/models/thredded/user_topic_follow.rb
|
|
841
843
|
- app/models/thredded/user_topic_read_state.rb
|
|
842
|
-
- app/notifiers/thredded/base_notifier.rb
|
|
843
844
|
- app/notifiers/thredded/email_notifier.rb
|
|
844
845
|
- app/policies/thredded/messageboard_group_policy.rb
|
|
845
846
|
- app/policies/thredded/messageboard_policy.rb
|
|
@@ -872,6 +873,7 @@ files:
|
|
|
872
873
|
- app/views/thredded/messageboard_groups/new.html.erb
|
|
873
874
|
- app/views/thredded/messageboards/_form.html.erb
|
|
874
875
|
- app/views/thredded/messageboards/_messageboard.html.erb
|
|
876
|
+
- app/views/thredded/messageboards/_messageboard_meta.html.erb
|
|
875
877
|
- app/views/thredded/messageboards/edit.html.erb
|
|
876
878
|
- app/views/thredded/messageboards/index.html.erb
|
|
877
879
|
- app/views/thredded/messageboards/new.html.erb
|
|
@@ -971,11 +973,14 @@ files:
|
|
|
971
973
|
- bin/rails
|
|
972
974
|
- bin/rubocop
|
|
973
975
|
- config/i18n-tasks.yml
|
|
976
|
+
- config/locales/de.yml
|
|
974
977
|
- config/locales/en.yml
|
|
975
978
|
- config/locales/es.yml
|
|
979
|
+
- config/locales/fr.yml
|
|
976
980
|
- config/locales/pl.yml
|
|
977
981
|
- config/locales/pt-BR.yml
|
|
978
982
|
- config/locales/ru.yml
|
|
983
|
+
- config/locales/zh-CN.yml
|
|
979
984
|
- config/routes.rb
|
|
980
985
|
- db/migrate/20160329231848_create_thredded.rb
|
|
981
986
|
- db/seeds.rb
|
|
@@ -986,12 +991,14 @@ files:
|
|
|
986
991
|
- db/upgrade_migrations/20170125033319_upgrade_v0_9_to_v0_10.rb
|
|
987
992
|
- db/upgrade_migrations/20170312131417_upgrade_thredded_v0_10_to_v0_11.rb
|
|
988
993
|
- db/upgrade_migrations/20170420163138_upgrade_thredded_v0_11_to_v0_12.rb
|
|
994
|
+
- db/upgrade_migrations/20170811090735_upgrade_thredded_v0_13_to_v_014.rb
|
|
989
995
|
- lib/generators/thredded/install/USAGE
|
|
990
996
|
- lib/generators/thredded/install/install_generator.rb
|
|
991
997
|
- lib/generators/thredded/install/templates/initializer.rb
|
|
992
998
|
- lib/tasks/thredded_tasks.rake
|
|
993
999
|
- lib/thredded.rb
|
|
994
1000
|
- lib/thredded/base_migration.rb
|
|
1001
|
+
- lib/thredded/base_notifier.rb
|
|
995
1002
|
- lib/thredded/collection_to_strings_with_cache_renderer.rb
|
|
996
1003
|
- lib/thredded/content_formatter.rb
|
|
997
1004
|
- lib/thredded/database_seeder.rb
|
|
@@ -1010,7 +1017,7 @@ files:
|
|
|
1010
1017
|
- lib/thredded/version.rb
|
|
1011
1018
|
- lib/thredded/view_hooks/config.rb
|
|
1012
1019
|
- lib/thredded/view_hooks/renderer.rb
|
|
1013
|
-
- vendor/assets/javascripts/autosize.js
|
|
1020
|
+
- vendor/assets/javascripts/autosize.min.js
|
|
1014
1021
|
- vendor/assets/javascripts/textcomplete.min.js
|
|
1015
1022
|
homepage: https://thredded.org
|
|
1016
1023
|
licenses:
|
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
Autosize 3.0.20
|
|
3
|
-
license: MIT
|
|
4
|
-
http://www.jacklmoore.com/autosize
|
|
5
|
-
*/
|
|
6
|
-
(function (global, factory) {
|
|
7
|
-
if (typeof define === 'function' && define.amd) {
|
|
8
|
-
define(['exports', 'module'], factory);
|
|
9
|
-
} else if (typeof exports !== 'undefined' && typeof module !== 'undefined') {
|
|
10
|
-
factory(exports, module);
|
|
11
|
-
} else {
|
|
12
|
-
var mod = {
|
|
13
|
-
exports: {}
|
|
14
|
-
};
|
|
15
|
-
factory(mod.exports, mod);
|
|
16
|
-
global.autosize = mod.exports;
|
|
17
|
-
}
|
|
18
|
-
})(this, function (exports, module) {
|
|
19
|
-
'use strict';
|
|
20
|
-
|
|
21
|
-
var map = typeof Map === "function" ? new Map() : (function () {
|
|
22
|
-
var keys = [];
|
|
23
|
-
var values = [];
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
has: function has(key) {
|
|
27
|
-
return keys.indexOf(key) > -1;
|
|
28
|
-
},
|
|
29
|
-
get: function get(key) {
|
|
30
|
-
return values[keys.indexOf(key)];
|
|
31
|
-
},
|
|
32
|
-
set: function set(key, value) {
|
|
33
|
-
if (keys.indexOf(key) === -1) {
|
|
34
|
-
keys.push(key);
|
|
35
|
-
values.push(value);
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
'delete': function _delete(key) {
|
|
39
|
-
var index = keys.indexOf(key);
|
|
40
|
-
if (index > -1) {
|
|
41
|
-
keys.splice(index, 1);
|
|
42
|
-
values.splice(index, 1);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
})();
|
|
47
|
-
|
|
48
|
-
var createEvent = function createEvent(name) {
|
|
49
|
-
return new Event(name, { bubbles: true });
|
|
50
|
-
};
|
|
51
|
-
try {
|
|
52
|
-
new Event('test');
|
|
53
|
-
} catch (e) {
|
|
54
|
-
// IE does not support `new Event()`
|
|
55
|
-
createEvent = function (name) {
|
|
56
|
-
var evt = document.createEvent('Event');
|
|
57
|
-
evt.initEvent(name, true, false);
|
|
58
|
-
return evt;
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function assign(ta) {
|
|
63
|
-
if (!ta || !ta.nodeName || ta.nodeName !== 'TEXTAREA' || map.has(ta)) return;
|
|
64
|
-
|
|
65
|
-
var heightOffset = null;
|
|
66
|
-
var clientWidth = ta.clientWidth;
|
|
67
|
-
var cachedHeight = null;
|
|
68
|
-
|
|
69
|
-
function init() {
|
|
70
|
-
var style = window.getComputedStyle(ta, null);
|
|
71
|
-
|
|
72
|
-
if (style.resize === 'vertical') {
|
|
73
|
-
ta.style.resize = 'none';
|
|
74
|
-
} else if (style.resize === 'both') {
|
|
75
|
-
ta.style.resize = 'horizontal';
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (style.boxSizing === 'content-box') {
|
|
79
|
-
heightOffset = -(parseFloat(style.paddingTop) + parseFloat(style.paddingBottom));
|
|
80
|
-
} else {
|
|
81
|
-
heightOffset = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
|
|
82
|
-
}
|
|
83
|
-
// Fix when a textarea is not on document body and heightOffset is Not a Number
|
|
84
|
-
if (isNaN(heightOffset)) {
|
|
85
|
-
heightOffset = 0;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
update();
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function changeOverflow(value) {
|
|
92
|
-
{
|
|
93
|
-
// Chrome/Safari-specific fix:
|
|
94
|
-
// When the textarea y-overflow is hidden, Chrome/Safari do not reflow the text to account for the space
|
|
95
|
-
// made available by removing the scrollbar. The following forces the necessary text reflow.
|
|
96
|
-
var width = ta.style.width;
|
|
97
|
-
ta.style.width = '0px';
|
|
98
|
-
// Force reflow:
|
|
99
|
-
/* jshint ignore:start */
|
|
100
|
-
ta.offsetWidth;
|
|
101
|
-
/* jshint ignore:end */
|
|
102
|
-
ta.style.width = width;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
ta.style.overflowY = value;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function getParentOverflows(el) {
|
|
109
|
-
var arr = [];
|
|
110
|
-
|
|
111
|
-
while (el && el.parentNode && el.parentNode instanceof Element) {
|
|
112
|
-
if (el.parentNode.scrollTop) {
|
|
113
|
-
arr.push({
|
|
114
|
-
node: el.parentNode,
|
|
115
|
-
scrollTop: el.parentNode.scrollTop
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
el = el.parentNode;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return arr;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function resize() {
|
|
125
|
-
var originalHeight = ta.style.height;
|
|
126
|
-
var overflows = getParentOverflows(ta);
|
|
127
|
-
var docTop = document.documentElement && document.documentElement.scrollTop; // Needed for Mobile IE (ticket #240)
|
|
128
|
-
|
|
129
|
-
ta.style.height = 'auto';
|
|
130
|
-
|
|
131
|
-
var endHeight = ta.scrollHeight + heightOffset;
|
|
132
|
-
|
|
133
|
-
if (ta.scrollHeight === 0) {
|
|
134
|
-
// If the scrollHeight is 0, then the element probably has display:none or is detached from the DOM.
|
|
135
|
-
ta.style.height = originalHeight;
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
ta.style.height = endHeight + 'px';
|
|
140
|
-
|
|
141
|
-
// used to check if an update is actually necessary on window.resize
|
|
142
|
-
clientWidth = ta.clientWidth;
|
|
143
|
-
|
|
144
|
-
// prevents scroll-position jumping
|
|
145
|
-
overflows.forEach(function (el) {
|
|
146
|
-
el.node.scrollTop = el.scrollTop;
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
if (docTop) {
|
|
150
|
-
document.documentElement.scrollTop = docTop;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function update() {
|
|
155
|
-
resize();
|
|
156
|
-
|
|
157
|
-
var styleHeight = Math.round(parseFloat(ta.style.height));
|
|
158
|
-
var computed = window.getComputedStyle(ta, null);
|
|
159
|
-
var actualHeight = Math.round(parseFloat(computed.height));
|
|
160
|
-
|
|
161
|
-
// The actual height not matching the style height (set via the resize method) indicates that
|
|
162
|
-
// the max-height has been exceeded, in which case the overflow should be set to visible.
|
|
163
|
-
if (actualHeight !== styleHeight) {
|
|
164
|
-
if (computed.overflowY !== 'visible') {
|
|
165
|
-
changeOverflow('visible');
|
|
166
|
-
resize();
|
|
167
|
-
actualHeight = Math.round(parseFloat(window.getComputedStyle(ta, null).height));
|
|
168
|
-
}
|
|
169
|
-
} else {
|
|
170
|
-
// Normally keep overflow set to hidden, to avoid flash of scrollbar as the textarea expands.
|
|
171
|
-
if (computed.overflowY !== 'hidden') {
|
|
172
|
-
changeOverflow('hidden');
|
|
173
|
-
resize();
|
|
174
|
-
actualHeight = Math.round(parseFloat(window.getComputedStyle(ta, null).height));
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (cachedHeight !== actualHeight) {
|
|
179
|
-
cachedHeight = actualHeight;
|
|
180
|
-
var evt = createEvent('autosize:resized');
|
|
181
|
-
try {
|
|
182
|
-
ta.dispatchEvent(evt);
|
|
183
|
-
} catch (err) {
|
|
184
|
-
// Firefox will throw an error on dispatchEvent for a detached element
|
|
185
|
-
// https://bugzilla.mozilla.org/show_bug.cgi?id=889376
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
var pageResize = function pageResize() {
|
|
191
|
-
if (ta.clientWidth !== clientWidth) {
|
|
192
|
-
update();
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
var destroy = (function (style) {
|
|
197
|
-
window.removeEventListener('resize', pageResize, false);
|
|
198
|
-
ta.removeEventListener('input', update, false);
|
|
199
|
-
ta.removeEventListener('keyup', update, false);
|
|
200
|
-
ta.removeEventListener('autosize:destroy', destroy, false);
|
|
201
|
-
ta.removeEventListener('autosize:update', update, false);
|
|
202
|
-
|
|
203
|
-
Object.keys(style).forEach(function (key) {
|
|
204
|
-
ta.style[key] = style[key];
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
map['delete'](ta);
|
|
208
|
-
}).bind(ta, {
|
|
209
|
-
height: ta.style.height,
|
|
210
|
-
resize: ta.style.resize,
|
|
211
|
-
overflowY: ta.style.overflowY,
|
|
212
|
-
overflowX: ta.style.overflowX,
|
|
213
|
-
wordWrap: ta.style.wordWrap
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
ta.addEventListener('autosize:destroy', destroy, false);
|
|
217
|
-
|
|
218
|
-
// IE9 does not fire onpropertychange or oninput for deletions,
|
|
219
|
-
// so binding to onkeyup to catch most of those events.
|
|
220
|
-
// There is no way that I know of to detect something like 'cut' in IE9.
|
|
221
|
-
if ('onpropertychange' in ta && 'oninput' in ta) {
|
|
222
|
-
ta.addEventListener('keyup', update, false);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
window.addEventListener('resize', pageResize, false);
|
|
226
|
-
ta.addEventListener('input', update, false);
|
|
227
|
-
ta.addEventListener('autosize:update', update, false);
|
|
228
|
-
ta.style.overflowX = 'hidden';
|
|
229
|
-
ta.style.wordWrap = 'break-word';
|
|
230
|
-
|
|
231
|
-
map.set(ta, {
|
|
232
|
-
destroy: destroy,
|
|
233
|
-
update: update
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
init();
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
function destroy(ta) {
|
|
240
|
-
var methods = map.get(ta);
|
|
241
|
-
if (methods) {
|
|
242
|
-
methods.destroy();
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
function update(ta) {
|
|
247
|
-
var methods = map.get(ta);
|
|
248
|
-
if (methods) {
|
|
249
|
-
methods.update();
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
var autosize = null;
|
|
254
|
-
|
|
255
|
-
// Do nothing in Node.js environment and IE8 (or lower)
|
|
256
|
-
if (typeof window === 'undefined' || typeof window.getComputedStyle !== 'function') {
|
|
257
|
-
autosize = function (el) {
|
|
258
|
-
return el;
|
|
259
|
-
};
|
|
260
|
-
autosize.destroy = function (el) {
|
|
261
|
-
return el;
|
|
262
|
-
};
|
|
263
|
-
autosize.update = function (el) {
|
|
264
|
-
return el;
|
|
265
|
-
};
|
|
266
|
-
} else {
|
|
267
|
-
autosize = function (el, options) {
|
|
268
|
-
if (el) {
|
|
269
|
-
Array.prototype.forEach.call(el.length ? el : [el], function (x) {
|
|
270
|
-
return assign(x, options);
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
return el;
|
|
274
|
-
};
|
|
275
|
-
autosize.destroy = function (el) {
|
|
276
|
-
if (el) {
|
|
277
|
-
Array.prototype.forEach.call(el.length ? el : [el], destroy);
|
|
278
|
-
}
|
|
279
|
-
return el;
|
|
280
|
-
};
|
|
281
|
-
autosize.update = function (el) {
|
|
282
|
-
if (el) {
|
|
283
|
-
Array.prototype.forEach.call(el.length ? el : [el], update);
|
|
284
|
-
}
|
|
285
|
-
return el;
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
module.exports = autosize;
|
|
290
|
-
});
|
|
File without changes
|