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
2bba2325
Commit
2bba2325
authored
Nov 29, 2013
by
Thibaut Frain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working with RSVP
parent
cfb3aab4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
59 deletions
+64
-59
src/js/gadget_index.js
src/js/gadget_index.js
+32
-27
src/js/gadget_io.js
src/js/gadget_io.js
+31
-31
test/codemirror-gadget-test.html
test/codemirror-gadget-test.html
+1
-1
No files found.
src/js/gadget_index.js
View file @
2bba2325
...
@@ -7,10 +7,9 @@
...
@@ -7,10 +7,9 @@
$
.
mobile
.
hashListeningEnabled
=
false
;
$
.
mobile
.
hashListeningEnabled
=
false
;
$
.
mobile
.
pushStateEnabled
=
false
;
$
.
mobile
.
pushStateEnabled
=
false
;
rJS
(
window
).
ready
(
function
()
{
rJS
(
window
).
ready
(
function
(
g
)
{
var
g
=
rJS
(
this
),
var
body
=
g
.
element
,
body
=
g
.
context
,
main_context
=
window
.
document
.
getElementById
(
'
.ui-content
'
),
main_context
=
g
.
context
.
find
(
'
.ui-content
'
).
first
(),
ioGadgetConfig
=
{
"
type
"
:
"
local
"
,
ioGadgetConfig
=
{
"
type
"
:
"
local
"
,
"
username
"
:
"
officejs
"
,
"
username
"
:
"
officejs
"
,
"
application_name
"
:
"
officejs
"
"
application_name
"
:
"
officejs
"
...
@@ -18,12 +17,12 @@
...
@@ -18,12 +17,12 @@
jioGadget
;
jioGadget
;
function
setTitle
(
title
)
{
function
setTitle
(
title
)
{
g
.
contex
t
.
find
(
"
#headergadget
"
).
find
(
"
h1
"
).
text
(
title
);
g
.
elemen
t
.
find
(
"
#headergadget
"
).
find
(
"
h1
"
).
text
(
title
);
return
$
(
'
title
'
).
text
(
"
OfficeJS |
"
+
title
);
return
$
(
'
title
'
).
text
(
"
OfficeJS |
"
+
title
);
}
}
function
enhanceGadgetRendering
(
gadget
)
{
function
enhanceGadgetRendering
(
gadget
)
{
gadget
.
contex
t
.
enhanceWithin
();
gadget
.
elemen
t
.
enhanceWithin
();
return
gadget
.
getTitle
()
return
gadget
.
getTitle
()
.
then
(
setTitle
);
.
then
(
setTitle
);
}
}
...
@@ -64,77 +63,83 @@
...
@@ -64,77 +63,83 @@
function
initializeRoute
()
{
function
initializeRoute
()
{
body
body
.
route
(
"
add
"
,
""
,
1
)
.
route
(
"
add
"
,
""
,
1
)
.
done
(
function
()
{
.
then
(
function
()
{
$
.
url
.
redirect
(
'
/login/
'
);
$
.
url
.
redirect
(
'
/login/
'
);
});
});
body
body
.
route
(
"
add
"
,
"
/about/
"
,
1
)
.
route
(
"
add
"
,
"
/about/
"
,
1
)
.
done
(
function
()
{
.
then
(
function
()
{
g
.
declareGadget
(
'
./about.html
'
,
main_context
)
g
.
declareGadget
(
'
./about.html
'
,
{
element
:
main_context
}
)
.
then
(
enhanceGadgetRendering
);
.
then
(
enhanceGadgetRendering
);
});
});
body
body
.
route
(
"
add
"
,
"
/contact/
"
,
1
)
.
route
(
"
add
"
,
"
/contact/
"
,
1
)
.
done
(
function
()
{
.
then
(
function
()
{
g
.
declareGadget
(
'
./contact.html
'
,
main_context
)
g
.
declareGadget
(
'
./contact.html
'
,
{
element
:
main_context
}
)
.
then
(
enhanceGadgetRendering
);
.
then
(
enhanceGadgetRendering
);
});
});
body
body
.
route
(
"
add
"
,
"
/login/
"
,
1
)
.
route
(
"
add
"
,
"
/login/
"
,
1
)
.
done
(
function
()
{
.
then
(
function
()
{
g
.
declareGadget
(
'
./login.html
'
,
main_context
)
g
.
declareGadget
(
'
./login.html
'
,
{
element
:
main_context
}
)
.
then
(
enhanceGadgetRendering
);
.
then
(
enhanceGadgetRendering
);
});
});
body
body
.
route
(
"
add
"
,
"
/spreadsheet/
"
,
1
)
.
route
(
"
add
"
,
"
/spreadsheet/
"
,
1
)
.
done
(
function
()
{
.
then
(
function
()
{
g
.
declareIframedGadget
(
'
./jqs.html
'
,
main_context
)
g
.
declareGadget
(
'
./jqs.html
'
,
{
sandbox
:
"
iframe
"
,
element
:
main_context
})
.
then
(
registerIOButtons
);
.
then
(
registerIOButtons
);
});
});
body
body
.
route
(
"
add
"
,
"
/bootstrap-wysiwyg/
"
,
1
)
.
route
(
"
add
"
,
"
/bootstrap-wysiwyg/
"
,
1
)
.
done
(
function
()
{
.
then
(
function
()
{
g
.
declareIframedGadget
(
'
./bootstrap-wysiwyg.html
'
,
main_context
)
g
.
declareGadget
(
'
./bootstrap-wysiwyg.html
'
,
{
sandbox
:
"
iframe
"
,
element
:
main_context
})
.
then
(
registerIOButtons
);
.
then
(
registerIOButtons
);
});
});
body
body
.
route
(
"
add
"
,
"
/mercury/
"
,
1
)
.
route
(
"
add
"
,
"
/mercury/
"
,
1
)
.
done
(
function
()
{
.
then
(
function
()
{
g
.
declareIframedGadget
(
'
./mercury.html
'
,
main_context
)
g
.
declareGadget
(
'
./mercury.html
'
,
{
sandbox
:
"
iframe
"
,
element
:
main_context
})
.
then
(
registerIOButtons
);
.
then
(
registerIOButtons
);
});
});
body
body
.
route
(
"
add
"
,
"
/codemirror/
"
,
1
)
.
route
(
"
add
"
,
"
/codemirror/
"
,
1
)
.
done
(
function
()
{
.
then
(
function
()
{
g
.
declareIframedGadget
(
'
./codemirror.html
'
,
main_context
)
g
.
declareGadget
(
'
./codemirror.html
'
,
{
sandbox
:
"
iframe
"
,
element
:
main_context
})
.
then
(
registerIOButtons
);
.
then
(
registerIOButtons
);
});
});
body
body
.
route
(
"
add
"
,
"
/svgedit/
"
,
1
)
.
route
(
"
add
"
,
"
/svgedit/
"
,
1
)
.
done
(
function
()
{
.
then
(
function
()
{
g
.
declareIframedGadget
(
'
./svg-editor.html
'
,
main_context
)
g
.
declareGadget
(
'
./svg-editor.html
'
,
{
sandbox
:
"
iframe
"
,
element
:
main_context
})
.
then
(
registerIOButtons
);
.
then
(
registerIOButtons
);
});
});
}
}
g
.
declareGadget
(
'
./io.html
'
,
g
.
context
.
find
(
"
#iogadget
"
))
g
.
declareGadget
(
'
./io.html
'
,
.
done
(
function
(
ioGadget
)
{
{
element
:
document
.
getElementById
(
"
iogadget
"
)})
.
then
(
function
(
ioGadget
)
{
window
.
jio
=
ioGadget
;
window
.
jio
=
ioGadget
;
jioGadget
=
ioGadget
;
jioGadget
=
ioGadget
;
// Trigger route change
// Trigger route change
initializeRoute
();
initializeRoute
();
$
.
url
.
onhashchange
(
function
()
{
$
.
url
.
onhashchange
(
function
()
{
body
.
route
(
"
go
"
,
$
.
url
.
getPath
())
body
.
route
(
"
go
"
,
$
.
url
.
getPath
())
.
fail
(
function
()
{
.
then
(
null
,
function
()
{
g
.
declareGadget
(
'
./error.html
'
,
main_context
)
g
.
declareGadget
(
'
./error.html
'
,
{
element
:
main_context
}
)
.
then
(
enhanceGadgetRendering
)
.
then
(
enhanceGadgetRendering
)
.
then
(
initializeRoute
);
.
then
(
initializeRoute
);
});
});
...
...
src/js/gadget_io.js
View file @
2bba2325
/*global window, j
Query, jIO, rJS
*/
/*global window, j
IO, rJS, RSVP
*/
/*jslint unparam: true*/
/*jslint unparam: true*/
"
use strict
"
;
"
use strict
"
;
(
function
(
window
,
$
,
jIO
,
rJS
)
{
(
function
(
window
,
jIO
,
rJS
,
RSVP
)
{
var
gk
=
rJS
(
window
);
var
gk
=
rJS
(
window
);
gk
.
declareMethod
(
'
configureIO
'
,
function
(
json_configuration
,
key
)
{
gk
.
declareMethod
(
'
configureIO
'
,
function
(
json_configuration
,
key
)
{
rJS
(
this
).
jio
=
jIO
.
newJio
(
json_configuration
);
rJS
(
this
).
jio
=
jIO
.
newJio
(
json_configuration
);
rJS
(
this
).
jio_key
=
key
;
rJS
(
this
).
jio_key
=
key
;
//console.log(rJS(this).jio);
return
key
;
return
key
;
})
})
.
declareMethod
(
'
getIO
'
,
function
()
{
.
declareMethod
(
'
getIO
'
,
function
()
{
var
deferred
=
$
.
Deferred
(),
default_value
=
""
,
gadget
=
rJS
(
this
);
gadget
.
jio
.
getAttachment
({
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
"
_id
"
:
gadget
.
jio_key
,
var
default_value
=
""
,
"
_attachment
"
:
"
body.txt
"
gadget
=
rJS
(
this
);
},
function
(
err
,
response
)
{
if
(
err
)
{
gadget
.
jio
.
getAttachment
({
if
(
err
.
status
===
404
)
{
"
_id
"
:
gadget
.
jio_key
,
deferred
.
resolve
(
default_value
);
"
_attachment
"
:
"
body.txt
"
},
function
(
err
,
response
)
{
if
(
err
)
{
if
(
err
.
status
===
404
)
{
resolve
(
default_value
);
}
else
{
reject
(
err
);
}
}
else
{
}
else
{
deferred
.
reject
(
err
);
resolve
(
response
||
default_value
);
}
}
}
else
{
});
//console.log("getIO: " + response);
deferred
.
resolve
(
response
||
default_value
);
}
});
});
return
deferred
.
promise
();
})
})
.
declareMethod
(
'
setIO
'
,
function
(
value
)
{
.
declareMethod
(
'
setIO
'
,
function
(
value
)
{
//console.log("couscous");
var
deferred
=
$
.
Deferred
(),
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
gadget
=
rJS
(
this
);
var
gadget
=
rJS
(
this
);
gadget
.
jio
.
put
({
"
_id
"
:
gadget
.
jio_key
},
function
(
err
,
response
)
{
gadget
.
jio
.
put
({
"
_id
"
:
gadget
.
jio_key
},
function
(
err
,
response
)
{
if
(
err
)
{
if
(
err
)
{
deferred
.
reject
(
err
);
reject
(
err
);
}
else
{
}
else
{
gadget
.
jio
.
putAttachment
({
gadget
.
jio
.
putAttachment
({
"
_id
"
:
gadget
.
jio_key
,
"
_id
"
:
gadget
.
jio_key
,
"
_attachment
"
:
"
body.txt
"
,
"
_attachment
"
:
"
body.txt
"
,
"
_data
"
:
value
,
"
_data
"
:
value
,
"
_mimetype
"
:
"
text/plain
"
"
_mimetype
"
:
"
text/plain
"
},
function
(
err
,
response
)
{
},
function
(
err
,
response
)
{
if
(
err
)
{
if
(
err
)
{
deferred
.
reject
(
err
);
reject
(
err
);
}
else
{
}
else
{
//console.log("putIO: " + value);
//console.log("putIO: " + value);
deferred
.
resolve
();
resolve
();
}
}
});
});
}
}
});
});
return
deferred
.
promise
();
});
});
});
}(
window
,
j
Query
,
jIO
,
rJS
));
}(
window
,
j
IO
,
rJS
,
RSVP
));
test/codemirror-gadget-test.html
View file @
2bba2325
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
<meta
charset=
"utf-8"
>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, height=device-height"
/>
<meta
name=
"viewport"
content=
"width=device-width, height=device-height"
/>
<title>
Test
Bootstrap Wysiwyg
gadget
</title>
<title>
Test
Codemirror
gadget
</title>
<link
rel=
"stylesheet"
href=
"../src/lib/qunit/qunit.css"
>
<link
rel=
"stylesheet"
href=
"../src/lib/qunit/qunit.css"
>
...
...
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