[BluetoothChat]Updated Private -> RSA
authorji.ji <ji.ji@samsung.com>
Tue, 9 Jul 2013 10:19:44 +0000 (19:19 +0900)
committerji.ji <ji.ji@samsung.com>
Tue, 9 Jul 2013 10:19:44 +0000 (19:19 +0900)
Change-Id: Ie3dea66cc6d8c7e057b753d17bf2154002d9981d

.project
config.xml
css/style.css
index.html
js/app.ui.events.js
js/app.ui.js
templates/chat_page.tpl
templates/choose_page.tpl
templates/keyboard_page.tpl

index c15a453..ea56a52 100644 (file)
--- a/.project
+++ b/.project
                        </arguments>
                </buildCommand>
                <buildCommand>
-                       <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
                        <name>json.validation.builder</name>
                        <arguments>
                        </arguments>
                                </dictionary>
                        </arguments>
                </buildCommand>
+               <buildCommand>
+                       <name>org.tizen.web.privilege.nature.PrivilegeBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.tizen.web.editor.css.nature.CSSBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
        </buildSpec>
        <natures>
                <nature>json.validation.nature</nature>
@@ -52,5 +57,7 @@
                <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
                <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
                <nature>org.tizen.web.project.builder.WebNature</nature>
+               <nature>org.tizen.web.privilege.nature.PrivilegeNature</nature>
+               <nature>org.tizen.web.editor.css.nature.CSSNature</nature>
        </natures>
 </projectDescription>
index daf92ea..ce97e15 100644 (file)
@@ -3,7 +3,7 @@
        <tizen:application id="QmwDyrmOzO.BluetoothChat" package="QmwDyrmOzO" required_version="2.2"/>
        <content src="index.html"/>
        <icon src="icon.png"/>
-       <name>BluetoothChat</name>
+       <name>Bluetooth chat</name>
        <tizen:privilege name="http://tizen.org/privilege/application.launch"/>
        <tizen:privilege name="http://tizen.org/privilege/bluetooth.admin"/>
        <tizen:privilege name="http://tizen.org/privilege/bluetooth.gap"/>
index 02bdcf7..b58c955 100644 (file)
@@ -16,7 +16,7 @@
 }
 
 #chat-header .ui-btn-footer-down {
-       width: 45px;
+       top: 19px;
        right: 0px;
 }
 
@@ -75,10 +75,7 @@ html {
 }
 
 #keyboard-ok-button {
-       position: absolute;
-       right: 5px;
-       bottom: 15px;
-       width: 40px;
+       width: 30%;
 }
 
 #ui-textArea {
@@ -143,6 +140,10 @@ html {
        font-size: 1.4em;
 }
 
+#chat-header {
+       min-height: 2.5em;
+}
+
 #chat-header-type {
        font-size: 0.5em;
        position: absolute;
@@ -173,8 +174,12 @@ html {
 }
 
 #discovering {
-       right: 17px;
-       top: 17px;
+       right: 8px;
+       top: 8px;
 }
 
-.focus {}
\ No newline at end of file
+.focus {}
+
+.ui-btn-back {
+       visibility:hidden;
+}
index de43bf8..4d378c2 100644 (file)
@@ -16,7 +16,7 @@
 </head>
 
 <body>
-       <div id="start" data-role="page" data-add-back-btn="header">
+       <div id="start" data-role="page">
                <div id="start-header" data-role="header" data-position="fixed">
                        <h1>Bluetooth chat</h1>
                </div>
@@ -27,7 +27,7 @@
                                <div data-role="button" class="ui-btn-start" id="clientButton" style="display: none;">Join server</div>
                                <div data-role="button" class="ui-btn-start" id="turnOnButton" style="display: none;">Turn bluetooth on</div>
                                <div id="start-monit" style="display: none;">
-                                       <p>... waiting for bluetooth radio ...</p>
+                                       <p>Waiting for Bluetooth radio...</p>
                                </div>
                        </div>
                </div>
index d76f756..0d0088f 100644 (file)
@@ -89,13 +89,7 @@ function UiEvents(parent) {
                                setTimeout(function () { $('#keyboard-text').focus(); }, 500);
                        });
 
