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
cf2c1649
Commit
cf2c1649
authored
Oct 25, 2013
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed navigation (1 level for now), removed unnecessary code
parent
f52bf52a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
87 deletions
+79
-87
js/erp5_loader.js
js/erp5_loader.js
+79
-87
No files found.
js/erp5_loader.js
View file @
cf2c1649
...
...
@@ -9,11 +9,15 @@
// utility methods
var
util
=
{};
/* ============================================?========================= */
/* MAPPING ERP5 */
/* ====================================================================== */
// ERP5 custom methods
var
erp5
=
{};
// JQM content generator
var
factory
=
{};
/* ====================================================================== */
/* MAPPING ERP5 */
/* ====================================================================== */
erp5
.
map_buttons
=
{
"
jump
"
:
{
"
classes
"
:
"
action ui-disabled
"
,
...
...
@@ -39,35 +43,6 @@
}
};
erp5
.
map_info
=
{
};
erp5
.
map_popup_content
=
{
};
erp5
.
map_portal_types
=
{
"
app
"
:
"
app
"
,
"
dashboard
"
:
"
dashboard
"
,
"
invoices
"
:
"
invoices
"
,
"
invoices_01
"
:
"
invoices_01
"
,
"
Sale Invoice Transaction
"
:
"
invoices_fields
"
};
erp5
.
map_references
=
{
/**
* Generate list of browsable items
* @method browse
*/
browse
:
function
()
{
var
fragment
=
document
.
createDocumentFragment
();
return
fragment
;
}
};
// TODO: remove duplicate code for pagination
erp5
.
map_actions
=
{
...
...
@@ -219,7 +194,7 @@
* @returns {objects} fragment
*/
// TODO: parameters are not good, modify into something more generic!
constructL
istbox
:
function
(
config
,
answer
,
fields
,
update
)
{
l
istbox
:
function
(
config
,
answer
,
fields
,
update
)
{
var
fragment
,
bar
,
wrap
,
arr
,
local_popup
,
global_popup
,
set
,
id
;
if
(
config
)
{
...
...
@@ -316,16 +291,13 @@
/* ====================================================================== */
/* FACTORY */
/* ====================================================================== */
var
factory
=
{};
/* ********************************************************************** */
/* "mapping to erp5" */
/* ********************************************************************** */
factory
.
map_buttons
=
erp5
.
map_buttons
;
factory
.
map_info
=
erp5
.
map_info
;
factory
.
map_actions
=
erp5
.
map_actions
;
factory
.
map_gadgets
=
erp5
.
map_gadgets
;
factory
.
map_references
=
erp5
.
map_references
;
/* ********************************************************************** */
/* JQM "Bar" */
...
...
@@ -530,7 +502,7 @@
if
(
field_config
)
{
title
=
temp
[
property
]
||
field_config
.
widget
.
title
;
}
else
{
title
=
util
.
capFirstLetter
(
property
)
;
title
=
property
;
}
if
(
settings
.
configuration
.
table
.
sorting_columns
&&
field
.
sort
)
{
text
=
{}
...
...
@@ -1825,16 +1797,13 @@
options
.
query
);
if
(
reference
===
"
object
"
)
{
info
=
"
Search =
"
+
util
.
capFirstLetter
(
reference
.
key
).
replace
(
"
_
"
,
"
"
)
+
"
:
"
+
util
.
capFirstLetter
(
reference
.
value
).
replace
(
"
%
"
,
""
);
info
=
"
Search =
"
+
reference
.
key
.
replace
(
"
_
"
,
"
"
)
+
"
:
"
+
reference
.
value
.
replace
(
"
%
"
,
""
);
}
else
{
info
=
"
Search =
"
;
for
(
k
=
0
;
k
<
reference
.
length
;
k
+=
1
)
{
info
+=
util
.
capFirstLetter
(
reference
[
k
].
key
).
replace
(
"
_
"
,
"
"
)
+
"
:
"
+
util
.
capFirstLetter
(
reference
[
k
].
value
).
replace
(
"
%
"
,
""
);
info
+=
reference
[
k
].
key
.
replace
(
"
_
"
,
"
"
)
+
"
:
"
+
reference
[
k
].
value
.
replace
(
"
%
"
,
""
);
if
(
k
>=
1
&&
k
<
reference
.
length
)
{
info
+=
"
,
"
;
}
...
...
@@ -2063,7 +2032,7 @@
// give user half second to pick his state
init
.
timer
=
window
.
setTimeout
(
function
()
{
// update gadget
// update gadget
s
init
.
setPageElements
(
{},
{
"
default
"
:{
"
sections
"
:[{
"
gadget
"
:
config
.
id
}]}},
false
);
...
...
@@ -2367,16 +2336,6 @@
return
(
crc
^
finalXORValue
)
>>>
0
;
};
/**
* Uppercase first letter of a string
* @method capFirstLetter
* @param {string} string To uppercase first letter
* @return {string} Capitalized string
*/
util
.
capFirstLetter
=
function
(
string
)
{
return
string
.
charAt
(
0
).
toUpperCase
()
+
string
.
slice
(
1
);
};
/**
* Convert 1,2,3 into a,b,c
* @method: toLetters
...
...
@@ -2505,14 +2464,13 @@
/**
* parse a link into query-able parameters
* @method parseLink
* @param {string} url
* @param {
object} location object
* @param {string} url
Url to go to
* @param {
boolean} hashed Backwards transition
* @return {object} pointer object
*/
// TODO: map this to URL router! And... this is crap!
util
.
parseLink
=
function
(
url
)
{
var
fragments
,
config
;
// TODO: this whole function is crap... works, but refactor!!!!
util
.
parseLink
=
function
(
url
,
back
)
{
var
fragments
,
config
=
{
"
url
"
:
url
||
location
.
href
};
...
...
@@ -2527,6 +2485,10 @@
// all we can do
config
[
"
id
"
]
=
util
.
getActivePageModule
();
}
}
else
{
if
(
back
&&
location
.
hash
)
{
config
[
"
id
"
]
=
location
.
hash
.
replace
(
"
#
"
,
""
);
config
[
"
deeplink
"
]
=
true
;
}
else
{
fragments
=
util
.
removeTrailingSlash
(
url
).
split
(
"
/
"
);
...
...
@@ -2539,6 +2501,8 @@
}
}
}
}
return
config
;
};
...
...
@@ -2565,10 +2529,11 @@
* @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
*/
// NOTE: parseLink is called here in case pointers is undefined!
init
.
parsePage
=
function
(
url
,
create
)
{
var
config
=
util
.
parseLink
(
url
);
init
.
parsePage
=
function
(
url
,
create
,
hashchange
)
{
var
config
=
util
.
parseLink
(
url
,
hashchange
);
if
(
config
.
deeplink
)
{
create
=
true
;
...
...
@@ -2699,7 +2664,7 @@
}
else
{
gadget_type
=
gadget
.
type
||
gadget
.
getAttribute
(
"
data-gadget-type
"
);
constructor
=
"
construct
"
+
util
.
capFirstLetter
(
gadget_type
)
;
constructor
=
gadget_type
;
query
=
{};
}
return
util
.
fetchData
(
"
items
"
,
query
);
...
...
@@ -2773,7 +2738,7 @@
// JQM treatment
$
(
document
).
enhanceWithin
();
$
.
mobile
.
changePage
(
"
#
"
+
config
.
id
,
"
slide
"
);
$
.
mobile
.
changePage
(
"
#
"
+
config
.
id
);
}
else
{
// populate existing page and enhance
if
(
gadgets
.
length
>
0
&&
create
===
undefined
)
{
...
...
@@ -2792,17 +2757,17 @@
* @param {object} layout configuration
*/
init
.
setPageTitle
=
function
(
page
,
layout
)
{
var
header
,
title
;
var
header
,
title
,
text
=
layout
.
title
||
page
.
id
;
if
(
layout
.
title
)
{
if
(
text
)
{
// WARNING: IE8- children() retrieves comments, too
header
=
document
.
getElementById
(
"
global_header
"
)
||
page
.
children
()[
0
];
if
(
util
.
testForClass
(
header
.
className
,
"
ui-header
"
))
{
title
=
header
.
getElementsByTagName
(
"
h1
"
)[
0
];
title
.
innerHTML
=
layout
.
title
;
title
.
setAttribute
(
"
data-i18n
"
,
layout
.
title_i18n
);
title
.
innerHTML
=
text
;
title
.
setAttribute
(
"
data-i18n
"
,
(
layout
.
title_i18n
||
""
)
);
}
}
};
...
...
@@ -2996,21 +2961,48 @@
// generate dynamic pages
.
on
(
"
pagebeforechange
"
,
function
(
e
,
data
)
{
if
(
typeof
data
.
toPage
===
"
string
"
)
{
// stay calm if...
if
(
document
.
getElementById
(
data
.
toPage
.
replace
(
"
#
"
,
""
))
||
data
.
toPage
===
$
.
mobile
.
getDocumentUrl
()
||
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
;
}
init
.
parsePage
(
data
.
toPage
,
true
);
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
],
{});
}
}
})
// 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
.
on
(
"
pagehide
"
,
"
div.ui-page
"
,
function
(
e
)
{
if
(
this
.
getAttribute
(
"
data-external-page
"
))
{
$
(
this
).
page
(
"
destroy
"
).
remove
()
};
})
// clear cache when removing a page
// TODO: remove once cache is set on gadgets!
.
on
(
"
pageremove
"
,
"
div.ui-page
"
,
function
(
e
)
{
console
.
log
(
"
pageRemove
"
);
delete
ram_cache
[
e
.
target
.
id
];
})
...
...
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