Insert an element into collection at specified position.

@param $element
@param $position
@param null|Closure $callback

@return $this
187841
public function insert($element, $position, Closure $callback = null): self
    {
        $element = $this->createElement($element);

        if ($callback) {
            $callback($element);
        }

        if (is_string($position)) {
            $this->push($element);

            return $this->move($element->id(), $position);
        }

        if ($position >= $this->count()) {
            return $this->push($element);
        }

        if (0 === $position) {
            return $this->prepend($element);
        }

        $items = [];
        foreach ($this->all() as $index => $value) {
            if ($index === $position) {
                array_push($items, $element);
            }

            array_push($items, $value);
        }
        $this->items = $items;

        return $this;
    }
423482
public function addSortable($element, Closure $callback = null)
    {
        $this->scaffoldSortable();

        if (null === $callback) {
            $this->sortable[] = $element;
        } else {
            $this->sortable[$element] = $callback;
        }

        return $this;
    }
524213
function _insertInList($list, $element, position, $relativeElement) {
        // Determine where to insert. Default is LAST.
        var inserted = false;
        if (position) {

            // Adjust relative position for menu section positions since $relativeElement
            // has already been resolved by _getRelativeMenuItem() to a menuItem
            if (position === FIRST_IN_SECTION) {
                position = BEFORE;
            } else if (position === LAST_IN_SECTION) {
                position = AFTER;
            }

            if (position === FIRST) {
                $list.prepend($element);
                inserted = true;
            } else if ($relativeElement && $relativeElement.length > 0) {
                if (position === AFTER) {
                    $relativeElement.after($element);
                    inserted = true;
                } else if (position === BEFORE) {
                    $relativeElement.before($element);
                    inserted = true;
                }
            }
        }

        // Default to LAST
        if (!inserted) {
            $list.append($element);
        }
    }
1035810
public function setJobTitle($position)
    {
        $this->jobTitle = new Element('small', 'source');
        $this->jobTitle->textContent->push($position);

        return $this;
    }
801842
public function insert( $position, $string )
	{
		if( $position<= $this->count() && $position >=0 )
		{
			if( $position < $this->pointer )
				$this->pointer = $this->pointer + strlen( $string );
			$left	= substr( $this->toString(), 0, $position );
			$right	= substr( $this->toString(), $position );
			$this->buffer = $left.$string.$right;
		}
		return $this->toString();
	}
160492
public function insertAt($position = null)
    {
        if (null === $position) {
            $position = $this->listifyTop();
        }

        $this->insertAtPositionAndReorder($position);

        return $this;
    }
54495
function (ele) {
            var node = this[0];
            //(ele string ??)
            if (node.parentNode) {
                node.parentNode.insertBefore(ele, node.nextSibling);
            }
            return this;
        }
579855
function insertOrAppend(container, pos, el) {
    var childs = container.childNodes;
    if (pos < childs.length) {
      var refNode = childs[pos];
      container.insertBefore(el, refNode);
    } else {
      container.appendChild(el);
    }
  }
1002741
function(node, position) {

	var newParent = ( node instanceof NWTNodeInstance ) ? node : localnwt.one(node);

	newParent.insert(this, position);

	return this;
}
926097
public function withinFrame($selector, Closure $callback)
    {
        $this->driver->switchTo()->frame($this->resolver->findOrFail($selector));

        $callback($this);

        $this->driver->switchTo()->defaultContent();

        return $this;
    }
1008441
public static function insert($eventName = NULL, $callback = NULL, $priority = NULL) : Event
    {
        Listener::insert($eventName, $callback, $priority);

        return new self;
    }
1089922
public function add($element, $key = null)
    {
        if ($key == null) {
            $this->items[] = $element;

            return;
        }
        $this->set($key, $element);
    }
599237
public static By callback(final Function<SearchContext, List<WebElement>> callback) {
		if (callback == null)
			throw new IllegalArgumentException("Cannot find elements when the callback is null");

		return new ByCallback(callback);
	}
856794
@SuppressWarnings("unchecked")
    public void insert(Widget widget, int position) {

        assert widget instanceof I_CmsListItem;
        insert(widget, (Element)getElement(), position, true);
        registerItem((I)widget);
    }
1328383
public function createAddon($node = null, $position = Group\AddOn::ADDON_LEFT)
    {
        $addOn = new Group\AddOn($position);

        if (isset($node)) {
            if ($node instanceof Element) {
                $addOn->childNodes->push($node);
            } else {
                $addOn->textContent->push($node);
            }
        }

        $this->addOns->push($addOn);

        return $this->addOns->last();
    }
582587
public function addInToolbar($element,$callback=NULL){
		$tb=$this->getToolbar();
		if($element instanceof BaseWidget){
			if($element->getIdentifier()===""){
				$element->setIdentifier("tb-item-".$this->identifier."-".$tb->count());
			}
		}
		if(isset($callback)){
			if(\is_callable($callback)){
				$callback($element);
			}
		}
		return $tb->addItem($element);
	}
1047903
public function insertFieldButton($index,$caption,$visibleHover=true,$callback=null){
		$this->insertField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback));
		return $this;
	}