Merge pull request #5637 from svbergerem/add-js-linter
Add JSHint javascript linter
This commit is contained in:
commit
dce1e3c6f5
138 changed files with 1107 additions and 997 deletions
4
.hound.yml
Normal file
4
.hound.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
java_script:
|
||||
enabled: true
|
||||
config_file: config/.jshint.json
|
||||
ignore_file: config/.jshint_ignore
|
||||
5
Gemfile
5
Gemfile
|
|
@ -217,6 +217,9 @@ group :development do
|
|||
gem 'rb-fsevent', '0.9.4', :require => false
|
||||
gem 'rb-inotify', '0.9.5', :require => false
|
||||
|
||||
# Linters
|
||||
gem 'jshint', '1.3.1'
|
||||
|
||||
# Preloading environment
|
||||
|
||||
gem 'spring', '1.2.0'
|
||||
|
|
@ -261,5 +264,5 @@ group :development, :test do
|
|||
# Jasmine (client side application tests (JS))
|
||||
gem 'jasmine', '2.1.0'
|
||||
gem 'jasmine-jquery-rails', '2.0.3'
|
||||
gem 'sinon-rails', '1.10.3'
|
||||
gem 'sinon-rails', '1.10.3'
|
||||
end
|
||||
|
|
|
|||
10
Gemfile.lock
10
Gemfile.lock
|
|
@ -308,12 +308,17 @@ GEM
|
|||
sprockets-rails
|
||||
js_image_paths (0.0.1)
|
||||
rails (~> 4.0)
|
||||
jshint (1.3.1)
|
||||
execjs (>= 1.4.0)
|
||||
multi_json (~> 1.0)
|
||||
therubyracer (~> 0.12.1)
|
||||
json (1.8.1)
|
||||
jwt (1.0.0)
|
||||
kaminari (0.16.1)
|
||||
actionpack (>= 3.0.0)
|
||||
activesupport (>= 3.0.0)
|
||||
kgio (2.9.2)
|
||||
libv8 (3.16.14.7)
|
||||
listen (2.8.3)
|
||||
celluloid (>= 0.15.2)
|
||||
rb-fsevent (>= 0.9.3)
|
||||
|
|
@ -488,6 +493,7 @@ GEM
|
|||
redis (3.1.0)
|
||||
redis-namespace (1.5.1)
|
||||
redis (~> 3.0, >= 3.0.4)
|
||||
ref (1.0.5)
|
||||
remotipart (1.2.1)
|
||||
request_store (1.1.0)
|
||||
responders (1.1.2)
|
||||
|
|
@ -569,6 +575,9 @@ GEM
|
|||
systemu (2.6.4)
|
||||
test_after_commit (0.4.0)
|
||||
activerecord (>= 3.2)
|
||||
therubyracer (0.12.1)
|
||||
libv8 (~> 3.16.14.0)
|
||||
ref
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.4)
|
||||
tilt (1.4.1)
|
||||
|
|
@ -658,6 +667,7 @@ DEPENDENCIES
|
|||
jquery-rails (= 3.1.2)
|
||||
js-routes (= 0.9.9)
|
||||
js_image_paths (= 0.0.1)
|
||||
jshint (= 1.3.1)
|
||||
json (= 1.8.1)
|
||||
markerb (= 1.0.2)
|
||||
messagebus_ruby_api (= 1.0.3)
|
||||
|
|
|
|||
|
|
@ -35,8 +35,11 @@ var app = {
|
|||
events: _.extend({}, Backbone.Events),
|
||||
|
||||
user: function(userAttrs) {
|
||||
if(userAttrs) { return this._user = new app.models.User(userAttrs) }
|
||||
return this._user || false
|
||||
if(userAttrs) {
|
||||
this._user = new app.models.User(userAttrs);
|
||||
return this._user;
|
||||
}
|
||||
return this._user || false;
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
|
|
@ -52,25 +55,25 @@ var app = {
|
|||
},
|
||||
|
||||
hasPreload : function(prop) {
|
||||
return !!(window.gon.preloads && window.gon.preloads[prop]) //returning boolean variable so that parsePreloads, which cleans up properly is used instead
|
||||
return !!(window.gon.preloads && window.gon.preloads[prop]); //returning boolean variable so that parsePreloads, which cleans up properly is used instead
|
||||
},
|
||||
|
||||
setPreload : function(prop, val) {
|
||||
window.gon.preloads = window.gon.preloads || {}
|
||||
window.gon.preloads[prop] = val
|
||||
window.gon.preloads = window.gon.preloads || {};
|
||||
window.gon.preloads[prop] = val;
|
||||
},
|
||||
|
||||
parsePreload : function(prop) {
|
||||
if(!app.hasPreload(prop)) { return }
|
||||
|
||||
var preload = window.gon.preloads[prop]
|
||||
delete window.gon.preloads[prop] //prevent dirty state across navigates
|
||||
var preload = window.gon.preloads[prop];
|
||||
delete window.gon.preloads[prop]; //prevent dirty state across navigates
|
||||
|
||||
return(preload)
|
||||
return(preload);
|
||||
},
|
||||
|
||||
setupDummyPreloads: function() {
|
||||
if (window.gon == undefined) {
|
||||
if (window.gon === undefined) {
|
||||
window.gon = {preloads:{}};
|
||||
}
|
||||
},
|
||||
|
|
@ -101,8 +104,8 @@ var app = {
|
|||
evt.preventDefault();
|
||||
var link = $(this);
|
||||
|
||||
$(".stream_title").text(link.text())
|
||||
app.router.navigate(link.attr("href").substring(1) ,true)
|
||||
$(".stream_title").text(link.text());
|
||||
app.router.navigate(link.attr("href").substring(1) ,true);
|
||||
});
|
||||
},
|
||||
|
||||
|
|
@ -118,7 +121,7 @@ var app = {
|
|||
/* mixpanel wrapper function */
|
||||
instrument : function(type, name, object, callback) {
|
||||
if(!window.mixpanel) { return }
|
||||
window.mixpanel[type](name, object, callback)
|
||||
window.mixpanel[type](name, object, callback);
|
||||
},
|
||||
|
||||
setupDisabledLinks: function() {
|
||||
|
|
@ -132,4 +135,3 @@ $(function() {
|
|||
app.initialize();
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@
|
|||
|
||||
app.collections.AspectMemberships = Backbone.Collection.extend({
|
||||
model: app.models.AspectMembership
|
||||
})
|
||||
});
|
||||
// @license-end
|
||||
|
|
|
|||
|
|
@ -25,6 +25,5 @@ app.collections.Aspects = Backbone.Collection.extend({
|
|||
var separator = Diaspora.I18n.t("comma") + ' ';
|
||||
return this.selectedAspects('name').join(separator).replace(/,\s([^,]+)$/, ' ' + Diaspora.I18n.t("and") + ' $1') || Diaspora.I18n.t("my_aspects");
|
||||
}
|
||||
})
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ app.collections.Comments = Backbone.Collection.extend({
|
|||
var deferred = comment.save({}, {
|
||||
url: '/posts/'+this.post.id+'/comments',
|
||||
success: function() {
|
||||
comment.set({author: app.currentUser.toJSON(), parent: self.post })
|
||||
self.add(comment)
|
||||
comment.set({author: app.currentUser.toJSON(), parent: self.post });
|
||||
self.add(comment);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -25,4 +25,3 @@ app.collections.Comments = Backbone.Collection.extend({
|
|||
}
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ app.collections.Likes = Backbone.Collection.extend({
|
|||
model: app.models.Like,
|
||||
|
||||
initialize : function(models, options) {
|
||||
this.url = "/posts/" + options.post.id + "/likes" //not delegating to post.url() because when it is in a stream collection it delegates to that url
|
||||
this.url = "/posts/" + options.post.id + "/likes"; //not delegating to post.url() because when it is in a stream collection it delegates to that url
|
||||
}
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ app.collections.Photos = Backbone.Collection.extend({
|
|||
url : "/photos",
|
||||
|
||||
model: function(attrs, options) {
|
||||
var modelClass = app.models.Photo
|
||||
var modelClass = app.models.Photo;
|
||||
return new modelClass(attrs, options);
|
||||
},
|
||||
|
||||
|
|
@ -13,4 +13,3 @@ app.collections.Photos = Backbone.Collection.extend({
|
|||
}
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
return timestamp || 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
})();
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
|
||||
|
||||
Handlebars.registerHelper('t', function(scope, values) {
|
||||
return Diaspora.I18n.t(scope, values.hash)
|
||||
return Diaspora.I18n.t(scope, values.hash);
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('txtDirClass', function(str) {
|
||||
|
|
@ -29,7 +29,7 @@ Handlebars.registerHelper('linkToAuthor', function(context, block) {
|
|||
html += block.fn(context);
|
||||
html += "</a>";
|
||||
|
||||
return html
|
||||
return html;
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('linkToPerson', function(context, block) {
|
||||
|
|
@ -38,7 +38,7 @@ Handlebars.registerHelper('linkToPerson', function(context, block) {
|
|||
html += block.fn(context);
|
||||
html += "</a>";
|
||||
|
||||
return html
|
||||
return html;
|
||||
});
|
||||
|
||||
// relationship indicator for profile page
|
||||
|
|
@ -61,7 +61,7 @@ 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 ) {
|
||||
if( app.currentUser.get('guid') !== person.guid ) {
|
||||
return 'hovercardable';
|
||||
}
|
||||
return '';
|
||||
|
|
@ -104,7 +104,7 @@ Handlebars.registerHelper('fmtText', function(text) {
|
|||
|
||||
Handlebars.registerHelper('isCurrentPage', function(path_helper, id, options){
|
||||
var currentPage = "/"+Backbone.history.fragment;
|
||||
if (currentPage == Handlebars.helpers.urlTo(path_helper, id, options.data)) {
|
||||
if (currentPage === Handlebars.helpers.urlTo(path_helper, id, options.data)) {
|
||||
return options.fn(this);
|
||||
} else {
|
||||
return options.inverse(this);
|
||||
|
|
@ -121,7 +121,7 @@ Handlebars.registerHelper('aspectMembershipIndicator', function(contact,in_aspec
|
|||
if(!app.aspect || !app.aspect.get('id')) return '<div class="aspect_membership_dropdown placeholder"></div>';
|
||||
|
||||
var html = '<i class="entypo ';
|
||||
if( in_aspect == 'in_aspect' ) {
|
||||
if( in_aspect === 'in_aspect' ) {
|
||||
html += 'circled-cross contact_remove-from-aspect" ';
|
||||
html += 'title="' + Diaspora.I18n.t('contacts.remove_contact') + '" ';
|
||||
} else {
|
||||
|
|
@ -132,4 +132,3 @@ Handlebars.registerHelper('aspectMembershipIndicator', function(contact,in_aspec
|
|||
return html;
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
/* we need to wrap this in a document ready to ensure JST is accessible */
|
||||
$(function(){
|
||||
Handlebars.registerPartial('status-message', HandlebarsTemplates['status-message_tpl'])
|
||||
Handlebars.registerPartial('status-message', HandlebarsTemplates['status-message_tpl']);
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -6,13 +6,12 @@
|
|||
if (!o_embed_cache) { return "" }
|
||||
|
||||
var data = o_embed_cache.data;
|
||||
if (data.type == "photo") {
|
||||
return '<img src="' + data.url + '" width="' + data.width + '" height="' + data.height + '" />'
|
||||
if (data.type === "photo") {
|
||||
return '<img src="' + data.url + '" width="' + data.width + '" height="' + data.height + '" />';
|
||||
} else {
|
||||
return data.html || ""
|
||||
return data.html || "";
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
})();
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
var punycodeURL = function(url){
|
||||
try {
|
||||
while(url.indexOf("%") !== -1 && url != decodeURI(url)) url = decodeURI(url);
|
||||
while(url.indexOf("%") !== -1 && url !== decodeURI(url)) url = decodeURI(url);
|
||||
}
|
||||
catch(e){}
|
||||
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
url = // rebuild the url
|
||||
(!addr.scheme ? '' : addr.scheme +
|
||||
( (addr.scheme.toLowerCase()=="mailto" || addr.scheme.toLowerCase()=="xmpp") ? ':' : '://')) +
|
||||
( (addr.scheme.toLowerCase() === "mailto" || addr.scheme.toLowerCase() === "xmpp") ? ':' : '://')) +
|
||||
(!addr.user ? '' : addr.user +
|
||||
(!addr.pass ? '' : ':'+addr.pass) + '@') +
|
||||
punycode.toASCII(addr.host) +
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
(function() {
|
||||
app.helpers.truncate = function(passedString, length) {
|
||||
if (passedString == null || passedString == undefined) {
|
||||
if (passedString === null || passedString === undefined) {
|
||||
return passedString;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ app.models.Contact = Backbone.Model.extend({
|
|||
},
|
||||
|
||||
inAspect : function(id) {
|
||||
return this.aspect_memberships.any(function(membership){ return membership.get('aspect').id == id; });
|
||||
return this.aspect_memberships.any(function(membership){ return membership.get('aspect').id === id; });
|
||||
}
|
||||
});
|
||||
// @license-end
|
||||
|
|
|
|||
|
|
@ -12,20 +12,20 @@ app.models.Person = Backbone.Model.extend({
|
|||
|
||||
isSharing: function() {
|
||||
var rel = this.get('relationship');
|
||||
return (rel == 'mutual' || rel == 'sharing');
|
||||
return (rel === 'mutual' || rel === 'sharing');
|
||||
},
|
||||
|
||||
isReceiving: function() {
|
||||
var rel = this.get('relationship');
|
||||
return (rel == 'mutual' || rel == 'receiving');
|
||||
return (rel === 'mutual' || rel === 'receiving');
|
||||
},
|
||||
|
||||
isMutual: function() {
|
||||
return (this.get('relationship') == 'mutual');
|
||||
return (this.get('relationship') === 'mutual');
|
||||
},
|
||||
|
||||
isBlocked: function() {
|
||||
return (this.get('relationship') == 'blocked');
|
||||
return (this.get('relationship') === 'blocked');
|
||||
},
|
||||
|
||||
block: function() {
|
||||
|
|
|
|||
|
|
@ -4,17 +4,17 @@ app.models.Post = Backbone.Model.extend(_.extend({}, app.models.formatDateMixin,
|
|||
urlRoot : "/posts",
|
||||
|
||||
initialize : function() {
|
||||
this.interactions = new app.models.Post.Interactions(_.extend({post : this}, this.get("interactions")))
|
||||
this.delegateToInteractions()
|
||||
this.interactions = new app.models.Post.Interactions(_.extend({post : this}, this.get("interactions")));
|
||||
this.delegateToInteractions();
|
||||
},
|
||||
|
||||
delegateToInteractions : function(){
|
||||
this.comments = this.interactions.comments
|
||||
this.likes = this.interactions.likes
|
||||
this.comments = this.interactions.comments;
|
||||
this.likes = this.interactions.likes;
|
||||
|
||||
this.comment = function(){
|
||||
this.interactions.comment.apply(this.interactions, arguments)
|
||||
}
|
||||
this.interactions.comment.apply(this.interactions, arguments);
|
||||
};
|
||||
},
|
||||
|
||||
interactedAt : function() {
|
||||
|
|
@ -22,11 +22,12 @@ app.models.Post = Backbone.Model.extend(_.extend({}, app.models.formatDateMixin,
|
|||
},
|
||||
|
||||
reshare : function(){
|
||||
return this._reshare = this._reshare || new app.models.Reshare({root_guid : this.get("guid")});
|
||||
this._reshare = this._reshare || new app.models.Reshare({root_guid : this.get("guid")});
|
||||
return this._reshare;
|
||||
},
|
||||
|
||||
reshareAuthor : function(){
|
||||
return this.get("author")
|
||||
return this.get("author");
|
||||
},
|
||||
|
||||
blockAuthor: function() {
|
||||
|
|
@ -38,7 +39,7 @@ app.models.Post = Backbone.Model.extend(_.extend({}, app.models.formatDateMixin,
|
|||
},
|
||||
|
||||
toggleFavorite : function(options){
|
||||
this.set({favorite : !this.get("favorite")})
|
||||
this.set({favorite : !this.get("favorite")});
|
||||
|
||||
/* guard against attempting to save a model that a user doesn't own */
|
||||
if(options.save){ this.save() }
|
||||
|
|
@ -46,28 +47,28 @@ app.models.Post = Backbone.Model.extend(_.extend({}, app.models.formatDateMixin,
|
|||
|
||||
headline : function() {
|
||||
var headline = this.get("text").trim()
|
||||
, newlineIdx = headline.indexOf("\n")
|
||||
return (newlineIdx > 0 ) ? headline.substr(0, newlineIdx) : headline
|
||||
, newlineIdx = headline.indexOf("\n");
|
||||
return (newlineIdx > 0 ) ? headline.substr(0, newlineIdx) : headline;
|
||||
},
|
||||
|
||||
body : function(){
|
||||
var body = this.get("text").trim()
|
||||
, newlineIdx = body.indexOf("\n")
|
||||
return (newlineIdx > 0 ) ? body.substr(newlineIdx+1, body.length) : ""
|
||||
, newlineIdx = body.indexOf("\n");
|
||||
return (newlineIdx > 0 ) ? body.substr(newlineIdx+1, body.length) : "";
|
||||
},
|
||||
|
||||
//returns a promise
|
||||
preloadOrFetch : function(){
|
||||
var action = app.hasPreload("post") ? this.set(app.parsePreload("post")) : this.fetch()
|
||||
return $.when(action)
|
||||
var action = app.hasPreload("post") ? this.set(app.parsePreload("post")) : this.fetch();
|
||||
return $.when(action);
|
||||
},
|
||||
|
||||
hasPhotos : function(){
|
||||
return this.get("photos") && this.get("photos").length > 0
|
||||
return this.get("photos") && this.get("photos").length > 0;
|
||||
},
|
||||
|
||||
hasText : function(){
|
||||
return $.trim(this.get("text")) !== ""
|
||||
return $.trim(this.get("text")) !== "";
|
||||
}
|
||||
}));
|
||||
// @license-end
|
||||
|
|
|
|||
|
|
@ -4,137 +4,136 @@
|
|||
|
||||
app.models.Post.Interactions = Backbone.Model.extend({
|
||||
url : function(){
|
||||
return this.post.url() + "/interactions"
|
||||
return this.post.url() + "/interactions";
|
||||
},
|
||||
|
||||
initialize : function(options){
|
||||
this.post = options.post
|
||||
this.comments = new app.collections.Comments(this.get("comments"), {post : this.post})
|
||||
this.post = options.post;
|
||||
this.comments = new app.collections.Comments(this.get("comments"), {post : this.post});
|
||||
this.likes = new app.collections.Likes(this.get("likes"), {post : this.post});
|
||||
this.reshares = new app.collections.Reshares(this.get("reshares"), {post : this.post});
|
||||
},
|
||||
|
||||
parse : function(resp){
|
||||
this.comments.reset(resp.comments)
|
||||
this.likes.reset(resp.likes)
|
||||
this.reshares.reset(resp.reshares)
|
||||
this.comments.reset(resp.comments);
|
||||
this.likes.reset(resp.likes);
|
||||
this.reshares.reset(resp.reshares);
|
||||
|
||||
var comments = this.comments
|
||||
, likes = this.likes
|
||||
, reshares = this.reshares
|
||||
, reshares = this.reshares;
|
||||
|
||||
return {
|
||||
comments : comments,
|
||||
likes : likes,
|
||||
reshares : reshares,
|
||||
fetched : true
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
likesCount : function(){
|
||||
return (this.get("fetched") ? this.likes.models.length : this.get("likes_count") )
|
||||
return (this.get("fetched") ? this.likes.models.length : this.get("likes_count") );
|
||||
},
|
||||
|
||||
resharesCount : function(){
|
||||
return this.get("fetched") ? this.reshares.models.length : this.get("reshares_count")
|
||||
return this.get("fetched") ? this.reshares.models.length : this.get("reshares_count");
|
||||
},
|
||||
|
||||
commentsCount : function(){
|
||||
return this.get("fetched") ? this.comments.models.length : this.get("comments_count")
|
||||
return this.get("fetched") ? this.comments.models.length : this.get("comments_count");
|
||||
},
|
||||
|
||||
userLike : function(){
|
||||
return this.likes.select(function(like){ return like.get("author").guid == app.currentUser.get("guid")})[0]
|
||||
return this.likes.select(function(like){ return like.get("author").guid === app.currentUser.get("guid")})[0];
|
||||
},
|
||||
|
||||
userReshare : function(){
|
||||
return this.reshares.select(function(reshare){
|
||||
return reshare.get("author") && reshare.get("author").guid == app.currentUser.get("guid")})[0]
|
||||
return reshare.get("author") && reshare.get("author").guid === app.currentUser.get("guid")})[0];
|
||||
},
|
||||
|
||||
toggleLike : function() {
|
||||
if(this.userLike()) {
|
||||
this.unlike()
|
||||
this.unlike();
|
||||
} else {
|
||||
this.like()
|
||||
this.like();
|
||||
}
|
||||
},
|
||||
|
||||
like : function() {
|
||||
var self = this;
|
||||
this.likes.create({}, {success : function(){
|
||||
self.trigger("change")
|
||||
self.set({"likes_count" : self.get("likes_count") + 1})
|
||||
}})
|
||||
self.trigger("change");
|
||||
self.set({"likes_count" : self.get("likes_count") + 1});
|
||||
}});
|
||||
|
||||
app.instrument("track", "Like")
|
||||
app.instrument("track", "Like");
|
||||
},
|
||||
|
||||
unlike : function() {
|
||||
var self = this;
|
||||
this.userLike().destroy({success : function(model, resp) {
|
||||
self.trigger('change')
|
||||
self.set({"likes_count" : self.get("likes_count") - 1})
|
||||
this.userLike().destroy({success : function() {
|
||||
self.trigger('change');
|
||||
self.set({"likes_count" : self.get("likes_count") - 1});
|
||||
}});
|
||||
|
||||
app.instrument("track", "Unlike")
|
||||
app.instrument("track", "Unlike");
|
||||
},
|
||||
|
||||
comment : function (text) {
|
||||
var self = this;
|
||||
|
||||
this.comments.make(text).fail(function () {
|
||||
flash = new Diaspora.Widgets.FlashMessages;
|
||||
var flash = new Diaspora.Widgets.FlashMessages();
|
||||
flash.render({
|
||||
success: false,
|
||||
notice: Diaspora.I18n.t("failed_to_post_message")
|
||||
});
|
||||
}).done(function() {
|
||||
self.trigger('change') //updates after sync
|
||||
self.trigger('change'); //updates after sync
|
||||
});
|
||||
|
||||
this.trigger("change") //updates count in an eager manner
|
||||
this.trigger("change"); //updates count in an eager manner
|
||||
|
||||
app.instrument("track", "Comment")
|
||||
app.instrument("track", "Comment");
|
||||
},
|
||||
|
||||
reshare : function(){
|
||||
var interactions = this
|
||||
, reshare = this.post.reshare()
|
||||
, flash = new Diaspora.Widgets.FlashMessages;
|
||||
, flash = new Diaspora.Widgets.FlashMessages();
|
||||
|
||||
reshare.save({}, {
|
||||
success : function(resp){
|
||||
success : function(){
|
||||
flash.render({
|
||||
success: true,
|
||||
notice: Diaspora.I18n.t("reshares.successful")
|
||||
});
|
||||
},
|
||||
error: function(resp){
|
||||
error: function(){
|
||||
flash.render({
|
||||
success: false,
|
||||
notice: Diaspora.I18n.t("reshares.duplicate")
|
||||
});
|
||||
}
|
||||
}).done(function(){
|
||||
interactions.reshares.add(reshare)
|
||||
interactions.reshares.add(reshare);
|
||||
}).done(function(){
|
||||
interactions.trigger("change")
|
||||
interactions.trigger("change");
|
||||
});
|
||||
|
||||
app.instrument("track", "Reshare")
|
||||
app.instrument("track", "Reshare");
|
||||
},
|
||||
|
||||
userCanReshare : function(){
|
||||
var isReshare = this.post.get("post_type") == "Reshare"
|
||||
var isReshare = this.post.get("post_type") === "Reshare"
|
||||
, rootExists = (isReshare ? this.post.get("root") : true)
|
||||
, publicPost = this.post.get("public")
|
||||
, userIsNotAuthor = this.post.get("author").diaspora_id != app.currentUser.get("diaspora_id")
|
||||
, userIsNotRootAuthor = rootExists && (isReshare ? this.post.get("root").author.diaspora_id != app.currentUser.get("diaspora_id") : true)
|
||||
, userIsNotAuthor = this.post.get("author").diaspora_id !== app.currentUser.get("diaspora_id")
|
||||
, userIsNotRootAuthor = rootExists && (isReshare ? this.post.get("root").author.diaspora_id !== app.currentUser.get("diaspora_id") : true)
|
||||
, notReshared = !this.userReshare();
|
||||
|
||||
return publicPost && app.currentUser.authenticated() && userIsNotAuthor && userIsNotRootAuthor && notReshared;
|
||||
}
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -5,19 +5,19 @@ app.models.Profile = Backbone.Model.extend({
|
|||
}, {
|
||||
|
||||
preloadOrFetch : function(id){
|
||||
return app.hasPreload("person") ? this.preload() : this.findByGuid(id)
|
||||
return app.hasPreload("person") ? this.preload() : this.findByGuid(id);
|
||||
},
|
||||
|
||||
preload : function(){
|
||||
var person = new app.models.Profile(app.parsePreload("person"))
|
||||
person.deferred = $.when(true)
|
||||
return person
|
||||
var person = new app.models.Profile(app.parsePreload("person"));
|
||||
person.deferred = $.when(true);
|
||||
return person;
|
||||
},
|
||||
|
||||
findByGuid : function(personId){
|
||||
var person = new app.models.Profile({ id : personId})
|
||||
person.deferred = person.fetch()
|
||||
return person
|
||||
var person = new app.models.Profile({ id : personId});
|
||||
person.deferred = person.fetch();
|
||||
return person;
|
||||
}
|
||||
});
|
||||
// @license-end
|
||||
|
|
|
|||
|
|
@ -5,15 +5,15 @@ app.models.Reshare = app.models.Post.extend({
|
|||
|
||||
rootPost : function(){
|
||||
this._rootPost = this._rootPost || new app.models.Post(this.get("root"));
|
||||
return this._rootPost
|
||||
return this._rootPost;
|
||||
},
|
||||
|
||||
reshare : function(){
|
||||
return this.rootPost().reshare()
|
||||
return this.rootPost().reshare();
|
||||
},
|
||||
|
||||
reshareAuthor : function(){
|
||||
return this.rootPost().reshareAuthor()
|
||||
return this.rootPost().reshareAuthor();
|
||||
}
|
||||
});
|
||||
// @license-end
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ app.models.StatusMessage = app.models.Post.extend({
|
|||
photos : this.photos && this.photos.pluck("id"),
|
||||
services : this.get("services"),
|
||||
poll : this.get("poll")
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
// @license-end
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
//= require ../collections/photos
|
||||
app.models.Stream = Backbone.Collection.extend({
|
||||
initialize : function(models, options){
|
||||
var collectionClass = app.collections.Posts
|
||||
var collectionClass = app.collections.Posts;
|
||||
if( options ) {
|
||||
options.collection && (collectionClass = options.collection);
|
||||
options.basePath && (this.streamPath = options.basePath);
|
||||
|
|
@ -14,11 +14,11 @@ app.models.Stream = Backbone.Collection.extend({
|
|||
|
||||
collectionOptions :function(){
|
||||
var order = this.sortOrder();
|
||||
return { comparator : function(item) { return -item[order](); } }
|
||||
return { comparator : function(item) { return -item[order](); } };
|
||||
},
|
||||
|
||||
url : function(){
|
||||
return _.any(this.items.models) ? this.timeFilteredPath() : this.basePath()
|
||||
return _.any(this.items.models) ? this.timeFilteredPath() : this.basePath();
|
||||
},
|
||||
|
||||
_fetchOpts: function(opts) {
|
||||
|
|
@ -35,14 +35,14 @@ app.models.Stream = Backbone.Collection.extend({
|
|||
},
|
||||
|
||||
isFetching : function() {
|
||||
return (this.deferred && this.deferred.state() == "pending");
|
||||
return (this.deferred && this.deferred.state() === "pending");
|
||||
},
|
||||
|
||||
triggerFetchedEvents : function(resp){
|
||||
this.trigger("fetched", this);
|
||||
// all loaded?
|
||||
var respItems = this.items.parse(resp);
|
||||
if(respItems && (respItems.author || respItems.length == 0)) {
|
||||
if(respItems && (respItems.author || respItems.length === 0)) {
|
||||
this.trigger("allItemsLoaded", this);
|
||||
}
|
||||
},
|
||||
|
|
@ -57,11 +57,11 @@ app.models.Stream = Backbone.Collection.extend({
|
|||
|
||||
maxTime: function(){
|
||||
var lastPost = _.last(this.items.models);
|
||||
return lastPost[this.sortOrder()]()
|
||||
return lastPost[this.sortOrder()]();
|
||||
},
|
||||
|
||||
sortOrder : function() {
|
||||
return this.basePath().match(/activity/) ? "interactedAt" : "createdAt"
|
||||
return this.basePath().match(/activity/) ? "interactedAt" : "createdAt";
|
||||
},
|
||||
|
||||
/* This function is for adding a large number of posts one by one.
|
||||
|
|
@ -71,7 +71,7 @@ app.models.Stream = Backbone.Collection.extend({
|
|||
* stream for the changes to take effect in the infinite stream view
|
||||
*/
|
||||
add : function(models){
|
||||
this.items.add(models)
|
||||
this.items.add(models);
|
||||
},
|
||||
|
||||
/* This function is for adding a single post. It immediately triggers
|
||||
|
|
@ -84,14 +84,13 @@ app.models.Stream = Backbone.Collection.extend({
|
|||
},
|
||||
|
||||
preloadOrFetch : function(){ //hai, plz test me THNX
|
||||
return $.when(app.hasPreload("stream") ? this.preload() : this.fetch())
|
||||
return $.when(app.hasPreload("stream") ? this.preload() : this.fetch());
|
||||
},
|
||||
|
||||
preload : function(){
|
||||
this.items.reset(app.parsePreload("stream"))
|
||||
this.deferred = $.when(true)
|
||||
this.trigger("fetched")
|
||||
this.items.reset(app.parsePreload("stream"));
|
||||
this.deferred = $.when(true);
|
||||
this.trigger("fetched");
|
||||
}
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
app.models.StreamAspects = app.models.Stream.extend({
|
||||
|
||||
url : function(){
|
||||
return _.any(this.items.models) ? this.timeFilteredPath() : this.basePath()
|
||||
return _.any(this.items.models) ? this.timeFilteredPath() : this.basePath();
|
||||
},
|
||||
|
||||
initialize : function(models, options){
|
||||
|
|
|
|||
|
|
@ -12,15 +12,15 @@ app.models.User = Backbone.Model.extend({
|
|||
},
|
||||
|
||||
expProfileUrl : function(){
|
||||
return "/people/" + app.currentUser.get("guid") + "?ex=true"
|
||||
return "/people/" + app.currentUser.get("guid") + "?ex=true";
|
||||
},
|
||||
|
||||
isServiceConfigured : function(providerName) {
|
||||
return _.include(this.get("configured_services"), providerName)
|
||||
return _.include(this.get("configured_services"), providerName);
|
||||
},
|
||||
|
||||
isAuthorOf: function(model) {
|
||||
return this.authenticated() && model.get("author").id == this.id;
|
||||
return this.authenticated() && model.get("author").id === this.id;
|
||||
}
|
||||
});
|
||||
// @license-end
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ app.pages.Contacts = Backbone.View.extend({
|
|||
$(".header > #aspect_name_form").show();
|
||||
},
|
||||
|
||||
updateAspectName: function(evt,data,status,xhr){
|
||||
updateAspectName: function(evt,data){
|
||||
$(".header #aspect_name").text(data['name']);
|
||||
$("#aspect_nav [data-aspect-id='"+data['id']+"'] .name").text(data['name']);
|
||||
$(".header > #aspect_name_form").hide();
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ app.pages.Profile = app.views.Base.extend({
|
|||
return new view({model: app.stream});
|
||||
},
|
||||
|
||||
blockPerson: function(evt) {
|
||||
blockPerson: function() {
|
||||
if( !confirm(Diaspora.I18n.t('ignore_user')) ) return;
|
||||
|
||||
var block = this.model.block();
|
||||
|
|
@ -106,7 +106,7 @@ app.pages.Profile = app.views.Base.extend({
|
|||
return false;
|
||||
},
|
||||
|
||||
unblockPerson: function(evt) {
|
||||
unblockPerson: function() {
|
||||
var block = this.model.unblock();
|
||||
block.fail(function() {
|
||||
Diaspora.page.flashMessages.render({
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ app.pages.SinglePostViewer = app.views.Base.extend({
|
|||
initialize : function(options) {
|
||||
this.model = new app.models.Post({ id : options.id });
|
||||
this.model.preloadOrFetch().done(_.bind(this.initViews, this));
|
||||
this.model.interactions.fetch() //async, yo, might want to throttle this later.
|
||||
this.setupLightbox()
|
||||
this.model.interactions.fetch(); //async, yo, might want to throttle this later.
|
||||
this.setupLightbox();
|
||||
},
|
||||
|
||||
setupLightbox : function(){
|
||||
|
|
@ -41,4 +41,3 @@ app.pages.SinglePostViewer = app.views.Base.extend({
|
|||
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ app.Router = Backbone.Router.extend({
|
|||
|
||||
//below here is oldness
|
||||
|
||||
stream : function(page) {
|
||||
stream : function() {
|
||||
app.stream = new app.models.Stream();
|
||||
app.stream.fetch();
|
||||
app.page = new app.views.Stream({model : app.stream});
|
||||
|
|
@ -113,7 +113,7 @@ app.Router = Backbone.Router.extend({
|
|||
var followedTagsAction = new app.views.TagFollowingAction(
|
||||
{tagText: decodeURIComponent(name).toLowerCase()}
|
||||
);
|
||||
$("#author_info").prepend(followedTagsAction.render().el)
|
||||
$("#author_info").prepend(followedTagsAction.render().el);
|
||||
app.tags = new app.views.Tags({tagName: name});
|
||||
}
|
||||
this._hideInactiveStreamLists();
|
||||
|
|
@ -143,15 +143,15 @@ app.Router = Backbone.Router.extend({
|
|||
},
|
||||
|
||||
_hideInactiveStreamLists: function() {
|
||||
if(this.aspects_list && Backbone.history.fragment != "aspects")
|
||||
if(this.aspects_list && Backbone.history.fragment !== "aspects")
|
||||
this.aspects_list.hideAspectsList();
|
||||
|
||||
if(this.followedTagsView && Backbone.history.fragment != "followed_tags")
|
||||
if(this.followedTagsView && Backbone.history.fragment !== "followed_tags")
|
||||
this.followedTagsView.hideFollowedTags();
|
||||
},
|
||||
|
||||
bookmarklet: function() {
|
||||
var contents = (window.gon) ? gon.preloads.bookmarklet : {}
|
||||
var contents = (window.gon) ? gon.preloads.bookmarklet : {};
|
||||
app.bookmarklet = new app.views.Bookmarklet(
|
||||
_.extend({}, {el: $('#bookmarklet')}, contents)
|
||||
).render();
|
||||
|
|
@ -164,4 +164,3 @@ app.Router = Backbone.Router.extend({
|
|||
}
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
app.views.Base = Backbone.View.extend({
|
||||
|
||||
initialize : function(options) {
|
||||
initialize : function() {
|
||||
this.setupRenderEvents();
|
||||
},
|
||||
|
||||
presenter : function(){
|
||||
return this.defaultPresenter()
|
||||
return this.defaultPresenter();
|
||||
},
|
||||
|
||||
setupRenderEvents : function(){
|
||||
|
|
@ -18,7 +18,7 @@ app.views.Base = Backbone.View.extend({
|
|||
},
|
||||
|
||||
defaultPresenter : function(){
|
||||
var modelJson = this.model && this.model.attributes ? _.clone(this.model.attributes) : {}
|
||||
var modelJson = this.model && this.model.attributes ? _.clone(this.model.attributes) : {};
|
||||
|
||||
return _.extend(modelJson, {
|
||||
current_user : app.currentUser.attributes,
|
||||
|
|
@ -27,19 +27,19 @@ app.views.Base = Backbone.View.extend({
|
|||
},
|
||||
|
||||
render : function() {
|
||||
this.renderTemplate()
|
||||
this.renderSubviews()
|
||||
this.renderPluginWidgets()
|
||||
this.removeTooltips()
|
||||
this.renderTemplate();
|
||||
this.renderSubviews();
|
||||
this.renderPluginWidgets();
|
||||
this.removeTooltips();
|
||||
|
||||
return this
|
||||
return this;
|
||||
},
|
||||
|
||||
renderTemplate : function(){
|
||||
var presenter = _.isFunction(this.presenter) ? this.presenter() : this.presenter
|
||||
this.template = HandlebarsTemplates[this.templateName+"_tpl"]
|
||||
var presenter = _.isFunction(this.presenter) ? this.presenter() : this.presenter;
|
||||
this.template = HandlebarsTemplates[this.templateName+"_tpl"];
|
||||
if(!this.template) {
|
||||
console.log(this.templateName ? ("no template for " + this.templateName) : "no templateName specified")
|
||||
console.log(this.templateName ? ("no template for " + this.templateName) : "no templateName specified");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -58,12 +58,12 @@ app.views.Base = Backbone.View.extend({
|
|||
renderSubviews : function(){
|
||||
var self = this;
|
||||
_.each(this.subviews, function(property, selector){
|
||||
var view = _.isFunction(self[property]) ? self[property]() : self[property]
|
||||
var view = _.isFunction(self[property]) ? self[property]() : self[property];
|
||||
if(view) {
|
||||
self.$(selector).html(view.render().el)
|
||||
self.$(selector).html(view.render().el);
|
||||
view.delegateEvents();
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
renderPluginWidgets : function() {
|
||||
|
|
@ -76,16 +76,16 @@ app.views.Base = Backbone.View.extend({
|
|||
},
|
||||
|
||||
setFormAttrs : function(){
|
||||
this.model.set(_.inject(this.formAttrs, _.bind(setValueFromField, this), {}))
|
||||
|
||||
function setValueFromField(memo, attribute, selector){
|
||||
if(attribute.slice("-2") === "[]") {
|
||||
memo[attribute.slice(0, attribute.length - 2)] = _.pluck(this.$el.find(selector).serializeArray(), "value")
|
||||
memo[attribute.slice(0, attribute.length - 2)] = _.pluck(this.$el.find(selector).serializeArray(), "value");
|
||||
} else {
|
||||
memo[attribute] = this.$el.find(selector).val() || this.$el.find(selector).text();
|
||||
}
|
||||
return memo
|
||||
return memo;
|
||||
}
|
||||
|
||||
this.model.set(_.inject(this.formAttrs, _.bind(setValueFromField, this), {}));
|
||||
},
|
||||
|
||||
report: function(evt) {
|
||||
|
|
@ -104,13 +104,13 @@ app.views.Base = Backbone.View.extend({
|
|||
|
||||
var report = new app.models.Report();
|
||||
report.save(data, {
|
||||
success: function(model, response) {
|
||||
success: function() {
|
||||
Diaspora.page.flashMessages.render({
|
||||
success: true,
|
||||
notice: Diaspora.I18n.t('report.status.created')
|
||||
});
|
||||
},
|
||||
error: function(model, response) {
|
||||
error: function() {
|
||||
Diaspora.page.flashMessages.render({
|
||||
success: false,
|
||||
notice: Diaspora.I18n.t('report.status.exists')
|
||||
|
|
@ -132,7 +132,7 @@ app.views.Base = Backbone.View.extend({
|
|||
})
|
||||
.fail(function() {
|
||||
self.$el.removeClass('deleting');
|
||||
var flash = new Diaspora.Widgets.FlashMessages;
|
||||
var flash = new Diaspora.Widgets.FlashMessages();
|
||||
flash.render({
|
||||
success: false,
|
||||
notice: Diaspora.I18n.t('failed_to_remove')
|
||||
|
|
@ -142,7 +142,7 @@ app.views.Base = Backbone.View.extend({
|
|||
},
|
||||
|
||||
avatars: {
|
||||
fallback: function(evt) {
|
||||
fallback: function() {
|
||||
$(this).attr("src", ImagePaths.get("user/default.png"));
|
||||
},
|
||||
selector: "img.avatar"
|
||||
|
|
@ -163,4 +163,3 @@ app.views.StaticContentView = app.views.Base.extend({
|
|||
},
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ app.views.AspectMembershipBlueprint = Backbone.View.extend({
|
|||
|
||||
// the user didn't have this person in any aspects before, congratulate them
|
||||
// on their newly found friendship ;)
|
||||
if( this.dropdown.find('li.selected').length == 0 ) {
|
||||
if( this.dropdown.find('li.selected').length === 0 ) {
|
||||
var msg = Diaspora.I18n.t('aspect_dropdown.started_sharing_with', { 'name': this._name() });
|
||||
Diaspora.page.flashMessages.render({ 'success':true, 'notice':msg });
|
||||
}
|
||||
|
|
@ -121,7 +121,7 @@ app.views.AspectMembershipBlueprint = Backbone.View.extend({
|
|||
|
||||
// we just removed the last aspect, inform the user with a flash message
|
||||
// that he is no longer sharing with that person
|
||||
if( this.dropdown.find('li.selected').length == 0 ) {
|
||||
if( this.dropdown.find('li.selected').length === 0 ) {
|
||||
var msg = Diaspora.I18n.t('aspect_dropdown.stopped_sharing_with', { 'name': this._name() });
|
||||
Diaspora.page.flashMessages.render({ 'success':true, 'notice':msg });
|
||||
}
|
||||
|
|
@ -143,7 +143,7 @@ app.views.AspectMembershipBlueprint = Backbone.View.extend({
|
|||
var aspects_cnt = this.dropdown.find('li.selected').length;
|
||||
var txt;
|
||||
|
||||
if( aspects_cnt == 0 ) {
|
||||
if( aspects_cnt === 0 ) {
|
||||
btn.removeClass('in_aspects');
|
||||
txt = Diaspora.I18n.t('aspect_dropdown.toggle.zero');
|
||||
} else {
|
||||
|
|
@ -157,11 +157,11 @@ app.views.AspectMembershipBlueprint = Backbone.View.extend({
|
|||
_pluralSummaryTxt: function(cnt) {
|
||||
var all_aspects_cnt = this.dropdown.find('li').length;
|
||||
|
||||
if( cnt == 1 ) {
|
||||
if( cnt === 1 ) {
|
||||
return this.dropdown.find('li.selected').first().text();
|
||||
}
|
||||
|
||||
if( cnt == all_aspects_cnt ) {
|
||||
if( cnt === all_aspects_cnt ) {
|
||||
return Diaspora.I18n.t('aspect_dropdown.all_aspects');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ app.views.AspectMembership = app.views.AspectsDropdown.extend({
|
|||
|
||||
// the user didn't have this person in any aspects before, congratulate them
|
||||
// on their newly found friendship ;)
|
||||
if( this.dropdown.find('li.selected').length == 0 ) {
|
||||
if( this.dropdown.find('li.selected').length === 0 ) {
|
||||
var msg = Diaspora.I18n.t('aspect_dropdown.started_sharing_with', { 'name': this._name() });
|
||||
Diaspora.page.flashMessages.render({ 'success':true, 'notice':msg });
|
||||
}
|
||||
|
|
@ -120,7 +120,7 @@ app.views.AspectMembership = app.views.AspectsDropdown.extend({
|
|||
|
||||
// we just removed the last aspect, inform the user with a flash message
|
||||
// that he is no longer sharing with that person
|
||||
if( this.dropdown.find('li.selected').length == 0 ) {
|
||||
if( this.dropdown.find('li.selected').length === 0 ) {
|
||||
var msg = Diaspora.I18n.t('aspect_dropdown.stopped_sharing_with', { 'name': this._name() });
|
||||
Diaspora.page.flashMessages.render({ 'success':true, 'notice':msg });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ app.views.Aspect = app.views.Base.extend({
|
|||
},
|
||||
|
||||
toggleAspect: function(evt) {
|
||||
if (evt) { evt.preventDefault(); };
|
||||
if (evt) { evt.preventDefault(); }
|
||||
this.model.toggleSelected();
|
||||
|
||||
app.router.aspects_stream();
|
||||
|
|
@ -21,8 +21,7 @@ app.views.Aspect = app.views.Base.extend({
|
|||
presenter : function() {
|
||||
return _.extend(this.defaultPresenter(), {
|
||||
aspect : this.model
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -32,12 +32,12 @@ app.views.AspectsDropdown = app.views.Base.extend({
|
|||
selectedAspects = this.$(".dropdown-menu > li.selected").length,
|
||||
buttonText;
|
||||
|
||||
if (selectedAspects == 0) {
|
||||
if (selectedAspects === 0) {
|
||||
button.removeClass(inAspectClass).addClass('btn-default');
|
||||
buttonText = Diaspora.I18n.t("aspect_dropdown.select_aspects");
|
||||
} else {
|
||||
button.removeClass('btn-default').addClass(inAspectClass);
|
||||
if (selectedAspects == 1) {
|
||||
if (selectedAspects === 1) {
|
||||
buttonText = this.$(".dropdown-menu > li.selected .text").first().text();
|
||||
} else {
|
||||
buttonText = Diaspora.I18n.t("aspect_dropdown.toggle", { count: selectedAspects.toString() });
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ app.views.AspectsList = app.views.Base.extend({
|
|||
},
|
||||
|
||||
toggleAll: function(evt) {
|
||||
if (evt) { evt.preventDefault(); };
|
||||
if (evt) { evt.preventDefault(); }
|
||||
|
||||
if (this.collection.allSelected()) {
|
||||
this.collection.deselectAll();
|
||||
|
|
@ -68,6 +68,5 @@ app.views.AspectsList = app.views.Base.extend({
|
|||
hideAspectsList: function() {
|
||||
this.$el.empty();
|
||||
},
|
||||
})
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -30,18 +30,18 @@ app.views.Bookmarklet = Backbone.View.extend({
|
|||
return contents;
|
||||
},
|
||||
|
||||
_postSubmit: function(evt) {
|
||||
_postSubmit: function() {
|
||||
this.$('h4').text(Diaspora.I18n.t('bookmarklet.post_submit'));
|
||||
},
|
||||
|
||||
_postSuccess: function(evt) {
|
||||
_postSuccess: function() {
|
||||
this.$('h4').text(Diaspora.I18n.t('bookmarklet.post_success'));
|
||||
app.publisher.close();
|
||||
this.$("#publisher").addClass("hidden");
|
||||
_.delay(window.close, 2000);
|
||||
},
|
||||
|
||||
_postError: function(evt) {
|
||||
_postError: function() {
|
||||
this.$('h4').text(Diaspora.I18n.t('bookmarklet.post_something'));
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ app.views.CommentStream = app.views.Base.extend({
|
|||
moreCommentsCount : (this.model.interactions.commentsCount() - 3),
|
||||
showExpandCommentsLink : (this.model.interactions.commentsCount() > 3),
|
||||
commentsCount : this.model.interactions.commentsCount()
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
createComment: function(evt) {
|
||||
|
|
@ -57,8 +57,8 @@ app.views.CommentStream = app.views.Base.extend({
|
|||
},
|
||||
|
||||
keyDownOnCommentBox: function(evt) {
|
||||
if(evt.keyCode == 13 && evt.ctrlKey) {
|
||||
this.$("form").submit()
|
||||
if(evt.keyCode === 13 && evt.ctrlKey) {
|
||||
this.$("form").submit();
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
|
@ -66,14 +66,14 @@ app.views.CommentStream = app.views.Base.extend({
|
|||
appendComment: function(comment) {
|
||||
// Set the post as the comment's parent, so we can check
|
||||
// on post ownership in the Comment view.
|
||||
comment.set({parent : this.model.toJSON()})
|
||||
comment.set({parent : this.model.toJSON()});
|
||||
|
||||
this.$(".comments").append(new app.views.Comment({
|
||||
model: comment
|
||||
}).render().el);
|
||||
},
|
||||
|
||||
commentTextareaFocused: function(evt){
|
||||
commentTextareaFocused: function(){
|
||||
this.$("form").removeClass('hidden').addClass("open");
|
||||
},
|
||||
|
||||
|
|
@ -83,20 +83,18 @@ app.views.CommentStream = app.views.Base.extend({
|
|||
|
||||
expandComments: function(evt){
|
||||
if(evt){ evt.preventDefault(); }
|
||||
|
||||
self = this;
|
||||
var self = this;
|
||||
|
||||
this.model.comments.fetch({
|
||||
success : function(resp){
|
||||
self.model.set({
|
||||
comments : resp.models,
|
||||
all_comments_loaded : true
|
||||
})
|
||||
});
|
||||
|
||||
self.model.trigger("commentsExpanded", self)
|
||||
self.model.trigger("commentsExpanded", self);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -13,27 +13,27 @@ app.views.Comment = app.views.Content.extend({
|
|||
},
|
||||
|
||||
initialize : function(options){
|
||||
this.templateName = options.templateName || this.templateName
|
||||
this.model.on("change", this.render, this)
|
||||
this.templateName = options.templateName || this.templateName;
|
||||
this.model.on("change", this.render, this);
|
||||
},
|
||||
|
||||
presenter : function() {
|
||||
return _.extend(this.defaultPresenter(), {
|
||||
canRemove: this.canRemove(),
|
||||
text : app.helpers.textFormatter(this.model.get("text"))
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
ownComment : function() {
|
||||
return app.currentUser.authenticated() && this.model.get("author").diaspora_id == app.currentUser.get("diaspora_id")
|
||||
return app.currentUser.authenticated() && this.model.get("author").diaspora_id === app.currentUser.get("diaspora_id");
|
||||
},
|
||||
|
||||
postOwner : function() {
|
||||
return app.currentUser.authenticated() && this.model.get("parent").author.diaspora_id == app.currentUser.get("diaspora_id")
|
||||
return app.currentUser.authenticated() && this.model.get("parent").author.diaspora_id === app.currentUser.get("diaspora_id");
|
||||
},
|
||||
|
||||
canRemove : function() {
|
||||
return app.currentUser.authenticated() && (this.ownComment() || this.postOwner())
|
||||
return app.currentUser.authenticated() && (this.ownComment() || this.postOwner());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -42,4 +42,3 @@ app.views.ExpandedComment = app.views.Comment.extend({
|
|||
}
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ app.views.Contact = app.views.Base.extend({
|
|||
postRenderTemplate: function() {
|
||||
var self = this;
|
||||
var dropdownEl = this.$('.aspect_membership_dropdown.placeholder');
|
||||
if( dropdownEl.length == 0 ) {
|
||||
if( dropdownEl.length === 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -44,10 +44,10 @@ app.views.Contact = app.views.Base.extend({
|
|||
'person_id': this.model.get('person_id'),
|
||||
'aspect_id': app.aspect.get('id')
|
||||
},{
|
||||
success: function(model,response){
|
||||
success: function(){
|
||||
self.render();
|
||||
},
|
||||
error: function(model,response){
|
||||
error: function(){
|
||||
var msg = Diaspora.I18n.t('contacts.error_add', { 'name': self.model.get('person').name });
|
||||
Diaspora.page.flashMessages.render({ 'success':false, 'notice':msg });
|
||||
}
|
||||
|
|
@ -57,12 +57,12 @@ app.views.Contact = app.views.Base.extend({
|
|||
removeContactFromAspect: function(){
|
||||
var self = this;
|
||||
this.model.aspect_memberships
|
||||
.find(function(membership){ return membership.get('aspect').id == app.aspect.id; })
|
||||
.find(function(membership){ return membership.get('aspect').id === app.aspect.id; })
|
||||
.destroy({
|
||||
success: function(model,response){
|
||||
success: function(){
|
||||
self.render();
|
||||
},
|
||||
error: function(model,response){
|
||||
error: function(){
|
||||
var msg = Diaspora.I18n.t('contacts.error_remove', { 'name': self.model.get('person').name });
|
||||
Diaspora.page.flashMessages.render({ 'success':false, 'notice':msg });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,13 +16,13 @@ app.views.Content = app.views.Base.extend({
|
|||
|
||||
|
||||
largePhoto : function() {
|
||||
var photos = this.model.get("photos")
|
||||
if(!photos || photos.length == 0) { return }
|
||||
return photos[0]
|
||||
var photos = this.model.get("photos");
|
||||
if(!photos || photos.length === 0) { return }
|
||||
return photos[0];
|
||||
},
|
||||
|
||||
smallPhotos : function() {
|
||||
var photos = this.model.get("photos")
|
||||
var photos = this.model.get("photos");
|
||||
if(!photos || photos.length < 2) { return }
|
||||
photos.splice(0, 1); // remove first photo as it is already shown as largePhoto
|
||||
return photos;
|
||||
|
|
@ -49,10 +49,10 @@ app.views.Content = app.views.Base.extend({
|
|||
, oembed = elem.find(".oembed")
|
||||
, opengraph = elem.find(".opengraph")
|
||||
, addHeight = 0;
|
||||
if($.trim(oembed.html()) != "") {
|
||||
if($.trim(oembed.html()) !== "") {
|
||||
addHeight += oembed.height();
|
||||
}
|
||||
if($.trim(opengraph.html()) != "") {
|
||||
if($.trim(opengraph.html()) !== "") {
|
||||
addHeight += opengraph.height();
|
||||
}
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ app.views.Content = app.views.Base.extend({
|
|||
},
|
||||
|
||||
postRenderTemplate : function(){
|
||||
_.defer(_.bind(this.collapseOversized, this))
|
||||
_.defer(_.bind(this.collapseOversized, this));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -95,15 +95,15 @@ app.views.OEmbed = app.views.Base.extend({
|
|||
},
|
||||
|
||||
presenter:function () {
|
||||
o_embed_cache = this.model.get("o_embed_cache")
|
||||
var o_embed_cache = this.model.get("o_embed_cache");
|
||||
if(o_embed_cache) {
|
||||
typemodel = { rich: false, photo: false, video: false, link: false }
|
||||
typemodel[o_embed_cache.data.type] = true
|
||||
o_embed_cache.data.types = typemodel
|
||||
var typemodel = { rich: false, photo: false, video: false, link: false };
|
||||
typemodel[o_embed_cache.data.type] = true;
|
||||
o_embed_cache.data.types = typemodel;
|
||||
}
|
||||
return _.extend(this.defaultPresenter(), {
|
||||
o_embed_html : app.helpers.oEmbed.html(o_embed_cache)
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
showOembedContent : function (evt) {
|
||||
|
|
@ -137,4 +137,3 @@ app.views.SPVOpenGraph = app.views.OpenGraph.extend({
|
|||
}
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ app.views.FaqQuestionView = app.views.Base.extend({
|
|||
},
|
||||
|
||||
toggled: function(e) {
|
||||
el = $(e.target);
|
||||
parent = el.parents('.question');
|
||||
var el = $(e.target);
|
||||
var parent = el.parents('.question');
|
||||
|
||||
parent.children('.answer').toggle();
|
||||
parent.toggleClass('opened').toggleClass('collapsed');
|
||||
|
|
|
|||
|
|
@ -18,11 +18,11 @@ app.views.Feedback = app.views.Base.extend({
|
|||
|
||||
initialize : function() {
|
||||
this.model.interactions.on('change', this.render, this);
|
||||
this.initViews && this.initViews() // I don't know why this was failing with $.noop... :(
|
||||
this.initViews && this.initViews(); // I don't know why this was failing with $.noop... :(
|
||||
},
|
||||
|
||||
presenter : function() {
|
||||
var interactions = this.model.interactions
|
||||
var interactions = this.model.interactions;
|
||||
|
||||
return _.extend(this.defaultPresenter(),{
|
||||
commentsCount : interactions.commentsCount(),
|
||||
|
|
@ -31,7 +31,7 @@ app.views.Feedback = app.views.Base.extend({
|
|||
userCanReshare : interactions.userCanReshare(),
|
||||
userLike : interactions.userLike(),
|
||||
userReshare : interactions.userReshare()
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
toggleLike: function(evt) {
|
||||
|
|
@ -85,4 +85,3 @@ app.views.Feedback = app.views.Base.extend({
|
|||
},
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ app.views.Header = app.views.Base.extend({
|
|||
"focusout #q": "toggleSearchActive"
|
||||
},
|
||||
|
||||
initialize : function(options) {
|
||||
initialize : function() {
|
||||
$(document.body).click($.proxy(this.hideDropdown, this));
|
||||
return this;
|
||||
},
|
||||
|
|
@ -40,7 +40,7 @@ app.views.Header = app.views.Base.extend({
|
|||
toggleSearchActive: function(ev) {
|
||||
// jQuery produces two events for focus/blur (for bubbling)
|
||||
// don't rely on which event arrives first, by allowing for both variants
|
||||
var is_active = (_.indexOf(['focus','focusin'], ev.type) != -1);
|
||||
var is_active = (_.indexOf(['focus','focusin'], ev.type) !== -1);
|
||||
$(ev.target).toggleClass('active', is_active);
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ app.views.HelpSectionView = app.views.StaticContentView.extend({
|
|||
},
|
||||
|
||||
toggled: function(e) {
|
||||
el = $(e.target);
|
||||
parent = el.parents('.question');
|
||||
var el = $(e.target);
|
||||
var parent = el.parents('.question');
|
||||
|
||||
parent.children('.answer.hideable').toggle();
|
||||
parent.toggleClass('opened').toggleClass('collapsed');
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ app.views.Help = app.views.StaticContentView.extend({
|
|||
"click .faq-link-keyboard-shortcuts" : "keyboardShortcuts",
|
||||
},
|
||||
|
||||
initialize : function(options) {
|
||||
initialize : function() {
|
||||
this.GETTING_HELP_SUBS = {
|
||||
getting_started_a: { tutorial_series: this.linkHtml("http://diasporafoundation.org/getting_started/sign_up", Diaspora.I18n.t( 'getting_started_tutorial' )) },
|
||||
get_support_a_website: { link: this.linkHtml("https://diasporafoundation.org/", Diaspora.I18n.t( 'foundation_website' ))},
|
||||
|
|
@ -52,7 +52,7 @@ app.views.Help = app.views.StaticContentView.extend({
|
|||
title_tags: Diaspora.I18n.t( 'tags.title' ),
|
||||
title_keyboard_shortcuts: Diaspora.I18n.t( 'keyboard_shortcuts.title' ),
|
||||
title_miscellaneous: Diaspora.I18n.t( 'miscellaneous.title' ),
|
||||
}
|
||||
};
|
||||
|
||||
return this;
|
||||
},
|
||||
|
|
@ -124,8 +124,8 @@ app.views.Help = app.views.StaticContentView.extend({
|
|||
|
||||
renderStaticSection: function(section, template, subs) {
|
||||
this.clearItems();
|
||||
data = $.extend(Diaspora.I18n.resolve(section), { className: section });
|
||||
help_section = new app.views.HelpSectionView({
|
||||
var data = $.extend(Diaspora.I18n.resolve(section), { className: section });
|
||||
var help_section = new app.views.HelpSectionView({
|
||||
template: template,
|
||||
data: data,
|
||||
subs: subs
|
||||
|
|
@ -173,4 +173,3 @@ app.views.Help = app.views.StaticContentView.extend({
|
|||
},
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ app.views.Hovercard = app.views.Base.extend({
|
|||
},
|
||||
|
||||
postRenderTemplate: function() {
|
||||
this.$el.appendTo($('body'))
|
||||
this.$el.appendTo($('body'));
|
||||
},
|
||||
|
||||
deactivate: function() {
|
||||
|
|
@ -41,7 +41,7 @@ app.views.Hovercard = app.views.Base.extend({
|
|||
},
|
||||
|
||||
_mouseenterHandler: function(event) {
|
||||
if( this.active == false ||
|
||||
if( this.active === false ||
|
||||
$.contains(this.el, event.target) ) { return false; }
|
||||
|
||||
var el = $(event.target);
|
||||
|
|
@ -49,7 +49,7 @@ app.views.Hovercard = app.views.Base.extend({
|
|||
el = el.parents('a');
|
||||
}
|
||||
|
||||
if( el.attr('href').indexOf('/people') == -1 ) {
|
||||
if( el.attr('href').indexOf('/people') === -1 ) {
|
||||
// can't fetch data from that URL, aborting
|
||||
return false;
|
||||
}
|
||||
|
|
@ -60,7 +60,7 @@ app.views.Hovercard = app.views.Base.extend({
|
|||
},
|
||||
|
||||
_mouseleaveHandler: function(event) {
|
||||
if( this.active == false ||
|
||||
if( this.active === false ||
|
||||
$.contains(this.el, event.relatedTarget) ) { return false; }
|
||||
|
||||
this.show_me = false;
|
||||
|
|
@ -95,7 +95,7 @@ app.views.Hovercard = app.views.Base.extend({
|
|||
|
||||
var self = this;
|
||||
$.get(href, function(person){
|
||||
if( !person || person.length == 0 ) {
|
||||
if( !person || person.length === 0 ) {
|
||||
throw new Error("received data is not a person object");
|
||||
}
|
||||
|
||||
|
|
@ -123,13 +123,13 @@ app.views.Hovercard = app.views.Base.extend({
|
|||
// TODO render me client side!!!
|
||||
var href = this.href();
|
||||
href += "/aspect_membership_button";
|
||||
if(gon.bootstrap == true){
|
||||
if(gon.bootstrap === true){
|
||||
href += "?bootstrap=true";
|
||||
}
|
||||
$.get(href, function(response) {
|
||||
self.dropdown_container.html(response);
|
||||
});
|
||||
var aspect_membership = new app.views.AspectMembership({el: self.dropdown_container});
|
||||
new app.views.AspectMembership({el: self.dropdown_container});
|
||||
},
|
||||
|
||||
_positionHovercard: function() {
|
||||
|
|
@ -143,4 +143,3 @@ app.views.Hovercard = app.views.Base.extend({
|
|||
}
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ app.views.InfScroll = app.views.Base.extend({
|
|||
|
||||
createPostView : function(post){
|
||||
var postView = new this.postClass({ model: post, stream: this.stream });
|
||||
if (this.collection.at(0).id == post.id) {
|
||||
if (this.collection.at(0).id === post.id) {
|
||||
// post is first in collection - insert view at top of the list
|
||||
this.postViews.unshift(postView);
|
||||
} else {
|
||||
|
|
@ -46,7 +46,7 @@ app.views.InfScroll = app.views.Base.extend({
|
|||
// called for every item inserted in this.collection
|
||||
addPostView : function(post) {
|
||||
var el = this.createPostView(post).render().el;
|
||||
if (this.collection.at(0).id == post.id) {
|
||||
if (this.collection.at(0).id === post.id) {
|
||||
this.prependedPosts.insertBefore(el, this.prependedPosts.firstChild);
|
||||
} else {
|
||||
this.appendedPosts.appendChild(el);
|
||||
|
|
@ -58,7 +58,7 @@ app.views.InfScroll = app.views.Base.extend({
|
|||
},
|
||||
|
||||
renderTemplate : function(){
|
||||
this.renderInitialPosts()
|
||||
this.renderInitialPosts();
|
||||
},
|
||||
|
||||
renderInitialPosts : function(){
|
||||
|
|
@ -66,7 +66,7 @@ app.views.InfScroll = app.views.Base.extend({
|
|||
var els = document.createDocumentFragment();
|
||||
this.stream.items.each(_.bind(function(post){
|
||||
els.appendChild(this.createPostView(post).render().el);
|
||||
}, this))
|
||||
}, this));
|
||||
this.$el.html(els);
|
||||
},
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ app.views.InfScroll = app.views.Base.extend({
|
|||
},
|
||||
|
||||
showLoader: function(){
|
||||
$("#paginate .loader").removeClass("hidden")
|
||||
$("#paginate .loader").removeClass("hidden");
|
||||
},
|
||||
|
||||
finishedAdding: function() {
|
||||
|
|
@ -108,4 +108,3 @@ app.views.InfScroll = app.views.Base.extend({
|
|||
}
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -19,13 +19,12 @@ app.views.LikesInfo = app.views.Base.extend({
|
|||
likes : this.model.interactions.likes.toJSON(),
|
||||
likesCount : this.model.interactions.likesCount(),
|
||||
likes_fetched : this.model.interactions.get("fetched"),
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
showAvatars : function(evt){
|
||||
if(evt) { evt.preventDefault() }
|
||||
this.model.interactions.fetch()
|
||||
this.model.interactions.fetch();
|
||||
}
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@ app.views.Location = Backbone.View.extend({
|
|||
$(this.el).append('<img alt="delete location" src="'+ImagePaths.get('ajax-loader.gif')+'">');
|
||||
},
|
||||
|
||||
getLocation: function(e){
|
||||
element = this.el;
|
||||
getLocation: function(){
|
||||
var element = this.el;
|
||||
|
||||
locator = new OSM.Locator();
|
||||
var locator = new OSM.Locator();
|
||||
locator.getAddress(function(address, latlng){
|
||||
$(element).html('<input id="location_address" type="text" class="input-block-level" value="' + address + '"/>');
|
||||
$('#location_coords').val(latlng.latitude + "," + latlng.longitude);
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ app.views.Notifications = Backbone.View.extend({
|
|||
},
|
||||
|
||||
toggleUnread: function(evt) {
|
||||
note = $(evt.target).closest(".stream_element");
|
||||
unread = note.hasClass("unread");
|
||||
var note = $(evt.target).closest(".stream_element");
|
||||
var unread = note.hasClass("unread");
|
||||
|
||||
if (unread) {
|
||||
this.setRead(note.data("guid"));
|
||||
|
|
@ -44,17 +44,17 @@ app.views.Notifications = Backbone.View.extend({
|
|||
},
|
||||
|
||||
clickSuccess: function(data) {
|
||||
type = $('.stream_element[data-guid=' + data["guid"] + ']').data('type');
|
||||
var type = $('.stream_element[data-guid=' + data["guid"] + ']').data('type');
|
||||
this.updateView(data["guid"], type, data["unread"]);
|
||||
},
|
||||
|
||||
updateView: function(guid, type, unread) {
|
||||
change = unread ? 1 : -1;
|
||||
all_notes = $('ul.nav > li:eq(0) .badge');
|
||||
type_notes = $('ul.nav > li[data-type=' + type + '] .badge');
|
||||
header_badge = $('#notification_badge .badge_count');
|
||||
var change = unread ? 1 : -1,
|
||||
all_notes = $('ul.nav > li:eq(0) .badge'),
|
||||
type_notes = $('ul.nav > li[data-type=' + type + '] .badge'),
|
||||
header_badge = $('#notification_badge .badge_count'),
|
||||
note = $('.stream_element[data-guid=' + guid + ']');
|
||||
|
||||
note = $('.stream_element[data-guid=' + guid + ']');
|
||||
if(unread) {
|
||||
note.removeClass("read").addClass("unread");
|
||||
$(".unread-toggle .entypo", note)
|
||||
|
|
@ -93,4 +93,3 @@ app.views.Notifications = Backbone.View.extend({
|
|||
}
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ app.views.PhotoViewer = app.views.Base.extend({
|
|||
templateName : "photo-viewer",
|
||||
|
||||
presenter : function(){
|
||||
return { photos : this.model.get("photos") } //json array of attributes, not backbone models, yet.
|
||||
return { photos : this.model.get("photos") }; //json array of attributes, not backbone models, yet.
|
||||
}
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
|
||||
|
||||
app.views.Photos = app.views.InfScroll.extend({
|
||||
initialize : function(options) {
|
||||
initialize : function() {
|
||||
this.stream = this.model;
|
||||
this.collection = this.stream.items;
|
||||
|
||||
// viable for extraction
|
||||
this.stream.fetch();
|
||||
|
||||
this.setupLightbox()
|
||||
this.setupInfiniteScroll()
|
||||
this.setupLightbox();
|
||||
this.setupInfiniteScroll();
|
||||
},
|
||||
|
||||
postClass : app.views.Photo,
|
||||
|
|
@ -24,4 +24,3 @@ app.views.Photos = app.views.InfScroll.extend({
|
|||
}
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ app.views.Poll = app.views.Base.extend({
|
|||
"click .toggle_result" : "toggleResult"
|
||||
},
|
||||
|
||||
initialize: function(options) {
|
||||
initialize: function() {
|
||||
this.model.bind('change', this.render, this);
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -6,12 +6,11 @@ app.views.Post = app.views.Base.extend({
|
|||
authorIsCurrentUser : app.currentUser.isAuthorOf(this.model),
|
||||
showPost : this.showPost(),
|
||||
text : app.helpers.textFormatter(this.model.get("text"), this.model.get("mentioned_people"))
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
showPost : function() {
|
||||
return (app.currentUser.get("showNsfw")) || !this.model.get("nsfw")
|
||||
return (app.currentUser.get("showNsfw")) || !this.model.get("nsfw");
|
||||
}
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ app.views.ProfileHeader = app.views.Base.extend({
|
|||
postRenderTemplate: function() {
|
||||
var self = this;
|
||||
var dropdownEl = this.$('.aspect_membership_dropdown.placeholder');
|
||||
if( dropdownEl.length == 0 ) {
|
||||
if( dropdownEl.length === 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
// Provides the ability to specify the visibility of posted content as public
|
||||
// or limited to selected aspects
|
||||
app.views.PublisherAspectSelectorBlueprint = Backbone.View.extend({
|
||||
/* global AspectsDropdown */
|
||||
|
||||
events: {
|
||||
"click .dropdown_list > li": "toggleAspect"
|
||||
|
|
@ -21,7 +22,6 @@ app.views.PublisherAspectSelectorBlueprint = Backbone.View.extend({
|
|||
// event handler for aspect selection
|
||||
toggleAspect: function(evt) {
|
||||
var el = $(evt.target);
|
||||
var btn = el.parent('.dropdown').find('.button');
|
||||
|
||||
// visually toggle the aspect selection
|
||||
if( el.is('.radio') ) {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ app.views.PublisherAspectSelector = app.views.AspectsDropdown.extend({
|
|||
|
||||
// update the globe or lock icon
|
||||
var icon = this.$('#visibility-icon');
|
||||
if (target.find('.text').text().trim() == Diaspora.I18n.t('stream.public')) {
|
||||
if (target.find('.text').text().trim() === Diaspora.I18n.t('stream.public')) {
|
||||
icon.removeClass('lock');
|
||||
icon.addClass('globe');
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ app.views.PublisherGettingStarted = Backbone.View.extend({
|
|||
var close = $(popup).find('.close');
|
||||
|
||||
close.click(function() {
|
||||
if( $('.popover').length==1 ) {
|
||||
if( $('.popover').length === 1 ) {
|
||||
$.get('/getting_started_completed', {success: function() {
|
||||
$("#welcome-to-diaspora, #welcome-to-diaspora~br").remove();
|
||||
}});
|
||||
|
|
|
|||
|
|
@ -66,8 +66,7 @@ app.views.PublisherPollCreator = app.views.Base.extend({
|
|||
this.$('input').val('');
|
||||
},
|
||||
|
||||
validate: function(evt){
|
||||
var input = $(evt.target);
|
||||
validate: function(){
|
||||
this.validatePoll();
|
||||
this.trigger('change');
|
||||
},
|
||||
|
|
@ -98,7 +97,7 @@ app.views.PublisherPollCreator = app.views.Base.extend({
|
|||
// Validate the input unless it is the last one, or there are only the
|
||||
// question field and two options
|
||||
if( i !== inputs.length - 1 || inputs.length <= 3) {
|
||||
if(_this.validateInput($(input)) == false) pollValid = false;
|
||||
if(_this.validateInput($(input)) === false) pollValid = false;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ app.views.PublisherUploader = Backbone.View.extend({
|
|||
.width(progress + '%');
|
||||
},
|
||||
|
||||
submitHandler: function(id, fileName) {
|
||||
submitHandler: function() {
|
||||
this.$el.addClass('loading');
|
||||
this._addPhotoPlaceholder();
|
||||
},
|
||||
|
|
@ -66,7 +66,7 @@ app.views.PublisherUploader = Backbone.View.extend({
|
|||
);
|
||||
},
|
||||
|
||||
uploadCompleteHandler: function(id, fileName, response) {
|
||||
uploadCompleteHandler: function(_id, fileName, response) {
|
||||
if (response.success){
|
||||
this.el_info.text(Diaspora.I18n.t('photo_uploader.completed', {file: fileName})).fadeTo(2000, 0);
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ app.views.PublisherUploader = Backbone.View.extend({
|
|||
.find('div.progress').remove();
|
||||
|
||||
// no more placeholders? enable buttons
|
||||
if( publisher.el_photozone.find('li.loading').length == 0 ) {
|
||||
if( publisher.el_photozone.find('li.loading').length === 0 ) {
|
||||
this.$el.removeClass('loading');
|
||||
publisher.setButtonsEnabled(true);
|
||||
}
|
||||
|
|
@ -127,7 +127,7 @@ app.views.PublisherUploader = Backbone.View.extend({
|
|||
// remove an already uploaded photo
|
||||
_removePhoto: function(evt) {
|
||||
var self = this;
|
||||
var photo = $(evt.target).parents('.publisher_photo')
|
||||
var photo = $(evt.target).parents('.publisher_photo');
|
||||
var img = photo.find('img');
|
||||
|
||||
photo.addClass('dim');
|
||||
|
|
@ -139,7 +139,7 @@ app.views.PublisherUploader = Backbone.View.extend({
|
|||
$.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');
|
||||
}
|
||||
|
|
@ -154,4 +154,3 @@ app.views.PublisherUploader = Backbone.View.extend({
|
|||
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -53,10 +53,10 @@ app.views.Publisher = Backbone.View.extend({
|
|||
$(window).on('beforeunload', _.bind(this._beforeUnload, this));
|
||||
|
||||
// sync textarea content
|
||||
if( this.el_hiddenInput.val() == "" ) {
|
||||
if( this.el_hiddenInput.val() === "" ) {
|
||||
this.el_hiddenInput.val( this.el_input.val() );
|
||||
}
|
||||
if( this.el_input.val() == "" ) {
|
||||
if( this.el_input.val() === "" ) {
|
||||
this.el_input.val( this.el_hiddenInput.val() );
|
||||
}
|
||||
|
||||
|
|
@ -71,11 +71,11 @@ app.views.Publisher = Backbone.View.extend({
|
|||
// textchange event won't be called in Backbone...
|
||||
this.el_input.bind('textchange', $.noop);
|
||||
|
||||
var _this = this
|
||||
var _this = this;
|
||||
$('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){
|
||||
_this.tryClose()
|
||||
if( _this.el && $(event.target).closest('#publisher').attr('id') !== _this.el.id){
|
||||
_this.tryClose();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -210,7 +210,7 @@ app.views.Publisher = Backbone.View.extend({
|
|||
// standalone means single-shot posting (until further notice)
|
||||
if( self.standalone ) self.setEnabled(false);
|
||||
},
|
||||
error: function(model, resp, options) {
|
||||
error: function(model, resp) {
|
||||
if( app.publisher ) app.publisher.trigger('publisher:error');
|
||||
self.setInputEnabled(true);
|
||||
Diaspora.page.flashMessages.render({ 'success':false, 'notice':resp.responseText });
|
||||
|
|
@ -222,7 +222,7 @@ app.views.Publisher = Backbone.View.extend({
|
|||
|
||||
// creates the location
|
||||
showLocation: function(){
|
||||
if($('#location').length == 0){
|
||||
if($('#location').length === 0){
|
||||
$('#location_container').append('<div id="location"></div>');
|
||||
this.el_wrapper.addClass('with_location');
|
||||
this.view_locator = new app.views.Location();
|
||||
|
|
@ -245,7 +245,7 @@ app.views.Publisher = Backbone.View.extend({
|
|||
|
||||
// avoid submitting form when pressing Enter key
|
||||
avoidEnter: function(evt){
|
||||
if(evt.keyCode == 13)
|
||||
if(evt.keyCode === 13)
|
||||
return false;
|
||||
},
|
||||
|
||||
|
|
@ -257,7 +257,7 @@ app.views.Publisher = Backbone.View.extend({
|
|||
|
||||
var serializedForm = $(evt.target).closest("form").serializeObject();
|
||||
|
||||
var photos = new Array();
|
||||
var photos = [];
|
||||
$('li.publisher_photo img').each(function(){
|
||||
var file = $(this).attr('src').substring("/uploads/images/".length);
|
||||
photos.push(
|
||||
|
|
@ -271,11 +271,19 @@ app.views.Publisher = Backbone.View.extend({
|
|||
);
|
||||
});
|
||||
|
||||
var mentioned_people = new Array();
|
||||
var regexp = new RegExp("@{\(\[\^\;\]\+\); \(\[\^\}\]\+\)}", "g");
|
||||
while(user=regexp.exec(serializedForm["status_message[text]"])){
|
||||
var mentioned_people = [],
|
||||
regexp = new RegExp("@{\(\[\^\;\]\+\); \(\[\^\}\]\+\)}", "g"),
|
||||
user;
|
||||
|
||||
var getMentionedUser = function(handle) {
|
||||
return Mentions.contacts.filter(function(user) {
|
||||
return user.handle === handle;
|
||||
})[0];
|
||||
};
|
||||
|
||||
while( (user = regexp.exec(serializedForm["status_message[text]"])) ){
|
||||
// user[1]: name, user[2]: handle
|
||||
var mentioned_user = Mentions.contacts.filter(function(item) { return item.handle == user[2];})[0];
|
||||
var mentioned_user = getMentionedUser(user[2]);
|
||||
if(mentioned_user){
|
||||
mentioned_people.push({
|
||||
"id":mentioned_user["id"],
|
||||
|
|
@ -289,7 +297,7 @@ app.views.Publisher = Backbone.View.extend({
|
|||
|
||||
var date = (new Date()).toISOString();
|
||||
|
||||
var poll = undefined;
|
||||
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){
|
||||
|
|
@ -308,7 +316,7 @@ app.views.Publisher = Backbone.View.extend({
|
|||
var previewMessage = {
|
||||
"id" : 0,
|
||||
"text" : serializedForm["status_message[text]"],
|
||||
"public" : serializedForm["aspect_ids[]"]=="public",
|
||||
"public" : serializedForm["aspect_ids[]"] === "public",
|
||||
"created_at" : date,
|
||||
"interacted_at" : date,
|
||||
"post_type" : "StatusMessage",
|
||||
|
|
@ -349,7 +357,7 @@ app.views.Publisher = Backbone.View.extend({
|
|||
},
|
||||
|
||||
keyDown : function(evt) {
|
||||
if( evt.keyCode == 13 && evt.ctrlKey ) {
|
||||
if( evt.keyCode === 13 && evt.ctrlKey ) {
|
||||
this.$("form").submit();
|
||||
this.open();
|
||||
return false;
|
||||
|
|
@ -406,7 +414,7 @@ app.views.Publisher = Backbone.View.extend({
|
|||
tryClose : function(){
|
||||
// if it is not submittable, close it.
|
||||
if( !this._submittable() ){
|
||||
this.close()
|
||||
this.close();
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -483,7 +491,7 @@ app.views.Publisher = Backbone.View.extend({
|
|||
},
|
||||
|
||||
_beforeUnload: function(e) {
|
||||
if(this._submittable() && this.el_input.val() != this.prefillText){
|
||||
if(this._submittable() && this.el_input.val() !== this.prefillText){
|
||||
var confirmationMessage = Diaspora.I18n.t("confirm_unload");
|
||||
(e || window.event).returnValue = confirmationMessage; //Gecko + IE
|
||||
return confirmationMessage; //Webkit, Safari, Chrome, etc.
|
||||
|
|
@ -509,4 +517,3 @@ $.fn.serializeObject = function()
|
|||
return o;
|
||||
};
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -10,14 +10,14 @@ app.views.SinglePostActions = app.views.Feedback.extend({
|
|||
},
|
||||
|
||||
presenter: function() {
|
||||
var interactions = this.model.interactions
|
||||
var interactions = this.model.interactions;
|
||||
|
||||
return _.extend(this.defaultPresenter(), {
|
||||
authorIsNotCurrentUser : this.authorIsNotCurrentUser(),
|
||||
userCanReshare : interactions.userCanReshare(),
|
||||
userLike : interactions.userLike(),
|
||||
userReshare : interactions.userReshare()
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
renderPluginWidgets : function() {
|
||||
|
|
@ -32,9 +32,7 @@ app.views.SinglePostActions = app.views.Feedback.extend({
|
|||
},
|
||||
|
||||
authorIsNotCurrentUser: function() {
|
||||
return app.currentUser.authenticated() && this.model.get("author").id != app.user().id
|
||||
return app.currentUser.authenticated() && this.model.get("author").id !== app.user().id;
|
||||
}
|
||||
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -9,25 +9,25 @@ app.views.SinglePostCommentStream = app.views.CommentStream.extend({
|
|||
|
||||
highlightPermalinkComment: function() {
|
||||
if(document.location.hash){
|
||||
element=$(document.location.hash);
|
||||
headerSize=50;
|
||||
var element = $(document.location.hash);
|
||||
var headerSize = 50;
|
||||
$(".highlighted").removeClass("highlighted");
|
||||
element.addClass("highlighted");
|
||||
pos=element.offset().top-headerSize;
|
||||
var pos = element.offset().top - headerSize;
|
||||
$("html").animate({scrollTop:pos});
|
||||
}
|
||||
},
|
||||
|
||||
postRenderTemplate: function() {
|
||||
app.views.CommentStream.prototype.postRenderTemplate.apply(this)
|
||||
this.$(".new_comment_form_wrapper").removeClass('hidden')
|
||||
_.defer(this.highlightPermalinkComment)
|
||||
app.views.CommentStream.prototype.postRenderTemplate.apply(this);
|
||||
this.$(".new_comment_form_wrapper").removeClass('hidden');
|
||||
_.defer(this.highlightPermalinkComment);
|
||||
},
|
||||
|
||||
appendComment: function(comment) {
|
||||
// Set the post as the comment's parent, so we can check
|
||||
// on post ownership in the Comment view.
|
||||
comment.set({parent : this.model.toJSON()})
|
||||
comment.set({parent : this.model.toJSON()});
|
||||
|
||||
this.$(".comments").append(new app.views.ExpandedComment({
|
||||
model: comment
|
||||
|
|
@ -39,8 +39,7 @@ app.views.SinglePostCommentStream = app.views.CommentStream.extend({
|
|||
moreCommentsCount : 0,
|
||||
showExpandCommentsLink : false,
|
||||
commentsCount : this.model.interactions.commentsCount()
|
||||
})
|
||||
});
|
||||
},
|
||||
})
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -32,12 +32,11 @@ app.views.SinglePostContent = app.views.Base.extend({
|
|||
authorIsCurrentUser :app.currentUser.isAuthorOf(this.model),
|
||||
showPost : this.showPost(),
|
||||
text : app.helpers.textFormatter(this.model.get("text"), this.model.get("mentioned_people"))
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
showPost : function() {
|
||||
return (app.currentUser.get("showNsfw")) || !this.model.get("nsfw")
|
||||
return (app.currentUser.get("showNsfw")) || !this.model.get("nsfw");
|
||||
}
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ app.views.SinglePostInteractions = app.views.Base.extend({
|
|||
|
||||
initialize : function() {
|
||||
this.model.interactions.on('change', this.render, this);
|
||||
this.commentStreamView = new app.views.SinglePostCommentStream({model: this.model})
|
||||
this.commentStreamView = new app.views.SinglePostCommentStream({model: this.model});
|
||||
},
|
||||
|
||||
presenter : function(){
|
||||
var interactions = this.model.interactions
|
||||
var interactions = this.model.interactions;
|
||||
return {
|
||||
likes : interactions.likes.toJSON(),
|
||||
comments : interactions.comments.toJSON(),
|
||||
|
|
@ -22,8 +22,7 @@ app.views.SinglePostInteractions = app.views.Base.extend({
|
|||
commentsCount : interactions.commentsCount(),
|
||||
likesCount : interactions.likesCount(),
|
||||
resharesCount : interactions.resharesCount(),
|
||||
}
|
||||
};
|
||||
},
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@ app.views.SinglePostModeration = app.views.Feedback.extend({
|
|||
},
|
||||
|
||||
presenter: function() {
|
||||
var interactions = this.model.interactions;
|
||||
|
||||
return _.extend(this.defaultPresenter(), {
|
||||
authorIsCurrentUser : this.authorIsCurrentUser(),
|
||||
});
|
||||
|
|
@ -21,7 +19,7 @@ app.views.SinglePostModeration = app.views.Feedback.extend({
|
|||
},
|
||||
|
||||
authorIsCurrentUser: function() {
|
||||
return app.currentUser.authenticated() && this.model.get("author").id == app.user().id;
|
||||
return app.currentUser.authenticated() && this.model.get("author").id === app.user().id;
|
||||
},
|
||||
|
||||
destroyModel: function(evt) {
|
||||
|
|
@ -35,7 +33,7 @@ app.views.SinglePostModeration = app.views.Feedback.extend({
|
|||
document.location.href = "/stream";
|
||||
})
|
||||
.fail(function() {
|
||||
var flash = new Diaspora.Widgets.FlashMessages;
|
||||
var flash = new Diaspora.Widgets.FlashMessages();
|
||||
flash.render({
|
||||
success: false,
|
||||
notice: Diaspora.I18n.t('failed_to_remove')
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ app.views.StreamFaces = app.views.Base.extend({
|
|||
tooltipSelector : ".avatar",
|
||||
|
||||
initialize : function(){
|
||||
this.updatePeople()
|
||||
app.stream.items.bind("add", this.updatePeople, this)
|
||||
this.updatePeople();
|
||||
app.stream.items.bind("add", this.updatePeople, this);
|
||||
},
|
||||
|
||||
presenter : function() {
|
||||
return {people : this.people}
|
||||
return {people : this.people};
|
||||
},
|
||||
|
||||
updatePeople : function(){
|
||||
|
|
@ -30,4 +30,3 @@ app.views.StreamFaces = app.views.Base.extend({
|
|||
}
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ app.views.StreamPost = app.views.Post.extend({
|
|||
var normalizedClass = this.model.get("post_type").replace(/::/, "__")
|
||||
, postClass = app.views[normalizedClass] || app.views.StatusMessage;
|
||||
|
||||
return new postClass({ model : this.model })
|
||||
return new postClass({ model : this.model });
|
||||
},
|
||||
|
||||
postLocationStreamView : function(){
|
||||
|
|
@ -63,7 +63,7 @@ app.views.StreamPost = app.views.Post.extend({
|
|||
|
||||
removeNsfwShield: function(evt){
|
||||
if(evt){ evt.preventDefault(); }
|
||||
this.model.set({nsfw : false})
|
||||
this.model.set({nsfw : false});
|
||||
this.render();
|
||||
},
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ app.views.StreamPost = app.views.Post.extend({
|
|||
|
||||
remove : function() {
|
||||
$(this.el).slideUp(400, _.bind(function(){this.$el.remove()}, this));
|
||||
return this
|
||||
return this;
|
||||
},
|
||||
|
||||
hidePost : function(evt) {
|
||||
|
|
@ -121,6 +121,5 @@ app.views.StreamPost = app.views.Post.extend({
|
|||
return this;
|
||||
}
|
||||
|
||||
})
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -5,17 +5,17 @@
|
|||
app.views.Stream = app.views.InfScroll.extend(_.extend(
|
||||
app.views.StreamShortcuts, {
|
||||
|
||||
initialize: function(options) {
|
||||
this.stream = this.model
|
||||
this.collection = this.stream.items
|
||||
initialize: function() {
|
||||
this.stream = this.model;
|
||||
this.collection = this.stream.items;
|
||||
|
||||
this.postViews = []
|
||||
this.postViews = [];
|
||||
|
||||
this.setupNSFW()
|
||||
this.setupLightbox()
|
||||
this.setupInfiniteScroll()
|
||||
this.setupShortcuts()
|
||||
this.markNavSelected()
|
||||
this.setupNSFW();
|
||||
this.setupLightbox();
|
||||
this.setupInfiniteScroll();
|
||||
this.setupShortcuts();
|
||||
this.markNavSelected();
|
||||
},
|
||||
|
||||
postClass : app.views.StreamPost,
|
||||
|
|
@ -26,11 +26,10 @@ app.views.Stream = app.views.InfScroll.extend(_.extend(
|
|||
},
|
||||
|
||||
setupNSFW : function(){
|
||||
app.currentUser.bind("nsfwChanged", reRenderPostViews, this)
|
||||
|
||||
function reRenderPostViews() {
|
||||
_.map(this.postViews, function(view){ view.render() })
|
||||
_.map(this.postViews, function(view){ view.render() });
|
||||
}
|
||||
app.currentUser.bind("nsfwChanged", reRenderPostViews, this);
|
||||
},
|
||||
|
||||
markNavSelected : function() {
|
||||
|
|
@ -41,4 +40,3 @@ app.views.Stream = app.views.InfScroll.extend(_.extend(
|
|||
}
|
||||
}));
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ app.views.TagFollowingAction = app.views.Base.extend({
|
|||
return _.extend(this.defaultPresenter(), {
|
||||
tag_is_followed : this.tag_is_followed(),
|
||||
followString : this.followString()
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
followString : function() {
|
||||
|
|
@ -35,7 +35,7 @@ app.views.TagFollowingAction = app.views.Base.extend({
|
|||
return !this.model.isNew();
|
||||
},
|
||||
|
||||
getTagFollowing : function(tagFollowing) {
|
||||
getTagFollowing : function() {
|
||||
this.model = app.tagFollowings.where({"name":this.tagText})[0] ||
|
||||
new app.models.TagFollowing({"name":this.tagText});
|
||||
this.model.bind("change", this.render, this);
|
||||
|
|
@ -63,4 +63,3 @@ app.views.TagFollowingAction = app.views.Base.extend({
|
|||
}
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -41,9 +41,9 @@ app.views.TagFollowingList = app.views.Base.extend({
|
|||
});
|
||||
|
||||
this.$("input").bind('keydown', function(evt){
|
||||
if(evt.keyCode == 13 || evt.keyCode == 9 || evt.keyCode == 32){
|
||||
if(evt.keyCode === 13 || evt.keyCode === 9 || evt.keyCode === 32){
|
||||
evt.preventDefault();
|
||||
if( $('li.as-result-item.active').length == 0 ){
|
||||
if( $('li.as-result-item.active').length === 0 ){
|
||||
$('li.as-result-item').first().click();
|
||||
}
|
||||
}
|
||||
|
|
@ -62,7 +62,6 @@ app.views.TagFollowingList = app.views.Base.extend({
|
|||
|
||||
createTagFollowing: function(evt) {
|
||||
if(evt){ evt.preventDefault(); }
|
||||
var name = this.$(".tag_input").val();
|
||||
|
||||
this.collection.create({"name":this.$(".tag_input").val()});
|
||||
this.$(".tag_input").val("");
|
||||
|
|
@ -80,4 +79,3 @@ app.views.TagFollowingList = app.views.Base.extend({
|
|||
},
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -29,9 +29,8 @@ app.views.TagFollowing = app.views.Base.extend({
|
|||
presenter : function() {
|
||||
return _.extend(this.defaultPresenter(), {
|
||||
tag : this.model
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,8 @@
|
|||
|
||||
app.views.Tags = Backbone.View.extend({
|
||||
|
||||
initialize: function(opts) {
|
||||
initialize: function() {
|
||||
app.publisher.setText("#"+ this.tagName + " ");
|
||||
}
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -10,36 +10,37 @@ var AspectsDropdown = {
|
|||
selectedAspects = dropdown.children(".selected").length,
|
||||
allAspects = dropdown.children().length,
|
||||
replacement,
|
||||
message,
|
||||
isInPublisher = dropdown.closest('#publisher').length;
|
||||
|
||||
if (number == 0) {
|
||||
if (number === 0) {
|
||||
button.removeClass(inAspectClass);
|
||||
if (isInPublisher) {
|
||||
replacement = Diaspora.I18n.t("aspect_dropdown.select_aspects");
|
||||
} else {
|
||||
replacement = Diaspora.I18n.t("aspect_dropdown.add_to_aspect");
|
||||
/* flash message prompt */
|
||||
var message = Diaspora.I18n.t("aspect_dropdown.stopped_sharing_with", {name: dropdown.data('person-short-name')});
|
||||
message = Diaspora.I18n.t("aspect_dropdown.stopped_sharing_with", {name: dropdown.data('person-short-name')});
|
||||
Diaspora.page.flashMessages.render({success: true, notice: message});
|
||||
}
|
||||
} else if (selectedAspects == allAspects) {
|
||||
} else if (selectedAspects === allAspects) {
|
||||
replacement = Diaspora.I18n.t('aspect_dropdown.all_aspects');
|
||||
} else if (number == 1) {
|
||||
} else if (number === 1) {
|
||||
button.addClass(inAspectClass);
|
||||
replacement = dropdown.find(".selected").first().text();
|
||||
/* flash message prompt */
|
||||
if (!isInPublisher) {
|
||||
var message = Diaspora.I18n.t("aspect_dropdown.started_sharing_with", {name: dropdown.data('person-short-name')});
|
||||
message = Diaspora.I18n.t("aspect_dropdown.started_sharing_with", {name: dropdown.data('person-short-name')});
|
||||
Diaspora.page.flashMessages.render({success: true, notice: message});
|
||||
}
|
||||
} else {
|
||||
replacement = Diaspora.I18n.t('aspect_dropdown.toggle', { count: number.toString()})
|
||||
replacement = Diaspora.I18n.t('aspect_dropdown.toggle', { count: number.toString()});
|
||||
}
|
||||
|
||||
// if we are in the publisher, we add the visibility icon
|
||||
if (isInPublisher) {
|
||||
var icon = $('#visibility-icon');
|
||||
if (replacement.trim() == Diaspora.I18n.t('stream.public')) {
|
||||
if (replacement.trim() === Diaspora.I18n.t('stream.public')) {
|
||||
icon.removeClass('lock');
|
||||
icon.addClass('globe');
|
||||
} else {
|
||||
|
|
@ -74,6 +75,4 @@ var AspectsDropdown = {
|
|||
});
|
||||
}
|
||||
};
|
||||
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ $.fn.clearForm = function() {
|
|||
$(this).attr('checked', false);
|
||||
} else if ($(this).is('select')) {
|
||||
this.selectedIndex = -1;
|
||||
} else if ($(this).attr('name') == 'photos[]') {
|
||||
} else if ($(this).attr('name') === 'photos[]') {
|
||||
$(this).val('');
|
||||
}
|
||||
$(this).blur();
|
||||
|
|
|
|||
|
|
@ -21,14 +21,18 @@
|
|||
var eventNames = eventName.split(" ");
|
||||
|
||||
for(eventName in eventNames) {
|
||||
this.eventsContainer.trigger(eventNames[eventName], args);
|
||||
if(eventNames.hasOwnProperty(eventName)) {
|
||||
this.eventsContainer.trigger(eventNames[eventName], args);
|
||||
}
|
||||
}
|
||||
},
|
||||
subscribe: function(eventName, callback, context) {
|
||||
var eventNames = eventName.split(" ");
|
||||
|
||||
for(eventName in eventNames) {
|
||||
this.eventsContainer.bind(eventNames[eventName], $.proxy(callback, context));
|
||||
if(eventNames.hasOwnProperty(eventName)) {
|
||||
this.eventsContainer.bind(eventNames[eventName], $.proxy(callback, context));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -38,7 +42,7 @@
|
|||
};
|
||||
|
||||
Diaspora.BaseWidget = {
|
||||
instantiate: function(Widget, element) {
|
||||
instantiate: function(Widget) {
|
||||
// Mobile version loads only some widgets
|
||||
if (typeof Diaspora.Widgets[Widget] === 'undefined') return;
|
||||
|
||||
|
|
@ -85,18 +89,16 @@
|
|||
|
||||
if(!$.mobile)//why does this need this?
|
||||
$.extend(Diaspora.page, new Diaspora.BasePage($(document.body)));
|
||||
Diaspora.page.publish("page/ready", [$(document.body)])
|
||||
Diaspora.page.publish("page/ready", [$(document.body)]);
|
||||
};
|
||||
|
||||
// temp hack to check if backbone is enabled for the page
|
||||
Diaspora.backboneEnabled = function(){
|
||||
return window.app && window.app.stream !== undefined;
|
||||
}
|
||||
};
|
||||
|
||||
window.Diaspora = Diaspora;
|
||||
})();
|
||||
|
||||
|
||||
$(Diaspora.instantiatePage);
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ Diaspora.I18n = {
|
|||
pluralizationKey: function(n) { return this.fallback.pluralizationKey(n); },
|
||||
data: {},
|
||||
fallback: {
|
||||
pluralizationKey: function(n) { return n == 1 ? "one" : "other"; },
|
||||
pluralizationKey: function(n) { return n === 1 ? "one" : "other"; },
|
||||
data: {}
|
||||
}
|
||||
},
|
||||
|
|
@ -20,9 +20,12 @@ Diaspora.I18n = {
|
|||
updateLocale: function(locale, data) {
|
||||
locale.data = $.extend(locale.data, data);
|
||||
|
||||
rule = this._resolve(locale, ['pluralization_rule']);
|
||||
var rule = this._resolve(locale, ['pluralization_rule']);
|
||||
if (rule !== "") {
|
||||
/* jshint evil:true */
|
||||
// TODO change this to `locale.pluralizationKey = rule`?
|
||||
eval("locale.pluralizationKey = "+rule);
|
||||
/* jshint evil:false */
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -37,7 +40,7 @@ Diaspora.I18n = {
|
|||
_resolve: function(locale, items) {
|
||||
var translatedMessage, nextNamespace, originalItems = items.slice();
|
||||
|
||||
while(nextNamespace = items.shift()) {
|
||||
while( (nextNamespace = items.shift()) ) {
|
||||
translatedMessage = (translatedMessage)
|
||||
? translatedMessage[nextNamespace]
|
||||
: locale.data[nextNamespace];
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ $(document).ready(function(){
|
|||
cBadge.html().replace(/\d+/, function(num){
|
||||
num = parseInt(num);
|
||||
cBadge.html(parseInt(num)-1);
|
||||
if(num == 1) {
|
||||
if(num === 1) {
|
||||
cBadge.addClass("hidden");
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ $(document).ready(function() {
|
|||
overwrite: true,
|
||||
onlogin: true
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ $(document).ready(function(){
|
|||
dataType: 'json',
|
||||
type: 'DELETE',
|
||||
beforeSend: showLoader(link),
|
||||
complete: function(data){
|
||||
complete: function(){
|
||||
removeLoader(link);
|
||||
link.attr("href", href.replace(/\/\d+$/, ''));
|
||||
|
||||
|
|
@ -110,10 +110,10 @@ $(document).ready(function(){
|
|||
dataType: 'json',
|
||||
type: 'POST',
|
||||
beforeSend: showLoader(link),
|
||||
success: function(data){
|
||||
success: function(){
|
||||
removeLoader(link);
|
||||
},
|
||||
error: function(data){
|
||||
error: function(){
|
||||
removeLoader(link);
|
||||
alert("Failed to reshare!");
|
||||
}
|
||||
|
|
@ -128,7 +128,7 @@ $(document).ready(function(){
|
|||
evt.preventDefault();
|
||||
var link = $(this),
|
||||
parent = link.closest(".bottom_bar").first(),
|
||||
commentsContainer = function(){ return parent.find(".comment_container").first(); }
|
||||
commentsContainer = function(){ return parent.find(".comment_container").first(); },
|
||||
existingCommentsContainer = commentsContainer();
|
||||
|
||||
if( link.hasClass('active') ) {
|
||||
|
|
@ -200,7 +200,7 @@ $(document).ready(function(){
|
|||
context: link,
|
||||
success: function(data){
|
||||
var textarea = function(target) { return target.closest(".stream_element").find('textarea.comment_box').first()[0] };
|
||||
link.removeClass('loading')
|
||||
link.removeClass('loading');
|
||||
|
||||
if(!link.hasClass("add_comment_bottom_link")){
|
||||
link.removeClass('inactive');
|
||||
|
|
@ -217,9 +217,9 @@ $(document).ready(function(){
|
|||
|
||||
$(".stream").delegate("a.cancel_new_comment", "tap click", function(evt){
|
||||
evt.preventDefault();
|
||||
var link = $(this);
|
||||
var link = $(this),
|
||||
form = link.closest("form"),
|
||||
commentActionLink = link.closest(".bottom_bar").find("a.comment_action").first();
|
||||
commentActionLink = link.closest(".bottom_bar").find("a.comment_action").first(),
|
||||
container = link.closest('.bottom_bar').find('.add_comment_bottom_link_container');
|
||||
|
||||
if(container.length > 0 ){
|
||||
|
|
@ -237,7 +237,7 @@ $(document).ready(function(){
|
|||
$.post(form.attr('action')+"?format=mobile", form.serialize(), function(data){
|
||||
var bottomBar = form.closest('.bottom_bar').first(),
|
||||
container = bottomBar.find('.add_comment_bottom_link_container'),
|
||||
commentActionLink = bottomBar.find("a.comment_action").first();
|
||||
commentActionLink = bottomBar.find("a.comment_action").first(),
|
||||
reactionLink = bottomBar.find(".show_comments").first(),
|
||||
commentCount = bottomBar.find(".comment_count");
|
||||
|
||||
|
|
@ -247,13 +247,13 @@ $(document).ready(function(){
|
|||
container.show();
|
||||
|
||||
} else {
|
||||
var container = $("<div class='comments_container not_all_present'></div>"),
|
||||
comments = $("<ul class='comments'></ul>");
|
||||
var comments = $("<ul class='comments'></ul>");
|
||||
container = $("<div class='comments_container not_all_present'></div>");
|
||||
|
||||
comments.html(data);
|
||||
container.append(comments);
|
||||
form.remove();
|
||||
container.appendTo(bottomBar)
|
||||
container.appendTo(bottomBar);
|
||||
}
|
||||
|
||||
reactionLink.text(reactionLink.text().replace(/(\d+)/, function(match){ return parseInt(match) + 1; }));
|
||||
|
|
@ -264,7 +264,7 @@ $(document).ready(function(){
|
|||
});
|
||||
|
||||
|
||||
$(".service_icon").bind("tap click", function(evt) {
|
||||
$(".service_icon").bind("tap click", function() {
|
||||
var service = $(this).toggleClass("dim"),
|
||||
selectedServices = $("#new_status_message .service_icon:not(.dim)"),
|
||||
provider = service.attr("id"),
|
||||
|
|
@ -302,6 +302,4 @@ $(document).ready(function(){
|
|||
});
|
||||
|
||||
});
|
||||
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ function createUploader(){
|
|||
|
||||
var aspectIds = gon.preloads.aspect_ids;
|
||||
|
||||
var uploader = new qq.FileUploaderBasic({
|
||||
new qq.FileUploaderBasic({
|
||||
element: document.getElementById('file-upload-publisher'),
|
||||
params: {'photo' : {'pending' : 'true', 'aspect_ids' : aspectIds},},
|
||||
allowedExtensions: ['jpg', 'jpeg', 'png', 'gif', 'tiff'],
|
||||
|
|
@ -25,7 +25,7 @@ function createUploader(){
|
|||
emptyError: Diaspora.I18n.t("photo_uploader.new_photo.empty")
|
||||
},
|
||||
|
||||
onSubmit: function(id, fileName){
|
||||
onSubmit: function(){
|
||||
$('#file-upload-publisher').addClass("loading");
|
||||
$('#publisher_textarea_wrapper').addClass("with_attachments");
|
||||
$('#photodropzone').append(
|
||||
|
|
@ -35,7 +35,7 @@ function createUploader(){
|
|||
);
|
||||
},
|
||||
|
||||
onComplete: function(id, fileName, responseJSON) {
|
||||
onComplete: function(_id, fileName, responseJSON) {
|
||||
$('#fileInfo-publisher').text(Diaspora.I18n.t("photo_uploader.completed", {'file': fileName}));
|
||||
var id = responseJSON.data.photo.id,
|
||||
url = responseJSON.data.photo.unprocessed_image.url,
|
||||
|
|
@ -53,8 +53,7 @@ function createUploader(){
|
|||
"<div class='circle'></div>");
|
||||
////
|
||||
|
||||
var publisher = $('#publisher'),
|
||||
textarea = publisher.find('textarea');
|
||||
var publisher = $('#publisher');
|
||||
|
||||
publisher.find("input[type='submit']").removeAttr('disabled');
|
||||
|
||||
|
|
@ -67,7 +66,7 @@ function createUploader(){
|
|||
success: function() {
|
||||
photo.fadeOut(400, function(){
|
||||
photo.remove();
|
||||
if ( $('.publisher_photo').length == 0){
|
||||
if ( $('.publisher_photo').length === 0){
|
||||
$('#publisher_textarea_wrapper').removeClass("with_attachments");
|
||||
}
|
||||
});
|
||||
|
|
@ -76,7 +75,7 @@ function createUploader(){
|
|||
});
|
||||
},
|
||||
|
||||
onAllComplete: function(completed_files){
|
||||
onAllComplete: function(){
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,22 +6,20 @@ OSM.Locator = function(){
|
|||
|
||||
var geolocalize = function(callback){
|
||||
navigator.geolocation.getCurrentPosition(function(position) {
|
||||
lat=position.coords.latitude;
|
||||
lon=position.coords.longitude;
|
||||
var display_name =$.getJSON("https://nominatim.openstreetmap.org/reverse?format=json&lat="+lat+"&lon="+lon+"&addressdetails=3", function(data){
|
||||
var lat=position.coords.latitude,
|
||||
lon=position.coords.longitude;
|
||||
$.getJSON("https://nominatim.openstreetmap.org/reverse?format=json&lat="+lat+"&lon="+lon+"&addressdetails=3", function(data){
|
||||
return callback(data.display_name, position.coords);
|
||||
});
|
||||
},errorGettingPosition);
|
||||
};
|
||||
|
||||
function errorGettingPosition(err) {
|
||||
function errorGettingPosition() {
|
||||
$("#location").remove();
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
getAddress: geolocalize
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
};
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ Diaspora.Pages.UsersGettingStarted = function() {
|
|||
self.peopleSearch = self.instantiate("Search", body.find("form.people.search_form"));
|
||||
self.tagSearch = self.instantiate("Search", body.find("form.tag_input.search_form"));
|
||||
|
||||
$('#edit_profile').bind('ajax:success', function(evt, data, status, xhr){
|
||||
$('#edit_profile').bind('ajax:success', function(){
|
||||
$('#gs-name-form-spinner').addClass("hidden");
|
||||
});
|
||||
|
||||
// It seems that the default behavior of rails ujs is to clear the remote form
|
||||
$('#edit_profile').bind('ajax:complete', function(evt, xhr, status){
|
||||
$('#edit_profile').bind('ajax:complete', function(){
|
||||
var firstNameField = $("#profile_first_name");
|
||||
firstNameField.val(firstNameField.data("cachedValue"));
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ Diaspora.Pages.UsersGettingStarted = function() {
|
|||
$(this).addClass("active_input");
|
||||
});
|
||||
|
||||
$("#awesome_button").bind("click", function(evt){
|
||||
$("#awesome_button").bind("click", function(){
|
||||
var confirmMessage = Diaspora.I18n.t("getting_started.no_tags");
|
||||
var message = Diaspora.I18n.t("getting_started.preparing_your_stream");
|
||||
var confirmation = true;
|
||||
|
|
@ -73,9 +73,9 @@ Diaspora.Pages.UsersGettingStarted = function() {
|
|||
});
|
||||
|
||||
autocompleteInput.bind('keydown', function(evt){
|
||||
if(evt.keyCode == 13 || evt.keyCode == 9 || evt.keyCode == 32){
|
||||
if(evt.keyCode === 13 || evt.keyCode === 9 || evt.keyCode === 32){
|
||||
evt.preventDefault();
|
||||
if( $('li.as-result-item.active').length == 0 ){
|
||||
if( $('li.as-result-item.active').length === 0 ){
|
||||
$('li.as-result-item').first().click();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,20 +38,20 @@ var View = {
|
|||
$(this).attr('checked', false);
|
||||
} else if ($(this).is('select')) {
|
||||
this.selectedIndex = -1;
|
||||
} else if ($(this).attr('name') == 'photos[]') {
|
||||
} else if ($(this).attr('name') === 'photos[]') {
|
||||
$(this).val('');
|
||||
}
|
||||
$(this).blur();
|
||||
});
|
||||
};
|
||||
|
||||
$(document).on('ajax:success', 'form[data-remote]', function (e) {
|
||||
$(document).on('ajax:success', 'form[data-remote]', function () {
|
||||
$(this).clearForm();
|
||||
$(this).focusout();
|
||||
});
|
||||
|
||||
/* tag following */
|
||||
$("#new_tag_following .tag_input").bind('focus', function(evt){
|
||||
$("#new_tag_following .tag_input").bind('focus', function(){
|
||||
$(this).siblings("#tag_following_submit").removeClass('hidden');
|
||||
});
|
||||
|
||||
|
|
@ -62,8 +62,8 @@ var View = {
|
|||
Diaspora.page.directionDetector.updateBinds();
|
||||
});
|
||||
|
||||
$("a.new_aspect").click(function(e){
|
||||
$("input#aspect_name").focus()
|
||||
$("a.new_aspect").click(function(){
|
||||
$("input#aspect_name").focus();
|
||||
});
|
||||
|
||||
/* facebox 'done' buttons */
|
||||
|
|
@ -111,4 +111,3 @@ $(function() {
|
|||
View.initialize();
|
||||
});
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -27,11 +27,10 @@
|
|||
(self.body.scrollTop() > 1000) ?
|
||||
'addClass' :
|
||||
'removeClass'
|
||||
]('visible')
|
||||
]('visible');
|
||||
};
|
||||
};
|
||||
|
||||
Diaspora.Widgets.BackToTop = BackToTop;
|
||||
})();
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ jQuery.fn.center = (function() {
|
|||
imageSelector: 'img.stream-photo'
|
||||
};
|
||||
|
||||
this.subscribe("widget/ready", function(evt) {
|
||||
this.subscribe("widget/ready", function() {
|
||||
$.extend(self, {
|
||||
lightbox: $("#lightbox"),
|
||||
navigation: $("#lightbox-navigation"),
|
||||
|
|
@ -94,7 +94,7 @@ jQuery.fn.center = (function() {
|
|||
|
||||
this.nextImage = function(thumb){
|
||||
var next = thumb.next();
|
||||
if (next.length == 0) {
|
||||
if (next.length === 0) {
|
||||
next = self.imageset.find("img").first();
|
||||
}
|
||||
return(next);
|
||||
|
|
@ -102,7 +102,7 @@ jQuery.fn.center = (function() {
|
|||
|
||||
this.prevImage = function(thumb){
|
||||
var prev = thumb.prev();
|
||||
if (prev.length == 0) {
|
||||
if (prev.length === 0) {
|
||||
prev = self.imageset.find("img").last();
|
||||
}
|
||||
return(prev);
|
||||
|
|
@ -130,9 +130,9 @@ jQuery.fn.center = (function() {
|
|||
"data-full-photo": image.attr("data-full-photo")
|
||||
});
|
||||
|
||||
if(image.attr("data-full-photo") == imageUrl) {
|
||||
if(image.attr("data-full-photo") === imageUrl) {
|
||||
imageThumb = thumb;
|
||||
};
|
||||
}
|
||||
|
||||
self.imageset.append(thumb);
|
||||
});
|
||||
|
|
@ -154,7 +154,7 @@ jQuery.fn.center = (function() {
|
|||
this.scrollToThumbnail = function(imageThumb) {
|
||||
self.navigation.animate({scrollLeft: (self.navigation.scrollLeft()
|
||||
+ imageThumb.offset().left +35 - (self.window.width() / 2))}, 200, 'swing');
|
||||
}
|
||||
};
|
||||
|
||||
this.selectImage = function(imageThumb) {
|
||||
$(".selected", self.imageset).removeClass("selected");
|
||||
|
|
|
|||
|
|
@ -85,10 +85,10 @@
|
|||
});
|
||||
self.dropdownNotifications.find("time.timeago").timeago();
|
||||
|
||||
self.dropdownNotifications.find('.unread').each(function(index) {
|
||||
self.dropdownNotifications.find('.unread').each(function() {
|
||||
Diaspora.page.header.notifications.setUpUnread( $(this) );
|
||||
});
|
||||
self.dropdownNotifications.find('.read').each(function(index) {
|
||||
self.dropdownNotifications.find('.read').each(function() {
|
||||
Diaspora.page.header.notifications.setUpRead( $(this) );
|
||||
});
|
||||
$('.notifications').perfectScrollbar('destroy');
|
||||
|
|
@ -97,10 +97,10 @@
|
|||
isLoading = false;
|
||||
$('.notifications').removeClass("loading");
|
||||
//Infinite Scrolling
|
||||
$('.notifications').scroll(function(e) {
|
||||
$('.notifications').scroll(function() {
|
||||
var bottom = $('.notifications').prop('scrollHeight') - $('.notifications').height();
|
||||
var currentPosition = $('.notifications').scrollTop();
|
||||
isLoading = ($('.loading').length == 1);
|
||||
isLoading = ($('.loading').length === 1);
|
||||
if (currentPosition + 50 >= bottom && notificationsLoaded <= self.notifications.length && !isLoading) {
|
||||
$('.notifications').addClass("loading");
|
||||
++currentPage;
|
||||
|
|
@ -113,4 +113,3 @@
|
|||
Diaspora.Widgets.NotificationsDropdown = NotificationDropdown;
|
||||
})();
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
type: "GET",
|
||||
dataType:'json',
|
||||
success: function(){
|
||||
self.notificationMenu.find('.unread').each(function(index) {
|
||||
self.notificationMenu.find('.unread').each(function() {
|
||||
self.setUpRead( $(this) );
|
||||
});
|
||||
self.resetCount();
|
||||
|
|
@ -41,7 +41,7 @@
|
|||
});
|
||||
this.setUpNotificationPage = function( page ) {
|
||||
self.notificationPage = page;
|
||||
}
|
||||
};
|
||||
this.unreadClick = function() {
|
||||
$.ajax({
|
||||
url: "/notifications/" + $(this).closest(".stream_element,.notification_element").data("guid"),
|
||||
|
|
@ -68,7 +68,7 @@
|
|||
.removeAttr('data-original-title')
|
||||
.attr('title', Diaspora.I18n.t('notifications.mark_read'))
|
||||
.tooltip();
|
||||
}
|
||||
};
|
||||
this.setUpRead = function( an_obj ) {
|
||||
an_obj.removeClass("unread").addClass( "read" );
|
||||
an_obj.find('.unread-toggle')
|
||||
|
|
@ -79,17 +79,17 @@
|
|||
.removeAttr('data-original-title')
|
||||
.attr('title', Diaspora.I18n.t('notifications.mark_unread'))
|
||||
.tooltip();
|
||||
}
|
||||
};
|
||||
this.clickSuccess = function( data ) {
|
||||
var itemID = data["guid"]
|
||||
var isUnread = data["unread"]
|
||||
self.notificationMenu.find('.read,.unread').each(function(index) {
|
||||
if ( $(this).data("guid") == itemID ) {
|
||||
var itemID = data["guid"];
|
||||
var isUnread = data["unread"];
|
||||
self.notificationMenu.find('.read,.unread').each(function() {
|
||||
if ( $(this).data("guid") === itemID ) {
|
||||
if ( isUnread ) {
|
||||
self.notificationMenu.find('a#mark_all_read_link').removeClass('disabled')
|
||||
self.setUpUnread( $(this) )
|
||||
self.notificationMenu.find('a#mark_all_read_link').removeClass('disabled');
|
||||
self.setUpUnread( $(this) );
|
||||
} else {
|
||||
self.setUpRead( $(this) )
|
||||
self.setUpRead( $(this) );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -118,7 +118,7 @@
|
|||
};
|
||||
|
||||
this.changeNotificationCount = function(change) {
|
||||
self.count = Math.max( self.count + change, 0 )
|
||||
self.count = Math.max( self.count + change, 0 );
|
||||
self.badge.text(self.count);
|
||||
|
||||
if(self.count === 0) {
|
||||
|
|
@ -128,7 +128,7 @@
|
|||
self.badge.removeClass("hidden");
|
||||
}
|
||||
};
|
||||
this.resetCount = function(change) {
|
||||
this.resetCount = function() {
|
||||
self.count = 0;
|
||||
this.changeNotificationCount(0);
|
||||
};
|
||||
|
|
@ -145,4 +145,3 @@
|
|||
Diaspora.Widgets.Notifications = Notifications;
|
||||
})();
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
this.parse = function(data) {
|
||||
var results = data.map(function(person){
|
||||
person['name'] = Handlebars.Utils.escapeExpression(person['name']);
|
||||
return {data : person, value : person['name']}
|
||||
return {data : person, value : person['name']};
|
||||
});
|
||||
|
||||
results.push({
|
||||
|
|
@ -81,4 +81,3 @@
|
|||
Diaspora.Widgets.Search = Search;
|
||||
})();
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
|
|
@ -6,14 +6,12 @@
|
|||
*/
|
||||
(function() {
|
||||
Diaspora.Widgets.TimeAgo = function() {
|
||||
var self = this;
|
||||
|
||||
this.subscribe("widget/ready", function() {
|
||||
if(Diaspora.I18n.language !== "en") {
|
||||
$.timeago.settings.lang = Diaspora.I18n.language;
|
||||
$.timeago.settings.strings[Diaspora.I18n.language] = {}
|
||||
$.timeago.settings.strings[Diaspora.I18n.language] = {};
|
||||
$.each($.timeago.settings.strings["en"], function(index) {
|
||||
if(index == "numbers") {
|
||||
if(index === "numbers") {
|
||||
$.timeago.settings.strings[Diaspora.I18n.language][index] = [];
|
||||
}
|
||||
else {
|
||||
|
|
@ -25,4 +23,3 @@
|
|||
};
|
||||
})();
|
||||
// @license-end
|
||||
|
||||
|
|
|
|||
65
config/.jshint.json
Normal file
65
config/.jshint.json
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
{
|
||||
"bitwise": false,
|
||||
"camelcase": false,
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"forin": true,
|
||||
"freeze": true,
|
||||
"immed": true,
|
||||
"indent": 2,
|
||||
"latedef": true,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"noempty": true,
|
||||
"nonbsp": true,
|
||||
"nonew": false,
|
||||
"notypeof": true,
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
|
||||
"asi": false,
|
||||
"boss": false,
|
||||
"browser": true,
|
||||
"devel": true,
|
||||
"eqnull": true,
|
||||
"evil": false,
|
||||
"expr": false,
|
||||
"jasmine": true,
|
||||
"jquery": true,
|
||||
"lastsemic": true,
|
||||
"laxbreak": false,
|
||||
"laxcomma": false,
|
||||
"loopfunc": false,
|
||||
"scripturl": false,
|
||||
"sub": false,
|
||||
"supernew": true,
|
||||
|
||||
"predef": [
|
||||
"_",
|
||||
"Backbone",
|
||||
"gon",
|
||||
"Handlebars",
|
||||
"HandlebarsTemplates",
|
||||
"ImagePaths",
|
||||
"jsxc",
|
||||
"MBP",
|
||||
"Routes",
|
||||
"OSM",
|
||||
"parse_url",
|
||||
"punycode",
|
||||
"qq",
|
||||
|
||||
"loginAs",
|
||||
"logout",
|
||||
"spec",
|
||||
"context",
|
||||
"factory",
|
||||
"stubView",
|
||||
"exports",
|
||||
|
||||
"app",
|
||||
"Diaspora",
|
||||
"Mentions",
|
||||
"PosixBracketExpressions"
|
||||
]
|
||||
}
|
||||
5
config/.jshint_ignore
Normal file
5
config/.jshint_ignore
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
vendor/assets/javascripts/**.js
|
||||
lib/assets/javascripts/fileuploader-custom.js
|
||||
lib/assets/javascripts/jquery.autoresize.js
|
||||
lib/assets/javascripts/jquery.mentionsInput.js
|
||||
lib/assets/javascripts/markdown-it-diaspora-linkify.js
|
||||
72
config/jshint.yml
Normal file
72
config/jshint.yml
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
files: ['**/*.js']
|
||||
|
||||
exclude_paths: [
|
||||
'vendor/assets/javascripts',
|
||||
'lib/assets/javascripts'
|
||||
]
|
||||
|
||||
options:
|
||||
# enforcing options
|
||||
bitwise: false
|
||||
camelcase: false
|
||||
curly: true
|
||||
eqeqeq: true
|
||||
forin: true
|
||||
freeze: true
|
||||
immed: true
|
||||
indent: 2
|
||||
latedef: true
|
||||
newcap: true
|
||||
noarg: true
|
||||
noempty: true
|
||||
nonbsp: true
|
||||
nonew: false
|
||||
notypeof: true
|
||||
undef: true
|
||||
unused: true
|
||||
|
||||
# relaxing options
|
||||
asi: false
|
||||
boss: false
|
||||
browser: true
|
||||
devel: true
|
||||
eqnull: true
|
||||
evil: false
|
||||
expr: false
|
||||
jasmine: true
|
||||
jquery: true
|
||||
lastsemic: true
|
||||
laxbreak: false
|
||||
laxcomma: false
|
||||
loopfunc: false
|
||||
scripturl: false
|
||||
sub: false
|
||||
supernew: true
|
||||
|
||||
globals:
|
||||
"_": true
|
||||
"Backbone": true
|
||||
"gon": true
|
||||
"Handlebars": true
|
||||
"HandlebarsTemplates": true
|
||||
"ImagePaths": true
|
||||
"jsxc": true
|
||||
"MBP": true
|
||||
"Routes": true
|
||||
"OSM": true
|
||||
"parse_url": true
|
||||
"punycode": true
|
||||
"qq": true
|
||||
|
||||
"loginAs": true
|
||||
"logout": true
|
||||
"spec": true
|
||||
"context": true
|
||||
"factory": true
|
||||
"stubView": true
|
||||
"exports": true
|
||||
|
||||
"app": true
|
||||
"Diaspora": true
|
||||
"Mentions": true
|
||||
"PosixBracketExpressions": true
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
|
||||
|
||||
// information for jshint
|
||||
/* exported PosixBracketExpressions */
|
||||
|
||||
var PosixBracketExpressions = {
|
||||
alnum : '\\u0030-\\u0039'
|
||||
+ '\\u0041-\\u005a'
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ describe("app", function() {
|
|||
});
|
||||
|
||||
it("sets the user if given one and returns the current user", function() {
|
||||
expect(app.user()).toBeFalsy()
|
||||
expect(app.user()).toBeFalsy();
|
||||
app.user({name: "alice"});
|
||||
expect(app.user().get("name")).toEqual("alice");
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
describe("app.collections.comments", function(){
|
||||
describe("url", function(){
|
||||
it("should user the post id", function(){
|
||||
var post =new app.models.Post({id : 5})
|
||||
var collection = new app.collections.Comments([], {post : post})
|
||||
expect(collection.url()).toBe("/posts/5/comments")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
var post =new app.models.Post({id : 5});
|
||||
var collection = new app.collections.Comments([], {post : post});
|
||||
expect(collection.url()).toBe("/posts/5/comments");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
describe("app.collections.Likes", function(){
|
||||
describe("url", function(){
|
||||
it("should user the post id", function(){
|
||||
var post =new app.models.Post({id : 5})
|
||||
var collection = new app.collections.Likes([], {post : post})
|
||||
expect(collection.url).toBe("/posts/5/likes")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
var post =new app.models.Post({id : 5});
|
||||
var collection = new app.collections.Likes([], {post : post});
|
||||
expect(collection.url).toBe("/posts/5/likes");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
describe("app.collections.TagFollowings", function(){
|
||||
beforeEach(function(){
|
||||
this.collection = new app.collections.TagFollowings();
|
||||
})
|
||||
});
|
||||
|
||||
describe("comparator", function() {
|
||||
it("should compare in reverse order", function() {
|
||||
var a = new app.models.TagFollowing({name: "aaa"}),
|
||||
b = new app.models.TagFollowing({name: "zzz"})
|
||||
expect(this.collection.comparator(a, b)).toBeGreaterThan(0)
|
||||
})
|
||||
})
|
||||
b = new app.models.TagFollowing({name: "zzz"});
|
||||
expect(this.collection.comparator(a, b)).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("create", function(){
|
||||
it("should not allow duplicates", function(){
|
||||
this.collection.create({"name":"name"})
|
||||
this.collection.create({"name":"name"})
|
||||
expect(this.collection.length).toBe(1)
|
||||
})
|
||||
})
|
||||
})
|
||||
this.collection.create({"name":"name"});
|
||||
this.collection.create({"name":"name"});
|
||||
expect(this.collection.length).toBe(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,31 +3,30 @@ describe("app.helpers.dateFormatter", function(){
|
|||
beforeEach(function(){
|
||||
this.statusMessage = factory.post();
|
||||
this.formatter = app.helpers.dateFormatter;
|
||||
})
|
||||
});
|
||||
|
||||
describe("parse", function(){
|
||||
context("modern web browsers", function(){
|
||||
it ("supports ISO 8601 UTC dates", function(){
|
||||
var timestamp = new Date(this.statusMessage.get("created_at")).getTime();
|
||||
expect(this.formatter.parse(this.statusMessage.get("created_at"))).toEqual(timestamp);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
context("legacy web browsers", function(){
|
||||
it("supports ISO 8601 UTC dates", function(){
|
||||
var timestamp = new Date(this.statusMessage.get("created_at")).getTime();
|
||||
|
||||
expect(this.formatter.parseISO8601UTC(this.statusMessage.get("created_at"))).toEqual(timestamp);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
context("status messages", function(){
|
||||
it("uses ISO 8601 UTC dates", function(){
|
||||
var iso8601_utc_pattern = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(.(\d{3}))?Z$/;
|
||||
|
||||
expect(iso8601_utc_pattern.test(this.statusMessage.get("created_at"))).toBe(true);
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ describe("app.helpers.textFormatter", function(){
|
|||
beforeEach(function(){
|
||||
this.statusMessage = factory.post();
|
||||
this.formatter = app.helpers.textFormatter;
|
||||
})
|
||||
});
|
||||
|
||||
// Some basic specs. For more detailed specs see
|
||||
// https://github.com/svbergerem/markdown-it-hashtag/tree/master/test
|
||||
|
|
@ -34,25 +34,25 @@ describe("app.helpers.textFormatter", function(){
|
|||
name : "Alice Smith",
|
||||
diaspora_id : "alice@example.com",
|
||||
id : "555"
|
||||
})
|
||||
});
|
||||
|
||||
this.bob = factory.author({
|
||||
name : "Bob Grimm",
|
||||
diaspora_id : "bob@example.com",
|
||||
id : "666"
|
||||
})
|
||||
});
|
||||
|
||||
this.statusMessage.set({text: "hey there @{Alice Smith; alice@example.com} and @{Bob Grimm; bob@example.com}"})
|
||||
this.statusMessage.set({mentioned_people : [this.alice, this.bob]})
|
||||
})
|
||||
this.statusMessage.set({text: "hey there @{Alice Smith; alice@example.com} and @{Bob Grimm; bob@example.com}"});
|
||||
this.statusMessage.set({mentioned_people : [this.alice, this.bob]});
|
||||
});
|
||||
|
||||
it("matches mentions", function(){
|
||||
var formattedText = this.formatter(this.statusMessage.get("text"), this.statusMessage.get("mentioned_people"))
|
||||
var formattedText = this.formatter(this.statusMessage.get("text"), this.statusMessage.get("mentioned_people"));
|
||||
var wrapper = $("<div>").html(formattedText);
|
||||
|
||||
_.each([this.alice, this.bob], function(person) {
|
||||
expect(wrapper.find("a[href='/people/" + person.guid + "']").text()).toContain(person.name)
|
||||
})
|
||||
expect(wrapper.find("a[href='/people/" + person.guid + "']").text()).toContain(person.name);
|
||||
});
|
||||
});
|
||||
|
||||
it("returns mentions for on posts that haven't been saved yet (framer posts)", function(){
|
||||
|
|
@ -61,19 +61,19 @@ describe("app.helpers.textFormatter", function(){
|
|||
handle : "bob@example.com",
|
||||
url : 'googlebot.com',
|
||||
id : "666"
|
||||
})
|
||||
});
|
||||
|
||||
this.statusMessage.set({'mentioned_people' : [freshBob] })
|
||||
this.statusMessage.set({'mentioned_people' : [freshBob] });
|
||||
|
||||
var formattedText = this.formatter(this.statusMessage.get("text"), this.statusMessage.get("mentioned_people"))
|
||||
var formattedText = this.formatter(this.statusMessage.get("text"), this.statusMessage.get("mentioned_people"));
|
||||
var wrapper = $("<div>").html(formattedText);
|
||||
expect(wrapper.find("a[href='googlebot.com']").text()).toContain(freshBob.name)
|
||||
})
|
||||
expect(wrapper.find("a[href='googlebot.com']").text()).toContain(freshBob.name);
|
||||
});
|
||||
|
||||
it('returns the name of the mention if the mention does not exist in the array', function(){
|
||||
var text = "hey there @{Chris Smith; chris@example.com}"
|
||||
var formattedText = this.formatter(text, [])
|
||||
expect(formattedText.match(/\<a/)).toBeNull();
|
||||
var text = "hey there @{Chris Smith; chris@example.com}";
|
||||
var formattedText = this.formatter(text, []);
|
||||
expect(formattedText.match(/<a/)).toBeNull();
|
||||
expect(formattedText).toContain('Chris Smith');
|
||||
});
|
||||
});
|
||||
|
|
@ -100,7 +100,7 @@ describe("app.helpers.textFormatter", function(){
|
|||
var linkElement = wrapper.find("a[href*='" + link + "']");
|
||||
expect(linkElement.text()).toContain(link);
|
||||
expect(linkElement.attr("target")).toContain("_blank");
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
context("symbol conversion", function() {
|
||||
|
|
@ -134,6 +134,7 @@ describe("app.helpers.textFormatter", function(){
|
|||
|
||||
context("non-ascii url", function() {
|
||||
beforeEach(function() {
|
||||
/* jshint -W100 */
|
||||
this.evilUrls = [
|
||||
"http://www.bürgerentscheid-krankenhäuser.de", // example from issue #2665
|
||||
"http://bündnis-für-krankenhäuser.de/wp-content/uploads/2011/11/cropped-logohp.jpg",
|
||||
|
|
@ -143,6 +144,7 @@ describe("app.helpers.textFormatter", function(){
|
|||
"http://de.wikipedia.org/wiki/Liste_der_Abkürzungen_(Netzjargon)", // #3645
|
||||
"http://wiki.com/?query=Kr%E4fte", // #4874
|
||||
];
|
||||
/* jshint +W100 */
|
||||
this.asciiUrls = [
|
||||
"http://www.xn--brgerentscheid-krankenhuser-xkc78d.de",
|
||||
"http://xn--bndnis-fr-krankenhuser-i5b27cha.de/wp-content/uploads/2011/11/cropped-logohp.jpg",
|
||||
|
|
@ -198,7 +200,7 @@ describe("app.helpers.textFormatter", function(){
|
|||
|
||||
context("misc breakage and/or other issues with weird urls", function(){
|
||||
it("doesn't crash Firefox", function() {
|
||||
var content = "antifaschistisch-feministische ://"
|
||||
var content = "antifaschistisch-feministische ://";
|
||||
var parsed = this.formatter(content);
|
||||
expect(parsed).toContain(content);
|
||||
});
|
||||
|
|
@ -219,7 +221,7 @@ describe("app.helpers.textFormatter", function(){
|
|||
|
||||
context("percent-encoded input url", function() {
|
||||
beforeEach(function() {
|
||||
this.input = "http://www.soilandhealth.org/01aglibrary/010175.tree%20crops.pdf" // #4507
|
||||
this.input = "http://www.soilandhealth.org/01aglibrary/010175.tree%20crops.pdf"; // #4507
|
||||
this.correctHref = 'href="'+this.input+'"';
|
||||
});
|
||||
|
||||
|
|
@ -264,4 +266,4 @@ describe("app.helpers.textFormatter", function(){
|
|||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue