diff --git a/Gemfile b/Gemfile
index 588f4b4c..5034947e 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,17 +1,17 @@
source 'https://rubygems.org'
-source 'https://rails-assets.org'
# Specify your gem's dependencies in best_in_place.gemspec
gemspec
-gem 'activerecord'
+gem "rails", github: "rails/rails"
gem 'rails-assets-jquery', '1.11.1'
gem 'rails-assets-jquery-ui', '1.10.4'
gem 'rdiscount'
gem 'rspec-rails'
gem 'nokogiri'
gem 'combustion'
-gem 'sprockets-rails'
+gem "sprockets", "~> 3"
+gem 'sprockets-rails', "~> 3"
gem 'capybara'
gem 'poltergeist'
gem 'sqlite3'
diff --git a/lib/best_in_place.rb b/lib/best_in_place.rb
index 76f94c34..8946dad9 100644
--- a/lib/best_in_place.rb
+++ b/lib/best_in_place.rb
@@ -3,6 +3,10 @@
require 'action_controller/railtie'
module BestInPlace
+ def self.deprecator
+ @deprecator ||= ActiveSupport::Deprecation.new("1.0", "BestInPlace")
+ end
+
def self.configure
@configuration ||= Configuration.new
yield @configuration if block_given?
@@ -30,4 +34,4 @@ def initialize
require 'best_in_place/helper'
require 'best_in_place/railtie'
require 'best_in_place/controller_extensions'
-require 'best_in_place/display_methods'
\ No newline at end of file
+require 'best_in_place/display_methods'
diff --git a/lib/best_in_place/display_methods.rb b/lib/best_in_place/display_methods.rb
index ad930fb5..4f55100e 100644
--- a/lib/best_in_place/display_methods.rb
+++ b/lib/best_in_place/display_methods.rb
@@ -30,15 +30,15 @@ def lookup(klass, attr)
end
def add_model_method(klass, attr, display_as)
- model_attributes(klass)[attr.to_s] = Renderer.new method: display_as.to_sym, type: :model
+ model_attributes(klass)[attr.to_s] = Renderer.new({ method: display_as.to_sym, type: :model })
end
def add_helper_method(klass, attr, helper_method, helper_options = nil)
- model_attributes(klass)[attr.to_s] = Renderer.new method: helper_method.to_sym, type: :helper, attr: attr, helper_options: helper_options
+ model_attributes(klass)[attr.to_s] = Renderer.new({ method: helper_method.to_sym, type: :helper, attr: attr, helper_options: helper_options })
end
def add_helper_proc(klass, attr, helper_proc)
- model_attributes(klass)[attr.to_s] = Renderer.new type: :proc, attr: attr, proc: helper_proc
+ model_attributes(klass)[attr.to_s] = Renderer.new({ type: :proc, attr: attr, proc: helper_proc })
end
def model_attributes(klass)
diff --git a/lib/best_in_place/engine.rb b/lib/best_in_place/engine.rb
index 1f1c5b5c..8a433538 100644
--- a/lib/best_in_place/engine.rb
+++ b/lib/best_in_place/engine.rb
@@ -1,8 +1,10 @@
module BestInPlace
class Engine < Rails::Engine
initializer 'best_in_place' do
- ActionView::Base.send(:include, BestInPlace::Helper)
- ActionController::Base.send(:include, BestInPlace::ControllerExtensions)
+ ActiveSupport.on_load(:action_controller) do
+ ActionView::Base.send(:include, BestInPlace::Helper)
+ ActionController::Base.send(:include, BestInPlace::ControllerExtensions)
+ end
end
end
end
diff --git a/lib/best_in_place/helper.rb b/lib/best_in_place/helper.rb
index e9be0795..f0e5baee 100644
--- a/lib/best_in_place/helper.rb
+++ b/lib/best_in_place/helper.rb
@@ -152,7 +152,7 @@ def best_in_place_deprecated_options(opts)
deprecations.each do |deprecation|
if deprecated_option = opts.delete(deprecation[:from])
opts[deprecation[:from]] = deprecated_option
- ActiveSupport::Deprecation.warn("[Best_in_place] :#{deprecation[:from]} is deprecated in favor of :#{deprecation[:to]} ")
+ BestInPlace.deprecator.warn("[Best_in_place] :#{deprecation[:from]} is deprecated in favor of :#{deprecation[:to]} ")
end
end
end
diff --git a/lib/best_in_place/railtie.rb b/lib/best_in_place/railtie.rb
index f67e191b..23035623 100644
--- a/lib/best_in_place/railtie.rb
+++ b/lib/best_in_place/railtie.rb
@@ -4,7 +4,11 @@
module BestInPlace
class Railtie < ::Rails::Railtie #:nodoc:
config.after_initialize do
- BestInPlace::ViewHelpers = ActionView::Base.new
+ BestInPlace::ViewHelpers = ActionView::Base.respond_to?(:empty) ? ActionView::Base.empty : ActionView::Base.new
+ end
+
+ initializer "best_in_place.deprecator" do |app|
+ app.deprecators[:best_in_place] = BestInPlace.deprecator if app.respond_to?(:deprecators)
end
end
end
diff --git a/spec/helper_spec.rb b/spec/helper_spec.rb
index 6bdf76cc..3e9347de 100644
--- a/spec/helper_spec.rb
+++ b/spec/helper_spec.rb
@@ -32,7 +32,7 @@
end
it "should show deprecation warning" do
- expect(ActiveSupport::Deprecation).to receive(:warn).with("[Best_in_place] :path is deprecated in favor of :url ")
+ expect(BestInPlace.deprecator).to receive(:warn).with("[Best_in_place] :path is deprecated in favor of :url ")
helper.best_in_place @user, :name, path: "http://example.com"
end
diff --git a/vendor/assets/javascripts/jquery.autosize.js b/vendor/assets/javascripts/jquery.autosize.js
index 61c862af..4e966990 100755
--- a/vendor/assets/javascripts/jquery.autosize.js
+++ b/vendor/assets/javascripts/jquery.autosize.js
@@ -1,12 +1,11 @@
/*!
- 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
+ Autosize 1.18.18
+ license: MIT
+ http://www.jacklmoore.com/autosize
*/
(function ($) {
- 'use strict';
- var defaults = {
+ var
+ defaults = {
className: 'autosizejs',
id: 'autosizejs',
append: '\n',
@@ -15,9 +14,6 @@
placeholder: true
},
- // border:0 is unnecessary, but avoids a bug in Firefox on OSX
- copy = '',
-
// line-height is conditionally included because IE7/IE8/old Opera do not return the correct value.
typographyStyles = [
'fontFamily',
@@ -27,14 +23,18 @@
'letterSpacing',
'textTransform',
'wordSpacing',
- 'textIndent'
+ 'textIndent',
+ 'whiteSpace'
],
// to keep track which textarea is being mirrored when adjust() is called.
mirrored,
// the mirror element, which is used to calculate what size the mirrored element should be.
- mirror = $(copy).data('autosize', true)[0];
+ mirror = $('').data('autosize', true)[0];
+
+ // border:0 is unnecessary, but avoids a bug in Firefox on OSX
+ mirror.style.cssText = "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;";
// test that line-height can be accurately copied.
mirror.style.lineHeight = '99px';
@@ -84,7 +84,7 @@
}
// IE8 and lower return 'auto', which parses to NaN, if no min-height is set.
- minHeight = Math.max(parseInt($ta.css('minHeight'), 10) - boxOffset || 0, $ta.height());
+ minHeight = Math.max(parseFloat($ta.css('minHeight')) - boxOffset || 0, $ta.height());
$ta.css({
overflow: 'hidden',
@@ -98,23 +98,18 @@
$ta.css('resize', 'horizontal');
}
- // The mirror width must exactly match the textarea width, so using getBoundingClientRect because it doesn't round the sub-pixel value.
- // window.getComputedStyle, getBoundingClientRect returning a width are unsupported, but also unneeded in IE8 and lower.
+ // getComputedStyle is preferred here because it preserves sub-pixel values, while jQuery's .width() rounds to an integer.
function setWidth() {
var width;
- var style = window.getComputedStyle ? window.getComputedStyle(ta, null) : false;
-
- if (style) {
-
- width = ta.getBoundingClientRect().width;
+ var style = window.getComputedStyle ? window.getComputedStyle(ta, null) : null;
- if (width === 0 || typeof width !== 'number') {
- width = parseInt(style.width,10);
+ if (style) {
+ width = parseFloat(style.width);
+ if (style.boxSizing === 'border-box' || style.webkitBoxSizing === 'border-box' || style.mozBoxSizing === 'border-box') {
+ $.each(['paddingLeft', 'paddingRight', 'borderLeftWidth', 'borderRightWidth'], function(i,val){
+ width -= parseFloat(style[val]);
+ });
}
-
- $.each(['paddingLeft', 'paddingRight', 'borderLeftWidth', 'borderRightWidth'], function(i,val){
- width -= parseInt(style[val],10);
- });
} else {
width = $ta.width();
}
@@ -128,7 +123,7 @@
mirrored = ta;
mirror.className = options.className;
mirror.id = options.id;
- maxHeight = parseInt($ta.css('maxHeight'), 10);
+ maxHeight = parseFloat($ta.css('maxHeight'));
// mirror is a duplicate textarea located off-screen that
// is automatically updated to contain the same text as the
@@ -138,7 +133,7 @@
$.each(typographyStyles, function(i,val){
styles[val] = $ta.css(val);
});
-
+
$(mirror).css(styles).attr('wrap', $ta.attr('wrap'));
setWidth();
@@ -157,7 +152,7 @@
// Using mainly bare JS in this function because it is going
// to fire very often while typing, and needs to very efficient.
function adjust() {
- var height, original;
+ var height, originalHeight;
if (mirrored !== ta) {
initMirror();
@@ -166,16 +161,17 @@
}
if (!ta.value && options.placeholder) {
- // If the textarea is empty, copy the placeholder text into
- // the mirror control and use that for sizing so that we
+ // If the textarea is empty, copy the placeholder text into
+ // the mirror control and use that for sizing so that we
// don't end up with placeholder getting trimmed.
- mirror.value = ($ta.attr("placeholder") || '') + options.append;
+ mirror.value = ($ta.attr("placeholder") || '');
} else {
- mirror.value = ta.value + options.append;
+ mirror.value = ta.value;
}
+ mirror.value += options.append || '';
mirror.style.overflowY = ta.style.overflowY;
- original = parseInt(ta.style.height,10);
+ originalHeight = parseFloat(ta.style.height) || 0;
// Setting scrollTop to zero is needed in IE8 and lower for the next step to be accurately applied
mirror.scrollTop = 0;
@@ -197,11 +193,16 @@
height += boxOffset;
- if (original !== height) {
+ if (Math.abs(originalHeight - height) > 1/100) {
ta.style.height = height + 'px';
+
+ // Trigger a repaint for IE8 for when ta is nested 2 or more levels inside an inline-block
+ mirror.className = mirror.className;
+
if (callback) {
options.callback.call(ta,ta);
}
+ $ta.trigger('autosize.resized');
}
}
@@ -269,4 +270,4 @@
adjust();
});
};
-}(window.jQuery || window.$)); // jQuery or jQuery-like library, such as Zepto
+}(jQuery || $)); // jQuery or jQuery-like library, such as Zepto