Modify nodes of a menu
199483
def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
        
        if breadcrumb:
            return nodes
        for node in nodes:
            if node.attr.get('hidden'):
                node.visible = False
        return nodes
934009
private void addMenuItems(Menu f, String[] m) {

        for (int i = 0; i < m.length; i++) {
            if (m[i].equals("-")) {
                f.addSeparator();
            } else {
                MenuItem item = new MenuItem(m[i]);

                item.addActionListener(this);
                f.add(item);
            }
        }
    }
342406
function updateBreadcrumb() {
        breadcrumbs.html("");
        var buffer = [];
        for (var i = 0; i < path.length; i++) {
            var node = path[i];
            if (node.type == FOLDER_TYPE) {
                var divider = "<span class='divider'>/</span>"
                if (i == path.length - 1) { //chk for last item
                    divider = "";
                }
                buffer.push("<li><a href='javascript:;' id='" + node.resourceId + "'>" + node.name + " </a> " + divider + "</li>");
            } else {
                buffer.push("<span  id='" + node.resourceId + "'>" + node.name + " </span>");
                // breadcrumbs.append("<li><span  id='"+ node.resourceId+"'>" + node.name + " </span></li>");
            }
        }

        breadcrumbs.append(buffer.join(""));

        breadcrumbs.find('a').click(function (e) {
            var id = e.currentTarget.id;
            try {
                id = parseInt(id);
            }
            catch (e) {
            }
            renderItemsByFolderId(id);
            while (true) {
                var cur = getCurrentItem();
                if (id == cur.resourceId) {
                    break;
                }
                path.pop();
            }
            updateBreadcrumb();
        });

        //handle disabling of Up node in tree when folderId is zero
        if (folderId === 0) {
            var upNode = resourceTree.find('ul li:first-child');
            if (path.length > 1) {
                upNode.removeClass('disabled');
                upNode.find('i').addClass('icon-arrow-up');
            }
            else {
                upNode.addClass('disabled');
                upNode.find('i').addClass('icon-home');
            }
        }
    }
561754
function() {

      var x, y, data, els, el, refs, actions;

      els = document.querySelectorAll('[hashedit]');
      data = [];

      for (x = 0; x < els.length; x += 1) {

        // remove action
        actions = els[x].querySelectorAll('.hashedit-edit');

        for(y=0; y<actions.length; y++) {
          actions[y].parentNode.removeChild(actions[y]);
        }

        // remove action
        actions = els[x].querySelectorAll('.hashedit-move');

        for(y=0; y<actions.length; y++) {
          actions[y].parentNode.removeChild(actions[y]);
        }

        // remove action
        actions = els[x].querySelectorAll('.hashedit-properties');

        for(y=0; y<actions.length; y++) {
          actions[y].parentNode.removeChild(actions[y]);
        }

        // remove action
        actions = els[x].querySelectorAll('.hashedit-remove');

        for(y=0; y<actions.length; y++) {
          actions[y].parentNode.removeChild(actions[y]);
        }

        // remove block menus
        actions = els[x].querySelectorAll('.hashedit-block-menu');

        for(y=0; y<actions.length; y++) {
          actions[y].parentNode.removeChild(actions[y]);
        }

        // remove block menus
        actions = els[x].querySelectorAll('.hashedit-element-menu');

        for(y=0; y<actions.length; y++) {
          actions[y].parentNode.removeChild(actions[y]);
        }

        // remove attributes
        actions = els[x].querySelectorAll('[hashedit-block]');

        for(y=0; y<actions.length; y++) {
          actions[y].removeAttribute('hashedit-block');
        }

        // remove attributes
        actions = els[x].querySelectorAll('[hashedit-element]');

        for(y=0; y<actions.length; y++) {
          actions[y].removeAttribute('hashedit-element');
        }

        // remove attributes
        actions = els[x].querySelectorAll('[hashedit-sortable]');

        for(y=0; y<actions.length; y++) {
          actions[y].removeAttribute('hashedit-sortable');
        }

        // remove attributes
        actions = els[x].querySelectorAll('[hashedit-empty]');

        for(y=0; y<actions.length; y++) {
          actions[y].removeAttribute('hashedit-empty');
        }

        // remove attributes
        actions = els[x].querySelectorAll('[contenteditable]');

        for(y=0; y<actions.length; y++) {
          actions[y].removeAttribute('contenteditable');
        }

        // remove attributes
        actions = els[x].querySelectorAll('[current-hashedit-element]');

        for(y=0; y<actions.length; y++) {
          actions[y].removeAttribute('current-hashedit-element');
        }


        el = {
          'selector': els[x].getAttribute('hashedit-selector'),
          'html': els[x].innerHTML
        };

        if(hashedit.debug === true) {
          console.log('update array');
          console.log(el);
        }

        data.push(el);
      }

      return {
        url: hashedit.url,
        changes: data
      };

    }
233834
function replaceNode(replacementNode, node) {
  remove(replacementNode)
  node.parentNode.insertBefore(replacementNode, node)
  remove(node)
}
517634
def addMenuLabel(menu, text):
    """"""
    qaw = QWidgetAction(menu)
    lab = QLabel(text, menu)
    qaw.setDefaultWidget(lab)
    lab.setAlignment(Qt.AlignCenter)
    lab.setFrameShape(QFrame.StyledPanel)
    lab.setFrameShadow(QFrame.Sunken)
    menu.addAction(qaw)
    return lab
563320
function modify( &$tpl, &$operatorName, &$operatorParameters, &$rootNamespace,
                     &$currentNamespace, &$operatorValue, &$namedParameters )
    {
       switch ( $operatorName )
       {
            case 'opengraph':
            {
                $operatorValue = $this->generateOpenGraphTags( $namedParameters['nodeid'] );
                break;
            }
            case 'language_code':
            {
                $operatorValue = eZLocale::instance()->httpLocaleCode();
                break;
            }
       }
    }
396209
function(nodes, options) {
        this.nodes = $(nodes);
        options = this.setOptions(options);
        this.createWrapper();

        // Remove title attributes
        if (options.getTitle === 'title') {
            options.getTitle = 'data-' + this.keyName + '-title';

            this.nodes.each(function(i, node) {
                $(node).attr(options.getTitle, $(node).attr('title')).removeAttr('title');
            });
        }

        // Initialize events
        this.addEvents([
            ['{mode}', 'document', 'onShowToggle', '{selector}'],
            ['resize', 'window', $.debounce(this.onHide.bind(this))]
        ]);

        if (options.mode === 'click') {
            this.addEvent('clickout', 'document', 'hide');
        } else {
            this.addEvent('mouseleave', 'document', 'hide', '{selector}');
        }

        this.initialize();
    }
1277934
def add_changes_markup(dom, ins_nodes, del_nodes):
    
    # add markup for inserted and deleted sections
    for node in reversed(del_nodes):
        # diff algorithm deletes nodes in reverse order, so un-reverse the
        # order for this iteration
        insert_or_append(node.orig_parent, node, node.orig_next_sibling)
        wrap(node, 'del')
    for node in ins_nodes:
        wrap(node, 'ins')
    # Perform post-processing and cleanup.
    remove_nesting(dom, 'del')
    remove_nesting(dom, 'ins')
    sort_del_before_ins(dom)
    merge_adjacent(dom, 'del')
    merge_adjacent(dom, 'ins')
677280
function updateBreadcrumbs(nodeArray, percentageString) {

  // Data join; key function combines name and depth (= position in sequence).
  var g = d3.select("#trail")
      .selectAll("g")
      .data(nodeArray, function(d) { return d.name + d.depth; });

  // Add breadcrumb and label for entering nodes.
  var entering = g.enter().append("svg:g");

  entering.append("svg:polygon")
      .attr("points", breadcrumbPoints)
      .style("fill", function(d) { return colors[d.name]; });

  entering.append("svg:text")
      .attr("x", (b.w + b.t) / 2)
      .attr("y", b.h / 2)
      .attr("dy", "0.35em")
      .attr("text-anchor", "middle")
      .text(function(d) { return d.name; });

  // Set position for entering and updating nodes.
  g.attr("transform", function(d, i) {
    return "translate(" + i * (b.w + b.s) + ", 0)";
  });

  // Remove exiting nodes.
  g.exit().remove();

  // Now move and update the percentage at the end.
  d3.select("#trail").select("#endlabel")
      .attr("x", (nodeArray.length + 0.5) * (b.w + b.s))
      .attr("y", b.h / 2)
      .attr("dy", "0.35em")
      .attr("text-anchor", "middle")
      .text(percentageString);

  // Make the breadcrumb trail visible, if it's hidden.
  d3.select("#trail")
      .style("visibility", "");

}
732269
function updatePossibleNavigations(element) {
  let canSelectNext;
  let canSelectPrevious;
  const items = element.items;
  if (items == null || items.length === 0) {
    // No items to select.
    canSelectNext = false;
    canSelectPrevious = false;
  } if (element.selectionWraps) {
    // Since there are items, can always go next/previous.
    canSelectNext = true;
    canSelectPrevious = true;
  } else {
    const index = element.selectedIndex;
    if (index < 0 && items.length > 0) {
      // Special case. If there are items but no selection, declare that it's
      // always possible to go next/previous to create a selection.
      canSelectNext = true;
      canSelectPrevious = true;
    } else {
      // Normal case: we have an index in a list that has items.
      canSelectPrevious = (index > 0);
      canSelectNext = (index < items.length - 1);
    }
  }
  if (element.canSelectNext !== canSelectNext) {
    element.canSelectNext = canSelectNext;
  }
  if (element.canSelectPrevious !== canSelectPrevious) {
    element.canSelectPrevious = canSelectPrevious;
  }
}
1110355
function setMenu() {
  var url = document.location.href;
  // strip extension
  url = stripExtension(url);
  
  var ulElement = document.getElementById("menu");
  var links = ulElement.getElementsByTagName("A");
  var i;
  for(i = 0; i < links.length; i++) {
    if(url.indexOf(stripExtension(links[i].href)) == 0) {
      links[i].className = "active_menu";
      return;
    }
  }
}
376091
private void adjustOverhead(final ObjectGraphNode node) {
		ObjectGraphNode[] originalChildren = new ObjectGraphNode[node.getChildCount()];
		int dataSize = 0;

		for (int i = 0; i < node.getChildCount(); i++) {
			ObjectGraphNode childNode = (ObjectGraphNode) node.getChildAt(i);
			dataSize += childNode.getSize();
			originalChildren[i] = childNode;
		}

		node.removeAll();

		// Figure out the list overhead.
		// All the original children will be included refs, as they have already been visited.
		visitComplexType(node);
		node.setSize(node.getSize() - originalChildren.length * ObjectGraphNode.OBJREF_SIZE);

		// re-attach the old children
		node.removeAll();

		for (int i = 0; i < originalChildren.length; i++) {
			node.add(originalChildren[i]);
		}
	}
1204651
private void prepareMenu(Container menu, Component component, int x, int y)
    {
        int n = menu.getComponentCount();
        for (int i=0; i<n; i++)
        {
            Component menuComponent = popupMenu.getComponent(i);
            if (menuComponent instanceof JMenu)
            {
                JMenu subMenu = (JMenu)menuComponent;
                prepareMenu(subMenu, component, x, y);
            }
            if (menuComponent instanceof AbstractButton)
            {
                AbstractButton abstractButton = (AbstractButton)menuComponent;
                Action action = abstractButton.getAction();
                if (action != null && action instanceof LocationBasedAction)
                {
                    LocationBasedAction locationBasedAction = 
                        (LocationBasedAction)action;
                    locationBasedAction.prepareShow(component, x, y);
                }
            }
        }
    }
753831
private void updateMenuIcon() {
        List<Image> iconList = null;
        if (rootParent instanceof JFrame) {
            iconList = ((JFrame) rootParent).getIconImages();
        } else if (rootParent instanceof JDialog) {
            iconList = ((JDialog) rootParent).getIconImages();
        }
        
        Image frameIcon = iconList != null && iconList.size() > 0 ? iconList.get(0) : null;

        SeaGlassContext context   = getContext(this);

        if (frameIcon != null) {
            Dimension maxSize   = (Dimension) context.getStyle().get(context, "InternalFrameTitlePane.maxFrameIconSize");
            int       maxWidth  = 16;
            int       maxHeight = 16;

            if (maxSize != null) {
                maxWidth  = maxSize.width;
                maxHeight = maxSize.height;
            }
            menuButton.setIcon(new ImageIcon(frameIcon.getScaledInstance(maxWidth, maxHeight, Image.SCALE_SMOOTH)));
        }

        context.dispose();
    }
260956
function (items) {
		
			var i, length;
		
			// remove previous <option>s nodes
			while (this.el.childNodes.length > 0) {
				this.el.removeChild(this.el.childNodes[0]);
			}
		
			// add new options
			for (i = 0, length = items.length; i < length ; i += 1) {
				this.addChoice({ value: items[i][this.options.valueKey], label: items[i][this.options.labelKey] });
			}
		}
967534
public void replaceMenuById(SubMenuItem subMenu, MenuItem toReplace) {
        synchronized (subMenuItems) {
            ArrayList<MenuItem> list = subMenuItems.get(subMenu);
            int idx = -1;
            for (int i = 0; i < list.size(); ++i) {
                if (list.get(i).getId() == toReplace.getId()) {
                    idx = i;
                }
            }

            if (idx != -1) {
                MenuItem oldItem = list.set(idx, toReplace);
                if (toReplace.hasChildren()) {
                    ArrayList<MenuItem> items = subMenuItems.remove(oldItem);
                    subMenuItems.put(toReplace, items);
                }
            }

        }
    }