Item renderer for stylesheet-picker dropdown
13388
function _stylesheetListRenderer(item) {
        var html = "<span class='stylesheet-name'>" + _.escape(item.name);
        if (item.subDirStr) {
            html += "<span class='stylesheet-dir'> — " + _.escape(item.subDirStr) + "</span>";
        }
        html += "</span>";
        return html;
    }
839950
function colorBox(selection, label) {
  selection
      .classed('form-row', true)
      .classed('align-items-center', true)
      .on('change', () => {
        // avoid update by mousemove on the colorpicker
        d3.event.stopPropagation();
      });
  selection.append('div')
      .classed('form-group', true)
      .classed('col-form-label', true)
      .classed('col-form-label-sm', true)
      .classed('col-4', true)
      .classed('mb-1', true)
      .text(label);
  selection.append('div')
      .classed('form-group', true)
      .classed('col-form-label', true)
      .classed('col-form-label-sm', true)
      .classed('col-4', true)
      .classed('mb-1', true)
    .append('input')
      .classed('form-control', true)
      .classed('form-control-sm', true)
      .attr('type', 'color');
}
741784
function (element, options) {
		this.$element = $(element);
		this.options = $.extend({}, $.fn.tree.defaults, options);

		this.$element.on('click', '.tree-item', $.proxy( function(ev) { this.selectItem(ev.currentTarget); } ,this));
		this.$element.on('click', '.tree-folder-header', $.proxy( function(ev) { this.selectFolder(ev.currentTarget); }, this));

		this.render();
	}
143856
function (options)
        {
            var self = this;

            self.options = $.extend({}, defaultOptions, options);
            // When itemValue is set, freeInput should always be false

            if (self.objectItems)
            {
                if (self.options.freeInput === true)
                {
                    self.options.freeInput = true;
                }
                else{
                    self.options.freeInput = false
                }
            }

            makeOptionItemFunction(self.options, 'itemValue');
            makeOptionItemFunction(self.options, 'itemText');
            makeOptionFunction(self.options, 'tagClass');

            // Typeahead.js
            if (self.options.typeaheadjs)
            {
                var typeaheadConfig   = null;
                var typeaheadDatasets = {};

                // Determine if main configurations were passed or simply a dataset
                var typeaheadjs = self.options.typeaheadjs;
                if ($.isArray(typeaheadjs))
                {
                    typeaheadConfig   = typeaheadjs[0];
                    typeaheadDatasets = typeaheadjs[1];
                }
                else
                {
                    typeaheadDatasets = typeaheadjs;
                }

                self.$input.typeahead(typeaheadConfig, typeaheadDatasets).on('typeahead:selected', $.proxy(function (obj, datum)
                {
                    if (typeaheadDatasets.valueKey)
                    {
                        self.add(datum[typeaheadDatasets.valueKey]);
                    }
                    else
                    {
                        self.add(datum);
                    }
                    self.$input.typeahead('val', '');
                }, self));
            }

            self.$container.on('click', $.proxy(function (event)
            {
                if (!self.$element.attr('disabled'))
                {
                    self.$input.removeAttr('disabled');
                }
                self.$input.focus();
            }, self));

            if (self.options.addOnBlur && self.options.freeInput)
            {
                self.$input.on('focusout', $.proxy(function (event)
                {
                    self.add(self.$input.val());
                    self.$input.val('');

                }, self));
            }

            self.$container.on('keydown', 'input', $.proxy(function (event)
            {
                var $input        = $(event.target),
                    $inputWrapper = self.findInputWrapper();

                if (self.$element.attr('disabled'))
                {
                    self.$input.attr('disabled', 'disabled');
                    return;
                }

                switch (event.which)
                {
                    // BACKSPACE
                    case 8:
                        if (self.options.deleteTagsOnBackspace && doGetCaretPosition($input[0]) === 0)
                        {
                            var prev = $inputWrapper.prev();
                            if (prev)
                            {
                                self.remove(prev.data('item'));
                            }
                        }
                        break;

                    // DELETE
                    case 46:
                        if (self.options.deleteTagsOnDeleteKey && doGetCaretPosition($input[0]) === 0)
                        {
                            var next = $inputWrapper.next();
                            if (next)
                            {
                                self.remove(next.data('item'));
                            }
                        }
                        break;

                    // LEFT ARROW
                    case 37:
                        // Try to move the input before the previous tag
                        var $prevTag = $inputWrapper.prev();
                        if (self.options.MoveTagOnLeftArrow && $input.val().length === 0 && $prevTag[0])
                        {
                            $prevTag.before($inputWrapper);
                            $input.focus();
                        }
                        break;
                    // RIGHT ARROW
                    case 39:
                        // Try to move the input after the next tag
                        var $nextTag = $inputWrapper.next();
                        if (self.options.MoveTagOnRightArrow && $input.val().length === 0 && $nextTag[0])
                        {
                            $nextTag.after($inputWrapper);
                            $input.focus();
                        }
                        break;
                    default:
                    // ignore
                }

                // Reset internal input's size
                var textLength = $input.val().length,
                    wordSpace  = Math.ceil(textLength / 5),
                    size       = textLength + wordSpace + 1;
                $input.attr('size', Math.max(this.inputSize, $input.val().length));
            }, self));

            self.$container.on('keydown', 'input', $.proxy(function (event)
            {
                var $input = $(event.target);

                if (self.$element.attr('disabled'))
                {
                    self.$input.attr('disabled', 'disabled');
                    return;
                }

                var text             = $input.val(),
                    maxLengthReached = self.options.maxChars && text.length >= self.options.maxChars;

                // If not text is entered and tab event is fired shouldn't prevent the default behavior
                if (self.options.allowTabOnEmpty && isEmpty(text) && event.which === tabKey) 
                {
                    return;
                }

                if (self.options.freeInput && (keyCombinationInList(event, self.options.confirmKeys) || maxLengthReached))
                {
                    self.add(maxLengthReached ? text.substr(0, self.options.maxChars) : text);
                    $input.val('');
                    (self.$input.typeahead) && self.$input.typeahead("val","");
                    event.preventDefault();
                }

                // Reset internal input's size
                var textLength = $input.val().length,
                    wordSpace  = Math.ceil(textLength / 5),
                    size      = textLength + wordSpace + 1;
                $input.attr('size', Math.max(this.inputSize, $input.val().length));
            }, self));

            // Remove icon clicked
            self.$container.on('click', '[data-role=remove]', $.proxy(function (event)
            {
                if (self.$element.attr('disabled'))
                {
                    return;
                }
                self.remove($(event.target).closest('.chip').data('item'));
            }, self));

            // Only add existing value as tags when using strings as tags
            if (self.options.itemValue === defaultOptions.itemValue)
            {
                if (self.$element[0].tagName === 'INPUT')
                {
                    self.add(self.$element.val());
                }
            }
        }
