Permalink
Browse files

add pjax pushState for better user experience

  • Loading branch information...
summerblue committed Aug 29, 2014
1 parent 4e77d0d commit a4fc92da93a153665cc0ca094d2a77f5ff71b84f

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1,27 +1,60 @@
$(document).ready(function()
{
moment.lang('zh-cn');
$('.timeago').each(function(){
$(this).text( moment( $(this).text() ).fromNow());
});
(function($){
var PHPHub = {
// Open External Links In New Window
$('a[href^="http://"], a[href^="https://"]').each(function() {
var a = new RegExp('/' + window.location.host + '/');
if(!a.test(this.href) ) {
$(this).click(function(event) {
event.preventDefault();
event.stopPropagation();
window.open(this.href, '_blank');
});
}
});
init: function(){
var self = this;
$(document).pjax('a', 'body');
$(document).on('pjax:start', function() {
NProgress.start();
});
$(document).on('pjax:end', function() {
NProgress.done();
self.siteBootUp();
});
self.siteBootUp();
},
siteBootUp: function(){
var self = this;
self.initExternalLink();
self.initTimeAgo();
self.initEmoji();
self.initScrollToTop();
},
initExternalLink: function(){
// Open External Links In New Window
$('a[href^="http://"], a[href^="https://"]').each(function() {
var a = new RegExp('/' + window.location.host + '/');
if(!a.test(this.href) ) {
$(this).click(function(event) {
event.preventDefault();
event.stopPropagation();
window.open(this.href, '_blank');
});
}
});
},
initTimeAgo: function(){
moment.lang('zh-cn');
$('.timeago').each(function(){
$(this).text( moment( $(this).text() ).fromNow());
});
},
initEmoji: function(){
emojify.run();
},
initScrollToTop: function(){
$.scrollUp();
}
}
window.PHPHub = PHPHub;
})(jQuery);
emojify.run();
$(document).ready(function()
{
PHPHub.init();
});
$.scrollUp();
})
function preview(){
replyContent = $("#reply_content");
oldContent = replyContent.val();
Oops, something went wrong.

0 comments on commit a4fc92d

Please sign in to comment.