indentation fixes for public/javascripts/widgets

This commit is contained in:
Dan Hansen 2011-07-14 13:35:24 -07:00
parent d88e86681d
commit 10026dd100
10 changed files with 88 additions and 87 deletions

View file

@ -4,27 +4,27 @@
this.faceboxTemplate = '<div id="diaspora_alert" class="facebox_content">' +
'<div class="span-12 last">' +
'<div id="facebox_header">' +
'<h4>' +
'{{title}}' +
'</h4>' +
'</div>' +
'{{content}}' +
'<div id="facebox_header">' +
'<h4>' +
'{{title}}' +
'</h4>' +
'</div>' +
'{{content}}' +
'</div>' +
'</div>';
this.subscribe("widget/ready", function() {
$(document).bind("close.facebox", function() {
$("#facebox, #diaspora_alert").remove();
$("#facebox, #diaspora_alert").remove();
});
});
this.alert = function(title, content) {
$($.mustache(self.faceboxTemplate, {
title: title,
content: content
title: title,
content: content
})).appendTo(document.body);
$.facebox({

View file

@ -13,49 +13,49 @@
self.updateBinds();
Diaspora.widgets.subscribe("stream/scrolled", function() {
self.updateBinds();
self.updateBinds();
});
});
this.isRTL = function(str) {
if(typeof str !== "string" || str.length < 1) {
return false;
return false;
}
var charCode = str.charCodeAt(0);
if(charCode >= 1536 && charCode <= 1791) // Sarabic, Persian, ...
return true;
return true;
else if(charCode >= 65136 && charCode <= 65279) // Arabic present 1
return true;
return true;
else if(charCode >= 64336 && charCode <= 65023) // Arabic present 2
return true;
return true;
else if(charCode>=1424 && charCode<=1535) // Hebrew
return true;
return true;
else if(charCode>=64256 && charCode<=64335) // Hebrew present
return true;
return true;
else if(charCode>=1792 && charCode<=1871) // Syriac
return true;
return true;
else if(charCode>=1920 && charCode<=1983) // Thaana
return true;
return true;
else if(charCode>=1984 && charCode<=2047) // NKo
return true;
return true;
else if(charCode>=11568 && charCode<=11647) // Tifinagh
return true;
return true;
return false;
};
this.updateBinds = function() {
$.each(self.binds, function(index, bind) {
bind.unbind("keyup", self.updateDirection);
bind.unbind("keyup", self.updateDirection);
});
self.binds = [];
@ -65,19 +65,19 @@
this.bind = function() {
self.binds.push(
$(this).bind("keyup", self.updateDirection)
$(this).bind("keyup", self.updateDirection)
);
};
this.updateDirection = function() {
var textArea = $(this),
cleaned = textArea.val().replace(self.cleaner, "").replace(/^[ ]+/, "");
cleaned = textArea.val().replace(self.cleaner, "").replace(/^[ ]+/, "");
if(self.isRTL(cleaned)) {
textArea.css("direction", "rtl");
textArea.css("direction", "rtl");
}
else {
textArea.css("direction", "ltr");
textArea.css("direction", "ltr");
}
};
};

View file

@ -12,7 +12,7 @@
self.subscribe("widget/ready", function() {
$.extend(self, {
stream: $("#main_stream")
stream: $("#main_stream")
});
self.ensureDOMStructure();
@ -23,7 +23,7 @@
this.ensureDOMStructure = function() {
var post = self.stream.children(".stream_element:first"),
content = post.children(".sm_body").children(".content").children("p");
content = post.children(".sm_body").children(".content").children("p");
self.canEmbed = !!content.length;
};
@ -43,14 +43,15 @@
this.embed = function(videoLink) {
var host = videoLink.data("host"),
container = $("<div/>", { "class": "video-container" }),
videoContainer = videoLink.closest(".content").children(".video-container");
container = $("<div/>", { "class": "video-container" }),
videoContainer = videoLink.closest(".content").children(".video-container");
if (videoContainer.length) {
videoContainer.slideUp("fast", function() {
$(this).detach();
});
return;
videoContainer.slideUp("fast", function() {
$(this).detach();
});
return;
}
if ($("div.video-container").length) {
@ -62,20 +63,20 @@
);
container.hide()
.insertAfter(videoLink.parent())
.slideDown("fast");
.insertAfter(videoLink.parent())
.slideDown("fast");
videoLink.click(function() {
videoContainer.slideUp("fast", function() {
$(this).detach();
});
videoContainer.slideUp("fast", function() {
$(this).detach();
});
});
};
this.onVideoLinkClicked = function(evt) {
if(self.canEmbed) {
evt.preventDefault();
self.embed($(this));
evt.preventDefault();
self.embed($(this));
}
};
@ -87,8 +88,8 @@
'<iframe class="youtube-player" type="text/html" src="http://www.youtube.com/embed/{{video-id}}?wmode=opaque{{anchor}}"></iframe>');
self.register("vimeo.com",
'<a href="http://vimeo.com/{{video-id}}">' + $.mustache(watchVideoOn, { provider: "Vimeo" }) + '</a><br />' +
'<iframe class="vimeo-player" src="http://player.vimeo.com/video/{{video-id}}"></iframe>');
'<a href="http://vimeo.com/{{video-id}}">' + $.mustache(watchVideoOn, { provider: "Vimeo" }) + '</a><br />' +
'<iframe class="vimeo-player" src="http://player.vimeo.com/video/{{video-id}}"></iframe>');
self.register("undefined", '<p>' + Diaspora.widgets.i18n.t("videos.unknown") + ' - {{host}}</p>');
};

