(function($) {
$.fn.iComputerSlide = function(options) {
options = $.extend({
height: 200,
btnClose: "Close",
btnOpen: "Open"
}, options);
makeWrap = function($element, options) {
return '<div class="io_item">' +
'<div class="io_item_wrap" style="max-height:' + options.height + 'px">' + $element[0].outerHTML +
'<div class="io_trans"></div>' +
'</div>' +
'<div class="io_button_wrap">' +
'<a class="io_button btn_close">' + options.btnClose + '</a>' +
'<a class="io_button btn_open">' + options.btnOpen + '</a>' +
'</div>' +
'</div>';
};
$(document).on("click", ".io_button", function() {
$(this).parents(".io_item").toggleClass("open");
});
return this.each(function() {
var $element = $(this);
$element.replaceWith(makeWrap($element, options));
document.querySelector('body').addEventListener(
'click',
function (e) {
if (e.currentTarget.classList.contains('btn_close')) {
e.currentTarget.scrollIntoView(true);
}
},
);
});
};
})(jQuery);
$(function() {
$(".item_text").iComputerSlide({
height: 150,
btnClose: "Свернуть",
btnOpen: "Читать"
});
});
let btn = document.querySelector('.btn_close');
let el = document.querySelector('.btn_close');
btn.addEventListener('click', function () {
el.scrollIntoView(true);
});
document.querySelector('body').addEventListener(
'click',
function (e) {
if (e.currentTarget.classList.contains('btn_close')
e.currentTarget.scrollIntoView(true);
},
);
let btn = document.querySelector('.btn_close');
let el = document.querySelector('.btn_close');
btn.addEventListener('click', function () {
el.scrollIntoView(true);
});
$(document).ready(function() {
// Configure/customize these variables.
var showChar = 230; // How many characters are shown by default
var ellipsestext = "...";
var moretext = "Показать больше";
var lesstext = "Скрыть";
$('.more').each(function() {
var content = $(this).html();
if(content.length > showChar) {
var c = content.substr(0, showChar);
var h = content.substr(showChar, content.length - showChar);
var html = c + '<span class="moreellipses">' + ellipsestext+ ' </span><span class="morecontent"><span>' + h + '</span> <a href="" class="morelink">' + moretext + '</a></span>';
$(this).html(html);
}
});
$(".morelink").click(function(){
if($(this).hasClass("less")) {
$(this).removeClass("less");
$(this).html(moretext);
} else {
$(this).addClass("less");
$(this).html(lesstext);
}
$(this).parent().prev().toggle();
$(this).prev().toggle();
return false;
});
});