Goes through the list of child boxes and organizes them into captions, header,
footer, etc.
349481
private void organizeContent()
    {
        table = new TableBox(el, g, ctx);
        table.adoptParent(this);
        table.setStyle(style);
        
        for (Iterator<Box> it = nested.iterator(); it.hasNext(); )
        {
            Box box = it.next();
            if (box instanceof TableCaptionBox)
            {
                caption = (TableCaptionBox) box;
            }
            else if (box instanceof BlockBox && ((BlockBox) box).isPositioned())
            {
                //positioned boxes are ignored
            }
            else //other elements belong to the table itself
            {
                table.addSubBox(box);
                box.setContainingBlockBox(table);
                box.setParent(table);
                it.remove();
                endChild--;
            }
        }
        
        addSubBox(table);
    }
1303597
function Headings({ toc, path }) {
    if (!toc.length) {
      return null
    }
    return (
      <ul>
        {toc.map(function(item, index) {
          const href = `${path}#${item.id}`

          return (
            <li key={index}>
              {item.children.length > 0 && (
                <input
                  id={href}
                  className="nav_toggle"
                  type="checkbox"
                  defaultChecked={false}
                />
              )}
              <a
                className={`nav_toggle-label nav_item-name nav_sublink
                  ${item.children.length ? '' : 'nav_childless'}`}
                href={href}
              >
                {item.title}
              </a>
              <Headings toc={item.children} path={path} />
            </li>
          )
        })}
      </ul>
    )
  }
1255916
function setup() {
		// ------------------------------
		// LIGHTBOX
		setupLigtbox();
		// ------------------------------
		
		
		
		// ------------------------------
		// CODE PRETTIFY
		if($('.prettyprint').length) {
			window.prettyPrint && prettyPrint();
		}
		// ------------------------------
		
		
		
		// ------------------------------
		// TABS
		$('.tabs').each(function() {
			if(!$(this).find('.tab-titles li a.active').length) {
				$(this).find('.tab-titles li:first-child a').addClass('active');
				$(this).find('.tab-content > div:first-child').show();
			} else {
				$(this).find('.tab-content > div').eq($(this).find('.tab-titles li a.active').parent().index()).show();	
			}
		});
		
		$('.tabs .tab-titles li a').click(function() {
			if($(this).hasClass('active')) { return; }
			$(this).parent().siblings().find('a').removeClass('active');
			$(this).addClass('active');
			$(this).parents('.tabs').find('.tab-content > div').hide().eq($(this).parent().index()).show();
			return false;
		});
		// ------------------------------
		
		
		// ------------------------------
		// TOGGLES
		var toggleSpeed = 300;
		$('.toggle h4.active + .toggle-content').show();
	
		$('.toggle h4').click(function() {
			if($(this).hasClass('active')) { 
				$(this).removeClass('active');
				$(this).next('.toggle-content').stop(true,true).slideUp(toggleSpeed);
			} else {
				
				$(this).addClass('active');
				$(this).next('.toggle-content').stop(true,true).slideDown(toggleSpeed);
				
				//accordion
				if($(this).parents('.toggle-group').hasClass('accordion')) {
					$(this).parent().siblings().find('h4').removeClass('active');
					$(this).parent().siblings().find('.toggle-content').stop(true,true).slideUp(toggleSpeed);
				}
				
			}
			return false;
		});
		// ------------------------------
		
		
		
		// ------------------------------
		// RESPONSIVE VIDEOS
		if($('.media-wrap, .portfolio-single').length) {
			$(".media-wrap, .portfolio-single").fitVids();
		}
		// ------------------------------
		
		
		
		// ------------------------------
		// UNIFORM
		$("select:not([multiple]), input:checkbox, input:radio, input:file").uniform();
		var ua = navigator.userAgent.toLowerCase();
		var isAndroid = ua.indexOf("android") > -1;
		if(isAndroid) {
			$('html').addClass('android');
		}
		// ------------------------------
		
		
		
		// ------------------------------
		/* FLEX SLIDER */
		// cache container
		var $flexslider = $('.flexslider');
		if($flexslider.length) {
			
			$flexslider.each(function() {
			
				//wait for images
				$(this).imagesLoaded(function() {
					
					//remove loading
					$(this).find('.loading').remove();
					
					//setup slider
					$(this).flexslider({ 
						smoothHeight: true,
						slideshow: $(this).attr('data-autoplay') != "false",
						slideshowSpeed: $(this).attr('data-interval'), 
						animationSpeed : $(this).attr('data-animationSpeed'),
						animation: $(this).attr('data-animation'), 
						direction : $(this).attr('data-direction'),
						directionNav : $(this).attr('data-directionNav') != "false",
						controlNav : $(this).attr('data-controlNav') != "false",
						randomize : $(this).attr('data-randomize') == "true",
						startAt : $(this).attr('data-startAt') != null ? parseInt($(this).attr('data-startAt')) : 0,
						animationLoop : $(this).attr('data-animationLoop') != "false",
						pauseOnHover : $(this).attr('data-pauseOnHover') != "false",
						reverse : $(this).attr('data-reverse') == "true",
						prevText: "",
						nextText: "",
						start: function(slider) {
								$('.slides li img').click(function(event){
									event.preventDefault();
									slider.flexAnimate(slider.getTarget("next"));
								});
							}
						});
					
				});
			
			});
		}
		// ------------------------------
		
		
		// ------------------------------
		/* MEDIAELEMENT.JS - self hosted html5 video and audio player */
		if($('video,audio').length) {
			$('video,audio').mediaelementplayer({ audioHeight: 50 });	
		}
		// ------------------------------
	}
115721
def flatten_pages(self, pages, level=1):
        """"""
        flattened = []

        for page in pages:
            if type(page) is list:
                flattened.append(
                             {
                                'file': page[0],
                                'title': page[1],
                                'level': level,
                             })
            if type(page) is dict:
                if type(list(page.values())[0]) is str:
                    flattened.append(
                            {
                                'file': list(page.values())[0],
                                'title': list(page.keys())[0],
                                'level': level,
                             })
                if type(list(page.values())[0]) is list:
                    flattened.extend(
                            self.flatten_pages(
                                list(page.values())[0],
                                level + 1)
                            )


        return flattened
1012796
def attachment_list
      container_classes = [SimpleFormAttachments.dom_class(:attachment_list)]
      container_classes << SimpleFormAttachments.dom_class(:attachment_list, :is_sortable) if sortable?
      template.content_tag :div, class: container_classes do
        @builder.simple_fields_for attribute_name do |attachment_fields|
          template.render(
            partial: attachment_fields.object.to_simple_form_partial_path, format: :html, layout: File.join('layouts', 'simple_form_attachments', 'attachment_layout'),
            locals: {
              attachment: attachment_fields.object,
              fields: attachment_fields,
              multiple: multiple?,
              form: @builder,
              relation_key: relation_key
            }
          )
        end
      end
    end