-                       $('#keyboard-header').on('tap', '#keyboard-back-button', function (event) {
-                               event.preventDefault();
-                               app.setDoNotSendBye(true);
-                               $.mobile.changePage('#start');
-                       });
-
-                       $('#keyboard-header').on('tap', '#keyboard-ok-button', function (event) {
+                       $('#keyboard-ok-button').on('tap', function (event) {
                                event.preventDefault();
                                var value = $('#keyboard-text').val(), mode;
                                if (value.length !== 0) {
@@ -147,6 +141,28 @@ function UiEvents(parent) {
                                self.ui.checkSendButtonState();
                        });
 
+                       $('#text').on('focus', function () {
+                               var content = $('#chat-content');
+                               if (self.ui.scrolltimeout !== null) {
+                                       clearTimeout(self.ui.scrolltimeout);
+                               }
+                               self.ui.scrolltimeout = setTimeout(function () {
+                                       self.ui.scrolltimeout = null;
+                                       self.ui.scrollToBottom(content);
+                               }, 1000);
+                       });
+
+                       $('#text').on('blur', function () {
+                               var content = $('#chat-content');
+                               if (self.ui.scrolltimeout !== null) {
+                                       clearTimeout(self.ui.scrolltimeout);
+                               }
+                               self.ui.scrolltimeout = setTimeout(function () {
+                                       self.ui.scrolltimeout = null;
+                                       self.ui.scrollToBottom(content);
+                               }, 700);
+                       });
+
                        $('#ui-mySend').on('tap', function (event) {
                                event.stopPropagation();
                                var message = $('#text').val();
@@ -172,10 +188,21 @@ function UiEvents(parent) {
                                $('#visibilityOK').trigger('tap');
                        });
 
-                       document.addEventListener('tizenhwkey', function(e) {
+                       $('#chat-content').on('touchstart', function () {
+                               if (self.ui.scrolltimeout !== null) {
+                                       clearTimeout(self.ui.scrolltimeout);
+                                       self.ui.scrolltimeout = null;
+                               }
+                       });
+
+                       window.addEventListener('tizenhwkey', function(e) {
                                if (e.keyName == "back") {
+                                       event.preventDefault();
+                                       app.setDoNotSendBye(true);
                                        if ($.mobile.activePage.attr('id') === 'start') {
                                                tizen.application.getCurrentApplication().exit();
+                                       } else if ($.mobile.activePage.attr('id') === 'chat') {
+                                               $.mobile.changePage('#start');
                                        } else {
                                                history.back();
                                        }
index e35250c..243adef 100644 (file)
@@ -20,6 +20,11 @@ function Ui(callback) {
                uiEvents: null,
 
                /**
+                * Timeout for chat scroll.
+                */
+               scrolltimeout: null,
+
+               /**
                 * UI module initialisation
                 */
                init: function Ui_init(callback) {
@@ -197,11 +202,9 @@ function Ui(callback) {
                        }
                },
 
-               moveMessagesListDown: function Ui_moveMessagesListDown(content, listHeight) {
-                       var delta = content.height() - listHeight;
-                       if (delta < 0) {
-                               content.scrollview('scrollTo', 0, delta, 500);
-                       }
+               scrollToBottom: function Ui_scrollToBottom(element) {
+                       var bottom = element.children().first().outerHeight(true) - element.height();
+                       element.scrollview('scrollTo', 0, -Math.max(0, bottom), 0);
                },
 
                displaySentMessage: function Ui_displaySentMessage(message) {
@@ -215,7 +218,10 @@ function Ui(callback) {
                        ul.append(listElement);
                        ul.listview('refresh');
                        this.checkSendButtonState();
-                       setTimeout(function () { self.moveMessagesListDown(content, ul.height()); }, 200);
+                       this.scrolltimeout = setTimeout(function () {
+                               self.scrolltimeout = null;
+                               self.scrollToBottom(content);
+                       }, 700);
                },
 
                setDiscoveringProgress: function Ui_setDiscoveringProgress(boolean) {
index 0b4b14f..c2c58dc 100644 (file)
@@ -1,4 +1,4 @@
-<div id="chat" data-role="page" data-add-back-btn="header" data-footer-exist="true">
+<div id="chat" data-role="page" data-footer-exist="true">
        <div id="chat-header" data-role="header" data-position="fixed">
                <h1><span id="chat-header-type"></span><span id="chat-header-name"></span></h1>
        </div>
index fd8e31a..102d358 100644 (file)
@@ -1,4 +1,4 @@
-<div data-role="page" id="choose" data-add-back-btn="footer" data-footer-exist="true">
+<div data-role="page" id="choose">
        <div data-role="header" id="choose-header" data-position="fixed">
                <h1>Choose your server</h1>
                <div data-role="progress" data-style="circle" id="discovering"></div>
@@ -7,6 +7,4 @@
        <div data-role="content" id="choose-content">
                <ul data-role="listview"></ul>
        </div>
-
-       <div data-role="footer" data-position="fixed" id="choose-footer"></div>
 </div>
\ No newline at end of file
index ed229ab..d9b1fef 100644 (file)
@@ -1,11 +1,10 @@
 <div data-role="page" id="keyboard" data-add-back-btn="none">
        <div data-role="header" id="keyboard-header" data-position="fixed">
                <h1></h1>
-               <a data-role="button" id="keyboard-ok-button">OK</a>
-               <a data-role="button" id="keyboard-back-button">Back</a>
        </div>
 
        <div data-role="content" id="keyboard-content">
                <input type="text" id="keyboard-text" maxlength="20"/>
+               <div data-role="button" class="ui-btn-start" id="keyboard-ok-button">OK</div>
        </div>
 </div>
\ No newline at end of file