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
7b86f889
Commit
7b86f889
authored
May 19, 2016
by
Julia Radzhabova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DE] Изменена структура плагинов.
parent
229d7110
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
165 additions
and
77 deletions
+165
-77
apps/api/documents/api.js
apps/api/documents/api.js
+52
-27
apps/common/main/lib/controller/Plugins.js
apps/common/main/lib/controller/Plugins.js
+43
-23
apps/common/main/lib/model/Plugin.js
apps/common/main/lib/model/Plugin.js
+22
-6
apps/common/main/lib/view/Plugins.js
apps/common/main/lib/view/Plugins.js
+1
-1
apps/documenteditor/main/app/controller/LeftMenu.js
apps/documenteditor/main/app/controller/LeftMenu.js
+7
-3
apps/documenteditor/main/app/controller/Main.js
apps/documenteditor/main/app/controller/Main.js
+39
-16
apps/documenteditor/main/app/view/LeftMenu.js
apps/documenteditor/main/app/view/LeftMenu.js
+1
-1
No files found.
apps/api/documents/api.js
View file @
7b86f889
...
...
@@ -107,37 +107,62 @@
chat: false,
comments: false
},
plugins: [{
name: "chess (fen)",
guid: "{FFE1F462-1EA2-4391-990D-4CC84940B754}",
url: "chess/index.html",
icons: ["chess/icon.png", "chess/icon2x.png"],
isVisual: true,
initDataType: 2,
isUpdateOleOnResize: true,
buttons: [{text:"Ok",primary:true},{text:"Cancel",primary:false}]
},
plugins: {
url: '../../../../sdkjs-plugins/',
pluginsData: [{
name : "chess (fen)",
guid : "{FFE1F462-1EA2-4391-990D-4CC84940B754}",
variations : [
{
name: "glavred",
guid: "{B631E142-E40B-4B4C-90B9-2D00222A286E}",
url: "glavred/index.html",
icons: ["glavred/icon.png", "glavred/icon2x.png"],
isVisual: true,
initDataType: 1,
isUpdateOleOnResize: false,
buttons: [{text:"Ok",primary:true}]
description : "chess",
url : "chess/index.html",
icons : ["chess/icon.png", "chess/icon@2x.png"],
isViewer : true,
EditorsSupport : ["word", "cell", "slide"],
isVisual : true,
isModal : true,
isInsideMode : false,
initDataType : "ole",
initData : "",
isUpdateOleOnResize : true,
buttons : [ { text: "Ok", primary: true },
{ text: "Cancel", primary: false } ]
}
]
},
{
name: "bold",
guid: "{14E46CC2-5E56-429C-9D55-1032B596D928}",
url: "bold/index.html",
icons: ["bold/icon.png", "bold/icon2x.png"],
isVisual: false,
initDataType: 0,
isUpdateOleOnResize: false,
buttons: []
name : "glavred",
guid : "{B631E142-E40B-4B4C-90B9-2D00222A286E}",
variations : [
{
description : "glavred",
url : "glavred/index.html",
icons : ["glavred/icon.png", "glavred/icon@2x.png"],
isViewer : true,
EditorsSupport : ["word", "cell", "slide"],
isVisual : true,
isModal : true,
isInsideMode : false,
initDataType : "text",
initData : "",
isUpdateOleOnResize : false,
buttons : [ { text: "Ok", primary: true } ]
}
]
}
}
},
events: {
'onReady': <document ready callback>,
...
...
apps/common/main/lib/controller/Plugins.js
View file @
7b86f889
...
...
@@ -68,24 +68,6 @@ define([
setApi
:
function
(
api
)
{
this
.
api
=
api
;
var
me
=
this
;
var
storePlugins
=
this
.
getApplication
().
getCollection
(
'
Common.Collections.Plugins
'
),
arr
=
[];
storePlugins
.
each
(
function
(
item
){
var
plugin
=
new
Asc
.
CPlugin
();
plugin
.
set_Name
(
item
.
get
(
'
name
'
));
plugin
.
set_Guid
(
item
.
get
(
'
guid
'
));
plugin
.
set_Url
(
item
.
get
(
'
url
'
));
plugin
.
set_Icons
(
item
.
get
(
'
icons
'
));
plugin
.
set_Visual
(
item
.
get
(
'
isVisual
'
));
plugin
.
set_InitDataType
(
item
.
get
(
'
initDataType
'
));
plugin
.
set_UpdateOleOnResize
(
item
.
get
(
'
isUpdateOleOnResize
'
));
plugin
.
set_Buttons
(
item
.
get
(
'
buttons
'
));
item
.
set
(
'
pluginObj
'
,
plugin
);
arr
.
push
(
plugin
);
});
this
.
api
.
asc_pluginsRegister
(
this
.
panelPlugins
.
pluginsPath
,
arr
);
this
.
api
.
asc_registerCallback
(
"
asc_onPluginShow
"
,
_
.
bind
(
this
.
onPluginShow
,
this
));
this
.
api
.
asc_registerCallback
(
"
asc_onPluginClose
"
,
_
.
bind
(
this
.
onPluginClose
,
this
));
...
...
@@ -93,21 +75,59 @@ define([
},
setMode
:
function
(
mode
)
{
if
(
mode
.
canPlugins
)
{
this
.
panelPlugins
.
pluginsPath
=
mode
.
pluginsPath
;
this
.
updatePluginsList
();
}
},
onAfterRender
:
function
(
historyView
)
{
historyView
.
viewPluginsList
.
on
(
'
item:click
'
,
_
.
bind
(
this
.
onSelectPlugin
,
this
));
},
updatePluginsList
:
function
()
{
var
me
=
this
;
var
storePlugins
=
this
.
getApplication
().
getCollection
(
'
Common.Collections.Plugins
'
),
arr
=
[];
storePlugins
.
each
(
function
(
item
){
var
plugin
=
new
Asc
.
CPlugin
();
plugin
.
set_Name
(
item
.
get
(
'
name
'
));
plugin
.
set_Guid
(
item
.
get
(
'
guid
'
));
var
variations
=
item
.
get
(
'
variations
'
),
variationsArr
=
[];
variations
.
forEach
(
function
(
itemVar
){
var
variation
=
new
Asc
.
CPluginVariation
();
variation
.
set_Description
(
itemVar
.
get
(
'
description
'
));
variation
.
set_Url
(
itemVar
.
get
(
'
url
'
));
variation
.
set_Icons
(
itemVar
.
get
(
'
icons
'
));
variation
.
set_Visual
(
itemVar
.
get
(
'
isVisual
'
));
variation
.
set_Viewer
(
itemVar
.
get
(
'
isViewer
'
));
variation
.
set_EditorsSupport
(
itemVar
.
get
(
'
EditorsSupport
'
));
variation
.
set_Modal
(
itemVar
.
get
(
'
isModal
'
));
variation
.
set_InsideMode
(
itemVar
.
get
(
'
isInsideMode
'
));
variation
.
set_InitDataType
(
itemVar
.
get
(
'
initDataType
'
));
variation
.
set_InitData
(
itemVar
.
get
(
'
initData
'
));
variation
.
set_UpdateOleOnResize
(
itemVar
.
get
(
'
isUpdateOleOnResize
'
));
variation
.
set_Buttons
(
itemVar
.
get
(
'
buttons
'
));
variationsArr
.
push
(
variation
);
});
plugin
.
set_Variations
(
variationsArr
);
item
.
set
(
'
pluginObj
'
,
plugin
);
arr
.
push
(
plugin
);
});
this
.
api
.
asc_pluginsRegister
(
this
.
panelPlugins
.
pluginsPath
,
arr
);
},
onSelectPlugin
:
function
(
picker
,
item
,
record
){
this
.
api
.
asc_pluginRun
(
record
.
get
(
'
guid
'
),
''
);
this
.
api
.
asc_pluginRun
(
record
.
get
(
'
guid
'
),
record
.
get
(
'
currentVariation
'
),
''
);
},
onPluginShow
:
function
(
plugin
)
{
if
(
!
plugin
.
get_Visual
())
return
;
var
variation
=
plugin
.
get_Variations
()[
0
];
if
(
!
variation
.
get_Visual
())
return
;
var
me
=
this
,
arrBtns
=
plugi
n
.
get_Buttons
(),
arrBtns
=
variatio
n
.
get_Buttons
(),
newBtns
=
{};
if
(
_
.
isArray
(
arrBtns
))
{
...
...
@@ -118,7 +138,7 @@ define([
me
.
pluginDlg
=
new
Common
.
Views
.
PluginDlg
({
title
:
plugin
.
get_Name
(),
url
:
me
.
panelPlugins
.
pluginsPath
+
plugi
n
.
get_Url
(),
url
:
me
.
panelPlugins
.
pluginsPath
+
variatio
n
.
get_Url
(),
buttons
:
newBtns
,
toolcallback
:
_
.
bind
(
this
.
onToolClose
,
this
)
});
...
...
@@ -130,7 +150,7 @@ define([
me
.
pluginDlg
.
show
();
},
onPluginClose
:
function
(
plugin
)
{
onPluginClose
:
function
()
{
if
(
this
.
pluginDlg
)
this
.
pluginDlg
.
close
();
},
...
...
apps/common/main/lib/model/Plugin.js
View file @
7b86f889
...
...
@@ -48,18 +48,34 @@ define([
],
function
(
_
,
Backbone
){
'
use strict
'
;
Common
.
Models
.
PluginVariation
=
Backbone
.
Model
.
extend
({
defaults
:
function
()
{
return
{
description
:
""
,
url
:
""
,
index
:
0
,
icons
:
undefined
,
isViewer
:
false
,
EditorsSupport
:
[
"
word
"
,
"
cell
"
,
"
slide
"
],
isVisual
:
false
,
isModal
:
false
,
isInsideMode
:
false
,
initDataType
:
0
,
initData
:
""
,
isUpdateOleOnResize
:
false
,
buttons
:
[]
}
}
});
Common
.
Models
.
Plugin
=
Backbone
.
Model
.
extend
({
defaults
:
function
()
{
return
{
id
:
Common
.
UI
.
getId
(),
name
:
''
,
guid
:
Common
.
UI
.
getId
(),
url
:
undefined
,
icons
:
undefined
,
isVisual
:
false
,
initDataType
:
undefined
,
isUpdateOleOnResize
:
false
,
buttons
:
[{
text
:
"
Ok
"
,
primary
:
true
},{
text
:
"
Cancel
"
,
primary
:
false
}],
variations
:
[],
currentVariation
:
0
,
pluginObj
:
undefined
,
allowSelected
:
false
,
selected
:
false
...
...
apps/common/main/lib/view/Plugins.js
View file @
7b86f889
...
...
@@ -75,7 +75,7 @@ define([
el
:
$
(
'
#plugins-list
'
),
store
:
this
.
storePlugins
,
enableKeyEvents
:
false
,
itemTemplate
:
_
.
template
(
'
<div id="<%= id %>" class="item-plugins" style="background-image: url(
'
+
this
.
pluginsPath
+
'
<%=
icons
[(window.devicePixelRatio > 1) ? 1 : 0] %>); background-position: 0 0;"></div>
'
)
itemTemplate
:
_
.
template
(
'
<div id="<%= id %>" class="item-plugins" style="background-image: url(
'
+
this
.
pluginsPath
+
'
<%=
variations[currentVariation].get("icons")
[(window.devicePixelRatio > 1) ? 1 : 0] %>); background-position: 0 0;"></div>
'
)
});
this
.
trigger
(
'
render:after
'
,
this
);
...
...
apps/documenteditor/main/app/controller/LeftMenu.js
View file @
7b86f889
...
...
@@ -174,14 +174,18 @@ define([
if
(
this
.
mode
.
canUseHistory
)
this
.
leftMenu
.
setOptionsPanel
(
'
history
'
,
this
.
getApplication
().
getController
(
'
Common.Controllers.History
'
).
getView
(
'
Common.Views.History
'
));
this
.
enablePlugins
();
Common
.
util
.
Shortcuts
.
resumeEvents
();
return
this
;
},
enablePlugins
:
function
()
{
if
(
this
.
mode
.
canPlugins
)
{
this
.
leftMenu
.
btnPlugins
.
show
();
this
.
leftMenu
.
setOptionsPanel
(
'
plugins
'
,
this
.
getApplication
().
getController
(
'
Common.Controllers.Plugins
'
).
getView
(
'
Common.Views.Plugins
'
));
}
else
this
.
leftMenu
.
btnPlugins
.
hide
();
Common
.
util
.
Shortcuts
.
resumeEvents
();
return
this
;
},
clickMenuFileItem
:
function
(
menu
,
action
,
isopts
)
{
...
...
apps/documenteditor/main/app/controller/Main.js
View file @
7b86f889
...
...
@@ -138,7 +138,7 @@ define([
// Initialize api gateway
this
.
editorConfig
=
{};
this
.
appOptions
=
{};
this
.
plugins
=
[]
;
this
.
plugins
=
undefined
;
Common
.
Gateway
.
on
(
'
init
'
,
_
.
bind
(
this
.
loadConfig
,
this
));
Common
.
Gateway
.
on
(
'
showmessage
'
,
_
.
bind
(
this
.
onExternalMessage
,
this
));
Common
.
Gateway
.
on
(
'
opendocument
'
,
_
.
bind
(
this
.
loadDocument
,
this
));
...
...
@@ -243,6 +243,8 @@ define([
this
.
appOptions
.
canBackToFolder
=
(
this
.
editorConfig
.
canBackToFolder
!==
false
)
&&
(
typeof
(
this
.
editorConfig
.
customization
)
==
'
object
'
)
&&
(
typeof
(
this
.
editorConfig
.
customization
.
goback
)
==
'
object
'
)
&&
!
_
.
isEmpty
(
this
.
editorConfig
.
customization
.
goback
.
url
);
this
.
appOptions
.
canBack
=
this
.
editorConfig
.
nativeApp
!==
true
&&
this
.
appOptions
.
canBackToFolder
===
true
;
this
.
appOptions
.
canPlugins
=
false
;
this
.
plugins
=
this
.
editorConfig
.
plugins
;
this
.
getApplication
()
.
getController
(
'
Viewport
'
)
...
...
@@ -254,9 +256,6 @@ define([
if
(
this
.
appOptions
.
location
==
'
us
'
||
this
.
appOptions
.
location
==
'
ca
'
)
Common
.
Utils
.
Metric
.
setDefaultMetric
(
Common
.
Utils
.
Metric
.
c_MetricUnits
.
inch
);
this
.
plugins
=
this
.
editorConfig
.
plugins
;
this
.
appOptions
.
canPlugins
=
(
this
.
plugins
&&
this
.
plugins
.
length
>
0
);
},
loadDocument
:
function
(
data
)
{
...
...
@@ -831,6 +830,8 @@ define([
application
.
getController
(
'
Common.Controllers.ExternalMergeEditor
'
).
setApi
(
this
.
api
).
loadConfig
({
config
:
this
.
editorConfig
,
customization
:
this
.
editorConfig
.
customization
});
pluginsController
.
setApi
(
this
.
api
);
this
.
updatePluginsList
(
this
.
plugins
);
this
.
api
.
asc_registerCallback
(
'
asc_onPluginsInit
'
,
_
.
bind
(
this
.
updatePluginsList
,
this
));
documentHolderController
.
setApi
(
me
.
api
);
documentHolderController
.
createDelayedElements
();
...
...
@@ -1010,9 +1011,6 @@ define([
var
translateArt
=
new
Asc
.
asc_TextArtTranslate
();
translateArt
.
asc_setDefaultText
(
this
.
txtArt
);
this
.
api
.
asc_setTextArtTranslate
(
translateArt
);
if
(
this
.
appOptions
.
canPlugins
)
this
.
updatePluginsList
();
}
},
...
...
@@ -1696,25 +1694,50 @@ define([
if
(
url
)
this
.
iframePrint
.
src
=
url
;
},
updatePluginsList
:
function
()
{
updatePluginsList
:
function
(
plugins
)
{
var
pluginStore
=
this
.
getApplication
().
getCollection
(
'
Common.Collections.Plugins
'
);
if
(
pluginStore
&&
this
.
plugins
)
{
if
(
pluginStore
&&
plugins
)
{
var
arr
=
[];
this
.
plugins
.
forEach
(
function
(
item
){
plugins
.
pluginsData
.
forEach
(
function
(
item
){
var
variations
=
item
.
variations
,
variationsArr
=
[];
variations
.
forEach
(
function
(
itemVar
){
variationsArr
.
push
(
new
Common
.
Models
.
PluginVariation
({
description
:
itemVar
.
description
,
index
:
itemVar
.
index
,
url
:
itemVar
.
url
,
icons
:
itemVar
.
icons
,
isViewer
:
itemVar
.
isViewer
,
EditorsSupport
:
itemVar
.
EditorsSupport
,
isVisual
:
itemVar
.
isVisual
,
isModal
:
itemVar
.
isModal
,
isInsideMode
:
itemVar
.
isInsideMode
,
initDataType
:
itemVar
.
initDataType
,
initData
:
itemVar
.
initData
,
isUpdateOleOnResize
:
itemVar
.
isUpdateOleOnResize
,
buttons
:
itemVar
.
buttons
}));
});
arr
.
push
(
new
Common
.
Models
.
Plugin
({
name
:
item
.
name
,
guid
:
item
.
guid
,
url
:
item
.
url
,
icons
:
item
.
icons
,
isVisual
:
item
.
isVisual
,
initDataType
:
item
.
initDataType
,
isUpdateOleOnResize
:
item
.
isUpdateOleOnResize
,
buttons
:
item
.
buttons
variations
:
variationsArr
,
currentVariation
:
0
}));
});
pluginStore
.
reset
(
arr
);
this
.
appOptions
.
pluginsPath
=
(
plugins
.
url
);
this
.
appOptions
.
canPlugins
=
(
arr
.
length
>
0
);
}
else
{
this
.
appOptions
.
pluginsPath
=
''
;
this
.
appOptions
.
canPlugins
=
false
;
}
if
(
this
.
appOptions
.
canPlugins
)
this
.
getApplication
().
getController
(
'
Common.Controllers.Plugins
'
).
setMode
(
this
.
appOptions
);
this
.
getApplication
().
getController
(
'
LeftMenu
'
).
enablePlugins
();
},
leavePageText
:
'
You have unsaved changes in this document. Click
\'
Stay on this Page
\'
then
\'
Save
\'
to save them. Click
\'
Leave this Page
\'
to discard all the unsaved changes.
'
,
...
...
apps/documenteditor/main/app/view/LeftMenu.js
View file @
7b86f889
...
...
@@ -245,7 +245,7 @@ define([
if
(
name
==
'
history
'
)
{
this
.
panelHistory
=
panel
.
render
(
'
#left-panel-history
'
);
}
else
if
(
name
==
'
plugins
'
)
{
if
(
name
==
'
plugins
'
&&
!
this
.
panelPlugins
)
{
this
.
panelPlugins
=
panel
.
render
(
'
#left-panel-plugins
'
);
}
},
...
...
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