1104133
function gatherHeaders(item) {
    var ret, i, l;
    if (isHashArray(item)) {
        //lets assume a multidimesional array with item 0 bing the title
        i = -1;
        l = item.length;
        ret = [];
        while (++i < l) {
            ret[i] = item[i][0];
        }
    } else if (isArray(item)) {
        ret = item;
    } else {
        ret = keys(item);
    }
    return ret;
}
352410
function processChildren( &$textElements,
                              &$children, $key, &$item, &$index, &$isFirstRun,
                              &$delimiterStructure, &$sequenceStructure, &$filterStructure,
                              $tpl, $rootNamespace, $name, $functionPlacement,
                              &$variableIterator, $noLastValue,
                              &$iteratorData )
    {
        if ( $variableIterator !== null )
        {
            unset( $last );
            if ( !$noLastValue and $iteratorData['iterator'] !== false )
            {
                $last =& $iteratorData['iterator'];
            }
            else
            {
                $last = false;
            }
            unset( $iteratorData['iterator'] );
            $iteratorData['iterator'] = new eZTemplateSectionIterator();
            $iteratorData['iterator']->setIteratorValues( $item, $key, $index, $index + 1, false, $last );
            unset( $last );

            $iteratorObject =& $iteratorData['iterator'];
            $tpl->setVariable( $variableIterator, $iteratorObject, $name );
        }
        else
        {
            $tpl->setVariable( "key", $key, $name );
            $tpl->setVariable( "item", $item, $name );
            $tpl->setVariable( "index", $index, $name );
            $tpl->setVariable( "number", $index + 1, $name );
        }
        if ( count( $filterStructure ) > 0 )
        {
            $filterCount = count( $filterStructure );
            $includeElement = true;
            for ( $i = 0; $i < $filterCount; ++$i )
            {
                $filterElement =& $filterStructure[$i];
                $filterParameters =& $filterElement[3];
                $filterName = $filterElement[2];
                $filterMatch = null;
                if ( isset( $filterParameters["match"] ) )
                {
                    $filterMatch = $tpl->elementValue( $filterParameters["match"], $rootNamespace, $name, $functionPlacement );
                    if ( $filterMatch )
                        $includeElement = $filterName == "section-exclude" ? false : true;
                }
                else
                    $tpl->missingParameter( "section:$filterName", "match" );
            }
            if ( !$includeElement )
                return false;
        }
        if ( $delimiterStructure !== null and !$isFirstRun )
        {
            $delimiterParameters = $delimiterStructure[3];
            $delimiterMatch = true;
            if ( isset( $delimiterParameters["modulo"] ) )
            {
                $delimiterModulo = $delimiterParameters["modulo"];
                $modulo = $tpl->elementValue( $delimiterModulo, $rootNamespace, $name, $functionPlacement );
                $modulo = trim( $modulo );
                if ( is_numeric( $modulo ) )
                    $delimiterMatch = ( $index % $modulo ) == 0;
            }
            if ( isset( $delimiterParameters["match"] ) )
            {
                $delimiterMatchParameter = $delimiterParameters["match"];
                $delimiterMatch = $tpl->elementValue( $delimiterMatchParameter, $rootNamespace, $name, $functionPlacement );
            }
            if ( $delimiterMatch )
            {
                $delimiterChildren =& $delimiterStructure[1];
                if ( is_array( $delimiterChildren ) )
                {
                    foreach ( array_keys( $delimiterChildren ) as $delimiterChildKey )
                    {
                        $delimiterChild =& $delimiterChildren[$delimiterChildKey];
                        $tpl->processNode( $delimiterChild, $textElements, $rootNamespace, $name );
                    }
                }
            }
        }
        $isFirstRun = false;
        if ( $sequenceStructure !== null and is_array( $sequenceStructure ) )
        {
            $sequenceValue = array_shift( $sequenceStructure );
            if ( $variableIterator !== null )
            {
                $iteratorData['iterator']->setSequence( $sequenceValue );
            }
            else
            {
                $tpl->setVariable( "sequence", $sequenceValue, $name );
            }
            $sequenceStructure[] = $sequenceValue;
        }
        foreach ( array_keys( $children ) as $childKey )
        {
            $child =& $children[$childKey];
            $tpl->processNode( $child, $textElements, $rootNamespace, $name );
        }
        ++$index;
        return true;
    }
541396
function() {
				if (list && colWidth) {
					var cl = 'elfinder-cwd-colwidth',
					first = cwd.find('tr[id]:first'),
					former;
					if (! first.hasClass(cl)) {
						former = cwd.find('tr.'+cl);
						former.removeClass(cl).find('td').css('width', '');
						first.addClass(cl);
						cwd.find('table:first').css('table-layout', 'fixed');
						$.each($.merge(['name'], customCols), function(i, k) {
							var w = colWidth[k] || first.find('td.elfinder-col-'+k).width();
							first.find('td.elfinder-col-'+k).width(w);
						});
					}
				}
			}
39654
@Override
    public void manipulateChildElements(List<HierarchyWrapper> children) {
        if (!children.isEmpty()) {
            builder.append(baseIndent).append("children=").append("\n");
        }
    }
1059317
private void addChildrenForOUNode(CmsOrganizationalUnit item) {

        List<Object> itemsToRemove = new ArrayList<Object>();

        Collection<?> childCol = m_treeContainer.getChildren(item);
        if (childCol != null) {
            itemsToRemove.addAll(childCol);
        }

        try {
            if (m_app.isOUManagable(item.getName())) {

                List<I_CmsOuTreeType> types = m_app.getTreeTypeProvider().getTreeTypes();
                for (I_CmsOuTreeType type : types) {
                    if (!type.isValidForOu(m_cms, item.getName())) {
                        continue;
                    }
                    if (type.isOrgUnit()) {
                        continue;
                    }
                    String itemId = type.getId() + item.getName();
                    Item newItem = m_treeContainer.addItem(itemId);
                    itemsToRemove.remove(itemId);
                    if (newItem != null) {
                        newItem.getItemProperty(PROP_NAME).setValue(getIconCaptionHTML(itemId, type));
                        newItem.getItemProperty(PROP_TYPE).setValue(type);
                        m_treeContainer.setParent(itemId, item);
                        setChildrenAllowed(itemId, type.isExpandable());
                    }
                }
            }
            List<CmsOrganizationalUnit> ous = OpenCms.getOrgUnitManager().getOrganizationalUnits(
                m_cms,
                item.getName(),
                false);
            List<CmsOrganizationalUnit> webOus = new ArrayList<CmsOrganizationalUnit>();
            for (CmsOrganizationalUnit ou : ous) {
                if (m_app.isParentOfManagableOU(ou.getName())) {
                    itemsToRemove.remove(ou);
                    if (ou.hasFlagWebuser()) {
                        webOus.add(ou);
                    } else {
                        addOuToTree(ou, item);
                    }
                }
            }
            for (CmsOrganizationalUnit ou : webOus) {
                if (m_app.isParentOfManagableOU(ou.getName())) {
                    itemsToRemove.remove(ou);
                    addOuToTree(ou, item);
                }
            }
        } catch (CmsException e) {
            LOG.error("Can't read ou", e);
        }
        for (Object it : itemsToRemove) {
            m_treeContainer.removeItemRecursively(it);
        }
    }
685513
def make_horizontal_box(cls, children, layout=Layout()):
        ""
        return widgets.HBox(children, layout=layout)
705745
function () {
		// Create Layout
		this._el.container 				= TL.Dom.create("div", "tl-slide");

		if (this.has.title) {
			this._el.container.className = "tl-slide tl-slide-titleslide";
		}

		if (this.data.unique_id) {
			this._el.container.id 		= this.data.unique_id;
		}
		this._el.scroll_container 		= TL.Dom.create("div", "tl-slide-scrollable-container", this._el.container);
		this._el.content_container		= TL.Dom.create("div", "tl-slide-content-container", this._el.scroll_container);
		this._el.content				= TL.Dom.create("div", "tl-slide-content", this._el.content_container);
		this._el.background				= TL.Dom.create("div", "tl-slide-background", this._el.container);
		// Style Slide Background
		if (this.data.background) {
			if (this.data.background.url) {
		    var media_type = TL.MediaType(this.data.background, true);
		    if(media_type) {
          this._background_media = new media_type.cls(this.data.background, {background: 1});

          this.has.background.image 					= true;
          this._el.container.className 				+= ' tl-full-image-background';
          this.has.background.color_value 		= "#000";
          this._el.background.style.display 	= "block";
        }
			}
			if (this.data.background.color) {
				this.has.background.color 					= true;
				this._el.container.className 				+= ' tl-full-color-background';
				this.has.background.color_value 			= this.data.background.color;
				//this._el.container.style.backgroundColor = this.data.background.color;
				//this._el.background.style.backgroundColor 	= this.data.background.color;
				//this._el.background.style.display 			= "block";
			}
			if (this.data.background.text_background) {
				this._el.container.className 				+= ' tl-text-background';
			}

		}



		// Determine Assets for layout and loading
		if (this.data.media && this.data.media.url && this.data.media.url != "") {
			this.has.media = true;
		}
		if (this.data.text && this.data.text.text) {
			this.has.text = true;
		}
		if (this.data.text && this.data.text.headline) {
			this.has.headline = true;
		}

		// Create Media
		if (this.has.media) {
			// Determine the media type
			this.data.media.mediatype = TL.MediaType(this.data.media);
			this.options.media_name 	= this.data.media.mediatype.name;
			this.options.media_type 	= this.data.media.mediatype.type;
      this.options.autolink 		= this.data.autolink;

			// Create a media object using the matched class name
			this._media = new this.data.media.mediatype.cls(this.data.media, this.options);
		}

		// Create Text
		if (this.has.text || this.has.headline) {
			this._text = new TL.Media.Text(this.data.text, {title:this.has.title,language: this.options.language, autolink: this.data.autolink });
			this._text.addDateText(this.getFormattedDate());
		}



		// Add to DOM
		if (!this.has.text && !this.has.headline && this.has.media) {
			TL.DomUtil.addClass(this._el.container, 'tl-slide-media-only');
			this._media.addTo(this._el.content);
		} else if (this.has.headline && this.has.media && !this.has.text) {
			TL.DomUtil.addClass(this._el.container, 'tl-slide-media-only');
			this._text.addTo(this._el.content);
			this._media.addTo(this._el.content);
		} else if (this.has.text && this.has.media) {
			this._media.addTo(this._el.content);
			this._text.addTo(this._el.content);
		} else if (this.has.text || this.has.headline) {
			TL.DomUtil.addClass(this._el.container, 'tl-slide-text-only');
			this._text.addTo(this._el.content);
		}

		// Fire event that the slide is loaded
		this.onLoaded();

	}
