2014-09-24 22:06:12 +02:00
|
|
|
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2014-09-05 21:12:05 +02:00
|
|
|
/* JavaScript for common UI services for mobile theme */
|
2014-08-06 22:11:39 +02:00
|
|
|
|
|
|
|
(function() {
|
2014-09-24 22:06:12 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name Dialog
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
function Dialog() {
|
|
|
|
}
|
|
|
|
|
|
|
|
Dialog.alert = function(title, content) {
|
|
|
|
var alertPopup = this.$ionicPopup.alert({
|
|
|
|
title: title,
|
|
|
|
template: content
|
|
|
|
});
|
|
|
|
return alertPopup;
|
|
|
|
};
|
|
|
|
|
|
|
|
Dialog.confirm = function(title, content) {
|
|
|
|
var confirmPopup = this.$ionicPopup.confirm({
|
|
|
|
title: title,
|
|
|
|
template: content
|
|
|
|
});
|
|
|
|
return confirmPopup;
|
|
|
|
};
|
|
|
|
|
|
|
|
Dialog.prompt = function(title, content) {
|
|
|
|
var promptPopup = this.$ionicPopup.prompt({
|
|
|
|
title: title,
|
|
|
|
inputPlaceholder: content
|
|
|
|
});
|
|
|
|
return promptPopup;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @memberof Dialog
|
|
|
|
* @desc The factory we'll register as sgDialog in the Angular module SOGo.UIMobile
|
|
|
|
*/
|
|
|
|
Dialog.$factory = ['$ionicPopup', function($ionicPopup) {
|
|
|
|
angular.extend(Dialog, { $ionicPopup: $ionicPopup });
|
|
|
|
|
|
|
|
return Dialog; // return constructor
|
|
|
|
}];
|
|
|
|
|
|
|
|
/* Angular module instanciation */
|
2014-11-23 07:09:04 +01:00
|
|
|
angular.module('SOGo.UIMobile', ['ionic', 'RecursionHelper'])
|
2014-09-24 22:06:12 +02:00
|
|
|
|
|
|
|
/* Factory registration in Angular module */
|
2014-11-23 07:09:04 +01:00
|
|
|
.factory('sgDialog', Dialog.$factory)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sgFolderTree - Provides hierarchical folders tree
|
|
|
|
* @memberof SOGo.UIDesktop
|
|
|
|
* @restrict element
|
|
|
|
* @see https://github.com/marklagendijk/angular-recursion
|
|
|
|
* @example:
|
|
|
|
|
|
|
|
<sg-folder-tree data-ng-repeat="folder in folders track by folder.id"
|
|
|
|
data-sg-root="account"
|
|
|
|
data-sg-folder="folder"
|
|
|
|
data-sg-set-folder="setCurrentFolder"><!-- tree --></sg-folder-tree>
|
|
|
|
*/
|
|
|
|
.directive("sgFolderTree", function(RecursionHelper) {
|
|
|
|
return {
|
|
|
|
restrict: "E",
|
|
|
|
scope: {
|
|
|
|
root: '=sgRoot',
|
|
|
|
folder: '=sgFolder',
|
2014-12-02 15:45:01 +01:00
|
|
|
setFolder: '=sgSetFolder',
|
|
|
|
edit: '=sgEdit'
|
2014-11-23 07:09:04 +01:00
|
|
|
},
|
|
|
|
template:
|
|
|
|
'<ion-item option-buttons="buttons" class="item-icon-left item-icon-right"' +
|
|
|
|
' ng-click="setFolder(root, folder)">' +
|
|
|
|
' <i class="icon ion-folder"><!-- mailbox --></i>{{folder.name}}' +
|
|
|
|
' <i class="icon ion-ios7-arrow-right"><!-- right arrow icon --></i>' +
|
|
|
|
' <ion-option-button class="button-info"' +
|
|
|
|
' ng-click="edit(folder)">{{"Edit" | loc}}</ion-option-button>' +
|
|
|
|
'</ion-item>' +
|
|
|
|
'<div>' +
|
|
|
|
' <span ng-repeat="child in folder.children track by child.id">' +
|
|
|
|
' <sg-folder-tree sg-root="root" sg-folder="child" sg-set-folder="setFolder"></sg-folder-tree>' +
|
|
|
|
' </span>' +
|
|
|
|
'</div>',
|
|
|
|
compile: function(element) {
|
|
|
|
return RecursionHelper.compile(element, function(scope, iElement, iAttrs, controller, transcludeFn) {
|
|
|
|
var level = scope.folder.path.split('/').length - 1;
|
|
|
|
iElement.find('ion-item').addClass('childLevel' + level);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2014-08-06 22:11:39 +02:00
|
|
|
})();
|