reorderItems action
AJAX POST
483662
public function reorderItems()
    {
        if (!$this->request->isAll(['ajax', 'post'])) {
            throw new MethodNotAllowedException();
        }

        if (empty($this->request->data)) {
            throw new BadRequestException();
        }

        $this->request->data = Hash::map($this->request->data, '{n}', function($item) {
            if ($item['parent_id'] === 'null') {
                $item['parent_id'] = null;
            }
            return $item;
        });

        // save the new language positions
        $menuItems = $this->MenuItems->patchEntities(
            $this->MenuItems->find('threaded'),
            $this->request->data
        );
        $this->MenuItems->connection()->begin();
        foreach ($menuItems as $menuItem) {
            $this->MenuItems->behaviors()->unload('Tree');
            if (!$this->MenuItems->save($menuItem)) {
                $this->MenuItems->connection()->rollback();
                break;
            }
        }
        if ($this->MenuItems->connection()->inTransaction()) {
            $this->MenuItems->connection()->commit();
            $status = 'success';
            $flashMessage = __d('wasabi_core', 'The menu item positions have been updated.');
        } else {
            $status = 'error';
            $flashMessage = $this->dbErrorMessage;
        }

        $this->set([
            'status' => $status,
            'flashMessage' => $flashMessage,
            '_serialize' => ['status', 'flashMessage']
        ]);
    }
369086
function initRepeaterActions () {
		var loadDelays = ['300', '600', '900', '1200'];

		var sort = function (data, sortProperty, sortDirection) {
			var sortedData = _.sortBy(data, function (item) {
				return item[sortProperty];
			});

			// sort direction
			if (sortDirection === 'desc') {
				sortedData = sortedData.reverse();
			}

			return sortedData;
		};

		function getSampleDataSet (options, callback) {
			var resp = {
				count: data.repeater.listData.length,
				items: [],
				page: options.pageIndex
			};

			// get start and end limits for JSON
			var i, l;
			resp.pages = Math.ceil(resp.count / (options.pageSize || 50));

			i = options.pageIndex * (options.pageSize || 50);
			l = i + (options.pageSize || 50);
			l = (l <= resp.count) ? l : resp.count;
			resp.start = i + 1;
			resp.end = l;

			// setup columns for list view
			resp.columns = [
				{
					label: 'Common Name',
					property: 'commonName',
					sortable: true
				},
				{
					label: 'Latin Name',
					property: 'latinName',
					sortable: true
				},
				{
					label: 'Appearance',
					property: 'appearance',
					sortable: true
				},
				{
					label: 'Sound',
					property: 'sound',
					sortable: true
				}
			];

			// add sample items to datasource
			for (i; i < l; i++) {
				// from data.js
				resp.items.push(data.repeater.listData[i]);
			}

			resp.items = sort(resp.items, options.sortProperty, options.sortDirection);

			// call and simulate latency
			setTimeout(function () {
				callback(resp);
			}, loadDelays[Math.floor(Math.random() * 4)]);

		}

		// initialize the repeater
		var repeaterActions = $('#myRepeaterActions');
		repeaterActions.repeater({
			list_noItemsHTML: '<span>foo</span>',
			list_highlightSortedColumn: true,
			list_selectable: 'multi',
			list_actions: {
				width: 37,
				items: [
					{
						name: 'edit',
						html: '<span class="glyphicon glyphicon-pencil"></span> Edit'
					},
					{
						name: 'copy',
						html: '<span class="glyphicon glyphicon-copy"></span> Copy'
					},
					{
						name: 'delete',
						html: '<span class="glyphicon glyphicon-trash"></span> Delete',
						clickAction: function (helpers, callback, e) {
							console.log('hey it worked');
							console.log(helpers);
							e.preventDefault();
							callback();
						}
					}
				]
			},
			// setup your custom datasource to handle data retrieval;
			// responsible for any paging, sorting, filtering, searching logic
			dataSource: getSampleDataSet
		});
	}
1064543
function reorder($expr, $direction = null)
    {
        $this->order(null);
        $this->order($expr, $direction);

        return $this;
    }
30900
function postForm({ url, payload, useBearer }) {
  return ajax({
    url,
    body: makeFormData( payload ),
    method: 'post',
    useBearer
  })
}
734837
protected function doReorder($new_order)
    {
        if (!$this->_original) {
            return;
        }

        $pages = Grav::instance()['pages'];
        $pages->init();

        $this->_original->path($this->path());

        $parent = $this->parent();
        $siblings = $parent ? $parent->children() : null;

        if ($siblings) {
            $siblings->order('slug', 'asc', $new_order);

            $counter = 0;

            // Reorder all moved pages.
            foreach ($siblings as $slug => $page) {
                $order = (int)trim($page->order(), '.');
                $counter++;

                if ($order) {
                    if ($page->path() === $this->path() && $this->folderExists()) {
                        // Handle current page; we do want to change ordering number, but nothing else.
                        $this->order($counter);
                        $this->save(false);
                    } else {
                        // Handle all the other pages.
                        $page = $pages->get($page->path());
                        if ($page && $page->folderExists() && !$page->_action) {
                            $page = $page->move($this->parent());
                            $page->order($counter);
                            $page->save(false);
                        }
                    }
                }
            }
        }
    }
811615
def refresh_content(self, order=None, name=None):
        
        order = order or self.content.order
        url = name or self.content.name

        # Hack to allow an order specified in the name by prompt_subreddit() to
        # override the current default
        if order == 'ignore':
            order = None

        with self.term.loader('Refreshing page'):
            self.content = SubmissionContent.from_url(
                self.reddit, url, self.term.loader, order=order,
                max_comment_cols=self.config['max_comment_cols'])
        if not self.term.loader.exception:
            self.nav = Navigator(self.content.get, page_index=-1)
516930
function(e) {
        Dom.setStyle(this.id, "visibility", "");
        
        // Fire the reordered event if position in list has changed
        var clickEl = this.getEl();
        var newIndex = inputEx.indexOf(clickEl ,clickEl.parentNode.childNodes);
        if(this._originalIndex != newIndex) {
           this._list.onReordered(this._originalIndex, newIndex);
        }
    }
1255055
def reorder(things, ids)
      ordered_things = []
      ids.each do |id|
        thing = things.find{ |t| t.id.to_s == id.to_s }
        ordered_things |= [thing] if thing
      end
      ordered_things
    end
533095
function nextPostHook(res) {
                    response = checkResponse(res, response);

                    if (currentPost + 1 < totalPost && self.__hooksEnabled !== false) {
                        currentPost += 1;

                        // Reference to current post hook
                        const currPost = posts[currentPost];
                        const hookMethod = currPost.displayName || currPost.name;
                        scope = getScope(self, name, res, hookMethod, 'post');

                        // Recursively call all the "post" hooks
                        return currPost.call(scope, response).then(nextPostHook, postHookErrorHandler);
                    }

                    /**
                     * All "post" hook process done.
                     * If the response has an "__override" property it will be our response
                     */
                    if (is.object(response) && {}.hasOwnProperty.call(response, '__override')) {
                        response = response.__override;
                    }

                    return resolveFn(response);
                }
801888
function reorderEvents( node, eventName ) {
		if( node.addEventListener || !node.shoestringData || !node.shoestringData.events ) {
			// add event listner obviates the need for all the callback order juggling
			return;
		}

		var otherEvents = node.shoestringData.events[ eventName ] || [];
		for( var j = otherEvents.length - 1; j >= 0; j-- ) {
			// DOM Events only, Custom events maintain their own order internally.
			if( !otherEvents[ j ].isCustomEvent ) {
				node.detachEvent( "on" + eventName, otherEvents[ j ].callback );
				node.attachEvent( "on" + eventName, otherEvents[ j ].callback );
			}
		}
	}
994698
function postRouter(sessions, controllers, nonObjTemplatelogLevel, req, res, next) {

    if (req.originalUrl.match(/amorphic\/xhr\?path\=/) && url.parse(req.originalUrl, true).query.form && req.method === 'POST') {
        processPost(req, res, sessions, controllers, nonObjTemplatelogLevel);
    }
    else {
        next();
    }
}
1283254
function sortPosts (posts) {
  return Object.keys(posts).map(function (post) { return posts[post]; })
    .sort(function (a,b) {
      if ( a.date < b.date ) return 1;
      if ( a.date > b.date ) return -1;
      return 0;
    });
}
931275
public function handleBulkActions($redirect_to, $action_name, $post_ids) {
        if('ilab_rekognizer_process' === $action_name) {
            $posts_to_import = [];
            if (count($post_ids) > 0) {
                foreach($post_ids as $post_id) {
                    $meta = wp_get_attachment_metadata($post_id);
                    if (!empty($meta) && !isset($meta['s3'])) {
                        continue;
                    }

                    $mime = get_post_mime_type($post_id);
                    if (!in_array($mime, ['image/jpeg', 'image/jpg', 'image/png'])) {
                        continue;
                    }

                    $posts_to_import[] = $post_id;
                }
            }

            if(count($posts_to_import) > 0) {
                set_site_transient($this->batchPrefix().'_post_selection', $posts_to_import, 10);
                return 'admin.php?page='.$this->menuSlug();
            }
        }

        return $redirect_to;
    }
1012651
def dfs_postorder(self, reverse=False):
        """"""
        stack = deque()
        stack.append(self)
        visited = set()
        while stack:
            node = stack.pop()
            if node in visited:
                yield node
            else:
                visited.add(node)
                stack.append(node)
                if hasattr(node, "childs"):
                    if reverse:
                        stack.extend(node.childs)
                    else:
                        stack.extend(node.childs[::-1])
565533
function sendReload() {
  if (saveChecksum) {
    $.ajax({
      url: jsbin.getURL() + '/reload',
      data: {
        code: jsbin.state.code,
        revision: jsbin.state.revision,
        checksum: saveChecksum
      },
      type: 'post'
    });
  }
}
634215
private void reorder()
    {
        if(getTransaction().isOrdering() && needsCommit && mhtObjectEnvelopes.size() > 1)
        {
            ObjectEnvelopeOrdering ordering = new ObjectEnvelopeOrdering(mvOrderOfIds, mhtObjectEnvelopes);
            ordering.reorder();
            Identity[] newOrder = ordering.getOrdering();

            mvOrderOfIds.clear();
            for(int i = 0; i < newOrder.length; i++)
            {
                mvOrderOfIds.add(newOrder[i]);
            }
        }
    }
1211644
private void handleRenderRedirect(final PrintWriter writer) {
		UIContext uic = UIContextHolder.getCurrent();
		// Redirect user to error page
		LOG.warn("User will be redirected to " + redirectUrl);

		// Setup response with redirect
		getResponse().setContentType(WebUtilities.CONTENT_TYPE_XML);
		writer.write(XMLUtil.getXMLDeclarationWithThemeXslt(uic));

		writer.print("<ui:ajaxresponse ");
		writer.print(XMLUtil.UI_NAMESPACE);
		writer.print(">");
		writer.print("<ui:ajaxtarget id=\"" + triggerId + "\" action=\"replace\">");

		// Redirect URL
		writer.print("<ui:redirect url=\"" + redirectUrl + "\" />");

		writer.print("</ui:ajaxtarget>");
		writer.print("</ui:ajaxresponse>");
	}