Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
web-apps
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
web-apps
Commits
8194d6fb
Commit
8194d6fb
authored
Jan 12, 2017
by
Maxim Kadushkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[SSE mobile] process locked/disconnected state
parent
abd400c9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
92 deletions
+76
-92
apps/spreadsheeteditor/mobile/app/controller/Statusbar.js
apps/spreadsheeteditor/mobile/app/controller/Statusbar.js
+51
-51
apps/spreadsheeteditor/mobile/app/view/Statusbar.js
apps/spreadsheeteditor/mobile/app/view/Statusbar.js
+19
-41
apps/spreadsheeteditor/mobile/resources/less/statusbar.less
apps/spreadsheeteditor/mobile/resources/less/statusbar.less
+6
-0
No files found.
apps/spreadsheeteditor/mobile/app/controller/Statusbar.js
View file @
8194d6fb
...
...
@@ -75,17 +75,19 @@ define([
this
.
sheets
=
this
.
getApplication
().
getCollection
(
'
Sheets
'
);
this
.
sheets
.
bind
({
add
:
function
(
model
,
collection
,
opts
)
{
console
.
log
(
'
add in collection
'
);
var
$item
=
me
.
statusbar
.
addSheet
(
model
);
model
.
set
(
'
el
'
,
$item
,
{
silent
:
true
});
},
change
:
function
(
model
)
{
console
.
log
(
'
change in collection
'
);
if
(
model
.
changed
)
{
if
(
model
.
changed
.
locked
!=
undefined
)
{
model
.
get
(
'
el
'
).
toggleClass
(
'
locked
'
,
model
.
changed
.
locked
);
}
}
},
reset
:
function
(
collection
,
opts
)
{
me
.
statusbar
.
clearTabs
();
collection
.
each
(
function
(
model
)
{
var
$item
=
me
.
statusbar
.
addSheet
(
model
);
model
.
set
(
'
el
'
,
$item
);
});
me
.
statusbar
.
addSheets
(
collection
);
}
});
...
...
@@ -97,21 +99,22 @@ define([
setApi
:
function
(
api
)
{
this
.
api
=
api
;
//
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(this.onApiDisconnect, this));
this
.
api
.
asc_registerCallback
(
'
asc_onCoAuthoringDisconnect
'
,
_
.
bind
(
this
.
onApiDisconnect
,
this
));
// Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiDisconnect, this));
// this.api.asc_registerCallback('asc_onUpdateTabColor', _.bind(this.onApiUpdateTabColor, this));
// this.api.asc_registerCallback('asc_onEditCell', _.bind(this.onApiEditCell, this));
/** coauthoring begin **/
// this.api.asc_registerCallback('asc_onWorkbookLocked', _.bind(this.onWorkbookLocked, this));
// this.api.asc_registerCallback('asc_onWorksheetLocked', _.bind(this.onWorksheetLocked, this));
/** coauthoring end **/
this
.
api
.
asc_registerCallback
(
'
asc_onWorkbookLocked
'
,
_
.
bind
(
this
.
onWorkbookLocked
,
this
));
this
.
api
.
asc_registerCallback
(
'
asc_onWorksheetLocked
'
,
_
.
bind
(
this
.
onWorksheetLocked
,
this
));
// this.api.asc_registerCallback('asc_onError', _.bind(this.onError, this));
// this.statusbar.setApi(api);
this
.
api
.
asc_registerCallback
(
'
asc_onSheetsChanged
'
,
this
.
onApiSheetsChanged
.
bind
(
this
));
},
setMode
:
function
(
mode
)
{
this
.
statusbar
.
setMode
(
mode
);
this
.
isEdit
=
mode
==
'
edit
'
;
},
/*
* api events
* */
...
...
@@ -129,8 +132,9 @@ define([
index
:
i
,
active
:
active_index
==
i
,
name
:
me
.
api
.
asc_getWorksheetName
(
i
),
cls
:
locked
?
'
coauth-locked
'
:
''
,
draglocked
:
locked
// cls : locked ? 'coauth-locked':'',
locked
:
locked
,
color
:
me
.
api
.
asc_getWorksheetTabColor
(
i
)
};
(
this
.
api
.
asc_isWorksheetHidden
(
i
)
?
hiddentems
:
items
).
push
(
new
SSE
.
Models
.
Sheet
(
tab
));
...
...
@@ -151,12 +155,14 @@ define([
},
onApiDisconnect
:
function
()
{
this
.
statusbar
.
setMode
(
{
isDisconnected
:
true
}
);
this
.
statusbar
.
update
()
;
this
.
statusbar
.
setMode
(
'
disconnect
'
);
this
.
isDisconnected
=
true
;
},
/** coauthoring begin **/
onWorkbookLocked
:
function
(
locked
)
{
this
.
statusbar
.
$btnAddTab
.
toggleClass
(
'
disabled
'
,
locked
);
return
;
this
.
statusbar
.
tabbar
[
locked
?
'
addClass
'
:
'
removeClass
'
](
'
coauth-locked
'
);
this
.
statusbar
.
btnAddWorksheet
.
setDisabled
(
locked
||
this
.
statusbar
.
rangeSelectionMode
==
Asc
.
c_oAscSelectionDialogType
.
Chart
||
this
.
statusbar
.
rangeSelectionMode
==
Asc
.
c_oAscSelectionDialogType
.
FormatTable
);
...
...
@@ -172,18 +178,11 @@ define([
}
},
onWorksheetLocked
:
function
(
index
,
locked
)
{
var
count
=
this
.
statusbar
.
tabbar
.
getCount
(),
tab
;
for
(
var
i
=
count
;
i
--
>
0
;
)
{
tab
=
this
.
statusbar
.
tabbar
.
getAt
(
i
);
if
(
index
==
tab
.
sheetindex
)
{
tab
[
locked
?
'
addClass
'
:
'
removeClass
'
](
'
coauth-locked
'
);
tab
.
isLockTheDrag
=
locked
||
(
this
.
statusbar
.
rangeSelectionMode
==
Asc
.
c_oAscSelectionDialogType
.
FormatTable
);
break
;
}
}
onWorksheetLocked
:
function
(
index
,
locked
)
{
var
model
=
this
.
sheets
.
findWhere
({
index
:
index
});
if
(
model
&&
model
.
get
(
'
locked
'
)
!=
locked
)
model
.
set
(
'
locked
'
,
locked
);
},
/** coauthoring end **/
onApiEditCell
:
function
(
state
)
{
var
disableAdd
=
(
state
==
Asc
.
c_oAscCellEditorState
.
editFormula
),
...
...
@@ -410,13 +409,6 @@ define([
}
},
onZoomShow
:
function
(
e
){
if
(
e
.
target
.
classList
.
contains
(
'
disabled
'
))
{
return
false
;
}
},
onError
:
function
(
id
,
level
,
errData
)
{
if
(
id
==
Asc
.
c_oAscError
.
ID
.
LockedWorksheetRename
)
this
.
statusbar
.
update
();
...
...
@@ -428,8 +420,13 @@ define([
var
sdkindex
=
model
.
get
(
'
index
'
);
if
(
sdkindex
==
this
.
api
.
asc_getActiveWorksheetIndex
()
)
{
if
(
!
opened
)
this
.
statusbar
.
showTabContextMenu
(
this
.
_getTabMenuItems
(),
model
);
if
(
!
opened
)
{
if
(
this
.
isEdit
&&
!
this
.
isDisconnected
)
{
this
.
api
.
asc_closeCellEditor
();
this
.
statusbar
.
showTabContextMenu
(
this
.
_getTabMenuItems
(
model
),
model
);
}
}
}
else
{
this
.
api
.
asc_showWorksheet
(
sdkindex
);
this
.
statusbar
.
setActiveTab
(
index
);
...
...
@@ -475,23 +472,26 @@ define([
},
_getTabMenuItems
:
function
()
{
var
items
=
[
{
_getTabMenuItems
:
function
(
model
)
{
var
wbLocked
=
this
.
api
.
asc_isWorkbookLocked
();
var
shLocked
=
this
.
api
.
asc_isWorksheetLockedOrDeleted
(
model
.
get
(
'
index
'
));
var
items
=
[{
caption
:
this
.
menuDuplicate
,
event
:
'
copy
'
},
{
event
:
'
copy
'
,
locked
:
wbLocked
||
shLocked
},
{
caption
:
this
.
menuDelete
,
event
:
'
del
'
},
{
event
:
'
del
'
,
locked
:
wbLocked
||
shLocked
},
{
caption
:
this
.
menuHide
,
event
:
'
hide
'
}
];
event
:
'
hide
'
,
locked
:
wbLocked
||
shLocked
}];
if
(
this
.
hiddensheets
.
length
)
{
if
(
!
wbLocked
&&
!
shLocked
&&
this
.
hiddensheets
.
length
)
{
items
.
push
({
caption
:
this
.
menuUnhide
,
event
:
'
unhide
'
...
...
apps/spreadsheeteditor/mobile/app/view/Statusbar.js
View file @
8194d6fb
...
...
@@ -49,16 +49,18 @@ define([
el
:
'
.pages > .page
'
,
template
:
'
<div class="statusbar">
'
+
'
<div id="box-addtab" class="status-group">
'
+
'
<a href="#" id="btn-addtab" class="button"><i class="icon icon-plus"></i></a>
'
+
'
<a href="#" id="btn-addtab" class="button"
style="display:none"
><i class="icon icon-plus"></i></a>
'
+
'
</div>
'
+
'
<div class="box-tabs">
'
+
'
<ul class="sheet-tabs bottom"></ul>
'
+
'
</div>
'
+
'
</div>
'
,
tabtemplate
:
_
.
template
(
'
<li class="tab"><a><%= label %></a></li>
'
),
tabtemplate
:
_
.
template
(
'
<li class="tab
<% if (locked) print(" locked"); %>
"><a><%= label %></a></li>
'
),
menutemplate
:
_
.
template
(
'
<% _.each(menuItems, function(item) { %>
'
+
'
<li data-event="<%= item.event %>"><a href="#" class="item-link list-button"><%= item.caption %></li>
'
+
'
<li data-event="<%= item.event %>" class="<% if (item.locked===true) print("disabled") %>">
'
+
'
<a href="#" class="item-link list-button"><%= item.caption %>
'
+
'
</li>
'
+
'
<% }); %>
'
),
events
:
{},
...
...
@@ -79,30 +81,16 @@ define([
});
// this.editMode = false;
// this.btnAddWorksheet = new Common.UI.Button({
// el: $('#status-btn-addtab',this.el),
// hint: this.tipAddTab,
// disabled: true,
// hintAnchor: 'top'
// });
return
this
;
},
// setApi: function(api) {
// this.api = api;
// this.api.asc_registerCallback('asc_onSheetsChanged', _.bind(this.update, this));
// return this;
// },
setMode
:
function
(
mode
)
{
this
.
mode
=
_
.
extend
({},
this
.
mode
,
mode
);
// this.$el.find('.el-edit')[mode.isEdit?'show':'hide']
();
this
.
btnAddWorksheet
.
setVisible
(
this
.
mode
.
isEdit
);
this
.
btnAddWorksheet
.
setDisabled
(
this
.
mode
.
isDisconnected
);
this
.
lblChangeRights
[(
!
this
.
mode
.
isOffline
&&
this
.
mode
.
sharingSettingsUrl
&&
this
.
mode
.
sharingSettingsUrl
.
length
)?
'
show
'
:
'
hide
'
](
);
// this.updateTabbarBorders();
if
(
'
edit
'
==
mode
)
{
this
.
$btnAddTab
.
show
();
}
else
if
(
'
disconnect
'
==
mode
)
{
this
.
$btnAddTab
.
toggleClass
(
'
disabled
'
,
true
);
}
},
setVisible
:
function
(
visible
)
{
...
...
@@ -112,7 +100,8 @@ define([
addSheet
:
function
(
model
)
{
var
index
=
this
.
$boxTabs
.
children
().
length
;
var
$item
=
$
(
this
.
tabtemplate
({
'
label
'
:
model
.
get
(
'
name
'
)
label
:
model
.
get
(
'
name
'
),
locked
:
model
.
get
(
'
locked
'
)
})).
appendTo
(
this
.
$boxTabs
);
$item
.
on
(
'
click
'
,
this
.
onSheetClick
.
bind
(
this
,
index
,
model
));
...
...
@@ -120,7 +109,12 @@ define([
return
$item
;
},
addSheets
:
function
()
{
addSheets
:
function
(
collection
)
{
var
me
=
this
;
collection
.
each
(
function
(
model
)
{
var
$item
=
me
.
addSheet
(
model
);
model
.
set
(
'
el
'
,
$item
,
{
silent
:
true
});
});
},
clearTabs
:
function
()
{
...
...
@@ -213,22 +207,6 @@ define([
);
},
updateTabbarBorders
:
function
()
{
var
right
=
parseInt
(
this
.
boxZoom
.
css
(
'
width
'
)),
visible
=
false
;
if
(
this
.
boxMath
.
is
(
'
:visible
'
))
{
right
+=
parseInt
(
this
.
boxMath
.
css
(
'
width
'
));
visible
=
true
;
}
if
(
this
.
panelUsers
.
is
(
'
:visible
'
))
{
right
+=
parseInt
(
this
.
panelUsers
.
css
(
'
width
'
));
visible
=
true
;
}
this
.
boxZoom
.
find
(
'
.separator
'
).
css
(
'
border-left-color
'
,
visible
?
''
:
'
transparent
'
);
this
.
tabBarBox
.
css
(
'
right
'
,
right
+
'
px
'
);
},
changeViewMode
:
function
(
edit
)
{
if
(
edit
)
{
this
.
tabBarBox
.
css
(
'
left
'
,
'
152px
'
);
...
...
apps/spreadsheeteditor/mobile/resources/less/statusbar.less
View file @
8194d6fb
...
...
@@ -70,4 +70,10 @@
}
}
}
.locked {
a {
box-shadow: inset 0 2px #f00;
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment