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
cf0bbd3c
Commit
cf0bbd3c
authored
Jun 22, 2011
by
François Billioud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
definitely fix the asynchrnous load for text editor and svg editor
parent
4cf62395
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
69 additions
and
27 deletions
+69
-27
UNGProject/images/ung/favicon.ico
UNGProject/images/ung/favicon.ico
+0
-0
UNGProject/js/editor.js
UNGProject/js/editor.js
+12
-1
UNGProject/js/illustration.js
UNGProject/js/illustration.js
+13
-7
UNGProject/js/theme.js
UNGProject/js/theme.js
+21
-11
UNGProject/js/tools.js
UNGProject/js/tools.js
+21
-6
UNGProject/theme.html
UNGProject/theme.html
+2
-2
No files found.
UNGProject/images/
erp5
/favicon.ico
→
UNGProject/images/
ung
/favicon.ico
View file @
cf0bbd3c
File moved
UNGProject/js/editor.js
View file @
cf0bbd3c
/**
* This file provides classes needed by the text editor
*/
/**
* Editors
* editors must implement the following methods :
* load : load the editor in the current page
* saveEdition : save the edition made by this editor to the current document
* loadContentFromDocument : display the content of the specified document in the editor
*/
var
Xinha
=
function
()
{
this
.
name
=
"
Xinha
"
;
...
...
@@ -15,7 +22,7 @@ var Xinha = function() {
}
this
.
loadContentFromDocument
=
function
(
doc
)
{
var
setText
=
function
()
{
xinha_editors
.
input_area
.
setEditorContent
(
doc
.
getContent
());}
waitBeforeSucceed
(
function
()
{
return
xinha_editors
.
input_area
;},
setText
);
tryUntilSucceed
(
setText
);
}
this
.
load
();
}
...
...
@@ -24,6 +31,10 @@ var Xinha = function() {
/**
* Text documents
* editable documents must implements the following methods
* getType : returns the type of a document
* saveEdition : set the argument as the new content of the document. Change last modification time and display the changes
* setAsCurrentDocument : set the document as currentDocument in the local storage and display its properties in the current page
*/
var
JSONTextDocument
=
function
()
{
...
...
UNGProject/js/illustration.js
View file @
cf0bbd3c
/**
* This file provides classes needed by the illustration editor
*/
/**
* Editors
* editors must implement the following methods :
* load : load the editor in the current page
* saveEdition : save the edition made by this editor to the current document
* loadContentFromDocument : display the content of the specified document in the editor
*/
SVGEditor
=
function
()
{
this
.
name
=
"
svg-editor
"
;
this
.
load
=
function
()
{
$
(
"
#svgframe
"
).
attr
(
"
src
"
,
"
svg-edit
or/svg-editor.html
"
)
}
this
.
load
=
function
()
{
$
(
"
#svgframe
"
).
attr
(
"
src
"
,
"
svg-edit
/svg-editor.html
"
);
}
this
.
saveEdition
=
function
()
{
var
s
=
"
svgframe
"
;
getCurrentDocument
().
saveEdition
(
window
.
frames
[
s
].
svgCanvas
.
getSvgString
());
}
this
.
loadContentFromDocument
=
function
(
doc
)
{
var
s
=
"
svgframe
"
;
window
.
frames
[
s
].
svgCanvas
.
setSvgString
(
doc
.
getContent
());
tryUntilSucceed
(
function
()
{
window
.
frames
[
"
svgframe
"
].
svgEditor
.
loadFromString
(
doc
.
getContent
());});
}
var
s
=
"
svgframe
"
;
this
.
svgCanvas
=
window
.
frames
[
s
].
svgCanvas
;
this
.
load
();
}
/**
* SVG documents
* editable documents must implements the following methods
* getType : returns the type of a document
* saveEdition : set the argument as the new content of the document. Change last modification time and display the changes
* setAsCurrentDocument : set the document as currentDocument in the local storage and display its properties in the current page
*/
var
JSONIllustrationDocument
=
function
()
{
JSONDocument
.
call
(
this
);
//inherits properties from JSONDocument
...
...
UNGProject/js/theme.js
View file @
cf0bbd3c
/**
* This file provides main classes to display the web page
*/
/*
* global variables
*/
...
...
@@ -8,7 +12,9 @@ currentPage = null;
/*
* load page functions
* Page Class
* used to decompose the page and give access to useful elements
* @param page name of the page to be created
*/
var
Page
=
function
(
page
)
{
this
.
name
=
page
;
...
...
@@ -58,6 +64,7 @@ Page.prototype = {
var
doc
=
null
;
var
editor
=
null
;
/* load the editor to work with and a new document to work on */
switch
(
this
.
name
)
{
case
"
editor
"
:
editor
=
new
Xinha
();
...
...
@@ -97,7 +104,10 @@ Page.prototype = {
var
head
=
$
(
this
.
getHTML
()).
find
(
"
head
"
).
append
(
object
);
},
//printers
/* these methods display dynamically information about the page, user or current document
* at the right place on the web page
*/
//user information
/* display the list of availaible languages */
displayLanguages
:
function
(
user
)
{
...
...
@@ -134,14 +144,12 @@ Page.prototype = {
pageContent
.
innerHTML
=
this
.
getContent
();
}
}
getCurrentPage
=
function
()
{
return
currentPage
;}
setCurrentPage
=
function
(
page
)
{
currentPage
=
new
Page
(
page
);
}
setCurrentPage
=
function
(
page
)
{
currentPage
=
new
Page
(
page
);}
/*
* user class
* User Class
* stores useful information about a user and provides methods to manipulate them
*/
var
User
=
function
(
details
)
{
this
.
name
=
"
unknown
"
;
...
...
@@ -149,8 +157,8 @@ var User = function(details) {
this
.
storage
=
"
http://www.unhosted-dav.com
"
;
this
.
identityProvider
=
"
http://www.webfinger.com
"
;
}
User
.
prototype
=
new
UngObject
();
User
.
prototype
.
load
({
User
.
prototype
=
new
UngObject
();
//inherits from UngObject
User
.
prototype
.
load
({
//add methods thanks to the UngObject.load method
getName
:
function
()
{
return
this
.
name
;},
setName
:
function
(
newName
)
{
this
.
name
=
newName
;},
getLanguage
:
function
()
{
return
this
.
language
;},
...
...
@@ -178,6 +186,8 @@ setCurrentUser = function(user) {localStorage.setItem("currentUser", JSON.string
/**
* Documents
* This class is used to store information about document and provide methodes
* to manipulate these elements.
*/
/* JSON document */
...
...
@@ -193,9 +203,9 @@ var JSONDocument = function() {
this
.
lastModification
=
currentTime
();
this
.
state
=
this
.
states
.
draft
;
}
JSONDocument
.
prototype
=
new
UngObject
();
JSONDocument
.
prototype
=
new
UngObject
();
//inherits from UngObject
JSONDocument
.
prototype
.
load
({
JSONDocument
.
prototype
.
load
({
//add methods thanks to the UngObject.load method
//type
getType
:
function
()
{
return
this
.
type
;},
...
...
UNGProject/js/tools.js
View file @
cf0bbd3c
/***
* This file provides some useful element used in the whole web site
*/
/**
* Class UngObject
* provides useful general methods
*/
UngObject
=
function
()
{}
/* return true if this object implements the interface */
...
...
@@ -71,17 +76,16 @@ saveXHR = function(address) {
// load
loadXHR
=
function
(
address
)
{
alert
(
'
loadXHR
'
);
$
.
ajax
({
url
:
address
,
type
:
"
GET
"
,
dataType
:
"
json
"
,
cache
:
false
,
/* username: "smik
",
password: "
asdf",*/
username
:
"
nom
"
,
password
:
"
test
"
,
success
:
function
(
data
){
alert
(
data
);
var
cDoc
=
getCurrentDocument
();
cDoc
.
load
(
JSON
.
parse
(
data
)
);
cDoc
.
load
(
data
);
cDoc
.
setAsCurrentDocument
();
}
});
...
...
@@ -93,7 +97,6 @@ loadXHR = function(address) {
waitBeforeSucceed
=
function
(
required
,
func
)
{
var
nb
=
2
;
//avoid to test too much times
var
execute
=
function
()
{
//if(test()) {tryUntilSucceed(func);}
try
{
if
(
!
required
.
call
())
{
throw
0
;}
func
.
call
();}
...
...
@@ -103,3 +106,15 @@ waitBeforeSucceed = function(required, func) {
execute
();
}
/*
* try a function until the execution meets with no error
*/
tryUntilSucceed
=
function
(
func
)
{
var
nb
=
2
;
//avoid to test too much times
var
execute
=
function
()
{
try
{
func
.
call
();}
catch
(
e
)
{
if
(
nb
<
100
)
{
setTimeout
(
execute
,
nb
*
400
);}
console
.
log
(
e
);}
nb
*=
nb
;
}
execute
();
}
\ No newline at end of file
UNGProject/theme.html
View file @
cf0bbd3c
...
...
@@ -33,8 +33,8 @@
// initialize
var
initPage
=
function
()
{
var
pageIWantToTest
=
"
editor
"
;
addressOfTestDocument
=
"
http://sidunhosted.com/webdav/emacs
"
;
var
pageIWantToTest
=
"
illustration
"
;
addressOfTestDocument
=
"
dav/temp2.json
"
;
setCurrentPage
(
pageIWantToTest
);
}
...
...
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