372284
function CSSLoader(loadItem, preferXHR) {
		this.AbstractLoader_constructor(loadItem, preferXHR, createjs.AbstractLoader.CSS);

		// public properties
		this.resultFormatter = this._formatResult;

		// protected properties
		this._tagSrcAttribute = "href";

		if (preferXHR) {
			this._tag = createjs.Elements.style();
		} else {
			this._tag = createjs.Elements.link();
		}

		this._tag.rel = "stylesheet";
		this._tag.type = "text/css";
	}
1338375
function renderSelectionInstantly(element, toSelection) {
  if (element[resetAnimationsOnNextRenderSymbol]) {
    resetAnimations(element);
    element[resetAnimationsOnNextRenderSymbol] = false;
  }
  const animationFractions = mixin.helpers.animationFractionsForSelection(element, toSelection);
  animationFractions.map((animationFraction, index) => {
    const item = element.items[index];
    if (animationFraction != null) {
      showItem(item, true);
      setAnimationFraction(element, index, animationFraction);
    } else {
      showItem(item, false);
    }
  });
}
215753
def render_item(self, contentitem):
        
        plugin = contentitem.plugin
        if not plugin.search_output and not plugin.search_fields:
            # Only render items when the item was output will be indexed.
            raise SkipItem

        if not plugin.search_output:
            output = ContentItemOutput('', cacheable=False)
        else:
            output = super(SearchRenderingPipe, self).render_item(contentitem)

        if plugin.search_fields:
            # Just add the results into the output, but avoid caching that somewhere.
            output.html += plugin.get_search_text(contentitem)
            output.cacheable = False

        return output
1210129
def group_items_html(grouped_items, options = {})
      default_opts  = {
          :group_nr_cols =>3,
          :item_nr_cols  => 1,
          :css_begin     => 'span-24 last',
          :render        => proc { |item| "<b>#{item.to_s}</b>" }
      }
      options       = default_opts.merge(options)
      title         = options[:title]
      group_nr_cols = options[:group_nr_cols]
      item_nr_cols  = options[:item_nr_cols]
      css_begin     = options[:css_begin]
      render        = options[:render]

      html          = ""
      html << "<h2>#{title}</h2>" if title
      grouped_items.each_with_index do |items_with_headers, items_box_index|
        headers = items_with_headers[0]
        items   = items_with_headers[1]
        html << "<div class='#{css_begin}'>" if (items_box_index % group_nr_cols) == 0
        if (items_box_index % group_nr_cols) == (group_nr_cols - 1)
          html << "<div class='span-8 last'>"
        else
          html << "<div class='span-8'>"
        end

        html << "<h2>"
        html << headers.first.to_s
        html << "- #{headers.last}" if headers.length > 1
        html << "</h2>"

        items.each_with_index do |item, index|
          if (index % (items.length / item_nr_cols + 1)) == 0
            html << "<div class='span-6#{index == ((items.length / item_nr_cols + 1) * (item_nr_cols-1)) ? "last" : ""}'/><ul>"
          end

          html << "<li>"
          html << render.call(item)
          html << "</li>"

          if (index % (items.length / item_nr_cols + 1)) == ((items.length / item_nr_cols + 1) -1)
            html << "</ul></div>"
          end
        end
        html << "</ul></div>" if ((items.length-1) % (items.length / item_nr_cols + 1)) != ((items.length / item_nr_cols + 1) -1)
        html << "</div>"
        html << "</div>" if (items_box_index % group_nr_cols) == (group_nr_cols - 1)
      end

      html
    end
35819
function() {
        var select = this.element,
            options = this.options,
            buildOption = this._buildOption.bind(this),
            renderTemplate = this.render.bind(this),
            dropdown = renderTemplate(options.optionsTemplate).attr('role', 'listbox').aria('multiselectable', this.multiple),
            list = $('<ul/>'),
            index = 0,
            self = this;

        // Must be set for `_buildOption()`
        this.dropdown = dropdown;

        select.children().each(function() {
            var optgroup = $(this);

            if (optgroup.prop('tagName').toLowerCase() === 'optgroup') {
                if (index === 0) {
                    options.hideFirst = false;
                }

                list.append(
                    renderTemplate(options.headingTemplate).text(optgroup.attr('label'))
                );

                optgroup.children().each(function() {
                    var option = $(this);

                    if (optgroup.prop('disabled')) {
                        option.prop('disabled', true);
                    }

                    if (option.prop('selected')) {
                        self.index = index;
                    }

                    list.append( buildOption(option, index) );
                    index++;
                });
            } else {
                if (optgroup.prop('selected')) {
                    self.index = index;
                }

                list.append( buildOption(optgroup, index) );
                index++;
            }
        });

        if (options.hideSelected && !options.multiple) {
            dropdown.addClass('hide-selected');
        }

        if (options.hideFirst) {
            dropdown.addClass('hide-first');
        }

        if (this.multiple) {
            dropdown.addClass('is-multiple');
        }

        this.wrapper.append(dropdown.append(list));

        return dropdown;
    }
350636
function(items) {

			var itemMarkup = '', i;
			for (i=0; i< items.length; i++) {
				itemMarkup += '<li><a href="#" data-value="' + items[i] + '">' + this.highlighter(items[i]) + '</a></li>';
			}

			var inputRegion = this.node.region();

			this.menu.setHtml(itemMarkup)
			this.menu.one('li').addClass('active')

			this.menu.setStyles({
				left: inputRegion.left,
				top: inputRegion.bottom,
				display:'block'
			});

			this.node.fire('typeahead:show')

			return this;
		}
