🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.javascript
Article #50228

Re: Automatyczne dzielenie tekstu na strony

#50228
From: Peter May
Date: Wed, 01 Sep 2010 18:58
46 lines
2438 bytes
W dniu 2010-09-01 13:15, Slawek-L pisze:
> W dniu 2010-08-30 09:30, Slawek-L pisze:
>> Witam,
>
> Sam sobie odpowiem. :) Może komuś się przyda.
>
>
> function splitToTabs(fromDiv, tabsDiv, tmpDiv, tabHeight)
> {
> var tabIndex = 1;
> var contentArray = new Array;
> var contentIndex =0;
> contentArray = jQuery.makeArray( $(fromDiv).contents().clone() );
>
> while ( contentIndex < contentArray.length )
> {
> $(tmpDiv).append( contentArray[contentIndex] );
> contentIndex++;
> if ( $(tmpDiv).outerHeight() > tabHeight )
> {
> contentIndex--;
> contentArray[contentIndex] = $(tmpDiv).contents().last();
> $("#tabs-"+tabIndex.toString() ).append( $(tmpDiv).contents() );
> tabIndex++;
> $(tabsDiv).tabs('add', '#tabs-'+tabIndex,tabIndex.toString());
> $(tmpDiv).contents().remove();
> }
> }
> if ( $(tmpDiv).contents() != null )
> {
> $("#tabs-"+tabIndex.toString() ).append( $(tmpDiv).contents() );
> }
> }
>
> Działa mniej więcej tak: we fromDiv jest treść do podzielenia,
> tabsDiv to element w którym będą zakładki, a tmpDiv to
> tymczasowy div służący do przerzucania treści.
> tabHeight to wysokość zakładki. Jeśli ta wysokość zostanie przekroczona
> to zostaje utworzona kolejna zakładka i ciąg dalszy jest wrzucany do
> następnych zakładek. tmpDiv musi mieć taką samą szerokość jak docelowa
> kolumna tekstu.

I wszystko dobrze, poza tym, że do tego jQuery wcale nie jest potrzebne :P

-- 
Peter
Technical Details
Message-ID: <i5m7pl$iol$4@news.onet.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!agh.edu.pl!news.agh.edu.pl!news.onet.pl!not-for-mail
References: <4c7b5dfa$0$21001$65785112@news.neostrada.pl> <4c7e35d7$0$22792$65785112@news.neostrada.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!agh.edu.pl!news.agh.edu.pl!news.onet.pl!not-for-mail
From: Peter May <peter.may@onet.pl>
Newsgroups: pl.comp.lang.javascript
Subject: Re: Automatyczne dzielenie tekstu na strony
Date: Wed, 01 Sep 2010 20:58:57 +0200
Organization: http://onet.pl
Lines: 46
Message-ID: <i5m7pl$iol$4@news.onet.pl>
References: <4c7b5dfa$0$21001$65785112@news.neostrada.pl> <4c7e35d7$0$22792$65785112@news.neostrada.pl>
NNTP-Posting-Host: 188.147.195.141.nat.umts.dynamic.eranet.pl
Mime-Version: 1.0
X-Trace: news.onet.pl 1283367542 19221 188.147.195.141 (1 Sep 2010 18:59:02 GMT)
X-Complaints-To: niusy@onet.pl
NNTP-Posting-Date: Wed, 1 Sep 2010 18:59:02 +0000 (UTC)
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; pl; rv:1.9.2.8) Gecko/20100802 Lightning/1.0b2 Thunderbird/3.1.2
In-Reply-To: <4c7e35d7$0$22792$65785112@news.neostrada.pl>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit