Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/toryanderson/hugo-icarus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordigitalcraftsman <digitalcraftsman@protonmail.com>2016-08-19 19:06:11 +0300
committerdigitalcraftsman <digitalcraftsman@protonmail.com>2016-08-19 19:06:11 +0300
commit3e5ca25aaccf730b01946a14f5fafe76170a5da2 (patch)
treed59fadb3a8d0273eb4c0c2b5fef3022d68bc90f1
parentc681bb5c5807ad59079a8d080dafd3c621872be5 (diff)
Update main.js script
Fixes #36
-rw-r--r--layouts/partials/sidebar.html2
-rw-r--r--static/js/script.js146
2 files changed, 48 insertions, 100 deletions
diff --git a/layouts/partials/sidebar.html b/layouts/partials/sidebar.html
index 9cfd364..fc63d8e 100644
--- a/layouts/partials/sidebar.html
+++ b/layouts/partials/sidebar.html
@@ -4,5 +4,5 @@
{{ partial "widgets/tags" . }}
{{ partial "widgets/tag_cloud" . }}
- <div id="toTop" class="fa fa-chevron-up"></div>
+ <div id="toTop" class="fa fa-angle-up"></div>
</aside>
diff --git a/static/js/script.js b/static/js/script.js
index d5f3696..b298f0c 100644
--- a/static/js/script.js
+++ b/static/js/script.js
@@ -1,106 +1,54 @@
(function($){
- var toTop = $('#toTop').length ? $('#toTop').offset().top - $(window).height() + 20 : 0;
-
- // Share
- $('body').on('click', function(){
- $('.article-share-box.on').removeClass('on');
- }).on('click', '.article-share-link', function(e){
- e.stopPropagation();
-
- var $this = $(this),
- url = $this.attr('data-url'),
- encodedUrl = encodeURIComponent(url),
- id = 'article-share-box-' + $this.attr('data-id'),
- offset = $this.offset();
-
- if ($('#' + id).length){
- var box = $('#' + id);
-
- if (box.hasClass('on')){
- box.removeClass('on');
- return;
- }
- } else {
- var html = [
- '<div id="' + id + '" class="article-share-box">',
- '<input class="article-share-input" value="' + url + '">',
- '<div class="article-share-links">',
- '<a href="https://twitter.com/intent/tweet?url=' + encodedUrl + '" class="fa fa-twitter article-share-twitter" target="_blank" title="Twitter"></a>',
- '<a href="https://www.facebook.com/sharer.php?u=' + encodedUrl + '" class="fa fa-facebook article-share-facebook" target="_blank" title="Facebook"></a>',
- '<a href="http://pinterest.com/pin/create/button/?url=' + encodedUrl + '" class="fa fa-pinterest article-share-pinterest" target="_blank" title="Pinterest"></a>',
- '<a href="https://plus.google.com/share?url=' + encodedUrl + '" class="fa fa-google article-share-google" target="_blank" title="Google+"></a>',
- '</div>',
- '</div>'
- ].join('');
-
- var box = $(html);
-
- $('body').append(box);
- }
-
- $('.article-share-box.on').hide();
-
- box.css({
- top: offset.top + 25,
- left: offset.left
- }).addClass('on');
- }).on('click', '.article-share-box', function(e){
- e.stopPropagation();
- }).on('click', '.article-share-box-input', function(){
- $(this).select();
- }).on('click', '.article-share-box-link', function(e){
- e.preventDefault();
- e.stopPropagation();
-
- window.open(this.href, 'article-share-box-window-' + Date.now(), 'width=500,height=450');
- });
-
- // Caption
- $('.article-entry').each(function(i){
- $(this).find('img').each(function(){
- if ($(this).parent().hasClass('fancybox')) return;
-
- var alt = this.alt;
-
- if (alt) $(this).after('<span class="caption">' + alt + '</span>');
-
- $(this).wrap('<a href="' + this.src + '" title="' + alt + '" class="fancybox"></a>');
+ var toTop = ($('#sidebar').height() - $(window).height()) + 60;
+ // Caption
+ $('.article-entry').each(function(i){
+ $(this).find('img').each(function(){
+ if ($(this).parent().hasClass('fancybox')) {
+ return;
+ }
+ var alt = this.alt;
+ if (alt) {
+ $(this).after('<span class="caption">' + alt + '</span>');
+ }
+
+ $(this).wrap('<a href="' + this.src + '" title="' + alt + '" class="fancybox"></a>');
+ });
+
+ $(this).find('.fancybox').each(function(){
+ $(this).attr('rel', 'article' + i);
+ });
});
+ if ($.fancybox){
+ $('.fancybox').fancybox();
+ }
- $(this).find('.fancybox').each(function(){
- $(this).attr('rel', 'article' + i);
+ // Profile card
+ $(document).on('click', function () {
+ $('#profile').removeClass('card');
+ }).on('click', '#profile-anchor', function (e) {
+ e.stopPropagation();
+ $('#profile').toggleClass('card');
+ }).on('click', '.profile-inner', function (e) {
+ e.stopPropagation();
});
- });
-
- if ($.fancybox){
- $('.fancybox').fancybox();
- }
-
- // Profile card
- $(document).on('click', function () {
- $('#profile').removeClass('card');
- }).on('click', '#profile-anchor', function (e) {
- e.stopPropagation();
- $('#profile').toggleClass('card');
- }).on('click', '.profile-inner', function (e) {
- e.stopPropagation();
- });
- // To Top
- $(document).on('scroll', function () {
- if ($(document).width() >= 800) {
- if($(this).scrollTop() > toTop) {
- $('#toTop').addClass('fix');
- $('#toTop').css('left', $('#sidebar').offset().left);
- } else {
- $('#toTop').removeClass('fix');
- }
- } else {
- $('#toTop').addClass('fix');
- $('#toTop').css('right', 20);
+ // To Top
+ if ($('#sidebar').length) {
+ $(document).on('scroll', function () {
+ if ($(document).width() >= 800) {
+ if(($(this).scrollTop() > toTop) && ($(this).scrollTop() > 0)) {
+ $('#toTop').fadeIn();
+ $('#toTop').css('left', $('#sidebar').offset().left);
+ } else {
+ $('#toTop').fadeOut();
+ }
+ } else {
+ $('#toTop').fadeIn();
+ $('#toTop').css('right', 20);
+ }
+ }).on('click', '#toTop', function () {
+ $('body, html').animate({ scrollTop: 0 }, 600);
+ });
}
- }).on('click', '#toTop', function () {
- $(document).scrollTop(0);
- });
-})(jQuery); \ No newline at end of file
+})(jQuery);