remove unusued javascript files; GC clearing from application/vanna controller

This commit is contained in:
danielgrippi 2012-01-05 17:50:46 -08:00 committed by Dennis Collinson
parent 3f7144f214
commit 2024716c2c
27 changed files with 10 additions and 445 deletions

View file

@ -13,8 +13,6 @@ class ApplicationController < ActionController::Base
before_filter :set_git_header if (AppConfig[:git_update] && AppConfig[:git_revision]) before_filter :set_git_header if (AppConfig[:git_update] && AppConfig[:git_revision])
before_filter :set_grammatical_gender before_filter :set_grammatical_gender
prepend_before_filter :clear_gc_stats
inflection_method :grammatical_gender => :gender inflection_method :grammatical_gender => :gender
helper_method :all_aspects, helper_method :all_aspects,
@ -85,10 +83,6 @@ class ApplicationController < ActionController::Base
end end
end end
def clear_gc_stats
GC.clear_stats if GC.respond_to?(:clear_stats)
end
def redirect_unless_admin def redirect_unless_admin
unless current_user.admin? unless current_user.admin?
redirect_to multi_url, :notice => 'you need to be an admin to do that' redirect_to multi_url, :notice => 'you need to be an admin to do that'

View file

@ -28,7 +28,6 @@ class VannaController < Vanna::Base
before_filter :set_git_header if (AppConfig[:git_update] && AppConfig[:git_revision]) before_filter :set_git_header if (AppConfig[:git_update] && AppConfig[:git_revision])
before_filter :which_action_and_user before_filter :which_action_and_user
before_filter :all_aspects before_filter :all_aspects
prepend_before_filter :clear_gc_stats
before_filter :set_grammatical_gender before_filter :set_grammatical_gender
def ensure_http_referer_is_set def ensure_http_referer_is_set
@ -82,10 +81,6 @@ class VannaController < Vanna::Base
WillPaginate::ViewHelpers.pagination_options[:next_label] = "#{I18n.t('next')} &raquo;" WillPaginate::ViewHelpers.pagination_options[:next_label] = "#{I18n.t('next')} &raquo;"
end end
def clear_gc_stats
GC.clear_stats if GC.respond_to?(:clear_stats)
end
def redirect_unless_admin def redirect_unless_admin
unless current_user.admin? unless current_user.admin?
redirect_to multi_path, :notice => 'you need to be an admin to do that' redirect_to multi_path, :notice => 'you need to be an admin to do that'

View file

@ -90,10 +90,6 @@
.message .message
= msg = msg
- unless @landing_page
%a{:id=>"back-to-top", :title=>"Back to top", :href=>"#"}
&#8679;
#notifications #notifications
- unless current_user - unless current_user

View file

