Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
ecommerce-ui
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
ecommerce-ui
Commits
a2a5ea79
Commit
a2a5ea79
authored
Jul 24, 2013
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor items gadgets (not done)
parent
16d91fb9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
46 deletions
+82
-46
modules/items/items.css
modules/items/items.css
+2
-0
modules/items/items.js
modules/items/items.js
+80
-46
No files found.
modules/items/items.css
View file @
a2a5ea79
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
.items_listview
li
{
.items_listview
li
{
float
:
left
;
float
:
left
;
width
:
25%
;
width
:
25%
;
list-style
:
none
;
}
}
.items_listview
li
,
.items_listview
li
,
.items_listview
li
a
{
.items_listview
li
a
{
...
@@ -61,6 +62,7 @@
...
@@ -61,6 +62,7 @@
white-space
:
normal
;
white-space
:
normal
;
width
:
100%
;
width
:
100%
;
padding-bottom
:
0
;
padding-bottom
:
0
;
text-decoration
:
none
;
}
}
/* we can safely use nth-child, because IE8- doesn't support corners anyway */
/* we can safely use nth-child, because IE8- doesn't support corners anyway */
...
...
modules/items/items.js
View file @
a2a5ea79
...
@@ -4,17 +4,38 @@ define([
...
@@ -4,17 +4,38 @@ define([
,
'
css!items
'
,
'
css!items
'
],
],
function
(
App
,
source
)
{
function
(
App
,
source
)
{
var
response
=
{};
var
that
=
{};
var
priv
=
{};
response
.
data
=
source
;
// in the perfect renderjs world, the items gadget should either expose
// TODO: the method to query and display items should be set be
// an API on how to pass ... query string ... or have default config
// either the searchbar or the storage?
// like pointers or a default fallback. This is what we are doing currently.
response
.
mockup
=
function
(
source
,
callback_mockup
)
{
// Leave it like that!
// Javascript closest()
priv
.
closest
=
function
(
elem
,
selector
)
{
var
matchesSelector
=
elem
.
matches
||
elem
.
webkitMatchesSelector
||
elem
.
mozMatchesSelector
||
elem
.
msMatchesSelector
;
while
(
elem
)
{
if
(
matchesSelector
.
bind
(
elem
)(
selector
))
{
return
elem
;
}
else
{
elem
=
elem
.
parentNode
;
}
}
return
false
;
};
// generate items to display
priv
.
generateItems
=
function
(
params
)
{
var
markup
,
spec
,
var
markup
,
spec
,
gadget
=
RenderJs
.
getSelfGadget
(),
id
=
params
.
gadget
.
dom
.
attr
(
'
id
'
).
split
(
"
__
"
).
splice
(
-
1
)[
0
],
id
=
gadget
.
dom
.
attr
(
'
id
'
).
split
(
"
__
"
).
splice
(
-
1
)[
0
],
config
=
params
.
gadget
.
state
[
0
][
id
].
_config
,
config
=
gadget
.
state
[
0
][
id
].
_config
,
module
=
config
.
datasource
.
module
,
module
=
config
.
datasource
.
module
,
// settable options
// settable options
screen
=
App
.
settings
.
screen_format
,
screen
=
App
.
settings
.
screen_format
,
size
=
screen
===
"
small
"
?
"
small
"
:
"
medium
"
,
size
=
screen
===
"
small
"
?
"
small
"
:
"
medium
"
,
...
@@ -78,38 +99,51 @@ define([
...
@@ -78,38 +99,51 @@ define([
}
}
// add to data
// add to data
markup
=
source
.
replace
(
/<!-- items -->/g
,
str
);
// TODO: this should only replace list items and not the whole
// gadget content...
markup
=
params
.
source
.
replace
(
/<!-- items -->/g
,
str
);
// this is not response.callback(!!)
// this is not response.callback(!!)
callback_mockup
(
markup
);
params
.
callback_mockup
(
markup
);
}
}
// query for items
// query for items
App
[
module
].
switchboard
(
spec
);
App
[
module
].
switchboard
(
spec
);
};
};
response
.
callback
=
function
(
self
)
{
// response object
var
closest
=
function
(
elem
,
selector
)
{
that
.
data
=
source
;
var
matchesSelector
=
elem
.
matches
||
that
.
mockup
=
function
(
source
,
callback_mockup
)
{
elem
.
webkitMatchesSelector
||
var
spec
=
{};
elem
.
mozMatchesSelector
||
elem
.
msMatchesSelector
;
spec
.
gadget
=
RenderJs
.
getSelfGadget
();
// TODO: this is for page event bindings. Once JQM content replaces
while
(
elem
)
{
// page, remove this and make the gadget the content section to
if
(
matchesSelector
.
bind
(
elem
)(
selector
))
{
// be updated.
return
elem
;
spec
.
page
=
priv
.
closest
(
spec
.
gadget
.
dom
[
0
],
"
div[data-role='page']
"
);
spec
.
pageId
=
"
#
"
+
spec
.
page
.
attr
(
'
id
'
);
spec
.
source
=
source
;
spec
.
callback_mockup
=
callback_mockup
;
// if unbound, bind and run once, if bound, just run
if
(
spec
.
gadget
.
sourceSet
===
undefined
)
{
spec
.
gadget
.
sourceSet
=
true
;
$
(
document
).
on
(
"
pagebeforeshow
"
,
spec
.
pageId
,
function
(
e
)
{
priv
.
generateItems
(
spec
);
});
priv
.
generateItems
(
spec
);
}
else
{
}
else
{
elem
=
elem
.
parentNode
;
priv
.
generateItems
(
spec
);
}
}
}
return
false
;
};
};
that
.
callback
=
function
(
self
)
{
// set binding for opening a detailed view
// set binding for opening a detailed view
// TODO: this should also be a link-method call
// TODO: this should also be a link-method call
self
.
dom
.
find
(
"
ul
"
).
on
(
"
click
"
,
"
a
"
,
function
(
e
)
{
self
.
dom
.
find
(
"
ul
"
).
on
(
"
click
"
,
"
a
"
,
function
(
e
)
{
var
key
;
var
key
;
e
.
preventDefault
();
e
.
preventDefault
();
key
=
closest
(
e
.
target
,
"
a
"
).
getAttribute
(
"
href
"
).
split
(
"
?
"
)[
1
];
key
=
priv
.
closest
(
e
.
target
,
"
a
"
).
getAttribute
(
"
href
"
).
split
(
"
?
"
)[
1
];
// show this item
// show this item
$
.
mobile
.
changePage
(
"
details.html
"
,
{
$
.
mobile
.
changePage
(
"
details.html
"
,
{
"
transition
"
:
"
slide
"
,
"
transition
"
:
"
slide
"
,
...
@@ -136,6 +170,6 @@ define([
...
@@ -136,6 +170,6 @@ define([
};
};
// return response object
// return response object
return
response
;
return
that
;
}
}
);
);
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