Making us less dependant on javascript trust

Many of the microapps are pretty javascript dependant, but at least
we should allow users to get to the new notice field without allowing
javascript to run in the browser. :)
This commit is contained in:
Mikael Nordfeldth 2014-02-24 02:05:31 +01:00
parent c0c8250ff7
commit 1e37f374b3
5 changed files with 28 additions and 6 deletions

View File

@ -966,6 +966,9 @@ StartShowNoticeForm: before showing the notice form (before <form>)
EndShowNoticeForm: after showing the notice form (after <form>)
- $action: action being executed
StartShowEntryForms: microapp entry form tab data
- &$tabs: tab assoc array with 'tag' => (title, href to create new entry)
StartGrantRole: when a role is being assigned
- $profile: profile that will have the role
- $role: string name of the role

View File

@ -1414,6 +1414,8 @@ var SN = { // StatusNet
SN.Init.NoticeFormSetup(form);
})
.find('.notice_data-text').focus();
return false;
},
showMoreMenuItems: function (menuid) {

View File

@ -681,7 +681,8 @@ class Action extends HTMLOutputter // lawsuit
function showNoticeForm()
{
// TRANS: Tab on the notice form.
$tabs = array('status' => _m('TAB','Status'));
$tabs = array('status' => array('title' => _m('TAB','Status'),
'href' => common_local_url('newnotice')));
$this->elementStart('div', 'input_forms');
@ -689,7 +690,8 @@ class Action extends HTMLOutputter // lawsuit
$this->elementStart('ul', array('class' => 'nav',
'id' => 'input_form_nav'));
foreach ($tabs as $tag => $title) {
foreach ($tabs as $tag => $data) {
$tag = htmlspecialchars($tag);
$attrs = array('id' => 'input_form_nav_'.$tag,
'class' => 'input_form_nav_tab');
@ -702,8 +704,9 @@ class Action extends HTMLOutputter // lawsuit
$this->elementStart('li', $attrs);
$this->element('a',
array('href' => 'javascript:SN.U.switchInputFormTab("'.$tag.'")'),
$title);
array('onclick' => 'return SN.U.switchInputFormTab("'.$tag.'");',
'href' => $data['href']),
$data['title']);
$this->elementEnd('li');
}
@ -716,7 +719,7 @@ class Action extends HTMLOutputter // lawsuit
$form->show();
$this->elementEnd('div');
foreach ($tabs as $tag => $title) {
foreach ($tabs as $tag => $data) {
$attrs = array('class' => 'input_form',
'id' => 'input_form_'.$tag);

View File

@ -162,6 +162,14 @@ abstract class MicroAppPlugin extends Plugin
*/
abstract function deleteRelated($notice);
/**
*
*/
public function newFormAction() {
// such as 'newbookmark' or 'newevent' route
return 'new'.$this->tag();
}
/**
* Check if a given notice object should be handled by this micro-app
* plugin.
@ -536,7 +544,9 @@ abstract class MicroAppPlugin extends Plugin
function onStartShowEntryForms(&$tabs)
{
$tabs[$this->tag()] = $this->appTitle();
$tabs[$this->tag()] = array('title' => $this->appTitle(),
'href' => common_local_url($this->newFormAction()),
);
return true;
}

View File

@ -65,6 +65,10 @@ class QnAPlugin extends MicroAppPlugin
return true;
}
public function newFormAction() {
return 'qnanewquestion';
}
/**
* Map URLs to actions
*