← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8507: Impl scroll up and down buttons in read message conversation screen

 

------------------------------------------------------------
revno: 8507
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-10-12 14:49:44 +0200
message:
  Impl scroll up and down buttons in read message conversation screen
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/readMessage.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2012-09-21 08:30:28 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2012-10-12 12:49:44 +0000
@@ -40,6 +40,37 @@
 }
 
 /**
+ * Scrolls the view port to the bottom of the document.
+ */
+function scrollToBottom()
+{
+	var scrollTop = parseInt( $( document ).height() - $( window ).height() );
+	
+	if ( scrollIsRelevant() )
+	{
+		$( document ).scrollTop( scrollTop );
+	}
+}
+
+/**
+ * Scrolls the view port to the top of the document.
+ */
+function scrollToTop()
+{
+	$( document ).scrollTop( 0 );
+}
+
+/**
+ * Indicates whether there is a need for scrolling.
+ */
+function scrollIsRelevant()
+{
+	var scrollTop = parseInt( $( document ).height() - $( window ).height() );	
+	var relevant = ( scrollTop > 0 );
+	return relevant;
+}
+
+/**
  * Joins the names of the given array of objects and returns it as a single string.
  */
 function joinNameableObjects( objects )

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties	2012-10-11 19:54:10 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties	2012-10-12 12:49:44 +0000
@@ -83,4 +83,6 @@
 follow_up=Follow up
 unread=Unread
 send_message=Send message
-to=to
\ No newline at end of file
+to=to
+scroll_down=Scroll down
+scroll_up=Scroll up
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/readMessage.vm'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/readMessage.vm	2012-10-07 19:07:53 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/readMessage.vm	2012-10-12 12:49:44 +0000
@@ -1,6 +1,10 @@
 <script type="text/javascript">
 $( document ).ready( function() {
-	$( '#text' ).autogrow();
+	jQuery( '#text' ).autogrow();
+	
+	if ( scrollIsRelevant() == false ) {
+	   jQuery( '.scrollButton' ).hide();
+	}
 } );
 	
 var i18n_sender = '$encoder.jsEscape( $i18n.getString( "sender" ), "'")';
@@ -49,6 +53,7 @@
 <input type="button" value="$i18n.getString( 'mark_unread' )" onclick="window.location.href='unreadMessage.action?id=${conversation.id}'" style="width:120px">
 <input type="button" value="$i18n.getString( 'remove' )" onclick="window.location.href='removeMessageRedirect.action?id=${conversation.id}'" style="width:120px">
 <input type="button" value="$i18n.getString( 'back' )" onclick="window.location.href='message.action?currentPage=${keyCurrentPage}'" style="width:120px">
+<input type="button" value="$i18n.getString( 'scroll_down' )" onclick="scrollToBottom()" style="width:120px" class="scrollButton">
 </div>
 
 <div>
@@ -74,4 +79,5 @@
 <input type="button" value="$i18n.getString( 'mark_unread' )" onclick="window.location.href='unreadMessage.action?id=${conversation.id}'" style="width:120px">
 <input type="button" value="$i18n.getString( 'remove' )" onclick="window.location.href='removeMessageRedirect.action?id=${conversation.id}'" style="width:120px">
 <input type="button" value="$i18n.getString( 'back' )" onclick="window.location.href='message.action'" style="width:120px">
+<input type="button" value="$i18n.getString( 'scroll_up' )" onclick="scrollToTop()" style="width:120px" class="scrollButton">
 </div>