From: Andreas Gohr Date: Wed, 25 Jan 2006 15:34:16 +0000 (+0100) Subject: inplace editing for tags X-Git-Tag: 0.7.1~94 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8a5a3f9e85c2238ab4078659ff47d677934e1682;p=contagged inplace editing for tags darcs-hash:20060125153416-6e07b-6f14c44030a1961fb1ed9d3cf005ddf6bb69eabd.gz --- diff --git a/ajax.php b/ajax.php index 32ffcf8..75da75a 100644 --- a/ajax.php +++ b/ajax.php @@ -8,6 +8,8 @@ if($_REQUEST['taglookup']){ ajax_taglookup($_REQUEST['taglookup']); }elseif($_REQUEST['addnote']){ ajax_addnote($_REQUEST['addnote'],$_REQUEST['note']); +}elseif($_REQUEST['settags']){ + ajax_settags($_REQUEST['settags'],$_REQUEST['tags']); } /** @@ -33,6 +35,30 @@ function ajax_addnote($dn,$note){ print smarty_modifier_noteparser($note); } +/** + * Sett tags for a contact + */ +function ajax_settags($dn,$tags){ + global $conf; + global $LDAP_CON; + if(!$conf[extended]) return; + + $tags = explode(',',$tags); + $tags = array_map('trim',$tags); + $tags = array_unique($tags); + + $entry['marker'] = $tags; + ldap_modify($LDAP_CON,$dn,$entry); + + foreach ($tags as $tag){ + print ''; + print htmlspecialchars($tag); + print ' '; + } +} + /** * Find all tags (markers) starting with the given * string diff --git a/entry.php b/entry.php index 10d4661..a1db323 100644 --- a/entry.php +++ b/entry.php @@ -23,6 +23,7 @@ $_REQUEST[entry][jpegPhoto][]=_getUploadData(); $_REQUEST[entry][marker] = explode(',',$_REQUEST[entry][markers]); $_REQUEST[entry][marker] = array_map('trim',$_REQUEST[entry][marker]); + $_REQUEST[entry][marker] = array_unique($_REQUEST[entry][marker]); unset($_REQUEST[entry][markers]); $dn = _saveData(); } diff --git a/js/gui.js b/js/gui.js index c64013a..3d6053b 100644 --- a/js/gui.js +++ b/js/gui.js @@ -1,26 +1,70 @@ +function tedit_showEditor(dn){ + // if the editor already exists cancel it + if($('tedit_editor') !== null){ + tedit_cleanUp(); + return; + } -/** - * Note Editor Class - */ + var tags = $('tedit_out').innerHTML; + tags = tags.replace(/>[ \n\r]+, '; + editor += '
'; + editor += 'save
'; + editor += 'cancel'; + editor += ''; + + Element.hide('tedit_out'); + new Insertion.Top($('tedit_insert'), editor); + + new Ajax.Autocompleter('tedit_edit','tedit_completion', 'ajax.php', {paramName: 'taglookup', tokens: ','}); + + Event.observe('tedit_save', 'click', function(){ tedit_saveChanges(dn) }, false); + Event.observe('tedit_cancel', 'click', tedit_cleanUp, false); + $('tedit_edit').focus(); +} + +function tedit_cleanUp(){ + Element.remove('tedit_editor'); + Element.show('tedit_out'); +} + +function tedit_saveChanges(dn){ + var content = encodeURI($F('tedit_edit')); + dn = encodeURI(dn); -/* -NoteEditor.prototype = { + $('tedit_editor').innerHTML = "Saving..."; - initialize: function(ident,type,controlId){ - this.type = type; - this.ident = ident; - this.ctl = $(controlId); - // add click handler to control - Event.observe(controlId, 'click', this.edit, false); - }, -*/ + var success = function(resp){tedit_complete(resp)}; + var failure = function(resp){tedit_failed(resp)}; + var pars = 'settags='+dn+'&tags='+content; + var ajax = new Ajax.Request('ajax.php', {method:'post',postBody:pars,onSuccess:success,onFailure:failure}); +} + +function tedit_complete(resp){ + $('tedit_out').innerHTML = resp.responseText; + tedit_cleanUp(); +} + +function tedit_failed(resp){ + tedit_cleanUp(); + alert("Saving failed."); +} + + + +// -------------------------------------------------------------------- /** * Create the editor component */ - function nedit_showEditor(type,dn,name){ // if the editor already exists cancel it if($('nedit_editor') !== null){ @@ -42,18 +86,16 @@ function nedit_showEditor(type,dn,name){ var dt = new Date(); editor += '//'+dt.formatDate('j. M y H:i')+' '+name+'//: '; - editor += '
'; + editor += ''; - editor += ''; - editor += ''; + editor += 'save
'; + editor += 'cancel'; editor += ''; new Insertion.Top($('nedit_insert'), editor); Event.observe('nedit_save', 'click', function(){ nedit_saveChanges(dn) }, false); Event.observe('nedit_cancel', 'click', nedit_cleanUp, false); - -// $('nedit_edit').scrollIntoView(); $('nedit_edit').focus(); }; diff --git a/pix/accept.png b/pix/accept.png new file mode 100644 index 0000000..a24d605 Binary files /dev/null and b/pix/accept.png differ diff --git a/pix/cancel.png b/pix/cancel.png new file mode 100644 index 0000000..744df79 Binary files /dev/null and b/pix/cancel.png differ diff --git a/pix/tag_blue_edit.png b/pix/tag_blue_edit.png new file mode 100644 index 0000000..4824827 Binary files /dev/null and b/pix/tag_blue_edit.png differ diff --git a/templates/entry_show.tpl b/templates/entry_show.tpl index c1a73e4..70a0367 100644 --- a/templates/entry_show.tpl +++ b/templates/entry_show.tpl @@ -114,13 +114,13 @@ {$lang.note} {if $user} - - - - + + + + {/if} -
+
{$entry.note|noteparser}
diff --git a/templates/extended_show.tpl b/templates/extended_show.tpl index 8508101..ff90894 100644 --- a/templates/extended_show.tpl +++ b/templates/extended_show.tpl @@ -8,15 +8,21 @@ {$entry.anniversary|date_format:$conf.dateformat} {/if} - {if $entry.marker} - {$lang.marker}: - + + {$lang.marker}: + + + + {foreach from=$entry.marker item=marker}
{$marker} {/foreach} + + {if $user} + + {/if} - {/if}
diff --git a/templates/layout.css b/templates/layout.css index 15d24ca..82d6f50 100644 --- a/templates/layout.css +++ b/templates/layout.css @@ -14,7 +14,18 @@ div#toolbar ul { } div#toolbar li.sep { - height: 1em; + margin: 0.5em 2px; + border-bottom: 1px solid #ccc; +} + +div#toolbar img { + padding: 2px; + margin: 1px 0; + border: 1px solid #fff; +} + +div#toolbar img:hover { + border: 1px solid #ccc; } /* top row */ diff --git a/templates/style.css b/templates/style.css index 52e63ec..899864e 100644 --- a/templates/style.css +++ b/templates/style.css @@ -117,23 +117,22 @@ div.autocomplete li.selected { } div#nedit_editor textarea{ - border-width:1px; - border-style:solid; - border-color:#000000; - margin:2px; - font-family:Lucida,Helvetica,Verdana,Arial,Sans-Serif; - font-size: 12px; width: 60%; + border: 1px solid #000; + margin: 2px; + float: left; height: 10em; } -div#nedit_editor input { - border-width:1px; - border-style:solid; - border-color:#000000; - margin:2px; - font-family:Lucida,Helvetica,Verdana,Arial,Sans-Serif; - font-size: 12px; +div#tedit_editor textarea{ + width: 90%; + border: 1px solid #000; + margin: 2px; + float: left; +} + +img.click { + cursor: pointer; } /* TagCloud */