1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-04 13:47:31 +02:00

userpicker() functioning correctly with jquery

This commit is contained in:
Cameron
2013-02-05 16:39:48 -08:00
parent 2855665d56
commit 39e9b14cf6
5 changed files with 61 additions and 17 deletions

View File

@@ -208,12 +208,11 @@ class e_form
if(vartrue($options['typeahead'])) if(vartrue($options['typeahead']))
{ {
$options['data-provide'] ="typeahead";
if(vartrue($options['typeahead']) == 'users') if(vartrue($options['typeahead']) == 'users')
{ {
$options['data-source'] = e_BASE."user.php"; $options['data-source'] = e_BASE."user.php";
$options['class'] .= " e-typeahead";
} }
} }
$options = $this->format_options('text', $name, $options); $options = $this->format_options('text', $name, $options);
@@ -643,6 +642,14 @@ class e_form
{ {
if(!is_array($options)) parse_str($options, $options); if(!is_array($options)) parse_str($options, $options);
//TODO Auto-calculate $name_fld from $id_fld ie. append "_usersearch" here ?
return $this->text($name_fld,$default_name,20, "typeahead=users&readonly=".vartrue($options['readonly']))
.$this->hidden($id_fld,$default_id, array('id' => $this->name2id($id_fld)))." id# ".$default_id;
/*
$label_fld = str_replace('_', '-', $name_fld).'-upicker-lable'; $label_fld = str_replace('_', '-', $name_fld).'-upicker-lable';
//'.$this->text($id_fld, $default_id, 10, array('id' => false, 'readonly'=>true, 'class'=>'tbox number')).' //'.$this->text($id_fld, $default_id, 10, array('id' => false, 'readonly'=>true, 'class'=>'tbox number')).'
@@ -657,9 +664,9 @@ class e_form
<div class="e-autocomplete"></div> <div class="e-autocomplete"></div>
</div> </div>
'; ';
// FIXME - switch to external JS, jQuery support
e107::getJs()->requireCoreLib('scriptaculous/controls.js', 2); e107::getJs()->requireCoreLib('scriptaculous/controls.js', 2);
//TODO - external JS
e107::getJs()->footerInline(" e107::getJs()->footerInline("
//autocomplete fields //autocomplete fields
\$\$('input[name={$name_fld}]').each(function(el) { \$\$('input[name={$name_fld}]').each(function(el) {
@@ -695,7 +702,7 @@ class e_form
}); });
"); ");
return $ret; return $ret;
*/
} }
@@ -1045,6 +1052,7 @@ class e_form
$name = (strpos($name, '[') === false) ? $name.'[]' : $name; $name = (strpos($name, '[') === false) ? $name.'[]' : $name;
if(!is_array($selected)) $selected = explode(",",$selected); if(!is_array($selected)) $selected = explode(",",$selected);
} }
$text = $this->select_open($name, $options)."\n"; $text = $this->select_open($name, $options)."\n";
if(isset($options['default'])) if(isset($options['default']))

View File

