summaryrefslogtreecommitdiff
path: root/web-ui/app/js/mail_view/ui/recipients/recipients_iterator.js
diff options
context:
space:
mode:
Diffstat (limited to 'web-ui/app/js/mail_view/ui/recipients/recipients_iterator.js')
-rw-r--r--web-ui/app/js/mail_view/ui/recipients/recipients_iterator.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/web-ui/app/js/mail_view/ui/recipients/recipients_iterator.js b/web-ui/app/js/mail_view/ui/recipients/recipients_iterator.js
new file mode 100644
index 00000000..73aefc79
--- /dev/null
+++ b/web-ui/app/js/mail_view/ui/recipients/recipients_iterator.js
@@ -0,0 +1,41 @@
+define(['helpers/iterator'], function (Iterator) {
+
+ return RecipientsIterator;
+
+ function RecipientsIterator(options) {
+
+ this.iterator = new Iterator(options.elements, options.elements.length - 1);
+ this.input = options.exitInput;
+
+ this.current = function () {
+ return this.iterator.current();
+ };
+
+ this.moveLeft = function () {
+ if (this.iterator.hasPrevious()) {
+ this.iterator.current().unselect();
+ this.iterator.previous().select();
+ }
+ };
+
+ this.moveRight = function () {
+ this.iterator.current().unselect();
+ if (this.iterator.hasNext()) {
+ this.iterator.next().select();
+ } else {
+ this.input.focus();
+ }
+ };
+
+ this.deleteCurrent = function () {
+ this.iterator.removeCurrent().destroy();
+
+ if (this.iterator.hasElements()) {
+ this.iterator.current().select()
+ } else {
+ this.input.focus();
+ }
+ };
+ }
+
+}); \ No newline at end of file