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
ce04d5f3
Commit
ce04d5f3
authored
Nov 13, 2013
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enabled deeplinks by overwriting inital page in JQM history on deeplinks
parent
6ede497b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
45 deletions
+19
-45
js/erp5_loader.js
js/erp5_loader.js
+19
-45
No files found.
js/erp5_loader.js
View file @
ce04d5f3
...
...
@@ -3629,10 +3629,9 @@
init
.
fetchPageLayouts
(
"
settings
"
,
page
.
id
)
.
then
(
function
(
reply
)
{
init
.
setPageTitle
(
page
,
util
.
parseIfNeeded
(
reply
.
response
[
0
]));
if
(
!
page
.
querySelectorAll
(
"
div.ui-content
"
)[
0
]
.
getAttribute
(
"
data-bound
"
))
{
return
init
.
setPageElements
({},
reply
,
undefined
);
return
init
.
setPageElements
({
"
id
"
:
page
.
id
},
reply
,
undefined
);
}
})
.
fail
(
util
.
errorHandler
);
...
...
@@ -3724,7 +3723,7 @@
* @param {object} data Data passed along with this (JQM) event
*/
init
.
parsePage
=
function
(
e
,
data
)
{
var
create
,
config
,
raw_url
,
handle
;
var
create
,
config
,
raw_url
,
handle
,
clean_url
,
parsed_url
;
// TODO:maybe this is the problem???
if
(
data
)
{
...
...
@@ -3741,10 +3740,6 @@
config
=
util
.
parseLink
(
raw_url
);
if
(
e
)
{
// console.log(document.getElementById(raw_url.replace("#", "")))
// console.log(data.options.role === "popup")
// console.log(raw_url === $.mobile.getDocumentUrl())
// console.log($.mobile.getDocumentUrl())
if
(
document
.
getElementById
(
raw_url
.
split
(
"
#
"
).
pop
())
||
raw_url
===
$
.
mobile
.
getDocumentUrl
()
||
data
.
options
.
role
===
"
popup
"
)
{
...
...
@@ -3761,10 +3756,19 @@
e
.
preventDefault
();
}
}
else
{
// if ($.mobile.navigate.history.initialDst && location.hash !== "") {
// console.log("CLEANUP - set initialDst to ")
// $.mobile.navigate.history.initialDst = "";
// }
// HACK: overwrite JQM history, so deeplinks are correctly handled
if
(
$
.
mobile
.
navigate
.
history
.
initialDst
&&
location
.
hash
!==
""
)
{
// this is the inital page (not) loaded, but stored as initial page!
clean_url
=
location
.
href
.
split
(
"
#
"
)[
0
];
parsed_url
=
$
.
mobile
.
path
.
parseUrl
(
clean_url
);
// overwrite :-)
$
.
mobile
.
navigate
.
history
.
stack
[
0
].
hash
=
""
;
$
.
mobile
.
navigate
.
history
.
stack
[
0
].
url
=
clean_url
;
$
.
mobile
.
path
.
documentUrl
=
parsed_url
;
$
.
mobile
.
path
.
documentBase
=
parsed_url
;
}
}
}
if
(
e
===
undefined
||
handle
)
{
...
...
@@ -3829,18 +3833,16 @@
gadgets
=
layout
.
children
||
page
.
querySelectorAll
(
"
[data-gadget-id]
"
);
console
.
log
(
gadgets
)
// NOTE: this may include local header/footer/panel/popups
// TODO: beware of target when adding the above! should not be content
// TODO: bundle into a single DOM operation!
for
(
i
=
0
;
i
<
gadgets
.
length
;
i
+=
1
)
{
gadget
=
gadgets
[
i
];
console
.
log
(
gadget
)
baggage
=
{
"
layout
"
:
gadget
,
"
id
"
:
gadget
.
id
||
gadget
.
getAttribute
(
"
data-gadget-id
"
)
};
console
.
log
(
"
SET BAGGAGE TO:
"
+
baggage
.
id
)
if
(
create
!==
false
)
{
baggage
.
constructor
=
gadget
.
type
||
gadget
.
getAttribute
(
"
data-gadget-type
"
);
}
...
...
@@ -3882,7 +3884,6 @@
// TODO: remove when not needed anymore
if
(
create
!==
false
)
{
// 3. Test for data in JIO
console
.
log
(
"
testing for
"
+
baggage
.
type
)
return
init
.
testForSampleData
({
"
storage
"
:
"
items
"
,
"
type
"
:
baggage
.
type
,
...
...
@@ -3902,13 +3903,6 @@
"
baggage
"
:
baggage
});
}
// TODO: I thought we would need to purge here, in case we start
// on deeplink and fetch single record, based on deeplink, but I
// guess we don't... check why this makes a transition from deeplink
// to firstpage work
console
.
log
(
"
CRAP
"
)
console
.
log
(
reply
.
response
)
return
{
"
baggage
"
:
baggage
};
}
return
{
"
baggage
"
:
baggage
};
})
...
...
@@ -3926,8 +3920,6 @@
return
{
"
baggage
"
:
baggage
};
})
.
then
(
function
(
reply
)
{
console
.
log
(
"
DONE
"
)
console
.
log
(
reply
)
var
baggage
=
reply
.
baggage
;
if
(
create
===
false
)
{
...
...
@@ -3953,7 +3945,6 @@
})
.
then
(
function
(
reply
)
{
var
parsed
,
baggage
=
reply
.
baggage
;
console
.
log
(
"
FOO, why is it not working...
"
);
// single item query
// TODO: more levels? how to generalize and not only search by _id?
...
...
@@ -3968,19 +3959,14 @@
baggage
.
state
.
query
.
limit
=
baggage
.
store_limit
;
delete
baggage
.
store_limit
;
}
else
{
console
.
log
(
"
So we update or create and set query
"
);
baggage
.
state
.
query
=
init
.
generateQueryObject
(
baggage
.
config
.
initial_query
,
baggage
.
type
,
'
_id
'
,
baggage
.
value
);
console
.
log
(
"
What is the initial query
"
)
console
.
log
(
baggage
.
config
.
initial_query
)
}
// new item, no query!
if
(
baggage
.
config
.
mode
)
{
return
{
"
baggage
"
:
baggage
};
}
else
{
console
.
log
(
"
fetch items....:
"
);
console
.
log
(
baggage
.
state
.
query
)
return
util
.
fetchData
({
"
storage
"
:
"
items
"
,
"
query
"
:
baggage
.
state
.
query
,
...
...
@@ -3990,7 +3976,6 @@
})
.
then
(
function
(
reply
)
{
var
baggage
=
reply
.
baggage
,
selector
;
console
.
log
(
"
we are done fetching shit, let's make some content
"
);
// append gadget to wrapping div
element
=
factory
.
map_gadgets
[
baggage
.
constructor
](
...
...
@@ -4006,13 +3991,9 @@
// NOTE: in case of update, element will be the section to update
// not the gadget/fragment, so we need to find the gadget
// NOTE: in case of forms, we find the form!
console
.
log
(
"
we have an element
"
)
console
.
log
(
element
)
console
.
log
(
"
do we have a selector
"
)
selector
=
element
.
querySelector
(
"
#
"
+
baggage
.
id
)
||
document
.
getElementById
(
baggage
.
config
.
form
)
||
element
;
console
.
log
(
selector
)
baggage
.
state
.
gadget
=
selector
;
}
...
...
@@ -4034,9 +4015,6 @@
)
.
enhanceWithin
();
}
else
{
console
.
log
(
"
appending element
"
)
console
.
log
(
target
)
console
.
log
(
element
)
target
.
appendChild
(
element
);
}
delete
baggage
;
...
...
@@ -4047,9 +4025,8 @@
// once the loop is done, we assemble and return the whole thing
return
RSVP
.
all
(
promises
)
.
then
(
function
()
{
console
.
log
(
"
ALL SET
"
)
// set a flag on target to indicate it has been enhanced
target
.
setAttribute
(
"
data-bound
"
,
true
);
target
.
setAttribute
(
"
data-bound
"
,
true
);
// append, initialize and enhance new page
if
(
create
===
true
)
{
...
...
@@ -4069,9 +4046,6 @@
}
else
{
// populate existing page and enhance
if
(
gadgets
.
length
>
0
&&
create
===
undefined
)
{
console
.
log
(
"
PAGE
"
)
console
.
log
(
page
)
console
.
log
(
target
)
$
(
page
).
empty
().
append
(
target
).
enhanceWithin
();
}
}
...
...
@@ -4406,7 +4380,7 @@
/* ====================================================================== */
init
.
contentLoaded
(
window
,
function
()
{
//
TODO: don't
//
HACK: don't!
localStorage
.
clear
();
init
...
...
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