@@ -137,7 +137,11 @@ class pm_extended extends private_message
$tpl_file = THEME.'pm_template.php'; $tpl_file = THEME.'pm_template.php';
include_once(is_readable($tpl_file) ? $tpl_file : e_PLUGIN.'pm/pm_template.php'); include_once(is_readable($tpl_file) ? $tpl_file : e_PLUGIN.'pm/pm_template.php');
$enc = (check_class($this->pmPrefs['attach_class']) ? "enctype='multipart/form-data'" : ''); $enc = (check_class($this->pmPrefs['attach_class']) ? "enctype='multipart/form-data'" : '');
setScVar('pm_handler_shortcodes','pmInfo', $pm_info); // setScVar('pm_handler_shortcodes','pmInfo', $pm_info);
$sc = e107::getScBatch('pm',TRUE);
$sc->setVars($pm_info);
$text = "<form {$enc} method='post' action='".e_SELF."' id='dataform'> $text = "<form {$enc} method='post' action='".e_SELF."' id='dataform'>
<div><input type='hidden' name='numsent' value='{$pm_outbox['outbox']['total']}' />". <div><input type='hidden' name='numsent' value='{$pm_outbox['outbox']['total']}' />".
$this->e107->tp->parseTemplate($PM_SEND_PM, TRUE). $this->e107->tp->parseTemplate($PM_SEND_PM, TRUE).
@@ -155,35 +159,39 @@ class pm_extended extends private_message
function show_inbox($start = 0) function show_inbox($start = 0)
{ {
$tp = e107::getParser();
$tpl_file = THEME.'pm_template.php'; $tpl_file = THEME.'pm_template.php';
include(is_readable($tpl_file) ? $tpl_file : e_PLUGIN.'pm/pm_template.php'); include(is_readable($tpl_file) ? $tpl_file : e_PLUGIN.'pm/pm_template.php');
$pm_blocks = $this->block_get(); $pm_blocks = $this->block_get();
$pmlist = $this->pm_get_inbox(USERID, $start, $this->pmPrefs['perpage']); $pmlist = $this->pm_get_inbox(USERID, $start, $this->pmPrefs['perpage']);
// setScVar('pm_handler_shortcodes', 'pmNextPrev', array('start' => $start, 'total' => $pmlist['total_messages'])); // setScVar('pm_handler_shortcodes', 'pmNextPrev', array('start' => $start, 'total' => $pmlist['total_messages']));
$sc = e107::getScBatch('pm',TRUE); $sc = e107::getScBatch('pm',TRUE);
$sc->pmNextPrev = array('start' => $start, 'total' => $pmlist['total_messages']); $sc->pmNextPrev = array('start' => $start, 'total' => $pmlist['total_messages']);
$txt = "<form method='post' action='".e_SELF."?".e_QUERY."'>"; $txt = "<form method='post' action='".e_SELF."?".e_QUERY."'>";
$txt .= $this->e107->tp->parseTemplate($PM_INBOX_HEADER, true); $txt .= $tp->parseTemplate($PM_INBOX_HEADER, true);
if($pmlist['total_messages']) if($pmlist['total_messages'])
{ {
foreach($pmlist['messages'] as $rec) foreach($pmlist['messages'] as $rec)
{ {
if(trim($rec['pm_subject']) == '') { $rec['pm_subject'] = '['.LAN_PM_61.']'; } if(trim($rec['pm_subject']) == '') { $rec['pm_subject'] = '['.LAN_PM_61.']'; }
// setScVar('pm_handler_shortcodes','pmInfo', $rec);
$sc->setVars($rec); $sc->setVars($rec);
$txt .= $tp->parseTemplate($PM_INBOX_TABLE, true);
$txt .= $this->e107->tp->parseTemplate($PM_INBOX_TABLE, true);
} }
} }
else else
{ {
$txt .= $this->e107->tp->parseTemplate($PM_INBOX_EMPTY, true); $txt .= $tp->parseTemplate($PM_INBOX_EMPTY, true);
} }
$txt .= $this->e107->tp->parseTemplate($PM_INBOX_FOOTER, true);
$txt .= $tp->parseTemplate($PM_INBOX_FOOTER, true);
$txt .= "</form>"; $txt .= "</form>";
return $txt; return $txt;
} }
@@ -324,6 +332,9 @@ class pm_extended extends private_message
*/ */
function post_pm() function post_pm()
{ {
print_a($_POST);
if(!check_class($this->pmPrefs['pm_class'])) if(!check_class($this->pmPrefs['pm_class']))
{ {
return LAN_PM_12; return LAN_PM_12;

View File

@@ -112,6 +112,7 @@ class pm_shortcodes extends e_shortcode
else else
{ {
$frm = e107::getForm(); $frm = e107::getForm();
//TODO Use $frm->userpicker();
return $frm->text('pm_to','',10,'typeahead=users'); return $frm->text('pm_to','',10,'typeahead=users');
$ret = $us->select_form($type, 'pm_to', '', $this->pmPrefs['pm_class']); $ret = $us->select_form($type, 'pm_to', '', $this->pmPrefs['pm_class']);

View File

@@ -13,6 +13,29 @@ $(document).ready(function()
// $(".e-spinner").spinner(); //FIXME breaks tooltips // $(".e-spinner").spinner(); //FIXME breaks tooltips
$('.e-typeahead').each(function() {
var id = $(this).attr("id");
var name = '#' + id.replace('-usersearch', '');
var newval = $(this).attr("data-value");
$(this).typeahead({
source: $(this).attr("data-source"),
updater: function(text, type){
if(type == 'value')
{
$(name).val(text);
}
return text;
}
})
});
//check all //check all
$("#check-all").click(function(event){ $("#check-all").click(function(event){
var val = $(this).val(), selector = '.field-spacer'; var val = $(this).val(), selector = '.field-spacer';

View File

@@ -26,11 +26,12 @@ if(e_AJAX_REQUEST)
if(vartrue($_GET['q'])) if(vartrue($_GET['q']))
{ {
$q = filter_var($_GET['q'], FILTER_SANITIZE_STRING); $q = filter_var($_GET['q'], FILTER_SANITIZE_STRING);
if($sql->select("user", "user_name", "user_name LIKE '". $q."%' ORDER BY user_name LIMIT 15")) if($sql->select("user", "user_id,user_name", "user_name LIKE '". $q."%' ORDER BY user_name LIMIT 15"))
{ {
while($row = $sql->db_Fetch()) while($row = $sql->db_Fetch())
{ {
$data[] = $row['user_name']; $id = $row['user_id'];
$data[$id] = $row['user_name'];
} }
if(count($data)) if(count($data))