[DE] Add user email to comment
This commit is contained in:
parent
58a1ddb834
commit
145008eaae
|
@ -550,7 +550,7 @@ define([
|
||||||
return this.offset;
|
return this.offset;
|
||||||
},
|
},
|
||||||
|
|
||||||
alignPosition: function() {
|
alignPosition: function(fixedAlign, fixedOffset) {
|
||||||
var menuRoot = (this.cmpEl.attr('role') === 'menu')
|
var menuRoot = (this.cmpEl.attr('role') === 'menu')
|
||||||
? this.cmpEl
|
? this.cmpEl
|
||||||
: this.cmpEl.find('[role=menu]'),
|
: this.cmpEl.find('[role=menu]'),
|
||||||
|
@ -597,8 +597,13 @@ define([
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (top + menuH > docH)
|
if (top + menuH > docH) {
|
||||||
top = docH - menuH;
|
if (fixedAlign) {
|
||||||
|
m = fixedAlign.match(/^([a-z]+)-([a-z]+)/);
|
||||||
|
top = offset.top - posMenu[m[1]][1] + posParent[m[2]][1] + this.offset[1] + (fixedOffset || 0);
|
||||||
|
} else
|
||||||
|
top = docH - menuH;
|
||||||
|
}
|
||||||
|
|
||||||
if (top < 0)
|
if (top < 0)
|
||||||
top = 0;
|
top = 0;
|
||||||
|
|
|
@ -1124,9 +1124,11 @@ define([
|
||||||
if (_.isUndefined(this.popover)) {
|
if (_.isUndefined(this.popover)) {
|
||||||
this.popover = Common.Views.ReviewPopover.prototype.getPopover({
|
this.popover = Common.Views.ReviewPopover.prototype.getPopover({
|
||||||
commentsStore : this.popoverComments,
|
commentsStore : this.popoverComments,
|
||||||
renderTo : this.sdkViewName
|
renderTo : this.sdkViewName,
|
||||||
|
userEmail: this.mode.userEmail
|
||||||
});
|
});
|
||||||
this.popover.setCommentsStore(this.popoverComments);
|
this.popover.setCommentsStore(this.popoverComments);
|
||||||
|
this.popover.setUserEmail(this.mode.userEmail);
|
||||||
}
|
}
|
||||||
return this.popover;
|
return this.popover;
|
||||||
},
|
},
|
||||||
|
|
|
@ -100,6 +100,7 @@ define([
|
||||||
|
|
||||||
this.commentsStore = options.commentsStore;
|
this.commentsStore = options.commentsStore;
|
||||||
this.reviewStore = options.reviewStore;
|
this.reviewStore = options.reviewStore;
|
||||||
|
this.userEmail = options.userEmail;
|
||||||
this._state = {commentsVisible: false, reviewVisible: false};
|
this._state = {commentsVisible: false, reviewVisible: false};
|
||||||
|
|
||||||
_options.tpl = _.template(this.template)(_options);
|
_options.tpl = _.template(this.template)(_options);
|
||||||
|
@ -455,6 +456,22 @@ define([
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.emailMenu = new Common.UI.Menu({
|
||||||
|
maxHeight: 200,
|
||||||
|
cyclic: false,
|
||||||
|
items: []
|
||||||
|
}).on('render:after', function(mnu) {
|
||||||
|
this.scroller = new Common.UI.Scroller({
|
||||||
|
el: $(this.el).find('.dropdown-menu '),
|
||||||
|
useKeyboard: this.enableKeyEvents && !this.handleSelect,
|
||||||
|
minScrollbarLength : 40,
|
||||||
|
alwaysVisibleY: true
|
||||||
|
});
|
||||||
|
}).on('show:after', function () {
|
||||||
|
this.scroller.update({alwaysVisibleY: true});
|
||||||
|
});
|
||||||
|
|
||||||
me.on({
|
me.on({
|
||||||
'show': function () {
|
'show': function () {
|
||||||
me.commentsView.autoHeightTextBox();
|
me.commentsView.autoHeightTextBox();
|
||||||
|
@ -872,6 +889,41 @@ define([
|
||||||
|
|
||||||
me.e = event;
|
me.e = event;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (this.userEmail && this.userEmail.length>0) {
|
||||||
|
textBox && textBox.keydown(function (event) {
|
||||||
|
if ( event.keyCode == Common.UI.Keys.SPACE ||
|
||||||
|
event.keyCode == Common.UI.Keys.HOME || event.keyCode == Common.UI.Keys.END || event.keyCode == Common.UI.Keys.RIGHT ||
|
||||||
|
event.keyCode == Common.UI.Keys.LEFT || event.keyCode == Common.UI.Keys.UP || event.keyCode == Common.UI.Keys.DOWN) {
|
||||||
|
// hide email menu
|
||||||
|
me.onEmailListMenu();
|
||||||
|
}
|
||||||
|
me.e = event;
|
||||||
|
});
|
||||||
|
textBox && textBox.on('input', function (event) {
|
||||||
|
var $this = $(this),
|
||||||
|
start = this.selectionStart,
|
||||||
|
val = $this.val(),
|
||||||
|
left = 0, right = val.length-1;
|
||||||
|
for (var i=start; i>=0; i--) {
|
||||||
|
if (val.charCodeAt(i) == 32 /*space*/ || val.charCodeAt(i) == 13 || val.charCodeAt(i) == 10 || val.charCodeAt(i) == 9) {
|
||||||
|
left = i+1; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (var i=start; i<=right; i++) {
|
||||||
|
if (val.charCodeAt(i) == 32 || val.charCodeAt(i) == 13 || val.charCodeAt(i) == 10 || val.charCodeAt(i) == 9) {
|
||||||
|
right = i-1; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var str = val.substring(left, right+1),
|
||||||
|
res = str.match(/^(?:[@]|[+](?!1))(\S*)/);
|
||||||
|
if (res && res.length>1) {
|
||||||
|
str = res[1]; // send to show email menu
|
||||||
|
console.log(str);
|
||||||
|
me.onEmailListMenu(str, left, right);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
hideTips: function () {
|
hideTips: function () {
|
||||||
|
@ -901,6 +953,10 @@ define([
|
||||||
this.commentsView.setStore(this.commentsStore);
|
this.commentsView.setStore(this.commentsStore);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setUserEmail: function(email) {
|
||||||
|
this.userEmail = email;
|
||||||
|
},
|
||||||
|
|
||||||
getPopover: function(options) {
|
getPopover: function(options) {
|
||||||
if (!this.popover)
|
if (!this.popover)
|
||||||
this.popover = new Common.Views.ReviewPopover(options);
|
this.popover = new Common.Views.ReviewPopover(options);
|
||||||
|
@ -925,6 +981,78 @@ define([
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onEmailListMenu: function(str, left, right) {
|
||||||
|
var emails = this.userEmail;
|
||||||
|
var me = this,
|
||||||
|
menu = me.emailMenu;
|
||||||
|
if (typeof str == 'string') {
|
||||||
|
var menuContainer = me.$window.find(Common.Utils.String.format('#menu-container-{0}', menu.id)),
|
||||||
|
arr = [];
|
||||||
|
str = str.toLowerCase();
|
||||||
|
|
||||||
|
for (var i = 0; i < menu.items.length; i++) {
|
||||||
|
menu.removeItem(menu.items[i]);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
if (str.length>0) {
|
||||||
|
for (var i = 0; i < emails.length; i++) {
|
||||||
|
if (0 === emails[i].toLowerCase().indexOf(str)) {
|
||||||
|
arr.push(emails[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
arr = emails;
|
||||||
|
|
||||||
|
_.each(arr, function(menuItem, index) {
|
||||||
|
var mnu = new Common.UI.MenuItem({
|
||||||
|
caption : menuItem
|
||||||
|
}).on('click', function(item, e) {
|
||||||
|
me.insertEmailToTextbox(item.caption, left, right);
|
||||||
|
});
|
||||||
|
menu.addItem(mnu);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (arr.length>0) {
|
||||||
|
var textbox = this.commentsView.getTextBox(),
|
||||||
|
textboxDom = textbox[0],
|
||||||
|
showPoint = [textboxDom.offsetLeft, textboxDom.offsetTop + textboxDom.clientHeight + 3];
|
||||||
|
|
||||||
|
if (!menu.rendered) {
|
||||||
|
// Prepare menu container
|
||||||
|
if (menuContainer.length < 1) {
|
||||||
|
menuContainer = $(Common.Utils.String.format('<div id="menu-container-{0}" style="position: absolute; z-index: 10000;"><div class="dropdown-toggle" data-toggle="dropdown"></div></div>', menu.id));
|
||||||
|
me.$window.append(menuContainer);
|
||||||
|
}
|
||||||
|
|
||||||
|
menu.render(menuContainer);
|
||||||
|
menu.cmpEl.css('min-width', textboxDom.clientWidth);
|
||||||
|
menu.cmpEl.attr({tabindex: "-1"});
|
||||||
|
menu.on('hide:after', function(){
|
||||||
|
setTimeout(function(){
|
||||||
|
me.commentsView.getTextBox().focus();
|
||||||
|
}, 10);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
menuContainer.css({left: showPoint[0], top : showPoint[1]});
|
||||||
|
menu.menuAlignEl = textbox;
|
||||||
|
menu.show();
|
||||||
|
menu.cmpEl.css('display', '');
|
||||||
|
menu.alignPosition('bl-tl', -5);
|
||||||
|
} else {
|
||||||
|
menu.rendered && menu.cmpEl.css('display', 'none');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
menu.rendered && menu.cmpEl.css('display', 'none');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
insertEmailToTextbox: function(str, left, right) {
|
||||||
|
var textBox = this.commentsView.getTextBox(),
|
||||||
|
val = textBox.val();
|
||||||
|
textBox.val(val.substring(0, left) + '+' + str + val.substring(right+1, val.length));
|
||||||
|
},
|
||||||
|
|
||||||
textAddReply : 'Add Reply',
|
textAddReply : 'Add Reply',
|
||||||
textAdd : "Add",
|
textAdd : "Add",
|
||||||
textCancel : 'Cancel',
|
textCancel : 'Cancel',
|
||||||
|
|
|
@ -1160,6 +1160,7 @@ define([
|
||||||
this.appOptions.isRestrictedEdit = !this.appOptions.isEdit && (this.appOptions.canComments || this.appOptions.canFillForms);
|
this.appOptions.isRestrictedEdit = !this.appOptions.isEdit && (this.appOptions.canComments || this.appOptions.canFillForms);
|
||||||
if (this.appOptions.isRestrictedEdit && this.appOptions.canComments && this.appOptions.canFillForms) // must be one restricted mode, priority for filling forms
|
if (this.appOptions.isRestrictedEdit && this.appOptions.canComments && this.appOptions.canFillForms) // must be one restricted mode, priority for filling forms
|
||||||
this.appOptions.canComments = false;
|
this.appOptions.canComments = false;
|
||||||
|
this.appOptions.userEmail = ["ivanov.ivan@gmail.com", "petrov.petr@gmail.com", "abggg.sdf@gmail.com", "absss.ivan@yandex.ru"];
|
||||||
|
|
||||||
if ( this.appOptions.isLightVersion ) {
|
if ( this.appOptions.isLightVersion ) {
|
||||||
this.appOptions.canUseHistory =
|
this.appOptions.canUseHistory =
|
||||||
|
|
Loading…
Reference in a new issue