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
23936633
Commit
23936633
authored
Jul 31, 2013
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Gadgets/details: added RAM storage for items and cleanup
parent
743b346c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
130 additions
and
10 deletions
+130
-10
modules/core/app/app.js
modules/core/app/app.js
+3
-3
modules/core/config/configuration.json
modules/core/config/configuration.json
+3
-0
modules/core/utilities/utilities.js
modules/core/utilities/utilities.js
+28
-7
modules/ui/details/details.js
modules/ui/details/details.js
+96
-0
No files found.
modules/core/app/app.js
View file @
23936633
...
@@ -357,9 +357,9 @@ define([
...
@@ -357,9 +357,9 @@ define([
that
.
settings
=
priv
.
settings
;
that
.
settings
=
priv
.
settings
;
//
keep items in here, so all gadgets can access them vs. having
//
RAM cache of items
// to query jIO over and over from every gadget
that
.
cacheItems
=
{};
that
.
memoryItems
=
[]
;
that
.
activeItem
=
undefined
;
// ========================================================================
// ========================================================================
// PUBLISH APP
// PUBLISH APP
...
...
modules/core/config/configuration.json
View file @
23936633
...
@@ -11,6 +11,9 @@ config_call({
...
@@ -11,6 +11,9 @@ config_call({
"seo"
:
{
"seo"
:
{
"friendly_links"
:
"true"
"friendly_links"
:
"true"
},
},
"cache"
:
{
"max_items_in_ram"
:
25
},
"default_language"
:
"de-DE"
,
"default_language"
:
"de-DE"
,
"language_current"
:
"de-DE"
,
"language_current"
:
"de-DE"
,
"language_selector"
:
"translate"
,
"language_selector"
:
"translate"
,
...
...
modules/core/utilities/utilities.js
View file @
23936633
...
@@ -10,16 +10,37 @@ define([
...
@@ -10,16 +10,37 @@ define([
var
matchesSelector
=
elem
.
matches
||
var
matchesSelector
=
elem
.
matches
||
elem
.
webkitMatchesSelector
||
elem
.
webkitMatchesSelector
||
elem
.
mozMatchesSelector
||
elem
.
mozMatchesSelector
||
elem
.
msMatchesSelector
;
elem
.
msMatchesSelector
,
fallback
;
while
(
elem
)
{
if
(
matchesSelector
)
{
if
(
matchesSelector
.
bind
(
elem
)(
selector
))
{
while
(
elem
)
{
return
elem
;
if
(
matchesSelector
.
bind
(
elem
)(
selector
))
{
}
else
{
return
elem
;
elem
=
elem
.
parentNode
;
}
else
{
elem
=
elem
.
parentNode
;
}
}
return
false
;
}
else
{
// opera...
fallback
=
$
(
elem
).
closest
(
selector
);
if
(
fallback
.
length
>
0
)
{
return
fallback
;
}
return
false
;
}
};
// object size
that
.
objectSize
=
function
(
obj
)
{
var
size
=
0
,
key
;
for
(
key
in
obj
)
{
if
(
obj
.
hasOwnProperty
(
key
))
{
size
++
;
}
}
}
}
return
fals
e
;
return
siz
e
;
};
};
App
.
util
=
that
;
App
.
util
=
that
;
...
...
modules/ui/details/details.js
View file @
23936633
...
@@ -7,7 +7,103 @@ define([
...
@@ -7,7 +7,103 @@ define([
var
that
=
{};
var
that
=
{};
var
priv
=
{};
var
priv
=
{};
// cleanup memory
priv
.
cleanupMemory
=
function
(
memory
)
{
var
item
,
created
,
oldest
=
0
,
limit
=
App
.
settings
.
max_items_in_ram
||
15
,
size
=
App
.
util
.
objectSize
(
memory
);
if
(
size
>
limit
)
{
// find oldest
for
(
item
in
memory
)
{
if
(
memory
.
hasOwnProperty
(
item
))
{
created
=
memory
[
item
][
1
];
if
(
oldest
<
created
)
{
oldest
=
created
;
}
}
}
// purge
for
(
item
in
memory
)
{
if
(
memory
.
hasOwnProperty
(
item
))
{
if
(
created
===
memory
[
item
][
1
])
{
delete
memory
[
item
];
}
}
}
}
};
// retrieve and store item to display
priv
.
storeItem
=
function
(
params
)
{
var
id
,
now
,
spec
,
module
;
// we will have an item to display. Grab it and go!
if
(
location
.
search
!==
""
)
{
spec
=
{};
spec
.
pointer
=
location
.
search
.
split
(
"
=
"
)[
1
];
spec
.
storage
=
"
items
"
spec
.
method
=
"
get
"
spec
.
doc
=
{
"
_id
"
:
spec
.
pointer
}
// TODO: should be passed via JSON?
module
=
"
storage
"
;
now
=
new
Date
().
getTime
();
}
else
{
// route to all products
$
.
mobile
.
changePage
(
"
products.html
"
,
{
"
transition
"
:
"
fade
"
});
}
// jio response
spec
.
callback
=
function
(
err
,
response
)
{
if
(
err
)
{
// error handling
}
else
{
id
=
response
.
_id
;
App
.
cacheItems
[
id
]
=
[
response
,
now
];
App
.
activeItem
=
id
;
// memory
priv
.
cleanupMemory
(
App
.
cacheItems
);
}
// this is not response.callback(!!)
params
.
callback_mockup
(
params
.
source
);
}
// query for items
App
[
module
].
switchboard
(
spec
);
};
// response object
that
.
data
=
source
;
that
.
data
=
source
;
that
.
before
=
function
(
source
,
callback_mockup
)
{
var
spec
=
{};
spec
.
gadget
=
RenderJs
.
getSelfGadget
();
// TODO: this is for page event bindings. Once JQM content replaces
// page, remove this and make the gadget the content section to
// be updated.
spec
.
page
=
App
.
util
.
closest
(
spec
.
gadget
.
dom
.
get
(
0
),
"
div[data-role='page']
"
);
spec
.
pageId
=
"
#
"
+
spec
.
page
.
id
;
spec
.
source
=
source
;
spec
.
callback_mockup
=
callback_mockup
;
if
(
!
spec
.
page
.
getAttribute
(
"
events_details
"
))
{
spec
.
page
.
setAttribute
(
"
events_details
"
,
true
);
$
(
document
).
on
(
"
pagebeforeshow.details
"
,
spec
.
pageId
,
function
(
e
,
data
)
{
// TODO: if we allow to reload, we also need to trigger refresh on
// so we need to reload this every time a page is shown. question
// is how to trigger a refresh on this element ONLY
priv
.
storeItem
(
spec
);
});
// and run intial
priv
.
storeItem
(
spec
);
}
};
that
.
after
=
function
(
self
)
{
that
.
after
=
function
(
self
)
{
if
(
App
===
undefined
)
{
if
(
App
===
undefined
)
{
...
...
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