mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-23 04:15:26 +00:00
Initial Sass and JavaScript files
This commit is contained in:
@@ -0,0 +1,209 @@
|
||||
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* JavaScript for SOGoContacts */
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
angular.module('SOGo').config(['$routeProvider', function($routeProvider) {
|
||||
$routeProvider
|
||||
.when('/:addressbook_id', {
|
||||
controller: 'contactDisplayController',
|
||||
templateUrl: 'rightPanel.html'
|
||||
})
|
||||
.when('/:addressbook_id/:contact_id', {
|
||||
controller: 'contactDisplayController',
|
||||
templateUrl: 'rightPanel.html'
|
||||
})
|
||||
.otherwise({
|
||||
redirectTo: '/personal'
|
||||
});
|
||||
}]);
|
||||
|
||||
angular.module('SOGo').directive('sgFocusOn', function() {
|
||||
return function(scope, elem, attr) {
|
||||
scope.$on('sgFocusOn', function(e, name) {
|
||||
if (name === attr.sgFocusOn) {
|
||||
elem[0].focus();
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
angular.module('SOGo').factory('sgFocus', ['$rootScope', '$timeout', function ($rootScope, $timeout) {
|
||||
return function(name) {
|
||||
$timeout(function (){
|
||||
$rootScope.$broadcast('sgFocusOn', name);
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
// angular.module('SOGo').provider('Contact', function() {
|
||||
// var folders = contactFolders;
|
||||
// var selectedIndex;
|
||||
// this.$get = [function() {
|
||||
// var self = this;
|
||||
// var service = {
|
||||
// getFoldersList: function() {
|
||||
// return folders
|
||||
// },
|
||||
// selectFolder: function(index) {
|
||||
// selectedIndex = index;
|
||||
// },
|
||||
// currentFolder: function() {
|
||||
// return selectedIndex;
|
||||
// }
|
||||
// };
|
||||
// return service;
|
||||
// }];
|
||||
// });
|
||||
|
||||
// angular.module('SOGo').controller('addressbookSharingModal', ['$scope', '$rootScope', '$modal', function($scope, $rootScope, $modal) {
|
||||
|
||||
// }]);
|
||||
|
||||
angular.module('SOGo').controller('addressbooksList', ['$scope', '$rootScope', '$timeout', '$modal', 'sgFocus', 'sgContact', 'sgAddressBook', function($scope, $rootScope, $timeout, $modal, focus, Contact, AddressBook) {
|
||||
// Initialize with data from template
|
||||
// $rootScope.addressbooks = new Array();
|
||||
// angular.forEach(contactFolders, function(folder, index) {
|
||||
// $rootScope.addressbooks.push(new AddressBook(folder));
|
||||
// // contactFolders[index].$omit();
|
||||
// });
|
||||
//$scope.contactFolders = contactFolders;
|
||||
$rootScope.addressbooks = contactFolders;
|
||||
$scope.select = function(rowIndex) {
|
||||
//$rootScope.selectedAddressBook = $scope.contactFolders[rowIndex];
|
||||
$scope.editMode = false;
|
||||
};
|
||||
// $rootScope.$on('AddressBook:selected', function(event, id) {
|
||||
// $rootScope.selectedAddressBook = id;
|
||||
// });
|
||||
$scope.rename = function() {
|
||||
console.debug("rename folder");
|
||||
$scope.editMode = $rootScope.addressbook.id;
|
||||
focus('folderName');
|
||||
};
|
||||
$scope.save = function() {
|
||||
console.debug("save addressbook");
|
||||
$rootScope.addressbook.$save()
|
||||
.then(function(data) {
|
||||
console.debug("saved!");
|
||||
$scope.editMode = false;
|
||||
}, function(data, status) {
|
||||
console.debug("failed");
|
||||
});
|
||||
};
|
||||
$scope.sharing = function() {
|
||||
var modal = $modal.open({
|
||||
templateUrl: 'addressbookSharing.html',
|
||||
//controller: 'addressbookSharingCtrl'
|
||||
controller: function($scope, $modalInstance) {
|
||||
$scope.closeModal = function() {
|
||||
console.debug('please close it');
|
||||
$modalInstance.close();
|
||||
};
|
||||
}
|
||||
});
|
||||
// modal.result.then(function() {
|
||||
// console.debug('close');
|
||||
// }, function() {
|
||||
// console.debug('dismiss');
|
||||
// });
|
||||
};
|
||||
// $scope.rename = function(rowIndex) {
|
||||
// var folder = $scope.contactFolders[rowIndex];
|
||||
// if (folder.owner != "nobody") {
|
||||
// showPromptDialog(l("Properties"),
|
||||
// l("Address Book Name"),
|
||||
// onAddressBookModifyConfirm,
|
||||
// folder.name);
|
||||
// }
|
||||
// };
|
||||
}]);
|
||||
|
||||
// angular.module('SOGo').controller('addressbookSharingCtrl', ['$scope', '$modalInstance', function($scope, modal) {
|
||||
// $scope.closeModal = function() {
|
||||
// console.debug('please close it');
|
||||
// modal.close();
|
||||
// };
|
||||
// }]);
|
||||
|
||||
|
||||
angular.module('SOGo').controller('contactDisplayController', ['$scope', '$rootScope', 'sgAddressBook', 'sgContact', 'sgFocus', '$routeParams', function($scope, $rootScope, AddressBook, Contact, focus, $routeParams) {
|
||||
if ($routeParams.addressbook_id &&
|
||||
($rootScope.addressbook == undefined || $routeParams.addressbook_id != $rootScope.addressbook.id)) {
|
||||
// Selected addressbook has changed
|
||||
console.debug("show addressbook " + $routeParams.addressbook_id);
|
||||
$rootScope.addressbook = AddressBook.$find($routeParams.addressbook_id);
|
||||
// Extend resulting model instance with parameters from addressbooks listing
|
||||
angular.forEach($rootScope.addressbooks, function(o, i) {
|
||||
if (o.id == $routeParams.addressbook_id) {
|
||||
angular.extend($rootScope.addressbook, o);
|
||||
$rootScope.addressbooks[i] = $rootScope.addressbook;
|
||||
}
|
||||
});
|
||||
angular.extend($rootScope.addressbook, $rootScope.selectedAddressBook);
|
||||
}
|
||||
|
||||
if ($routeParams.contact_id) {
|
||||
console.debug("show contact " + $routeParams.contact_id);
|
||||
$rootScope.addressbook.$getContact($routeParams.contact_id);
|
||||
$scope.editMode = false;
|
||||
}
|
||||
$scope.allEmailTypes = Contact.$email_types;
|
||||
$scope.allTelTypes = Contact.$tel_types;
|
||||
$scope.allUrlTypes = Contact.$url_types;
|
||||
$scope.allAddressTypes = Contact.$address_types;
|
||||
// $scope.select = function(cname) {
|
||||
// console.debug('show contact ' + cname);
|
||||
// };
|
||||
$scope.edit = function() {
|
||||
$rootScope.master_contact = angular.copy($rootScope.addressbook.contact);
|
||||
$scope.editMode = true;
|
||||
console.debug('edit');
|
||||
};
|
||||
$scope.addOrgUnit = function() {
|
||||
var i = $rootScope.addressbook.contact.$addOrgUnit('');
|
||||
focus('orgUnit_' + i);
|
||||
};
|
||||
$scope.addCategory = function() {
|
||||
var i = $rootScope.addressbook.contact.$addCategory($scope.new_category);
|
||||
focus('category_' + i);
|
||||
};
|
||||
$scope.addEmail = function() {
|
||||
var i = $rootScope.addressbook.contact.$addEmail($scope.new_email_type);
|
||||
focus('email_' + i);
|
||||
};
|
||||
$scope.addPhone = function() {
|
||||
var i = $rootScope.addressbook.contact.$addPhone($scope.new_phone_type);
|
||||
focus('phone_' + i);
|
||||
};
|
||||
$scope.addUrl = function() {
|
||||
var i = $rootScope.addressbook.contact.$addUrl('', '');
|
||||
focus('url_' + i);
|
||||
};
|
||||
$scope.addAddress = function() {
|
||||
var i = $rootScope.addressbook.contact.$addAddress('', '', '', '', '', '', '', '');
|
||||
focus('address_' + i);
|
||||
};
|
||||
$scope.save = function(contactForm) {
|
||||
console.debug("save");
|
||||
if (contactForm.$valid) {
|
||||
$rootScope.addressbook.contact.$save()
|
||||
.then(function(data) {
|
||||
console.debug("saved!");
|
||||
$scope.editMode = false;
|
||||
}, function(data, status) {
|
||||
console.debug("failed");
|
||||
});
|
||||
}
|
||||
};
|
||||
$scope.cancel = function() {
|
||||
$scope.reset();
|
||||
$scope.editMode = false;
|
||||
};
|
||||
$scope.reset = function() {
|
||||
$rootScope.addressbook.contact = angular.copy($rootScope.master_contact);
|
||||
};
|
||||
}]);
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,8 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
angular.module('SOGo', ['ngRoute', 'ngSanitize', 'mm.foundation', 'mm.foundation.offcanvas'])
|
||||
.constant('sgSettings', {
|
||||
'baseURL': '/SOGo/so/francis/Contacts'
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,45 @@
|
||||
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* JavaScript for SOGoContacts */
|
||||
|
||||
'use strict';
|
||||
|
||||
var SOGoRootPageApp = angular.module('SOGoRootPage', ['SOGoAuthentication']);
|
||||
|
||||
SOGoRootPageApp.controller('loginController', ['$scope', '$http', 'SOGoAuthentication', function($scope, $http, SOGoAuthentication) {
|
||||
$scope.warning = false;
|
||||
$scope.login = function($event) {
|
||||
//$event.stopPropagation();
|
||||
$scope.warning = false;
|
||||
|
||||
var username = $scope.username,
|
||||
password = $scope.password,
|
||||
domain = $scope.domain,
|
||||
language,
|
||||
rememberLogin = $scope.rememberLogin ? 1 : 0;
|
||||
|
||||
if ($scope.loginSuffix && !username.endsWith($scope.loginSuffix)) {
|
||||
username += loginSuffix;
|
||||
domain = false;
|
||||
}
|
||||
if ($scope.language && $scope.language != 'WONoSelectionString') {
|
||||
language = $scope.language;
|
||||
}
|
||||
|
||||
SOGoAuthentication.login(username, password, domain, language, rememberLogin)
|
||||
.then(function(url) {
|
||||
window.location.href = url;
|
||||
}, function(msg) {
|
||||
$scope.warning = msg;
|
||||
});
|
||||
// $http({
|
||||
// method: 'POST',
|
||||
// url: 'http://debian.inverse.ca/SOGo/connect',
|
||||
// params: postData})
|
||||
// .success(function(data, status, headers, config) {
|
||||
// alert('success: ' + status);
|
||||
// }).error(function(data, status, headers, config) {
|
||||
// alert('error: ' + status);
|
||||
// });
|
||||
return false;
|
||||
};
|
||||
}]);
|
||||
@@ -0,0 +1,84 @@
|
||||
//$(document).foundation();
|
||||
|
||||
String.prototype.endsWith = function(suffix) {
|
||||
return this.indexOf(suffix, this.length - suffix.length) !== -1;
|
||||
};
|
||||
|
||||
String.prototype.startsWith = function(pattern, position) {
|
||||
position = angular.isNumber(position) ? position : 0;
|
||||
return this.lastIndexOf(pattern, position) === position;
|
||||
};
|
||||
|
||||
String.prototype._base64_keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||
String.prototype.base64encode = function () {
|
||||
var output = "";
|
||||
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
|
||||
var i = 0;
|
||||
|
||||
var input = this.utf8encode();
|
||||
|
||||
while (i < input.length) {
|
||||
chr1 = input.charCodeAt(i++);
|
||||
chr2 = input.charCodeAt(i++);
|
||||
chr3 = input.charCodeAt(i++);
|
||||
|
||||
enc1 = chr1 >> 2;
|
||||
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
|
||||
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
|
||||
enc4 = chr3 & 63;
|
||||
|
||||
if (isNaN(chr2)) {
|
||||
enc3 = enc4 = 64;
|
||||
} else if (isNaN(chr3)) {
|
||||
enc4 = 64;
|
||||
}
|
||||
|
||||
output = output +
|
||||
this._base64_keyStr.charAt(enc1) + this._base64_keyStr.charAt(enc2) +
|
||||
this._base64_keyStr.charAt(enc3) + this._base64_keyStr.charAt(enc4);
|
||||
}
|
||||
|
||||
return output;
|
||||
};
|
||||
|
||||
String.prototype.base64decode = function() {
|
||||
var output = "";
|
||||
var chr1, chr2, chr3;
|
||||
var enc1, enc2, enc3, enc4;
|
||||
var i = 0;
|
||||
|
||||
var input = "" + this; // .replace(/[^A-Za-z0-9\+\/\=]/g, "")
|
||||
while (i < input.length) {
|
||||
enc1 = this._base64_keyStr.indexOf(input.charAt(i++));
|
||||
enc2 = this._base64_keyStr.indexOf(input.charAt(i++));
|
||||
enc3 = this._base64_keyStr.indexOf(input.charAt(i++));
|
||||
enc4 = this._base64_keyStr.indexOf(input.charAt(i++));
|
||||
|
||||
chr1 = (enc1 << 2) | (enc2 >> 4);
|
||||
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
||||
chr3 = ((enc3 & 3) << 6) | enc4;
|
||||
|
||||
output = output + String.fromCharCode(chr1);
|
||||
|
||||
if (enc3 != 64) {
|
||||
output = output + String.fromCharCode(chr2);
|
||||
}
|
||||
if (enc4 != 64) {
|
||||
output = output + String.fromCharCode(chr3);
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
};
|
||||
|
||||
function l(key) {
|
||||
var value = key;
|
||||
if (labels[key]) {
|
||||
value = labels[key];
|
||||
}
|
||||
else if (clabels[key]) {
|
||||
value = clabels[key];
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
Reference in New Issue
Block a user