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
db32744f
Commit
db32744f
authored
Oct 25, 2013
by
Thibaut Frain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring and adding some Jquery.sheet tests
parent
14a89b18
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
103 additions
and
74 deletions
+103
-74
src/gadget/index.html
src/gadget/index.html
+8
-0
src/js/gadget_index.js
src/js/gadget_index.js
+17
-6
src/js/gadget_jqs.js
src/js/gadget_jqs.js
+6
-6
test/jqs-gadget-test.js
test/jqs-gadget-test.js
+72
-62
No files found.
src/gadget/index.html
View file @
db32744f
...
@@ -83,6 +83,14 @@
...
@@ -83,6 +83,14 @@
<h3>
Spreadsheet
</h3>
<h3>
Spreadsheet
</h3>
</a>
</a>
</li>
</li>
<li
data-role=
"list-divider"
>
New document
</li>
<li
class=
"listview_item listview_icon"
>
<a
href=
"#/bootstrap-wysiwyg/"
>
<span
class=
"ui-li-icon ui-li-icon-custom ui-icon-folder-open-alt ui-icon"
>
</span>
<h3>
Bootstrap-wysiwyg
</h3>
</a>
</li>
<li
data-role=
"list-divider"
>
General
</li>
<li
data-role=
"list-divider"
>
General
</li>
<li
class=
"listview_item listview_icon"
>
<li
class=
"listview_item listview_icon"
>
<a
href=
"#/about/"
>
<a
href=
"#/about/"
>
...
...
src/js/gadget_index.js
View file @
db32744f
...
@@ -44,17 +44,23 @@
...
@@ -44,17 +44,23 @@
var
fileName
=
$
(
"
#iogadget input
"
).
val
();
var
fileName
=
$
(
"
#iogadget input
"
).
val
();
jioGadget
.
configureIO
(
ioGadgetConfig
,
fileName
)
jioGadget
.
configureIO
(
ioGadgetConfig
,
fileName
)
.
then
(
jioGadget
.
getIO
)
.
then
(
jioGadget
.
getIO
)
.
then
(
gadget
.
pu
tContent
);
.
then
(
gadget
.
se
tContent
);
});
});
return
gadget
;
return
gadget
;
}
}
function
registerClea
n
Button
(
gadget
)
{
function
registerClea
r
Button
(
gadget
)
{
$
(
"
#new-doc
"
).
click
(
function
()
{
$
(
"
#new-doc
"
).
click
(
function
()
{
gadget
.
resetShee
t
();
gadget
.
clearConten
t
();
});
});
}
}
function
registerIOButtons
(
gadget
)
{
registerSaveButton
(
gadget
);
registerLoadButton
(
gadget
);
registerClearButton
(
gadget
);
}
function
initializeRoute
()
{
function
initializeRoute
()
{
body
body
.
route
(
"
add
"
,
""
,
1
)
.
route
(
"
add
"
,
""
,
1
)
...
@@ -87,9 +93,14 @@
...
@@ -87,9 +93,14 @@
.
route
(
"
add
"
,
"
/spreadsheet/
"
,
1
)
.
route
(
"
add
"
,
"
/spreadsheet/
"
,
1
)
.
done
(
function
()
{
.
done
(
function
()
{
g
.
declareIframedGadget
(
'
./jqs.html
'
,
main_context
)
g
.
declareIframedGadget
(
'
./jqs.html
'
,
main_context
)
.
then
(
registerSaveButton
)
.
then
(
registerIOButtons
);
.
then
(
registerLoadButton
)
});
.
then
(
registerCleanButton
);
body
.
route
(
"
add
"
,
"
/bootstrap-wysiwyg/
"
,
1
)
.
done
(
function
()
{
g
.
declareIframedGadget
(
'
./bootstrap-wysiwyg.html
'
,
main_context
)
.
then
(
registerIOButtons
);
});
});
}
}
...
...
src/js/gadget_jqs.js
View file @
db32744f
...
@@ -32,25 +32,25 @@
...
@@ -32,25 +32,25 @@
rJS
(
window
).
declareMethod
(
'
getContent
'
,
function
()
{
rJS
(
window
).
declareMethod
(
'
getContent
'
,
function
()
{
var
content
=
JSON
.
stringify
(
$
.
sheet
.
instance
[
0
].
exportSheet
.
json
());
var
content
=
JSON
.
stringify
(
$
.
sheet
.
instance
[
0
].
exportSheet
.
json
());
//console.log("getContent: " + content);
console
.
log
(
"
function getContent
"
+
content
);
console
.
log
(
"
function getContent
"
+
content
);
return
content
;
return
content
;
})
})
.
declareMethod
(
'
pu
tContent
'
,
function
(
content
)
{
.
declareMethod
(
'
se
tContent
'
,
function
(
content
)
{
var
config
=
$
.
extend
({
var
config
=
$
.
extend
({
buildSheet
:
$
.
sheet
.
makeTable
.
json
(
JSON
.
parse
(
content
))
buildSheet
:
$
.
sheet
.
makeTable
.
json
(
JSON
.
parse
(
content
))
},
default_config
);
},
default_config
);
rJS
(
this
).
init
(
config
);
console
.
log
(
config
.
buildSheet
);
init
.
apply
(
rJS
(
this
),
[
config
]);
})
})
.
declareMethod
(
'
resetShee
t
'
,
function
()
{
.
declareMethod
(
'
clearConten
t
'
,
function
()
{
$
.
sheet
.
killAll
();
$
.
sheet
.
killAll
();
rJS
(
this
).
init
(
default_config
);
init
.
apply
(
rJS
(
this
),
[
default_config
]
);
})
})
.
ready
(
function
()
{
.
ready
(
function
()
{
init
.
apply
(
rJS
(
this
),
default_config
);
init
.
apply
(
rJS
(
this
),
[
default_config
]
);
});
});
}(
window
,
jQuery
,
rJS
));
}(
window
,
jQuery
,
rJS
));
test/jqs-gadget-test.js
View file @
db32744f
...
@@ -11,106 +11,116 @@ QUnit.config.testTimeout = 1000;
...
@@ -11,106 +11,116 @@ QUnit.config.testTimeout = 1000;
start
=
QUnit
.
start
,
start
=
QUnit
.
start
,
ok
=
QUnit
.
ok
,
ok
=
QUnit
.
ok
,
equal
=
QUnit
.
equal
,
equal
=
QUnit
.
equal
,
expect
=
QUnit
.
expect
;
expect
=
QUnit
.
expect
,
//throws = QUnit.throws,
//throws = QUnit.throws,
//deepEqual = QUnit.deepEqual;
//deepEqual = QUnit.deepEqual;
gadgetURL
=
'
../deploy/gadget/jqs.html
'
;
function
iframeSelector
(
selectorString
)
{
function
iframeSelector
(
selectorString
)
{
return
$
(
'
iframe
'
).
contents
().
find
(
selectorString
);
return
$
(
'
iframe
'
).
contents
().
find
(
selectorString
);
}
}
function
buildSelector
(
n
,
i
,
j
)
{
var
res
=
"
table.jSheet td#
"
;
return
res
+
n
+
"
_table0_cell_c
"
+
i
+
"
_r
"
+
j
;
}
rJS
(
window
).
ready
(
function
()
{
rJS
(
window
).
ready
(
function
()
{
var
g
=
rJS
(
this
),
var
g
=
rJS
(
this
),
jqs_context
=
g
.
context
.
find
(
'
.jqs-gadget
'
).
first
();
jqs_context
=
g
.
context
.
find
(
'
.jqs-gadget
'
).
first
();
asyncTest
(
"
jquery.sheet loading
"
,
function
()
{
asyncTest
(
"
jquery.sheet loading : sheet loads
"
,
2
,
function
()
{
expect
(
2
);
g
.
declareIframedGadget
(
gadgetURL
,
jqs_context
);
g
.
declareIframedGadget
(
'
../src/gadget/jqs.html
'
,
jqs_context
);
setTimeout
(
function
()
{
setTimeout
(
function
()
{
ok
(
iframeSelector
(
"
table.jSheet td#0_table0_cell_c0_r0
"
).
length
!=
0
);
var
c0r0
=
buildSelector
(
0
,
0
,
0
);
ok
(
iframeSelector
(
"
table.jSheet td#0_table0_cell_c1_r1
"
).
length
!=
0
);
var
c1r1
=
buildSelector
(
0
,
1
,
1
);
ok
(
iframeSelector
(
c0r0
).
length
!=
0
);
ok
(
iframeSelector
(
c1r1
).
length
!=
0
);
start
();
start
();
},
100
);
},
100
);
});
});
asyncTest
(
"
reset sheet
"
,
function
()
{
asyncTest
(
"
jquery.sheet loading : sheet is empty
"
,
2
,
function
()
{
expect
(
2
);
g
.
declareIframedGadget
(
gadgetURL
,
jqs_context
);
g
.
declareIframedGadget
(
'
../src/gadget/jqs.html
'
,
jqs_context
)
var
c0r0
=
buildSelector
(
0
,
0
,
0
);
var
c1r1
=
buildSelector
(
0
,
1
,
1
);
setTimeout
(
function
()
{
equal
(
iframeSelector
(
c0r0
).
html
(),
""
);
equal
(
iframeSelector
(
c1r1
).
html
(),
""
);
start
();
},
100
);
});
asyncTest
(
"
clear content
"
,
2
,
function
()
{
var
c0r0
=
buildSelector
(
0
,
0
,
0
);
var
c1r1
=
buildSelector
(
0
,
1
,
1
);
g
.
declareIframedGadget
(
gadgetURL
,
jqs_context
)
.
then
(
function
(
gadget
)
{
.
then
(
function
(
gadget
)
{
iframeSelector
(
"
table.jSheet td#0_table0_cell_c0_r0
"
)
iframeSelector
(
c0r0
).
html
(
'
c0r0Value
'
);
.
html
(
'
c0r0Value
'
);
iframeSelector
(
c1r1
).
html
(
'
c1r1Value
'
);
iframeSelector
(
"
table.jSheet td#0_table0_cell_c1_r1
"
)
.
html
(
'
c1r1Value
'
);
return
gadget
;
return
gadget
;
})
})
.
then
(
function
(
gadget
)
{
.
then
(
function
(
gadget
)
{
gadget
.
resetSheet
().
then
(
function
()
{
return
gadget
.
clearContent
().
then
(
function
()
{
equal
(
iframeSelector
(
equal
(
iframeSelector
(
c0r0
).
text
(),
""
);
"
table.jSheet td#0_table0_cell_c0_r0
"
).
text
(),
""
);
equal
(
iframeSelector
(
c1r1
).
text
(),
""
);
equal
(
iframeSelector
(
"
table.jSheet td#0_table0_cell_c1_r1
"
).
text
(),
""
);
start
();
});
});
});
})
.
always
(
start
);
});
});
asyncTest
(
"
get content of sheet
"
,
function
()
{
asyncTest
(
"
get content of sheet
"
,
2
,
function
()
{
expect
(
2
);
var
c0r0
=
buildSelector
(
0
,
0
,
0
);
g
.
declareIframedGadget
(
'
../src/gadget/jqs.html
'
,
jqs_context
)
var
c1r1
=
buildSelector
(
0
,
1
,
1
);
g
.
declareIframedGadget
(
gadgetURL
,
jqs_context
)
.
then
(
function
(
gadget
)
{
.
then
(
function
(
gadget
)
{
iframeSelector
(
iframeSelector
(
c0r0
).
html
(
'
c0r0Value
'
);
"
table.jSheet td#0_table0_cell_c0_r0
"
).
html
(
'
c0r0Value
'
);
iframeSelector
(
c1r1
).
html
(
'
c1r1Value
'
);
iframeSelector
(
"
table.jSheet td#0_table0_cell_c1_r1
"
).
html
(
'
c1r1Value
'
);
return
gadget
;
return
gadget
;
})
})
.
then
(
function
(
gadget
)
{
.
then
(
function
(
gadget
)
{
gadget
.
getContent
().
then
(
function
(
content
)
{
return
gadget
.
getContent
().
then
(
function
(
content
)
{
var
json
=
JSON
.
parse
(
content
)[
0
];
var
json
=
JSON
.
parse
(
content
)[
0
];
equal
(
json
.
data
.
r0
.
c0
.
value
,
"
c0r0Value
"
);
equal
(
json
.
data
.
r0
.
c0
.
value
,
"
c0r0Value
"
);
equal
(
json
.
data
.
r1
.
c1
.
value
,
"
c1r1Value
"
);
equal
(
json
.
data
.
r1
.
c1
.
value
,
"
c1r1Value
"
);
start
();
});
});
});
})
.
always
(
start
);
});
});
asyncTest
(
"
set content of sheet
"
,
function
()
{
asyncTest
(
"
set content of sheet
"
,
function
()
{
expect
(
4
);
expect
(
4
);
var
gadget
,
content
;
var
gadget
,
content
,
t0c0r0
=
buildSelector
(
0
,
0
,
0
),
t0c1r1
=
buildSelector
(
0
,
1
,
1
),
t2c0r0
=
buildSelector
(
2
,
0
,
0
),
t2c1r1
=
buildSelector
(
2
,
1
,
1
);
g
.
declareIframedGadget
(
'
../src/gadget/jqs.html
'
,
jqs_context
)
g
.
declareIframedGadget
(
gadgetURL
,
jqs_context
)
.
then
(
function
(
gd
)
{
.
then
(
function
(
gd
)
{
iframeSelector
(
iframeSelector
(
t0c0r0
).
html
(
'
c0r0Value
'
);
"
table.jSheet td#0_table0_cell_c0_r0
"
).
html
(
'
c0r0Value
'
);
iframeSelector
(
t0c1r1
).
html
(
'
c1r1Value
'
);
iframeSelector
(
"
table.jSheet td#0_table0_cell_c1_r1
"
).
html
(
'
c1r1Value
'
);
gadget
=
gd
;
gadget
=
gd
;
return
gadget
.
getContent
();
})
.
then
(
function
(
c
)
{
content
=
c
;
return
gadget
.
clearContent
();
})
.
then
(
function
()
{
equal
(
iframeSelector
(
t0c0r0
).
text
(),
""
);
equal
(
iframeSelector
(
t2c1r1
).
text
(),
""
);
return
gadget
.
setContent
(
content
);
})
.
then
(
function
()
{
equal
(
iframeSelector
(
t2c0r0
).
text
(),
"
c0r0Value
"
);
equal
(
iframeSelector
(
t2c1r1
).
text
(),
"
c1r1Value
"
);
})
})
.
always
(
function
()
{
.
always
(
start
);
gadget
.
getContent
()
.
then
(
function
(
c
)
{
content
=
c
;})
.
always
(
function
()
{
gadget
.
resetSheet
().
then
(
function
()
{
equal
(
iframeSelector
(
"
table.jSheet td#0_table0_cell_c0_r0
"
).
text
(),
""
);
equal
(
iframeSelector
(
"
table.jSheet td#0_table0_cell_c1_r1
"
).
text
(),
""
);
})
.
always
(
function
()
{
gadget
.
putContent
(
content
)
.
always
(
function
()
{
equal
(
iframeSelector
(
"
table.jSheet td#2_table0_cell_c0_r0
"
).
text
(),
"
c0r0Value
"
);
equal
(
iframeSelector
(
"
table.jSheet td#2_table0_cell_c1_r1
"
).
text
(),
"
c1r1Value
"
);
start
();
});
});
});
});
});
});
});
});
}
(
window
,
jQuery
,
QUnit
,
rJS
));
}
(
window
,
jQuery
,
QUnit
,
rJS
));
...
...
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