wagn 1.19.0 → 1.19.1
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/features/attach.feature +2 -2
- data/features/step_definitions/wagn_steps.rb +1 -1
- data/lib/wagn/application.rb +4 -1
- data/lib/wagn/commands.rb +2 -1
- data/lib/wagn/generators/wagn/templates/Gemfile +4 -2
- data/lib/wagn/generators/wagn/templates/config/application.rb +27 -0
- data/lib/wagn/tasks/wagn.rake +9 -23
- data/rails/engine-routes.rb +2 -2
- metadata +5 -10
- data/app/assets/javascripts/application.js +0 -25
- data/app/assets/javascripts/jquery.autosize.js +0 -254
- data/app/assets/javascripts/jquery.fileupload.js +0 -1111
- data/app/assets/javascripts/jquery.iframe-transport.js +0 -156
- data/app/assets/javascripts/jquery.ui.autocomplete.html.js +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14f55b768309e605aca4a4f0c764fd1b55576648
|
4
|
+
data.tar.gz: 5c3a73ba0701952db18eda8cf23957f0b609f937
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7eebe084324ca959722a74a31bc8ee0fd9001a1edc616a9191d26912c0a5f0c4a8fa9bb936df526a5fe88ce44ab0fc559e2636bce62b3714d6d2de4fb9b34d7f
|
7
|
+
data.tar.gz: a44126e1377445612b1a1a5037a0fd76f07b71c2df9275820b5e8fc2069bebdb93194536e52da452d97479b98cb6f4e2cbcb67b146b7c3645c7ff9885da3e412
|
data/features/attach.feature
CHANGED
@@ -42,14 +42,14 @@ Feature: File Upload
|
|
42
42
|
Then I should see an image of size "large" and type "jpg"
|
43
43
|
And I wait until ajax response done
|
44
44
|
|
45
|
-
Scenario: Changing a
|
45
|
+
Scenario: Changing a coded image
|
46
46
|
When I edit "*logo"
|
47
47
|
And I upload the image "image2.jpg"
|
48
48
|
And I wait until ajax response done
|
49
49
|
Then I should see "image2.jpg 69.8 KB"
|
50
50
|
And I press "Submit"
|
51
51
|
And I wait until ajax response done
|
52
|
-
Then I should see a non-
|
52
|
+
Then I should see a non-coded image of size "large" and type "jpg"
|
53
53
|
|
54
54
|
Scenario: uploading a file as a field in a form
|
55
55
|
When I go to "/new Cardtype"
|
@@ -384,7 +384,7 @@ Then img_sld do |selector, size, type|
|
|
384
384
|
end
|
385
385
|
end
|
386
386
|
|
387
|
-
img_should = /^I should see a non-
|
387
|
+
img_should = /^I should see a non-coded image of size "(.+)" and type "(.+)"$/
|
388
388
|
Then img_should do |size, type|
|
389
389
|
element = find("img[src*='#{size}.#{type}']")
|
390
390
|
expect(element[:src]).to match(%r{/~\d+/})
|
data/lib/wagn/application.rb
CHANGED
@@ -76,7 +76,10 @@ module Wagn
|
|
76
76
|
paths["app/models"] = []
|
77
77
|
paths["app/mailers"] = []
|
78
78
|
|
79
|
-
|
79
|
+
unless paths["config/routes.rb"].existent.present?
|
80
|
+
add_path paths, "config/routes.rb",
|
81
|
+
with: "rails/application-routes.rb"
|
82
|
+
end
|
80
83
|
|
81
84
|
Cardio.set_mod_paths # really this should happen later
|
82
85
|
|
data/lib/wagn/commands.rb
CHANGED
@@ -90,7 +90,8 @@ else
|
|
90
90
|
|
91
91
|
rspec_command =
|
92
92
|
"RAILS_ROOT=. #{opts[:simplecov]} #{opts[:executer]} " \
|
93
|
-
" #{opts[:rescue]} rspec #{rspec_args.shelljoin} #{opts[:files]}"
|
93
|
+
" #{opts[:rescue]} rspec #{rspec_args.shelljoin} #{opts[:files]} "\
|
94
|
+
" --exclude-pattern \"./card/vendor/**/*\""
|
94
95
|
exit_with_child_status rspec_command
|
95
96
|
when "--version", "-v"
|
96
97
|
puts "Wagn #{Card::Version.release}"
|
@@ -18,8 +18,8 @@ gem '<%= database_gemfile_entry.name %>'<%= %(, '#{database_gemfile_entry.versio
|
|
18
18
|
# To activate it you have to set config.active_job.queue_adapter to :delayed_job
|
19
19
|
# in your config file and start the background process with
|
20
20
|
# RAILS_ENV=production script/delayed_job start
|
21
|
-
gem 'delayed_job_active_record', '~> 4.1'
|
22
|
-
gem 'daemons'
|
21
|
+
# gem 'delayed_job_active_record', '~> 4.1'
|
22
|
+
# gem 'daemons'
|
23
23
|
|
24
24
|
|
25
25
|
<% if options['mod-dev'] || options['core-dev'] -%>
|
@@ -71,6 +71,8 @@ group :assets do
|
|
71
71
|
end
|
72
72
|
|
73
73
|
group :test do
|
74
|
+
gem 'fog'
|
75
|
+
gem 'fog-aws'
|
74
76
|
gem 'rspec-html-matchers'
|
75
77
|
gem 'rr' #, '=1.0.0'
|
76
78
|
gem 'simplecov', '~> 0.7.1', :require => false #test coverage
|
@@ -46,6 +46,33 @@ module <%= app_const_base %>
|
|
46
46
|
# config.paths['files'] = 'files'
|
47
47
|
# where uploaded files are actually stored. (eg Image and File cards)
|
48
48
|
|
49
|
+
# config.file_storage = :local
|
50
|
+
# File storage options (see http://wagn.org/file_storage_options)
|
51
|
+
# options include: local, cloud, web, coded
|
52
|
+
# defaults to local
|
53
|
+
# For cloud storage use the following config options and add the gems
|
54
|
+
# "fog" and "fog-aws" to your Gemfile.
|
55
|
+
# config.file_default_bucket = :my_bucket
|
56
|
+
# config.file_buckets = {
|
57
|
+
# my_bucket: {
|
58
|
+
# provider: "fog/aws",
|
59
|
+
# directory: "bucket-name",
|
60
|
+
# subdirectory: "files",
|
61
|
+
# credentials: {
|
62
|
+
# provider: 'AWS', # required
|
63
|
+
# aws_access_key_id: 'key', # required
|
64
|
+
# aws_secret_access_key: 'secret-key', # required
|
65
|
+
# region: 'eu-central-1', # optional, defaults to 'us-east-1'
|
66
|
+
# host: 's3.example.com', # optional, defaults to nil
|
67
|
+
# endpoint: 'https://s3.example.com:8080' # optional, defaults to nil
|
68
|
+
# },
|
69
|
+
# attributes: { "Cache-Control" => "max-age=#{365.day.to_i}" },
|
70
|
+
# public: true,
|
71
|
+
# authenticated_url_expiration: 180 # if public is set to false this
|
72
|
+
# # option is needed
|
73
|
+
# }
|
74
|
+
# }
|
75
|
+
|
49
76
|
# config.paths['mod'] << 'my-mod-dir'
|
50
77
|
# add a new directory for code customizations, or "mods"
|
51
78
|
|
data/lib/wagn/tasks/wagn.rake
CHANGED
@@ -50,7 +50,7 @@ namespace :wagn do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
desc "clear and load fixtures with existing tables"
|
53
|
-
task :
|
53
|
+
task reseed: :environment do
|
54
54
|
ENV["SCHEMA"] ||= "#{Cardio.gem_root}/db/schema.rb"
|
55
55
|
|
56
56
|
Rake::Task["wagn:clear"].invoke
|
@@ -255,6 +255,9 @@ namespace :wagn do
|
|
255
255
|
|
256
256
|
# FIXME: temporarily taking this out!!
|
257
257
|
Rake::Task["wagn:bootstrap:copy_mod_files"].invoke
|
258
|
+
Card[:all, :script].make_machine_output_coded
|
259
|
+
Card[:all, :style].make_machine_output_coded
|
260
|
+
Card[:script_html5shiv_printshiv].make_machine_output_coded
|
258
261
|
|
259
262
|
YAML::ENGINE.yamler = "syck" if RUBY_VERSION !~ /^(2|1\.9)/
|
260
263
|
# use old engine while we're supporting ruby 1.8.7 because it can't
|
@@ -287,7 +290,7 @@ namespace :wagn do
|
|
287
290
|
# mark mod files as mod files
|
288
291
|
Card::Auth.as_bot do
|
289
292
|
Card.search(type: %w(in Image File), ne: "").each do |card|
|
290
|
-
if card.
|
293
|
+
if card.coded? || card.codename == "new_file" ||
|
291
294
|
card.codename == "new_image"
|
292
295
|
puts "skipping #{card.name}: already in code"
|
293
296
|
next
|
@@ -295,31 +298,15 @@ namespace :wagn do
|
|
295
298
|
puts "working on #{card.name}"
|
296
299
|
end
|
297
300
|
|
298
|
-
raise "need codename for file" unless card.codename.present?
|
299
|
-
|
300
|
-
files = { original: card.attachment.path }
|
301
|
-
card.attachment.versions.each_key do |version|
|
302
|
-
files[version] = card.attachment.path(version)
|
303
|
-
end
|
304
|
-
|
305
301
|
# make card a mod file card
|
306
302
|
mod_name = if (l = card.left) && l.type_id == Card::SkinID
|
307
303
|
"bootstrap"
|
308
304
|
else
|
309
305
|
"standard"
|
310
306
|
end
|
311
|
-
card.
|
312
|
-
|
313
|
-
|
314
|
-
.update_column :value, card.attachment.db_content(mod: mod_name)
|
315
|
-
card.expire
|
316
|
-
card = Card.fetch card.name
|
317
|
-
|
318
|
-
target_dir = card.store_dir
|
319
|
-
|
320
|
-
files.each do |version, path|
|
321
|
-
FileUtils.cp path, card.attachment.path(version)
|
322
|
-
end
|
307
|
+
card.update_attributes! storage_type: :coded,
|
308
|
+
mod: mod_name,
|
309
|
+
empty_ok: true
|
323
310
|
end
|
324
311
|
end
|
325
312
|
end
|
@@ -329,8 +316,7 @@ namespace :wagn do
|
|
329
316
|
# FIXME: shouldn't we be more standard and use seed.rb for this code?
|
330
317
|
Rake.application.options.trace = true
|
331
318
|
puts "bootstrap load starting #{WAGN_SEED_PATH}"
|
332
|
-
|
333
|
-
ActiveRecord::FixtureSet.create_fixtures WAGN_SEED_PATH, WAGN_SEED_TABLES
|
319
|
+
Rake::Task["db:seed"].invoke
|
334
320
|
end
|
335
321
|
end
|
336
322
|
end
|
data/rails/engine-routes.rb
CHANGED
@@ -36,8 +36,8 @@ Decko::Engine.routes.draw do
|
|
36
36
|
get "account/accept" => "card#read", view: "edit", card: { type_code: :signup }
|
37
37
|
# use type_code rather than id because in some cases (eg populating test data) routes must get loaded without loading Card
|
38
38
|
|
39
|
-
get "admin/stats" => "card#read", id: ":
|
40
|
-
get "admin/:task" => "card#update", id: ":
|
39
|
+
get "admin/stats" => "card#read", id: ":admin"
|
40
|
+
get "admin/:task" => "card#update", id: ":admin"
|
41
41
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
42
42
|
|
43
43
|
# standard non-RESTful
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wagn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.19.
|
4
|
+
version: 1.19.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ethan McCutchen
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2016-08
|
14
|
+
date: 2016-09-08 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -33,14 +33,14 @@ dependencies:
|
|
33
33
|
requirements:
|
34
34
|
- - '='
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 1.19.
|
36
|
+
version: 1.19.1
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - '='
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 1.19.
|
43
|
+
version: 1.19.1
|
44
44
|
description: a wiki approach to stuctured data, dynamic interaction, and web design
|
45
45
|
email:
|
46
46
|
- info@wagn.org
|
@@ -71,11 +71,6 @@ files:
|
|
71
71
|
- app/assets/images/smoothness/ui-icons_454545_256x240.png
|
72
72
|
- app/assets/images/smoothness/ui-icons_888888_256x240.png
|
73
73
|
- app/assets/images/smoothness/ui-icons_cd0a0a_256x240.png
|
74
|
-
- app/assets/javascripts/application.js
|
75
|
-
- app/assets/javascripts/jquery.autosize.js
|
76
|
-
- app/assets/javascripts/jquery.fileupload.js
|
77
|
-
- app/assets/javascripts/jquery.iframe-transport.js
|
78
|
-
- app/assets/javascripts/jquery.ui.autocomplete.html.js
|
79
74
|
- bin/wagn
|
80
75
|
- features/attach.feature
|
81
76
|
- features/autonaming.feature
|
@@ -759,7 +754,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
759
754
|
version: '0'
|
760
755
|
requirements: []
|
761
756
|
rubyforge_project:
|
762
|
-
rubygems_version: 2.
|
757
|
+
rubygems_version: 2.6.6
|
763
758
|
signing_key:
|
764
759
|
specification_version: 4
|
765
760
|
summary: structured wiki web platform
|
@@ -1,25 +0,0 @@
|
|
1
|
-
// This is a manifest file that'll be compiled into including all the files listed below.
|
2
|
-
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
3
|
-
// be included in the compiled file accessible from http://example.com/assets/application.js
|
4
|
-
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
|
-
// the compiled file.
|
6
|
-
//
|
7
|
-
//= require jquery
|
8
|
-
//= require tinymce
|
9
|
-
|
10
|
-
//= !require jquery.mobile
|
11
|
-
/* jquery.mobile must be after wagn to avoid mobileinit nastiness */
|
12
|
-
//= require jquery.ui.all
|
13
|
-
/* jquery.ui.all must be after jquery.mobile to override dialog weirdness */
|
14
|
-
//= require jquery.ui.autocomplete.html.js
|
15
|
-
/* this autocomplete must be after jquery.ui stuff */
|
16
|
-
//= require jquery.autosize
|
17
|
-
//= require jquery.fileupload.js
|
18
|
-
//= require jquery.iframe-transport.js
|
19
|
-
//= require jquery_ujs
|
20
|
-
|
21
|
-
/*
|
22
|
-
Note: I attempted to get tinymce up with tinymce-jquery,
|
23
|
-
but it overrode val() in ways that broke our filed updating / autosave
|
24
|
-
*/
|
25
|
-
|
@@ -1,254 +0,0 @@
|
|
1
|
-
/*!
|
2
|
-
Autosize v1.17.7 - 2013-09-03
|
3
|
-
Automatically adjust textarea height based on user input.
|
4
|
-
(c) 2013 Jack Moore - http://www.jacklmoore.com/autosize
|
5
|
-
license: http://www.opensource.org/licenses/mit-license.php
|
6
|
-
*/
|
7
|
-
(function (factory) {
|
8
|
-
if (typeof define === 'function' && define.amd) {
|
9
|
-
// AMD. Register as an anonymous module.
|
10
|
-
define(['jquery'], factory);
|
11
|
-
} else {
|
12
|
-
// Browser globals: jQuery or jQuery-like library, such as Zepto
|
13
|
-
factory(window.jQuery || window.$);
|
14
|
-
}
|
15
|
-
}(function ($) {
|
16
|
-
var
|
17
|
-
defaults = {
|
18
|
-
className: 'autosizejs',
|
19
|
-
append: '',
|
20
|
-
callback: false,
|
21
|
-
resizeDelay: 10
|
22
|
-
},
|
23
|
-
|
24
|
-
// border:0 is unnecessary, but avoids a bug in FireFox on OSX
|
25
|
-
copy = '<textarea tabindex="-1" style="position:absolute; top:-999px; left:0; right:auto; bottom:auto; border:0; padding: 0; -moz-box-sizing:content-box; -webkit-box-sizing:content-box; box-sizing:content-box; word-wrap:break-word; height:0 !important; min-height:0 !important; overflow:hidden; transition:none; -webkit-transition:none; -moz-transition:none;"/>',
|
26
|
-
|
27
|
-
// line-height is conditionally included because IE7/IE8/old Opera do not return the correct value.
|
28
|
-
typographyStyles = [
|
29
|
-
'fontFamily',
|
30
|
-
'fontSize',
|
31
|
-
'fontWeight',
|
32
|
-
'fontStyle',
|
33
|
-
'letterSpacing',
|
34
|
-
'textTransform',
|
35
|
-
'wordSpacing',
|
36
|
-
'textIndent'
|
37
|
-
],
|
38
|
-
|
39
|
-
// to keep track which textarea is being mirrored when adjust() is called.
|
40
|
-
mirrored,
|
41
|
-
|
42
|
-
// the mirror element, which is used to calculate what size the mirrored element should be.
|
43
|
-
mirror = $(copy).data('autosize', true)[0];
|
44
|
-
|
45
|
-
// test that line-height can be accurately copied.
|
46
|
-
mirror.style.lineHeight = '99px';
|
47
|
-
if ($(mirror).css('lineHeight') === '99px') {
|
48
|
-
typographyStyles.push('lineHeight');
|
49
|
-
}
|
50
|
-
mirror.style.lineHeight = '';
|
51
|
-
|
52
|
-
$.fn.autosize = function (options) {
|
53
|
-
options = $.extend({}, defaults, options || {});
|
54
|
-
|
55
|
-
if (mirror.parentNode !== document.body) {
|
56
|
-
$(document.body).append(mirror);
|
57
|
-
}
|
58
|
-
|
59
|
-
return this.each(function () {
|
60
|
-
var
|
61
|
-
ta = this,
|
62
|
-
$ta = $(ta),
|
63
|
-
maxHeight,
|
64
|
-
minHeight,
|
65
|
-
boxOffset = 0,
|
66
|
-
callback = $.isFunction(options.callback),
|
67
|
-
originalStyles = {
|
68
|
-
height: ta.style.height,
|
69
|
-
overflow: ta.style.overflow,
|
70
|
-
overflowY: ta.style.overflowY,
|
71
|
-
wordWrap: ta.style.wordWrap,
|
72
|
-
resize: ta.style.resize
|
73
|
-
},
|
74
|
-
timeout,
|
75
|
-
width = $ta.width();
|
76
|
-
|
77
|
-
if ($ta.data('autosize')) {
|
78
|
-
// exit if autosize has already been applied, or if the textarea is the mirror element.
|
79
|
-
return;
|
80
|
-
}
|
81
|
-
$ta.data('autosize', true);
|
82
|
-
|
83
|
-
if ($ta.css('box-sizing') === 'border-box' || $ta.css('-moz-box-sizing') === 'border-box' || $ta.css('-webkit-box-sizing') === 'border-box'){
|
84
|
-
boxOffset = $ta.outerHeight() - $ta.height();
|
85
|
-
}
|
86
|
-
|
87
|
-
// IE8 and lower return 'auto', which parses to NaN, if no min-height is set.
|
88
|
-
minHeight = Math.max(parseInt($ta.css('minHeight'), 10) - boxOffset || 0, $ta.height());
|
89
|
-
|
90
|
-
$ta.css({
|
91
|
-
overflow: 'hidden',
|
92
|
-
overflowY: 'hidden',
|
93
|
-
wordWrap: 'break-word', // horizontal overflow is hidden, so break-word is necessary for handling words longer than the textarea width
|
94
|
-
resize: ($ta.css('resize') === 'none' || $ta.css('resize') === 'vertical') ? 'none' : 'horizontal'
|
95
|
-
});
|
96
|
-
|
97
|
-
// The mirror width must exactly match the textarea width, so using getBoundingClientRect because it doesn't round the sub-pixel value.
|
98
|
-
function setWidth() {
|
99
|
-
var style, width;
|
100
|
-
|
101
|
-
if ('getComputedStyle' in window) {
|
102
|
-
style = window.getComputedStyle(ta);
|
103
|
-
width = ta.getBoundingClientRect().width;
|
104
|
-
|
105
|
-
$.each(['paddingLeft', 'paddingRight', 'borderLeftWidth', 'borderRightWidth'], function(i,val){
|
106
|
-
width -= parseInt(style[val],10);
|
107
|
-
});
|
108
|
-
|
109
|
-
mirror.style.width = width + 'px';
|
110
|
-
}
|
111
|
-
else {
|
112
|
-
// window.getComputedStyle, getBoundingClientRect returning a width are unsupported and unneeded in IE8 and lower.
|
113
|
-
mirror.style.width = Math.max($ta.width(), 0) + 'px';
|
114
|
-
}
|
115
|
-
}
|
116
|
-
|
117
|
-
function initMirror() {
|
118
|
-
var styles = {};
|
119
|
-
|
120
|
-
mirrored = ta;
|
121
|
-
mirror.className = options.className;
|
122
|
-
maxHeight = parseInt($ta.css('maxHeight'), 10);
|
123
|
-
|
124
|
-
// mirror is a duplicate textarea located off-screen that
|
125
|
-
// is automatically updated to contain the same text as the
|
126
|
-
// original textarea. mirror always has a height of 0.
|
127
|
-
// This gives a cross-browser supported way getting the actual
|
128
|
-
// height of the text, through the scrollTop property.
|
129
|
-
$.each(typographyStyles, function(i,val){
|
130
|
-
styles[val] = $ta.css(val);
|
131
|
-
});
|
132
|
-
$(mirror).css(styles);
|
133
|
-
|
134
|
-
setWidth();
|
135
|
-
|
136
|
-
// Chrome-specific fix:
|
137
|
-
// When the textarea y-overflow is hidden, Chrome doesn't reflow the text to account for the space
|
138
|
-
// made available by removing the scrollbar. This workaround triggers the reflow for Chrome.
|
139
|
-
if (window.chrome) {
|
140
|
-
var width = ta.style.width;
|
141
|
-
ta.style.width = '0px';
|
142
|
-
var ignore = ta.offsetWidth;
|
143
|
-
ta.style.width = width;
|
144
|
-
}
|
145
|
-
}
|
146
|
-
|
147
|
-
// Using mainly bare JS in this function because it is going
|
148
|
-
// to fire very often while typing, and needs to very efficient.
|
149
|
-
function adjust() {
|
150
|
-
var height, original;
|
151
|
-
|
152
|
-
if (mirrored !== ta) {
|
153
|
-
initMirror();
|
154
|
-
} else {
|
155
|
-
setWidth();
|
156
|
-
}
|
157
|
-
|
158
|
-
mirror.value = ta.value + options.append;
|
159
|
-
mirror.style.overflowY = ta.style.overflowY;
|
160
|
-
original = parseInt(ta.style.height,10);
|
161
|
-
|
162
|
-
// Setting scrollTop to zero is needed in IE8 and lower for the next step to be accurately applied
|
163
|
-
mirror.scrollTop = 0;
|
164
|
-
|
165
|
-
mirror.scrollTop = 9e4;
|
166
|
-
|
167
|
-
// Using scrollTop rather than scrollHeight because scrollHeight is non-standard and includes padding.
|
168
|
-
height = mirror.scrollTop;
|
169
|
-
|
170
|
-
if (maxHeight && height > maxHeight) {
|
171
|
-
ta.style.overflowY = 'scroll';
|
172
|
-
height = maxHeight;
|
173
|
-
} else {
|
174
|
-
ta.style.overflowY = 'hidden';
|
175
|
-
if (height < minHeight) {
|
176
|
-
height = minHeight;
|
177
|
-
}
|
178
|
-
}
|
179
|
-
|
180
|
-
height += boxOffset;
|
181
|
-
|
182
|
-
if (original !== height) {
|
183
|
-
ta.style.height = height + 'px';
|
184
|
-
if (callback) {
|
185
|
-
options.callback.call(ta,ta);
|
186
|
-
}
|
187
|
-
}
|
188
|
-
}
|
189
|
-
|
190
|
-
function resize () {
|
191
|
-
clearTimeout(timeout);
|
192
|
-
timeout = setTimeout(function(){
|
193
|
-
var newWidth = $ta.width();
|
194
|
-
|
195
|
-
if (newWidth !== width) {
|
196
|
-
width = newWidth;
|
197
|
-
adjust();
|
198
|
-
}
|
199
|
-
}, parseInt(options.resizeDelay,10));
|
200
|
-
}
|
201
|
-
|
202
|
-
if ('onpropertychange' in ta) {
|
203
|
-
if ('oninput' in ta) {
|
204
|
-
// Detects IE9. IE9 does not fire onpropertychange or oninput for deletions,
|
205
|
-
// so binding to onkeyup to catch most of those occasions. There is no way that I
|
206
|
-
// know of to detect something like 'cut' in IE9.
|
207
|
-
$ta.on('input.autosize keyup.autosize', adjust);
|
208
|
-
} else {
|
209
|
-
// IE7 / IE8
|
210
|
-
$ta.on('propertychange.autosize', function(){
|
211
|
-
if(event.propertyName === 'value'){
|
212
|
-
adjust();
|
213
|
-
}
|
214
|
-
});
|
215
|
-
}
|
216
|
-
} else {
|
217
|
-
// Modern Browsers
|
218
|
-
$ta.on('input.autosize', adjust);
|
219
|
-
}
|
220
|
-
|
221
|
-
// Set options.resizeDelay to false if using fixed-width textarea elements.
|
222
|
-
// Uses a timeout and width check to reduce the amount of times adjust needs to be called after window resize.
|
223
|
-
|
224
|
-
if (options.resizeDelay !== false) {
|
225
|
-
$(window).on('resize.autosize', resize);
|
226
|
-
}
|
227
|
-
|
228
|
-
// Event for manual triggering if needed.
|
229
|
-
// Should only be needed when the value of the textarea is changed through JavaScript rather than user input.
|
230
|
-
$ta.on('autosize.resize', adjust);
|
231
|
-
|
232
|
-
// Event for manual triggering that also forces the styles to update as well.
|
233
|
-
// Should only be needed if one of typography styles of the textarea change, and the textarea is already the target of the adjust method.
|
234
|
-
$ta.on('autosize.resizeIncludeStyle', function() {
|
235
|
-
mirrored = null;
|
236
|
-
adjust();
|
237
|
-
});
|
238
|
-
|
239
|
-
$ta.on('autosize.destroy', function(){
|
240
|
-
mirrored = null;
|
241
|
-
clearTimeout(timeout);
|
242
|
-
$(window).off('resize', resize);
|
243
|
-
$ta
|
244
|
-
.off('autosize')
|
245
|
-
.off('.autosize')
|
246
|
-
.css(originalStyles)
|
247
|
-
.removeData('autosize');
|
248
|
-
});
|
249
|
-
|
250
|
-
// Call adjust in case the textarea already contains text.
|
251
|
-
adjust();
|
252
|
-
});
|
253
|
-
};
|
254
|
-
}));
|