[Linpha-cvs] SF.net SVN: linpha: [4587] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2006-10-17 22:23:58
|
Revision: 4587 http://svn.sourceforge.net/linpha/?rev=4587&view=rev Author: fangehrn Date: 2006-10-17 15:23:35 -0700 (Tue, 17 Oct 2006) Log Message: ----------- 2006-10-18 flo * implemented ajax add comment * had to disable the accesskeys when not in fullscreen mode because writing text in input fields didnt worked anymore any suggestions? :-( Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/linpha.template.class.php trunk/linpha2/lib/js/LinGlobal.js trunk/linpha2/lib/js/LinImage.js trunk/linpha2/templates/default/global.html.php trunk/linpha2/templates/default/view_img.html.php trunk/linpha2/templates/default/view_img_static.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-10-17 20:41:49 UTC (rev 4586) +++ trunk/linpha2/ChangeLog 2006-10-17 22:23:35 UTC (rev 4587) @@ -1,3 +1,9 @@ +2006-10-18 flo + * implemented ajax add comment + * had to disable the accesskeys when not in fullscreen mode + because writing text in input fields didnt worked anymore + any suggestions? :-( + 2006-10-11 flo * implemented slideshow * implemented movefirst() and movelast() Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-10-17 20:41:49 UTC (rev 4586) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-10-17 22:23:35 UTC (rev 4587) @@ -34,6 +34,7 @@ public $use_javascript; public $id_current, $id_parent, $img_type, $filename, $md5sum; private $nr_pages, $current_page; // only used if javascript disabled +private $newCommentAdded = false; // used for ajax /** * constructor @@ -51,14 +52,6 @@ { $this->orderby = getSqlSortOrder($GLOBALS['linpha']->sql->config->value['sys_style_sortorder']); - /** - * set usage of javascript - */ - if(isset($_GET['use_js'])) - { - $_SESSION['use_js'] = true; - } - if(isset($_GET['id']) && $_GET['id'] != 0) { /** @@ -1091,7 +1084,7 @@ $this->viewImgCommon(); $this->viewImgComments(); - if($_SESSION['use_js']) + if( isset($_SESSION['use_js']) && ! isset($_SESSION['disable_ajax']) ) { $GLOBALS['linpha']->template->setModuleName('view_img'); @@ -1146,6 +1139,11 @@ <?php } + if($this->newCommentAdded) + { + echo '<commentadded>'.i18n('Comment successfully added.').'</commentadded>'."\n"; + } + while($data = $GLOBALS['linpha']->template->output['image_comments']->FetchRow()) { ?> <comment> @@ -1205,20 +1203,23 @@ /** * save comment */ - if( isset( $_POST['cmd'] ) && $_POST['cmd']=='add_comment') + if( isset( $_POST['cmd'] ) && $_POST['cmd']=='add_comment' + && isset($_POST['inputAddCommentAuthor']) && !empty($_POST['inputAddCommentAuthor']) + && ( ( isset($_POST['inputAddCommentText']) && !empty($_POST['inputAddCommentText']) ) + || ( isset($_POST['inputAddCommentTextarea']) && !empty($_POST['inputAddCommentTextarea']) ) + ) + ) { - if( !empty($_POST['comment_textarea'])) - { - $comment = $_POST['comment_textarea']; + if( !empty($_POST['inputAddCommentTextarea'])) { + $comment = $_POST['inputAddCommentTextarea']; + } else { + $comment = $_POST['inputAddCommentText']; } - else - { - $comment = $_POST['comment_text']; - } $GLOBALS['linpha']->db->Execute("INSERT into ".PREFIX."meta_comments (meta_time, md5sum, meta_author, meta_comment)" . - "VALUES ('".time()."','".$GLOBALS['linpha']->imgview->md5sum."','".linSql::linAddslashes($_POST['author'])."'," . + "VALUES ('".time()."','".$GLOBALS['linpha']->imgview->md5sum."','".linSql::linAddslashes($_POST['inputAddCommentAuthor'])."'," . "'".linSql::linAddslashes($comment)."')"); + $this->newCommentAdded = true; // used for ajax } /** Modified: trunk/linpha2/lib/classes/linpha.template.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.template.class.php 2006-10-17 20:41:49 UTC (rev 4586) +++ trunk/linpha2/lib/classes/linpha.template.class.php 2006-10-17 22:23:35 UTC (rev 4587) @@ -80,11 +80,6 @@ </style> <![endif]--> -<?php if( isset( $GLOBALS['linpha']->template->output['slideshow_head'] ) ) { - echo '<!-- slideshow-->'; - echo $GLOBALS['linpha']->template->output['slideshow_head']; -} ?> - <script type="text/javascript" language="javascript" src="<?php echo LINPHA_DIR; ?>/lib/js/prototype.js"></script> <script type="text/javascript" language="javascript" src="<?php echo LINPHA_DIR; ?>/lib/js/LinGlobal.js"></script> <?php Modified: trunk/linpha2/lib/js/LinGlobal.js =================================================================== --- trunk/linpha2/lib/js/LinGlobal.js 2006-10-17 20:41:49 UTC (rev 4586) +++ trunk/linpha2/lib/js/LinGlobal.js 2006-10-17 22:23:35 UTC (rev 4587) @@ -5,9 +5,14 @@ */ function linSyslog(text) { - $('divSyslogText').innerHTML = text; + $('divSyslogText').innerHTML += text + '<br />'; Element.show('divSyslog'); } +function closeSyslog() +{ + $('divSyslogText').innerHTML = ''; + Element.hide('divSyslog'); +} /** * check ajax compatibilty Modified: trunk/linpha2/lib/js/LinImage.js =================================================================== --- trunk/linpha2/lib/js/LinImage.js 2006-10-17 20:41:49 UTC (rev 4586) +++ trunk/linpha2/lib/js/LinImage.js 2006-10-17 22:23:35 UTC (rev 4587) @@ -286,6 +286,7 @@ /** * set comments */ + initTextareaAddComment(); $('divcomments').innerHTML = ''; if(xmlDoc[curImgId].getElementsByTagName('comment').length > 0) { @@ -367,15 +368,35 @@ // keyboardAction() // keyboardAction: function(e) { - if (e == null) { // ie - keycode = event.keyCode; - } else { // mozilla - keycode = e.which; + + if( fullscreenActive ) + { + if (e == null) { // ie + keycode = event.keyCode; + } else { // mozilla + keycode = e.which; + } + + key = String.fromCharCode(keycode).toLowerCase(); + + + if( (key == 'f') || (key == 'x') || (key == 'o') || (key == 'c') ) // close fullscreen + { + myLinImage.fullscreenStop(); + } + else if(key == 's'){ // start/stop slideshow + myLinImage.slideshowStartStop(); + } else if(key == 'p'){ // display previous image + myLinImage.disableKeyboardNav(); + myLinImage.movePrev(); + } else if(key == 'n'){ // display next image + myLinImage.disableKeyboardNav(); + myLinImage.moveNext(); + } } - - key = String.fromCharCode(keycode).toLowerCase(); - - if( fullscreenActive && ( (key == 'x') || (key == 'o') || (key == 'c') ) ) { // close fullscreen + + + /*if( fullscreenActive && ( (key == 'x') || (key == 'o') || (key == 'c') ) ) { // close fullscreen myLinImage.fullscreenStop(); } else if(key == 'f'){ // start/stop fullscreen if( fullscreenActive ) { @@ -391,7 +412,8 @@ } else if(key == 'n'){ // display next image myLinImage.disableKeyboardNav(); myLinImage.moveNext(); - } + }*/ + }, /** @@ -758,6 +780,56 @@ return returnarray; } + +// ----------------------------------------------------------------------------------- +// Comments +// ----------------------------------------------------------------------------------- + +function saveComment(parameters) +{ + //alert(parameters); + + //new Ajax.Updater('div_to_be_updated', '/action/here', {asynchronous:true, parameters:Form.serialize(this)}) + + + var opt = { + // Use POST + method: 'post', + // Send this lovely data + postBody: parameters + , + // asynchron, of course + asynchronous:true, + + // Handle successful response + onSuccess: saveCommentContinue, + + // Handle 404 + on404: function(t) { + alert('Error 404: location "' + t.statusText + '" was not found.'); + }, + // Handle other errors + onFailure: function(t) { + alert('Error ' + t.status + ' -- ' + t.statusText); + } + } + + new Ajax.Request(xmlUrl + '&id=' + curImgId + '&xml', opt); +} + + +function saveCommentContinue(t) +{ + xmlDoc[curImgId] = t.responseXML.documentElement; + + if(xmlDoc[curImgId].getElementsByTagName('commentadded').length > 0) + { + linSyslog( xmlDoc[curImgId].getElementsByTagName('commentadded').item(0).firstChild.data ); + } + + myLinImage.loadImage(curImgId); +} + /** * openTextarea() * @@ -766,8 +838,17 @@ */ function openTextarea() { - document.getElementById('comment_textarea').style.display = 'block'; - document.getElementById('comment_div_text').style.display = 'none'; + Element.show('inputAddCommentTextarea'); + Element.hide('divAddCommentText'); - document.getElementById('comment_textarea').value = document.getElementById('comment_input_text').value; -} \ No newline at end of file + $('inputAddCommentTextarea').value = $('inputAddCommentText').value; +} + +function initTextareaAddComment() +{ + Element.hide('inputAddCommentTextarea'); + Element.show('divAddCommentText'); + + $('inputAddCommentTextarea').value = ''; + $('inputAddCommentText').value = ''; +} Modified: trunk/linpha2/templates/default/global.html.php =================================================================== --- trunk/linpha2/templates/default/global.html.php 2006-10-17 20:41:49 UTC (rev 4586) +++ trunk/linpha2/templates/default/global.html.php 2006-10-17 22:23:35 UTC (rev 4587) @@ -18,7 +18,7 @@ <!-- syslog --> <div id="divSyslog"<?php if( ! isset($GLOBALS['linpha']->template->output['sys_log']) ) { echo ' style="display: none;"'; } ?>> - <div id="divSyslogClose"><a href="javascript:void(0);" onclick="Element.hide('divSyslog')">X</a></div> + <div id="divSyslogClose"><a href="javascript:closeSyslog();">X</a></div> <?php echo i18n("Linpha Syslog"); ?>:<br /> <div id="divSyslogText"> <?php echo $GLOBALS['linpha']->template->output['sys_log']; ?> Modified: trunk/linpha2/templates/default/view_img.html.php =================================================================== --- trunk/linpha2/templates/default/view_img.html.php 2006-10-17 20:41:49 UTC (rev 4586) +++ trunk/linpha2/templates/default/view_img.html.php 2006-10-17 22:23:35 UTC (rev 4587) @@ -49,16 +49,16 @@ <?php if($GLOBALS['linpha']->sql->checkPermission('metadata_comments')) { ?> <!-- show add comment form --> <div class="add_comment"> - <form action="<?php echo $GLOBALS['linpha']->template->URL_full; ?>" method="POST"> + <form action="" method="POST" onsubmit="saveComment(Form.serialize(this)); return false;"> <?php echo i18n("Add Comment"); ?>:<br /> - <div id="comment_div_text"> - <input type="text" id="comment_input_text" name="comment_text" value="" tabindex="1" size="40" maxlength="40" /> + <div id="divAddCommentText"> + <input type="text" id="inputAddCommentText" name="inputAddCommentText" value="" tabindex="1" size="40" /> <a href="javascript:openTextarea()">(+)</a> </div> - <textarea style="display: none;" id="comment_textarea" name="comment_textarea" tabindex="1" rows="10" cols="50"></textarea> - <?php echo i18n("Name"); ?>: <input type="text" name="author" value="" tabindex="2" size="10" maxlength="40" /> + <textarea style="display: none;" id="inputAddCommentTextarea" name="inputAddCommentTextarea" tabindex="1" rows="10" cols="50"></textarea> + <?php echo i18n("Name"); ?>: <input type="text" name="inputAddCommentAuthor" value="" tabindex="2" size="10" maxlength="255" /> <input type="hidden" name="cmd" value="add_comment" /> - <input type="submit" name="submit" value="<?php echo i18n("submit"); ?>" /> + <input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>" tabindex="2" /> </form> </div> Modified: trunk/linpha2/templates/default/view_img_static.html.php =================================================================== --- trunk/linpha2/templates/default/view_img_static.html.php 2006-10-17 20:41:49 UTC (rev 4586) +++ trunk/linpha2/templates/default/view_img_static.html.php 2006-10-17 22:23:35 UTC (rev 4587) @@ -49,23 +49,23 @@ <div class="add_comment"> <form action="<?php echo $GLOBALS['linpha']->template->URL_full; ?>" method="POST"> <?php echo i18n("Add Comment"); ?>:<br /> - <div id="comment_div_text"> - <input type="text" id="comment_input_text" name="comment_text" value="" tabindex="1" size="40" maxlength="40" /> + <div id="divAddCommentText"> + <input type="text" id="inputAddCommentText" name="inputAddCommentText" value="" tabindex="1" size="40" /> <a href="javascript:openTextarea()">(+)</a> </div> - <textarea style="display: none;" id="comment_textarea" name="comment_textarea" tabindex="1" rows="10" cols="50"></textarea> - <?php echo i18n("Name"); ?>: <input type="text" name="author" value="" tabindex="2" size="10" maxlength="40" /> + <textarea style="display: none;" id="inputAddCommentTextarea" name="inputAddCommentTextarea" tabindex="1" rows="10" cols="50"></textarea> + <?php echo i18n("Name"); ?>: <input type="text" name="inputAddCommentAuthor" value="" tabindex="2" size="10" maxlength="255" /> <input type="hidden" name="cmd" value="add_comment" /> - <input type="submit" name="submit" value="<?php echo i18n("submit"); ?>" /> + <input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>" tabindex="2" /> </form> </div> <script language="JavaScript" type="text/javascript"> function openTextarea() { - document.getElementById('comment_textarea').style.display = 'block'; - document.getElementById('comment_div_text').style.display = 'none'; + document.getElementById('inputAddCommentTextarea').style.display = 'block'; + document.getElementById('divAddCommentText').style.display = 'none'; - document.getElementById('comment_textarea').value = document.getElementById('comment_input_text').value; + document.getElementById('inputAddCommentTextarea').value = document.getElementById('inputAddCommentText').value; } </script> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |