Merge branch 'develop' into feature/refactor

This commit is contained in:
Julia Radzhabova 2016-10-20 11:59:23 +03:00
commit f5fb3f94f5
17 changed files with 79 additions and 51 deletions

View file

@ -186,6 +186,16 @@ function getParent($this) {
return $parent && $parent.length ? $parent : $this.parent(); return $parent && $parent.length ? $parent : $this.parent();
} }
function clearMenus() {
$('.dropdown-toggle').each(function (e) {
var $parent = ($(this)).parent();
if (!$parent.hasClass('open')) return;
$parent.trigger(e = $.Event('hide.bs.dropdown'));
if (e.isDefaultPrevented()) return;
$parent.removeClass('open').trigger('hidden.bs.dropdown');
})
}
$(document) $(document)
.off('keydown.bs.dropdown.data-api') .off('keydown.bs.dropdown.data-api')
.on('keydown.bs.dropdown.data-api', '[data-toggle=dropdown], [role=menu]' , onDropDownKeyDown); .on('keydown.bs.dropdown.data-api', '[data-toggle=dropdown], [role=menu]' , onDropDownKeyDown);
@ -206,9 +216,8 @@ $(document)
} }
function onDropDownClick(e) { function onDropDownClick(e) {
if ((e.which == 1 || e.which == undefined) && !!clickDefHandler) { if (e.which == 1 || e.which == undefined)
clickDefHandler(e); clearMenus();
}
} }
if (!!clickDefHandler) { if (!!clickDefHandler) {

View file

@ -423,39 +423,41 @@ define([
var changes = version.changes, change, i; var changes = version.changes, change, i;
if (changes && changes.length>0) { if (changes && changes.length>0) {
arrVersions[arrVersions.length-1].set('changeid', changes.length-1);
arrVersions[arrVersions.length-1].set('docIdPrev', docIdPrev); arrVersions[arrVersions.length-1].set('docIdPrev', docIdPrev);
arrVersions[arrVersions.length-1].set('hasChanges', changes.length>1); if (!_.isEmpty(version.serverVersion) && version.serverVersion == this.appOptions.buildVersion) {
for (i=changes.length-2; i>=0; i--) { arrVersions[arrVersions.length-1].set('changeid', changes.length-1);
change = changes[i]; arrVersions[arrVersions.length-1].set('hasChanges', changes.length>1);
for (i=changes.length-2; i>=0; i--) {
change = changes[i];
user = usersStore.findUser(change.user.id); user = usersStore.findUser(change.user.id);
if (!user) { if (!user) {
user = new Common.Models.User({ user = new Common.Models.User({
id : change.user.id, id : change.user.id,
username : change.user.name, username : change.user.name,
colorval : Asc.c_oAscArrUserColors[usersCnt], colorval : Asc.c_oAscArrUserColors[usersCnt],
color : this.generateUserColor(Asc.c_oAscArrUserColors[usersCnt++]) color : this.generateUserColor(Asc.c_oAscArrUserColors[usersCnt++])
}); });
usersStore.add(user); usersStore.add(user);
}
arrVersions.push(new Common.Models.HistoryVersion({
version: version.versionGroup,
revision: version.version,
changeid: i,
userid : change.user.id,
username : change.user.name,
usercolor: user.get('color'),
created: change.created,
docId: version.key,
docIdPrev: docIdPrev,
selected: false,
canRestore: this.appOptions.canHistoryRestore,
isRevision: false,
isVisible: true
}));
arrColors.push(user.get('colorval'));
} }
arrVersions.push(new Common.Models.HistoryVersion({
version: version.versionGroup,
revision: version.version,
changeid: i,
userid : change.user.id,
username : change.user.name,
usercolor: user.get('color'),
created: change.created,
docId: version.key,
docIdPrev: docIdPrev,
selected: false,
canRestore: this.appOptions.canHistoryRestore,
isRevision: false,
isVisible: true
}));
arrColors.push(user.get('colorval'));
} }
} else if (ver==0 && versions.length==1) { } else if (ver==0 && versions.length==1) {
arrVersions[arrVersions.length-1].set('docId', version.key + '1'); arrVersions[arrVersions.length-1].set('docId', version.key + '1');
@ -954,6 +956,10 @@ define([
} }
this.permissions.review = (this.permissions.review === undefined) ? (this.permissions.edit !== false) : this.permissions.review; this.permissions.review = (this.permissions.review === undefined) ? (this.permissions.edit !== false) : this.permissions.review;
if (params.asc_getRights() !== Asc.c_oRights.Edit)
this.permissions.edit = this.permissions.review = false;
this.appOptions.canAnalytics = params.asc_getIsAnalyticsEnable(); this.appOptions.canAnalytics = params.asc_getIsAnalyticsEnable();
this.appOptions.canLicense = (licType === Asc.c_oLicenseResult.Success); this.appOptions.canLicense = (licType === Asc.c_oLicenseResult.Success);
this.appOptions.isLightVersion = params.asc_getIsLight(); this.appOptions.isLightVersion = params.asc_getIsLight();
@ -978,6 +984,7 @@ define([
this.appOptions.canEditStyles = this.appOptions.canLicense && this.appOptions.canEdit; this.appOptions.canEditStyles = this.appOptions.canLicense && this.appOptions.canEdit;
this.appOptions.canPrint = (this.permissions.print !== false); this.appOptions.canPrint = (this.permissions.print !== false);
this.appOptions.canRename = !!this.permissions.rename; this.appOptions.canRename = !!this.permissions.rename;
this.appOptions.buildVersion = params.asc_getBuildVersion();
var type = /^(?:(pdf|djvu|xps))$/.exec(this.document.fileType); var type = /^(?:(pdf|djvu|xps))$/.exec(this.document.fileType);
this.appOptions.canDownloadOrigin = !this.appOptions.nativeApp && this.permissions.download !== false && (type && typeof type[1] === 'string'); this.appOptions.canDownloadOrigin = !this.appOptions.nativeApp && this.permissions.download !== false && (type && typeof type[1] === 'string');

View file

@ -167,14 +167,15 @@ define([
this._settings[Common.Utils.documentSettingsType.MailMerge].locked = !can_add_table || in_equation; this._settings[Common.Utils.documentSettingsType.MailMerge].locked = !can_add_table || in_equation;
} }
var lastactive = -1, currentactive, priorityactive = -1; var lastactive = -1, currentactive, priorityactive = -1,
activePane = this.rightmenu.GetActivePane();
for (i=0; i<this._settings.length; i++) { for (i=0; i<this._settings.length; i++) {
var pnl = this._settings[i]; var pnl = this._settings[i];
if (pnl===undefined || pnl.btn===undefined || pnl.panel===undefined) continue; if (pnl===undefined || pnl.btn===undefined || pnl.panel===undefined) continue;
if ( pnl.hidden ) { if ( pnl.hidden ) {
if (!pnl.btn.isDisabled()) pnl.btn.setDisabled(true); if (!pnl.btn.isDisabled()) pnl.btn.setDisabled(true);
if (this.rightmenu.GetActivePane() == pnl.panelId) if (activePane == pnl.panelId)
currentactive = -1; currentactive = -1;
} else { } else {
if (pnl.btn.isDisabled()) pnl.btn.setDisabled(false); if (pnl.btn.isDisabled()) pnl.btn.setDisabled(false);
@ -182,7 +183,7 @@ define([
if ( pnl.needShow ) { if ( pnl.needShow ) {
pnl.needShow = false; pnl.needShow = false;
priorityactive = i; priorityactive = i;
} else if (this.rightmenu.GetActivePane() == pnl.panelId) } else if (activePane == pnl.panelId)
currentactive = i; currentactive = i;
pnl.panel.setLocked(pnl.locked); pnl.panel.setLocked(pnl.locked);
} }

View file

@ -1,7 +1,7 @@
<div class="statusbar" style="display:table;"> <div class="statusbar" style="display:table;">
<div class="status-group dropup"> <div class="status-group dropup">
<label id="label-pages" class="status-label" style="margin-left: 40px;" data-toggle="dropdown"><%= Common.Utils.String.format(scope.pageIndexText, 1, 1) %></label> <label id="label-pages" class="status-label dropdown-toggle" style="margin-left: 40px;" data-toggle="dropdown"><%= Common.Utils.String.format(scope.pageIndexText, 1, 1) %></label>
<div id="status-goto-box" class="dropdown-menu"> <div id="status-goto-box" class="dropdown-menu">
<label style="float:left;line-height:22px;"><%= scope.goToPageText %></label> <label style="float:left;line-height:22px;"><%= scope.goToPageText %></label>
<div id="status-goto-page" style="display:inline-block;"></div> <div id="status-goto-page" style="display:inline-block;"></div>

View file

@ -258,7 +258,7 @@ define([
this._settings[type].btn.toggle(true, false); this._settings[type].btn.toggle(true, false);
this._settings[type].btn.trigger('click', this._settings[type].btn); this._settings[type].btn.trigger('click', this._settings[type].btn);
} else { } else {
var target_pane = $("#" + this._settings[type].panel ); var target_pane = this.$el.find("#" + this._settings[type].panel );
if ( !target_pane.hasClass('active') ) { if ( !target_pane.hasClass('active') ) {
target_pane.parent().find('> .active').removeClass('active'); target_pane.parent().find('> .active').removeClass('active');
target_pane.addClass("active"); target_pane.addClass("active");
@ -271,7 +271,7 @@ define([
}, },
GetActivePane: function() { GetActivePane: function() {
return (this.minimizedMode) ? null : $(".settings-panel.active")[0].id; return (this.minimizedMode) ? null : this.$el.find(".settings-panel.active")[0].id;
}, },
clearSelection: function() { clearSelection: function() {

View file

@ -417,6 +417,7 @@ define([
usertip.setContent(); usertip.setContent();
} }
(length > 1) ? this.panelUsersBlock.attr('data-toggle', 'dropdown') : this.panelUsersBlock.removeAttr('data-toggle'); (length > 1) ? this.panelUsersBlock.attr('data-toggle', 'dropdown') : this.panelUsersBlock.removeAttr('data-toggle');
this.panelUsersBlock.toggleClass('dropdown-toggle', length > 1);
(length > 1) ? this.panelUsersBlock.off('click') : this.panelUsersBlock.on('click', _.bind(this.onUsersClick, this)); (length > 1) ? this.panelUsersBlock.off('click') : this.panelUsersBlock.on('click', _.bind(this.onUsersClick, this));
}, },

View file

@ -733,6 +733,9 @@ define([
return; return;
} }
if (params.asc_getRights() !== Asc.c_oRights.Edit)
this.permissions.edit = false;
this.appOptions.isOffline = this.api.asc_isOffline(); this.appOptions.isOffline = this.api.asc_isOffline();
this.appOptions.canLicense = (licType === Asc.c_oLicenseResult.Success); this.appOptions.canLicense = (licType === Asc.c_oLicenseResult.Success);
this.appOptions.isLightVersion = params.asc_getIsLight(); this.appOptions.isLightVersion = params.asc_getIsLight();

View file

@ -148,14 +148,15 @@ define([
} }
} }
var lastactive = -1, currentactive, priorityactive = -1; var lastactive = -1, currentactive, priorityactive = -1,
activePane = this.rightmenu.GetActivePane();
for (i=0; i<this._settings.length; i++) { for (i=0; i<this._settings.length; i++) {
var pnl = this._settings[i]; var pnl = this._settings[i];
if (pnl===undefined) continue; if (pnl===undefined) continue;
if ( pnl.hidden ) { if ( pnl.hidden ) {
if (!pnl.btn.isDisabled()) pnl.btn.setDisabled(true); if (!pnl.btn.isDisabled()) pnl.btn.setDisabled(true);
if (this.rightmenu.GetActivePane() == pnl.panelId) if (activePane == pnl.panelId)
currentactive = -1; currentactive = -1;
} else { } else {
if (pnl.btn.isDisabled()) pnl.btn.setDisabled(false); if (pnl.btn.isDisabled()) pnl.btn.setDisabled(false);
@ -165,7 +166,7 @@ define([
pnl.needShow = false; pnl.needShow = false;
priorityactive = i; priorityactive = i;
} else if ( i != Common.Utils.documentSettingsType.Slide || this.rightmenu._settings[i].isCurrent) { } else if ( i != Common.Utils.documentSettingsType.Slide || this.rightmenu._settings[i].isCurrent) {
if (this.rightmenu.GetActivePane() == pnl.panelId) if (activePane == pnl.panelId)
currentactive = i; currentactive = i;
} }

View file

@ -2,7 +2,7 @@
<div class="statusbar" style="display:table;"> <div class="statusbar" style="display:table;">
<div class="status-group dropup"> <div class="status-group dropup">
<button id="status-btn-preview" type="button" class="btn small btn-toolbar" style="margin-left: 9px;"><span class="btn-icon">&nbsp;</span></button> <button id="status-btn-preview" type="button" class="btn small btn-toolbar" style="margin-left: 9px;"><span class="btn-icon">&nbsp;</span></button>
<label id="status-label-pages" class="status-label" style="margin-left: 7px;" data-toggle="dropdown"><%= Common.Utils.String.format(scope.pageIndexText, 1, 1) %></label> <label id="status-label-pages" class="status-label dropdown-toggle" style="margin-left: 7px;" data-toggle="dropdown"><%= Common.Utils.String.format(scope.pageIndexText, 1, 1) %></label>
<div id="status-goto-box" class="dropdown-menu"> <div id="status-goto-box" class="dropdown-menu">
<label style="float:left;line-height:22px;"><%= scope.goToPageText %></label> <label style="float:left;line-height:22px;"><%= scope.goToPageText %></label>
<div id="status-goto-page" style="display:inline-block;"></div> <div id="status-goto-page" style="display:inline-block;"></div>

View file

@ -78,7 +78,7 @@ define([
'<div class="separator"/>', '<div class="separator"/>',
'</div>', '</div>',
'<div class="preview-group dropup">', '<div class="preview-group dropup">',
'<label id="preview-label-slides" class="status-label" data-toggle="dropdown">Slide 1 of 1</label>', '<label id="preview-label-slides" class="status-label dropdown-toggle" data-toggle="dropdown">Slide 1 of 1</label>',
'<div id="preview-goto-box" class="dropdown-menu">', '<div id="preview-goto-box" class="dropdown-menu">',
'<label style="float:left;line-height:22px;">' + this.goToSlideText + '</label>', '<label style="float:left;line-height:22px;">' + this.goToSlideText + '</label>',
'<div id="preview-goto-page" style="display:inline-block;"></div>', '<div id="preview-goto-page" style="display:inline-block;"></div>',

View file

@ -254,7 +254,7 @@ define([
}, },
GetActivePane: function() { GetActivePane: function() {
return (this.minimizedMode) ? null : $(".settings-panel.active")[0].id; return (this.minimizedMode) ? null : this.$el.find(".settings-panel.active")[0].id;
}, },
SetDisabled: function(id, disabled, all) { SetDisabled: function(id, disabled, all) {

View file

@ -321,6 +321,7 @@ define([
usertip.setContent(); usertip.setContent();
} }
(length > 1) ? this.panelUsersBlock.attr('data-toggle', 'dropdown') : this.panelUsersBlock.removeAttr('data-toggle'); (length > 1) ? this.panelUsersBlock.attr('data-toggle', 'dropdown') : this.panelUsersBlock.removeAttr('data-toggle');
this.panelUsersBlock.toggleClass('dropdown-toggle', length > 1);
(length > 1) ? this.panelUsersBlock.off('click') : this.panelUsersBlock.on('click', _.bind(this.onUsersClick, this)); (length > 1) ? this.panelUsersBlock.off('click') : this.panelUsersBlock.on('click', _.bind(this.onUsersClick, this));
}, },

View file

@ -752,6 +752,9 @@ define([
return; return;
} }
if (params.asc_getRights() !== Asc.c_oRights.Edit)
this.permissions.edit = false;
this.appOptions.canAutosave = true; this.appOptions.canAutosave = true;
this.appOptions.canAnalytics = params.asc_getIsAnalyticsEnable(); this.appOptions.canAnalytics = params.asc_getIsAnalyticsEnable();

View file

@ -177,7 +177,8 @@ define([
this._settings[settingsType].hidden = 0; this._settings[settingsType].hidden = 0;
} }
var lastactive = -1, currentactive, priorityactive = -1; var lastactive = -1, currentactive, priorityactive = -1,
activePane = this.rightmenu.GetActivePane();
for (i=0; i<this._settings.length; ++i) { for (i=0; i<this._settings.length; ++i) {
var pnl = this._settings[i]; var pnl = this._settings[i];
if (pnl===undefined) continue; if (pnl===undefined) continue;
@ -185,7 +186,7 @@ define([
if ( pnl.hidden ) { if ( pnl.hidden ) {
if ( !pnl.btn.isDisabled() ) if ( !pnl.btn.isDisabled() )
pnl.btn.setDisabled(true); pnl.btn.setDisabled(true);
if (this.rightmenu.GetActivePane() == pnl.panelId) if (activePane == pnl.panelId)
currentactive = -1; currentactive = -1;
} else { } else {
if ( pnl.btn.isDisabled() ) if ( pnl.btn.isDisabled() )
@ -194,7 +195,7 @@ define([
if ( pnl.needShow ) { if ( pnl.needShow ) {
pnl.needShow = false; pnl.needShow = false;
priorityactive = i; priorityactive = i;
} else if (this.rightmenu.GetActivePane() == pnl.panelId) } else if (activePane == pnl.panelId)
currentactive = i; currentactive = i;
pnl.panel.setLocked(pnl.locked); pnl.panel.setLocked(pnl.locked);
} }

View file

@ -234,7 +234,7 @@ define([
}, },
GetActivePane: function() { GetActivePane: function() {
return (this.minimizedMode) ? null : $(".settings-panel.active")[0].id; return (this.minimizedMode) ? null : this.$el.find(".settings-panel.active")[0].id;
}, },
clearSelection: function() { clearSelection: function() {

View file

@ -300,7 +300,7 @@ define([
}); });
}); });
this.tabbar.$el.append('<div class="menu-backdrop" data-toggle="dropdown" style="width:0; height:0;"/>'); this.tabbar.$el.append('<div class="menu-backdrop dropdown-toggle" data-toggle="dropdown" style="width:0; height:0;"/>');
this.tabMenu.render(this.tabbar.$el); this.tabMenu.render(this.tabbar.$el);
this.tabMenu.on('show:after', _.bind(this.onTabMenuAfterShow, this)); this.tabMenu.on('show:after', _.bind(this.onTabMenuAfterShow, this));
this.tabMenu.on('hide:after', _.bind(this.onTabMenuAfterHide, this)); this.tabMenu.on('hide:after', _.bind(this.onTabMenuAfterHide, this));
@ -445,6 +445,7 @@ define([
usertip.setContent(); usertip.setContent();
} }
(length > 1) ? this.panelUsersBlock.attr('data-toggle', 'dropdown') : this.panelUsersBlock.removeAttr('data-toggle'); (length > 1) ? this.panelUsersBlock.attr('data-toggle', 'dropdown') : this.panelUsersBlock.removeAttr('data-toggle');
this.panelUsersBlock.toggleClass('dropdown-toggle', length > 1);
(length > 1) ? this.panelUsersBlock.off('click') : this.panelUsersBlock.on('click', _.bind(this.onUsersClick, this)); (length > 1) ? this.panelUsersBlock.off('click') : this.panelUsersBlock.on('click', _.bind(this.onUsersClick, this));
}, },

View file

@ -598,7 +598,7 @@ define([
me.listStyles = new Common.UI.ComboDataView({ me.listStyles = new Common.UI.ComboDataView({
cls : 'combo-styles', cls : 'combo-styles',
enableKeyEvents : true, enableKeyEvents : true,
itemWidth : 104, itemWidth : 112,
itemHeight : 38, itemHeight : 38,
hint : this.tipCellStyle, hint : this.tipCellStyle,
menuMaxHeight : 226, menuMaxHeight : 226,