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
14a89b18
Commit
14a89b18
authored
Oct 24, 2013
by
Thibaut Frain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Jquery.sheet gadget test + functionnality refactoring
parent
daf15026
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
113 additions
and
112 deletions
+113
-112
src/js/erp5_loader.js
src/js/erp5_loader.js
+38
-38
src/js/gadget_index.js
src/js/gadget_index.js
+2
-7
src/js/gadget_jqs.js
src/js/gadget_jqs.js
+34
-42
test/jqs-gadget-test.html
test/jqs-gadget-test.html
+1
-1
test/jqs-gadget-test.js
test/jqs-gadget-test.js
+38
-24
No files found.
src/js/erp5_loader.js
View file @
14a89b18
/*global jQuery, window, document, jIO, confirm, alert */
/*jslint nomen: true */
/*jslint nomen: true
, todo: true, unparam: true
*/
"
use strict
"
;
(
function
(
window
,
document
,
$
,
jIO
)
{
...
...
@@ -222,11 +222,11 @@
* @return {string} The property value
*/
// NOTE: need a different way because this triggers a ton of http requests!
priv
.
getERP5property
=
function
(
id
,
lookup
)
{
var
key
=
id
+
"
/
"
+
lookup
;
// return $.ajax(priv.makeAjaxObject(key));
return
{
"
error
"
:
"
foo
"
};
};
//
priv.getERP5property = function (id, lookup) {
//
var key = id + "/" + lookup;
//
// return $.ajax(priv.makeAjaxObject(key));
//
return {"error": "foo"};
//
};
/**
...
...
@@ -244,9 +244,9 @@
* Create a checkbox to select table rows
* @method createCheckbox
*/
priv
.
createCheckbox
=
function
()
{
//
priv.createCheckbox = function () {
};
//
};
/**
* Create full table
...
...
@@ -273,7 +273,7 @@
console
.
log
(
response
);
var
i
,
j
,
k
,
//
k,
l
,
// table setup
fragment_container
,
...
...
@@ -293,7 +293,7 @@
configure_slot
,
pagination_elements
,
pagination_label
,
pagination_number_of_items
,
//
pagination_number_of_items,
pagination_link
,
pagination_clone
,
pagination_option
,
...
...
@@ -301,7 +301,7 @@
pagination_slot
,
// table
table
,
table_head
,
//
table_head,
table_row
,
table_body
,
table_tick_label
,
...
...
@@ -309,7 +309,7 @@
table_cell
,
table_header
,
table_header_cell
,
fields
,
//
fields,
property
,
cell
,
row
,
...
...
@@ -815,31 +815,31 @@
* @param {string} item Element to show
*/
// NOTE: this should be in another gadget/file
priv
.
generateItem
=
function
(
mode
,
item
)
{
if
(
item
)
{
// fetch data
priv
.
erp5
.
get
({
"
_id
"
:
item
},
function
(
error
,
response
)
{
var
property
,
value
,
abort
;
if
(
response
)
{
for
(
property
in
response
)
{
if
(
response
.
hasOwnProperty
(
property
))
{
value
=
response
[
property
];
priv
.
setValue
(
response
.
type
.
toLowerCase
(),
property
,
value
);
}
}
}
else
{
abort
=
confirm
(
"
Error trying to retrieve data! Go back to overview?
"
);
if
(
abort
===
true
)
{
$
.
mobile
.
changePage
(
"
computers.html
"
);
}
}
});
}
};
//
priv.generateItem = function (mode, item) {
//
if (item) {
//
// fetch data
//
priv.erp5.get({"_id": item}, function (error, response) {
//
var property, value, abort;
//
if (response) {
//
for (property in response) {
//
if (response.hasOwnProperty(property)) {
//
value = response[property];
//
priv.setValue(response.type.toLowerCase(), property, value);
//
}
//
}
//
} else {
//
abort = confirm(
//
"Error trying to retrieve data! Go back to overview?"
//
);
//
if (abort === true) {
//
$.mobile.changePage("computers.html");
//
}
//
}
//
});
//
}
//
};
/**
* Create a serialized object from all values in the form
...
...
@@ -1005,7 +1005,6 @@
return
$
.
mobile
.
path
.
parseUrl
(
path
).
search
.
slice
(
1
).
split
(
"
&
"
);
};
// BINDINGS
// NOTE: done in a hurry...
$
(
document
).
on
(
"
pagebeforeshow
"
,
"
#computers
"
,
function
()
{
...
...
@@ -1133,4 +1132,5 @@
// // select all
// .on("change", "table thead th input[type=checkbox]", function (e) {
});
}(
window
,
document
,
jQuery
,
jIO
));
src/js/gadget_index.js
View file @
14a89b18
/*global window, jQuery, rJS */
"
use strict
"
;
(
function
(
window
,
$
,
rJS
,
undefined
)
{
(
function
(
window
,
$
,
rJS
)
{
$
.
mobile
.
ajaxEnabled
=
false
;
$
.
mobile
.
linkBindingEnabled
=
false
;
...
...
@@ -15,12 +15,7 @@
"
username
"
:
"
officejs
"
,
"
application_name
"
:
"
officejs
"
},
jioGadget
,
jqsGadget
;
function
log
(
x
)
{
console
.
log
(
x
);
}
jioGadget
;
function
setTitle
(
title
)
{
g
.
context
.
find
(
"
#headergadget
"
).
find
(
"
h1
"
).
text
(
title
);
...
...
src/js/gadget_jqs.js
View file @
14a89b18
/*global window, jQuery, rJS*/
"
use strict
"
;
(
function
(
window
,
$
,
rJS
)
{
var
gk
=
rJS
(
window
),
default_config
=
{
id
:
"
jquerysheet-div
"
,
style
:
''
,
jquerySheet
:
true
,
jquerySheetCss
:
true
,
parser
:
true
,
jqueryUiCss
:
true
,
scrollTo
:
false
,
jQueryUI
:
false
,
raphaelJs
:
false
,
gRaphaelJs
:
false
,
colorPicker
:
false
,
colorPickerCss
:
false
,
elastic
:
false
,
advancedMath
:
false
,
finance
:
false
,
editable
:
true
,
autoFiller
:
true
,
urlGet
:
'
../lib/jquery.sheet-2.0.0/new_spreadsheet.html
'
};
(
function
(
window
,
$
,
rJS
)
{
gk
.
declareMethod
(
'
init
'
,
function
(
config
)
{
rJS
(
this
).
parent
=
rJS
(
this
).
context
.
find
(
'
.jQuerySheet
'
);
rJS
(
this
).
parent
.
sheet
(
config
);
rJS
(
this
).
updateInstance
();
function
init
(
config
)
{
this
.
parent
=
this
.
context
.
find
(
'
.jQuerySheet
'
);
this
.
parent
.
sheet
(
config
);
this
.
instance
=
this
.
parent
.
getSheet
();
}
var
default_config
=
{
id
:
"
jquerysheet-div
"
,
style
:
''
,
jquerySheet
:
true
,
jquerySheetCss
:
true
,
parser
:
true
,
jqueryUiCss
:
true
,
scrollTo
:
false
,
jQueryUI
:
false
,
raphaelJs
:
false
,
gRaphaelJs
:
false
,
colorPicker
:
false
,
colorPickerCss
:
false
,
elastic
:
false
,
advancedMath
:
false
,
finance
:
false
,
editable
:
true
,
autoFiller
:
true
,
urlGet
:
'
../lib/jquery.sheet-2.0.0/new_spreadsheet.html
'
};
rJS
(
window
).
declareMethod
(
'
getContent
'
,
function
()
{
var
content
=
JSON
.
stringify
(
$
.
sheet
.
instance
[
0
].
exportSheet
.
json
());
//console.log("getContent: " + content);
console
.
log
(
"
function getContent
"
+
content
);
return
content
;
})
.
declareMethod
(
'
getContent
'
,
function
()
{
var
content
=
JSON
.
stringify
(
$
.
sheet
.
instance
[
0
].
exportSheet
.
json
());
//console.log("getContent: " + content);
console
.
log
(
"
function getContent
"
+
content
);
return
content
;
})
.
declareMethod
(
'
putContent
'
,
function
(
content
)
{
var
config
=
$
.
extend
({
buildSheet
:
$
.
sheet
.
makeTable
.
json
(
JSON
.
parse
(
content
))
...
...
@@ -49,16 +49,8 @@
rJS
(
this
).
init
(
default_config
);
})
.
declareMethod
(
'
updateInstance
'
,
function
()
{
rJS
(
this
).
instance
=
rJS
(
this
).
parent
.
getSheet
();
})
.
declareMethod
(
'
getParent
'
,
function
()
{
return
rJS
(
this
).
parent
;
})
.
ready
(
function
()
{
rJS
(
this
).
init
(
default_config
);
init
.
apply
(
rJS
(
this
),
default_config
);
});
}(
window
,
jQuery
,
rJS
));
test/jqs-gadget-test.html
View file @
14a89b18
...
...
@@ -18,6 +18,6 @@
<body>
<div
id=
"qunit"
></div>
<div
id=
"qunit-fixture"
></div>
<div
class=
"jqs-gadget"
></div>
<div
class=
"jqs-gadget"
style=
"display:none;"
></div>
</body>
</html>
test/jqs-gadget-test.js
View file @
14a89b18
...
...
@@ -2,17 +2,18 @@
/*jslint indent: 2, maxerr: 3, maxlen: 79 */
"
use strict
"
;
QUnit
.
config
.
testTimeout
=
5
00
;
QUnit
.
config
.
testTimeout
=
10
00
;
(
function
(
window
,
$
,
QUnit
,
sinon
,
rJS
)
{
var
test
=
QUnit
.
test
,
stop
=
QUnit
.
stop
,
start
=
QUnit
.
start
,
ok
=
QUnit
.
ok
,
equal
=
QUnit
.
equal
,
expect
=
QUnit
.
expect
,
throws
=
QUnit
.
throws
,
deepEqual
=
QUnit
.
deepEqual
;
(
function
(
window
,
$
,
QUnit
,
rJS
)
{
//var test = QUnit.test,
var
asyncTest
=
QUnit
.
asyncTest
,
//stop = QUnit.stop,
start
=
QUnit
.
start
,
ok
=
QUnit
.
ok
,
equal
=
QUnit
.
equal
,
expect
=
QUnit
.
expect
;
//throws = QUnit.throws,
//deepEqual = QUnit.deepEqual;
function
iframeSelector
(
selectorString
)
{
return
$
(
'
iframe
'
).
contents
().
find
(
selectorString
);
...
...
@@ -37,14 +38,18 @@ QUnit.config.testTimeout = 500;
expect
(
2
);
g
.
declareIframedGadget
(
'
../src/gadget/jqs.html
'
,
jqs_context
)
.
then
(
function
(
gadget
)
{
iframeSelector
(
"
table.jSheet td#0_table0_cell_c0_r0
"
).
html
(
'
c0r0Value
'
);
iframeSelector
(
"
table.jSheet td#0_table0_cell_c1_r1
"
).
html
(
'
c1r1Value
'
);
iframeSelector
(
"
table.jSheet td#0_table0_cell_c0_r0
"
)
.
html
(
'
c0r0Value
'
);
iframeSelector
(
"
table.jSheet td#0_table0_cell_c1_r1
"
)
.
html
(
'
c1r1Value
'
);
return
gadget
;
})
.
then
(
function
(
gadget
)
{
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
(),
""
);
equal
(
iframeSelector
(
"
table.jSheet td#0_table0_cell_c0_r0
"
).
text
(),
""
);
equal
(
iframeSelector
(
"
table.jSheet td#0_table0_cell_c1_r1
"
).
text
(),
""
);
start
();
});
});
...
...
@@ -52,11 +57,12 @@ QUnit.config.testTimeout = 500;
asyncTest
(
"
get content of sheet
"
,
function
()
{
expect
(
2
);
var
c0r0selector
,
c1r1selector
;
g
.
declareIframedGadget
(
'
../src/gadget/jqs.html
'
,
jqs_context
)
.
then
(
function
(
gadget
)
{
iframeSelector
(
"
table.jSheet td#0_table0_cell_c0_r0
"
).
html
(
'
c0r0Value
'
);
iframeSelector
(
"
table.jSheet td#0_table0_cell_c1_r1
"
).
html
(
'
c1r1Value
'
);
iframeSelector
(
"
table.jSheet td#0_table0_cell_c0_r0
"
).
html
(
'
c0r0Value
'
);
iframeSelector
(
"
table.jSheet td#0_table0_cell_c1_r1
"
).
html
(
'
c1r1Value
'
);
return
gadget
;
})
.
then
(
function
(
gadget
)
{
...
...
@@ -75,8 +81,10 @@ QUnit.config.testTimeout = 500;
g
.
declareIframedGadget
(
'
../src/gadget/jqs.html
'
,
jqs_context
)
.
then
(
function
(
gd
)
{
iframeSelector
(
"
table.jSheet td#0_table0_cell_c0_r0
"
).
html
(
'
c0r0Value
'
);
iframeSelector
(
"
table.jSheet td#0_table0_cell_c1_r1
"
).
html
(
'
c1r1Value
'
);
iframeSelector
(
"
table.jSheet td#0_table0_cell_c0_r0
"
).
html
(
'
c0r0Value
'
);
iframeSelector
(
"
table.jSheet td#0_table0_cell_c1_r1
"
).
html
(
'
c1r1Value
'
);
gadget
=
gd
;
})
.
always
(
function
()
{
...
...
@@ -84,14 +92,20 @@ QUnit.config.testTimeout = 500;
.
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
(),
""
);
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
"
);
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
();
});
});
...
...
@@ -99,5 +113,5 @@ QUnit.config.testTimeout = 500;
});
});
});
}
(
window
,
jQuery
,
QUnit
,
sinon
,
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