Skip to content

Commit

Permalink
Do initial category selection based on category parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
zachmullen committed Feb 24, 2012
1 parent 4728e00 commit aa0c69a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
10 changes: 6 additions & 4 deletions controllers/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ function indexAction()
sort($this->view->allCategories);

$avalue = function($k, $a, $default) { return array_key_exists($k, $a) ? $a[$k] : $default; };
$params = $this->_getAllParams();

$this->view->os = $avalue('os', $_GET, '');
$this->view->arch = $avalue('arch', $_GET, '');
$this->view->release = $avalue('release', $_GET, '');
$this->view->revision = $avalue('revision', $_GET, '');
$this->view->os = $avalue('os', $params, '');
$this->view->arch = $avalue('arch', $params, '');
$this->view->release = $avalue('release', $params, '');
$this->view->revision = $avalue('revision', $params, '');
$this->view->category = $avalue('category', $params, '');
}

/**
Expand Down
9 changes: 7 additions & 2 deletions public/js/index/index.index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var midas = midas || {};
midas.slicerappstore = midas.slicerappstore || {};
midas.slicerappstore.category = '';

var json = null;

Expand Down Expand Up @@ -141,6 +140,7 @@ $(document).ready(function() {
midas.slicerappstore.arch = json.arch;
midas.slicerappstore.release = json.release;
midas.slicerappstore.revision = json.revision;
midas.slicerappstore.category = json.category;

if(json.slicerView) {
createNotice = function() {}; //dummy function definition to prevent exceptions
Expand Down Expand Up @@ -180,7 +180,7 @@ $(document).ready(function() {
midas.slicerappstore.selectedCategory = $(this);
$(this).addClass('selectedCategory');
midas.slicerappstore.applyFilter();
}).addClass('selectedCategory');
});

// Enable filtering by specific categories
$('li.categoryControl').click(function() {
Expand All @@ -191,6 +191,11 @@ $(document).ready(function() {
midas.slicerappstore.applyFilter();
});

var selector = midas.slicerappstore.category == '' ?
'li#categoryAll' :
'li.categoryControl[name="'+midas.slicerappstore.category+'"]';
midas.slicerappstore.selectedCategory = $(selector).addClass('selectedCategory');

// Fetch our results based on the initial settings
midas.slicerappstore.applyFilter();
});
3 changes: 2 additions & 1 deletion views/index/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ else
'os' => $this->os,
'arch' => $this->arch,
'release' => $this->release,
'revision' => $this->revision));
'revision' => $this->revision,
'category' => $this->category));
?>
</div>

0 comments on commit aa0c69a

Please sign in to comment.