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