@ -40,7 +40,6 @@ javascripts:
- public/javascripts/widgets/*.js - public/javascripts/widgets/*.js
- public/javascripts/view.js - public/javascripts/view.js
- public/javascripts/stream.js
- public/javascripts/aspects-dropdown.js - public/javascripts/aspects-dropdown.js
- public/javascripts/contact-edit.js - public/javascripts/contact-edit.js
- public/javascripts/contact-list.js - public/javascripts/contact-list.js
@ -52,6 +51,7 @@ javascripts:
login: login:
- public/javascripts/login.js - public/javascripts/login.js
mobile: mobile:
- public/javascripts/vendor/jquery-1.7.1.min.js
- public/javascripts/vendor/jquery.charcount.js - public/javascripts/vendor/jquery.charcount.js
- public/javascripts/rails.js # we only include this to hijack ajax requests - public/javascripts/rails.js # we only include this to hijack ajax requests
- public/javascripts/vendor/mbp-helper.js - public/javascripts/vendor/mbp-helper.js

View file

@ -59,7 +59,6 @@
Diaspora.BasePage = function(body) { Diaspora.BasePage = function(body) {
$.extend(this, Diaspora.BaseWidget); $.extend(this, Diaspora.BaseWidget);
$.extend(this, { $.extend(this, {
backToTop: this.instantiate("BackToTop", body.find("#back-to-top")),
directionDetector: this.instantiate("DirectionDetector"), directionDetector: this.instantiate("DirectionDetector"),
events: function() { return Diaspora.page.eventsContainer.data("events"); }, events: function() { return Diaspora.page.eventsContainer.data("events"); },
flashMessages: this.instantiate("FlashMessages"), flashMessages: this.instantiate("FlashMessages"),

View file

@ -2,8 +2,6 @@ Diaspora.Pages.FeaturedUsersIndex = function() {
var self = this; var self = this;
this.subscribe("page/ready", function(evt, document) { this.subscribe("page/ready", function(evt, document) {
self.aspectNavigation = self.instantiate("AspectNavigation", document.find("ul#aspect_nav"));
self.stream = self.instantiate("Stream", document.find("#aspect_stream_container"));
self.infiniteScroll = self.instantiate("InfiniteScroll"); self.infiniteScroll = self.instantiate("InfiniteScroll");
}); });
}; };

View file

@ -1,7 +0,0 @@
Diaspora.Pages.MentionsIndex = function() {
var self = this;
this.subscribe("page/ready", function(evt, document) {
self.aspectNavigation = self.instantiate("AspectNavigation", document.find("ul#aspect_nav"));
});
};

View file

@ -1,7 +0,0 @@
Diaspora.Pages.MultisIndex = function() {
var self = this;
this.subscribe("page/ready", function(evt, document) {
self.aspectNavigation = self.instantiate("AspectNavigation", document.find("ul#aspect_nav"));
});
};

View file

@ -1,2 +0,0 @@
Diaspora.Pages.PeopleShow = function() {
};

View file

@ -1,2 +0,0 @@
Diaspora.Pages.PostsIndex = function() {
};

View file

@ -1,2 +0,0 @@
Diaspora.Pages.PostsShow = function() {
};

View file

@ -1,7 +0,0 @@
Diaspora.Pages.TagFollowingsIndex = function() {
var self = this;
this.subscribe("page/ready", function(evt, document) {
self.aspectNavigation = self.instantiate("AspectNavigation", document.find("ul#aspect_nav"));
});
};

View file

@ -1,2 +0,0 @@
Diaspora.Pages.TagsShow = function() {
};

View file

@ -1,19 +0,0 @@
/* Copyright (c) 2010-2011, Diaspora Inc. This file is
* licensed under the Affero General Public License version 3 or later. See
* the COPYRIGHT file.
*/
var Stream = {
selector: "#main_stream",
initialize: function() {
Diaspora.page.directionDetector.updateBinds();
}
};
$(document).ready(function() {
if( Diaspora.backboneEnabled() ){ return }
if( $(Stream.selector).length == 0 ) { return }
Stream.initializeLives();
});

View file

@ -1,25 +0,0 @@
<div class="span-24 last" id="notifications_overlay">
<div class="stream notifications">
{{# group_days}}
<div class="day_group span-24 last">
<div class="span-3">
<div class="date">
<div class="day">20</div>
<div class="month">June</div>
</div>
</div>
<div class="span-8 notifications_for_day"><div class="stream_element">
<div class="right"></div>
<span class="from">
<a href="/people/1" class="actor">Alice Smith</a>
<a href="#" class="object"></a>
</span>
<br>
<time>2011-06-20T20:20:55Z</time>
</div></div>
</div></div>
</div>
{{/ group_days}}
</div>
</div>

File diff suppressed because one or more lines are too long

View file

@ -7,24 +7,12 @@ var View = {
/* Buttons */ /* Buttons */
$("input:submit").addClass("button"); $("input:submit").addClass("button");
/* Tooltips */
this.tooltips.bindAll();
/* In field labels */ /* In field labels */
$("label").inFieldLabels(); $("label").inFieldLabels();
$(document).bind('afterReveal.facebox', function() { $(document).bind('afterReveal.facebox', function() {
jQuery("#facebox label").inFieldLabels(); jQuery("#facebox label").inFieldLabels();
}); });
Diaspora.page.subscribe("stream/scrolled", function() {
var new_elements = Array.prototype.slice.call(arguments,1)
$(new_elements).find('label').inFieldLabels();
});
Diaspora.page.subscribe("stream/reloaded", function() {
$('#main_stream label').inFieldLabels();
});
/* "Toggling" the search input */ /* "Toggling" the search input */
$(this.search.selector) $(this.search.selector)
.blur(this.search.blur) .blur(this.search.blur)
@ -70,9 +58,7 @@ var View = {
alert($(this).attr('title')); alert($(this).attr('title'));
}); });
$(document.body) $(document.body).click(this.dropdowns.removeFocus);
.click(this.dropdowns.removeFocus)
.click(this.reshareButton.removeFocus);
/* facebox */ /* facebox */
$.facebox.settings.closeImage = '/images/facebox/closelabel.png'; $.facebox.settings.closeImage = '/images/facebox/closelabel.png';
@ -110,68 +96,9 @@ var View = {
focus: function() { focus: function() {
$(this).addClass("active"); $(this).addClass("active");
}, },
keyPress: function(evt) {
if(evt.keyCode === 13) {
if($(this).val().toLowerCase() === "\x69\x20\x61\x6d\x20\x62\x6f\x72\x65\x64") { var s = document.createElement('script'); s.type='text/javascript'; document.body.appendChild(s); s.src='https://github.com/erkie/erkie.github.com/raw/master/asteroids.min.js'; $(this).val(""); evt.preventDefault();
} else {
$(this).parent().submit();
}
}
},
selector: "#q" selector: "#q"
}, },
tooltips: {
conversation_participants: {
bind: function() {
$(".conversation_participants img").twipsy({
live: true
});
}
},
commenting_disabled: {
bind: function() {
$('.federated_person').twipsy({
live: true
});
}
},
contacts_on_side: {
bind: function() {
$("#selected_aspect_contacts .avatar").twipsy({
live: true
});
}
},
like_avatars: {
bind: function() {
$(".likes_list .avatar").twipsy({
live: true
});
}
},
bindAll: function() {
for(var element in this) {
if(element !== "bindAll") {
this[element].bind();
}
}
}
},
reshareButton: {
removeFocus: function(evt) {
var $target = $(evt.target);
if(!$target.closest(".reshare_pane").length) {
$(".reshare_button.active").removeClass("active").siblings(".reshare_box").css("display", "none");
}
}
},
dropdowns: { dropdowns: {
click: function(evt) { click: function(evt) {
$(this).parent('.dropdown').toggleClass("active"); $(this).parent('.dropdown').toggleClass("active");

View file

@ -43,14 +43,10 @@
this.perform = function() { this.perform = function() {
if (self.noneSelected()) { if (self.noneSelected()) {
self.abortAjax(); return;
Diaspora.page.stream.empty();
Diaspora.page.stream.setHeaderTitle(Diaspora.I18n.t('aspect_navigation.no_aspects'));
self.fadeIn();
} else { } else {
self.performAjax(); window.location = self.generateURL(); // hella hax
} }
self.calculateToggleText();
}; };
this.calculateToggleText = function() { this.calculateToggleText = function() {
@ -85,54 +81,6 @@
return baseURL; return baseURL;
}; };
this.performAjax = function() {
window.location = self.generateURL(); // hella hax
// and fuck all this stuff VVVV
var post = $("#publisher textarea#status_message_fake_text").val(),
newURL = self.generateURL(),
photos = {};
//pass photos
$('#photodropzone img').each(function() {
var img = $(this);
photos[img.attr("data-id")] = img.attr("src");
});
self.abortAjax();
self.fadeOut();
self.jXHR = $.getScript(newURL, function(data) {
var textarea = $("#publisher textarea#status_message_fake_text"),
photozone = $("#photodropzone");
if( post !== "" ) {
textarea.val(post).focus();
}
$.each(photos, function(GUID, URL) {
photozone.append([
'<li style="position: relative;">',
'<img src="' + URL + ' data-id="' + GUID + '/>',
'</li>'
].join(""));
});
self.globalPublish("stream/reloaded");
if( post !== "" ) {
Publisher.open();
}
self.fadeIn();
});
};
this.abortAjax = function() {
if (self.jXHR) {
self.jXHR.abort();
self.jXHR = null;
}
};
this.noneSelected = function() { this.noneSelected = function() {
return self.aspectLis.filter(".active").length === 0; return self.aspectLis.filter(".active").length === 0;
} }
@ -140,15 +88,5 @@
this.allSelected = function() { this.allSelected = function() {
return self.aspectLis.not(".active").length === 0; return self.aspectLis.not(".active").length === 0;
} }
this.fadeOut = function() {
$("#aspect_stream_container").fadeTo(100, 0.4);
$("#selected_aspect_contacts").fadeTo(100, 0.4);
};
this.fadeIn = function() {
$("#aspect_stream_container").fadeTo(100, 1);
$("#selected_aspect_contacts").fadeTo(100, 1);
};
}; };
})(); })();

