Commit 2024716c authored by danielgrippi's avatar danielgrippi Committed by Dennis Collinson

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

parent 3f7144f2
......@@ -13,8 +13,6 @@ class ApplicationController < ActionController::Base
before_filter :set_git_header if (AppConfig[:git_update] && AppConfig[:git_revision])
before_filter :set_grammatical_gender
prepend_before_filter :clear_gc_stats
inflection_method :grammatical_gender => :gender
helper_method :all_aspects,
......@@ -85,10 +83,6 @@ class ApplicationController < ActionController::Base
end
end
def clear_gc_stats
GC.clear_stats if GC.respond_to?(:clear_stats)
end
def redirect_unless_admin
unless current_user.admin?
redirect_to multi_url, :notice => 'you need to be an admin to do that'
......
......@@ -28,7 +28,6 @@ class VannaController < Vanna::Base
before_filter :set_git_header if (AppConfig[:git_update] && AppConfig[:git_revision])
before_filter :which_action_and_user
before_filter :all_aspects
prepend_before_filter :clear_gc_stats
before_filter :set_grammatical_gender
def ensure_http_referer_is_set
......@@ -82,10 +81,6 @@ class VannaController < Vanna::Base
WillPaginate::ViewHelpers.pagination_options[:next_label] = "#{I18n.t('next')} &raquo;"
end
def clear_gc_stats
GC.clear_stats if GC.respond_to?(:clear_stats)
end
def redirect_unless_admin
unless current_user.admin?
redirect_to multi_path, :notice => 'you need to be an admin to do that'
......
......@@ -90,10 +90,6 @@
.message
= msg
- unless @landing_page
%a{:id=>"back-to-top", :title=>"Back to top", :href=>"#"}
&#8679;
#notifications
- unless current_user
......
......@@ -40,7 +40,6 @@ javascripts:
- public/javascripts/widgets/*.js
- public/javascripts/view.js
- public/javascripts/stream.js
- public/javascripts/aspects-dropdown.js
- public/javascripts/contact-edit.js
- public/javascripts/contact-list.js
......@@ -52,6 +51,7 @@ javascripts:
login:
- public/javascripts/login.js
mobile:
- public/javascripts/vendor/jquery-1.7.1.min.js
- public/javascripts/vendor/jquery.charcount.js
- public/javascripts/rails.js # we only include this to hijack ajax requests
- public/javascripts/vendor/mbp-helper.js
......
......@@ -59,7 +59,6 @@
Diaspora.BasePage = function(body) {
$.extend(this, Diaspora.BaseWidget);
$.extend(this, {
backToTop: this.instantiate("BackToTop", body.find("#back-to-top")),
directionDetector: this.instantiate("DirectionDetector"),
events: function() { return Diaspora.page.eventsContainer.data("events"); },
flashMessages: this.instantiate("FlashMessages"),
......
......@@ -2,8 +2,6 @@ Diaspora.Pages.FeaturedUsersIndex = function() {
var self = this;
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");
});
};
Diaspora.Pages.MentionsIndex = function() {
var self = this;
this.subscribe("page/ready", function(evt, document) {
self.aspectNavigation = self.instantiate("AspectNavigation", document.find("ul#aspect_nav"));
});
};
Diaspora.Pages.MultisIndex = function() {
var self = this;
this.subscribe("page/ready", function(evt, document) {
self.aspectNavigation = self.instantiate("AspectNavigation", document.find("ul#aspect_nav"));
});
};
Diaspora.Pages.PeopleShow = function() {
};
Diaspora.Pages.PostsIndex = function() {
};
Diaspora.Pages.PostsShow = function() {
};
Diaspora.Pages.TagFollowingsIndex = function() {
var self = this;
this.subscribe("page/ready", function(evt, document) {
self.aspectNavigation = self.instantiate("AspectNavigation", document.find("ul#aspect_nav"));
});
};
Diaspora.Pages.TagsShow = function() {
};
/* 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();
});
<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>
\ No newline at end of file
This diff is collapsed.
......@@ -7,24 +7,12 @@ var View = {
/* Buttons */
$("input:submit").addClass("button");
/* Tooltips */
this.tooltips.bindAll();
/* In field labels */
$("label").inFieldLabels();
$(document).bind('afterReveal.facebox', function() {
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 */
$(this.search.selector)
.blur(this.search.blur)
......@@ -70,9 +58,7 @@ var View = {
alert($(this).attr('title'));
});
$(document.body)
.click(this.dropdowns.removeFocus)
.click(this.reshareButton.removeFocus);
$(document.body).click(this.dropdowns.removeFocus);
/* facebox */
$.facebox.settings.closeImage = '/images/facebox/closelabel.png';
......@@ -110,68 +96,9 @@ var View = {
focus: function() {
$(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"
},
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: {
click: function(evt) {
$(this).parent('.dropdown').toggleClass("active");
......
......@@ -43,14 +43,10 @@
this.perform = function() {
if (self.noneSelected()) {
self.abortAjax();
Diaspora.page.stream.empty();
Diaspora.page.stream.setHeaderTitle(Diaspora.I18n.t('aspect_navigation.no_aspects'));
self.fadeIn();
return;
} else {
self.performAjax();
window.location = self.generateURL(); // hella hax
}
self.calculateToggleText();
};
this.calculateToggleText = function() {
......@@ -85,54 +81,6 @@
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() {
return self.aspectLis.filter(".active").length === 0;
}
......@@ -140,15 +88,5 @@
this.allSelected = function() {
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);
};
};
})();
(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;
})();
(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;
})();
(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;
})();
(function() {
var Stream = function() {
var self = this;
this.streamElements = {};
this.subscribe("widget/ready", function(evt, stream) {
if( Diaspora.backboneEnabled() ){ return }
......@@ -11,31 +10,12 @@
mainStream: $(stream).find('#main_stream'),
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() {
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() {
self.mainStream.empty();
self.headerTitle.text(Diaspora.I18n.t('stream.no_aspects'));
......@@ -46,5 +26,7 @@
};
};
Diaspora.Widgets.Stream = Stream;
if(!Diaspora.backboneEnabled()) {
Diaspora.Widgets.Stream = Stream;
}
})();
......@@ -3294,20 +3294,6 @@ a.toggle_selector
.accept_invitation_text
:font
: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
:color $red
......
......@@ -40,7 +40,7 @@ describe("app.views.Stream", function(){
})
describe("infScroll", function(){
// NOTE: inf scroll happens at 300px
// NOTE: inf scroll happens at 500px
beforeEach(function(){
spyOn(this.view.collection, "fetch")
......
......@@ -11,7 +11,7 @@
# - dist/**/*.js
#
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/bootstrap/bootstrap-popover.js
- public/javascripts/vendor/bootstrap/bootstrap-twipsy.js
......
......@@ -4,7 +4,7 @@
*/
describe("View", function() {
it("is the object that helps the UI", function() {
it("is the object that helps the UI", function() {
expect(typeof View === "object").toBeTruthy();
});
......@@ -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();
});
});
});
});
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;
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment