Simplified util/misc.js requires

This commit is contained in:
Marcin Kurczewski 2014-12-20 10:30:10 +01:00
parent e5f2e293f0
commit 970b9bf06d
17 changed files with 38 additions and 50 deletions

View file

@ -72,8 +72,7 @@ App.Presenters.CommentListPresenter = function(
{
commentListItemTemplate: templates.commentListItem,
commentFormTemplate: templates.commentForm,
formatRelativeTime: util.formatRelativeTime,
formatMarkdown: util.formatMarkdown,
util: util,
comments: comments,
post: post,
},
@ -102,9 +101,7 @@ App.Presenters.CommentListPresenter = function(
function renderComment($targetList, comment) {
var $item = jQuery('<li>' + templates.commentListItem({
comment: comment,
formatRelativeTime: util.formatRelativeTime,
formatAbsoluteTime: util.formatAbsoluteTime,
formatMarkdown: util.formatMarkdown,
util: util,
canVote: auth.isLoggedIn(),
canEditComment: auth.isLoggedIn(comment.user.name) ? privileges.canEditOwnComments : privileges.canEditAllComments,
canDeleteComment: auth.isLoggedIn(comment.user.name) ? privileges.canDeleteOwnComments : privileges.canDeleteAllComments,

View file

@ -62,8 +62,7 @@ App.Presenters.HistoryPresenter = function(
function renderHistory($page, historyItems) {
$page.append(templates.history({
formatRelativeTime: util.formatRelativeTime,
formatAbsoluteTime: util.formatAbsoluteTime,
util: util,
history: historyItems}));
}

View file

@ -58,8 +58,7 @@ App.Presenters.HomePresenter = function(
title: topNavigationPresenter.getBaseTitle(),
canViewUsers: auth.hasPrivilege(auth.privileges.viewUsers),
canViewPosts: auth.hasPrivilege(auth.privileges.viewPosts),
formatRelativeTime: util.formatRelativeTime,
formatFileSize: util.formatFileSize,
util: util,
version: jQuery('head').attr('data-version'),
buildTime: jQuery('head').attr('data-build-time'),
}));

View file

@ -50,7 +50,7 @@ App.Presenters.PostNotesPresenter = function(
privileges: privileges,
post: post,
notes: notes,
formatMarkdown: util.formatMarkdown}));
util: util}));
$form = $target.find('.post-note-edit');
var $postNotes = $target.find('.post-note');

View file

@ -163,9 +163,7 @@ App.Presenters.PostPresenter = function(
postFavorites: post.favorites,
postHistory: post.history,
formatRelativeTime: util.formatRelativeTime,
formatAbsoluteTime: util.formatAbsoluteTime,
formatFileSize: util.formatFileSize,
util: util,
historyTemplate: templates.history,

View file

@ -108,7 +108,7 @@ App.Presenters.TagListPresenter = function(
_.each(tags, function(tag) {
var $item = jQuery(templates.listItem({
tag: tag,
formatRelativeTime: util.formatRelativeTime,
util: util,
}));
$target.append($item);
});

View file

@ -87,8 +87,7 @@ App.Presenters.TagPresenter = function(
tag: tag,
siblings: siblings,
tagCategories: JSON.parse(jQuery('head').attr('data-tag-categories')),
formatRelativeTime: util.formatRelativeTime,
formatAbsoluteTime: util.formatAbsoluteTime,
util: util,
historyTemplate: templates.history,
}));
$el.find('.post-list').hide();

View file

