Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
officejs
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
officejs
Commits
437e88f1
Commit
437e88f1
authored
May 25, 2012
by
Tristan Cavelier
Committed by
Sebastien Robin
Jun 07, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add method 'open' to OfficeJS that can open applications set in preferences.
parent
916cae47
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
157 additions
and
42 deletions
+157
-42
OfficeJS/component/elrte.html
OfficeJS/component/elrte.html
+1
-1
OfficeJS/component/left_nav_bar.html
OfficeJS/component/left_nav_bar.html
+34
-8
OfficeJS/js/officejs.js
OfficeJS/js/officejs.js
+122
-33
No files found.
OfficeJS/component/elrte.html
View file @
437e88f1
...
@@ -50,7 +50,7 @@ $().ready(function() {
...
@@ -50,7 +50,7 @@ $().ready(function() {
<input
type=
"text"
<input
type=
"text"
name=
"fileName"
name=
"fileName"
id=
"input_fileName"
id=
"input_fileName"
value=
"
{{CurrentFileName}}
"
value=
""
placeholder=
"File name here"
/>
placeholder=
"File name here"
/>
<button
type=
"submit"
<button
type=
"submit"
class=
"btn btn-primary"
class=
"btn btn-primary"
...
...
OfficeJS/component/left_nav_bar.html
View file @
437e88f1
...
@@ -6,8 +6,7 @@
...
@@ -6,8 +6,7 @@
<li>
<li>
<a
href=
"#/login"
<a
href=
"#/login"
onclick=
"javascript:
onclick=
"javascript:
TabbularGadget.addNewTabGadget(
OfficeJS.open({app:'login'});
'component/login.html','page-content');
return false;"
>
return false;"
>
<i
class=
"icon-ok"
>
<i
class=
"icon-ok"
>
</i>
</i>
...
@@ -18,16 +17,43 @@
...
@@ -18,16 +17,43 @@
<li
class=
"texteditor"
>
<li
class=
"texteditor"
>
<a
href=
"#/texteditor"
<a
href=
"#/texteditor"
onclick=
"javascript:
onclick=
"javascript:
TabbularGadget.addNewTabGadget(
OfficeJS.open({app:'textEditor'});
OfficeJS.getPathOf(OfficeJS.getPreference('textEditor')),
'page-content');
return false;"
>
return false;"
>
<i
class=
"icon-font"
></i>
<i
class=
"icon-font"
></i>
Text Editor
Writer
</a>
</li>
<li
class=
"imgeditor"
>
<a
href=
"#/imgeditor"
onclick=
"javascript:
OfficeJS.open({app:'imgEditor'});
'page-content');
return false;"
>
<i
class=
"icon-pencil"
></i>
Image Editor
</a>
</li>
<li
class=
"spreadsheet"
>
<a
href=
"#/spreadsheet"
onclick=
"javascript:
OfficeJS.open({app:'speadsheet'});
return false;"
>
<i
class=
"icon-signal"
></i>
Spreadsheet
</a>
</li>
<li
id=
"nav_document_list_header"
style=
"display:none"
>
<a
href=
"#/doclist"
onclick=
"javascript:
OfficeJS.open({app:'documentLister'});
return false;"
>
<!-- <i class="icon-list"></i> -->
Document List
</a>
</a>
<div
id=
"nav_document_list"
>
</div>
</li>
</li>
<li
class=
"nav-header"
><a
href=
"#/doclist"
>
Document List
</a></li>
<div
id=
"document_list"
></div>
</ul>
</ul>
</div>
</div>
</div>
</div>
...
...
OfficeJS/js/officejs.js
View file @
437e88f1
...
@@ -15,9 +15,18 @@
...
@@ -15,9 +15,18 @@
login
:
'
login
'
,
login
:
'
login
'
,
topnavbar
:
'
topnavbar
'
,
topnavbar
:
'
topnavbar
'
,
leftnavbar
:
'
leftnavbar
'
,
leftnavbar
:
'
leftnavbar
'
,
documentLister
:
'
slickgrid
'
,
textEditor
:
'
elrte
'
textEditor
:
'
elrte
'
};
};
priv
.
app_object
=
{
priv
.
app_object
=
{
topnavbar
:
{
path
:
'
component/top_nav_bar.html
'
,
gadgetid
:
'
page-top_nav_bar
'
},
leftnavbar
:
{
path
:
'
component/left_nav_bar.html
'
,
gadgetid
:
'
page-left_nav_bar
'
},
login
:
{
login
:
{
path
:
'
component/login.html
'
,
path
:
'
component/login.html
'
,
gadgetid
:
'
page-content
'
,
gadgetid
:
'
page-content
'
,
...
@@ -32,17 +41,23 @@
...
@@ -32,17 +41,23 @@
},
},
elrte
:
{
elrte
:
{
path
:
'
component/elrte.html
'
,
path
:
'
component/elrte.html
'
,
gadgetid
:
'
page-content
'
,
element
:
'
#elrte_editor
'
,
element
:
'
#elrte_editor
'
,
getContent
:
function
()
{
getContent
:
function
()
{
$
(
this
.
element
).
elrte
(
'
updateSource
'
);
$
(
this
.
element
).
elrte
(
'
updateSource
'
);
return
$
(
this
.
element
).
elrte
(
'
val
'
);
return
$
(
this
.
element
).
elrte
(
'
val
'
);
},
},
onload
:
function
()
{},
},
onunload
:
function
()
{}
slickgrid
:
{
path
:
'
component/slickgrid_document_lister.html
'
,
gadgetid
:
'
page-content
'
,
onload
:
function
()
{}
}
}
};
};
priv
.
data_object
=
{
priv
.
data_object
=
{
documentList
:[]
documentList
:[],
gadget_object
:{},
// contains current gadgets id with their location
currentFile
:
null
};
};
priv
.
loading_object
=
{
priv
.
loading_object
=
{
spinstate
:
0
,
spinstate
:
0
,
...
@@ -84,31 +99,108 @@
...
@@ -84,31 +99,108 @@
// Methods //
// Methods //
/**
/**
* @method getPreference
* Shows a list of document inside the left nav bar
* @param {string} key The preference
* @method showDocumentListInsideLeftNavBar
* @return {object} a clone of the preference object
*/
*/
that
.
getPreference
=
function
(
key
)
{
priv
.
showDocumentListInsideLeftNavBar
=
function
()
{
return
priv
.
preference_object
[
key
];
var
i
,
html_string
=
'
<ul>
'
;
for
(
i
=
0
;
i
<
priv
.
data_object
.
length
;
i
+=
1
)
{
html_string
+=
'
<li>
'
+
'
<a href="#/texteditor:
'
+
priv
.
data_object
[
i
].
fileName
+
'
">
'
+
priv
.
data_object
[
i
].
fileName
+
'
</a>
'
+
'
</li>
'
;
}
html_string
+=
'
</ul>
'
;
if
(
html_string
===
'
<ul></ul>
'
)
{
// if there's no document
html_string
=
'
<ul><li>No document</li></ul>
'
;
}
// show list in the left nav bar
$
(
'
#nav_document_list
'
).
html
(
html_string
);
$
(
'
#nav_document_list_header
'
).
show
();
};
/**
* @method getRealApplication
* @param {string} appname The app name set in preference.
* @return {object} The real application object.
*/
priv
.
getRealApplication
=
function
(
appname
)
{
var
realappname
=
that
.
getPreference
(
appname
);
if
(
!
realappname
)
{
return
;
}
// undefined
return
priv
.
app_object
[
realappname
];
};
};
/**
/**
* @method
jioIs
Set
* @method
isJio
Set
* @return {boolean} true if jio is set else false.
* @return {boolean} true if jio is set else false.
*/
*/
priv
.
jioIs
Set
=
function
()
{
priv
.
isJio
Set
=
function
()
{
return
(
typeof
priv
.
jio
===
'
object
'
);
return
(
typeof
priv
.
jio
===
'
object
'
);
};
};
/**
* Opens an application
* @method open
* @param {object} option Contains some settings:
* - app {string} The app name we want to open, set in preferences
* - ... and some other parameters
*/
that
.
open
=
function
(
option
)
{
var
realapp
,
realgadgetid
,
realpath
,
acientapp
;
realapp
=
priv
.
getRealApplication
(
option
.
app
);
realgadgetid
=
realapp
.
gadgetid
;
realpath
=
realapp
.
path
;
if
(
!
realapp
)
{
// cannot get real app
console
.
error
(
'
Unknown application:
'
+
that
.
getPreference
(
option
.
app
));
return
null
;
}
ancientapp
=
priv
.
data_object
.
gadget_object
[
realgadgetid
];
if
(
ancientapp
)
{
// if there is already a gadget there, unload it
if
(
typeof
ancientapp
.
onunload
!==
'
undefined
'
&&
!
ancientapp
.
onunload
())
{
// if onunload return false, it means that we must not
// load a new gadget because this one is not ready to
// exit.
return
null
;
}
}
priv
.
data_object
.
gadget_object
[
realgadgetid
]
=
realapp
;
TabbularGadget
.
addNewTabGadget
(
realpath
,
realgadgetid
);
if
(
typeof
realapp
.
onload
!==
'
undefined
'
)
{
return
realapp
.
onload
(
option
);
}
};
/**
* @method getPreference
* @param {string} key The preference
* @return {string} The content of the preference.
*/
that
.
getPreference
=
function
(
key
)
{
return
priv
.
preference_object
[
key
];
};
/**
/**
* @method getContentOf
* @method getContentOf
* @param {string} app The application name
* @param {string} app The application name
* @return {string} The content of the application, or null.
* @return {string} The content of the application, or null.
*/
*/
that
.
getContentOf
=
function
(
app
)
{
that
.
getContentOf
=
function
(
app
)
{
if
(
priv
.
app_object
[
app
]
&&
var
realapp
=
that
.
getPreference
(
app
);
typeof
priv
.
app_object
[
app
].
getContent
!==
'
undefined
'
)
{
if
(
!
realapp
)
{
return
priv
.
app_object
[
app
].
getContent
();
console
.
error
(
'
Unknown application:
'
+
that
.
getPreference
(
app
));
return
null
;
}
if
(
priv
.
app_object
[
realapp
]
&&
typeof
priv
.
app_object
[
realapp
].
getContent
!==
'
undefined
'
)
{
return
priv
.
app_object
[
realapp
].
getContent
();
}
}
return
null
;
return
null
;
};
};
...
@@ -119,8 +211,14 @@
...
@@ -119,8 +211,14 @@
* @return {string} The path of the application component, or null.
* @return {string} The path of the application component, or null.
*/
*/
that
.
getPathOf
=
function
(
app
)
{
that
.
getPathOf
=
function
(
app
)
{
if
(
priv
.
app_object
[
app
])
{
var
realapp
=
that
.
getPreference
(
app
);
return
priv
.
app_object
[
app
].
path
;
if
(
!
realapp
)
{
console
.
error
(
'
Unknown application:
'
+
that
.
getPreference
(
app
));
return
null
;
}
if
(
priv
.
app_object
[
realapp
])
{
return
priv
.
app_object
[
realapp
].
path
;
}
}
return
null
;
return
null
;
};
};
...
@@ -131,7 +229,7 @@
...
@@ -131,7 +229,7 @@
* @param {object} applicant The applicant informations
* @param {object} applicant The applicant informations
*/
*/
that
.
setJio
=
function
(
storage
,
applicant
)
{
that
.
setJio
=
function
(
storage
,
applicant
)
{
if
(
priv
.
jioIs
Set
())
{
if
(
priv
.
isJio
Set
())
{
alert
(
'
Jio already set.
'
);
alert
(
'
Jio already set.
'
);
return
;
return
;
}
}
...
@@ -145,7 +243,7 @@
...
@@ -145,7 +243,7 @@
* @method getList
* @method getList
*/
*/
that
.
getList
=
function
()
{
that
.
getList
=
function
()
{
if
(
!
priv
.
jioIs
Set
())
{
if
(
!
priv
.
isJio
Set
())
{
console
.
error
(
'
No Jio set yet.
'
);
console
.
error
(
'
No Jio set yet.
'
);
return
;
return
;
}
}
...
@@ -155,11 +253,11 @@
...
@@ -155,11 +253,11 @@
'
callback
'
:
function
(
result
)
{
'
callback
'
:
function
(
result
)
{
if
(
result
.
status
===
'
done
'
)
{
if
(
result
.
status
===
'
done
'
)
{
priv
.
data_object
=
result
.
return_value
;
priv
.
data_object
=
result
.
return_value
;
priv
.
showDocumentListInsideLeftNavBar
();
}
else
{
}
else
{
console
.
error
(
result
.
message
);
console
.
error
(
result
.
message
);
}
}
priv
.
loading_object
.
end_getlist
();
priv
.
loading_object
.
end_getlist
();
// TODO : show list somewhere
}
}
});
});
};
};
...
@@ -171,7 +269,7 @@
...
@@ -171,7 +269,7 @@
* @param {string} content The content of the document.
* @param {string} content The content of the document.
*/
*/
that
.
save
=
function
(
name
,
content
)
{
that
.
save
=
function
(
name
,
content
)
{
if
(
!
priv
.
jioIs
Set
())
{
if
(
!
priv
.
isJio
Set
())
{
console
.
error
(
'
No Jio set yet.
'
);
console
.
error
(
'
No Jio set yet.
'
);
return
;
return
;
}
}
...
@@ -195,7 +293,7 @@
...
@@ -195,7 +293,7 @@
* @param {string} name The document name.
* @param {string} name The document name.
*/
*/
that
.
load
=
function
(
name
)
{
that
.
load
=
function
(
name
)
{
if
(
!
priv
.
jioIs
Set
())
{
if
(
!
priv
.
isJio
Set
())
{
console
.
error
(
'
No Jio set yet.
'
);
console
.
error
(
'
No Jio set yet.
'
);
return
;
return
;
}
}
...
@@ -219,7 +317,7 @@
...
@@ -219,7 +317,7 @@
* @param {string} name The document name.
* @param {string} name The document name.
*/
*/
that
.
remove
=
function
(
name
)
{
that
.
remove
=
function
(
name
)
{
if
(
!
priv
.
jioIs
Set
())
{
if
(
!
priv
.
isJio
Set
())
{
console
.
error
(
'
No Jio set yet.
'
);
console
.
error
(
'
No Jio set yet.
'
);
return
;
return
;
}
}
...
@@ -242,16 +340,7 @@
...
@@ -242,16 +340,7 @@
}());
// end OfficeJS
}());
// end OfficeJS
// show gadgets
// show gadgets
TabbularGadget
.
addNewTabGadget
(
OfficeJS
.
open
({
app
:
'
topnavbar
'
});
'
component/top_nav_bar.html
'
,
OfficeJS
.
open
({
app
:
'
leftnavbar
'
});
'
page-top_nav_bar
'
,
OfficeJS
.
open
({
app
:
'
login
'
});
undefined
);
TabbularGadget
.
addNewTabGadget
(
'
component/left_nav_bar.html
'
,
'
page-left_nav_bar
'
,
undefined
);
TabbularGadget
.
addNewTabGadget
(
'
component/login.html
'
,
'
page-content
'
,
undefined
);
}());
}());
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