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
ad323839
Commit
ad323839
authored
Oct 28, 2013
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rewrote dummy-url based navigation
parent
e6035e9c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
83 deletions
+68
-83
js/erp5_loader.js
js/erp5_loader.js
+68
-83
No files found.
js/erp5_loader.js
View file @
ad323839
...
...
@@ -614,10 +614,8 @@
if
(
field
.
show
)
{
if
(
field
.
merge
===
undefined
)
{
cell
=
factory
.
generateElement
(
"
td
"
,{},{},{});
// TODO: how to enable column based links?
// must be through gadget definitions
link
=
"
object.html?type=
"
+
settings
.
portal_type_title
+
"
&mode=edit
"
+
"
&item=
"
+
item
.
_id
;
// TODO: links should be passed or there is a method to generate
link
=
"
#
"
+
settings
.
portal_type_title
+
"
/
"
+
item
.
_id
;
// TODO: crap...refactor whole section
// fetch non portal_type values
...
...
@@ -2035,7 +2033,7 @@
init
.
timer
=
window
.
setTimeout
(
function
()
{
// update gadgets
init
.
setPageElements
(
{},
{
"
default
"
:{
"
section
s
"
:[{
"
gadget
"
:
config
.
id
}]}},
false
{},
{
"
default
"
:{
"
section
_list
"
:[{
"
gadget
"
:
config
.
id
}]}},
false
);
init
.
timer
=
0
;
},
500
);
...
...
@@ -2087,7 +2085,7 @@
// update gadget
init
.
setPageElements
(
{},
{
"
default
"
:{
"
section
s
"
:[{
"
gadget
"
:
config
.
id
}]}},
false
{},
{
"
default
"
:{
"
section
_list
"
:[{
"
gadget
"
:
config
.
id
}]}},
false
);
})
.
fail
(
init
.
errorHandler
);
...
...
@@ -2138,7 +2136,7 @@
// update gadget
init
.
setPageElements
(
{},
{
"
default
"
:{
"
section
s
"
:[{
"
gadget
"
:
config
.
id
}]}},
false
{},
{
"
default
"
:{
"
section
_list
"
:[{
"
gadget
"
:
config
.
id
}]}},
false
);
}
else
{
util
.
errorHandler
({
"
Error
"
:
"
No state information stored for gadget
"
});
...
...
@@ -2419,41 +2417,21 @@
* @param {boolean} hashed Backwards transition
* @return {object} pointer object
*/
// TODO:
this whole function is crap... works, but refactor!!!!
util
.
parseLink
=
function
(
url
,
back
)
{
var
fragments
,
// TODO:
replace with renderjs logic
util
.
parseLink
=
function
(
url
)
{
var
path
=
$
.
mobile
.
path
.
parseUrl
(
url
)
,
config
=
{
"
url
"
:
url
||
location
.
href
"
url
"
:
url
};
if
(
url
===
undefined
)
{
if
(
location
.
hash
)
{
// TODO: break this down further e.g. #invoices/1234-56767/1 (map?)
config
[
"
id
"
]
=
location
.
hash
.
replace
(
"
#
"
,
""
);
// flag to generate a deeplinked page dynamically!
config
[
"
deeplink
"
]
=
true
;
}
else
{
// all we can do
config
[
"
id
"
]
=
util
.
getActivePageModule
();
}
if
(
path
.
hash
===
""
)
{
config
.
id
=
util
.
getActivePageModule
();
}
else
{
if
(
back
&&
location
.
hash
)
{
config
[
"
id
"
]
=
location
.
hash
.
replace
(
"
#
"
,
""
);
config
[
"
deeplink
"
]
=
true
;
}
else
{
fragments
=
util
.
removeTrailingSlash
(
url
).
split
(
"
/
"
);
for
(
i
=
0
;
i
<
fragments
.
length
;
i
+=
1
)
{
fragment
=
fragments
[
i
];
identifier
=
fragment
.
split
(
"
;
"
);
if
(
identifier
[
1
]
!==
undefined
)
{
config
[
identifier
[
0
]]
=
identifier
[
1
].
split
(
"
=
"
)[
1
];
}
}
}
config
.
fragments
=
path
.
hash
.
replace
(
"
#
"
,
""
).
split
(
"
/
"
);
config
.
id
=
config
.
fragments
[
0
];
config
.
deeplink
=
true
;
config
.
level
=
config
.
fragments
.
length
;
}
return
config
;
};
...
...
@@ -2478,24 +2456,59 @@
/**
* Parse a page for gadgets and run page setup
* @method parsePage
* @param {object} pointer Parsed link containing info on page to generate
* @param {boolean} create Create a page or not
* @param {boolean} hashchange Indicating backwards transition
* @param {object} e Event (pagebeforechange)
* @param {object} data Data passed along with this (JQM) event
*/
// NOTE: parseLink is called here in case pointers is undefined!
init
.
parsePage
=
function
(
url
,
create
,
hashchange
)
{
var
config
=
util
.
parseLink
(
url
,
hashchange
);
init
.
parsePage
=
function
(
e
,
data
)
{
var
create
,
config
,
raw_url
,
handle
;
if
(
config
.
deeplink
)
{
create
=
true
;
if
(
data
)
{
if
(
data
.
options
.
link
)
{
raw_url
=
data
.
options
.
link
[
0
].
href
;
}
else
{
raw_url
=
data
.
toPage
;
}
}
else
{
raw_url
=
location
.
href
;
}
init
.
fetchPageLayouts
(
"
settings
"
,
config
.
id
)
.
then
(
function
(
layouts
)
{
init
.
setPageElements
(
config
,
layouts
,
create
)
})
.
then
(
init
.
setPageBindings
)
.
fail
(
util
.
errorHandler
);
if
(
typeof
raw_url
===
"
string
"
)
{
config
=
util
.
parseLink
(
raw_url
);
if
(
e
)
{
if
(
document
.
getElementById
(
raw_url
.
replace
(
"
#
"
,
""
))
||
raw_url
===
$
.
mobile
.
getDocumentUrl
()
||
data
.
options
.
role
===
"
popup
"
)
{
return
;
}
if
(
document
.
getElementById
(
config
.
id
))
{
e
.
preventDefault
();
return
;
}
else
{
// PASS!
handle
=
true
;
e
.
preventDefault
();
}
}
}
else
{
// once transition done. Update gadgets if going back to page in DOM
if
(
data
.
options
.
fromHashChange
)
{
init
.
setPageTitle
(
data
.
toPage
[
0
],
{});
}
return
;
}
if
(
e
===
undefined
||
handle
)
{
if
(
config
.
deeplink
)
{
create
=
true
;
}
init
.
fetchPageLayouts
(
"
settings
"
,
config
.
id
)
.
then
(
function
(
layouts
)
{
init
.
setPageElements
(
config
,
layouts
,
create
)
})
.
then
(
init
.
setPageBindings
)
.
fail
(
util
.
errorHandler
);
}
};
/**
...
...
@@ -2536,7 +2549,7 @@
element
,
promises
=
[],
fragment
=
document
.
createDocumentFragment
(),
layout
=
layouts
[
config
.
l
ayout
||
"
default
"
];
layout
=
layouts
[
config
.
l
evel
||
0
];
if
(
create
===
true
)
{
page
=
factory
.
generatePage
(
config
,
layout
);
...
...
@@ -2549,7 +2562,7 @@
}
}
gadgets
=
layout
.
section
s
||
page
.
querySelectorAll
(
"
[data-gadget-id]
"
);
gadgets
=
layout
.
section
_list
||
page
.
querySelectorAll
(
"
[data-gadget-id]
"
);
// generate content
// NOTE: this may include local header/footer/panel/popups
...
...
@@ -2909,37 +2922,9 @@
// generate dynamic pages
.
on
(
"
pagebeforechange
"
,
function
(
e
,
data
)
{
var
clean_url
,
raw_url
=
data
.
toPage
,
hashchange
=
data
.
options
.
fromHashChange
;
if
(
typeof
raw_url
===
"
string
"
)
{
clean_url
=
util
.
parseLink
(
raw_url
,
hashchange
).
id
;
// stay idle if...
// 2nd pagebeforechange for this page
if
(
document
.
getElementById
(
raw_url
.
replace
(
"
#
"
,
""
))
||
// going back to first page
raw_url
===
$
.
mobile
.
getDocumentUrl
()
||
// opening a popup
data
.
options
.
role
===
"
popup
"
)
{
return
;
}
if
(
document
.
getElementById
(
clean_url
))
{
// page in DOM (with clean_url) Stop, because same page transition
e
.
preventDefault
();
}
else
{
// generate a new page and transition to it
init
.
parsePage
(
raw_url
,
true
,
hashchange
);
e
.
preventDefault
();
}
}
else
{
//TODO: this should update the whole layout not only the title
if
(
data
.
options
.
fromHashChange
)
{
init
.
setPageTitle
(
data
.
toPage
[
0
],
{});
}
}
init
.
parsePage
(
e
,
data
);
})
// clean dynamic pages on hide
// NOTE: alternative would be to hack JQM and call bindRemove on
// dynamically generated content/pages, too. Then JQM will remove
...
...
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