Add scroll to top function
Add share buttons to news item Add logo to footer
This commit is contained in:
56
public/js/functions.js
vendored
56
public/js/functions.js
vendored
@@ -139,6 +139,62 @@ $(function () {
|
||||
});
|
||||
});
|
||||
|
||||
$(function () {
|
||||
$('.scroll_top').click(function (e) {
|
||||
e.preventDefault();
|
||||
$("html, body").stop().animate({scrollTop: 0}, 500, 'swing');
|
||||
});
|
||||
});
|
||||
|
||||
(function ($) {
|
||||
/**
|
||||
* @param {object} _options
|
||||
*/
|
||||
$.fn.share = function (_options) {
|
||||
var options = {
|
||||
type: '',
|
||||
types: {
|
||||
facebook: {
|
||||
url: 'https://www.facebook.com/sharer/sharer.php?u=',
|
||||
textOption: false
|
||||
},
|
||||
twitter_x: {
|
||||
url: 'https://twitter.com/share?url=',
|
||||
textOption: 'text='
|
||||
},
|
||||
},
|
||||
excerptClass: 'excerpt'
|
||||
};
|
||||
|
||||
$.extend(options, _options);
|
||||
|
||||
this.click(function (e) {
|
||||
e.preventDefault();
|
||||
var type = options.types[options.type];
|
||||
if (type !== undefined) {
|
||||
var extra = '';
|
||||
if (type.textOption) {
|
||||
var text = $('.' + options.excerptClass).text();
|
||||
if (text.length + location.href.length > 278) {
|
||||
text = text.substring(0, 278 - (location.href.length + 3)) + '...';
|
||||
}
|
||||
extra = '&' + type.textOption + encodeURI(text);
|
||||
}
|
||||
window.open(type.url + encodeURI(location.href) + extra, "pop", "width=600, height=400, scrollbars=no");
|
||||
} else {
|
||||
console.error(options.type + ' is unknown');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
}(jQuery));
|
||||
|
||||
$(function () {
|
||||
$('[data-share]').each(function () {
|
||||
$(this).share({type: $(this).data('share')});
|
||||
});
|
||||
});
|
||||
|
||||
(function ($) {
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user