Skip to content
Extraits de code Groupes Projets
Valider f9c230dd rédigé par Jonne Haß's avatar Jonne Haß
Parcourir les fichiers

Merge pull request #4738 from svbergerem/remove-unused-spv-files

Remove unused beta code
parents 9fe17f1a 0f156cd9
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de
avec 1 ajout et 674 suppressions
......@@ -2,6 +2,7 @@
## Refactor
* Drop number of followers from tags page [#4717](https://github.com/diaspora/diaspora/issues/4717)
* Remove some unused beta code [#4738](https://github.com/diaspora/diaspora/issues/4738)
## Bug fixes
* Improve time agos by updating the plugin [#4280](https://github.com/diaspora/diaspora/issues/4280)
......
......@@ -11,7 +11,6 @@
//= require_tree ./pages
//= require_tree ./collections
//= require_tree ./views
//= require_tree ./forms
var app = {
collections: {},
......
app.forms.PictureBase = app.views.Base.extend({
events : {
'ajax:complete .new_photo' : "photoUploaded",
"change input[name='photo[user_file]']" : "submitForm"
},
onSubmit : $.noop,
uploadSuccess : $.noop,
postRenderTemplate : function(){
this.$("input[name=authenticity_token]").val($("meta[name=csrf-token]").attr("content"))
},
submitForm : function (){
this.$("form").submit();
this.onSubmit();
},
photoUploaded : function(evt, xhr) {
resp = JSON.parse(xhr.responseText)
if(resp.success) {
this.uploadSuccess(resp)
} else {
alert("Upload failed! Please try again. " + resp.error);
}
}
});
/* multi photo uploader */
app.forms.Picture = app.forms.PictureBase.extend({
templateName : "picture-form",
initialize : function() {
this.photos = this.model.photos || new Backbone.Collection()
this.photos.bind("add", this.render, this)
},
postRenderTemplate : function(){
this.$("input[name=authenticity_token]").val($("meta[name=csrf-token]").attr("content"))
this.$("input[name=photo_ids]").val(this.photos.pluck("id"))
this.renderPhotos();
},
onSubmit : function (){
this.$(".photos").append($('<span class="loader" style="margin-left: 80px;"></span>'))
},
uploadSuccess : function(resp) {
this.photos.add(new Backbone.Model(resp.data))
},
renderPhotos : function(){
var photoContainer = this.$(".photos")
this.photos.each(function(photo){
var photoView = new app.views.Photo({model : photo}).render().el
photoContainer.append(photoView)
})
}
});
app.forms.Post = app.views.Base.extend({
templateName : "post-form",
className : "post-form",
subviews : {
".new_picture" : "pictureForm"
},
initialize : function() {
this.pictureForm = new app.forms.Picture({model: this.model});
},
postRenderTemplate : function() {
Mentions.initialize(this.$("textarea.text"));
Mentions.fetchContacts(); //mentions should use app.currentUser
this.$('textarea').autoResize({minHeight: '200', maxHeight:'300', animate: false});
}
});
\ No newline at end of file
app.pages.Stream = app.views.Base.extend({
templateName : "stream",
events : {
'activate .stream-frame-wrapper' : 'triggerInteractionLoad'
},
subviews : {
"#stream-content" : "streamView",
"#stream-interactions" : "interactionsView"
},
initialize : function(){
this.stream = this.model = new app.models.Stream()
this.stream.preloadOrFetch()
this.streamView = new app.pages.Stream.InfiniteScrollView({ model : this.stream })
this.interactionsView = new app.views.StreamInteractions()
this.streamView.on('loadMore', this.updateUrlState, this);
this.stream.on("fetched", this.refreshScrollSpy, this)
this.stream.on("frame:interacted", this.selectFrame, this)
},
selectFrame : function(post){
if(this.selectedPost == post) { return }
this.selectedPost = post
this.$(".stream-frame-wrapper").removeClass("selected-frame")
this.$(".stream-frame-wrapper[data-id=" + this.selectedPost.id +"]").addClass("selected-frame")
this.interactionsView.setInteractions(this.selectedPost)
},
updateUrlState : function(){
var post = this.stream.items.last();
if(post){
this.navigateToPost(post)
}
},
navigateToPost : function(post){
app.router.navigate(location.pathname + "?max_time=" + post.createdAt(), {replace: true})
},
triggerInteractionLoad : function(evt){
this._throttledInteractions = this._throttledInteractions || _.bind(_.throttle(function(id){
this.selectFrame(this.stream.items.get(id))
}, 500), this)
this._throttledInteractions($(evt.target).data("id"))
},
refreshScrollSpy : function(){
_.defer($('body').scrollspy('refresh'))
}
},
//static methods
{
InfiniteScrollView : app.views.InfScroll.extend({
initialize: function(){
this.stream = this.model
this.collection = this.stream.items
this.postClass = app.views.Post.StreamFrame
this.setupInfiniteScroll()
}
})
});
/**
* the aspects dropdown specifies the scope of a posted status message.
*
* this view is part of the publisher where users are presented the options
* 'public', 'all aspects' and a list of their personal aspects, for limiting
* 'the audience of created contents.
*/
app.views.AspectsDropdown = app.views.Base.extend({
templateName : "aspects-dropdown",
events : {
"change .dropdown-menu input" : "setVisibility"
},
presenter : function(){
var selectedAspects = this.model.get("aspect_ids")
, parsedIds = _.map(selectedAspects, parseInt)
return {
aspects : _.map(app.currentUser.get('aspects'), function(aspect){
return _.extend({}, aspect, {checked :_.include(parsedIds, aspect.id) })
}),
public :_.include(selectedAspects, "public"),
'all-aspects' :_.include(selectedAspects, "all_aspects")
}
},
postRenderTemplate : function(){
if(this.model.get("aspect_ids")) {
this.setDropdownText()
} else {
this.setVisibility({target : this.$("input[value='public']").first()})
}
},
setVisibility : function(evt){
var input = $(evt.target).closest("input")
if(_.include(['public', 'all_aspects'], input.val())) {
this.$("input").attr("checked", false)
input.attr("checked", "checked")
} else {
this.$("input.public, input.all_aspects").attr("checked", false)
}
this.setDropdownText()
},
setDropdownText : function(){
var selected = this.$("input").serializeArray()
, text;
switch (selected.length) {
case 0:
text = "Private"
break
case 1:
text = selected[0].name
break
default:
text = ["In", selected.length, "aspects"].join(" ")
break
}
$.trim(this.$(".dropdown-toggle .text").text(text))
}
});
//= require ./small_frame
app.views.Post.CanvasFrame = app.views.Post.SmallFrame.extend({
SINGLE_COLUMN_WIDTH : 265,
DOUBLE_COLUMN_WIDTH : 560,
events : {
"click .info" : "goToPost", // the only event copied from SmallFrame
"click .content" : "favoritePost",
"click .delete" : "killPost"
},
adjustedImageHeight : function() {
if(!(this.model.get("photos") || [])[0]) { return }
var modifiers = [this.dimensionsClass(), this.colorClass()].join(' ')
, width;
/* mobile width
*
* currently does not re-calculate on orientation change */
if($(window).width() <= 767) {
width = $(window).width();
}
var firstPhoto = this.model.get("photos")[0]
, width = width || (modifiers.search("x2") != -1 ? this.DOUBLE_COLUMN_WIDTH : this.SINGLE_COLUMN_WIDTH)
, ratio = width / firstPhoto.dimensions.width;
return(ratio * firstPhoto.dimensions.height)
},
presenter : function(){
return _.extend(this.smallFramePresenter(), {
adjustedImageHeight : this.adjustedImageHeight()
})
},
favoritePost : function(evt) {
if(evt) {
/* follow links instead of faving the targeted post */
if($(evt.target).is('a')) { return }
evt.stopImmediatePropagation(); evt.preventDefault();
}
var prevDimension = this.dimensionsClass();
this.model.toggleFavorite({save : this.model.get("author").diaspora_id == app.currentUser.get("diaspora_id")})
this.$el.removeClass(prevDimension)
this.render()
app.page.stream.trigger("reLayout")
//trigger moar relayouts in the case of images WHOA GROSS HAX
_.delay(function(){app.page.stream.trigger("reLayout")}, 200)
// track the action
app.instrument("track", "Resize Frame")
},
killPost : function(){
this.destroyModel()
_.delay(function(){app.page.stream.trigger("reLayout")}, 0)
}
});
//= require "../post_view"
app.views.Post.SmallFrame = app.views.Post.extend({
className : "canvas-frame",
templateName : "small-frame/default", // default to fall back to
events : {
"click .info" : "goToPost"
},
subviews : {
'.embed-frame' : "oEmbedView",
'.open-graph-frame' : 'openGraphView'
},
initialize : function(options) {
this.stream = options.stream;
this.addStylingClasses()
},
oEmbedView : function(){
return new app.views.OEmbed({model : this.model})
},
openGraphView : function(){
return new app.views.OpenGraph({model : this.model})
},
smallFramePresenter : function(){
//todo : we need to have something better for small frame text, probably using the headline() scenario.
return _.extend(this.defaultPresenter(),
{
text : this.model && app.helpers.textFormatter(this.model.get("text"), this.model),
likesCount : this.model.interactions.likesCount(),
resharesCount : this.model.interactions.resharesCount(),
commentsCount : this.model.interactions.commentsCount()
})
},
postRenderTemplate : function() {
this.addStylingClasses()
},
addStylingClasses : function() {
this.$el.addClass([this.dimensionsClass(), this.colorClass(), this.frameClass()].join(' '))
},
frameClass : function(){
var name = this.model.get("frame_name") || ""
return name.toLowerCase()
},
colorClass : function() {
var text = this.model.get("text")
, baseClass = $.trim(text).length == 0 ? "no-text" : "has-text";
if(this.model.get("photos").length > 0 || this.model.get("o_embed_cache") || this.model.get("open_graph_cache"))
baseClass += " has-media";
if(baseClass == "no-text" || this.model.get("photos").length > 0 || this.model.get("o_embed_cache") || this.model.get("open_graph_cache")) { return baseClass }
var randomColor = _.first(_.shuffle(['cyan', 'green', 'yellow', 'purple', 'lime-green', 'orange', 'red', 'turquoise', 'sand']));
var textClass = randomColor;
if(text.length < 40) {
textClass += " big-text"
}
return [baseClass, textClass].join(" ")
},
dimensionsClass : function() {
return (this.model.get("favorite")) ? "x2 width height" : ""
},
goToPost : function(evt) {
if(evt) { evt.preventDefault() && evt.stopImmediatePropagation(); }
app.setPreload('post',this.model.attributes)
app.router.navigate(this.model.url(), true)
}
});
app.views.Post.StreamFrame = app.views.Base.extend({
className : "stream-frame",
templateName : "stream-frame",
subviews : {
".small-frame" : "smallFrameView",
".stream-frame-feedback" : "feedbackView"
},
initialize : function(options) {
this.stream = options.stream
this.smallFrameView = new app.views.Post.SmallFrame({model : this.model})
this.feedbackView = new app.views.FeedbackActions({ model: this.model })
},
events : {
'click .content' : 'triggerInteracted',
"click a.permalink" : "goToPost"
},
triggerInteracted : function() {
this.stream.trigger("frame:interacted", this.model)
},
goToPost : function(evt) {
this.smallFrameView.goToPost(evt)
}
});
app.views.StreamInteractions = app.views.Base.extend({
id : "post-info",
subviews:{
".comments" : "comments",
".new-comment" : "newCommentView"
},
templateName : "stream-interactions",
setInteractions : function (model) {
model.interactions.fetch().done(
_.bind(function () {
this.render()
}, this));
this.comments = new app.views.PostViewerReactions({ model: model.interactions })
this.newCommentView = new app.views.PostViewerNewComment({ model : model })
}
});
app.views.PostViewerNewComment = app.views.Base.extend({
templateName: "single-post-viewer/new-comment",
events : {
"click button" : "createComment",
"focus textarea" : "scrollToBottom"
},
scrollableArea : "#post-reactions",
initialize : function(){
this.model.interactions.comments.bind("sync", this.clearAndReactivateForm, this)
},
postRenderTemplate : function() {
this.$("textarea").placeholder();
this.$("textarea").autoResize({'extraSpace' : 0});
},
createComment: function(evt) {
if(evt){ evt.preventDefault(); }
this.toggleFormState()
this.model.comment(this.$("textarea").val());
},
clearAndReactivateForm : function() {
this.toggleFormState()
this.$("textarea").val("")
.css('height', '18px')
.focus()
},
toggleFormState : function() {
this.$("form").children().toggleClass('disabled')
},
scrollToBottom : function() {
$(this.scrollableArea).scrollTop($(this.scrollableArea).prop("scrollHeight"))
}
});
app.views.PostViewerReactions = app.views.Base.extend({
className : "",
templateName: "single-post-viewer/reactions",
tooltipSelector : ".avatar",
initialize : function() {
this.model.on('change', this.render, this);
this.model.comments.bind("add", this.appendComment, this)
},
presenter : function(){
return {
likes : this.model.likes.toJSON(),
comments : this.model.comments.toJSON(),
reshares : this.model.reshares.toJSON()
}
},
postRenderTemplate : function() {
this.populateComments()
},
/* copy pasta from commentStream */
populateComments : function() {
this.model.comments.each(this.appendComment, this)
},
/* copy pasta from commentStream */
appendComment: function(comment) {
// Set the post as the comment's parent, so we can check on post ownership in the Comment view.
// model was post on old view, is interactions on new view
var parent = this.model.get("post_type") ? this.model.toJSON : this.model.post.toJSON()
comment.set({parent : parent})
this.$("#post-comments").append(new app.views.Comment({
model: comment,
className : "post-comment media",
templateName : "post-viewer/comment"
}).render().el);
}
});
<a href="#" rel="auth-required" class="label like" title="{{#if userLike}} {{t "viewer.unlike"}} {{else}} {{t "viewer.like"}} {{/if}}">
{{#if userLike}}
<i class="icon-heart icon-red"></i>
{{else}}
<i class="icon-heart icon-white"></i>
{{/if}}
{{likesCount}}
</a>
{{#if userCanReshare}}
<a href="#" rel="auth-required" class="label reshare" title="{{#if userReshare}} {{t "viewer.reshared"}} {{else}} {{t "viewer.reshare"}} {{/if}}">
{{#if userReshare}}
<i class="icon-retweet icon-blue"></i>
{{else}}
<i class="icon-retweet icon-white"></i>
{{/if}}
{{resharesCount}}
</a>
{{else}}
<a class="label reshare-viewonly" title="{{#if userReshare}} {{t "viewer.reshared"}} {{else}} {{t "viewer.reshare"}} {{/if}}">
{{#if userReshare}}
<i class="icon-retweet icon-blue"></i>
{{else}}
<i class="icon-retweet icon-white"></i>
{{/if}}
{{resharesCount}}
</a>
{{/if}}
<a href="#" class="label comment" rel="invoke-interaction-pane" title="{{t "viewer.comment"}}">
<i class="icon-comment icon-white"></i>
{{commentsCount}}
</a>
<div class="container">
<section class="photo_viewer"></section>
<!--Temp hacks-->
{{#if o_embed_cache}}
{{#if o_embed_cache.data}}
{{{o_embed_cache.data.html}}}
{{/if}}
{{else}}
{{#if open_graph_cache}}
<div class="opengraph">
<a href="{{open_graph_cache.url}}" target="_blank">
<h2>{{{open_graph_cache.title}}}</h2>
<img src="{{open_graph_cache.image}}"/>
<p>{{open_graph_cache.description}}</p>
</a>
</div>
{{/if}}
{{/if}}
<header>{{{headline}}}</header>
<section class="body">{{{body}}}</section>
</div>
<form accept-charset="UTF-8" action="/photos" class="new_photo" data-remote="true" enctype="multipart/form-data" method="post">
<input name="authenticity_token" type="hidden"/>
<div style="margin:0;padding:0;display:inline">
<input name="utf8" type="hidden" value="✓"/>
</div>
<div class="photos well">
<div id='photo_upload_button'>
<a class='btn'><i class="icon-camera" style="margin-right:4px;"></i>Add Photos</a>
<input name="photo[user_file]" type="file"/>
</div>
</div>
</form>
<div class="new_picture"/>
<form class="new-post">
<fieldset>
<textarea name="text" id='post_text' class="text span8" placeholder="Add Text">{{text}}</textarea>
<textarea id="text_with_markup" style="display:none;"/>
</fieldset>
</form>
<div id="new-post-comment-container">
<form class="form-inline">
<textarea class="new-comment-text" id="new-comment-text" placeholder="{{t "stream.comment"}}"></textarea>
<button type="submit" class="btn btn-small">
{{t "stream.comment"}}
</button>
</form>
</div>
{{# if likes}}
<div id="post-likes">
<div class="well media">
<div class="img">
<i class="icon-heart icon-red"></i>
</div>
<div class="bd">
{{#each likes}}
{{#linkToPerson author}}
{{{personImage this "small" "micro"}}}
{{/linkToPerson}}
{{/each}}
</div>
</div>
</div>
{{/if}}
{{# if reshares}}
<div id="post-reshares">
<div class="well media">
<div class="img">
<i class="icon-retweet icon-blue"></i>
</div>
<div class="bd">
{{#each reshares}}
{{#linkToPerson author}}
{{{personImage this "small" "micro"}}}
{{/linkToPerson}}
{{/each}}
</div>
</div>
</div>
{{/if}}
<div id="post-comments"> </div>
<div class="content">
{{#if photos}}
<div class="image-container">
{{#each photos}}
<img src="{{sizes.large}}" {{#if ../../adjustedImageHeight}}style="height:{{../../adjustedImageHeight}}px;"{{/if}} />
{{/each}}
</div>
{{/if}}
{{#if object_url}}
<div class="image-container">
<a href="{{object_url}}" class="stream-photo-link">
<img src="{{image_url}}" data-small-photo="{{image_url}}" data-full-photo="{{image_url}}" class="stream-photo" />
</a>
</div>
{{/if}}
<div class="embed-frame" />
<div class="open-graph-frame" />
{{#if text}}
<div class="text-content">
{{{text}}}
</div>
<div class="background-color"></div>
{{else}}
<div class="text-content">
<p></p>
</div>
{{/if}}
<!--Handlebars partial territory-->
<div class=controls>
<a href="#" class="delete"></a>
</div>
<div class="info permalink">
{{#if root}}
{{#linkToPerson root.author}}
{{{personImage this}}
{{/linkToPerson}}
{{/if}}
<i class="icon-time timestamp" title="{{created_at}}" rel="tooltip"></i>
<i class="icon-chevron-right permalink" title="View Post" rel="tooltip"></i>
<i class="icon-heart"></i> {{likesCount}}
<i class="icon-retweet"></i> {{resharesCount}}
<i class="icon-comment"></i> {{commentsCount}}
</div>
</div>
<div class="feedback"/>
<div class="comments"/>
<div class="new-comment"/>
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter