From: Ben Klang Date: Fri, 19 Mar 2010 16:31:19 +0000 (-0400) Subject: Shout: Add UI to change sound file X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=86846d96ad9064fec8bde556f7dcd105afc50cd4;p=horde.git Shout: Add UI to change sound file --- diff --git a/shout/lib/Ajax/Application.php b/shout/lib/Ajax/Application.php index 5151d1b35..092106131 100644 --- a/shout/lib/Ajax/Application.php +++ b/shout/lib/Ajax/Application.php @@ -33,7 +33,7 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base public function addDestination() { $vars = $this->_vars; - $shout = Horde_Registry::appInit('shout'); + $shout = $GLOBALS['registry']->getApiInstance('shout', 'application'); $account = $_SESSION['shout']['curaccount']; try { $shout = $GLOBALS['registry']->getApiInstance('shout', 'application'); @@ -53,7 +53,7 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base public function deleteDestination() { $vars = $this->_vars; - $shout = Horde_Registry::appInit('shout'); + $shout = $GLOBALS['registry']->getApiInstance('shout', 'application'); $account = $_SESSION['shout']['curaccount']; try { // FIXME: Use Form? @@ -74,7 +74,7 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base public function getDestinations() { $vars = $this->_vars; - $shout = Horde_Registry::appInit('shout'); + $shout = $GLOBALS['registry']->getApiInstance('shout', 'application'); $account = $_SESSION['shout']['curaccount']; try { return $shout->extensions->getExtensions($account); @@ -92,7 +92,7 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base { try { $vars = $this->_vars; - $shout = Horde_Registry::appInit('shout'); + $shout = $GLOBALS['registry']->getApiInstance('shout', 'application'); $account = $_SESSION['shout']['curaccount']; $menus = $shout->storage->getMenus($account); $menu = $vars->menu; @@ -114,6 +114,11 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base } } + public function saveMenuInfo() + { + return true; + } + /** * TODO */ @@ -121,7 +126,7 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base { try { $vars = $this->_vars; - $GLOBALS['shout'] = Horde_Registry::appInit('shout'); + $shout = $GLOBALS['registry']->getApiInstance('shout', 'application'); $account = $_SESSION['shout']['curaccount']; $actions = Shout::getMenuActions($contex, $menu); return $actions; @@ -139,7 +144,7 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base if (!($action = $vars->get('action'))) { throw new Shout_Exception("Invalid action requested."); } - $GLOBALS['shout'] = Horde_Registry::appInit('shout'); + $shout = $GLOBALS['registry']->getApiInstance('shout', 'application'); $account = $_SESSION['shout']['curaccount']; $actions = Shout::getMenuActions(); $action = $actions[$action]; diff --git a/shout/templates/dialplan/edit.inc b/shout/templates/dialplan/edit.inc index 362c494d5..54c6fecec 100644 --- a/shout/templates/dialplan/edit.inc +++ b/shout/templates/dialplan/edit.inc @@ -142,26 +142,63 @@ function cancelEdit() $('editActionOverlay').hide(); } -function changeSoundfile() +function changeSoundFile() { - //empty($('editSound')); + empty($('editSound')); // FIXME: Add spinner new Ajax.Request(ajax_url + 'getRecordings', { method: 'get', onSuccess: function(r) { - //var form = document.createElement('form'); - //form.name = 'selectSoundFile'; - //form.id = 'selectSoundFile'; - //var select = document.createElement('select'); - //select.name = 'filename'; - var recordings = r.responseJSON.response; - alert('done'); + var form = document.createElement('form'); + form.name = 'selectSoundFile'; + form.id = 'selectSoundFile'; + var select = document.createElement('select'); + select.name = 'filename'; + var recordings = $H(r.responseJSON.response); + recordings.each(function (pair) { + var option = document.createElement('option'); + option.value = pair.value.name; + var text = document.createTextNode(pair.value.name); + option.appendChild(text); + select.appendChild(option); + }); + form.appendChild(select); + var spacer = document.createTextNode(' '); + form.appendChild(spacer); + var save = document.createElement('input'); + save.type = 'submit'; + save.name = 'save'; + save.value = ''; + form.appendChild(save); + $('editSound').appendChild(form); + Event.observe($('selectSoundFile'), 'submit', function(event) {saveSoundFile(event);}); } }); } -function playSoundfile() +function saveSoundFile(event) +{ + Event.stop(event); + var form = event.target; + Element.extend(form); + var file = form.getElements().first().getValue(); + // TODO: Allow editing other menu details + // TODO: Add spinner + new Ajax.Request(ajax_url + 'saveMenuInfo', + { + method: 'post', + parameters: $H({ + 'file': file + }), + onSuccess: function(r) { + refreshMenu(); + // TODO: Stop spinner + } + }); +} + +function playSoundFile() { alert("Playing soundfile"); } @@ -185,24 +222,24 @@ function refreshMenu() // Handle the soundfile row specially row = document.createElement('tr'); col = document.createElement('td'); - col.id = 'editSound'; col.className = 'menuStatName'; text = document.createTextNode(''); col.appendChild(text); row.appendChild(col); col = document.createElement('td'); + col.id = 'editSound'; col.className='menuStatValue'; text = document.createTextNode(meta.soundfile); col.appendChild(text); img = document.createElement('img'); img.src = ''; - img.alt = ''; - img.setAttribute('onclick', 'changeSoundfile()'); + img.alt = ''; + img.setAttribute('onclick', 'changeSoundFile()'); col.appendChild(img); img = document.createElement('img'); img.src = ''; - img.alt = ''; - img.setAttribute('onclick', 'playSoundfile()'); + img.alt = ''; + img.setAttribute('onclick', 'playSoundFile()'); img.setAttribute("style", img.getAttribute("style") + "; float:right; "); col.appendChild(img); row.appendChild(col);