notes widget

This commit is contained in:
friendica 2013-12-09 15:27:46 -08:00
parent b5f73d01c5
commit f85cba10eb
5 changed files with 52 additions and 2 deletions

View File

@ -135,3 +135,17 @@ function widget_follow($args) {
));
}
function widget_notes($arr) {
if(! local_user())
return '';
$text = htmlspecialchars(get_pconfig(local_user(),'notes','text'));
$o = replace_macros(get_markup_template('notes.tpl'), array(
'$banner' => t('Notes'),
'$text' => $text,
'$save' => t('Save'),
));
return $o;
}

View File

@ -54,7 +54,7 @@ function network_init(&$a) {
$a->set_widget('suggestions',widget_suggestions(array()));
$a->set_widget('savedsearch',saved_searches($search));
$a->set_widget('filer',fileas_widget($a->get_baseurl(true) . '/network',(x($_GET, 'file') ? $_GET['file'] : '')));
$a->set_widget('notes',widget_notes(array()));
if($search) {
if(strpos($search,'@') === 0) {

16
mod/notes.php Normal file
View File

@ -0,0 +1,16 @@
<?php /** @file */
function notes_init(&$a) {
if(! local_user())
return;
logger('mod_notes: ' . print_r($_REQUEST,true));
$ret = array('success' => true);
if($_REQUEST['note_text']) {
$body = escape_tags($_REQUEST['note_text']);
set_pconfig(local_user(),'notes','text',$body);
}
logger('notes saved.');
json_return_and_die($ret);
}

View File

@ -2985,4 +2985,11 @@ img.mail-list-sender-photo {
.comment-edit-text-full {
color: black;
}
.suggest-widget-more { margin-top: 10px; }
.suggest-widget-more { margin-top: 10px; }
#note-text {
width: 190px;
max-width: 190px;
height: 150px;
}
#note-save { margin-top: 10px; }

13
view/tpl/notes.tpl Normal file
View File

@ -0,0 +1,13 @@
<div class="widget">
<script>
function notePost() {
$('#note-rotator').spin('tiny');
$.post('notes', { 'note_text' : $('#note-text').val() },function(data) { $('#note-rotator').spin(false); });
}
</script>
<h3>{{$banner}}</h3>
<textarea name="note_text" id="note-text">{{$text}}</textarea>
<input type="submit" name="submit" id="note-save" value="{{$save}}" onclick="notePost(); return true;">
<div id="note-rotator"></div>
</div>