1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-11 17:32:41 +01:00
phorge-phorge/src/view/page/menu/PhabricatorMainMenuSearchView.php
epriestley e3f6bbfff8 Refactor the main menu in preparation for a mobile application menu
Summary:
As per discussion, this primes the existing mobile menu / menu button for "phabricator" and "application" menus.

Design here is very rough, I'm just trying to get everything laid in functionally first. It's based on `frame_v3.png` but missing a lot of touches.

Test Plan:
{F26143}
{F26144}

Reviewers: chad

Reviewed By: chad

CC: aran

Maniphest Tasks: T1960

Differential Revision: https://secure.phabricator.com/D4058
2012-12-07 13:33:03 -08:00

85 lines
1.7 KiB
PHP

<?php
final class PhabricatorMainMenuSearchView extends AphrontView {
private $user;
private $scope;
private $id;
public function setUser(PhabricatorUser $user) {
$this->user = $user;
return $this;
}
public function setScope($scope) {
$this->scope = $scope;
return $this;
}
public function getID() {
if (!$this->id) {
$this->id = celerity_generate_unique_node_id();
}
return $this->id;
}
public function render() {
$user = $this->user;
$target_id = celerity_generate_unique_node_id();
$search_id = $this->getID();
$input = phutil_render_tag(
'input',
array(
'type' => 'text',
'name' => 'query',
'id' => $search_id,
'autocomplete' => 'off',
));
$scope = $this->scope;
$target = javelin_render_tag(
'div',
array(
'id' => $target_id,
'class' => 'phabricator-main-menu-search-target',
),
'');
Javelin::initBehavior(
'phabricator-search-typeahead',
array(
'id' => $target_id,
'input' => $search_id,
'src' => '/typeahead/common/mainsearch/',
'limit' => 10,
'placeholder' => PhabricatorSearchScope::getScopePlaceholder($scope),
));
$scope_input = phutil_render_tag(
'input',
array(
'type' => 'hidden',
'name' => 'scope',
'value' => $scope,
));
$form = phabricator_render_form(
$user,
array(
'action' => '/search/',
'method' => 'POST',
),
'<div class="phabricator-main-menu-search-container">'.
$input.
'<button>Search</button>'.
$scope_input.
$target.
'</div>');
return $form;
}
}