2022.2

Table Of Contents
Inan'Eachmatchedelement'scriptyouwouldfirstneedtocheckthereturnvalueofthis.next():
var nextSibling = this.next();
if nextSibling != null { nextSibling.css("font-weight", "bold"); }
overflows()
Theoverflows()methodreturnsabooleanvalueindicatingwhetheranHTMLelementoverflowsits
boxboundaries.
Thisfunctioncouldforinstancebeusedinadesignwherecontentneedstoflowseparatelyfromthe
maintextflow,orwhereanew,full-page,multi-columnboxshouldbeinsertedwhenthecurrentone
overflows.
NotethatwhencalledinaStandardscript,thismethodrunsbeforethepaginationofPrintoutput.After
pagination-intheoutput,andinPreviewmode-theelement'soverflowmayhavechanged,especially
whentheelementiscombinedwithfloatingelements(i.e.elementsthathavetheCSSstylefloat)and
locatednearapage-break.
Topreventthisfromhappening,itmayhelptosettheelement'sCSSstyletooverflow:hidden.
Theoverflows()methodcanalsobeusedinaPostPaginationscript.
Tip: Youdon'tneedascripttoresizetextinordertomakeitfitinabox.TheCopyFitfeatureauto-
maticallyscalestexttotheavailablespace(see"CopyFit"onpage685).
Examples
var $box = query("#mybox");
while ( ! $box.overflows()) {
//do something
}
Aslightlyshorterversion:
while ( ! query("#mybox").overflows()) {
//do something
}
Thefollowingscriptselectsthreeboxesthatallhavetheclassbox(selector:.box).Itloopsoverthem,
insertingasmanyproductsfromanarrayaspossibleintothebox.Infact,itinsertsonetoomanyand
removesthelastonebeforemovingontothenextbox.
var products = ["Appetizer","Beans","Beef","Lettuce","Sprouts","Coconut","Juice","Soup","Coriander","Cheese","Pasta","Sugar","Vinegar","Bread"];
var i = 0;
results.each( function() {
// Add elements to the box until it overflows.
while ( ! this.overflows() && i < products.length ) {
this.append("<p>" + products[i] + "</p>");
Page 1226