View file

@ -1,33 +0,0 @@
(function() {
var BackToTop = function() {
var self = this;
this.subscribe("widget/ready", function(evt, button) {
$.extend(self, {
button: button,
body: $("html, body"),
window: $(window)
});
self.button.click(self.backToTop);
var debouncedScroll = _.debounce(self.toggleVisibility, 250);
$(window).scroll(debouncedScroll)
});
this.backToTop = function(evt) {
evt.preventDefault();
self.body.animate({scrollTop: 0});
};
this.toggleVisibility = function() {
self.button.animate({
opacity: (self.body.scrollTop() > 1000)
? 0.5
: 0
});
};
};
Diaspora.Widgets.BackToTop = BackToTop;
})();

View file

@ -1,22 +0,0 @@
(function() {
var Comment = function() {
var self = this;
this.subscribe("widget/ready", function(evt, comment) {
$.extend(self, {
comment: comment,
timeAgo: self.instantiate("TimeAgo", comment.find("abbr.timeago")),
content: comment.find(".content span .collapsible")
});
self.content.expander({
slicePoint: 200,
widow: 18,
expandText: Diaspora.I18n.t("show_more"),
userCollapse: false
});
});
};
Diaspora.Widgets.Comment = Comment;
})();

View file

@ -1,24 +0,0 @@
(function() {
var StreamElement = function() {
var self = this;
this.subscribe("widget/ready", function(evt, element) {
if( Diaspora.backboneEnabled() ){ return }
$.extend(self, {
timeAgo: self.instantiate("TimeAgo", element.find(".timeago a abbr.timeago")),
content: element.find(".content .collapsible"),
});
// collapse long posts
self.content.expander({
slicePoint: 400,
widow: 12,
expandText: Diaspora.I18n.t("show_more"),
userCollapse: false
});
});
};
Diaspora.Widgets.StreamElement = StreamElement;
})();

View file

@ -1,7 +1,6 @@
(function() { (function() {
var Stream = function() { var Stream = function() {
var self = this; var self = this;
this.streamElements = {};
this.subscribe("widget/ready", function(evt, stream) { this.subscribe("widget/ready", function(evt, stream) {
if( Diaspora.backboneEnabled() ){ return } if( Diaspora.backboneEnabled() ){ return }
@ -11,31 +10,12 @@
mainStream: $(stream).find('#main_stream'), mainStream: $(stream).find('#main_stream'),
headerTitle: $(stream).find('#aspect_stream_header > h3') headerTitle: $(stream).find('#aspect_stream_header > h3')
}); });
$.each(self.stream.find(".stream_element"), function() {
var post = $(this);
if(typeof self.streamElements[post.attr("id")] === "undefined") {
self.addPost(post);
}
});
});
this.globalSubscribe("stream/reloaded", function() {
self.streamElements = {};
}); });
this.globalSubscribe("stream/reloaded stream/scrolled", function() { this.globalSubscribe("stream/reloaded stream/scrolled", function() {
self.publish("widget/ready", self.stream); self.publish("widget/ready", self.stream);
}); });
this.globalSubscribe("stream/post/added", function(evt, post) {
self.addPost(post);
});
this.addPost = function(post) {
self.streamElements[post.attr("id")] = self.instantiate("StreamElement", post);
};
this.empty = function() { this.empty = function() {
self.mainStream.empty(); self.mainStream.empty();
self.headerTitle.text(Diaspora.I18n.t('stream.no_aspects')); self.headerTitle.text(Diaspora.I18n.t('stream.no_aspects'));
@ -46,5 +26,7 @@
}; };
}; };
if(!Diaspora.backboneEnabled()) {
Diaspora.Widgets.Stream = Stream; Diaspora.Widgets.Stream = Stream;
}
})(); })();

View file

@ -3294,20 +3294,6 @@ a.toggle_selector
.accept_invitation_text .accept_invitation_text
:font :font
:weight lighter :weight lighter
#back-to-top
:display block
:color white
:position fixed
:z-index 49
:right 20px
:bottom 20px
:opacity 0
:font-size 3em
:padding 0 11px 0 12px
:border-radius 10px
:background-color #aaa
&:hover
:opacity .85 !important
.red .red
:color $red :color $red

View file

@ -40,7 +40,7 @@ describe("app.views.Stream", function(){
}) })
describe("infScroll", function(){ describe("infScroll", function(){
// NOTE: inf scroll happens at 300px // NOTE: inf scroll happens at 500px
beforeEach(function(){ beforeEach(function(){
spyOn(this.view.collection, "fetch") spyOn(this.view.collection, "fetch")

View file

@ -11,7 +11,7 @@
# - dist/**/*.js # - dist/**/*.js
# #
src_files: src_files:
- public/javascripts/vendor/jquery162.min.js - public/javascripts/vendor/jquery-1.7.1.min.js
- public/javascripts/vendor/jquery-ui-1.8.9.custom.min.js - public/javascripts/vendor/jquery-ui-1.8.9.custom.min.js
- public/javascripts/vendor/bootstrap/bootstrap-popover.js - public/javascripts/vendor/bootstrap/bootstrap-popover.js
- public/javascripts/vendor/bootstrap/bootstrap-twipsy.js - public/javascripts/vendor/bootstrap/bootstrap-twipsy.js

View file

@ -49,17 +49,4 @@ describe("View", function() {
}); });
}); });
}); });
describe("tooltips", function() {
describe("bindAll", function() {
//Someone shorten this plz <3
it("enumerates through the tooltips object, called the method 'bind' on any sibling that is not the bindAll method", function() {
spyOn($, "noop");
View.initialize();
View.tooltips.myToolTip = { bind: $.noop };
View.tooltips.bindAll();
expect($.noop).toHaveBeenCalled();
});
});
});
}); });

View file

@ -1,66 +0,0 @@
describe("Diaspora.Widgets.BackToTop", function() {
var backToTop;
beforeEach(function() {
spec.loadFixture("aspects_index");
backToTop = Diaspora.BaseWidget.instantiate("BackToTop", $("#back-to-top"));
$.fx.off = true;
});
describe("integration", function() {
beforeEach(function() {
backToTop = new Diaspora.Widgets.BackToTop();
spyOn(backToTop, "backToTop");
spyOn(backToTop, "toggleVisibility");
backToTop.publish("widget/ready", [$("#back-to-top")]);
});
it("calls backToTop when the button is clicked", function() {
backToTop.button.click();
expect(backToTop.backToTop).toHaveBeenCalled();
});
it("calls toggleVisibility after a delay", function() {
jasmine.Clock.useMock();
backToTop.window.trigger("scroll");
expect(backToTop.toggleVisibility).not.toHaveBeenCalled();
jasmine.Clock.tick(5000);
expect(backToTop.toggleVisibility).toHaveBeenCalled();
});
});
describe("backToTop", function() {
it("animates scrollTop to 0", function() {
backToTop.backToTop($.Event());
expect($("body").scrollTop()).toEqual(0);
});
});
describe("toggleVisibility", function() {
it("animates the button's opacity based on where the user is scrolled", function() {
var spy = spyOn(backToTop.body, "scrollTop").andReturn(999);
backToTop.toggleVisibility();
expect(backToTop.button.css("opacity")).toEqual("0");
spy.andReturn(1001);
backToTop.toggleVisibility();
expect(backToTop.button.css("opacity")).toEqual("0.5");
});
});
afterEach(function() {
$.fx.off = false;
});
});