720425
function(){
		$('.entry-content').each(function(i){
			var _i = i;
			$(this).find('img').each(function(){
				var alt = this.alt;

				if (alt != ''){
					$(this).after('<span class="caption">'+alt+'</span>');
				}

				$(this).wrap('<a href="'+this.src+'" title="'+alt+'" class="fancybox" rel="gallery'+_i+'" />');
			});
		});
	}
1117872
def _check_jp2h_child_boxes(self, boxes, parent_box_name):
        """"""
        JP2H_CHILDREN = set(['bpcc', 'cdef', 'cmap', 'ihdr', 'pclr'])

        box_ids = set([box.box_id for box in boxes])
        intersection = box_ids.intersection(JP2H_CHILDREN)
        if len(intersection) > 0 and parent_box_name not in ['jp2h', 'jpch']:
            msg = "A {0} box can only be nested in a JP2 header box."
            raise IOError(msg.format(list(intersection)[0]))

        # Recursively check any contained superboxes.
        for box in boxes:
            if hasattr(box, 'box'):
                self._check_jp2h_child_boxes(box.box, box.box_id)
1060472
function ()
    {
        var stacks = {};
        jQuery.each(jQuery('.jBox-Notice'), function (index, el)
        {
          el = jQuery(el);
          var pos = el.data('jBox-Notice-position');
          if (!stacks[pos]) {
              stacks[pos] = [];
          }
          stacks[pos].push(el);
        });
        for (var pos in stacks) {
            var position = pos.split('-');
            var direction = position[1];
            stacks[pos].reverse();
            var margin = 0;
            for (var i in stacks[pos]) {
                el = stacks[pos][i];
                el.css('margin-' + direction, margin);
                margin += el.outerHeight() + this.options.stackSpacing;
            }
        }
    }
1064664
private void addChildren(CmsTreeItem parent, List<CmsCategoryTreeEntry> children, List<String> selectedCategories) {

        if (children != null) {
            for (CmsCategoryTreeEntry child : children) {
                // set the category tree item and add to parent tree item
                CmsTreeItem treeItem = buildTreeItem(child, selectedCategories);
                if ((selectedCategories != null) && selectedCategories.contains(child.getPath())) {
                    parent.setOpen(true);
                    openParents(parent);
                }
                parent.addChild(treeItem);
                addChildren(treeItem, child.getChildren(), selectedCategories);
            }
        }
    }
1094946
private void organizeCells(ArrayList<TextPiece> linesOfAPage,
	    TableCandidate tc) {
	float captionY = linesOfAPage.get(tc.getCaptionStartLine()).getY();
	float captionEndY = linesOfAPage.get(tc.getCaptionEndLine()).getEndY();
	ArrayList<TextPiece> rawCells = new ArrayList<TextPiece>();
	/*
	 * Copy & sort
	 */
	for (int i = tc.getBodyStartLine(); i <= tc.getBodyEndLine(); i++) {
	    rawCells.add(linesOfAPage.get(i));
	}

	Collections.sort(rawCells);
	assert rawCells.size() >= 4; // due to previous check
	TableRow currentRow = null; // creates first row

	for (TextPiece cell : rawCells) {
	    /*
	     * Skips lines beyond caption //TODO: remove the far Y
	     */
	    if (tc.isTopCaption() && (cell.getY() < captionY))
		continue;
	    if (!tc.isTopCaption() && (cell.getEndY() > captionEndY))
		continue;

	    /*
	     * Lines too close to each other are treated as a single line
	     */
	    if (currentRow != null
		    && cell.getY() - currentRow.getY() < m_docInfo
			    .getAverageLineGap() / 2.0)
		currentRow.addCell(cell);
	    else {
		/*
		 * Creates a new row
		 */
		currentRow = new TableRow();
		currentRow.setY(cell.getY());
		if (cell.isSuperScriptBeginning())
		    currentRow.setSuperScriptRow(true);
		currentRow.addCell(cell);
		tc.addRow(currentRow);
	    }
	}
	if (tc.getRows().size() < 2)
	    tc.setValid(false);
    }