/** * @name Elastic * @descripton Elastic is jQuery plugin that grow and shrink your textareas automatically * @version 1.6.11 * @requires jQuery 1.2.6+ * * @author Jan Jarfalk * @author-email jan.jarfalk@unwrongest.com * @author-website http://www.unwrongest.com * * @licence MIT License - http://www.opensource.org/licenses/mit-license.php */ (function($){ jQuery.fn.extend({ elastic: function() { // We will create a div clone of the textarea // by copying these attributes from the textarea to the div. var mimics = [ 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'fontSize', 'lineHeight', 'fontFamily', 'width', 'fontWeight', 'border-top-width', 'border-right-width', 'border-bottom-width', 'border-left-width', 'borderTopStyle', 'borderTopColor', 'borderRightStyle', 'borderRightColor', 'borderBottomStyle', 'borderBottomColor', 'borderLeftStyle', 'borderLeftColor' ]; return this.each( function() { // Elastic only works on textareas if ( this.type !== 'textarea' ) { return false; } var $textarea = jQuery(this), $twin = jQuery('
').css({ 'position' : 'absolute', 'display' : 'none', 'word-wrap' : 'break-word', 'white-space' :'pre-wrap' }), lineHeight = 0, //parseInt($textarea.css('line-height'),10) || parseInt($textarea.css('font-size'),'10'), minheight = parseInt($textarea.css('height'),10) || lineHeight*2, maxheight = parseInt($textarea.css('max-height'),10) || Number.MAX_VALUE, goalheight = 0; // Opera returns max-height of -1 if not set if (maxheight < 0) { maxheight = Number.MAX_VALUE; } // Append the twin to the DOM // We are going to meassure the height of this, not the textarea. $twin.appendTo($textarea.parent()); // Copy the essential styles (mimics) from the textarea to the twin var i = mimics.length; while(i--){ $twin.css(mimics[i].toString(),$textarea.css(mimics[i].toString())); } // Updates the width of the twin. (solution for textareas with widths in percent) function setTwinWidth(){ var curatedWidth = Math.floor(parseInt($textarea.width(),10)); if($twin.width() !== curatedWidth){ $twin.css({'width': curatedWidth + 'px'}); // Update height of textarea update(true); } } // Sets a given height and overflow state on the textarea function setHeightAndOverflow(height, overflow){ var curratedHeight = Math.floor(parseInt(height,10)); if (parseInt($textarea.css('height'),10) !== curratedHeight){ $textarea.css({'height': curratedHeight + 'px','overflow':overflow}); } } // This function will update the height of the textarea if necessary function update(forced) { // Get curated content from the textarea. var textareaContent = $textarea.val().replace(/&/g,'&').replace(/ {2}/g, ' ').replace(/<|>/g, '>').replace(/\n/g, '
'); // Compare curated content with curated twin. var twinContent = $twin.html().replace(/
/ig,'
'); if (forced || textareaContent+' ' !== twinContent){ // Add an extra white space so new rows are added when you are at the end of a row. $twin.html(textareaContent+' '); // Change textarea height if twin plus the height of one line differs more than 3 pixel from textarea height if (Math.abs(parseInt($twin.css('height'),10) + lineHeight - parseInt($textarea.css('height'),10)) > 3) { var goalheight = parseInt($twin.css('height'),10) + lineHeight; if (goalheight >= maxheight) { setHeightAndOverflow(maxheight,'auto'); } else if (goalheight <= minheight) { setHeightAndOverflow(minheight,'hidden'); } else { setHeightAndOverflow(goalheight,'hidden'); } } } } // Hide scrollbars $textarea.css({'overflow':'hidden'}); // Update textarea size on keyup, change, cut and paste $textarea.bind('keyup change cut paste', function(){ update(); }); // Update width of twin if browser or textarea is resized (solution for textareas with widths in percent) $(window).bind('resize', setTwinWidth); $textarea.bind('resize', setTwinWidth); $textarea.bind('update', update); // Compact textarea on blur $textarea.bind('blur',function(){ if(parseInt($twin.css('height'),10) < maxheight){ if(parseInt($twin.css('height'),10) > minheight) { $textarea.css({'height': parseInt($twin.css('height'),10) + 'px'}); } else { $textarea.css({'height': minheight + 'px'}); } } }); // And this line is to catch the browser paste event $textarea.bind('input paste',function(e){ setTimeout( update, 250); }); // Run update once when elastic is initialized update(); }); } }); })(jQuery);function showvideo(type, videonumber, width=1000, height=600){ var video = $("#video"); if (video !== null) remove_video(); if (type == "youtube"){ var iframe = ''; var close = '
'; var div2 = '
'+close+iframe+'
'; var div = '
'+div2+'
'; $("body").append(div); $("*").find("div").not("#video,#innerDiv,#closeVideo").css('opacity', '0.5'); $("body").css('overflow', 'hidden'); } function remove_video() { $("#video").remove(); $("*").find("div").not("#video").css('opacity', '1'); $("body").css('overflow', 'inherit'); }$.addShowTabs=function(t,p){ if(t.grid)return false; p=$.extend({ usko:false, data:false, setCFlag:false, onClick:false },p); var g={ setChangeFlag:function(a,b){ var d=a.namedItem(b); if(d.getAttribute('abbr_ch')!==null){ $(d).find('input').bind('change.zmena_prvku',function(){ this.setAttribute('spec_change',true); }); } }, bindClick:function(c){ c.bind('click',function(){ var s1=new Date().getTime(), p=this.parentElement, u=p.children; if($(p).is('#roll_tabs_okno')){ p=p.parentElement.parentElement; } var n=p.nextElementSibling===undefined?p.nextSibling:p.nextElementSibling; while(n.nodeName=='#comment'){ n=n.nextElementSibling===undefined?n.nextSibling:n.nextElementSibling; } var d=n.children, pp=p.parentElement, a=this.getAttribute('abbr'), b=p.getAttribute('id'), du=false, j=0; if(n.getAttribute('id')!=b+'_data') d=pp.nextElementSibling===undefined?pp.nextSibling.children:pp.nextElementSibling.children; for(var i=0; i50){ s.css('left',(p+50)); }else{ if(-p>0){ s.css('left',0); } } }); b.last().bind('click',function(){ var s=$(this).prev().children().first(), p=s.position().left, m=s.width()-s.parent().width(); if(-p'); }else{ ii.val(c.filter('.big').attr('abbr')); } if(b.first().is('#roll_left')){ var ow=0; c.each(function(){ ow+=$(this).outerWidth(true); }); b.first().next().children().first().css('width',(ow+10)+'px'); if(ow 0){ setInterval(function(){ webOdosliDopytAjax('/hu/ajax/updatemessagecount'); }, 60000); } });