View file

@ -17,10 +17,10 @@
this.render = function(result) {
$("<div/>", {
id: (result.success) ? "flash_notice" : "flash_error"
id: (result.success) ? "flash_notice" : "flash_error"
})
.prependTo(document.body)
.html(result.notice);
.prependTo(document.body)
.html(result.notice);
self.animateMessages();
};

View file

@ -15,16 +15,16 @@
this.t = function(item, views) {
var translatedMessage,
items = item.split(".");
items = item.split(".");
while(nextNamespace = items.shift()) {
translatedMessage = (translatedMessage)
? translatedMessage[nextNamespace]
: self.locale[nextNamespace];
translatedMessage = (translatedMessage)
? translatedMessage[nextNamespace]
: self.locale[nextNamespace];
if(typeof translatedMessage === "undefined") {
return "";
}
if(typeof translatedMessage === "undefined") {
return "";
}
}
return $.mustache(translatedMessage, views || { });

View file

@ -11,9 +11,9 @@
nextSelector : ".paginate",
itemSelector : ".stream_element",
pathParse : function( pathStr, nextPage ){
var newPath = pathStr.replace("?", "?only_posts=true&");
var last_time = $('#main_stream .stream_element').last().find('.time').attr('integer');
return newPath.replace( /max_time=\d+/, 'max_time=' + last_time);
var newPath = pathStr.replace("?", "?only_posts=true&"),
lastTime = $('#main_stream .stream_element').last().find('.time').attr('integer');
return newPath.replace( /max_time=\d+/, 'max_time=' + lastTime);
},
bufferPx: 500,
debug: false,
@ -34,16 +34,16 @@
this.initialize = function() {
if($('#main_stream').length !== 0){
$('#main_stream').infinitescroll(this.options, function() {
Diaspora.widgets.publish("stream/scrolled");
});
$('#main_stream').infinitescroll(this.options, function() {
Diaspora.widgets.publish("stream/scrolled");
});
} else if($('#people_stream.contacts').length !== 0){
$("#people_stream.contacts").infinitescroll($.extend(self.options, {
navSelector : ".pagination",
nextSelector : ".next_page",
}), function() {
Diaspora.widgets.publish("stream/scrolled");
});
$("#people_stream.contacts").infinitescroll($.extend(self.options, {
navSelector : ".pagination",
nextSelector : ".next_page",
}), function() {
Diaspora.widgets.publish("stream/scrolled");
});
}
};

View file

@ -11,7 +11,7 @@
self.ajaxLoader = self.dropdown.find(".ajax_loader");
self.badgeLink.toggle(function(evt) {
evt.preventDefault();
evt.preventDefault();
evt.stopPropagation();
self.ajaxLoader.show();

View file

@ -36,14 +36,14 @@
this.showNotification = function(notification) {
$(notification.html).prependTo(this.notificationArea)
.fadeIn(200)
.delay(8000)
.fadeOut(200, function() {
$(this).detach();
});
.fadeIn(200)
.delay(8000)
.fadeOut(200, function() {
$(this).detach();
});
if(typeof notification.incrementCount === "undefined" || notification.incrementCount) {
this.incrementCount();
this.incrementCount();
}
};
@ -51,18 +51,18 @@
this.count += change;
if(this.badge.text() !== "") {
this.badge.text(this.count);
if(this.on_index_page)
this.index_badge.text(this.count + " ");
this.badge.text(this.count);
if(this.onIndexPage)
this.indexBadge.text(this.count + " ");
if(this.count === 0) {
this.badge.addClass("hidden");
if(this.on_index_page)
this.index_badge.removeClass('unread');
}
else if(this.count === 1) {
this.badge.removeClass("hidden");
}
if(this.count === 0) {
this.badge.addClass("hidden");
if(this.onIndexPage)
this.indexBadge.removeClass('unread');
}
else if(this.count === 1) {
this.badge.removeClass("hidden");
}
}
};

View file

@ -33,13 +33,13 @@
this.expandLikes = function(evt){
evt.preventDefault();
var likesList = $(this).siblings(".likes_list");
if(likesList.children().length == 0){
if(likesList.children().length == 0) {
likesList.append("<img alt='loading' src='/images/ajax-loader.gif' />");
$.ajax({
url: this.href,
success: function(data){
likesList.html(data)
.fadeToggle(100);
.fadeToggle(100);
}
});
}

View file

@ -12,9 +12,9 @@
self.updateTimeAgo();
if(Diaspora.widgets.i18n.language !== "en") {
$.each($.timeago.settings.strings, function(index) {
$.timeago.settings.strings[index] = Diaspora.widgets.i18n.t("timeago." + index);
});
$.each($.timeago.settings.strings, function(index) {
$.timeago.settings.strings[index] = Diaspora.widgets.i18n.t("timeago." + index);
});
}
});