From 8a5a3f9e85c2238ab4078659ff47d677934e1682 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 25 Jan 2006 16:34:16 +0100 Subject: [PATCH] inplace editing for tags darcs-hash:20060125153416-6e07b-6f14c44030a1961fb1ed9d3cf005ddf6bb69eabd.gz --- ajax.php | 26 ++++++++++++ entry.php | 1 + js/gui.js | 80 +++++++++++++++++++++++++++--------- pix/accept.png | Bin 0 -> 917 bytes pix/cancel.png | Bin 0 -> 853 bytes pix/tag_blue_edit.png | Bin 0 -> 884 bytes templates/entry_show.tpl | 10 ++--- templates/extended_show.tpl | 14 +++++-- templates/layout.css | 13 +++++- templates/style.css | 25 ++++++----- 10 files changed, 127 insertions(+), 42 deletions(-) create mode 100644 pix/accept.png create mode 100644 pix/cancel.png create mode 100644 pix/tag_blue_edit.png 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 0000000000000000000000000000000000000000..a24d6052d0091ca884fba0db05ae610c925e5030 GIT binary patch literal 917 zcmV;G18V$RCwBA z{Qv(y10?_;fLPE4l217*|M~Mf>hIrwaX)|mkofoS4+F!$e=ivRF)aG?_wTZe-q-IU zs|N@mMr0Qxp0Er4`TOT&X$ECUeNkHmZdQJ<_~&0A7*0Ok&2Zz>`R71`a`%QkSPRnw z5I}GP;*Z$`fB*e+p*5d3x4N(a!?W*?8J>N63YL@Nl4g+Llwr8`{1n6Tt4qHEogIHN z=@HlvfB*s;5PR54>F1x{hph#?rBsFW8IHc*&+zBpUm*U+zywkR@+%`VgSD6=!_}v! z7?xaG_6+C}+e_Jx?*Rl5NS@*EpWiXkjLK3Vn?ag?{Q1rB>+f%dKS2EJ&o2gGm@v3X zc{7}PahO3z+KjnB4jNH0JDferZn^QW``n-Ig(uMdHm|1x+; z`!Hl^6#_LgF$5@vGuTVJfeqb!XC=ea5BC@ZImHA zW?lv>2?qu~HhzX$vknF!4iT{CSr>X4Zoj$Az{AP|3=?3$|Axc@KmdVV!0-oX@VD0t z(p<6(Uw(dMn0BF);p^|uV9o#j|6`bSuAAZdtMlN%l;V?Pc>Uoy&~*&pC;|u|NErP7 zzxe3A-3(HkvJ9;M7#LoCea0~HbTh-Pw^teFobP40_WA-)10w?y5X?+f=UcB zeDVw@?;T`VuyxBHtzq={}K#;fhm!Z@dZ$7 r5isPJJ(&CiB{Km85F@4886dy_xpiI^gI>TZ00000NkvXXu0mjfoPMTo literal 0 HcmV?d00001 diff --git a/pix/cancel.png b/pix/cancel.png new file mode 100644 index 0000000000000000000000000000000000000000..744df795af9996f6c1007a592dad168a5e5c5a2d GIT binary patch literal 853 zcmV-b1FHOqP)Ssu>GBh%Ekafg z5I~H`E&ytdXXWEsAYi1)z{=0V@c;K828O@?7#M+azuvxQczfgw!_QZ5k`!kym=Dtf z5I}GPp0?B{vhZ@v6ExOhVEguzf#KC728MtC7#Ki?{QSwlz%R-0lUIh}^}!PiKVQF1 zR$jDn9!MWR0D%p7+FX~&!UxoB1l0T$sQKAF2B33+*8T<>@Ec;tuU`xd;tC8u1>_iB z9yktiNuuiNO$z`5hzVp0(4U!thMEj)A0IO?Ji5)mASlDYpyLSC_?LmS0+d=Kmb7k@y}m9R&H(vhHF5Ze*$gd;Add4@?&7&5@cZb z_8G|bVqjP`1t@=sf#LR526kmVpaH-2L0SO<2yDRrKfk~I|M`=h5oF^JppEAaGBB`k zGBCJ?Lqh7{Mh1q%J0Nn5Obq{i`~n&94I~8+Kwty@f&2?|?)P61O|0yQxMBqw_U9km z0HBLOmV%`K0tn)Q-@myT8Gy0z?Hj}pV|xY$hX4kKU27N^K7U|f2u=Y8EHGA9%wzy5 zV`2p9`NIv;3lKn%F!=rZ^6$6rjoE~O0d?mZ1H-)=3=E4VFfi=f1hfrk)2rveczz6t zP9-gdAFtkkTyPnr6(E41Uidxz)sfS4L{0S>*uQ;eV7LjCyLJ&0jUeysSPwSnkFplS zPbD3OXS??S4fs19q!%E7;0ft&OlS%#FVAc-Gb09$`&WQ20lMP1o#>L0u#@_e}BON_x;UV zhBx~UGW>l0GD+v`Rd`Yc2p~rE+<4Q=DenKDKfuiNS06}!XFz18OF%qb_w2QW$m#(C fh>_Cl3=m)dj8|3`UT=(b00000NkvXXu0mjfzhief#ze>$zQMn;AW=x5o_|JWE7-C<<-`IiwGnEx0Y z<>kRHdUt=@tDDPaGcfb$GJJh=kb&{X(|CXYVgX8gfA{Vkr;v~kSkZ?+EDVcoGcxe9 zF)|3SF)*Be%LFw3AA<$QWd?5Mrwp9BF%0~Qh72F>t25l#HKz+8fIwbwzjNo#_cw3e zfSk$j2I%x({}>rS+E{>u06PQ2na8lcVH|qs0%VN_{slc;CR2E!G?7QgMhLZ z!;fdP85mjLGqCdTGO+)7&G1^tmf^La?Q?(tVuS@E2mnLb8pz+Rsj11y@cuLd)A!>H zVmbi~Kb}r!U}F8l@awZ8!|NmG86JrRGrar9uM`{{d>N|9x|EpSoiGB7g#V)*e<2CVskbUed{pDaotAtCoc>Hz|X2|ZpPtxwjF6Zp>d`=1oU z^UITg;s1l->pN+NSI4h1Jdlb-(F_6r0mOoC0H1=|94(tPhMOx&7;YUt#=tJ8&+zZ_ zD~2D+(F`Acv7u-N0e}F)aKX(xFaG?xx`jbe-{$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 */ -- 2.39.5