1
0
mirror of https://github.com/nerzhul/ocsms.git synced 2025-06-07 16:06:15 +00:00

Prepare angular.js template. Merge controllers into one global controller

This commit is contained in:
Loic Blot 2015-01-10 13:40:33 +00:00
parent 642f78e859
commit 13e3d47620
2 changed files with 10 additions and 13 deletions

View File

@ -22,27 +22,21 @@ var originalTitle = document.title;
var app = angular.module('OcSms', ['OC']);
app.controller('SettingsController', ['$scope',
app.controller('OcSmsController', ['$scope',
function ($scope) {
$scope.buttons = [
{text: "Send"}
];
$scope.contacts = [];
$scope.sendCountry = function () {
$.post(OC.generateUrl('/apps/ocsms/set/country'),{'country': $('select[name=intl_phone]').val()});
};
}
]);
app.controller('ContactsController' ['$scope',
function ($scope) {
$scope.loadConversation = function () {
alert('loadConversation');
};
}
]);
$.urlParam = function(name){
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
if (results == null) {
@ -116,7 +110,7 @@ var checkNewMessages = function() {
if (typeof jsondata['photos'][peerLabel] != 'undefined') {
peerListBuf += 'style="background-image: url(' + jsondata['photos'][peerLabel] + ');"';
}
peerListBuf += '></div><a href="#" ng-click="ctCtl.loadConversation();" mailbox-navigation="' + idxVal2 + '" style="font-weight: bold;" mailbox-label="' + peerLabel + '">' + peerLabel + ' (' + val + ')</a></li>';
peerListBuf += '></div><a href="#" ng-click="loadConversation();" mailbox-navigation="' + idxVal2 + '" style="font-weight: bold;" mailbox-label="' + peerLabel + '">' + peerLabel + ' (' + val + ')</a></li>';
$('#app-mailbox-peers ul').prepend(peerListBuf);
bufferedContacts.push(peerLabel);
@ -320,7 +314,7 @@ function fetchInitialPeerList(jsondata) {
if (typeof jsondata['photos'][peerLabel] != 'undefined') {
peerListBuf += 'style="background-image: url(' + jsondata['photos'][peerLabel] + ');"';
}
peerListBuf += '></div><a href="#" ng-click="ctCtl.loadConversation();" mailbox-navigation="' + idxVal2 + '" mailbox-label="' + peerLabel + '">' + peerLabel + '</a></li>';
peerListBuf += '></div><a href="#" ng-click="loadConversation();" mailbox-navigation="' + idxVal2 + '" mailbox-label="' + peerLabel + '">' + peerLabel + '</a></li>';
bufferedContacts.push(peerLabel);
}
});

View File

@ -7,17 +7,20 @@ use \OCA\OcSms\Lib\CountryCodes;
\OCP\Util::addStyle('ocsms', 'style');
?>
<div class="ng-scope" id="app" ng-app="OcSms">
<div class="ng-scope" id="app" ng-app="OcSms" ng-controller="OcSmsController">
<div id="app-mailbox-peers">
<ul>
<li><div id="ocsms-empty-peers">There isn't any conversation</div></li>
<li ng-repeat="contact in contacts">
<div class="ocsms-plavatar"></div>
<a mailbox-label="{{ contact.label }}" mailbox-navigation="{{ contact.nav }}" ng-click="loadConversation();" href="#">{{ contact.label }}</a>
</li>
</ul>
</div>
<div id="app-settings" class="ng-scope">
<div id="app-settings-header">
<button name="app settings" class="settings-button" data-apps-slide-toggle="#app-settings-content"></button>
</div>
<div id="app-settings-content" ng-controller="SettingsController">
<div id="app-settings-content">
<select name="intl_phone">
<?php foreach (CountryCodes::$codes as $code => $cval) { ?>
<option><?php p($code); ?></option>