Merge branch 'svbergerem-textarea-autosize' into develop

This commit is contained in:
Dennis Schubert 2016-02-07 05:39:12 +01:00
commit 26e37c46bd
10 changed files with 43 additions and 13 deletions

View file

@ -81,6 +81,7 @@ Contributions are very welcome, the hard work is done!
* Refactor mobile comment section [#6509](https://github.com/diaspora/diaspora/pull/6509) * Refactor mobile comment section [#6509](https://github.com/diaspora/diaspora/pull/6509)
* Set vertical resize as default for all textareas [#6654](https://github.com/diaspora/diaspora/pull/6654) * Set vertical resize as default for all textareas [#6654](https://github.com/diaspora/diaspora/pull/6654)
* Unifiy max-widths and page layouts [#6675](https://github.com/diaspora/diaspora/pull/6675) * Unifiy max-widths and page layouts [#6675](https://github.com/diaspora/diaspora/pull/6675)
* Enable autosizing for all textareas [6674](https://github.com/diaspora/diaspora/pull/6674)
## Bug fixes ## Bug fixes
* Destroy Participation when removing interactions with a post [#5852](https://github.com/diaspora/diaspora/pull/5852) * Destroy Participation when removing interactions with a post [#5852](https://github.com/diaspora/diaspora/pull/5852)

View file

@ -144,6 +144,9 @@ var app = {
// add placeholder support for old browsers // add placeholder support for old browsers
$("input, textarea").placeholder(); $("input, textarea").placeholder();
// init autosize plugin
autosize($("textarea"));
// setup remote forms // setup remote forms
$(document).on("ajax:success", "form[data-remote]", function() { $(document).on("ajax:success", "form[data-remote]", function() {
$(this).clearForm(); $(this).clearForm();

View file

@ -53,6 +53,9 @@ app.views.Base = Backbone.View.extend({
// add placeholder support for old browsers // add placeholder support for old browsers
this.$("input, textarea").placeholder(); this.$("input, textarea").placeholder();
// init autosize plugin
autosize(this.$("textarea"));
this.postRenderTemplate(); this.postRenderTemplate();
}, },

View file

@ -30,7 +30,7 @@ app.views.CommentStream = app.views.Base.extend({
// add autoexpanders to new comment textarea // add autoexpanders to new comment textarea
this.$("textarea").val(this.textareaValue); this.$("textarea").val(this.textareaValue);
autosize(this.$("textarea")); autosize.update(this.$("textarea"));
}, },
presenter: function(){ presenter: function(){

View file

@ -94,9 +94,6 @@ app.views.Publisher = Backbone.View.extend({
this.viewPollCreator.render(); this.viewPollCreator.render();
}); });
// init autosize plugin
autosize(this.inputEl);
this.initSubviews(); this.initSubviews();
this.checkSubmitAvailability(); this.checkSubmitAvailability();
return this; return this;

View file

@ -37,6 +37,9 @@ $(document).ready(function(){
.toggleClass('inactive'); .toggleClass('inactive');
}; };
// init autosize plugin
autosize($("textarea"));
/* Drawer menu */ /* Drawer menu */
$("#menu-badge").bind("tap click", function(evt){ $("#menu-badge").bind("tap click", function(evt){
evt.preventDefault(); evt.preventDefault();

View file

@ -38,6 +38,4 @@ $(document).ready(function(){
evt.preventDefault(); evt.preventDefault();
$("#new_status_message").submit(); $("#new_status_message").submit();
}); });
autosize($("#status_message_text"));
}); });

View file

@ -45,6 +45,13 @@ describe("app", function() {
expect($.fn.placeholder).toHaveBeenCalled(); expect($.fn.placeholder).toHaveBeenCalled();
expect($.fn.placeholder.calls.mostRecent().object.selector).toBe("input, textarea"); expect($.fn.placeholder.calls.mostRecent().object.selector).toBe("input, textarea");
}); });
it("initializes autosize for textareas", function(){
spyOn(window, "autosize");
app.setupForms();
expect(window.autosize).toHaveBeenCalled();
expect(window.autosize.calls.mostRecent().args[0].selector).toBe("textarea");
});
}); });
describe("setupAjaxErrorRedirect", function() { describe("setupAjaxErrorRedirect", function() {

View file

@ -15,10 +15,10 @@ describe("app.views.CommentStream", function(){
describe("postRenderTemplate", function(){ describe("postRenderTemplate", function(){
it("autoResizes the new comment textarea", function(){ it("autoResizes the new comment textarea", function(){
spyOn(window, "autosize"); spyOn(window.autosize, "update");
this.view.postRenderTemplate(); this.view.postRenderTemplate();
expect(window.autosize).toHaveBeenCalled(); expect(window.autosize.update).toHaveBeenCalled();
expect(window.autosize.calls.mostRecent().args[0].selector).toBe("textarea"); expect(window.autosize.update.calls.mostRecent().args[0].selector).toBe("textarea");
}); });
}); });

View file

@ -1,10 +1,12 @@
describe("app.views.Base", function(){ describe("app.views.Base", function(){
beforeEach(function(){
var StaticTemplateClass = app.views.Base.extend({ templateName : "static-text" });
this.model = new Backbone.Model({text : "model attributes are in the default presenter"});
this.view = new StaticTemplateClass({model: this.model});
});
describe("#render", function(){ describe("#render", function(){
beforeEach(function(){ beforeEach(function(){
var staticTemplateClass = app.views.Base.extend({ templateName : "static-text" });
this.model = new Backbone.Model({text : "model attributes are in the default presenter"});
this.view = new staticTemplateClass({model: this.model});
this.view.render(); this.view.render();
}); });
@ -85,4 +87,20 @@ describe("app.views.Base", function(){
}); });
}); });
}); });
describe("#renderTemplate", function(){
it("calls jQuery.placeholder() for inputs", function() {
spyOn($.fn, "placeholder");
this.view.renderTemplate();
expect($.fn.placeholder).toHaveBeenCalled();
expect($.fn.placeholder.calls.mostRecent().object.selector).toBe("input, textarea");
});
it("initializes autosize for textareas", function(){
spyOn(window, "autosize");
this.view.renderTemplate();
expect(window.autosize).toHaveBeenCalled();
expect(window.autosize.calls.mostRecent().args[0].selector).toBe("textarea");
});
});
}); });