From 8f0bcf29205997d746e37efec885e5567ed77e7f Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Tue, 16 Sep 2014 20:17:39 +0000 Subject: [PATCH] Prepare JS AJAX interactions. Show phone numbers into the appropriate div. Import some CSS things. Cleanup JS code --- controller/smscontroller.php | 1 + css/style.css | 30 ++++++++++++++++++++++++++++++ js/script.js | 30 +++++++++++++++++------------- templates/main.php | 2 ++ templates/part.navigation.php | 2 +- 5 files changed, 51 insertions(+), 14 deletions(-) diff --git a/controller/smscontroller.php b/controller/smscontroller.php index 718e456..fb342b4 100644 --- a/controller/smscontroller.php +++ b/controller/smscontroller.php @@ -38,6 +38,7 @@ class SmsController extends Controller { $mboxes = array( 'PNLConversations' => array( 'label' => 'Conversations', + 'phoneNumbers' => $this->smsMapper->getAllPeersPhoneNumbers($this->userId), 'url' => \OCP\Util::linkToAbsolute('index.php', 'apps/ocsms/', array('feed' => 'conversations')) ), 'PNLDrafts' => array( diff --git a/css/style.css b/css/style.css index 81503d2..62bb501 100644 --- a/css/style.css +++ b/css/style.css @@ -13,3 +13,33 @@ -ms-user-select: none; user-select: none; } + +#app-mailbox-peers > ul { + position: relative; + height: 100%; + overflow: auto; + -moz-box-sizing: border-box; box-sizing: border-box; +} +#app-mailbox-peers li { + position: relative; + width: 100%; + -moz-box-sizing: border-box; box-sizing: border-box; +} + +#app-mailbox-peers li:hover > a, +#app-mailbox-peers .selected, +#app-mailbox-peers .selected a { + background-color: #ccc; +} + +#app-mailbox-peers li > a { + display: block; + width: 100%; + line-height: 44px; + padding: 0 12px; + overflow: hidden; + -moz-box-sizing: border-box; box-sizing: border-box; + white-space: nowrap; + text-overflow: ellipsis; + color: #333; +} diff --git a/js/script.js b/js/script.js index 498a7da..f51a25b 100644 --- a/js/script.js +++ b/js/script.js @@ -9,23 +9,27 @@ */ (function ($, OC) { - $(document).ready(function () { - $('#push').click(function () { - var url = OC.generateUrl('/apps/ocsms/push'); - var data = { - smsCount: 2, - smsDatas: [ - {"read": true, "date": 1410524385, "seen": false, "draft": false, "address": "+33612121212", "body": "testSMS", "id": 10}, - {"read": false, "date": 1400524385, "seen": true, "draft": true, "address": "+33614121212", "body": "test SMS 2", "id": 14}, - ] - }; + // Now bind the events when we click on the phone number + $('#app-navigation').find('a').on('click', function (event) { + OC.Util.History.pushState('feed=' + $(this).attr('nav-feed')); + event.preventDefault(); + }); - $.post(url, data).success(function (response) { - $('#push-result').text(response); + $.getJSON(OC.generateUrl('/apps/ocsms/get/peerlist'), function(jsondata, status) { + var peerListBuf = ""; + $.each(jsondata['phonelist'], function(id, val) { + peerListBuf += '
  • ' + val + '
  • '; }); + $('#app-mailbox-peers ul').html(peerListBuf); + + // Now bind the events when we click on the phone number + $('#app-mailbox-peers').find('a[mailbox-navigation]').on('click', function (event) { + OC.Util.History.pushState('phonenumber=' + $(this).attr('mailbox-navigation')); + event.preventDefault(); + }); - }); + }); }); })(jQuery, OC); diff --git a/templates/main.php b/templates/main.php index 4073351..23a9f87 100644 --- a/templates/main.php +++ b/templates/main.php @@ -9,6 +9,8 @@
    +
    diff --git a/templates/part.navigation.php b/templates/part.navigation.php index a1b62d9..f97f8c9 100644 --- a/templates/part.navigation.php +++ b/templates/part.navigation.php @@ -1,7 +1,7 @@