librairies to bower

This commit is contained in:
sarah garcin
2015-05-06 15:05:01 +02:00
parent 1313e1f0e2
commit da4d135279
135 changed files with 247157 additions and 4 deletions

View File

@@ -0,0 +1,30 @@
{
"name": "jquery.columnizer",
"version": "1.6.2",
"description": "Automatically layout your content in newspaper column format. Specify column width or a static number of columns.",
"main": "src/jquery.columnizer.js",
"author": "Adam Wulf",
"ignore": [
"samples",
"tools",
"src/jquery.js",
"compress.sh"
],
"dependencies": {
"jquery": ">= 1.10.0"
},
"keywords": [
"jquery, layout, column"
],
"homepage": "https://github.com/adamwulf/Columnizer-jQuery-Plugin",
"_release": "1.6.2",
"_resolution": {
"type": "version",
"tag": "1.6.2",
"commit": "0416e343e09ddaa8e91ab81ab9fd6a7e9383d82a"
},
"_source": "git://github.com/adamwulf/Columnizer-jQuery-Plugin.git",
"_target": "~1.6.2",
"_originalSource": "jquery.columnizer",
"_direct": true
}

View File

@@ -0,0 +1,319 @@
Creative Commons Legal Code
Attribution 3.0 Unported
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR
DAMAGES RESULTING FROM ITS USE.
License
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE
COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY
COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS
AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE
TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY
BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS
CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND
CONDITIONS.
1. Definitions
a. "Adaptation" means a work based upon the Work, or upon the Work and
other pre-existing works, such as a translation, adaptation,
derivative work, arrangement of music or other alterations of a
literary or artistic work, or phonogram or performance and includes
cinematographic adaptations or any other form in which the Work may be
recast, transformed, or adapted including in any form recognizably
derived from the original, except that a work that constitutes a
Collection will not be considered an Adaptation for the purpose of
this License. For the avoidance of doubt, where the Work is a musical
work, performance or phonogram, the synchronization of the Work in
timed-relation with a moving image ("synching") will be considered an
Adaptation for the purpose of this License.
b. "Collection" means a collection of literary or artistic works, such as
encyclopedias and anthologies, or performances, phonograms or
broadcasts, or other works or subject matter other than works listed
in Section 1(f) below, which, by reason of the selection and
arrangement of their contents, constitute intellectual creations, in
which the Work is included in its entirety in unmodified form along
with one or more other contributions, each constituting separate and
independent works in themselves, which together are assembled into a
collective whole. A work that constitutes a Collection will not be
considered an Adaptation (as defined above) for the purposes of this
License.
c. "Distribute" means to make available to the public the original and
copies of the Work or Adaptation, as appropriate, through sale or
other transfer of ownership.
d. "Licensor" means the individual, individuals, entity or entities that
offer(s) the Work under the terms of this License.
e. "Original Author" means, in the case of a literary or artistic work,
the individual, individuals, entity or entities who created the Work
or if no individual or entity can be identified, the publisher; and in
addition (i) in the case of a performance the actors, singers,
musicians, dancers, and other persons who act, sing, deliver, declaim,
play in, interpret or otherwise perform literary or artistic works or
expressions of folklore; (ii) in the case of a phonogram the producer
being the person or legal entity who first fixes the sounds of a
performance or other sounds; and, (iii) in the case of broadcasts, the
organization that transmits the broadcast.
f. "Work" means the literary and/or artistic work offered under the terms
of this License including without limitation any production in the
literary, scientific and artistic domain, whatever may be the mode or
form of its expression including digital form, such as a book,
pamphlet and other writing; a lecture, address, sermon or other work
of the same nature; a dramatic or dramatico-musical work; a
choreographic work or entertainment in dumb show; a musical
composition with or without words; a cinematographic work to which are
assimilated works expressed by a process analogous to cinematography;
a work of drawing, painting, architecture, sculpture, engraving or
lithography; a photographic work to which are assimilated works
expressed by a process analogous to photography; a work of applied
art; an illustration, map, plan, sketch or three-dimensional work
relative to geography, topography, architecture or science; a
performance; a broadcast; a phonogram; a compilation of data to the
extent it is protected as a copyrightable work; or a work performed by
a variety or circus performer to the extent it is not otherwise
considered a literary or artistic work.
g. "You" means an individual or entity exercising rights under this
License who has not previously violated the terms of this License with
respect to the Work, or who has received express permission from the
Licensor to exercise rights under this License despite a previous
violation.
h. "Publicly Perform" means to perform public recitations of the Work and
to communicate to the public those public recitations, by any means or
process, including by wire or wireless means or public digital
performances; to make available to the public Works in such a way that
members of the public may access these Works from a place and at a
place individually chosen by them; to perform the Work to the public
by any means or process and the communication to the public of the
performances of the Work, including by public digital performance; to
broadcast and rebroadcast the Work by any means including signs,
sounds or images.
i. "Reproduce" means to make copies of the Work by any means including
without limitation by sound or visual recordings and the right of
fixation and reproducing fixations of the Work, including storage of a
protected performance or phonogram in digital form or other electronic
medium.
2. Fair Dealing Rights. Nothing in this License is intended to reduce,
limit, or restrict any uses free from copyright or rights arising from
limitations or exceptions that are provided for in connection with the
copyright protection under copyright law or other applicable laws.
3. License Grant. Subject to the terms and conditions of this License,
Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
perpetual (for the duration of the applicable copyright) license to
exercise the rights in the Work as stated below:
a. to Reproduce the Work, to incorporate the Work into one or more
Collections, and to Reproduce the Work as incorporated in the
Collections;
b. to create and Reproduce Adaptations provided that any such Adaptation,
including any translation in any medium, takes reasonable steps to
clearly label, demarcate or otherwise identify that changes were made
to the original Work. For example, a translation could be marked "The
original work was translated from English to Spanish," or a
modification could indicate "The original work has been modified.";
c. to Distribute and Publicly Perform the Work including as incorporated
in Collections; and,
d. to Distribute and Publicly Perform Adaptations.
e. For the avoidance of doubt:
i. Non-waivable Compulsory License Schemes. In those jurisdictions in
which the right to collect royalties through any statutory or
compulsory licensing scheme cannot be waived, the Licensor
reserves the exclusive right to collect such royalties for any
exercise by You of the rights granted under this License;
ii. Waivable Compulsory License Schemes. In those jurisdictions in
which the right to collect royalties through any statutory or
compulsory licensing scheme can be waived, the Licensor waives the
exclusive right to collect such royalties for any exercise by You
of the rights granted under this License; and,
iii. Voluntary License Schemes. The Licensor waives the right to
collect royalties, whether individually or, in the event that the
Licensor is a member of a collecting society that administers
voluntary licensing schemes, via that society, from any exercise
by You of the rights granted under this License.
The above rights may be exercised in all media and formats whether now
known or hereafter devised. The above rights include the right to make
such modifications as are technically necessary to exercise the rights in
other media and formats. Subject to Section 8(f), all rights not expressly
granted by Licensor are hereby reserved.
4. Restrictions. The license granted in Section 3 above is expressly made
subject to and limited by the following restrictions:
a. You may Distribute or Publicly Perform the Work only under the terms
of this License. You must include a copy of, or the Uniform Resource
Identifier (URI) for, this License with every copy of the Work You
Distribute or Publicly Perform. You may not offer or impose any terms
on the Work that restrict the terms of this License or the ability of
the recipient of the Work to exercise the rights granted to that
recipient under the terms of the License. You may not sublicense the
Work. You must keep intact all notices that refer to this License and
to the disclaimer of warranties with every copy of the Work You
Distribute or Publicly Perform. When You Distribute or Publicly
Perform the Work, You may not impose any effective technological
measures on the Work that restrict the ability of a recipient of the
Work from You to exercise the rights granted to that recipient under
the terms of the License. This Section 4(a) applies to the Work as
incorporated in a Collection, but this does not require the Collection
apart from the Work itself to be made subject to the terms of this
License. If You create a Collection, upon notice from any Licensor You
must, to the extent practicable, remove from the Collection any credit
as required by Section 4(b), as requested. If You create an
Adaptation, upon notice from any Licensor You must, to the extent
practicable, remove from the Adaptation any credit as required by
Section 4(b), as requested.
b. If You Distribute, or Publicly Perform the Work or any Adaptations or
Collections, You must, unless a request has been made pursuant to
Section 4(a), keep intact all copyright notices for the Work and
provide, reasonable to the medium or means You are utilizing: (i) the
name of the Original Author (or pseudonym, if applicable) if supplied,
and/or if the Original Author and/or Licensor designate another party
or parties (e.g., a sponsor institute, publishing entity, journal) for
attribution ("Attribution Parties") in Licensor's copyright notice,
terms of service or by other reasonable means, the name of such party
or parties; (ii) the title of the Work if supplied; (iii) to the
extent reasonably practicable, the URI, if any, that Licensor
specifies to be associated with the Work, unless such URI does not
refer to the copyright notice or licensing information for the Work;
and (iv) , consistent with Section 3(b), in the case of an Adaptation,
a credit identifying the use of the Work in the Adaptation (e.g.,
"French translation of the Work by Original Author," or "Screenplay
based on original Work by Original Author"). The credit required by
this Section 4 (b) may be implemented in any reasonable manner;
provided, however, that in the case of a Adaptation or Collection, at
a minimum such credit will appear, if a credit for all contributing
authors of the Adaptation or Collection appears, then as part of these
credits and in a manner at least as prominent as the credits for the
other contributing authors. For the avoidance of doubt, You may only
use the credit required by this Section for the purpose of attribution
in the manner set out above and, by exercising Your rights under this
License, You may not implicitly or explicitly assert or imply any
connection with, sponsorship or endorsement by the Original Author,
Licensor and/or Attribution Parties, as appropriate, of You or Your
use of the Work, without the separate, express prior written
permission of the Original Author, Licensor and/or Attribution
Parties.
c. Except as otherwise agreed in writing by the Licensor or as may be
otherwise permitted by applicable law, if You Reproduce, Distribute or
Publicly Perform the Work either by itself or as part of any
Adaptations or Collections, You must not distort, mutilate, modify or
take other derogatory action in relation to the Work which would be
prejudicial to the Original Author's honor or reputation. Licensor
agrees that in those jurisdictions (e.g. Japan), in which any exercise
of the right granted in Section 3(b) of this License (the right to
make Adaptations) would be deemed to be a distortion, mutilation,
modification or other derogatory action prejudicial to the Original
Author's honor and reputation, the Licensor will waive or not assert,
as appropriate, this Section, to the fullest extent permitted by the
applicable national law, to enable You to reasonably exercise Your
right under Section 3(b) of this License (right to make Adaptations)
but not otherwise.
5. Representations, Warranties and Disclaimer
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR
OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY
KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE,
INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY,
FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF
LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS,
WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION
OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE
LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR
ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES
ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
7. Termination
a. This License and the rights granted hereunder will terminate
automatically upon any breach by You of the terms of this License.
Individuals or entities who have received Adaptations or Collections
from You under this License, however, will not have their licenses
terminated provided such individuals or entities remain in full
compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will
survive any termination of this License.
b. Subject to the above terms and conditions, the license granted here is
perpetual (for the duration of the applicable copyright in the Work).
Notwithstanding the above, Licensor reserves the right to release the
Work under different license terms or to stop distributing the Work at
any time; provided, however that any such election will not serve to
withdraw this License (or any other license that has been, or is
required to be, granted under the terms of this License), and this
License will continue in full force and effect unless terminated as
stated above.
8. Miscellaneous
a. Each time You Distribute or Publicly Perform the Work or a Collection,
the Licensor offers to the recipient a license to the Work on the same
terms and conditions as the license granted to You under this License.
b. Each time You Distribute or Publicly Perform an Adaptation, Licensor
offers to the recipient a license to the original Work on the same
terms and conditions as the license granted to You under this License.
c. If any provision of this License is invalid or unenforceable under
applicable law, it shall not affect the validity or enforceability of
the remainder of the terms of this License, and without further action
by the parties to this agreement, such provision shall be reformed to
the minimum extent necessary to make such provision valid and
enforceable.
d. No term or provision of this License shall be deemed waived and no
breach consented to unless such waiver or consent shall be in writing
and signed by the party to be charged with such waiver or consent.
e. This License constitutes the entire agreement between the parties with
respect to the Work licensed here. There are no understandings,
agreements or representations with respect to the Work not specified
here. Licensor shall not be bound by any additional provisions that
may appear in any communication from You. This License may not be
modified without the mutual written agreement of the Licensor and You.
f. The rights granted under, and the subject matter referenced, in this
License were drafted utilizing the terminology of the Berne Convention
for the Protection of Literary and Artistic Works (as amended on
September 28, 1979), the Rome Convention of 1961, the WIPO Copyright
Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996
and the Universal Copyright Convention (as revised on July 24, 1971).
These rights and subject matter take effect in the relevant
jurisdiction in which the License terms are sought to be enforced
according to the corresponding provisions of the implementation of
those treaty provisions in the applicable national law. If the
standard suite of rights granted under applicable copyright law
includes additional rights not granted under this License, such
additional rights are deemed to be included in the License; this
License is not intended to restrict the license of any rights under
applicable law.
Creative Commons Notice
Creative Commons is not a party to this License, and makes no warranty
whatsoever in connection with the Work. Creative Commons will not be
liable to You or any party on any legal theory for any damages
whatsoever, including without limitation any general, special,
incidental or consequential damages arising in connection to this
license. Notwithstanding the foregoing two (2) sentences, if Creative
Commons has expressly identified itself as the Licensor hereunder, it
shall have all rights and obligations of Licensor.
Except for the limited purpose of indicating to the public that the
Work is licensed under the CCPL, Creative Commons does not authorize
the use by either party of the trademark "Creative Commons" or any
related trademark or logo of Creative Commons without the prior
written consent of Creative Commons. Any permitted use will be in
compliance with Creative Commons' then-current trademark usage
guidelines, as may be published on its website or otherwise made
available upon request from time to time. For the avoidance of doubt,
this trademark restriction does not form part of this License.
Creative Commons may be contacted at http://creativecommons.org/.

View File

@@ -0,0 +1,136 @@
## Documentation
### CSS Classes for Created Columns
Columnizer will add CSS classes to the columns it creates. Each column will have a "column" classname. The first column will have "first" and last column will have "last". This lets you target specific columns in your CSS markup more easily.
### Options
<table style="width: 100%; border: 1px solid #000000; margin-bottom: 25px;" border="1" cellspacing="0" cellpadding="3">
<tbody>
<tr>
<th style="width: 200px; background-color: #6690bc;" align="center" valign="middle"><span style="color: #ffffff;">Option Name</span></th>
<th style="background-color: #6690bc;" align="center" valign="middle"><span style="color: #ffffff;">Purpose</span></th>
</tr>
<tr>
<td style="text-align: right; padding-right: 10px;"><em>width</em></td>
<td style="padding-left: 10px;">a rough width your columns, and Columnizer will create as many as will fit in the browser window</td>
</tr>
<tr>
<td style="text-align: right; padding-right: 10px;"><em>height</em></td>
<td style="padding-left: 10px;">This option can only be used in conjunction with the width option. When both the width and height options are set, columns will continue to be built to those measurements to fill all of the content. This is useful for scrolling columns horizontally. See <a href="http://welcome.totheinter.net/autocolumn/sample5.html">sample 5</a> for an example.</td>
</tr>
<tr>
<td style="text-align: right; padding-right: 10px;"><em>columns</em></td>
<td style="padding-left: 10px;">an alternative to the width option. Sets a static number of columns to build, regardless of widget.</td>
</tr>
<tr>
<td style="text-align: right; padding-right: 10px;"><em>target</em></td>
<td style="padding-left: 10px;">An optional CSS selector may be used here to determine where the columnized content should be placed. If a target is specified, the columnized node will remain unchanged, and the target node will contain columnized content.</td>
</tr>
<tr>
<td style="text-align: right; padding-right: 10px;"><em>doneFunc</em></td>
<td style="padding-left: 10px;">This function will be called when columnizing is complete.</td>
</tr>
<tr>
<td style="text-align: right; padding-right: 10px;"><em>ignoreImageLoading<br>
</em></td>
<td style="padding-left: 10px;">true by default. If set to false, Columnizer will try to wait until images in the content have loaded before columnizing the data.</td>
</tr>
<tr>
<td style="text-align: right; padding-right: 10px;"><em>columnFloat</em></td>
<td style="padding-left: 10px;">default is “left”. Change to “right” for right to left languages.</td>
</tr>
<tr>
<td style="text-align: right; padding-right: 10px;"><em>lastNeverTallest<br>
</em></td>
<td style="padding-left: 10px;">false by default. Set to true to ensure that the last column of the columnized content is not the tallest column.</td>
</tr>
<tr>
<td style="text-align: right; padding-right: 10px;"><em>buildOnce</em></td>
<td style="padding-left: 10px;">if buildOnce is false, the content will be re-columnized when the window is resized. If buildOnce is true, the content will only be columnized once.</td>
</tr>
<tr>
<td style="text-align: right; padding-right: 10px;" rowspan="4" valign="top"><em>overflow</em></td>
<td style="padding-left: 10px;">If this option is used, then a static height is set to the columnized content, and any content that does not fit within the height is put into the element specified by $(id). See <a href="http://welcome.totheinter.net/autocolumn/sample1.html">demo 1</a> for an example.</td>
</tr>
<tr>
<td style="padding-left: 10px;"><em>height</em> (required): the static height for the columnized content</td>
</tr>
<tr>
<td style="padding-left: 10px;"><em>id</em> (required): The id of the element to put the remainder of the content</td>
</tr>
<tr>
<td style="padding-left: 10px;"><em>doneFunc</em> (optional): a function to be called after the content has been columnized. This is a great place to columnize the remainder content.</td>
</tr>
<tr>
<td style="text-align: right; padding-right: 10px;"><em>manualBreaks</em></td>
<td style="padding-left: 10px;">Defaults to false. Set to true if you only want to create columns with manual column breaks. If true, then width, height, columns options are ignored.</td>
</tr>
</tbody>
</table>
### CSS Classes
<table style="width: 100%; border: 1px solid #000000; margin-bottom: 25px;" border="1" cellspacing="0" cellpadding="3">
<tbody>
<tr>
<th style="width: 200px; background-color: #6690bc;" align="center" valign="middle"><span style="color: #ffffff;">Class Name</span></th>
<th style="background-color: #6690bc;" align="center" valign="middle"><span style="color: #ffffff;">Purpose</span></th>
</tr>
<tr>
<td style="text-align: right; padding-right: 10px;"><em>columnbreak</em></td>
<td style="padding-left: 10px;">Any node that has the CSS class “columnbreak” will act as a column break, as you'd expect in any word processor. The "columnbreak" node will always be the last node in its column. Works well with the optional "columnBreak" option.</td>
</tr>
<tr>
<td style="text-align: right; padding-right: 10px;"><em>dontsplit</em></td>
<td style="padding-left: 10px;">Any node that has the CSS class “dontsplit” wont be split into multiple columns. This is handy to make sure that tables, etc, arent chopped in half if they land at the bottom of a column.</td>
</tr>
<tr>
<td style="text-align: right; padding-right: 10px;"><em>dontend</em></td>
<td style="padding-left: 10px;">Any node that has the CSS class “dontend” will never be put at the end of a column.</td>
</tr>
<tr>
<td style="text-align: right; padding-right: 10px;"><em>removeiffirst</em></td>
<td style="padding-left: 10px;">Any node that has the CSS class “removeiffirst” will be removed from the content if it is the first node in a column.</td>
</tr>
<tr>
<td style="text-align: right; padding-right: 10px;"><em>removeiflast</em></td>
<td style="padding-left: 10px;">Any node that has the CSS class “removeiflast” will be removed from the content if it is the last node in a column.</td>
</tr>
</table>
### Helpful Hints
1. You can specify a rough width your columns, and Columnizer will create as many as will fit in the browser window. Just use: $(selector).columnize({width: 400 }) syntax
2. You can specify a specific number of columns, and Columnizer will distribute your content between that many columns. Just use: $(selector).columnize({columns: 2 }) syntax
3. When using the width and height options to scroll horizontally, make sure that the .column CSS class does not specify any padding or margin or border. See CSS for sample 5 for an example on how to create buffer between columns.
4. Make sure that you are columnizing visible content. If your content is display:none it may not columnize correctly. Try visibility:hidden and display:block instead.
5. Columnizer does not auto-class any of your content. See the Suggested Defaults For Your Content section.
### Suggested Defaults For Your Content
Columnizer does not add default "dontsplit" or "dontend" classes to your content. If you are finding your content is breaking columns at awkward locations, try the following:
$yourContent.find('table, thead, tbody, tfoot, colgroup, caption, label, legend, script, style, textarea, button, object, embed, tr, th, td, li, h1, h2, h3, h4, h5, h6, form').addClass('dontsplit');
$yourContent.find('h1, h2, h3, h4, h5, h6').addClass('dontend');
$yourContent.find('br').addClass('removeiflast').addClass('removeiffirst');
## Troubleshooting
### Why isn't my content columnizing?
Make sure that your content "has display". If the content you're columnizing has display:none, then the browser has difficulty estimating the size of some nodes, which makes columnizing impossible. instead of display:none, use visibility:hidden and keep display:block. then in the doneFunc() of columnizer, change the visibility and display to whatever your page or application needs.
## Additional Notes
### Minimize
To compress into a zip file, run compress.sh
### Bug report?
Check the issues on the [GitHub page](https://github.com/adamwulf/Columnizer-jQuery-Plugin/issues)

View File

@@ -0,0 +1,19 @@
{
"name": "jquery.columnizer",
"version": "1.6.2",
"description": "Automatically layout your content in newspaper column format. Specify column width or a static number of columns.",
"main": "src/jquery.columnizer.js",
"author": "Adam Wulf",
"ignore": [
"samples",
"tools",
"src/jquery.js",
"compress.sh"
],
"dependencies": {
"jquery": ">= 1.10.0"
},
"keywords": [
"jquery, layout, column"
]
}

View File

@@ -0,0 +1,3 @@
rm src/jquery.columnizer.min.js
php tools/compress.php
echo "wrote src/jquery.columnizer.min.js"

View File

@@ -0,0 +1,889 @@
// version 1.6.2
// http://welcome.totheinter.net/columnizer-jquery-plugin/
// created by: Adam Wulf @adamwulf, adam.wulf@gmail.com
(function($){
$.fn.columnize = function(options) {
this.cols =[];
this.offset= 0;
this.before=[];
this.lastOther=0;
this.prevMax =0;
this.debug=0;
this.setColumnStart =null;
this.elipsisText='';
var defaults = {
// default width of columns
width: 400,
// optional # of columns instead of width
columns : false,
// true to build columns once regardless of window resize
// false to rebuild when content box changes bounds
buildOnce : false,
// an object with options if the text should overflow
// it's container if it can't fit within a specified height
overflow : false,
// this function is called after content is columnized
doneFunc : function(){},
// if the content should be columnized into a
// container node other than it's own node
target : false,
// re-columnizing when images reload might make things
// run slow. so flip this to true if it's causing delays
ignoreImageLoading : true,
// should columns float left or right
columnFloat : "left",
// ensure the last column is never the tallest column
lastNeverTallest : false,
// (int) the minimum number of characters to jump when splitting
// text nodes. smaller numbers will result in higher accuracy
// column widths, but will take slightly longer
accuracy : false,
// false to round down column widths (for compatibility)
// true to conserve all decimals in the column widths
precise : false,
// don't automatically layout columns, only use manual columnbreak
manualBreaks : false,
// previx for all the CSS classes used by this plugin
// default to empty string for backwards compatibility
cssClassPrefix : "",
elipsisText:'...',
debug:0
};
options = $.extend(defaults, options);
if(typeof(options.width) == "string"){
options.width = parseInt(options.width,10);
if(isNaN(options.width)){
options.width = defaults.width;
}
}
if(typeof options.setColumnStart== 'function') {
this.setColumnStart=options.setColumnStart;
}
if(typeof options.elipsisText== 'string') {
this.elipsisText=options.elipsisText;
}
if(options.debug) { // assert is off by default
this.debug=options.debug;
}
if(!options.setWidth) {
if (options.precise) {
options.setWidth = function (numCols) {
return 100 / numCols;
};
} else {
options.setWidth = function (numCols) {
return Math.floor(100 / numCols);
};
}
}
/**
* appending a text node to a <table> will
* cause a jquery crash.
* so wrap all append() calls and revert to
* a simple appendChild() in case it fails
*/
function appendSafe($target, $elem){
try{
$target.append($elem);
}catch(e){
$target[0].appendChild($elem[0]);
}
}
return this.each(function() {
var $inBox = options.target ? $(options.target) : $(this);
var maxHeight = $(this).height();
var $cache = $('<div></div>'); // this is where we'll put the real content
var lastWidth = 0;
var columnizing = false;
var manualBreaks = options.manualBreaks;
var cssClassPrefix = defaults.cssClassPrefix;
if(typeof(options.cssClassPrefix) == "string"){
cssClassPrefix = options.cssClassPrefix;
}
var adjustment = 0;
appendSafe($cache, $(this).contents().clone(true));
// images loading after dom load
// can screw up the column heights,
// so recolumnize after images load
if(!options.ignoreImageLoading && !options.target){
if(!$inBox.data("imageLoaded")){
$inBox.data("imageLoaded", true);
if($(this).find("img").length > 0){
// only bother if there are
// actually images...
var func = function($inBox,$cache){ return function(){
if(!$inBox.data("firstImageLoaded")){
$inBox.data("firstImageLoaded", "true");
appendSafe($inBox.empty(), $cache.children().clone(true));
$inBox.columnize(options);
}
};
}($(this), $cache);
$(this).find("img").one("load", func);
$(this).find("img").one("abort", func);
return;
}
}
}
$inBox.empty();
columnizeIt();
if(!options.buildOnce){
$(window).resize(function() {
if(!options.buildOnce){
if($inBox.data("timeout")){
clearTimeout($inBox.data("timeout"));
}
$inBox.data("timeout", setTimeout(columnizeIt, 200));
}
});
}
function prefixTheClassName(className, withDot){
var dot = withDot ? "." : "";
if(cssClassPrefix.length){
return dot + cssClassPrefix + "-" + className;
}
return dot + className;
}
/**
* this fuction builds as much of a column as it can without
* splitting nodes in half. If the last node in the new column
* is a text node, then it will try to split that text node. otherwise
* it will leave the node in $pullOutHere and return with a height
* smaller than targetHeight.
*
* Returns a boolean on whether we did some splitting successfully at a text point
* (so we know we don't need to split a real element). return false if the caller should
* split a node if possible to end this column.
*
* @param putInHere, the jquery node to put elements into for the current column
* @param $pullOutHere, the jquery node to pull elements out of (uncolumnized html)
* @param $parentColumn, the jquery node for the currently column that's being added to
* @param targetHeight, the ideal height for the column, get as close as we can to this height
*/
function columnize($putInHere, $pullOutHere, $parentColumn, targetHeight){
//
// add as many nodes to the column as we can,
// but stop once our height is too tall
while((manualBreaks || $parentColumn.height() < targetHeight) &&
$pullOutHere[0].childNodes.length){
var node = $pullOutHere[0].childNodes[0];
//
// Because we're not cloning, jquery will actually move the element"
// http://welcome.totheinter.net/2009/03/19/the-undocumented-life-of-jquerys-append/
if($(node).find(prefixTheClassName("columnbreak", true)).length){
//
// our column is on a column break, so just end here
return;
}
if($(node).hasClass(prefixTheClassName("columnbreak"))){
//
// our column is on a column break, so just end here
return;
}
appendSafe($putInHere, $(node));
}
if($putInHere[0].childNodes.length === 0) return;
// now we're too tall, so undo the last one
var kids = $putInHere[0].childNodes;
var lastKid = kids[kids.length-1];
$putInHere[0].removeChild(lastKid);
var $item = $(lastKid);
// now lets try to split that last node
// to fit as much of it as we can into this column
if($item[0].nodeType == 3){
// it's a text node, split it up
var oText = $item[0].nodeValue;
var counter2 = options.width / 18;
if(options.accuracy)
counter2 = options.accuracy;
var columnText;
var latestTextNode = null;
while($parentColumn.height() < targetHeight && oText.length){
//
// it's been brought up that this won't work for chinese
// or other languages that don't have the same use of whitespace
// as english. This will need to be updated in the future
// to better handle non-english languages.
//
// https://github.com/adamwulf/Columnizer-jQuery-Plugin/issues/124
var indexOfSpace = oText.indexOf(' ', counter2);
if (indexOfSpace != -1) {
columnText = oText.substring(0, indexOfSpace);
} else {
columnText = oText;
}
latestTextNode = document.createTextNode(columnText);
appendSafe($putInHere, $(latestTextNode));
if(oText.length > counter2 && indexOfSpace != -1){
oText = oText.substring(indexOfSpace);
}else{
oText = "";
}
}
if($parentColumn.height() >= targetHeight && latestTextNode !== null){
// too tall :(
$putInHere[0].removeChild(latestTextNode);
oText = latestTextNode.nodeValue + oText;
}
if(oText.length){
$item[0].nodeValue = oText;
}else{
return false; // we ate the whole text node, move on to the next node
}
}
if($pullOutHere.contents().length){
$pullOutHere.prepend($item);
}else{
appendSafe($pullOutHere, $item);
}
return $item[0].nodeType == 3;
}
/**
* Split up an element, which is more complex than splitting text. We need to create
* two copies of the element with it's contents divided between each
*/
function split($putInHere, $pullOutHere, $parentColumn, targetHeight){
if($putInHere.contents(":last").find(prefixTheClassName("columnbreak", true)).length){
//
// our column is on a column break, so just end here
return;
}
if($putInHere.contents(":last").hasClass(prefixTheClassName("columnbreak"))){
//
// our column is on a column break, so just end here
return;
}
if($pullOutHere.contents().length){
var $cloneMe = $pullOutHere.contents(":first");
//
// make sure we're splitting an element
if( typeof $cloneMe.get(0) == 'undefined' || $cloneMe.get(0).nodeType != 1 ) return;
//
// clone the node with all data and events
var $clone = $cloneMe.clone(true);
//
// need to support both .prop and .attr if .prop doesn't exist.
// this is for backwards compatibility with older versions of jquery.
if($cloneMe.hasClass(prefixTheClassName("columnbreak"))){
//
// ok, we have a columnbreak, so add it into
// the column and exit
appendSafe($putInHere, $clone);
$cloneMe.remove();
}else if (manualBreaks){
// keep adding until we hit a manual break
appendSafe($putInHere, $clone);
$cloneMe.remove();
}else if($clone.get(0).nodeType == 1 && !$clone.hasClass(prefixTheClassName("dontend"))){
appendSafe($putInHere, $clone);
if($clone.is("img") && $parentColumn.height() < targetHeight + 20){
//
// we can't split an img in half, so just add it
// to the column and remove it from the pullOutHere section
$cloneMe.remove();
}else if($cloneMe.hasClass(prefixTheClassName("dontsplit")) && $parentColumn.height() < targetHeight + 20){
//
// pretty close fit, and we're not allowed to split it, so just
// add it to the column, remove from pullOutHere, and be done
$cloneMe.remove();
}else if($clone.is("img") || $cloneMe.hasClass(prefixTheClassName("dontsplit"))){
//
// it's either an image that's too tall, or an unsplittable node
// that's too tall. leave it in the pullOutHere and we'll add it to the
// next column
$clone.remove();
}else{
//
// ok, we're allowed to split the node in half, so empty out
// the node in the column we're building, and start splitting
// it in half, leaving some of it in pullOutHere
$clone.empty();
if(!columnize($clone, $cloneMe, $parentColumn, targetHeight)){
// this node may still have non-text nodes to split
// add the split class and then recur
$cloneMe.addClass(prefixTheClassName("split"));
//if this node was ol element, the child should continue the number ordering
if($cloneMe.get(0).tagName == 'OL'){
var startWith = $clone.get(0).childElementCount + $clone.get(0).start;
$cloneMe.attr('start',startWith+1);
}
if($cloneMe.children().length){
split($clone, $cloneMe, $parentColumn, targetHeight);
}
}else{
// this node only has text node children left, add the
// split class and move on.
$cloneMe.addClass(prefixTheClassName("split"));
}
if($clone.get(0).childNodes.length === 0){
// it was split, but nothing is in it :(
$clone.remove();
$cloneMe.removeClass(prefixTheClassName("split"));
}else if($clone.get(0).childNodes.length == 1){
// was the only child node a text node w/ whitespace?
var onlyNode = $clone.get(0).childNodes[0];
if(onlyNode.nodeType == 3){
// text node
var whitespace = /\s/;
var str = onlyNode.nodeValue;
if(whitespace.test(str)){
// yep, only a whitespace textnode
$clone.remove();
$cloneMe.removeClass(prefixTheClassName("split"));
}
}
}
}
}
}
}
function singleColumnizeIt() {
if ($inBox.data("columnized") && $inBox.children().length == 1) {
return;
}
$inBox.data("columnized", true);
$inBox.data("columnizing", true);
$inBox.empty();
$inBox.append($("<div class='"
+ prefixTheClassName("first") + " "
+ prefixTheClassName("last") + " "
+ prefixTheClassName("column") + " "
+ "' style='width:100%; float: " + options.columnFloat + ";'></div>")); //"
$col = $inBox.children().eq($inBox.children().length-1);
$destroyable = $cache.clone(true);
if(options.overflow){
targetHeight = options.overflow.height;
columnize($col, $destroyable, $col, targetHeight);
// make sure that the last item in the column isn't a "dontend"
if(!$destroyable.contents().find(":first-child").hasClass(prefixTheClassName("dontend"))){
split($col, $destroyable, $col, targetHeight);
}
while($col.contents(":last").length && checkDontEndColumn($col.contents(":last").get(0))){
var $lastKid = $col.contents(":last");
$lastKid.remove();
$destroyable.prepend($lastKid);
}
var html = "";
var div = document.createElement('DIV');
while($destroyable[0].childNodes.length > 0){
var kid = $destroyable[0].childNodes[0];
if(kid.attributes){
for(var i=0;i<kid.attributes.length;i++){
if(kid.attributes[i].nodeName.indexOf("jQuery") === 0){
kid.removeAttribute(kid.attributes[i].nodeName);
}
}
}
div.innerHTML = "";
div.appendChild($destroyable[0].childNodes[0]);
html += div.innerHTML;
}
var overflow = $(options.overflow.id)[0];
overflow.innerHTML = html;
}else{
appendSafe($col, $destroyable.contents());
}
$inBox.data("columnizing", false);
if(options.overflow && options.overflow.doneFunc){
options.overflow.doneFunc();
}
options.doneFunc();
}
/**
* returns true if the input dom node
* should not end a column.
* returns false otherwise
*/
function checkDontEndColumn(dom){
if(dom.nodeType == 3){
// text node. ensure that the text
// is not 100% whitespace
if(/^\s+$/.test(dom.nodeValue)){
//
// ok, it's 100% whitespace,
// so we should return checkDontEndColumn
// of the inputs previousSibling
if(!dom.previousSibling) return false;
return checkDontEndColumn(dom.previousSibling);
}
return false;
}
if(dom.nodeType != 1) return false;
if($(dom).hasClass(prefixTheClassName("dontend"))) return true;
if(dom.childNodes.length === 0) return false;
return checkDontEndColumn(dom.childNodes[dom.childNodes.length-1]);
}
function columnizeIt() {
//reset adjustment var
adjustment = 0;
if(lastWidth == $inBox.width()) return;
lastWidth = $inBox.width();
var numCols = Math.round($inBox.width() / options.width);
var optionWidth = options.width;
var optionHeight = options.height;
if(options.columns) numCols = options.columns;
if(manualBreaks){
numCols = $cache.find(prefixTheClassName("columnbreak", true)).length + 1;
optionWidth = false;
}
// if ($inBox.data("columnized") && numCols == $inBox.children().length) {
// return;
// }
if(numCols <= 1){
return singleColumnizeIt();
}
if($inBox.data("columnizing")) return;
$inBox.data("columnized", true);
$inBox.data("columnizing", true);
$inBox.empty();
$inBox.append($("<div style='width:" + options.setWidth(numCols) + "%; float: " + options.columnFloat + ";'></div>")); //"
$col = $inBox.children(":last");
appendSafe($col, $cache.clone());
maxHeight = $col.height();
$inBox.empty();
var targetHeight = maxHeight / numCols;
var firstTime = true;
var maxLoops = 3;
var scrollHorizontally = false;
if(options.overflow){
maxLoops = 1;
targetHeight = options.overflow.height;
}else if(optionHeight && optionWidth){
maxLoops = 1;
targetHeight = optionHeight;
scrollHorizontally = true;
}
//
// We loop as we try and workout a good height to use. We know it initially as an average
// but if the last column is higher than the first ones (which can happen, depending on split
// points) we need to raise 'adjustment'. We try this over a few iterations until we're 'solid'.
//
// also, lets hard code the max loops to 20. that's /a lot/ of loops for columnizer,
// and should keep run aways in check. if somehow someone has content combined with
// options that would cause an infinite loop, then this'll definitely stop it.
for(var loopCount=0;loopCount<maxLoops && loopCount<20;loopCount++){
$inBox.empty();
var $destroyable, className, $col, $lastKid;
try{
$destroyable = $cache.clone(true);
}catch(e){
// jquery in ie6 can't clone with true
$destroyable = $cache.clone();
}
$destroyable.css("visibility", "hidden");
// create the columns
for (var i = 0; i < numCols; i++) {
/* create column */
className = (i === 0) ? prefixTheClassName("first") : "";
className += " " + prefixTheClassName("column");
className = (i == numCols - 1) ? (prefixTheClassName("last") + " " + className) : className;
$inBox.append($("<div class='" + className + "' style='width:" + options.setWidth(numCols) + "%; float: " + options.columnFloat + ";'></div>")); //"
}
// fill all but the last column (unless overflowing)
i = 0;
while(i < numCols - (options.overflow ? 0 : 1) || scrollHorizontally && $destroyable.contents().length){
if($inBox.children().length <= i){
// we ran out of columns, make another
$inBox.append($("<div class='" + className + "' style='width:" + options.setWidth(numCols) + "%; float: " + options.columnFloat + ";'></div>")); //"
}
$col = $inBox.children().eq(i);
if(scrollHorizontally){
$col.width(optionWidth + "px");
}
columnize($col, $destroyable, $col, targetHeight);
// make sure that the last item in the column isn't a "dontend"
split($col, $destroyable, $col, targetHeight);
while($col.contents(":last").length && checkDontEndColumn($col.contents(":last").get(0))){
$lastKid = $col.contents(":last");
$lastKid.remove();
$destroyable.prepend($lastKid);
}
i++;
//
// https://github.com/adamwulf/Columnizer-jQuery-Plugin/issues/47
//
// check for infinite loop.
//
// this could happen when a dontsplit or dontend item is taller than the column
// we're trying to build, and its never actually added to a column.
//
// this results in empty columns being added with the dontsplit item
// perpetually waiting to get put into a column. lets force the issue here
if($col.contents().length === 0 && $destroyable.contents().length){
//
// ok, we're building zero content columns. this'll happen forever
// since nothing can ever get taken out of destroyable.
//
// to fix, lets put 1 item from destroyable into the empty column
// before we iterate
$col.append($destroyable.contents(":first"));
}else if(i == numCols - (options.overflow ? 0 : 1) && !options.overflow){
//
// ok, we're about to exit the while loop because we're done with all
// columns except the last column.
//
// if $destroyable still has columnbreak nodes in it, then we need to keep
// looping and creating more columns.
if($destroyable.find(prefixTheClassName("columnbreak", true)).length){
numCols ++;
}
}
}
if(options.overflow && !scrollHorizontally){
var IE6 = false;
/*@cc_on
@if (@_jscript_version < 5.7)
IE6 = true;
@end
@*/
var IE7 = (document.all) && (navigator.appVersion.indexOf("MSIE 7.") != -1);
if(IE6 || IE7){
var html = "";
var div = document.createElement('DIV');
while($destroyable[0].childNodes.length > 0){
var kid = $destroyable[0].childNodes[0];
for(i=0;i<kid.attributes.length;i++){
if(kid.attributes[i].nodeName.indexOf("jQuery") === 0){
kid.removeAttribute(kid.attributes[i].nodeName);
}
}
div.innerHTML = "";
div.appendChild($destroyable[0].childNodes[0]);
html += div.innerHTML;
}
var overflow = $(options.overflow.id)[0];
overflow.innerHTML = html;
}else{
$(options.overflow.id).empty().append($destroyable.contents().clone(true));
}
}else if(!scrollHorizontally){
// the last column in the series
$col = $inBox.children().eq($inBox.children().length-1);
$destroyable.contents().each( function() {
$col.append( $(this) );
});
var afterH = $col.height();
var diff = afterH - targetHeight;
var totalH = 0;
var min = 10000000;
var max = 0;
var lastIsMax = false;
var numberOfColumnsThatDontEndInAColumnBreak = 0;
$inBox.children().each(function($inBox){ return function($item){
var $col = $inBox.children().eq($item);
var endsInBreak = $col.children(":last").find(prefixTheClassName("columnbreak", true)).length;
if(!endsInBreak){
var h = $col.height();
lastIsMax = false;
totalH += h;
if(h > max) {
max = h;
lastIsMax = true;
}
if(h < min) min = h;
numberOfColumnsThatDontEndInAColumnBreak++;
}
};
}($inBox));
var avgH = totalH / numberOfColumnsThatDontEndInAColumnBreak;
if(totalH === 0){
//
// all columns end in a column break,
// so we're done here
loopCount = maxLoops;
}else if(options.lastNeverTallest && lastIsMax){
// the last column is the tallest
// so allow columns to be taller
// and retry
//
// hopefully this'll mean more content fits into
// earlier columns, so that the last column
// can be shorter than the rest
adjustment += 5;
targetHeight = targetHeight + 30;
if(loopCount == maxLoops-1) maxLoops++;
}else if(max - min > 30){
// too much variation, try again
targetHeight = avgH + 30;
}else if(Math.abs(avgH-targetHeight) > 20){
// too much variation, try again
targetHeight = avgH;
}else {
// solid, we're done
loopCount = maxLoops;
}
}else{
// it's scrolling horizontally, fix the width/classes of the columns
$inBox.children().each(function(i){
$col = $inBox.children().eq(i);
$col.width(optionWidth + "px");
if(i === 0){
$col.addClass(prefixTheClassName("first"));
}else if(i==$inBox.children().length-1){
$col.addClass(prefixTheClassName("last"));
}else{
$col.removeClass(prefixTheClassName("first"));
$col.removeClass(prefixTheClassName("last"));
}
});
$inBox.width($inBox.children().length * optionWidth + "px");
}
$inBox.append($("<br style='clear:both;'>"));
}
$inBox.find(prefixTheClassName("column", true)).find(":first" + prefixTheClassName("removeiffirst", true)).remove();
$inBox.find(prefixTheClassName("column", true)).find(':last' + prefixTheClassName("removeiflast", true)).remove();
$inBox.find(prefixTheClassName("split", true)).find(":first" + prefixTheClassName("removeiffirst", true)).remove();
$inBox.find(prefixTheClassName("split", true)).find(':last' + prefixTheClassName("removeiflast", true)).remove();
$inBox.data("columnizing", false);
if(options.overflow){
options.overflow.doneFunc();
}
options.doneFunc();
}
});
};
$.fn.renumberByJS=function($searchTag, $colno, $targetId, $targetClass ) {
this.setList = function($cols, $list, $tag1) {
var $parents = this.before.parents();
var $rest;
$rest = $($cols[this.offset-1]).find('>*');
if( ($rest.last())[0].tagName!=$tag1.toUpperCase()) {
if(this.debug) {
console.log("Last item in previous column, isn't a list...");
}
return 0;
}
$rest = $rest.length;
var $tint = 1;
if(this.lastOther<=0) {
$tint = this.before.children().length+1;
} else {
$tint = $($parents[this.lastOther]).children().length+1;
}
// if the first LI in the current column is split, decrement, as we want the same number/key
if( $($cols[this.offset]).find($tag1+':first li.split').length ) {
var $whereElipsis=$($cols[this.offset-1]).find($tag1+':last li:last');
if( this.elipsisText==='' ||
$($cols[this.offset-1]).find($tag1+':last ~ div').length ||
$($cols[this.offset-1]).find($tag1+':last ~ p').length ) {
;
} else {
if($($whereElipsis).find('ul, ol, dl').length ==0 ) {
var $txt=$whereElipsis.last().text();
// char counting, 'cus MSIE 8 is appearently stupid
var $len=$txt.length;
if($txt.substring($len-1)==';') {
if($txt.substring($len-4)!=this.elipsisText+';') {
$txt=$txt.substring(0, $len-1)+this.elipsisText+';';
}
} else {
if($txt.substring($len-3)!=this.elipsisText) {
$txt+=this.elipsisText;
}
}
$whereElipsis.last().text($txt);
}
}
// an item in split between two columns. it only holds one key...
if($($cols[this.offset]).find($tag1+':first >li.split >'+$tag1).length==0) {
$tint--;
}
}
if($rest==1) {
// the last column only held one thing, so assume its wrapped to the column before that as well.
$tint += this.prevMax ;
}
if(this.nest>1) {
if(this.debug) {
console.log("Supposed to be a nested list...decr");
}
$tint--;
// some how, id previous list starts split, need secins decrement,
// if "split" is now correct, reference this
var $tt = $($cols[this.offset -1]).find($tag1+':first li.split:first');
if($tt.length>0) {
if(this.debug) {
console.log("Previous column started with a split item, so that count is one less than expected");
}
$tint--;
}
$tt = $($cols[this.offset]).find($tag1+':first li:first').clone();
$tt.children().remove();
if( $.trim($tt.text()).length>0 ){
if(this.debug) {
console.log("If that was a complete list in the previous column, don't decr.");
}
$tint++;
if($($cols[this.offset-1]).find(">"+$tag1+':last ').children().length==0 ) {
if(this.debug) {
console.log("unless that was empty, in which case revert");
}
$tint--;
}
}
} else {
var $tt = $($cols[this.offset]).find($tag1+':first li:first '+$tag1+".split li.split");
if($tt.length>0) {
if(this.debug) {
console.log("[Nested] Column started with a split item, so that count is one less than expected");
}
$tint--;
}
}
if(this.debug) {
console.log("Setting the start value to "+$tint+" ("+this.prevMax +")");
}
if($tint >0) {
// if the above computation leads to 0, or an empty list (more likely), don't set, leave as 1
if(typeof this.setColumnStart == 'function') {
this.setColumnStart($list, $tint);
} else {
$list.attr('start', $tint);
}
}
return 0;
}
if(typeof $targetId === 'undefined') { $targetId=false; }
if(typeof $targetClass === 'undefined') { $targetClass=false; }
if(! $targetId && !$targetClass ) {
throw "renumberByJS(): Bad param, must pass an id or a class";
}
var $target ='';
this.prevMax =1;
if($targetClass) {
$target ="."+$targetClass;
} else {
$target ="#"+$targetId;
}
var $tag1 = $searchTag.toLowerCase();
var $tag2 = $searchTag.toUpperCase();
this.cols = $($target);
if(this.debug) {
console.log("There are "+this.cols.length+" items, looking for "+$tag1);
}
this.before = $(this.cols[0]).find($tag1+':last');
this.prevMax = this.before.children().length;
// start at 1, as must compare to previous...
for(this.offset=1; this.offset<this.cols.length; this.offset++) {
if(this.debug) {
console.log("iterating "+this.offset+"...[of "+this.cols.length+"]");
}
// if the first column again, nothing to the left of you, do nothing...
if(this.offset % $colno==0) {
if(this.debug) {
console.log("First column (in theory..)");
}
this.prevMax = 1;
continue;
}
this.before = $(this.cols[this.offset-1]).find($tag1+':last');
// if there are no occurences of the searchTag, do nothing
if(this.before.length) {
if(this.debug) {
console.log("Have some "+$searchTag+" elements in the previous column");
}
var $list = $(this.cols[this.offset]).find($tag1+':first');
var $first = $(this.cols[this.offset]).find('*:first');
if($first[0] !== $list[0]) {
// don't renumber anything, its not a rollover list
continue;
}
var $parents = this.before.parents();
this.lastOther = 0;
var $found = false;
for(; this.lastOther<$parents.length; this.lastOther++) {
if($parents[this.lastOther].tagName != $tag2 && $parents[this.lastOther].tagName != "LI") {
$found = true;
this.lastOther--;
break;
}
}
this.nest =1;
if($(this.cols[this.offset]).find(">"+$tag1+':first li '+$tag1+":first").length) {
this.nest = 2;
}
this.setList(this.cols, $list, $tag1);
this.lastOther--;
$list = $(this.cols[this.offset]).find($tag1+':first li '+$tag1+":first");
if($list.length) {
// I hope the two columns have same nesting, or its busted
this.before= $(this.cols[this.offset-1]).find(">"+$tag1+':last li '+$tag1+":last");
this.prevMax= 0;
this.nest =1;
this.setList(this.cols, $list, $tag1);
}
var $reset = $(this.cols[this.offset-1]).find(">"+$tag1+':last');
this.prevMax = $reset.children().length;
}
}
return 0;
};
})(jQuery);

View File

@@ -0,0 +1,90 @@
(function($){$.fn.columnize=function(options){this.cols=[];this.offset=0;this.before=[];this.lastOther=0;this.prevMax=0;this.debug=0;this.setColumnStart=null;this.elipsisText='';var defaults={width:400,columns:false,buildOnce:false,overflow:false,doneFunc:function(){},target:false,ignoreImageLoading:true,columnFloat:"left",lastNeverTallest:false,accuracy:false,precise:false,manualBreaks:false,cssClassPrefix:"",elipsisText:'...',debug:0};options=$.extend(defaults,options);if(typeof(options.width)=="string"){options.width=parseInt(options.width,10);if(isNaN(options.width)){options.width=defaults.width;}}
if(typeof options.setColumnStart=='function'){this.setColumnStart=options.setColumnStart;}
if(typeof options.elipsisText=='string'){this.elipsisText=options.elipsisText;}
if(options.debug){this.debug=options.debug;}
if(!options.setWidth){if(options.precise){options.setWidth=function(numCols){return 100/numCols;};}else{options.setWidth=function(numCols){return Math.floor(100/numCols);};}}
function appendSafe($target,$elem){try{$target.append($elem);}catch(e){$target[0].appendChild($elem[0]);}}
return this.each(function(){var $inBox=options.target?$(options.target):$(this);var maxHeight=$(this).height();var $cache=$('<div></div>');var lastWidth=0;var columnizing=false;var manualBreaks=options.manualBreaks;var cssClassPrefix=defaults.cssClassPrefix;if(typeof(options.cssClassPrefix)=="string"){cssClassPrefix=options.cssClassPrefix;}
var adjustment=0;appendSafe($cache,$(this).contents().clone(true));if(!options.ignoreImageLoading&&!options.target){if(!$inBox.data("imageLoaded")){$inBox.data("imageLoaded",true);if($(this).find("img").length>0){var func=function($inBox,$cache){return function(){if(!$inBox.data("firstImageLoaded")){$inBox.data("firstImageLoaded","true");appendSafe($inBox.empty(),$cache.children().clone(true));$inBox.columnize(options);}};}($(this),$cache);$(this).find("img").one("load",func);$(this).find("img").one("abort",func);return;}}}
$inBox.empty();columnizeIt();if(!options.buildOnce){$(window).resize(function(){if(!options.buildOnce){if($inBox.data("timeout")){clearTimeout($inBox.data("timeout"));}
$inBox.data("timeout",setTimeout(columnizeIt,200));}});}
function prefixTheClassName(className,withDot){var dot=withDot?".":"";if(cssClassPrefix.length){return dot+cssClassPrefix+"-"+className;}
return dot+className;}
function columnize($putInHere,$pullOutHere,$parentColumn,targetHeight){while((manualBreaks||$parentColumn.height()<targetHeight)&&$pullOutHere[0].childNodes.length){var node=$pullOutHere[0].childNodes[0];if($(node).find(prefixTheClassName("columnbreak",true)).length){return;}
if($(node).hasClass(prefixTheClassName("columnbreak"))){return;}
appendSafe($putInHere,$(node));}
if($putInHere[0].childNodes.length===0)return;var kids=$putInHere[0].childNodes;var lastKid=kids[kids.length-1];$putInHere[0].removeChild(lastKid);var $item=$(lastKid);if($item[0].nodeType==3){var oText=$item[0].nodeValue;var counter2=options.width/18;if(options.accuracy)
counter2=options.accuracy;var columnText;var latestTextNode=null;while($parentColumn.height()<targetHeight&&oText.length){var indexOfSpace=oText.indexOf(' ',counter2);if(indexOfSpace!=-1){columnText=oText.substring(0,indexOfSpace);}else{columnText=oText;}
latestTextNode=document.createTextNode(columnText);appendSafe($putInHere,$(latestTextNode));if(oText.length>counter2&&indexOfSpace!=-1){oText=oText.substring(indexOfSpace);}else{oText="";}}
if($parentColumn.height()>=targetHeight&&latestTextNode!==null){$putInHere[0].removeChild(latestTextNode);oText=latestTextNode.nodeValue+oText;}
if(oText.length){$item[0].nodeValue=oText;}else{return false;}}
if($pullOutHere.contents().length){$pullOutHere.prepend($item);}else{appendSafe($pullOutHere,$item);}
return $item[0].nodeType==3;}
function split($putInHere,$pullOutHere,$parentColumn,targetHeight){if($putInHere.contents(":last").find(prefixTheClassName("columnbreak",true)).length){return;}
if($putInHere.contents(":last").hasClass(prefixTheClassName("columnbreak"))){return;}
if($pullOutHere.contents().length){var $cloneMe=$pullOutHere.contents(":first");if(typeof $cloneMe.get(0)=='undefined'||$cloneMe.get(0).nodeType!=1)return;var $clone=$cloneMe.clone(true);if($cloneMe.hasClass(prefixTheClassName("columnbreak"))){appendSafe($putInHere,$clone);$cloneMe.remove();}else if(manualBreaks){appendSafe($putInHere,$clone);$cloneMe.remove();}else if($clone.get(0).nodeType==1&&!$clone.hasClass(prefixTheClassName("dontend"))){appendSafe($putInHere,$clone);if($clone.is("img")&&$parentColumn.height()<targetHeight+20){$cloneMe.remove();}else if($cloneMe.hasClass(prefixTheClassName("dontsplit"))&&$parentColumn.height()<targetHeight+20){$cloneMe.remove();}else if($clone.is("img")||$cloneMe.hasClass(prefixTheClassName("dontsplit"))){$clone.remove();}else{$clone.empty();if(!columnize($clone,$cloneMe,$parentColumn,targetHeight)){$cloneMe.addClass(prefixTheClassName("split"));if($cloneMe.get(0).tagName=='OL'){var startWith=$clone.get(0).childElementCount+$clone.get(0).start;$cloneMe.attr('start',startWith+1);}
if($cloneMe.children().length){split($clone,$cloneMe,$parentColumn,targetHeight);}}else{$cloneMe.addClass(prefixTheClassName("split"));}
if($clone.get(0).childNodes.length===0){$clone.remove();$cloneMe.removeClass(prefixTheClassName("split"));}else if($clone.get(0).childNodes.length==1){var onlyNode=$clone.get(0).childNodes[0];if(onlyNode.nodeType==3){var whitespace=/\s/;var str=onlyNode.nodeValue;if(whitespace.test(str)){$clone.remove();$cloneMe.removeClass(prefixTheClassName("split"));}}}}}}}
function singleColumnizeIt(){if($inBox.data("columnized")&&$inBox.children().length==1){return;}
$inBox.data("columnized",true);$inBox.data("columnizing",true);$inBox.empty();$inBox.append($("<div class='"
+prefixTheClassName("first")+" "
+prefixTheClassName("last")+" "
+prefixTheClassName("column")+" "
+"' style='width:100%; float: "+options.columnFloat+";'></div>"));$col=$inBox.children().eq($inBox.children().length-1);$destroyable=$cache.clone(true);if(options.overflow){targetHeight=options.overflow.height;columnize($col,$destroyable,$col,targetHeight);if(!$destroyable.contents().find(":first-child").hasClass(prefixTheClassName("dontend"))){split($col,$destroyable,$col,targetHeight);}
while($col.contents(":last").length&&checkDontEndColumn($col.contents(":last").get(0))){var $lastKid=$col.contents(":last");$lastKid.remove();$destroyable.prepend($lastKid);}
var html="";var div=document.createElement('DIV');while($destroyable[0].childNodes.length>0){var kid=$destroyable[0].childNodes[0];if(kid.attributes){for(var i=0;i<kid.attributes.length;i++){if(kid.attributes[i].nodeName.indexOf("jQuery")===0){kid.removeAttribute(kid.attributes[i].nodeName);}}}
div.innerHTML="";div.appendChild($destroyable[0].childNodes[0]);html+=div.innerHTML;}
var overflow=$(options.overflow.id)[0];overflow.innerHTML=html;}else{appendSafe($col,$destroyable.contents());}
$inBox.data("columnizing",false);if(options.overflow&&options.overflow.doneFunc){options.overflow.doneFunc();}
options.doneFunc();}
function checkDontEndColumn(dom){if(dom.nodeType==3){if(/^\s+$/.test(dom.nodeValue)){if(!dom.previousSibling)return false;return checkDontEndColumn(dom.previousSibling);}
return false;}
if(dom.nodeType!=1)return false;if($(dom).hasClass(prefixTheClassName("dontend")))return true;if(dom.childNodes.length===0)return false;return checkDontEndColumn(dom.childNodes[dom.childNodes.length-1]);}
function columnizeIt(){adjustment=0;if(lastWidth==$inBox.width())return;lastWidth=$inBox.width();var numCols=Math.round($inBox.width()/options.width);var optionWidth=options.width;var optionHeight=options.height;if(options.columns)numCols=options.columns;if(manualBreaks){numCols=$cache.find(prefixTheClassName("columnbreak",true)).length+1;optionWidth=false;}
if(numCols<=1){return singleColumnizeIt();}
if($inBox.data("columnizing"))return;$inBox.data("columnized",true);$inBox.data("columnizing",true);$inBox.empty();$inBox.append($("<div style='width:"+options.setWidth(numCols)+"%; float: "+options.columnFloat+";'></div>"));$col=$inBox.children(":last");appendSafe($col,$cache.clone());maxHeight=$col.height();$inBox.empty();var targetHeight=maxHeight/numCols;var firstTime=true;var maxLoops=3;var scrollHorizontally=false;if(options.overflow){maxLoops=1;targetHeight=options.overflow.height;}else if(optionHeight&&optionWidth){maxLoops=1;targetHeight=optionHeight;scrollHorizontally=true;}
for(var loopCount=0;loopCount<maxLoops&&loopCount<20;loopCount++){$inBox.empty();var $destroyable,className,$col,$lastKid;try{$destroyable=$cache.clone(true);}catch(e){$destroyable=$cache.clone();}
$destroyable.css("visibility","hidden");for(var i=0;i<numCols;i++){className=(i===0)?prefixTheClassName("first"):"";className+=" "+prefixTheClassName("column");className=(i==numCols-1)?(prefixTheClassName("last")+" "+className):className;$inBox.append($("<div class='"+className+"' style='width:"+options.setWidth(numCols)+"%; float: "+options.columnFloat+";'></div>"));}
i=0;while(i<numCols-(options.overflow?0:1)||scrollHorizontally&&$destroyable.contents().length){if($inBox.children().length<=i){$inBox.append($("<div class='"+className+"' style='width:"+options.setWidth(numCols)+"%; float: "+options.columnFloat+";'></div>"));}
$col=$inBox.children().eq(i);if(scrollHorizontally){$col.width(optionWidth+"px");}
columnize($col,$destroyable,$col,targetHeight);split($col,$destroyable,$col,targetHeight);while($col.contents(":last").length&&checkDontEndColumn($col.contents(":last").get(0))){$lastKid=$col.contents(":last");$lastKid.remove();$destroyable.prepend($lastKid);}
i++;if($col.contents().length===0&&$destroyable.contents().length){$col.append($destroyable.contents(":first"));}else if(i==numCols-(options.overflow?0:1)&&!options.overflow){if($destroyable.find(prefixTheClassName("columnbreak",true)).length){numCols++;}}}
if(options.overflow&&!scrollHorizontally){var IE6=false;var IE7=(document.all)&&(navigator.appVersion.indexOf("MSIE 7.")!=-1);if(IE6||IE7){var html="";var div=document.createElement('DIV');while($destroyable[0].childNodes.length>0){var kid=$destroyable[0].childNodes[0];for(i=0;i<kid.attributes.length;i++){if(kid.attributes[i].nodeName.indexOf("jQuery")===0){kid.removeAttribute(kid.attributes[i].nodeName);}}
div.innerHTML="";div.appendChild($destroyable[0].childNodes[0]);html+=div.innerHTML;}
var overflow=$(options.overflow.id)[0];overflow.innerHTML=html;}else{$(options.overflow.id).empty().append($destroyable.contents().clone(true));}}else if(!scrollHorizontally){$col=$inBox.children().eq($inBox.children().length-1);$destroyable.contents().each(function(){$col.append($(this));});var afterH=$col.height();var diff=afterH-targetHeight;var totalH=0;var min=10000000;var max=0;var lastIsMax=false;var numberOfColumnsThatDontEndInAColumnBreak=0;$inBox.children().each(function($inBox){return function($item){var $col=$inBox.children().eq($item);var endsInBreak=$col.children(":last").find(prefixTheClassName("columnbreak",true)).length;if(!endsInBreak){var h=$col.height();lastIsMax=false;totalH+=h;if(h>max){max=h;lastIsMax=true;}
if(h<min)min=h;numberOfColumnsThatDontEndInAColumnBreak++;}};}($inBox));var avgH=totalH/numberOfColumnsThatDontEndInAColumnBreak;if(totalH===0){loopCount=maxLoops;}else if(options.lastNeverTallest&&lastIsMax){adjustment+=5;targetHeight=targetHeight+30;if(loopCount==maxLoops-1)maxLoops++;}else if(max-min>30){targetHeight=avgH+30;}else if(Math.abs(avgH-targetHeight)>20){targetHeight=avgH;}else{loopCount=maxLoops;}}else{$inBox.children().each(function(i){$col=$inBox.children().eq(i);$col.width(optionWidth+"px");if(i===0){$col.addClass(prefixTheClassName("first"));}else if(i==$inBox.children().length-1){$col.addClass(prefixTheClassName("last"));}else{$col.removeClass(prefixTheClassName("first"));$col.removeClass(prefixTheClassName("last"));}});$inBox.width($inBox.children().length*optionWidth+"px");}
$inBox.append($("<br style='clear:both;'>"));}
$inBox.find(prefixTheClassName("column",true)).find(":first"+prefixTheClassName("removeiffirst",true)).remove();$inBox.find(prefixTheClassName("column",true)).find(':last'+prefixTheClassName("removeiflast",true)).remove();$inBox.find(prefixTheClassName("split",true)).find(":first"+prefixTheClassName("removeiffirst",true)).remove();$inBox.find(prefixTheClassName("split",true)).find(':last'+prefixTheClassName("removeiflast",true)).remove();$inBox.data("columnizing",false);if(options.overflow){options.overflow.doneFunc();}
options.doneFunc();}});};$.fn.renumberByJS=function($searchTag,$colno,$targetId,$targetClass){this.setList=function($cols,$list,$tag1){var $parents=this.before.parents();var $rest;$rest=$($cols[this.offset-1]).find('>*');if(($rest.last())[0].tagName!=$tag1.toUpperCase()){if(this.debug){console.log("Last item in previous column, isn't a list...");}
return 0;}
$rest=$rest.length;var $tint=1;if(this.lastOther<=0){$tint=this.before.children().length+1;}else{$tint=$($parents[this.lastOther]).children().length+1;}
if($($cols[this.offset]).find($tag1+':first li.split').length){var $whereElipsis=$($cols[this.offset-1]).find($tag1+':last li:last');if(this.elipsisText===''||$($cols[this.offset-1]).find($tag1+':last ~ div').length||$($cols[this.offset-1]).find($tag1+':last ~ p').length){;}else{if($($whereElipsis).find('ul, ol, dl').length==0){var $txt=$whereElipsis.last().text();var $len=$txt.length;if($txt.substring($len-1)==';'){if($txt.substring($len-4)!=this.elipsisText+';'){$txt=$txt.substring(0,$len-1)+this.elipsisText+';';}}else{if($txt.substring($len-3)!=this.elipsisText){$txt+=this.elipsisText;}}
$whereElipsis.last().text($txt);}}
if($($cols[this.offset]).find($tag1+':first >li.split >'+$tag1).length==0){$tint--;}}
if($rest==1){$tint+=this.prevMax;}
if(this.nest>1){if(this.debug){console.log("Supposed to be a nested list...decr");}
$tint--;var $tt=$($cols[this.offset-1]).find($tag1+':first li.split:first');if($tt.length>0){if(this.debug){console.log("Previous column started with a split item, so that count is one less than expected");}
$tint--;}
$tt=$($cols[this.offset]).find($tag1+':first li:first').clone();$tt.children().remove();if($.trim($tt.text()).length>0){if(this.debug){console.log("If that was a complete list in the previous column, don't decr.");}
$tint++;if($($cols[this.offset-1]).find(">"+$tag1+':last ').children().length==0){if(this.debug){console.log("unless that was empty, in which case revert");}
$tint--;}}}else{var $tt=$($cols[this.offset]).find($tag1+':first li:first '+$tag1+".split li.split");if($tt.length>0){if(this.debug){console.log("[Nested] Column started with a split item, so that count is one less than expected");}
$tint--;}}
if(this.debug){console.log("Setting the start value to "+$tint+" ("+this.prevMax+")");}
if($tint>0){if(typeof this.setColumnStart=='function'){this.setColumnStart($list,$tint);}else{$list.attr('start',$tint);}}
return 0;}
if(typeof $targetId==='undefined'){$targetId=false;}
if(typeof $targetClass==='undefined'){$targetClass=false;}
if(!$targetId&&!$targetClass){throw"renumberByJS(): Bad param, must pass an id or a class";}
var $target='';this.prevMax=1;if($targetClass){$target="."+$targetClass;}else{$target="#"+$targetId;}
var $tag1=$searchTag.toLowerCase();var $tag2=$searchTag.toUpperCase();this.cols=$($target);if(this.debug){console.log("There are "+this.cols.length+" items, looking for "+$tag1);}
this.before=$(this.cols[0]).find($tag1+':last');this.prevMax=this.before.children().length;for(this.offset=1;this.offset<this.cols.length;this.offset++){if(this.debug){console.log("iterating "+this.offset+"...[of "+this.cols.length+"]");}
if(this.offset%$colno==0){if(this.debug){console.log("First column (in theory..)");}
this.prevMax=1;continue;}
this.before=$(this.cols[this.offset-1]).find($tag1+':last');if(this.before.length){if(this.debug){console.log("Have some "+$searchTag+" elements in the previous column");}
var $list=$(this.cols[this.offset]).find($tag1+':first');var $first=$(this.cols[this.offset]).find('*:first');if($first[0]!==$list[0]){continue;}
var $parents=this.before.parents();this.lastOther=0;var $found=false;for(;this.lastOther<$parents.length;this.lastOther++){if($parents[this.lastOther].tagName!=$tag2&&$parents[this.lastOther].tagName!="LI"){$found=true;this.lastOther--;break;}}
this.nest=1;if($(this.cols[this.offset]).find(">"+$tag1+':first li '+$tag1+":first").length){this.nest=2;}
this.setList(this.cols,$list,$tag1);this.lastOther--;$list=$(this.cols[this.offset]).find($tag1+':first li '+$tag1+":first");if($list.length){this.before=$(this.cols[this.offset-1]).find(">"+$tag1+':last li '+$tag1+":last");this.prevMax=0;this.nest=1;this.setList(this.cols,$list,$tag1);}
var $reset=$(this.cols[this.offset-1]).find(">"+$tag1+':last');this.prevMax=$reset.children().length;}}
return 0;};})(jQuery);