501939
function renderer(parent, config){
    this.parent = ( ( "string" == typeof parent )
		    ? document.getElementById(parent)
		    : parent );
    if (this.parent === undefined) {
        throw "can't find parent element " + parent;
    }
    this.tree = new tree();
    this.node_hidden = {};
    this.children_hidden = {};
    this._sort = "ladderize_up";
    this._layout_dirty = true;
    this._css_prefix = "phylo_tree_" + (id_counter++) + "_";

    var self = this;
    this.node_elem_click_handler = function(event) {
        var node_elem =
            (event.currentTarget) ? event.currentTarget : event.srcElement;
        var node = self.tree.nodes[node_elem.node_id];
        if (node) return self.node_clicked(node, node_elem, event);
    };

    var default_config = {
        // these are in pixels
        // leaf box vertical height, including padding and borders
        box_height: 24,
        // vertical space between leaf boxes
        box_spacing: 10,
        // space between leaf box edge and leaf label
        leaf_padding: 4,
        // leaf border thickness
        leaf_border: 2,
        // leaf left offset
        leaf_margin: 1,
        // width/height of internal nodes
        node_size: 8,

        // leaf border color
        leaf_border_color: "blue",
        // font for leaf labels
        leaf_font: "Helvetica, Arial, sans-serif",
        transition_time: "0.8s"
    };

    this.config = ("object" == typeof config
                   ? bbop.core.merge(default_config, config)
                   : default_config);

    //config settings with default values dependent on other config values
    this.config.parent_padding = ( (this.config.parent_padding === undefined)
                                   ? ((this.config.box_spacing / 2) | 0)
                                   : this.config.parent_padding );

    this.node_style = {
        position: "absolute",
        background: "white",
        "z-index": 2,
        width: this.config.node_size + "px",
        height: this.config.node_size + "px",
        "margin-top": (-this.config.node_size / 2) + "px",
        "margin-left": (-this.config.node_size / 2) + "px",
        border: "1px solid black",
        "transition-property": "top, left",
        "transition-duration": this.config.transition_time,
        "transition-timing-function": "ease-in-out, ease-in-out",
        "box-sizing": "content-box",
        "-moz-box-sizing": "content-box"
    };

    this.leaf_style = {
        position: "absolute",
        background: "#f1f1ff",
        "z-index": 1,
        padding: this.config.leaf_padding + "px",
        // if leaf_padding is too low, the branch line will touch the text
        "padding-left": Math.max(this.config.leaf_padding, 3) + "px",

        // so that the leaves don't cover up the connection lines
        "margin-left": this.config.leaf_margin + "px",

        "margin-top": (-this.config.box_height / 2) + "px",

        // setting font size from box height.  We'd like to set font cap height
        // directly, but we can only set em box size.  Cap height on average is
        // 70% of em box size, so we'll set the font size to the intended
	// height divided by 0.7
        font: ( ( this.config.box_height
                  - ( this.config.leaf_padding * 2 )
                  - ( this.config.leaf_border * 2 ) )
                / 0.7 ) + "px " + this.config.leaf_font,

        // this.config.box_height includes padding and borders, so we
        // subtract those out to set the CSS height, which doesn't include
        // padding or borders
        height: ( this.config.box_height
                  - ( this.config.leaf_padding * 2 )
                  - ( this.config.leaf_border * 2 ) ) + "px",

        // center vertically by setting the line height to 0.7em
        // (corresponding to the way we set font size above)
        "line-height": "0.7em",
        "border-radius": (this.config.leaf_padding + 1) + "px",
        "white-space": "nowrap",
        "transition-property": "top, left",
        "transition-duration": this.config.transition_time,
        "transition-timing-function": "ease-in-out, ease-in-out",
        "box-sizing": "content-box",
        "-moz-box-sizing": "content-box"
    };

    if (this.config.leaf_border > 0) {
        this.leaf_style.border =
            this.config.leaf_border + "px solid "
            + this.config.leaf_border_color;
    }

    this.connection_style = {
        position: "absolute",
        "border-left": "2px solid black",
        "border-top": "2px solid black",
        "border-bottom": "2px solid black",
        "border-right": "none",
        "transition-property": "top, height, left, width, border",
        "transition-duration": this.config.transition_time,
        "transition-timing-function": 
            "ease-in-out, ease-in-out, ease-in-out, ease-in-out, step-start"
    };
}
134729
function renderTemplate(skipInterpolation) {
	skipInterpolation = typeof skipInterpolation === "string" ? [skipInterpolation] : skipInterpolation;
	const handlebarsMatcher = /{{([^{}]+)}}/;

	return function (files, metalsmith, done) {
		const keys = Object.keys(files);
		const metadata = metalsmith.metadata();

		async.each(keys, (file, next) => {

			// skipping files with skipInterpolation option
			if (skipInterpolation && multimatch([file], skipInterpolation, { dot: true }).length) {
				return next();
			}

			async.series([

				// interpolate the file contents
				function (callback) {
					const str = files[file].contents.toString();
					if (!handlebarsMatcher.test(str)) {
						return callback();
					}

					render(str, metadata, function (err, res) {
						if (err) return callback(err);
						files[file].contents = Buffer.from(res);
						callback();
					});
				},

				// interpolate the file name
				function (callback) {
					if (!handlebarsMatcher.test(file)) {
						return callback();
					}

					render(file, metadata, function (err, res) {
						if (err) return callback(err);
						// safety check to prevent file deletion in case filename doesn't change
						if (file === res) return callback();
						// safety check to prevent overwriting another file
						if (files[res]) return callback(`Cannot rename file ${file} to ${res}. A file with that name already exists.`);

						// add entry for interpolated file name
						files[res] = files[file];
						// delete entry for template file name
						delete files[file];
						callback();
					});
				}

			], function (err) {
				if (err) return done(err);
				next();
			});
		}, done);
	};
}
942397
async function exportCustomSelectorsToCssFile(to, customSelectors) {
	const cssContent = Object.keys(customSelectors).reduce((cssLines, name) => {
		cssLines.push(`@custom-selector ${name} ${customSelectors[name]};`);

		return cssLines;
	}, []).join('\n');
	const css = `${cssContent}\n`;

	await writeFile(to, css);
}
791821
function DropdownItem({
  className,
  icon,
  value,
  children,
  badge,
  badgeType,
  to,
  RootComponent,
  onClick,
}: Props): React.Node {
  const classes = cn({ "dropdown-item": true }, className);
  const childrenForAll = (
    <React.Fragment>
      {badge && (
        <span className="float-right">
          <Badge color={badgeType}>{badge}</Badge>
        </span>
      )}
      {icon && (
        <React.Fragment>
          <Icon name={icon} className="dropdown-icon" />{" "}
        </React.Fragment>
      )}
      {value}
      {children}
    </React.Fragment>
  );
  return RootComponent ? (
    <RootComponent className={classes} to={to} onClick={onClick}>
      {childrenForAll}
    </RootComponent>
  ) : (
    <a className={classes} href={to} onClick={onClick}>
      {childrenForAll}
    </a>
  );
}
1131156
function renderSearchResults(items){
    var html = '';

    // Loop through items, building up an HTML string
    for(var i = 0; i < items.length; i += 1){
      var f = items[i];
      html += [
        '<a class="item" data-value="', f.fullPath, '.html">',
          '<span class="score">', ~~f.score, '</span>',
          '<span class="filename">', highlightString(f.fileName, f.highlight.fileName), '</span>',
          '<span class="fullpath">', highlightString(f.fullPath, f.highlight.fullPath), '</span>',
        '</a>'
      ].join('');
    }

    // Dump all the html into the results list
    document.getElementById('searchresults').innerHTML = html;

    // Select the first item
    selectIndex(0);
  }
316327
function renderSelection() {
  if (!this.selectedItem) {
    return;
  }
  const selection = FractionalSelectionMixin.helpers.elementSelection(this);
  const itemCount = this.items ? this.items.length : 0;
  const damped = FractionalSelectionMixin.helpers.dampedSelection(selection, itemCount);
  // Use a percentage so the transform will still work if screen size changes
  // (e.g., if device orientation changes).
  const left = -damped * 100;
  const transform = 'translateX(' + left + '%)';
  this.$.slidingContainer.style.webkitTransform = transform;
  this.$.slidingContainer.style.transform = transform;
}
189480
def nested_dropdown(items, text = 'post_title')
      result = []
      items.map do |item, sub_items|
        name = text == 'post_title' && !item.parent.blank? && item.parent.disabled == 'Y' ? item[text.to_sym] + " (parent: #{item.parent.post_title})" : item[text.to_sym]
        result << [('- ' * item.depth) + name.html_safe, item[:id]]
        result += nested_dropdown(sub_items, text) unless sub_items.blank?
      end
      result
    end