fixed two bugs in admin, meta.buildTitle errors out because no notification icon is present; pagination element missing

& final less cleanup for today
This commit is contained in:
psychobunny
2013-08-28 02:32:38 +08:00
parent e82a9ec37a
commit 7666ed3010
4 changed files with 30 additions and 23 deletions

View File

@@ -94,10 +94,10 @@ footer.footer {
i { i {
-webkit-transition: color 100ms linear; -webkit-transition: color 100ms linear;
-moz-transition: color 100ms linear; -moz-transition: color 100ms linear;
-ms-transition: color 100ms linear; -ms-transition: color 100ms linear;
-o-transition: color 100ms linear; -o-transition: color 100ms linear;
transition: color 100ms linear; transition: color 100ms linear;
&.icon-twitter-sign:hover { &.icon-twitter-sign:hover {
color: #4099FF; color: #4099FF;

View File

@@ -25,12 +25,17 @@ var ajaxify = {};
if (event !== null && event.state && event.state.url !== undefined) ajaxify.go(event.state.url, null, null, true); if (event !== null && event.state && event.state.url !== undefined) ajaxify.go(event.state.url, null, null, true);
}; };
var pagination;
ajaxify.go = function(url, callback, template, quiet) { ajaxify.go = function(url, callback, template, quiet) {
// the following should be set like so: ajaxify.onchange(function(){}); where the code actually belongs // start: the following should be set like so: ajaxify.onchange(function(){}); where the code actually belongs
$(window).off('scroll'); $(window).off('scroll');
app.enter_room('global'); app.enter_room('global');
document.getElementById('pagination').style.display = 'none';
pagination = pagination || document.getElementById('pagination');
if (pagination) pagination.style.display = 'none';
window.onscroll = null; window.onscroll = null;
// end
var url = url.replace(/\/$/, ""); var url = url.replace(/\/$/, "");

View File

@@ -1,5 +1,5 @@
(function (module) { (function (module) {
var utils, fs; var utils, fs;
try { try {
@@ -39,15 +39,15 @@
}); });
}); });
}, },
relativeTime: function(timestamp, min) { relativeTime: function(timestamp, min) {
var now = +new Date(), var now = +new Date(),
difference = now - Math.floor(parseFloat(timestamp)); difference = now - Math.floor(parseFloat(timestamp));
difference = Math.floor(difference / 1000); difference = Math.floor(difference / 1000);
if (difference < 60) return difference + (min ? 's' : ' second') + (difference !== 1 && !min ? 's' : ''); if (difference < 60) return difference + (min ? 's' : ' second') + (difference !== 1 && !min ? 's' : '');
difference = Math.floor(difference / 60); difference = Math.floor(difference / 60);
if (difference < 60) return difference + (min ? 'm' : ' minute') + (difference !== 1 && !min ? 's' : ''); if (difference < 60) return difference + (min ? 'm' : ' minute') + (difference !== 1 && !min ? 's' : '');
@@ -63,7 +63,7 @@
difference = Math.floor(difference / 12); difference = Math.floor(difference / 12);
return difference + (min ? 'y' : ' year') + (difference !== 1 && !min ? 's' : ''); return difference + (min ? 'y' : ' year') + (difference !== 1 && !min ? 's' : '');
}, },
//http://dense13.com/blog/2009/05/03/converting-string-to-slug-javascript/ //http://dense13.com/blog/2009/05/03/converting-string-to-slug-javascript/
slugify: function(str) { slugify: function(str) {
str = str.replace(/^\s+|\s+$/g, ''); // trim str = str.replace(/^\s+|\s+$/g, ''); // trim
@@ -93,7 +93,7 @@
isUserNameValid: function(name) { isUserNameValid: function(name) {
return (name && name !== "" && (/^[a-zA-Z0-9 _-]{3,14}$/.test(name))); return (name && name !== "" && (/^[a-zA-Z0-9 _-]{3,14}$/.test(name)));
}, },
isPasswordValid: function(password) { isPasswordValid: function(password) {
return password && password.indexOf(' ') === -1 && password.length > 5; return password && password.indexOf(' ') === -1 && password.length > 5;
}, },
@@ -132,10 +132,12 @@
a.href = document.location; a.href = document.location;
url = a.pathname.slice(1); url = a.pathname.slice(1);
} }
var notificationIcon;
socket.emit('api:meta.buildTitle', url, function(title, numNotifications) { socket.emit('api:meta.buildTitle', url, function(title, numNotifications) {
document.title = (numNotifications > 0 ? '(' + numNotifications + ') ' : '') + title; document.title = (numNotifications > 0 ? '(' + numNotifications + ') ' : '') + title;
if (numNotifications > 0) document.querySelector('.notifications a i').className = 'icon-circle active'; notificationIcon = notificationIcon || document.querySelector('.notifications a i');
if (numNotifications > 0 && notificationIcon) notificationIcon.className = 'icon-circle active';
}); });
jQuery.getJSON(RELATIVE_PATH + '/api/unread/total', function(data) { jQuery.getJSON(RELATIVE_PATH + '/api/unread/total', function(data) {
@@ -169,16 +171,16 @@
if (!String.prototype.ltrim) { if (!String.prototype.ltrim) {
String.prototype.ltrim=function(){return this.replace(/^\s+/,'');}; String.prototype.ltrim=function(){return this.replace(/^\s+/,'');};
} }
if (!String.prototype.rtrim) { if (!String.prototype.rtrim) {
String.prototype.rtrim=function(){return this.replace(/\s+$/,'');}; String.prototype.rtrim=function(){return this.replace(/\s+$/,'');};
}
if (!String.prototype.fulltrim) {
String.prototype.fulltrim=function(){return this.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g,'').replace(/\s+/g,' ');};
} }
if (!String.prototype.fulltrim) {
String.prototype.fulltrim=function(){return this.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g,'').replace(/\s+/g,' ');};
}
if ('undefined' !== typeof window) { if ('undefined' !== typeof window) {
window.utils = module.exports; window.utils = module.exports;
} }

View File

@@ -28,7 +28,7 @@
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"> <link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> <script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="{relative_path}/src/utils.js"></script> <script src="{relative_path}/src/utils.js"></script>
<link rel="stylesheet" type="text/css" href="{relative_path}/css/style.css" /> <link rel="stylesheet" type="text/css" href="{relative_path}/css/style.css" />
<link rel="stylesheet" type="text/css" href="{relative_path}/css/admin.css" /> <link rel="stylesheet" type="text/css" href="{relative_path}/css/admin.css" />
</head> </head>
@@ -64,7 +64,7 @@
</div> </div>
<div id="alert_window"></div> <div id="alert_window"></div>
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-md-3"> <div class="col-md-3">
@@ -102,4 +102,4 @@
</ul> </ul>
</div><!--/.well --> </div><!--/.well -->
</div><!--/span--> </div><!--/span-->
<div class="span9" id="content"> <div class="col-md-9" id="content">