[CallLog] updated CallLog sources
authorPiotr Dabrowski <p.dabrowski2@samsung.com>
Fri, 30 Aug 2013 13:56:07 +0000 (15:56 +0200)
committerPiotr Dabrowski <p.dabrowski2@samsung.com>
Fri, 30 Aug 2013 13:56:07 +0000 (15:56 +0200)
Change-Id: I65370dc28ac19c88837bc55a47fffd812f10384f

css/style.css
js/app.helpers.js
js/app.ui.js
templates/callView.tpl

index 6a400d7..68171d9 100644 (file)
@@ -29,8 +29,10 @@ li {
        border-bottom: 1px solid #5A99BA;
        padding: 8px 8px 6px 8px;
        background-color: #FFF;
-       /*float: left;*/
+       /*
+       float: left;
        width: 100%;
+       */
 }
 
 #delete span {
index 594f1f8..08f8c4c 100644 (file)
@@ -48,6 +48,37 @@ function Helpers() {
                        str = ((seconds % 24 < 10) ? '0' : '') + (seconds % 24) + str;
                        seconds = parseInt(seconds / 24, 10);
                        return str;
+               },
+
+               /**
+                * Returns scroll position of the given scroll view.
+                * @param {object} element ScrollView element
+                * @returns {number} scroll position
+                */
+               getScrollPosition: function Helpers_getScrollPosition(element) {
+                       return element.scrollview('getScrollPosition').y;
+               },
+
+               /**
+                * Scrolls given jQuery ScrollView to given Y position.
+                * @param {object} element ScrollView element to be scrolled.
+                * @param {number} position Y position to scroll to
+                */
+               scrollTo: function Helpers_scrollTo(element, position) {
+                       // don't allow scrolling too much
+                       var maxPosition = element.children().first().outerHeight(true) - element.height();
+                       if (maxPosition < 0) {
+                               maxPosition = 0;
+                       }
+                       if (position > maxPosition) {
+                               position = maxPosition;
+                       }
+                       if (position < 0) {
+                               position = 0;
+                       }
+                       // scroll
+                       element.scrollview('scrollTo', 0, -position);
                }
+
        };
 }());
index f980b70..518a6bb 100644 (file)
@@ -422,7 +422,10 @@ function Ui(contacts) {
                                filterResult,
                                groupsOfDays = [],
                                dayLog,
-                               index = 0;
+                               index = 0,
+                               calllogList = $('#calllogList'),
+                               calllogListContent = $('#calllogListContent'),
+                               calllogListContentPos;
 
                        function filterForSameEntry(element) {
                                return self.getNumber(current) === self.getNumber(element)
@@ -471,14 +474,13 @@ function Ui(contacts) {
                                        elements.push(this.getCallItemRow(dayLog.entries[j], dayLog.counters[j]));
                                }
                        }
-                       $('#calllogList')
-                               .empty()
-                               .append(elements);
+                       calllogListContentPos = this.helpers.getScrollPosition(calllogListContent);
+                       calllogList.empty().append(elements);
 
                        /* workaround solution for not auto refreshing list view*/
                        setTimeout(function () {
                                // original code, do not remove until web-ui release; N_SE-48946
-                               $( "#calllogList" ).listview({
+                               calllogList.listview({
                                        autodividers: true,
                                        //filter: true,
                                        autodividersSelector: function ( li ) {
@@ -498,6 +500,8 @@ function Ui(contacts) {
                                        .removeClass('hidden');
                                $('#forCallerList .toRemove').show()
                        }
+
+                       setTimeout(this.helpers.scrollTo.bind(this, calllogListContent, calllogListContentPos), 10);
                },
 
                /**
index 1f5a3f3..15c7610 100644 (file)
@@ -2,7 +2,7 @@
                <div data-role="header" id="page-header" data-position="fixed">
                        <h1>Call log</h1>
                </div>
-               <div data-role="content">
+               <div data-role="content" id="calllogListContent">
                        <ul data-role="listview"
                                id="calllogList"
                                data-filter="true"