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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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