Fix styleguide violations

Fix hound remark 12

Remove unnecessary explicit div tag

Rename el_**** to ****El (hound remark 2 and 3)

Only find and replace operations were done with
this commit

Fix hound remark 4 and 8

Fix hound remark 6

Fix hound remark 7

Fix hound remark 9

Fix hound remark 10 and 11

Fix hound remark 13

Fix hound remark 1

Change single quotes to double quotes

Change single quotes to double in publisher view

Fix camelCase and missing {} in publisher view

Change single quotes to double in bookmarklet view

Use dot notation for serializedForm in publisher

Change single quotes to double in bookmarklet spec

Change single quotes to double in publisher spec

Fix missing {} in publisher views

Use ruby 1.9 hash syntax in invite_link

Fix indentation in publisher view
This commit is contained in:
theworldbright 2015-06-03 13:21:23 +09:00 committed by Jonne Haß
parent a3725599ef
commit 98f11b944a
13 changed files with 279 additions and 270 deletions

View file

@ -60,11 +60,8 @@ Handlebars.registerHelper('sharingMessage', function(person) {
// allow hovercards for users that are not the current user.
// returns the html class name used to trigger hovercards.
Handlebars.registerHelper('hovercardable', function(person) {
if( app.currentUser.get('guid') !== person.guid ) {
return 'hovercardable';
}
return '';
Handlebars.registerHelper("hovercardable", function(person) {
return app.currentUser.get("guid") === person.guid ? "" : "hovercardable";
});
Handlebars.registerHelper('personImage', function(person, size, imageClass) {
@ -78,9 +75,10 @@ Handlebars.registerHelper('personImage', function(person, size, imageClass) {
size = ( !_.isString(size) ) ? "small" : size;
imageClass = ( !_.isString(imageClass) ) ? size : imageClass;
return _.template('<img src="<%= src %>" class="<%= img_class %>" title="<%= title %>" alt="<%= title %>" />')({
return _.template("<img src=\"<%= src %>\" class=\"<%= imageClass %>\" " +
"title=\"<%= title %>\" alt=\"<%= title %>\" />")({
src: avatar[size],
img_class: imageClass + " avatar img-responsive center-block",
imageClass: imageClass + " avatar img-responsive center-block",
title: _.escape(name)
});
});

View file

@ -12,8 +12,10 @@
app.views.AspectMembership = app.views.AspectsDropdown.extend({
events: {
"click ul.aspect_membership.dropdown-menu > li.aspect_selector": "_clickHandler",
"keypress ul.aspect_membership.dropdown-menu > li.aspect_selector": "_clickHandler"
"click ul.aspect_membership.dropdown-menu > li.aspect_selector"
: "_clickHandler",
"keypress ul.aspect_membership.dropdown-menu > li.aspect_selector"
: "_clickHandler"
},
initialize: function() {

View file

@ -7,9 +7,9 @@ app.views.Bookmarklet = Backbone.View.extend({
// init a standalone publisher
app.publisher = new app.views.Publisher({standalone: true});
app.publisher.on('publisher:add', this._postSubmit, this);
app.publisher.on('publisher:sync', this._postSuccess, this);
app.publisher.on('publisher:error', this._postError, this);
app.publisher.on("publisher:add", this._postSubmit, this);
app.publisher.on("publisher:sync", this._postSuccess, this);
app.publisher.on("publisher:error", this._postError, this);
this.param_contents = opts;
},
@ -35,18 +35,18 @@ app.views.Bookmarklet = Backbone.View.extend({
},
_postSubmit: function() {
this.$('h4').text(Diaspora.I18n.t('bookmarklet.post_submit'));
this.$("h4").text(Diaspora.I18n.t("bookmarklet.post_submit"));
},
_postSuccess: function() {
this.$('h4').text(Diaspora.I18n.t('bookmarklet.post_success'));
this.$("h4").text(Diaspora.I18n.t("bookmarklet.post_success"));
app.publisher.close();
this.$("#publisher").addClass("hidden");
_.delay(window.close, 2000);
},
_postError: function() {
this.$('h4').text(Diaspora.I18n.t('bookmarklet.post_something'));
this.$("h4").text(Diaspora.I18n.t("bookmarklet.post_something"));
}
});
// @license-end

View file

@ -15,9 +15,9 @@ app.views.Notifications = Backbone.View.extend({
toggleUnread: function(evt) {
var note = $(evt.target).closest(".stream_element");
var unread = note.hasClass("unread");
if (unread){ this.setRead(note.data("guid")); }
else { this.setUnread(note.data("guid")); }
var guid = note.data.guid;
if (unread){ this.setRead(guid); }
else { this.setUnread(guid); }
},
getAllUnread: function(){ return $(".media.stream_element.unread"); },
@ -37,8 +37,9 @@ app.views.Notifications = Backbone.View.extend({
},
clickSuccess: function(data) {
var type = $(".stream_element[data-guid=" + data["guid"] + "]").data("type");
this.updateView(data["guid"], type, data["unread"]);
var guid = data.guid;
var type = $(".stream_element[data-guid=" + guid + "]").data("type");
this.updateView(guid, type, data.unread);
},
markAllRead: function(evt){

View file

@ -11,14 +11,14 @@
app.views.PublisherGettingStarted = Backbone.View.extend({
initialize: function(opts) {
this.el_first_msg = opts.el_first_msg;
this.el_visibility = opts.el_visibility;
this.el_stream = opts.el_stream;
this.firstMessage = opts.firstMessageEl;
this.visibility = opts.visibilityEl;
this.stream = opts.streamEl;
},
// initiate all the popover message boxes
show: function() {
this._addPopover(this.el_first_msg, {
this._addPopover(this.firstMessage, {
trigger: "manual",
offset: 30,
id: "first_message_explain",
@ -26,7 +26,7 @@ app.views.PublisherGettingStarted = Backbone.View.extend({
html: true,
container: "body"
}, 600);
this._addPopover(this.el_visibility, {
this._addPopover(this.visibility, {
trigger: "manual",
offset: 10,
id: "message_visibility_explain",
@ -34,7 +34,7 @@ app.views.PublisherGettingStarted = Backbone.View.extend({
html: true,
container: "body"
}, 1000);
this._addPopover(this.el_stream, {
this._addPopover(this.stream, {
trigger: "manual",
offset: -5,
id: "stream_explain",
@ -45,8 +45,8 @@ app.views.PublisherGettingStarted = Backbone.View.extend({
// hide some popovers when a post is created
this.$("#submit").click(function() {
this.el_visibility.popover("hide");
this.el_first_msg.popover("hide");
this.visibility.popover("hide");
this.firstMessage.popover("hide");
});
},

View file

@ -6,7 +6,7 @@
app.views.PublisherUploader = Backbone.View.extend({
allowedExtensions: ['jpg', 'jpeg', 'png', 'gif', 'tif', 'tiff'],
allowedExtensions: ["jpg", "jpeg", "png", "gif", "tif", "tiff"],
sizeLimit: 4194304, // bytes
initialize: function(opts) {
@ -18,14 +18,14 @@ app.views.PublisherUploader = Backbone.View.extend({
//debug: true,
action: '/photos',
action: "/photos",
params: { photo: { pending: true }},
allowedExtensions: this.allowedExtensions,
sizeLimit: this.sizeLimit,
messages: {
typeError: Diaspora.I18n.t('photo_uploader.invalid_ext'),
sizeError: Diaspora.I18n.t('photo_uploader.size_error'),
emptyError: Diaspora.I18n.t('photo_uploader.empty')
typeError: Diaspora.I18n.t("photo_uploader.invalid_ext"),
sizeError: Diaspora.I18n.t("photo_uploader.size_error"),
emptyError: Diaspora.I18n.t("photo_uploader.empty")
},
onProgress: _.bind(this.progressHandler, this),
onSubmit: _.bind(this.submitHandler, this),
@ -33,22 +33,22 @@ app.views.PublisherUploader = Backbone.View.extend({
});
this.el_info = $('<div id="fileInfo" />');
this.publisher.el_wrapper.before(this.el_info);
this.info = $("<div id=\"fileInfo\" />");
this.publisher.wrapperEl.before(this.info);
this.publisher.el_photozone.on('click', '.x', _.bind(this._removePhoto, this));
this.publisher.photozoneEl.on("click", ".x", _.bind(this._removePhoto, this));
},
progressHandler: function(id, fileName, loaded, total) {
var progress = Math.round(loaded / total * 100);
this.el_info.text(fileName + ' ' + progress + '%').fadeTo(200, 1);
this.publisher.el_photozone
.find('li.loading').first().find('.bar')
.width(progress + '%');
this.info.text(fileName + " " + progress + "%").fadeTo(200, 1);
this.publisher.photozoneEl
.find("li.loading").first().find(".bar")
.width(progress + "%");
},
submitHandler: function() {
this.$el.addClass('loading');
this.$el.addClass("loading");
this._addPhotoPlaceholder();
},
@ -57,32 +57,32 @@ app.views.PublisherUploader = Backbone.View.extend({
var publisher = this.publisher;
publisher.setButtonsEnabled(false);
publisher.el_wrapper.addClass('with_attachments');
publisher.el_photozone.append(
'<li class="publisher_photo loading" style="position:relative;">' +
' <div class="progress progress-striped active"><div class="bar"></div></div>' +
' <img src="'+Handlebars.helpers.imageUrl('ajax-loader2.gif')+'" class="ajax-loader" alt="" />'+
'</li>'
publisher.wrapperEl.addClass("with_attachments");
publisher.photozoneEl.append(
"<li class=\"publisher_photo loading\" style=\"position:relative;\">" +
" <div class=\"progress progress-striped active\"><div class=\"bar\"></div></div>" +
" <img src=\"\"+Handlebars.helpers.imageUrl(\"ajax-loader2.gif\")+\"\" class=\"ajax-loader\" alt=\"\" />"+
"</li>"
);
},
uploadCompleteHandler: function(_id, fileName, response) {
if (response.success){
this.el_info.text(Diaspora.I18n.t('photo_uploader.completed', {file: fileName})).fadeTo(2000, 0);
this.info.text(Diaspora.I18n.t("photo_uploader.completed", {file: fileName})).fadeTo(2000, 0);
var id = response.data.photo.id,
url = response.data.photo.unprocessed_image.url;
this._addFinishedPhoto(id, url);
this.trigger('change');
this.trigger("change");
} else {
this._cancelPhotoUpload();
this.trigger('change');
this.el_info.text(Diaspora.I18n.t('photo_uploader.error', {file: fileName}));
this.publisher.el_wrapper.find('#photodropzone_container').first().after(
'<div id="upload_error">' +
Diaspora.I18n.t('photo_uploader.error', {file: fileName}) +
'</div>'
this.trigger("change");
this.info.text(Diaspora.I18n.t("photo_uploader.error", {file: fileName}));
this.publisher.wrapperEl.find("#photodropzone_container").first().after(
"<div id=\"upload_error\">" +
Diaspora.I18n.t("photo_uploader.error", {file: fileName}) +
"</div>"
);
}
},
@ -93,58 +93,58 @@ app.views.PublisherUploader = Backbone.View.extend({
var publisher = this.publisher;
// add form input element
publisher.$('.content_creation form').append(
'<input type="hidden", value="'+id+'" name="photos[]" />'
publisher.$(".content_creation form").append(
"<input type=\"hidden\", value=\"\"+id+\"\" name=\"photos[]\" />"
);
// replace placeholder
var placeholder = publisher.el_photozone.find('li.loading').first();
var placeholder = publisher.photozoneEl.find("li.loading").first();
placeholder
.removeClass('loading')
.removeClass("loading")
.prepend(
'<div class="x"></div>'+
'<div class="circle"></div>'
"<div class=\"x\"></div>"+
"<div class=\"circle\"></div>"
)
.find('img').attr({'src': url, 'data-id': id}).removeClass('ajax-loader');
.find("img").attr({"src": url, "data-id": id}).removeClass("ajax-loader");
placeholder
.find('div.progress').remove();
.find("div.progress").remove();
// no more placeholders? enable buttons
if( publisher.el_photozone.find('li.loading').length === 0 ) {
this.$el.removeClass('loading');
if( publisher.photozoneEl.find("li.loading").length === 0 ) {
this.$el.removeClass("loading");
publisher.setButtonsEnabled(true);
}
},
_cancelPhotoUpload: function() {
var publisher = this.publisher;
var placeholder = publisher.el_photozone.find('li.loading').first();
var placeholder = publisher.photozoneEl.find("li.loading").first();
placeholder
.removeClass('loading')
.find('img').remove();
.removeClass("loading")
.find("img").remove();
},
// remove an already uploaded photo
_removePhoto: function(evt) {
var self = this;
var photo = $(evt.target).parents('.publisher_photo');
var img = photo.find('img');
var photo = $(evt.target).parents(".publisher_photo");
var img = photo.find("img");
photo.addClass('dim');
photo.addClass("dim");
$.ajax({
url: '/photos/'+img.attr('data-id'),
dataType: 'json',
type: 'DELETE',
url: "/photos/"+img.attr("data-id"),
dataType: "json",
type: "DELETE",
success: function() {
$.when(photo.fadeOut(400)).then(function(){
photo.remove();
if( self.publisher.$('.publisher_photo').length === 0 ) {
if( self.publisher.$(".publisher_photo").length === 0 ) {
// no more photos left...
self.publisher.el_wrapper.removeClass('with_attachments');
self.publisher.wrapperEl.removeClass("with_attachments");
}
self.trigger('change');
self.trigger("change");
});
}
});

View file

@ -34,29 +34,29 @@ app.views.Publisher = Backbone.View.extend({
this.disabled = false;
// init shortcut references to the various elements
this.el_input = this.$('#status_message_fake_text');
this.el_hiddenInput = this.$('#status_message_text');
this.el_wrapper = this.$('#publisher_textarea_wrapper');
this.el_submit = this.$('input[type=submit], button#submit');
this.el_preview = this.$('button.post_preview_button');
this.el_photozone = this.$('#photodropzone');
this.inputEl = this.$("#status_message_fake_text");
this.hiddenInputEl = this.$("#status_message_text");
this.wrapperEl = this.$("#publisher_textarea_wrapper");
this.submitEl = this.$("input[type=submit], button#submit");
this.previewEl = this.$("button.post_preview_button");
this.photozoneEl = this.$("#photodropzone");
// init mentions plugin
Mentions.initialize(this.el_input);
Mentions.initialize(this.inputEl);
// init autoresize plugin
this.el_input.autoResize({ 'extraSpace' : 10, 'maxHeight' : Infinity });
this.inputEl.autoResize({ "extraSpace" : 10, "maxHeight" : Infinity });
// if there is data in the publisher we ask for a confirmation
// before the user is able to leave the page
$(window).on('beforeunload', _.bind(this._beforeUnload, this));
$(window).on("beforeunload", _.bind(this._beforeUnload, this));
// sync textarea content
if( this.el_hiddenInput.val() === "" ) {
this.el_hiddenInput.val( this.el_input.val() );
if( this.hiddenInputEl.val() === "" ) {
this.hiddenInputEl.val( this.inputEl.val() );
}
if( this.el_input.val() === "" ) {
this.el_input.val( this.el_hiddenInput.val() );
if( this.inputEl.val() === "" ) {
this.inputEl.val( this.hiddenInputEl.val() );
}
// hide close and preview buttons and manage services link
@ -64,37 +64,37 @@ app.views.Publisher = Backbone.View.extend({
// (e.g. bookmarklet, mentions popup)
if( this.standalone ) {
this.$("#hide_publisher").hide();
this.el_preview.hide();
this.previewEl.hide();
this.$(".question_mark").hide();
}
// this has to be here, otherwise for some reason the callback for the
// textchange event won't be called in Backbone...
this.el_input.bind('textchange', $.noop);
this.inputEl.bind("textchange", $.noop);
var _this = this;
$('body').on('click', function(event){
$("body").on("click", function(event){
// if the click event is happened outside the publisher view, then try to close the box
if( _this.el && $(event.target).closest('#publisher').attr('id') !== _this.el.id){
if( _this.el && $(event.target).closest("#publisher").attr("id") !== _this.el.id){
_this.tryClose();
}
});
// close publisher on post
this.on('publisher:add', function() {
this.on("publisher:add", function() {
this.close();
this.showSpinner(true);
});
// open publisher on post error
this.on('publisher:error', function() {
this.on("publisher:error", function() {
this.open();
this.showSpinner(false);
});
// resetting the poll view
this.on('publisher:sync', function() {
this.view_poll_creator.render();
this.on("publisher:sync", function() {
this.viewPollCreator.render();
});
this.initSubviews();
@ -103,7 +103,7 @@ app.views.Publisher = Backbone.View.extend({
},
initSubviews: function() {
var form = this.$('.content_creation form');
var form = this.$(".content_creation form");
this.view_services = new app.views.PublisherServices({
el: this.$('#publisher_service_icons'),
@ -111,48 +111,48 @@ app.views.Publisher = Backbone.View.extend({
form: form
});
this.view_aspect_selector = new app.views.PublisherAspectSelector({
el: this.$('.public_toggle .aspect_dropdown'),
this.viewAspectSelector = new app.views.PublisherAspectSelector({
el: this.$(".public_toggle .aspect_dropdown"),
form: form
});
this.view_getting_started = new app.views.PublisherGettingStarted({
el_first_msg: this.el_input,
el_visibility: this.$('.public_toggle .aspect_dropdown > .dropdown-toggle'),
el_stream: $('#gs-shim')
this.viewGettingStarted = new app.views.PublisherGettingStarted({
firstMessageEl: this.inputEl,
visibilityEl: this.$(".public_toggle .aspect_dropdown > .dropdown-toggle"),
streamEl: $("#gs-shim")
});
this.view_uploader = new app.views.PublisherUploader({
el: this.$('#file-upload'),
this.viewUploader = new app.views.PublisherUploader({
el: this.$("#file-upload"),
publisher: this
});
this.view_uploader.on('change', this.checkSubmitAvailability, this);
this.viewUploader.on("change", this.checkSubmitAvailability, this);
this.view_poll_creator = new app.views.PublisherPollCreator({
el: this.$('#poll_creator_container')
this.viewPollCreator = new app.views.PublisherPollCreator({
el: this.$("#poll_creator_container")
});
this.view_poll_creator.on('change', this.checkSubmitAvailability, this);
this.view_poll_creator.render();
this.viewPollCreator.on("change", this.checkSubmitAvailability, this);
this.viewPollCreator.render();
},
// set the selected aspects in the dropdown by their ids
setSelectedAspects: function(ids) {
this.view_aspect_selector.updateAspectsSelector(ids);
this.viewAspectSelector.updateAspectsSelector(ids);
},
// inject content into the publisher textarea
setText: function(txt) {
this.el_input.val(txt);
this.el_hiddenInput.val(txt);
this.inputEl.val(txt);
this.hiddenInputEl.val(txt);
this.prefillText = txt;
this.el_input.trigger('input');
this.inputEl.trigger("input");
this.handleTextchange();
},
// show the "getting started" popups around the publisher
triggerGettingStarted: function() {
this.view_getting_started.show();
this.viewGettingStarted.show();
},
createStatusMessage : function(evt) {
@ -164,7 +164,7 @@ app.views.Publisher = Backbone.View.extend({
// Auto-adding a poll answer always leaves an empty box when the user starts
// typing in the last box. We'll delete the last one to avoid submitting an
// empty poll answer and failing validation.
this.view_poll_creator.removeLastAnswer();
this.viewPollCreator.removeLastAnswer();
//add missing mentions at end of post:
this.handleTextchange();
@ -175,7 +175,9 @@ app.views.Publisher = Backbone.View.extend({
// lulz this code should be killed.
var statusMessage = new app.models.Post();
if( app.publisher ) app.publisher.trigger('publisher:add');
if( app.publisher ) {
app.publisher.trigger("publisher:add");
}
statusMessage.save({
"status_message" : {
@ -192,9 +194,9 @@ app.views.Publisher = Backbone.View.extend({
url : "/status_messages",
success : function() {
if( app.publisher ) {
app.publisher.$el.trigger('ajax:success');
app.publisher.trigger('publisher:sync');
self.view_poll_creator.trigger('publisher:sync');
app.publisher.$el.trigger("ajax:success");
app.publisher.trigger("publisher:sync");
self.viewPollCreator.trigger("publisher:sync");
}
if(app.stream && !self.standalone){
@ -208,9 +210,11 @@ app.views.Publisher = Backbone.View.extend({
if( self.standalone ) self.setEnabled(false);
},
error: function(model, resp) {
if( app.publisher ) app.publisher.trigger('publisher:error');
if( app.publisher ) {
app.publisher.trigger("publisher:error");
}
self.setInputEnabled(true);
Diaspora.page.flashMessages.render({ 'success':false, 'notice':resp.responseText });
Diaspora.page.flashMessages.render({ "success":false, "notice":resp.responseText });
self.setButtonsEnabled(true);
self.setInputEnabled(true);
}
@ -219,9 +223,9 @@ app.views.Publisher = Backbone.View.extend({
// creates the location
showLocation: function(){
if($('#location').length === 0){
$('#location_container').append('<div id="location"></div>');
this.el_wrapper.addClass('with_location');
if($("#location").length === 0){
$("#location_container").append("<div id=\"location\"></div>");
this.wrapperEl.addClass("with_location");
this.view_locator = new app.views.Location();
}
},
@ -230,14 +234,14 @@ app.views.Publisher = Backbone.View.extend({
destroyLocation: function(){
if(this.view_locator){
this.view_locator.remove();
this.el_wrapper.removeClass('with_location');
this.wrapperEl.removeClass("with_location");
delete this.view_locator;
}
},
togglePollCreator: function(){
this.view_poll_creator.$el.toggle();
this.el_input.focus();
this.viewPollCreator.$el.toggle();
this.inputEl.focus();
},
// avoid submitting form when pressing Enter key
@ -255,8 +259,8 @@ app.views.Publisher = Backbone.View.extend({
var serializedForm = $(evt.target).closest("form").serializeObject();
var photos = [];
$('li.publisher_photo img').each(function(){
var file = $(this).attr('src').substring("/uploads/images/".length);
$("li.publisher_photo img").each(function(){
var file = $(this).attr("src").substring("/uploads/images/".length);
photos.push(
{
"sizes":{
@ -295,18 +299,20 @@ app.views.Publisher = Backbone.View.extend({
var date = (new Date()).toISOString();
var poll;
var poll_question = serializedForm["poll_question"];
var poll_answers_arry = _.flatten([serializedForm["poll_answers[]"]]);
var poll_answers = _.map(poll_answers_arry, function(answer){
if(answer) return { 'answer' : answer };
var pollQuestion = serializedForm.poll_question;
var pollAnswersArray = _.flatten([serializedForm["poll_answers[]"]]);
var pollAnswers = _.map(pollAnswersArray, function(answer){
if (answer) {
return { "answer" : answer };
}
});
poll_answers = _.without(poll_answers, undefined);
pollAnswers = _.without(pollAnswers, undefined);
if(poll_question && poll_answers.length) {
if(pollQuestion && pollAnswers.length) {
poll = {
'question': poll_question,
'poll_answers' : poll_answers,
'participation_count': '0'
"question": pollQuestion,
"poll_answers" : pollAnswers,
"participation_count": "0"
};
}
@ -324,30 +330,30 @@ app.views.Publisher = Backbone.View.extend({
"title" : serializedForm["status_message[text]"],
"address" : $("#location_address").val(),
"interactions" : {"likes":[],"reshares":[],"comments_count":0,"likes_count":0,"reshares_count":0},
'poll': poll
"poll": poll
};
if(app.stream) {
this.removePostPreview();
app.stream.addNow(previewMessage);
this.recentPreview=previewMessage;
this.modifyPostPreview($('.stream_element:first',$('.stream_container')));
this.modifyPostPreview($(".stream_element:first",$(".stream_container")));
}
},
modifyPostPreview : function(post) {
post.addClass('post_preview');
$('.collapsible',post).removeClass('collapsed').addClass('opened');
$('a.delete.remove_post',post).hide();
$('a.like, a.focus_comment_textarea',post).removeAttr("href");
$('a.like',post).addClass("like_preview");
$('a.like',post).removeClass("like");
$('a.focus_comment_textarea',post).addClass("focus_comment_textarea_preview");
$('a.focus_comment_textarea',post).removeClass("focus_comment_textarea");
$('a',$('span.details.grey',post)).removeAttr("href");
post.addClass("post_preview");
$(".collapsible",post).removeClass("collapsed").addClass("opened");
$("a.delete.remove_post",post).hide();
$("a.like, a.focus_comment_textarea",post).removeAttr("href");
$("a.like",post).addClass("like_preview");
$("a.like",post).removeClass("like");
$("a.focus_comment_textarea",post).addClass("focus_comment_textarea_preview");
$("a.focus_comment_textarea",post).removeClass("focus_comment_textarea");
$("a",$("span.details.grey",post)).removeAttr("href");
},
removePostPreview : function() {
if(app.stream && this.recentPreview){
if(app.stream && this.recentPreview) {
app.stream.items.remove(this.recentPreview);
delete this.recentPreview;
}
@ -363,21 +369,21 @@ app.views.Publisher = Backbone.View.extend({
clear : function() {
// clear text(s)
this.el_input.val('');
this.el_hiddenInput.val('');
this.el_input.trigger('keyup')
.trigger('keydown');
this.inputEl.val("");
this.hiddenInputEl.val("");
this.inputEl.trigger("keyup")
.trigger("keydown");
// remove mentions
this.el_input.mentionsInput('reset');
this.inputEl.mentionsInput("reset");
// remove photos
this.el_photozone.find('li').remove();
this.photozoneEl.find("li").remove();
this.$("input[name='photos[]']").remove();
this.el_wrapper.removeClass("with_attachments");
this.wrapperEl.removeClass("with_attachments");
// empty upload-photo
this.$('#fileInfo').empty();
this.$("#fileInfo").empty();
// close publishing area (CSS)
this.close();
@ -401,11 +407,11 @@ app.views.Publisher = Backbone.View.extend({
this.destroyLocation();
// clear poll form
this.view_poll_creator.clearInputs();
this.viewPollCreator.clearInputs();
// force textchange plugin to update lastValue
this.el_input.data('lastValue', '');
this.el_hiddenInput.data('lastValue', '');
this.inputEl.data("lastValue", "");
this.hiddenInputEl.data("lastValue", "");
return this;
},
@ -421,8 +427,8 @@ app.views.Publisher = Backbone.View.extend({
if( this.disabled ) return;
// visually 'open' the publisher
this.$el.removeClass('closed');
this.el_wrapper.addClass('active');
this.$el.removeClass("closed");
this.wrapperEl.addClass("active");
// fetch contacts for mentioning
Mentions.fetchContacts();
@ -431,17 +437,19 @@ app.views.Publisher = Backbone.View.extend({
close : function() {
$(this.el).addClass("closed");
this.el_wrapper.removeClass("active");
this.el_input.css('height', '');
this.view_poll_creator.$el.hide();
this.wrapperEl.removeClass("active");
this.inputEl.css("height", "");
this.viewPollCreator.$el.hide();
return this;
},
showSpinner: function(bool) {
if (bool)
this.$('#publisher_spinner').removeClass('hidden');
else
this.$('#publisher_spinner').addClass('hidden');
if (bool) {
this.$("#publisher_spinner").removeClass("hidden");
}
else {
this.$("#publisher_spinner").addClass("hidden");
}
},
checkSubmitAvailability: function() {
@ -461,29 +469,29 @@ app.views.Publisher = Backbone.View.extend({
setButtonsEnabled: function(bool) {
if (bool) {
this.el_submit.removeProp('disabled');
this.el_preview.removeProp('disabled');
this.submitEl.removeProp("disabled");
this.previewEl.removeProp("disabled");
} else {
this.el_submit.prop('disabled', true);
this.el_preview.prop('disabled', true);
this.submitEl.prop("disabled", true);
this.previewEl.prop("disabled", true);
}
},
setInputEnabled: function(bool) {
if (bool) {
this.el_input.removeProp('disabled');
this.el_hiddenInput.removeProp('disabled');
this.inputEl.removeProp("disabled");
this.hiddenInputEl.removeProp("disabled");
} else {
this.el_input.prop('disabled', true);
this.el_hiddenInput.prop('disabled', true);
this.inputEl.prop("disabled", true);
this.hiddenInputEl.prop("disabled", true);
}
},
// determine submit availability
_submittable: function() {
var onlyWhitespaces = ($.trim(this.el_input.val()) === ''),
isPhotoAttached = (this.el_photozone.children().length > 0),
isValidPoll = this.view_poll_creator.validatePoll();
var onlyWhitespaces = ($.trim(this.inputEl.val()) === ""),
isPhotoAttached = (this.photozoneEl.children().length > 0),
isValidPoll = this.viewPollCreator.validatePoll();
return (!onlyWhitespaces || isPhotoAttached) && isValidPoll && !this.disabled;
},
@ -492,13 +500,13 @@ app.views.Publisher = Backbone.View.extend({
var self = this;
this.checkSubmitAvailability();
this.el_input.mentionsInput("val", function(value){
self.el_hiddenInput.val(value);
this.inputEl.mentionsInput("val", function(value){
self.hiddenInputEl.val(value);
});
},
_beforeUnload: function(e) {
if(this._submittable() && this.el_input.val() !== this.prefillText){
if(this._submittable() && this.inputEl.val() !== this.prefillText){
var confirmationMessage = Diaspora.I18n.t("confirm_unload");
(e || window.event).returnValue = confirmationMessage; //Gecko + IE
return confirmationMessage; //Webkit, Safari, Chrome, etc.
@ -516,9 +524,9 @@ $.fn.serializeObject = function()
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
o[this.name].push(this.value || "");
} else {
o[this.name] = this.value || '';
o[this.name] = this.value || "";
}
});
return o;

View file

@ -6,7 +6,7 @@ module InvitationCodesHelper
end
def invite_link(invite_code)
text_field_tag :invite_code, invite_code_url(invite_code), :class => 'form-control', :readonly => true
text_field_tag :invite_code, invite_code_url(invite_code), class: "form-control", readonly: true
end
def invited_by_message

View file

@ -20,7 +20,7 @@
= render partial: 'conversations/conversation', collection: @conversations,
locals: { authors: @authors, unread_counts: @unread_counts }
- else
%div{ class: 'no-messages' }
.no-messages
%i
= t('.no_messages')

View file

@ -86,7 +86,7 @@ describe("app.views.AspectCreate", function() {
});
it("should hide the modal", function() {
this.view.$('.modal').removeClass('fade');
this.view.$(".modal").removeClass("fade");
this.view.$(".modal").modal("toggle");
expect(this.view.$(".modal")).toHaveClass("in");
this.view.createAspect();
@ -109,7 +109,7 @@ describe("app.views.AspectCreate", function() {
});
it("should hide the modal", function() {
this.view.$('.modal').removeClass('fade');
this.view.$(".modal").removeClass("fade");
this.view.$(".modal").modal("show");
expect(this.view.$(".modal")).toHaveClass("in");
this.view.createAspect();

View file

@ -15,8 +15,8 @@ describe("app.views.AspectsDropdown", function(){
context('_toggleCheckbox', function() {
beforeEach(function() {
this.view.$('li.selected').removeClass('selected');
this.view.$('li.all_aspects').addClass('selected');
this.view.$("li.selected").removeClass("selected");
this.view.$("li.all_aspects").addClass("selected");
});
it('deselects all radio buttons', function() {
@ -45,21 +45,21 @@ describe("app.views.AspectsDropdown", function(){
});
it('deselects all checkboxes', function() {
this.view._toggleRadio(this.view.$('li.all_aspects'));
expect(this.view.$('li.aspect_selector:eq(0)').hasClass('selected')).toBeFalsy();
expect(this.view.$('li.aspect_selector:eq(1)').hasClass('selected')).toBeFalsy();
this.view._toggleRadio(this.view.$("li.all_aspects"));
expect(this.view.$("li.aspect_selector:eq(0)").hasClass("selected")).toBeFalsy();
expect(this.view.$("li.aspect_selector:eq(1)").hasClass("selected")).toBeFalsy();
});
it('toggles the clicked radio buttons', function() {
this.view._toggleRadio(this.view.$('li.all_aspects'));
expect(this.view.$('li.all_aspects').hasClass('selected')).toBeTruthy();
expect(this.view.$('li.public').hasClass('selected')).toBeFalsy();
this.view._toggleRadio(this.view.$('li.public'));
expect(this.view.$('li.all_aspects').hasClass('selected')).toBeFalsy();
expect(this.view.$('li.public').hasClass('selected')).toBeTruthy();
this.view._toggleRadio(this.view.$('li.all_aspects'));
expect(this.view.$('li.all_aspects').hasClass('selected')).toBeTruthy();
expect(this.view.$('li.public').hasClass('selected')).toBeFalsy();
this.view._toggleRadio(this.view.$("li.all_aspects"));
expect(this.view.$("li.all_aspects").hasClass("selected")).toBeTruthy();
expect(this.view.$("li.public").hasClass("selected")).toBeFalsy();
this.view._toggleRadio(this.view.$("li.public"));
expect(this.view.$("li.all_aspects").hasClass("selected")).toBeFalsy();
expect(this.view.$("li.public").hasClass("selected")).toBeTruthy();
this.view._toggleRadio(this.view.$("li.all_aspects"));
expect(this.view.$("li.all_aspects").hasClass("selected")).toBeTruthy();
expect(this.view.$("li.public").hasClass("selected")).toBeFalsy();
});
});
@ -90,9 +90,9 @@ describe("app.views.AspectsDropdown", function(){
});
it('shows the name of the selected radio button', function() {
this.view.$('li.all_aspects').addClass('selected');
this.view._updateButton('inAspectClass');
expect(this.view.$('.btn.dropdown-toggle > .text').text()).toContain(Diaspora.I18n.t('aspect_dropdown.all_aspects'));
this.view.$("li.all_aspects").addClass("selected");
this.view._updateButton("inAspectClass");
expect(this.view.$(".btn.dropdown-toggle > .text").text()).toContain(Diaspora.I18n.t("aspect_dropdown.all_aspects"));
});
it('shows the name of the selected aspect ( == 1 )', function() {

View file

@ -1,9 +1,9 @@
describe('app.views.Bookmarklet', function() {
describe("app.views.Bookmarklet", function() {
var test_data = {
url: 'https://www.youtube.com/watch?v=0Bmhjf0rKe8',
title: 'Surprised Kitty',
notes: 'cute kitty'
url: "https://www.youtube.com/watch?v=0Bmhjf0rKe8",
title: "Surprised Kitty",
notes: "cute kitty"
};
var evil_test_data = _.extend({}, {
notes: "**love** This is such a\n\n great \"cute kitty\" '''blabla''' %28%29\\"
@ -11,46 +11,46 @@ describe('app.views.Bookmarklet', function() {
var init_bookmarklet = function(data) {
app.bookmarklet = new app.views.Bookmarklet(
_.extend({el: $('#bookmarklet')}, data)
_.extend({el: $("#bookmarklet")}, data)
).render();
};
beforeEach(function() {
app.stream = null; // avoid rendering posts
loginAs({name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}});
spec.loadFixture('bookmarklet');
spec.loadFixture("bookmarklet");
});
it('initializes a standalone publisher', function() {
it("initializes a standalone publisher", function() {
new app.views.Bookmarklet();
expect(app.publisher).not.toBeNull();
expect(app.publisher.standalone).toBeTruthy();
});
it('prefills the publisher', function() {
it("prefills the publisher", function() {
init_bookmarklet(test_data);
expect($.trim(app.publisher.el_input.val())).not.toEqual('');
expect($.trim(app.publisher.el_hiddenInput.val())).not.toEqual('');
expect($.trim(app.publisher.inputEl.val())).not.toEqual("");
expect($.trim(app.publisher.hiddenInputEl.val())).not.toEqual("");
});
it('handles dirty input well', function() {
it("handles dirty input well", function() {
init_bookmarklet(evil_test_data);
expect($.trim(app.publisher.el_input.val())).not.toEqual('');
expect($.trim(app.publisher.el_hiddenInput.val())).not.toEqual('');
expect($.trim(app.publisher.inputEl.val())).not.toEqual("");
expect($.trim(app.publisher.hiddenInputEl.val())).not.toEqual("");
});
it('allows changing a prefilled publisher', function() {
it("allows changing a prefilled publisher", function() {
init_bookmarklet(test_data);
app.publisher.setText(app.publisher.el_input.val()+'A');
app.publisher.setText(app.publisher.inputEl.val()+"A");
expect(app.publisher.el_hiddenInput.val()).toMatch(/.+A$/);
expect(app.publisher.hiddenInputEl.val()).toMatch(/.+A$/);
});
it('keeps the publisher disabled after successful post creation', function() {
it("keeps the publisher disabled after successful post creation", function() {
init_bookmarklet(test_data);
spec.content().find('form').submit();
spec.content().find("form").submit();
jasmine.Ajax.requests.mostRecent().respondWith({
status: 200, // success!

View file

@ -109,12 +109,12 @@ describe("app.views.Publisher", function() {
it("removes all photos from the dropzone area", function(){
var self = this;
_.times(3, function(){
self.view.el_photozone.append($("<li>"));
self.view.photozoneEl.append($("<li>"));
});
expect(this.view.el_photozone.html()).not.toBe("");
expect(this.view.photozoneEl.html()).not.toBe("");
this.view.clear($.Event());
expect(this.view.el_photozone.html()).toBe("");
expect(this.view.photozoneEl.html()).toBe("");
});
it("removes all photo values appended by the photo uploader", function(){
@ -153,32 +153,32 @@ describe("app.views.Publisher", function() {
});
describe('#setText', function() {
it('sets the content text', function() {
this.view.setText('FOO bar');
it("sets the content text", function() {
this.view.setText("FOO bar");
expect(this.view.el_input.val()).toEqual('FOO bar');
expect(this.view.el_hiddenInput.val()).toEqual('FOO bar');
expect(this.view.inputEl.val()).toEqual("FOO bar");
expect(this.view.hiddenInputEl.val()).toEqual("FOO bar");
});
});
describe('#setEnabled', function() {
it('disables the publisher', function() {
it("disables the publisher", function() {
expect(this.view.disabled).toBeFalsy();
this.view.setEnabled(false);
expect(this.view.disabled).toBeTruthy();
expect(this.view.el_input.prop('disabled')).toBeTruthy();
expect(this.view.el_hiddenInput.prop('disabled')).toBeTruthy();
expect(this.view.inputEl.prop("disabled")).toBeTruthy();
expect(this.view.hiddenInputEl.prop("disabled")).toBeTruthy();
});
it("disables submitting", function() {
this.view.setText('TESTING');
expect(this.view.el_submit.prop('disabled')).toBeFalsy();
expect(this.view.el_preview.prop('disabled')).toBeFalsy();
this.view.setText("TESTING");
expect(this.view.submitEl.prop("disabled")).toBeFalsy();
expect(this.view.previewEl.prop("disabled")).toBeFalsy();
this.view.setEnabled(false);
expect(this.view.el_submit.prop('disabled')).toBeTruthy();
expect(this.view.el_preview.prop('disabled')).toBeTruthy();
expect(this.view.submitEl.prop("disabled")).toBeTruthy();
expect(this.view.previewEl.prop("disabled")).toBeTruthy();
});
});
@ -305,7 +305,7 @@ describe("app.views.Publisher", function() {
spec.loadFixture("status_message_new");
Diaspora.I18n.load({ stream: { public: 'Public' }});
this.view_aspect_selector = new app.views.PublisherAspectSelector({
this.viewAspectSelector = new app.views.PublisherAspectSelector({
el: $('.public_toggle .aspect_dropdown'),
form: $('.content_creation form')
});
@ -349,7 +349,7 @@ describe("app.views.Publisher", function() {
expect(selected.first().val()).toBe('all_aspects');
var evt = $.Event("click", { target: $('.aspect_dropdown li.aspect_selector:last') });
this.view.view_aspect_selector.toggleAspect(evt);
this.view.viewAspectSelector.toggleAspect(evt);
selected = $('input[name="aspect_ids[]"]');
expect(selected.length).toBe(1);
@ -360,20 +360,20 @@ describe("app.views.Publisher", function() {
expect($('input[name="aspect_ids[]"][value="42"]').length).toBe(0);
var evt = $.Event("click", { target: $('.aspect_dropdown li.aspect_selector:last') });
this.view.view_aspect_selector.toggleAspect(evt);
this.view.viewAspectSelector.toggleAspect(evt);
expect($('input[name="aspect_ids[]"][value="42"]').length).toBe(1);
evt = $.Event("click", { target: $('.aspect_dropdown li.aspect_selector:last') });
this.view.view_aspect_selector.toggleAspect(evt);
this.view.viewAspectSelector.toggleAspect(evt);
expect($('input[name="aspect_ids[]"][value="42"]').length).toBe(0);
});
it("keeps other fields with different values", function() {
$('.dropdown-menu').append('<li data-aspect_id="99" class="aspect_selector" />');
var evt = $.Event("click", { target: $('.aspect_dropdown li.aspect_selector:eq(-2)') });
this.view.view_aspect_selector.toggleAspect(evt);
this.view.viewAspectSelector.toggleAspect(evt);
evt = $.Event("click", { target: $('.aspect_dropdown li.aspect_selector:eq(-1)') });
this.view.view_aspect_selector.toggleAspect(evt);
this.view.viewAspectSelector.toggleAspect(evt);
expect($('input[name="aspect_ids[]"][value="42"]').length).toBe(1);
expect($('input[name="aspect_ids[]"][value="99"]').length).toBe(1);
@ -460,7 +460,7 @@ describe("app.views.Publisher", function() {
this.view = new app.views.Publisher();
// replace the uploader plugin with a dummy object
var upload_view = this.view.view_uploader;
var upload_view = this.view.viewUploader;
this.uploader = {
onProgress: _.bind(upload_view.progressHandler, upload_view),
onSubmit: _.bind(upload_view.submitHandler, upload_view),
@ -473,7 +473,7 @@ describe("app.views.Publisher", function() {
it('shows progress in percent', function() {
this.uploader.onProgress(null, 'test.jpg', 20, 100);
var info = this.view.view_uploader.el_info;
var info = this.view.viewUploader.infoEl;
expect(info.text()).toContain('test.jpg');
expect(info.text()).toContain('20%');
});
@ -485,13 +485,13 @@ describe("app.views.Publisher", function() {
});
it('adds a placeholder', function() {
expect(this.view.el_wrapper.attr('class')).toContain('with_attachments');
expect(this.view.el_photozone.find('li').length).toBe(1);
expect(this.view.wrapperEl.attr("class")).toContain("with_attachments");
expect(this.view.photozoneEl.find("li").length).toBe(1);
});
it('disables the publisher buttons', function() {
expect(this.view.el_submit.prop('disabled')).toBeTruthy();
expect(this.view.el_preview.prop('disabled')).toBeTruthy();
expect(this.view.submitEl.prop("disabled")).toBeTruthy();
expect(this.view.previewEl.prop("disabled")).toBeTruthy();
});
});
@ -509,7 +509,7 @@ describe("app.views.Publisher", function() {
});
it('shows it in text form', function() {
var info = this.view.view_uploader.el_info;
var info = this.view.viewUploader.infoEl;
expect(info.text()).toBe(Diaspora.I18n.t('photo_uploader.completed', {file: 'test.jpg'}));
});
@ -519,7 +519,7 @@ describe("app.views.Publisher", function() {
});
it('replaces the placeholder', function() {
var li = this.view.el_photozone.find('li');
var li = this.view.photozoneEl.find("li");
var img = li.find('img');
expect(li.attr('class')).not.toContain('loading');
@ -528,8 +528,8 @@ describe("app.views.Publisher", function() {
});
it('re-enables the buttons', function() {
expect(this.view.el_submit.prop('disabled')).toBeFalsy();
expect(this.view.el_preview.prop('disabled')).toBeFalsy();
expect(this.view.submitEl.prop("disabled")).toBeFalsy();
expect(this.view.previewEl.prop("disabled")).toBeFalsy();
});
});
@ -547,7 +547,7 @@ describe("app.views.Publisher", function() {
});
it('shows error message', function() {
var info = this.view.view_uploader.el_info;
var info = this.view.viewUploader.infoEl;
expect(info.text()).toBe(Diaspora.I18n.t('photo_uploader.error', {file: 'test.jpg'}));
});
});
@ -556,21 +556,21 @@ describe("app.views.Publisher", function() {
context('photo removal', function() {
beforeEach(function() {
this.view = new app.views.Publisher();
this.view.el_wrapper.addClass('with_attachments');
this.view.el_photozone.html(
'<li class="publisher_photo">.'+
' <img data-id="444" />'+
' <div class="x">X</div>'+
' <div class="circle"></div>'+
'</li>'
this.view.wrapperEl.addClass("with_attachments");
this.view.photozoneEl.html(
"<li class=\"publisher_photo\">."+
" <img data-id=\"444\" />"+
" <div class=\"x\">X</div>"+
" <div class=\"circle\"></div>"+
"</li>"
);
spyOn(jQuery, 'ajax').and.callFake(function(opts) { opts.success(); });
this.view.el_photozone.find('.x').click();
this.view.photozoneEl.find(".x").click();
});
it('removes the element', function() {
var photo = this.view.el_photozone.find('li.publisher_photo');
var photo = this.view.photozoneEl.find("li.publisher_photo");
expect(photo.length).toBe(0);
});
@ -579,7 +579,7 @@ describe("app.views.Publisher", function() {
});
it('removes class on wrapper element', function() {
expect(this.view.el_wrapper.attr('class')).not.toContain('with_attachments');
expect(this.view.wrapperEl.attr("class")).not.toContain("with_attachments");
});
});
});