@ -76,8 +76,7 @@ App.Presenters.UserListPresenter = function(
_.each(users, function(user) {
var $item = jQuery('<li>' + templates.listItem(_.extend({
user: user,
formatRelativeTime: util.formatRelativeTime,
formatAbsoluteTime: util.formatAbsoluteTime,
util: util,
}, privileges)) + '</li>');
$target.append($item);
});

View file

@ -74,8 +74,7 @@ App.Presenters.UserPresenter = function(
$el.html(templates.user({
user: user,
isLoggedIn: auth.isLoggedIn(user.name),
formatRelativeTime: util.formatRelativeTime,
formatAbsoluteTime: util.formatAbsoluteTime,
util: util,
canChangeBrowsingSettings: userBrowsingSettingsPresenter.getPrivileges().canChangeBrowsingSettings,
canChangeAccountSettings: _.any(userAccountSettingsPresenter.getPrivileges()),
canDeleteAccount: userAccountRemovalPresenter.getPrivileges().canDeleteAccount}));

View file

@ -27,8 +27,8 @@
<% } %>
</span>
<span class="date" title="<%= formatAbsoluteTime(comment.creationTime) %>">
<%= formatRelativeTime(comment.creationTime) %>
<span class="date" title="<%= util.formatAbsoluteTime(comment.creationTime) %>">
<%= util.formatRelativeTime(comment.creationTime) %>
</span>
<span class="score">
@ -60,7 +60,7 @@
</div>
<div class="content">
<%= formatMarkdown(comment.text) %>
<%= util.formatMarkdown(comment.text) %>
</div>
</div>
</div>

View file

@ -22,8 +22,8 @@ var showDifference = function(className, difference) {
<tbody>
<% _.each(history, function( historyEntry) { %>
<tr>
<td class="time" title="<%= formatAbsoluteTime(historyEntry.time) %>">
<%= formatRelativeTime(historyEntry.time) %>
<td class="time" title="<%= util.formatAbsoluteTime(historyEntry.time) %>">
<%= util.formatRelativeTime(historyEntry.time) %>
</td>
<td class="user">

View file

@ -1,7 +1,7 @@
<div id="home">
<h1><%= title %></h1>
<p class="subheader">
Serving <%= globals.postCount || 0 %> posts (<%= formatFileSize(globals.postSize || 0) %>)
Serving <%= globals.postCount || 0 %> posts (<%= util.formatFileSize(globals.postSize || 0) %>)
</p>
<% if (post && post.id) { %>
@ -25,12 +25,12 @@
<% } %>
uploaded
<%= formatRelativeTime(post.uploadTime) %>
<%= util.formatRelativeTime(post.uploadTime) %>
</span>
<span class="right">
featured
<%= formatRelativeTime(post.lastFeatureTime) %>
<%= util.formatRelativeTime(post.lastFeatureTime) %>
by
<% var showLink = canViewUsers && user.name %>
@ -56,7 +56,7 @@
<p>
<small class="version">
Version: <a href="//github.com/rr-/szurubooru/commits/master"><%= version %></a> (built <%= formatRelativeTime(buildTime) %>)
Version: <a href="//github.com/rr-/szurubooru/commits/master"><%= version %></a> (built <%= util.formatRelativeTime(buildTime) %>)
|
<a href="#/history">Recent tag and post edits</a>
</small>

View file

@ -8,7 +8,7 @@
<div class="text-wrapper">
<div class="text">
<%= formatMarkdown(note.text) %>
<%= util.formatMarkdown(note.text) %>
</div>
</div>

View file

@ -10,7 +10,7 @@
</div>
<div class="search">
<a class="enabled" href="#/posts/query=<%= query.query %>;order=<%= query.order %>">
<a class="enabled" href="<%= util.appendComplexRouteParam('#/posts', {query: query.query, order: query.order}) %>">
Current search: <%= query.query || '-' %>
</a>
</div>
@ -32,7 +32,7 @@
<a class="download" href="<%= permaLink %>">
<i class="fa fa-download"></i>
<br/>
<%= post.contentExtension + ', ' + formatFileSize(post.originalFileSize) %>
<%= post.contentExtension + ', ' + util.formatFileSize(post.originalFileSize) %>
</a>
</li>
<% } %>
@ -109,8 +109,8 @@
<br/>
<span class="date" title="<%= formatAbsoluteTime(post.uploadTime) %>">
<%= formatRelativeTime(post.uploadTime) %>
<span class="date" title="<%= util.formatAbsoluteTime(post.uploadTime) %>">
<%= util.formatRelativeTime(post.uploadTime) %>
</span>
</div>
@ -126,7 +126,7 @@
<% if (post.originalFileSize) { %>
<li>
File size:
<%= formatFileSize(post.originalFileSize) %>
<%= util.formatFileSize(post.originalFileSize) %>
</li>
<% } %>
@ -140,8 +140,8 @@
<% if (post.lastEditTime !== post.uploadTime) { %>
<li>
Edited:
<span title="<%= formatAbsoluteTime(post.lastEditTime) %>">
<%= formatRelativeTime(post.lastEditTime) %>
<span title="<%= util.formatAbsoluteTime(post.lastEditTime) %>">
<%= util.formatRelativeTime(post.lastEditTime) %>
</span>
</li>
<% } %>
@ -149,7 +149,7 @@
<% if (post.featureCount > 0) { %>
<li>
Featured: <%= post.featureCount %> <%= post.featureCount < 2 ? 'time' : 'times' %>
<small>(<%= formatRelativeTime(post.lastFeatureTime) %>)</small>
<small>(<%= util.formatRelativeTime(post.lastFeatureTime) %>)</small>
</li>
<% } %>
@ -277,8 +277,7 @@
<h1>History</h1>
<%= historyTemplate({
history: postHistory,
formatRelativeTime: formatRelativeTime,
formatAbsoluteTime: formatAbsoluteTime,
util: util,
}) %>
</div>
<% } %>

View file

@ -103,8 +103,7 @@
<h3>History</h3>
<%= historyTemplate({
history: tag.history,
formatRelativeTime: formatRelativeTime,
formatAbsoluteTime: formatAbsoluteTime,
util: util,
}) %>
</div>
<% } %>

View file

@ -19,11 +19,11 @@
<%= user.name %>
<% } %>
</h1>
<div class="date-joined" title="<%= formatAbsoluteTime(user.registrationTime) %>">
Joined: <%= formatRelativeTime(user.registrationTime) %>
<div class="date-joined" title="<%= util.formatAbsoluteTime(user.registrationTime) %>">
Joined: <%= util.formatRelativeTime(user.registrationTime) %>
</div>
<div class="date-seen" title="<%= formatAbsoluteTime(user.lastLoginTime) %>">
Last seen: <%= formatRelativeTime(user.lastLoginTime) %>
<div class="date-seen" title="<%= util.formatAbsoluteTime(user.lastLoginTime) %>">
Last seen: <%= util.formatRelativeTime(user.lastLoginTime) %>
</div>
</div>
</div>

View file

@ -51,15 +51,15 @@
<table>
<tr>
<td>Registered:</td>
<td title="<%= formatAbsoluteTime(user.registrationTime) %>">
<%= formatRelativeTime(user.registrationTime) %>
<td title="<%= util.formatAbsoluteTime(user.registrationTime) %>">
<%= util.formatRelativeTime(user.registrationTime) %>
</td>
</tr>
<tr>
<td>Seen:</td>
<td title="<%= formatAbsoluteTime(user.lastLoginTime) %>">
<%= formatRelativeTime(user.lastLoginTime) %>
<td title="<%= util.formatAbsoluteTime(user.lastLoginTime) %>">
<%= util.formatRelativeTime(user.lastLoginTime) %>
</td>
</tr>