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>) EndShowNoticeForm: after showing the notice form (after <form>)
- $action: action being executed - $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 StartGrantRole: when a role is being assigned
- $profile: profile that will have the role - $profile: profile that will have the role
- $role: string name of the role - $role: string name of the role

View File

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

View File

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

View File

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

View File

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