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