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

View file

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

View file

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

View file

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

View file

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

View file

@ -6,7 +6,7 @@
app.views.PublisherUploader = Backbone.View.extend({ app.views.PublisherUploader = Backbone.View.extend({
allowedExtensions: ['jpg', 'jpeg', 'png', 'gif', 'tif', 'tiff'], allowedExtensions: ["jpg", "jpeg", "png", "gif", "tif", "tiff"],
sizeLimit: 4194304, // bytes sizeLimit: 4194304, // bytes
initialize: function(opts) { initialize: function(opts) {
@ -18,14 +18,14 @@ app.views.PublisherUploader = Backbone.View.extend({
//debug: true, //debug: true,
action: '/photos', action: "/photos",
params: { photo: { pending: true }}, params: { photo: { pending: true }},
allowedExtensions: this.allowedExtensions, allowedExtensions: this.allowedExtensions,
sizeLimit: this.sizeLimit, sizeLimit: this.sizeLimit,
messages: { messages: {
typeError: Diaspora.I18n.t('photo_uploader.invalid_ext'), typeError: Diaspora.I18n.t("photo_uploader.invalid_ext"),
sizeError: Diaspora.I18n.t('photo_uploader.size_error'), sizeError: Diaspora.I18n.t("photo_uploader.size_error"),
emptyError: Diaspora.I18n.t('photo_uploader.empty') emptyError: Diaspora.I18n.t("photo_uploader.empty")
}, },
onProgress: _.bind(this.progressHandler, this), onProgress: _.bind(this.progressHandler, this),
onSubmit: _.bind(this.submitHandler, this), onSubmit: _.bind(this.submitHandler, this),
@ -33,22 +33,22 @@ app.views.PublisherUploader = Backbone.View.extend({
}); });
this.el_info = $('<div id="fileInfo" />'); this.info = $("<div id=\"fileInfo\" />");
this.publisher.el_wrapper.before(this.el_info); 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) { progressHandler: function(id, fileName, loaded, total) {
var progress = Math.round(loaded / total * 100); var progress = Math.round(loaded / total * 100);
this.el_info.text(fileName + ' ' + progress + '%').fadeTo(200, 1); this.info.text(fileName + " " + progress + "%").fadeTo(200, 1);
this.publisher.el_photozone this.publisher.photozoneEl
.find('li.loading').first().find('.bar') .find("li.loading").first().find(".bar")
.width(progress + '%'); .width(progress + "%");
}, },
submitHandler: function() { submitHandler: function() {
this.$el.addClass('loading'); this.$el.addClass("loading");
this._addPhotoPlaceholder(); this._addPhotoPlaceholder();
}, },
@ -57,32 +57,32 @@ app.views.PublisherUploader = Backbone.View.extend({
var publisher = this.publisher; var publisher = this.publisher;
publisher.setButtonsEnabled(false); publisher.setButtonsEnabled(false);
publisher.el_wrapper.addClass('with_attachments'); publisher.wrapperEl.addClass("with_attachments");
publisher.el_photozone.append( publisher.photozoneEl.append(
'<li class="publisher_photo loading" style="position:relative;">' + "<li class=\"publisher_photo loading\" style=\"position:relative;\">" +
' <div class="progress progress-striped active"><div class="bar"></div></div>' + " <div class=\"progress progress-striped active\"><div class=\"bar\"></div></div>" +
' <img src="'+Handlebars.helpers.imageUrl('ajax-loader2.gif')+'" class="ajax-loader" alt="" />'+ " <img src=\"\"+Handlebars.helpers.imageUrl(\"ajax-loader2.gif\")+\"\" class=\"ajax-loader\" alt=\"\" />"+
'</li>' "</li>"
); );
}, },
uploadCompleteHandler: function(_id, fileName, response) { uploadCompleteHandler: function(_id, fileName, response) {
if (response.success){ 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, var id = response.data.photo.id,
url = response.data.photo.unprocessed_image.url; url = response.data.photo.unprocessed_image.url;
this._addFinishedPhoto(id, url); this._addFinishedPhoto(id, url);
this.trigger('change'); this.trigger("change");
} else { } else {
this._cancelPhotoUpload(); this._cancelPhotoUpload();
this.trigger('change'); this.trigger("change");
this.el_info.text(Diaspora.I18n.t('photo_uploader.error', {file: fileName})); this.info.text(Diaspora.I18n.t("photo_uploader.error", {file: fileName}));
this.publisher.el_wrapper.find('#photodropzone_container').first().after( this.publisher.wrapperEl.find("#photodropzone_container").first().after(
'<div id="upload_error">' + "<div id=\"upload_error\">" +
Diaspora.I18n.t('photo_uploader.error', {file: fileName}) + Diaspora.I18n.t("photo_uploader.error", {file: fileName}) +
'</div>' "</div>"
); );
} }
}, },
@ -93,58 +93,58 @@ app.views.PublisherUploader = Backbone.View.extend({
var publisher = this.publisher; var publisher = this.publisher;
// add form input element // add form input element
publisher.$('.content_creation form').append( publisher.$(".content_creation form").append(
'<input type="hidden", value="'+id+'" name="photos[]" />' "<input type=\"hidden\", value=\"\"+id+\"\" name=\"photos[]\" />"
); );
// replace placeholder // replace placeholder
var placeholder = publisher.el_photozone.find('li.loading').first(); var placeholder = publisher.photozoneEl.find("li.loading").first();
placeholder placeholder
.removeClass('loading') .removeClass("loading")
.prepend( .prepend(
'<div class="x"></div>'+ "<div class=\"x\"></div>"+
'<div class="circle"></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 placeholder
.find('div.progress').remove(); .find("div.progress").remove();
// no more placeholders? enable buttons // no more placeholders? enable buttons
if( publisher.el_photozone.find('li.loading').length === 0 ) { if( publisher.photozoneEl.find("li.loading").length === 0 ) {
this.$el.removeClass('loading'); this.$el.removeClass("loading");
publisher.setButtonsEnabled(true); publisher.setButtonsEnabled(true);
} }
}, },
_cancelPhotoUpload: function() { _cancelPhotoUpload: function() {
var publisher = this.publisher; var publisher = this.publisher;
var placeholder = publisher.el_photozone.find('li.loading').first(); var placeholder = publisher.photozoneEl.find("li.loading").first();
placeholder placeholder
.removeClass('loading') .removeClass("loading")
.find('img').remove(); .find("img").remove();
}, },
// remove an already uploaded photo // remove an already uploaded photo
_removePhoto: function(evt) { _removePhoto: function(evt) {
var self = this; var self = this;
var photo = $(evt.target).parents('.publisher_photo'); var photo = $(evt.target).parents(".publisher_photo");
var img = photo.find('img'); var img = photo.find("img");
photo.addClass('dim'); photo.addClass("dim");
$.ajax({ $.ajax({
url: '/photos/'+img.attr('data-id'), url: "/photos/"+img.attr("data-id"),
dataType: 'json', dataType: "json",
type: 'DELETE', type: "DELETE",
success: function() { success: function() {
$.when(photo.fadeOut(400)).then(function(){ $.when(photo.fadeOut(400)).then(function(){
photo.remove(); photo.remove();
if( self.publisher.$('.publisher_photo').length === 0 ) { if( self.publisher.$(".publisher_photo").length === 0 ) {
// no more photos left... // 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; this.disabled = false;
// init shortcut references to the various elements // init shortcut references to the various elements
this.el_input = this.$('#status_message_fake_text'); this.inputEl = this.$("#status_message_fake_text");
this.el_hiddenInput = this.$('#status_message_text'); this.hiddenInputEl = this.$("#status_message_text");
this.el_wrapper = this.$('#publisher_textarea_wrapper'); this.wrapperEl = this.$("#publisher_textarea_wrapper");
this.el_submit = this.$('input[type=submit], button#submit'); this.submitEl = this.$("input[type=submit], button#submit");
this.el_preview = this.$('button.post_preview_button'); this.previewEl = this.$("button.post_preview_button");
this.el_photozone = this.$('#photodropzone'); this.photozoneEl = this.$("#photodropzone");
// init mentions plugin // init mentions plugin
Mentions.initialize(this.el_input); Mentions.initialize(this.inputEl);
// init autoresize plugin // 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 // if there is data in the publisher we ask for a confirmation
// before the user is able to leave the page // 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 // sync textarea content
if( this.el_hiddenInput.val() === "" ) { if( this.hiddenInputEl.val() === "" ) {
this.el_hiddenInput.val( this.el_input.val() ); this.hiddenInputEl.val( this.inputEl.val() );
} }
if( this.el_input.val() === "" ) { if( this.inputEl.val() === "" ) {
this.el_input.val( this.el_hiddenInput.val() ); this.inputEl.val( this.hiddenInputEl.val() );
} }
// hide close and preview buttons and manage services link // hide close and preview buttons and manage services link
@ -64,37 +64,37 @@ app.views.Publisher = Backbone.View.extend({
// (e.g. bookmarklet, mentions popup) // (e.g. bookmarklet, mentions popup)
if( this.standalone ) { if( this.standalone ) {
this.$("#hide_publisher").hide(); this.$("#hide_publisher").hide();
this.el_preview.hide(); this.previewEl.hide();
this.$(".question_mark").hide(); this.$(".question_mark").hide();
} }
// this has to be here, otherwise for some reason the callback for the // this has to be here, otherwise for some reason the callback for the
// textchange event won't be called in Backbone... // textchange event won't be called in Backbone...
this.el_input.bind('textchange', $.noop); this.inputEl.bind("textchange", $.noop);
var _this = this; 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 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(); _this.tryClose();
} }
}); });
// close publisher on post // close publisher on post
this.on('publisher:add', function() { this.on("publisher:add", function() {
this.close(); this.close();
this.showSpinner(true); this.showSpinner(true);
}); });
// open publisher on post error // open publisher on post error
this.on('publisher:error', function() { this.on("publisher:error", function() {
this.open(); this.open();
this.showSpinner(false); this.showSpinner(false);
}); });
// resetting the poll view // resetting the poll view
this.on('publisher:sync', function() { this.on("publisher:sync", function() {
this.view_poll_creator.render(); this.viewPollCreator.render();
}); });
this.initSubviews(); this.initSubviews();
@ -103,7 +103,7 @@ app.views.Publisher = Backbone.View.extend({
}, },
initSubviews: function() { initSubviews: function() {
var form = this.$('.content_creation form'); var form = this.$(".content_creation form");
this.view_services = new app.views.PublisherServices({ this.view_services = new app.views.PublisherServices({
el: this.$('#publisher_service_icons'), el: this.$('#publisher_service_icons'),
@ -111,48 +111,48 @@ app.views.Publisher = Backbone.View.extend({
form: form form: form
}); });
this.view_aspect_selector = new app.views.PublisherAspectSelector({ this.viewAspectSelector = new app.views.PublisherAspectSelector({
el: this.$('.public_toggle .aspect_dropdown'), el: this.$(".public_toggle .aspect_dropdown"),
form: form form: form
}); });
this.view_getting_started = new app.views.PublisherGettingStarted({ this.viewGettingStarted = new app.views.PublisherGettingStarted({
el_first_msg: this.el_input, firstMessageEl: this.inputEl,
el_visibility: this.$('.public_toggle .aspect_dropdown > .dropdown-toggle'), visibilityEl: this.$(".public_toggle .aspect_dropdown > .dropdown-toggle"),
el_stream: $('#gs-shim') streamEl: $("#gs-shim")
}); });
this.view_uploader = new app.views.PublisherUploader({ this.viewUploader = new app.views.PublisherUploader({
el: this.$('#file-upload'), el: this.$("#file-upload"),
publisher: this 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({ this.viewPollCreator = new app.views.PublisherPollCreator({
el: this.$('#poll_creator_container') el: this.$("#poll_creator_container")
}); });
this.view_poll_creator.on('change', this.checkSubmitAvailability, this); this.viewPollCreator.on("change", this.checkSubmitAvailability, this);
this.view_poll_creator.render(); this.viewPollCreator.render();
}, },
// set the selected aspects in the dropdown by their ids // set the selected aspects in the dropdown by their ids
setSelectedAspects: function(ids) { setSelectedAspects: function(ids) {
this.view_aspect_selector.updateAspectsSelector(ids); this.viewAspectSelector.updateAspectsSelector(ids);
}, },
// inject content into the publisher textarea // inject content into the publisher textarea
setText: function(txt) { setText: function(txt) {
this.el_input.val(txt); this.inputEl.val(txt);
this.el_hiddenInput.val(txt); this.hiddenInputEl.val(txt);
this.prefillText = txt; this.prefillText = txt;
this.el_input.trigger('input'); this.inputEl.trigger("input");
this.handleTextchange(); this.handleTextchange();
}, },
// show the "getting started" popups around the publisher // show the "getting started" popups around the publisher
triggerGettingStarted: function() { triggerGettingStarted: function() {
this.view_getting_started.show(); this.viewGettingStarted.show();
}, },
createStatusMessage : function(evt) { 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 // 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 // typing in the last box. We'll delete the last one to avoid submitting an
// empty poll answer and failing validation. // empty poll answer and failing validation.
this.view_poll_creator.removeLastAnswer(); this.viewPollCreator.removeLastAnswer();
//add missing mentions at end of post: //add missing mentions at end of post:
this.handleTextchange(); this.handleTextchange();
@ -175,7 +175,9 @@ app.views.Publisher = Backbone.View.extend({
// lulz this code should be killed. // lulz this code should be killed.
var statusMessage = new app.models.Post(); var statusMessage = new app.models.Post();
if( app.publisher ) app.publisher.trigger('publisher:add'); if( app.publisher ) {
app.publisher.trigger("publisher:add");
}
statusMessage.save({ statusMessage.save({
"status_message" : { "status_message" : {
@ -192,9 +194,9 @@ app.views.Publisher = Backbone.View.extend({
url : "/status_messages", url : "/status_messages",
success : function() { success : function() {
if( app.publisher ) { if( app.publisher ) {
app.publisher.$el.trigger('ajax:success'); app.publisher.$el.trigger("ajax:success");
app.publisher.trigger('publisher:sync'); app.publisher.trigger("publisher:sync");
self.view_poll_creator.trigger('publisher:sync'); self.viewPollCreator.trigger("publisher:sync");
} }
if(app.stream && !self.standalone){ if(app.stream && !self.standalone){
@ -208,9 +210,11 @@ app.views.Publisher = Backbone.View.extend({
if( self.standalone ) self.setEnabled(false); if( self.standalone ) self.setEnabled(false);
}, },
error: function(model, resp) { error: function(model, resp) {
if( app.publisher ) app.publisher.trigger('publisher:error'); if( app.publisher ) {
app.publisher.trigger("publisher:error");
}
self.setInputEnabled(true); 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.setButtonsEnabled(true);
self.setInputEnabled(true); self.setInputEnabled(true);
} }
@ -219,9 +223,9 @@ app.views.Publisher = Backbone.View.extend({
// creates the location // creates the location
showLocation: function(){ showLocation: function(){
if($('#location').length === 0){ if($("#location").length === 0){
$('#location_container').append('<div id="location"></div>'); $("#location_container").append("<div id=\"location\"></div>");
this.el_wrapper.addClass('with_location'); this.wrapperEl.addClass("with_location");
this.view_locator = new app.views.Location(); this.view_locator = new app.views.Location();
} }
}, },
@ -230,14 +234,14 @@ app.views.Publisher = Backbone.View.extend({
destroyLocation: function(){ destroyLocation: function(){
if(this.view_locator){ if(this.view_locator){
this.view_locator.remove(); this.view_locator.remove();
this.el_wrapper.removeClass('with_location'); this.wrapperEl.removeClass("with_location");
delete this.view_locator; delete this.view_locator;
} }
}, },
togglePollCreator: function(){ togglePollCreator: function(){
this.view_poll_creator.$el.toggle(); this.viewPollCreator.$el.toggle();
this.el_input.focus(); this.inputEl.focus();
}, },
// avoid submitting form when pressing Enter key // 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 serializedForm = $(evt.target).closest("form").serializeObject();
var photos = []; var photos = [];
$('li.publisher_photo img').each(function(){ $("li.publisher_photo img").each(function(){
var file = $(this).attr('src').substring("/uploads/images/".length); var file = $(this).attr("src").substring("/uploads/images/".length);
photos.push( photos.push(
{ {
"sizes":{ "sizes":{
@ -295,18 +299,20 @@ app.views.Publisher = Backbone.View.extend({
var date = (new Date()).toISOString(); var date = (new Date()).toISOString();
var poll; var poll;
var poll_question = serializedForm["poll_question"]; var pollQuestion = serializedForm.poll_question;
var poll_answers_arry = _.flatten([serializedForm["poll_answers[]"]]); var pollAnswersArray = _.flatten([serializedForm["poll_answers[]"]]);
var poll_answers = _.map(poll_answers_arry, function(answer){ var pollAnswers = _.map(pollAnswersArray, function(answer){
if(answer) return { 'answer' : 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 = { poll = {
'question': poll_question, "question": pollQuestion,
'poll_answers' : poll_answers, "poll_answers" : pollAnswers,
'participation_count': '0' "participation_count": "0"
}; };
} }
@ -324,30 +330,30 @@ app.views.Publisher = Backbone.View.extend({
"title" : serializedForm["status_message[text]"], "title" : serializedForm["status_message[text]"],
"address" : $("#location_address").val(), "address" : $("#location_address").val(),
"interactions" : {"likes":[],"reshares":[],"comments_count":0,"likes_count":0,"reshares_count":0}, "interactions" : {"likes":[],"reshares":[],"comments_count":0,"likes_count":0,"reshares_count":0},
'poll': poll "poll": poll
}; };
if(app.stream) { if(app.stream) {
this.removePostPreview(); this.removePostPreview();
app.stream.addNow(previewMessage); app.stream.addNow(previewMessage);
this.recentPreview=previewMessage; this.recentPreview=previewMessage;
this.modifyPostPreview($('.stream_element:first',$('.stream_container'))); this.modifyPostPreview($(".stream_element:first",$(".stream_container")));
} }
}, },
modifyPostPreview : function(post) { modifyPostPreview : function(post) {
post.addClass('post_preview'); post.addClass("post_preview");
$('.collapsible',post).removeClass('collapsed').addClass('opened'); $(".collapsible",post).removeClass("collapsed").addClass("opened");
$('a.delete.remove_post',post).hide(); $("a.delete.remove_post",post).hide();
$('a.like, a.focus_comment_textarea',post).removeAttr("href"); $("a.like, a.focus_comment_textarea",post).removeAttr("href");
$('a.like',post).addClass("like_preview"); $("a.like",post).addClass("like_preview");
$('a.like',post).removeClass("like"); $("a.like",post).removeClass("like");
$('a.focus_comment_textarea',post).addClass("focus_comment_textarea_preview"); $("a.focus_comment_textarea",post).addClass("focus_comment_textarea_preview");
$('a.focus_comment_textarea',post).removeClass("focus_comment_textarea"); $("a.focus_comment_textarea",post).removeClass("focus_comment_textarea");
$('a',$('span.details.grey',post)).removeAttr("href"); $("a",$("span.details.grey",post)).removeAttr("href");
}, },
removePostPreview : function() { removePostPreview : function() {
if(app.stream && this.recentPreview){ if(app.stream && this.recentPreview) {
app.stream.items.remove(this.recentPreview); app.stream.items.remove(this.recentPreview);
delete this.recentPreview; delete this.recentPreview;
} }
@ -363,21 +369,21 @@ app.views.Publisher = Backbone.View.extend({
clear : function() { clear : function() {
// clear text(s) // clear text(s)
this.el_input.val(''); this.inputEl.val("");
this.el_hiddenInput.val(''); this.hiddenInputEl.val("");
this.el_input.trigger('keyup') this.inputEl.trigger("keyup")
.trigger('keydown'); .trigger("keydown");
// remove mentions // remove mentions
this.el_input.mentionsInput('reset'); this.inputEl.mentionsInput("reset");
// remove photos // remove photos
this.el_photozone.find('li').remove(); this.photozoneEl.find("li").remove();
this.$("input[name='photos[]']").remove(); this.$("input[name='photos[]']").remove();
this.el_wrapper.removeClass("with_attachments"); this.wrapperEl.removeClass("with_attachments");
// empty upload-photo // empty upload-photo
this.$('#fileInfo').empty(); this.$("#fileInfo").empty();
// close publishing area (CSS) // close publishing area (CSS)
this.close(); this.close();
@ -401,11 +407,11 @@ app.views.Publisher = Backbone.View.extend({
this.destroyLocation(); this.destroyLocation();
// clear poll form // clear poll form
this.view_poll_creator.clearInputs(); this.viewPollCreator.clearInputs();
// force textchange plugin to update lastValue // force textchange plugin to update lastValue
this.el_input.data('lastValue', ''); this.inputEl.data("lastValue", "");
this.el_hiddenInput.data('lastValue', ''); this.hiddenInputEl.data("lastValue", "");
return this; return this;
}, },
@ -421,8 +427,8 @@ app.views.Publisher = Backbone.View.extend({
if( this.disabled ) return; if( this.disabled ) return;
// visually 'open' the publisher // visually 'open' the publisher
this.$el.removeClass('closed'); this.$el.removeClass("closed");
this.el_wrapper.addClass('active'); this.wrapperEl.addClass("active");
// fetch contacts for mentioning // fetch contacts for mentioning
Mentions.fetchContacts(); Mentions.fetchContacts();
@ -431,17 +437,19 @@ app.views.Publisher = Backbone.View.extend({
close : function() { close : function() {
$(this.el).addClass("closed"); $(this.el).addClass("closed");
this.el_wrapper.removeClass("active"); this.wrapperEl.removeClass("active");
this.el_input.css('height', ''); this.inputEl.css("height", "");
this.view_poll_creator.$el.hide(); this.viewPollCreator.$el.hide();
return this; return this;
}, },
showSpinner: function(bool) { showSpinner: function(bool) {
if (bool) if (bool) {
this.$('#publisher_spinner').removeClass('hidden'); this.$("#publisher_spinner").removeClass("hidden");
else }
this.$('#publisher_spinner').addClass('hidden'); else {
this.$("#publisher_spinner").addClass("hidden");
}
}, },
checkSubmitAvailability: function() { checkSubmitAvailability: function() {
@ -461,29 +469,29 @@ app.views.Publisher = Backbone.View.extend({
setButtonsEnabled: function(bool) { setButtonsEnabled: function(bool) {
if (bool) { if (bool) {
this.el_submit.removeProp('disabled'); this.submitEl.removeProp("disabled");
this.el_preview.removeProp('disabled'); this.previewEl.removeProp("disabled");
} else { } else {
this.el_submit.prop('disabled', true); this.submitEl.prop("disabled", true);
this.el_preview.prop('disabled', true); this.previewEl.prop("disabled", true);
} }
}, },
setInputEnabled: function(bool) { setInputEnabled: function(bool) {
if (bool) { if (bool) {
this.el_input.removeProp('disabled'); this.inputEl.removeProp("disabled");
this.el_hiddenInput.removeProp('disabled'); this.hiddenInputEl.removeProp("disabled");
} else { } else {
this.el_input.prop('disabled', true); this.inputEl.prop("disabled", true);
this.el_hiddenInput.prop('disabled', true); this.hiddenInputEl.prop("disabled", true);
} }
}, },
// determine submit availability // determine submit availability
_submittable: function() { _submittable: function() {
var onlyWhitespaces = ($.trim(this.el_input.val()) === ''), var onlyWhitespaces = ($.trim(this.inputEl.val()) === ""),
isPhotoAttached = (this.el_photozone.children().length > 0), isPhotoAttached = (this.photozoneEl.children().length > 0),
isValidPoll = this.view_poll_creator.validatePoll(); isValidPoll = this.viewPollCreator.validatePoll();
return (!onlyWhitespaces || isPhotoAttached) && isValidPoll && !this.disabled; return (!onlyWhitespaces || isPhotoAttached) && isValidPoll && !this.disabled;
}, },
@ -492,13 +500,13 @@ app.views.Publisher = Backbone.View.extend({
var self = this; var self = this;
this.checkSubmitAvailability(); this.checkSubmitAvailability();
this.el_input.mentionsInput("val", function(value){ this.inputEl.mentionsInput("val", function(value){
self.el_hiddenInput.val(value); self.hiddenInputEl.val(value);
}); });
}, },
_beforeUnload: function(e) { _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"); var confirmationMessage = Diaspora.I18n.t("confirm_unload");
(e || window.event).returnValue = confirmationMessage; //Gecko + IE (e || window.event).returnValue = confirmationMessage; //Gecko + IE
return confirmationMessage; //Webkit, Safari, Chrome, etc. return confirmationMessage; //Webkit, Safari, Chrome, etc.
@ -516,9 +524,9 @@ $.fn.serializeObject = function()
if (!o[this.name].push) { if (!o[this.name].push) {
o[this.name] = [o[this.name]]; o[this.name] = [o[this.name]];
} }
o[this.name].push(this.value || ''); o[this.name].push(this.value || "");
} else { } else {
o[this.name] = this.value || ''; o[this.name] = this.value || "";
} }
}); });
return o; return o;

View file

@ -6,7 +6,7 @@ module InvitationCodesHelper
end end
def invite_link(invite_code) 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 end
def invited_by_message def invited_by_message

View file

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

View file

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

View file

@ -15,8 +15,8 @@ describe("app.views.AspectsDropdown", function(){
context('_toggleCheckbox', function() { context('_toggleCheckbox', function() {
beforeEach(function() { beforeEach(function() {
this.view.$('li.selected').removeClass('selected'); this.view.$("li.selected").removeClass("selected");
this.view.$('li.all_aspects').addClass('selected'); this.view.$("li.all_aspects").addClass("selected");
}); });
it('deselects all radio buttons', function() { it('deselects all radio buttons', function() {
@ -45,21 +45,21 @@ describe("app.views.AspectsDropdown", function(){
}); });
it('deselects all checkboxes', function() { it('deselects all checkboxes', function() {
this.view._toggleRadio(this.view.$('li.all_aspects')); 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(0)").hasClass("selected")).toBeFalsy();
expect(this.view.$('li.aspect_selector:eq(1)').hasClass('selected')).toBeFalsy(); expect(this.view.$("li.aspect_selector:eq(1)").hasClass("selected")).toBeFalsy();
}); });
it('toggles the clicked radio buttons', function() { it('toggles the clicked radio buttons', function() {
this.view._toggleRadio(this.view.$('li.all_aspects')); this.view._toggleRadio(this.view.$("li.all_aspects"));
expect(this.view.$('li.all_aspects').hasClass('selected')).toBeTruthy(); expect(this.view.$("li.all_aspects").hasClass("selected")).toBeTruthy();
expect(this.view.$('li.public').hasClass('selected')).toBeFalsy(); expect(this.view.$("li.public").hasClass("selected")).toBeFalsy();
this.view._toggleRadio(this.view.$('li.public')); this.view._toggleRadio(this.view.$("li.public"));
expect(this.view.$('li.all_aspects').hasClass('selected')).toBeFalsy(); expect(this.view.$("li.all_aspects").hasClass("selected")).toBeFalsy();
expect(this.view.$('li.public').hasClass('selected')).toBeTruthy(); expect(this.view.$("li.public").hasClass("selected")).toBeTruthy();
this.view._toggleRadio(this.view.$('li.all_aspects')); this.view._toggleRadio(this.view.$("li.all_aspects"));
expect(this.view.$('li.all_aspects').hasClass('selected')).toBeTruthy(); expect(this.view.$("li.all_aspects").hasClass("selected")).toBeTruthy();
expect(this.view.$('li.public').hasClass('selected')).toBeFalsy(); 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() { it('shows the name of the selected radio button', function() {
this.view.$('li.all_aspects').addClass('selected'); this.view.$("li.all_aspects").addClass("selected");
this.view._updateButton('inAspectClass'); this.view._updateButton("inAspectClass");
expect(this.view.$('.btn.dropdown-toggle > .text').text()).toContain(Diaspora.I18n.t('aspect_dropdown.all_aspects')); 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() { 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 = { var test_data = {
url: 'https://www.youtube.com/watch?v=0Bmhjf0rKe8', url: "https://www.youtube.com/watch?v=0Bmhjf0rKe8",
title: 'Surprised Kitty', title: "Surprised Kitty",
notes: 'cute kitty' notes: "cute kitty"
}; };
var evil_test_data = _.extend({}, { var evil_test_data = _.extend({}, {
notes: "**love** This is such a\n\n great \"cute kitty\" '''blabla''' %28%29\\" 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) { var init_bookmarklet = function(data) {
app.bookmarklet = new app.views.Bookmarklet( app.bookmarklet = new app.views.Bookmarklet(
_.extend({el: $('#bookmarklet')}, data) _.extend({el: $("#bookmarklet")}, data)
).render(); ).render();
}; };
beforeEach(function() { beforeEach(function() {
app.stream = null; // avoid rendering posts app.stream = null; // avoid rendering posts
loginAs({name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}}); 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(); new app.views.Bookmarklet();
expect(app.publisher).not.toBeNull(); expect(app.publisher).not.toBeNull();
expect(app.publisher.standalone).toBeTruthy(); expect(app.publisher.standalone).toBeTruthy();
}); });
it('prefills the publisher', function() { it("prefills the publisher", function() {
init_bookmarklet(test_data); init_bookmarklet(test_data);
expect($.trim(app.publisher.el_input.val())).not.toEqual(''); expect($.trim(app.publisher.inputEl.val())).not.toEqual("");
expect($.trim(app.publisher.el_hiddenInput.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); init_bookmarklet(evil_test_data);
expect($.trim(app.publisher.el_input.val())).not.toEqual(''); expect($.trim(app.publisher.inputEl.val())).not.toEqual("");
expect($.trim(app.publisher.el_hiddenInput.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); 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); init_bookmarklet(test_data);
spec.content().find('form').submit(); spec.content().find("form").submit();
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
status: 200, // success! status: 200, // success!

View file

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