layout has more widget-like setup now. side playlist reused in search.
This commit is contained in:
parent
565d789baa
commit
5795871bcc
|
@ -65,7 +65,7 @@ $pages = array(
|
|||
'label' => 'Search',
|
||||
'module' => 'default',
|
||||
'controller' => 'Search',
|
||||
'action' => 'display',
|
||||
'action' => 'index',
|
||||
'resource' => 'search'
|
||||
)
|
||||
)
|
||||
|
|
|
@ -24,16 +24,23 @@ class LibraryController extends Zend_Controller_Action
|
|||
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->headScript()->appendFile('/js/contextmenu/jquery.contextMenu.js','text/javascript');
|
||||
$this->view->headScript()->appendFile('/js/campcaster/library/library.js','text/javascript');
|
||||
|
||||
$this->view->headLink()->appendStylesheet('/css/jquery.contextMenu.css');
|
||||
|
||||
$this->_helper->layout->setLayout('library');
|
||||
|
||||
$this->_helper->actionStack('context-menu', 'library');
|
||||
$this->_helper->actionStack('contents', 'library');
|
||||
$this->_helper->actionStack('index', 'sideplaylist');
|
||||
}
|
||||
|
||||
public function contextMenuAction()
|
||||
{
|
||||
$this->_helper->viewRenderer->setResponseSegment('library');
|
||||
|
||||
$this->view->headScript()->appendFile('/js/campcaster/library/context-menu.js','text/javascript');
|
||||
$this->view->headScript()->appendFile('/js/contextmenu/jquery.contextMenu.js','text/javascript');
|
||||
$this->view->headLink()->appendStylesheet('/css/jquery.contextMenu.css');
|
||||
|
||||
$pl_sess = $this->pl_sess;
|
||||
$contextMenu;
|
||||
|
||||
|
@ -43,8 +50,6 @@ class LibraryController extends Zend_Controller_Action
|
|||
$contextMenu[] = array('action' => '/Playlist/add-item', 'text' => 'Add To Playlist');
|
||||
|
||||
$this->view->menu = $contextMenu;
|
||||
|
||||
$this->_helper->actionStack('contents', 'library');
|
||||
}
|
||||
|
||||
public function deleteAction()
|
||||
|
@ -77,12 +82,12 @@ class LibraryController extends Zend_Controller_Action
|
|||
|
||||
public function contentsAction()
|
||||
{
|
||||
$this->_helper->viewRenderer->setResponseSegment('library');
|
||||
|
||||
$query["category"] = $this->_getParam('ob', "dc:creator");
|
||||
$query["order"] = $this->_getParam('order', "asc");
|
||||
|
||||
$this->view->files = StoredFile::getFiles($query);
|
||||
|
||||
$this->_helper->actionStack('index', 'sideplaylist');
|
||||
}
|
||||
|
||||
public function searchAction()
|
||||
|
|
|
@ -14,6 +14,7 @@ class SearchController extends Zend_Controller_Action
|
|||
|
||||
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
||||
$ajaxContext->addActionContext('newfield', 'html')
|
||||
->addActionContext('display', 'json')
|
||||
->initContext();
|
||||
|
||||
$this->form = new Application_Form_AdvancedSearch();
|
||||
|
@ -21,7 +22,12 @@ class SearchController extends Zend_Controller_Action
|
|||
|
||||
public function indexAction()
|
||||
{
|
||||
// action body
|
||||
$this->_helper->layout->setLayout('search');
|
||||
|
||||
$this->_helper->actionStack('context-menu', 'library');
|
||||
$this->_helper->actionStack('display', 'search');
|
||||
$this->_helper->actionStack('contents', 'library');
|
||||
$this->_helper->actionStack('index', 'sideplaylist');
|
||||
}
|
||||
|
||||
public function displayAction()
|
||||
|
@ -29,11 +35,15 @@ class SearchController extends Zend_Controller_Action
|
|||
$this->view->headScript()->appendFile('/js/campcaster/library/advancedsearch.js','text/javascript');
|
||||
$this->view->headLink()->appendStylesheet('/css/library_search.css');
|
||||
|
||||
$this->_helper->viewRenderer->setResponseSegment('search');
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
||||
$this->form = new Application_Form_AdvancedSearch();
|
||||
$form = $this->form;
|
||||
|
||||
// Form has not been submitted - pass to view and return
|
||||
if (!$this->getRequest()->isPost()) {
|
||||
// Form has not been submitted - displayed using layouts
|
||||
if (!$request->isPost()) {
|
||||
$sub = new Application_Form_AdvancedSearchRow(1);
|
||||
$form->addSubForm($sub, 'row_1');
|
||||
$form->getSubForm('row_1')->removeDecorator('DtDdWrapper');
|
||||
|
@ -43,18 +53,20 @@ class SearchController extends Zend_Controller_Action
|
|||
}
|
||||
|
||||
// Form has been submitted - run data through preValidation()
|
||||
$form->preValidation($_POST);
|
||||
$form->preValidation($request->getPost());
|
||||
|
||||
if (!$form->isValid($_POST)) {
|
||||
$this->view->form = $form;
|
||||
if (!$form->isValid($request->getPost())) {
|
||||
$this->view->form = $form->__toString();
|
||||
return;
|
||||
}
|
||||
|
||||
// Form is valid
|
||||
$this->view->form = $form;
|
||||
// form was submitted, send back strings to json response.
|
||||
//$this->view->form = $form->__toString();
|
||||
|
||||
$info = $form->getValues();
|
||||
$info = $form->getValues();
|
||||
$this->view->files = StoredFile::searchFiles($info);
|
||||
$this->view->results = $this->view->render('library/update.phtml');
|
||||
unset($this->view->files);
|
||||
}
|
||||
|
||||
public function newfieldAction()
|
||||
|
|
|
@ -17,7 +17,8 @@ class SideplaylistController extends Zend_Controller_Action
|
|||
|
||||
public function indexAction()
|
||||
{
|
||||
$this->_helper->layout->setLayout('sidebar');
|
||||
$this->view->headScript()->appendFile('/js/campcaster/library/spl.js','text/javascript');
|
||||
|
||||
$this->_helper->viewRenderer->setResponseSegment('spl');
|
||||
|
||||
$pl_sess = $this->pl_sess;
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
<body>
|
||||
|
||||
<div id="nav"><?php echo $this->navigation()->menu()->setRenderInvisible(true) ?></div>
|
||||
|
||||
<div id="content"><?php echo $this->layout()->content ?></div>
|
||||
|
||||
<div id="library_content"><?php echo $this->layout()->library ?></div>
|
||||
|
||||
<div id="side_playlist"><?php echo $this->layout()->spl ?></div>
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<!-- application/layouts/scripts/layout.phtml -->
|
||||
<?php echo $this->doctype() ?>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Campcaster</title>
|
||||
<?php echo $this->headScript() ?>
|
||||
<?php echo $this->headLink() ?>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="nav"><?php echo $this->navigation()->menu()->setRenderInvisible(true) ?></div>
|
||||
|
||||
<div id="search"><?php echo $this->layout()->search ?></div>
|
||||
|
||||
<div id="library_content"><?php echo $this->layout()->library ?></div>
|
||||
|
||||
<div id="side_playlist"><?php echo $this->layout()->spl ?></div>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,2 @@
|
|||
<?php
|
||||
echo $this->partialLoop('library/libraryTablePartial.phtml', $this->files);
|
|
@ -1,29 +1,6 @@
|
|||
<?php
|
||||
|
||||
$this->form->setAction($this->url());
|
||||
echo $this->form;
|
||||
?>
|
||||
<span id="search_add">Add</span>
|
||||
<span id="search_submit">Submit</span>
|
||||
|
||||
<?php
|
||||
if($this->files) {
|
||||
?>
|
||||
<table id="library_display">
|
||||
<tr>
|
||||
<th><span class="title">Title</span></th>
|
||||
<th><span class="artist">Artist</span></th>
|
||||
<th><span class="album">Album</span></th>
|
||||
<th><span class="track">Track</span></th>
|
||||
<th><span class="length">Length</span></th>
|
||||
</tr>
|
||||
<?php
|
||||
echo $this->partialLoop('library/libraryTablePartial.phtml', $this->files);
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
else {
|
||||
echo "<div>No Results</div>";
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -28,15 +28,49 @@ function ajaxAddField() {
|
|||
});
|
||||
}
|
||||
|
||||
function searchLibrary() {
|
||||
var url, data;
|
||||
|
||||
url = '/Search/display/format/json';
|
||||
data = $("form").serializeArray();
|
||||
|
||||
$.post(url, data, function(json){
|
||||
|
||||
if(json.form) {
|
||||
$("#search")
|
||||
.empty()
|
||||
.append(json.form);
|
||||
}
|
||||
|
||||
|
||||
if(json.results) {
|
||||
$("#library_display tr:not(:first-child)").remove();
|
||||
$("#library_display tbody").append(json.results);
|
||||
|
||||
$("#library_display tr:not(:first-child)")
|
||||
.contextMenu({menu: 'myMenu'}, contextMenu)
|
||||
.draggable({
|
||||
helper: 'clone'
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$("#search_add").click(ajaxAddField);
|
||||
$("#search_submit").click(function(){
|
||||
$("form").submit();
|
||||
});
|
||||
$("#search_submit").click(searchLibrary);
|
||||
|
||||
$('[id^="fieldset-row_"]').each(function(i, el){
|
||||
addRemove(el);
|
||||
});
|
||||
|
||||
$("#library_display tr:not(:first-child)")
|
||||
.contextMenu({menu: 'myMenu'}, contextMenu)
|
||||
.draggable({
|
||||
helper: 'clone'
|
||||
});
|
||||
|
||||
setUpSPL();
|
||||
});
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
function contextMenu(action, el, pos) {
|
||||
var method = action.split('/').pop(),
|
||||
url;
|
||||
|
||||
if (method === 'delete') {
|
||||
url = action + '/format/json';
|
||||
url = url + '/id/' + $(el).attr('id');
|
||||
$.post(url, deleteItem);
|
||||
}
|
||||
else if (method === 'add-item') {
|
||||
url = action + '/format/json';
|
||||
url = url + '/id/' + $(el).attr('id');
|
||||
$.post(url, setSPLContent);
|
||||
}
|
||||
}
|
|
@ -1,19 +1,3 @@
|
|||
function contextMenu(action, el, pos) {
|
||||
var method = action.split('/').pop(),
|
||||
url;
|
||||
|
||||
if (method === 'delete') {
|
||||
url = action + '/format/json';
|
||||
url = url + '/id/' + $(el).attr('id');
|
||||
$.post(url, deleteItem);
|
||||
}
|
||||
else if (method === 'add-item') {
|
||||
url = action + '/format/json';
|
||||
url = url + '/id/' + $(el).attr('id');
|
||||
$.post(url, setSPLContent);
|
||||
}
|
||||
}
|
||||
|
||||
function deleteItem(json){
|
||||
var id;
|
||||
|
||||
|
@ -35,75 +19,6 @@ function setLibraryContents(data){
|
|||
);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------------
|
||||
//Side Playlist Functions
|
||||
//--------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function setSPLContent(json) {
|
||||
|
||||
if(json.message) {
|
||||
alert(json.message);
|
||||
return;
|
||||
}
|
||||
|
||||
$('#spl_name').empty()
|
||||
.append(json.name);
|
||||
$('#spl_length').empty()
|
||||
.append(json.length);
|
||||
$('#spl_sortable').empty()
|
||||
.append(json.html);
|
||||
}
|
||||
|
||||
function addSPLItem(event, ui){
|
||||
|
||||
var url, tr, id;
|
||||
|
||||
tr = ui.helper;
|
||||
|
||||
if(tr.get(0).tagName === 'LI')
|
||||
return;
|
||||
|
||||
id = tr.attr('id');
|
||||
|
||||
url = '/Playlist/add-item/format/json';
|
||||
url = url + '/id/'+id;
|
||||
|
||||
$.post(url, setSPLContent);
|
||||
}
|
||||
|
||||
function deleteSPLItem(){
|
||||
|
||||
var url, pos;
|
||||
|
||||
url = '/Playlist/delete-item/format/json/view/spl';
|
||||
|
||||
pos = $('form[name="SPL"]').find(':checked').not('input[name="all"]').map(function() {
|
||||
return "/pos/" + $(this).attr('name');
|
||||
}).get().join("");
|
||||
|
||||
url = url + pos;
|
||||
|
||||
$.post(url, setSPLContent);
|
||||
}
|
||||
|
||||
function moveSPLItem(event, ui) {
|
||||
var li, newPos, oldPos, url;
|
||||
|
||||
li = ui.item;
|
||||
|
||||
newPos = li.index();
|
||||
oldPos = li.attr('id').split("_").pop();
|
||||
|
||||
url = '/Playlist/move-item'
|
||||
url = url + '/format/json';
|
||||
url = url + '/view/spl';
|
||||
url = url + '/oldPos/' + oldPos;
|
||||
url = url + '/newPos/' + newPos;
|
||||
|
||||
$.post(url, setSPLContent);
|
||||
}
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$("#library_display tr:first-child span.title").data({'ob': 'dc:title', 'order' : 'asc'});
|
||||
|
@ -139,15 +54,6 @@ $(document).ready(function() {
|
|||
helper: 'clone'
|
||||
});
|
||||
|
||||
$("#spl_sortable").sortable();
|
||||
$("#spl_sortable" ).bind( "sortstop", moveSPLItem);
|
||||
$("#spl_remove_selected").click(deleteSPLItem);
|
||||
|
||||
$("#side_playlist").droppable();
|
||||
$("#side_playlist" ).bind( "drop", addSPLItem);
|
||||
|
||||
$('input[name="all"]').click(function(){
|
||||
$('form[name="SPL"]').find('input').attr("checked", $(this).attr("checked"));
|
||||
});
|
||||
setUpSPL();
|
||||
|
||||
});
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
//--------------------------------------------------------------------------------------------------------------------------------
|
||||
//Side Playlist Functions
|
||||
//--------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function setSPLContent(json) {
|
||||
|
||||
if(json.message) {
|
||||
alert(json.message);
|
||||
return;
|
||||
}
|
||||
|
||||
$('#spl_name').empty()
|
||||
.append(json.name);
|
||||
$('#spl_length').empty()
|
||||
.append(json.length);
|
||||
$('#spl_sortable').empty()
|
||||
.append(json.html);
|
||||
}
|
||||
|
||||
function addSPLItem(event, ui){
|
||||
|
||||
var url, tr, id;
|
||||
|
||||
tr = ui.helper;
|
||||
|
||||
if(tr.get(0).tagName === 'LI')
|
||||
return;
|
||||
|
||||
id = tr.attr('id');
|
||||
|
||||
url = '/Playlist/add-item/format/json';
|
||||
url = url + '/id/'+id;
|
||||
|
||||
$.post(url, setSPLContent);
|
||||
}
|
||||
|
||||
function deleteSPLItem(){
|
||||
|
||||
var url, pos;
|
||||
|
||||
url = '/Playlist/delete-item/format/json/view/spl';
|
||||
|
||||
pos = $('form[name="SPL"]').find(':checked').not('input[name="all"]').map(function() {
|
||||
return "/pos/" + $(this).attr('name');
|
||||
}).get().join("");
|
||||
|
||||
url = url + pos;
|
||||
|
||||
$.post(url, setSPLContent);
|
||||
}
|
||||
|
||||
function moveSPLItem(event, ui) {
|
||||
var li, newPos, oldPos, url;
|
||||
|
||||
li = ui.item;
|
||||
|
||||
newPos = li.index();
|
||||
oldPos = li.attr('id').split("_").pop();
|
||||
|
||||
url = '/Playlist/move-item'
|
||||
url = url + '/format/json';
|
||||
url = url + '/view/spl';
|
||||
url = url + '/oldPos/' + oldPos;
|
||||
url = url + '/newPos/' + newPos;
|
||||
|
||||
$.post(url, setSPLContent);
|
||||
}
|
||||
|
||||
function setUpSPL() {
|
||||
|
||||
$("#spl_sortable").sortable();
|
||||
$("#spl_sortable" ).bind( "sortstop", moveSPLItem);
|
||||
$("#spl_remove_selected").click(deleteSPLItem);
|
||||
|
||||
$("#side_playlist").droppable();
|
||||
$("#side_playlist" ).bind( "drop", addSPLItem);
|
||||
|
||||
$('input[name="all"]').click(function(){
|
||||
$('form[name="SPL"]').find('input').attr("checked", $(this).attr("checked"));
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue