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
efd032cf
Commit
efd032cf
authored
Dec 30, 2013
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jslint
parent
0c34c59d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
929 additions
and
1028 deletions
+929
-1028
js/erp5_loader.js
js/erp5_loader.js
+929
-1028
No files found.
js/erp5_loader.js
View file @
efd032cf
/*jslint indent: 2, maxlen: 80, nomen: true, sloppy: true, todo: true */
/*jslint indent: 2, maxlen: 80, nomen: true, sloppy: true, todo: true */
/*global console, window, jIO, complex_queries, FormData, RSVP, document,
/*global console, window, jIO, complex_queries, FormData, RSVP, document,
jQuery */
jQuery
, i18n, hello, Recaptcha, XMLHttpRequest, Modernizr
*/
(
function
(
window
,
document
,
$
)
{
(
function
(
window
,
document
,
$
)
{
"
use strict
"
;
"
use strict
"
;
...
@@ -36,10 +36,9 @@
...
@@ -36,10 +36,9 @@
"
translateLookup
"
:
function
(
path
)
{
"
translateLookup
"
:
function
(
path
)
{
if
(
i18n
)
{
if
(
i18n
)
{
return
i18n
.
t
(
path
);
return
i18n
.
t
(
path
);
}
else
{
util
.
error
({
"
error
"
:
"
Translate NodeList - i18n not defined
"
});
return
""
}
}
util
.
error
({
"
error
"
:
"
Translate NodeList - i18n not defined
"
});
return
""
;
},
},
/**
/**
...
@@ -82,20 +81,20 @@
...
@@ -82,20 +81,20 @@
if
(
lookup
.
indexOf
(
"
;
"
)
>
-
1
)
{
if
(
lookup
.
indexOf
(
"
;
"
)
>
-
1
)
{
targets
=
lookup
.
split
(
"
;
"
);
targets
=
lookup
.
split
(
"
;
"
);
}
else
{
}
else
{
targets
=
[
lookup
]
targets
=
[
lookup
]
;
}
}
for
(
l
=
0
;
l
<
targets
.
length
;
l
+=
1
)
{
for
(
l
=
0
;
l
<
targets
.
length
;
l
+=
1
)
{
target
=
targets
[
l
].
split
(
"
]
"
);
target
=
targets
[
l
].
split
(
"
]
"
);
// all hail performance
// all hail performance
switch
(
target
[
0
])
{
switch
(
target
[
0
])
{
case
"
[placeholder
"
:
case
"
[placeholder
"
:
case
"
[alt
"
:
case
"
[alt
"
:
case
"
[title
"
:
case
"
[title
"
:
element
.
setAttribute
(
target
[
0
].
substr
(
1
),
i18n
.
t
(
target
[
1
]));
element
.
setAttribute
(
target
[
0
].
substr
(
1
),
i18n
.
t
(
target
[
1
]));
break
;
break
;
case
"
[value
"
:
case
"
[value
"
:
if
(
route_text
)
{
if
(
route_text
)
{
element
.
previousSibling
.
textContent
=
i18n
.
t
(
target
[
1
]);
element
.
previousSibling
.
textContent
=
i18n
.
t
(
target
[
1
]);
}
}
element
.
value
=
i18n
.
t
(
target
[
1
]);
element
.
value
=
i18n
.
t
(
target
[
1
]);
...
@@ -116,7 +115,7 @@
...
@@ -116,7 +115,7 @@
}
}
}
}
}
else
{
}
else
{
util
.
error
({
"
error
"
:
"
Translate NodeList - i18n not defined
"
});
util
.
error
({
"
error
"
:
"
Translate NodeList - i18n not defined
"
});
}
}
},
},
...
@@ -179,24 +178,23 @@
...
@@ -179,24 +178,23 @@
* @param {object} obj Action Object
* @param {object} obj Action Object
**/
**/
"
logout_user
"
:
function
(
obj
)
{
"
logout_user
"
:
function
(
obj
)
{
var
provider
;
hello
(
obj
.
id
).
logout
(
function
(
x
)
{
hello
(
obj
.
id
).
logout
(
function
()
{
return
;
return
;
});
});
// update flux
// update flux
if
(
flux
&&
flux
.
state
)
{
if
(
flux
&&
flux
.
state
)
{
if
(
flux
.
state
[
obj
.
id
.
slice
(
0
,
2
)])
{
if
(
flux
.
state
[
obj
.
id
.
slice
(
0
,
2
)])
{
delete
flux
.
state
[
obj
.
id
.
slice
(
0
,
2
)]
delete
flux
.
state
[
obj
.
id
.
slice
(
0
,
2
)];
}
else
{
}
else
{
delete
flux
.
state
[
"
self
"
]
;
delete
flux
.
state
.
self
;
}
}
}
}
// TODO: Try to log out correctly
// TODO: Try to log out correctly
// http://
stackoverflow.com/questions/17050575/logout-link-with-return-url-oauth/17127388#17127388
// http://
bit.ly/1aih0UU
// http://
stackoverflow.com/questions/16946798/logout-from-external-login-service-gmail-facebook-using-oauth
// http://
bit.ly/1kUUuJz
// update login button, so it's back to login
// update login button, so it's back to login
obj
.
element
.
parentNode
.
replaceChild
(
obj
.
element
.
parentNode
.
replaceChild
(
...
@@ -212,11 +210,9 @@
...
@@ -212,11 +210,9 @@
**/
**/
// TODO: failed login?
// TODO: failed login?
"
login_user
"
:
function
(
obj
)
{
"
login_user
"
:
function
(
obj
)
{
var
signature
,
match_string
,
reply
,
element
,
active
,
hashed_list
,
var
signature
,
match_string
,
gadget_list
,
i
,
gadget
,
id
;
gadget_list
,
i
,
gadget
,
id
;
// create signature and ticket
// create signature and ticket
element
=
obj
.
element
;
signature
=
util
.
generateRandomIdentifier
(
36
);
signature
=
util
.
generateRandomIdentifier
(
36
);
flux
[
signature
]
=
util
.
generateUuid
();
flux
[
signature
]
=
util
.
generateUuid
();
...
@@ -227,8 +223,8 @@
...
@@ -227,8 +223,8 @@
// close 3rd party popup
// close 3rd party popup
window
.
parent
.
close
();
window
.
parent
.
close
();
})
})
.
then
(
function
(
response
)
{
.
then
(
function
(
response
)
{
reply
=
util
.
parseIfNeeded
(
response
);
//
reply = util.parseIfNeeded(response);
if
(
response
.
authResponse
!==
undefined
)
{
if
(
response
.
authResponse
!==
undefined
)
{
match_string
=
response
.
authResponse
.
state
;
match_string
=
response
.
authResponse
.
state
;
...
@@ -252,12 +248,12 @@
...
@@ -252,12 +248,12 @@
// TODO: this is crap...
// TODO: this is crap...
$
(
"
.ui-popup
"
).
popup
(
"
close
"
);
$
(
"
.ui-popup
"
).
popup
(
"
close
"
);
})
})
.
then
(
function
()
{
.
then
(
function
()
{
util
.
loader
(
""
,
"
global_dict.status_dict.saving
"
);
util
.
loader
(
""
,
"
global_dict.status_dict.saving
"
);
// register the user
// register the user
return
app
.
register
(
obj
.
id
)
return
app
.
register
(
obj
.
id
)
.
then
(
function
()
{
.
then
(
function
()
{
// TODO: should not get elements like this!
// TODO: should not get elements like this!
gadget_list
=
document
.
getElementById
(
util
.
getActivePage
())
gadget_list
=
document
.
getElementById
(
util
.
getActivePage
())
...
@@ -274,7 +270,7 @@
...
@@ -274,7 +270,7 @@
// update gadget
// update gadget
app
.
setContent
(
app
.
setContent
(
{
{
"
generate
"
:
"
gadget
"
,
"
generate
"
:
"
gadget
"
,
"
id
"
:
id
,
"
id
"
:
id
,
"
href
"
:
id
,
"
href
"
:
id
,
"
type
"
:
gadget
.
state
.
method
"
type
"
:
gadget
.
state
.
method
...
@@ -286,7 +282,7 @@
...
@@ -286,7 +282,7 @@
undefined
,
undefined
,
true
true
)
)
.
then
(
function
(
answer
)
{
.
then
(
function
(
answer
)
{
gadget
.
parentNode
.
replaceChild
(
answer
,
gadget
);
gadget
.
parentNode
.
replaceChild
(
answer
,
gadget
);
})
})
.
then
(
app
.
setPageBindings
)
.
then
(
app
.
setPageBindings
)
...
@@ -344,6 +340,17 @@
...
@@ -344,6 +340,17 @@
factory
.
util
.
setPopupPointer
(
obj
,
"
export
"
);
factory
.
util
.
setPopupPointer
(
obj
,
"
export
"
);
},
},
/**
* Download a document as pdf
* @method download
* @param {string} type
* @param {string} portal type
* @param {string} identifier
**/
"
download
"
:
function
()
{
util
.
error
({
"
error
"
:
"
Download: Not implemented.
"
});
},
/**
/**
* Generic pagination method changing number of records displayed
* Generic pagination method changing number of records displayed
* @method limit
* @method limit
...
@@ -508,17 +515,17 @@
...
@@ -508,17 +515,17 @@
// TODO: allow multiple header rows!
// TODO: allow multiple header rows!
// TODO: make i18n optional if it's not passed!
// TODO: make i18n optional if it's not passed!
"
mapTableRows
"
:
function
(
items
,
spec
,
field_dict
,
url_pointer
,
update
)
{
"
mapTableRows
"
:
function
(
items
,
spec
,
field_dict
,
url_pointer
,
update
)
{
var
arr
,
obj
,
cell
,
row
,
i
,
j
,
k
,
l
,
m
,
layout
,
config
,
makeSection
,
var
arr
,
obj
,
cell
,
row
,
i
,
j
,
k
,
m
,
layout
,
config
,
makeSection
,
translation
,
core
,
item
,
linkable
,
action
,
level
,
identifier
;
translation
,
core
,
item
,
linkable
,
action
,
level
,
identifier
;
arr
=
[];
arr
=
[];
layout
=
spec
.
property_dict
.
layout
;
layout
=
spec
.
property_dict
.
layout
;
level
=
url_pointer
.
layout
,
level
=
url_pointer
.
layout
;
core
=
url_pointer
.
fragment_list
.
slice
(
0
,
level
+
1
).
join
(
"
::
"
)
,
core
=
url_pointer
.
fragment_list
.
slice
(
0
,
level
+
1
).
join
(
"
::
"
)
;
linkable
=
spec
.
property_dict
.
feature_dict
.
linkable
;
linkable
=
spec
.
property_dict
.
feature_dict
.
linkable
;
action
=
spec
.
property_dict
.
feature_dict
.
action_menu
;
action
=
spec
.
property_dict
.
feature_dict
.
action_menu
;
makeSection
=
function
(
type
)
{
makeSection
=
function
(
type
)
{
return
{
"
generate
"
:
type
,
"
properties
"
:
{
"
rows
"
:
[]}}
return
{
"
generate
"
:
type
,
"
properties
"
:
{
"
rows
"
:
[]}}
;
};
};
// table header mapping
// table header mapping
...
@@ -527,7 +534,7 @@
...
@@ -527,7 +534,7 @@
// loop header rows
// loop header rows
for
(
i
=
0
;
i
<
layout
.
header
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
layout
.
header
.
length
;
i
+=
1
)
{
row
=
[]
row
=
[]
;
// loop columns per row
// loop columns per row
for
(
j
=
0
;
j
<
layout
.
header
[
i
].
length
;
j
+=
1
)
{
for
(
j
=
0
;
j
<
layout
.
header
[
i
].
length
;
j
+=
1
)
{
...
@@ -560,7 +567,7 @@
...
@@ -560,7 +567,7 @@
// fallback to _id if no link identifier is specified
// fallback to _id if no link identifier is specified
if
(
identifier
===
undefined
)
{
if
(
identifier
===
undefined
)
{
identifier
=
item
[
"
_id
"
]
;
identifier
=
item
.
_id
;
}
}
if
(
item
===
undefined
)
{
if
(
item
===
undefined
)
{
...
@@ -579,7 +586,7 @@
...
@@ -579,7 +586,7 @@
}
}
cell
.
identifier
=
identifier
;
cell
.
identifier
=
identifier
;
// test for translation
in dynamic data or custom field text_i18n
// test for translation
translation
=
item
[
cell
.
column
+
"
_i18n
"
]
||
cell
.
text_i18n
;
translation
=
item
[
cell
.
column
+
"
_i18n
"
]
||
cell
.
text_i18n
;
if
(
translation
)
{
if
(
translation
)
{
cell
.
text_i18n
=
translation
;
cell
.
text_i18n
=
translation
;
...
@@ -631,11 +638,11 @@
...
@@ -631,11 +638,11 @@
// NOTE: can't use hash, because the hash updates after storage operation
// NOTE: can't use hash, because the hash updates after storage operation
// and thus may be wrong depending on storage being accessed
// and thus may be wrong depending on storage being accessed
"
mapListItems
"
:
function
(
items
,
spec
,
url_pointer
)
{
"
mapListItems
"
:
function
(
items
,
spec
,
url_pointer
)
{
var
property
,
obj
,
i
,
j
,
item
,
clean
,
value
,
store
,
split
,
host
,
var
property
,
obj
,
i
,
item
,
clean
,
value
,
store
,
split
,
host
,
i18n
,
app
,
level
,
core
,
arr
;
i18n
,
app
lication
,
level
,
core
,
arr
;
level
=
url_pointer
.
layout
,
level
=
url_pointer
.
layout
;
core
=
url_pointer
.
fragment_list
.
slice
(
0
,
level
+
1
).
join
(
"
::
"
)
,
core
=
url_pointer
.
fragment_list
.
slice
(
0
,
level
+
1
).
join
(
"
::
"
)
;
arr
=
[];
arr
=
[];
for
(
i
=
0
;
i
<
items
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
items
.
length
;
i
+=
1
)
{
...
@@ -659,7 +666,7 @@
...
@@ -659,7 +666,7 @@
// checkbox
// checkbox
if
(
spec
.
property_dict
.
check
)
{
if
(
spec
.
property_dict
.
check
)
{
obj
.
right
=
{
"
check
"
:
true
,
"
action
"
:
"
check
"
};
obj
.
right
=
{
"
check
"
:
true
,
"
action
"
:
"
check
"
};
}
}
// TODO: we can't handle normal URLs if they are passed!
// TODO: we can't handle normal URLs if they are passed!
...
@@ -677,7 +684,7 @@
...
@@ -677,7 +684,7 @@
switch
(
clean
)
{
switch
(
clean
)
{
case
"
url
"
:
case
"
url
"
:
obj
[
"
href
"
]
=
item
[
property
];
obj
.
href
=
item
[
property
];
split
=
item
[
property
].
split
(
"
//
"
);
split
=
item
[
property
].
split
(
"
//
"
);
// TODO: crap... an empty link will generate a ribbon...
// TODO: crap... an empty link will generate a ribbon...
...
@@ -688,10 +695,10 @@
...
@@ -688,10 +695,10 @@
// TODO: refactor. Determining whether a link is external
// TODO: refactor. Determining whether a link is external
if
(
split
.
length
>
1
)
{
if
(
split
.
length
>
1
)
{
host
=
split
[
1
].
split
(
"
/
"
)[
0
];
host
=
split
[
1
].
split
(
"
/
"
)[
0
];
app
=
split
[
1
].
split
(
"
/
"
)[
1
];
app
lication
=
split
[
1
].
split
(
"
/
"
)[
1
];
}
}
if
((
split
.
length
>
1
&&
window
.
location
.
host
!==
host
)
||
if
((
split
.
length
>
1
&&
window
.
location
.
host
!==
host
)
||
app
===
"
app
"
)
{
app
lication
===
"
app
"
)
{
obj
.
external
=
true
;
obj
.
external
=
true
;
}
}
break
;
break
;
...
@@ -753,7 +760,7 @@
...
@@ -753,7 +760,7 @@
// the mapping from (ERP5) custom API to internal API here
// the mapping from (ERP5) custom API to internal API here
"
mapFormField
"
:
function
(
spec
,
overrides
,
passed_value
)
{
"
mapFormField
"
:
function
(
spec
,
overrides
,
passed_value
)
{
var
validation_list
,
class_list
,
element
,
type
,
prevail
,
clear
,
config
,
var
validation_list
,
class_list
,
element
,
type
,
prevail
,
clear
,
config
,
error_log
,
field_value
;
field_value
;
// build config object
// build config object
config
=
{};
config
=
{};
...
@@ -787,12 +794,13 @@
...
@@ -787,12 +794,13 @@
// easy way out if not enabled
// easy way out if not enabled
if
(
prevail
.
properties
.
enabled
===
false
||
if
(
prevail
.
properties
.
enabled
===
false
||
spec
.
properties
.
enabled
===
false
)
{
spec
.
properties
.
enabled
===
false
)
{
return
config
=
{
config
=
{
"
type
"
:
"
span
"
,
"
type
"
:
"
span
"
,
"
direct
"
:
{
"
className
"
:
"
static
"
},
"
direct
"
:
{
"
className
"
:
"
static
"
},
"
attributes
"
:
{},
"
attributes
"
:
{},
"
logic
"
:
{
"
text
"
:
field_value
}
"
logic
"
:
{
"
text
"
:
field_value
}
}
};
return
config
;
}
}
validation_list
=
""
;
validation_list
=
""
;
...
@@ -811,7 +819,6 @@
...
@@ -811,7 +819,6 @@
if
(
prevail
.
properties
.
required
===
true
||
if
(
prevail
.
properties
.
required
===
true
||
spec
.
properties
.
required
===
true
)
{
spec
.
properties
.
required
===
true
)
{
class_list
+=
"
required
"
;
class_list
+=
"
required
"
;
error_log
=
true
;
}
}
// maximum_length
// maximum_length
...
@@ -908,10 +915,10 @@
...
@@ -908,10 +915,10 @@
"
rows
"
:
prevail
.
widget
.
width
||
spec
.
widget
.
width
||
undefined
,
"
rows
"
:
prevail
.
widget
.
width
||
spec
.
widget
.
width
||
undefined
,
"
cols
"
:
prevail
.
widget
.
height
||
spec
.
widget
.
height
||
undefined
,
"
cols
"
:
prevail
.
widget
.
height
||
spec
.
widget
.
height
||
undefined
,
"
disabled
"
:
(
prevail
.
properties
.
enabled
||
spec
.
properties
.
enabled
)
?
"
disabled
"
:
(
prevail
.
properties
.
enabled
||
spec
.
properties
.
enabled
)
?
(
undefined
)
:
true
,
undefined
:
true
,
"
value
"
:
field_value
,
"
value
"
:
field_value
,
"
readonly
"
:
(
prevail
.
properties
.
editable
===
false
||
"
readonly
"
:
(
prevail
.
properties
.
editable
===
false
||
spec
.
properties
.
editable
===
false
)
?
(
true
)
:
undefined
,
spec
.
properties
.
editable
===
false
)
?
true
:
undefined
,
"
options
"
:
(
prevail
.
widget
.
items
||
spec
.
widget
.
items
)
?
"
options
"
:
(
prevail
.
widget
.
items
||
spec
.
widget
.
items
)
?
([
([
prevail
.
widget
.
items
||
spec
.
widget
.
items
||
null
,
prevail
.
widget
.
items
||
spec
.
widget
.
items
||
null
,
...
@@ -949,10 +956,10 @@
...
@@ -949,10 +956,10 @@
* @param {object} content_dict JSON configuration for global setup
* @param {object} content_dict JSON configuration for global setup
**/
**/
"
setGlobalConfiguration
"
:
function
(
content_dict
)
{
"
setGlobalConfiguration
"
:
function
(
content_dict
)
{
var
i
,
j
,
translator
,
single_path
,
supported
,
target
,
content
,
language
,
var
i
,
j
,
translator
,
single_path
,
supported
,
target
,
language
,
container
,
foreign
,
promises
,
path_flag
,
status_flag
,
set_state
,
container
,
foreign
,
promises
,
path_flag
,
status_flag
,
set_state
,
multi_language_flag
,
force_browser_language
,
logger
,
depend
,
element
,
multi_language_flag
,
force_browser_language
,
logger
,
element
,
need_update
,
set_login
,
set_i18n
,
open_auth
,
skip_restore
;
set_login
,
skip_restore
;
promises
=
[];
promises
=
[];
path_flag
=
content_dict
.
property_dict
.
path_dict
;
path_flag
=
content_dict
.
property_dict
.
path_dict
;
...
@@ -966,7 +973,6 @@
...
@@ -966,7 +973,6 @@
if
(
logger
!==
undefined
)
{
if
(
logger
!==
undefined
)
{
app
.
default_dict
.
state_dict
.
login
=
true
;
app
.
default_dict
.
state_dict
.
login
=
true
;
foreign
=
logger
.
third_party
;
foreign
=
logger
.
third_party
;
depend
=
"
login_state
"
;
if
(
foreign
)
{
if
(
foreign
)
{
switch
(
foreign
.
provider
)
{
switch
(
foreign
.
provider
)
{
case
"
hellojs
"
:
case
"
hellojs
"
:
...
@@ -997,11 +1003,11 @@
...
@@ -997,11 +1003,11 @@
// setup loader
// setup loader
if
(
status_flag
)
{
if
(
status_flag
)
{
switch
(
status_flag
.
type
)
{
switch
(
status_flag
.
type
)
{
case
"
loader
"
:
{
case
"
loader
"
:
app
.
default_dict
.
loader
=
true
;
app
.
default_dict
.
loader
=
true
;
app
.
default_dict
.
loader_theme
=
status_flag
.
theme
;
app
.
default_dict
.
loader_theme
=
status_flag
.
theme
;
break
;
}
}
};
}
}
// create path dict
// create path dict
...
@@ -1031,7 +1037,7 @@
...
@@ -1031,7 +1037,7 @@
}
}
promises
[
content_dict
.
children
.
length
+
1
]
=
promises
[
content_dict
.
children
.
length
+
1
]
=
i18n
.
init
(
translator
,
function
()
{
i18n
.
init
(
translator
,
function
()
{
return
;
return
;
});
});
}
else
{
}
else
{
...
@@ -1040,12 +1046,12 @@
...
@@ -1040,12 +1046,12 @@
);
);
}
}
break
;
break
;
}
;
}
}
}
// start setup
// start setup
app
.
checkLoginStatus
(
set_login
)
app
.
checkLoginStatus
(
set_login
)
.
then
(
function
(
response
)
{
.
then
(
function
(
response
)
{
if
(
response
.
error
)
{
if
(
response
.
error
)
{
skip_restore
=
true
;
skip_restore
=
true
;
}
}
...
@@ -1061,7 +1067,8 @@
...
@@ -1061,7 +1067,8 @@
}
}
return
set_state
;
return
set_state
;
})
})
.
then
(
function
(
state
)
{
.
then
(
function
(
state
)
{
var
open_auth
;
// try to register user
// try to register user
if
(
skip_restore
===
undefined
)
{
if
(
skip_restore
===
undefined
)
{
if
(
foreign
&&
foreign
.
initializer_dict
)
{
if
(
foreign
&&
foreign
.
initializer_dict
)
{
...
@@ -1077,7 +1084,7 @@
...
@@ -1077,7 +1084,7 @@
}
}
return
state
;
return
state
;
})
})
.
then
(
function
(
state
)
{
.
then
(
function
(
)
{
// global elements
// global elements
if
(
content_dict
.
children
)
{
if
(
content_dict
.
children
)
{
for
(
i
=
0
;
i
<
content_dict
.
children
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
content_dict
.
children
.
length
;
i
+=
1
)
{
...
@@ -1146,8 +1153,8 @@
...
@@ -1146,8 +1153,8 @@
return
RSVP
.
all
(
promises
);
return
RSVP
.
all
(
promises
);
default
:
default
:
util
.
error
({
"
error
"
:
"
setStorage: Missing storage type
"
});
util
.
error
({
"
error
"
:
"
setStorage: Missing storage type
"
});
return
RSVP
.
all
(
promises
)
return
RSVP
.
all
(
promises
);
}
;
}
},
},
/**
/**
...
@@ -1174,12 +1181,12 @@
...
@@ -1174,12 +1181,12 @@
* @param {object} url_dict JSON configuration generated from URL
* @param {object} url_dict JSON configuration generated from URL
* @param {boolean} create Override to force new page creation
* @param {boolean} create Override to force new page creation
**/
**/
"
pageIndex
"
:
function
(
content_dict
,
url_dict
,
create
)
{
"
pageIndex
"
:
function
(
content_dict
,
url_dict
)
{
var
page_dict
=
content_dict
var
page_dict
=
content_dict
.
children
[
url_dict
?
(
url_dict
.
layout_level
||
0
)
:
0
];
.
children
[
url_dict
?
(
url_dict
.
layout_level
||
0
)
:
0
];
if
(
page_dict
===
undefined
)
{
if
(
page_dict
===
undefined
)
{
util
.
error
({
"
error
"
:
"
Pageindex: Missing page definition
"
});
util
.
error
({
"
error
"
:
"
Pageindex: Missing page definition
"
});
}
else
{
}
else
{
// NOTE: 3rd parameter "create" needs to be set to undefined,
// NOTE: 3rd parameter "create" needs to be set to undefined,
...
@@ -1190,7 +1197,7 @@
...
@@ -1190,7 +1197,7 @@
page_dict
,
page_dict
,
url_dict
,
url_dict
,
document
.
getElementById
(
url_dict
.
id
)
?
undefined
:
true
document
.
getElementById
(
url_dict
.
id
)
?
undefined
:
true
).
then
(
function
(
response
)
{
).
then
(
function
(
response
)
{
return
response
;
return
response
;
});
});
}
}
...
@@ -1208,7 +1215,7 @@
...
@@ -1208,7 +1215,7 @@
* @return {object} fragment
* @return {object} fragment
**/
**/
"
listgrid
"
:
function
(
spec
,
answer
,
field_dict
,
update
,
url_pointer
)
{
"
listgrid
"
:
function
(
spec
,
answer
,
field_dict
,
update
,
url_pointer
)
{
var
element
,
i
,
empty
,
target
,
placeholder
;
var
element
,
i
,
target
,
placeholder
;
// set update of gadget flag
// set update of gadget flag
if
(
spec
.
property_dict
.
depends_on
)
{
if
(
spec
.
property_dict
.
depends_on
)
{
...
@@ -1235,7 +1242,7 @@
...
@@ -1235,7 +1242,7 @@
if
(
update
)
{
if
(
update
)
{
target
=
document
.
createDocumentFragment
();
target
=
document
.
createDocumentFragment
();
}
else
{
}
else
{
target
=
factory
.
util
.
wrapInForm
(
spec
)
target
=
factory
.
util
.
wrapInForm
(
spec
)
;
}
}
// query has results
// query has results
...
@@ -1260,7 +1267,8 @@
...
@@ -1260,7 +1267,8 @@
element
.
children
=
map
.
utils
.
mapListItems
(
element
.
children
=
map
.
utils
.
mapListItems
(
answer
.
data
.
rows
,
answer
.
data
.
rows
,
spec
,
spec
,
url_pointer
url_pointer
,
field_dict
);
);
}
}
...
@@ -1287,8 +1295,7 @@
...
@@ -1287,8 +1295,7 @@
* @return {object} fragment
* @return {object} fragment
**/
**/
"
listbox
"
:
function
(
spec
,
answer
,
field_dict
,
update
,
url_pointer
)
{
"
listbox
"
:
function
(
spec
,
answer
,
field_dict
,
update
,
url_pointer
)
{
var
element
,
i
,
empty
,
target
,
container
,
pack
,
slot
,
pop
,
active
,
var
element
,
i
,
target
,
container
,
pack
,
slot
,
pop
,
active
,
placeholder
;
placeholder
;
// set update of gadget flag
// set update of gadget flag
if
(
spec
.
property_dict
.
depends_on
)
{
if
(
spec
.
property_dict
.
depends_on
)
{
...
@@ -1308,7 +1315,8 @@
...
@@ -1308,7 +1315,8 @@
target
=
factory
.
util
.
wrapInForm
(
spec
);
target
=
factory
.
util
.
wrapInForm
(
spec
);
target
.
appendChild
(
app
.
noItemsFound
(
placeholder
.
no_auth
));
target
.
appendChild
(
app
.
noItemsFound
(
placeholder
.
no_auth
));
return
target
;
return
target
;
}
else
{
}
// determine target element, that will be returned
// determine target element, that will be returned
if
(
update
)
{
if
(
update
)
{
target
=
document
.
createDocumentFragment
();
target
=
document
.
createDocumentFragment
();
...
@@ -1329,7 +1337,7 @@
...
@@ -1329,7 +1337,7 @@
active
=
util
.
getActivePage
();
active
=
util
.
getActivePage
();
if
(
document
.
getElementById
(
active
)
if
(
document
.
getElementById
(
active
)
.
querySelectorAll
(
"
div.local_popup
"
)
===
null
)
{
.
querySelectorAll
(
"
div.local_popup
"
)
===
null
)
{
target
.
appendChild
(
factory
.
popup
(
undefined
,
active_page
));
target
.
appendChild
(
factory
.
popup
(
undefined
,
undefined
));
}
}
}
else
{
}
else
{
if
(
document
.
getElementById
(
"
global_popup
"
)
===
null
)
{
if
(
document
.
getElementById
(
"
global_popup
"
)
===
null
)
{
...
@@ -1383,7 +1391,6 @@
...
@@ -1383,7 +1391,6 @@
return
container
;
return
container
;
}
}
return
target
;
return
target
;
}
},
},
/**
/**
...
@@ -1396,7 +1403,7 @@
...
@@ -1396,7 +1403,7 @@
* @param {object} url_pointer indicates layout used
* @param {object} url_pointer indicates layout used
* @return {object} fragment
* @return {object} fragment
**/
**/
"
fieldlist
"
:
function
(
spec
,
answer
,
field_dict
,
update
,
url_pointer
)
{
"
fieldlist
"
:
function
(
spec
,
answer
,
field_dict
)
{
var
i
,
element
,
target
,
placeholder
,
update_gadget
,
reset_state
,
data
;
var
i
,
element
,
target
,
placeholder
,
update_gadget
,
reset_state
,
data
;
// set update of gadget flag
// set update of gadget flag
...
@@ -1421,7 +1428,8 @@
...
@@ -1421,7 +1428,8 @@
return
target
;
return
target
;
// auth or allow
// auth or allow
}
else
{
}
target
=
document
.
createDocumentFragment
();
target
=
document
.
createDocumentFragment
();
if
((
answer
.
data
&&
answer
.
data
.
total_rows
===
0
)
||
if
((
answer
.
data
&&
answer
.
data
.
total_rows
===
0
)
||
...
@@ -1440,7 +1448,7 @@
...
@@ -1440,7 +1448,7 @@
}
else
{
}
else
{
data
=
answer
.
data
.
rows
[
0
].
doc
;
data
=
answer
.
data
.
rows
[
0
].
doc
;
if
(
data
===
undefined
)
{
if
(
data
===
undefined
)
{
util
.
errorHandler
({
"
error
"
:
"
fieldlist: include_docs missing
"
});
util
.
error
({
"
error
"
:
"
fieldlist: include_docs missing
"
});
}
}
}
}
}
}
...
@@ -1462,7 +1470,6 @@
...
@@ -1462,7 +1470,6 @@
}
}
return
target
;
return
target
;
}
}
}
};
};
/* ====================================================================== */
/* ====================================================================== */
...
@@ -1501,16 +1508,17 @@
...
@@ -1501,16 +1508,17 @@
delete
new_dict
.
attributes
[
"
data-rel
"
];
delete
new_dict
.
attributes
[
"
data-rel
"
];
new_dict
.
direct
.
className
=
new_dict
.
direct
.
className
=
new_dict
.
direct
.
className
.
replace
(
new_dict
.
direct
.
className
.
replace
(
(
off
?
"
user
"
:
"
off
"
),
(
off
?
"
off
"
:
"
user
"
)
(
off
?
"
user
"
:
"
off
"
),
(
off
?
"
off
"
:
"
user
"
)
);
);
new_dict
.
direct
.
href
=
off
?
"
#
"
:
"
#global-popup
"
;
new_dict
.
direct
.
href
=
off
?
"
#
"
:
"
#global-popup
"
;
new_dict
.
attributes
[
"
data-action
"
]
=
off
?
"
logout_user
"
:
"
login
"
;
new_dict
.
attributes
[
"
data-action
"
]
=
off
?
"
logout_user
"
:
"
login
"
;
new_dict
.
logic
[
"
data-reference
"
]
=
off
?
"
google
"
:
null
;
new_dict
.
logic
[
"
data-reference
"
]
=
off
?
"
google
"
:
null
;
new_dict
.
attributes
[
"
data-icon
"
]
=
off
?
"
on
"
:
"
off
"
;
new_dict
.
attributes
[
"
data-icon
"
]
=
off
?
"
on
"
:
"
off
"
;
new_dict
.
attributes
[
"
data-i18n
"
]
=
new_dict
.
attributes
[
"
data-i18n
"
]
=
"
global_dict.common_dict.
"
+
off
?
"
logout
"
:
"
login
"
"
global_dict.common_dict.
"
+
off
?
"
logout
"
:
"
login
"
;
new_dict
.
logic
[
"
data-rel
"
]
=
off
===
true
?
null
:
"
popup
"
;
new_dict
.
logic
[
"
data-rel
"
]
=
off
===
true
?
null
:
"
popup
"
;
new_dict
.
logic
[
"
text
"
]
=
off
?
"
Logout
"
:
"
Login
"
;
new_dict
.
logic
.
text
=
off
?
"
Logout
"
:
"
Login
"
;
}
else
{
}
else
{
new_dict
.
type
=
"
a
"
;
new_dict
.
type
=
"
a
"
;
new_dict
.
direct
=
{
new_dict
.
direct
=
{
...
@@ -1528,7 +1536,7 @@
...
@@ -1528,7 +1536,7 @@
"
text
"
:
off
?
"
Logout
"
:
"
Login
"
,
"
text
"
:
off
?
"
Logout
"
:
"
Login
"
,
"
data-rel
"
:
off
===
true
?
null
:
"
popup
"
,
"
data-rel
"
:
off
===
true
?
null
:
"
popup
"
,
"
data-reference
"
:
off
?
"
google
"
:
null
"
data-reference
"
:
off
?
"
google
"
:
null
}
};
if
(
off
===
false
)
{
if
(
off
===
false
)
{
new_dict
.
attributes
[
"
data-depend
"
]
=
"
login_state
"
;
new_dict
.
attributes
[
"
data-depend
"
]
=
"
login_state
"
;
new_dict
.
attributes
[
"
aria-haspopup
"
]
=
true
;
new_dict
.
attributes
[
"
aria-haspopup
"
]
=
true
;
...
@@ -1560,10 +1568,8 @@
...
@@ -1560,10 +1568,8 @@
// TODO: find a better way
// TODO: find a better way
factory
.
util
.
generateNestedElement
=
function
(
content_dict
)
{
factory
.
util
.
generateNestedElement
=
function
(
content_dict
)
{
switch
(
content_dict
.
generate
)
{
switch
(
content_dict
.
generate
)
{
case
"
widget
"
:
case
"
widget
"
:
return
factory
[
content_dict
.
type
](
content_dict
,
{},
undefined
);
return
factory
[
content_dict
.
type
](
content_dict
,
{},
undefined
);
default
:
default
:
switch
(
content_dict
.
type
)
{
switch
(
content_dict
.
type
)
{
case
"
input
"
:
case
"
input
"
:
...
@@ -1626,17 +1632,15 @@
...
@@ -1626,17 +1632,15 @@
factory
.
util
.
generatePopupContents
=
function
(
obj
)
{
factory
.
util
.
generatePopupContents
=
function
(
obj
)
{
var
i
,
j
,
promises
,
fragment
,
popup
,
reference
,
state
;
var
i
,
j
,
promises
,
fragment
,
popup
,
reference
,
state
;
popup
=
obj
.
gadget
,
popup
=
obj
.
gadget
;
reference
=
popup
.
getAttribute
(
"
data-reference
"
)
,
reference
=
popup
.
getAttribute
(
"
data-reference
"
)
;
state
=
popup
.
getAttribute
(
"
data-state
"
);
state
=
popup
.
getAttribute
(
"
data-state
"
);
// don't reload if same popup is opened
// don't reload if same popup is opened
if
(
state
!==
reference
)
{
if
(
state
!==
reference
)
{
if
(
reference
===
null
)
{
if
(
reference
===
null
)
{
util
.
error
({
"
error
"
:
"
Global Bindings: No handler for popup
"
});
util
.
error
({
"
error
"
:
"
Global Bindings: No popup handler
"
});
fragment
=
factory
.
element
(
fragment
=
factory
.
element
(
"
p
"
,
{},
{},
{
"
text
"
:
"
No popup handler
"
});
"
p
"
,
{},
{},
{
"
text
"
:
"
No handler for popup
"
}
);
}
else
{
}
else
{
popup
.
setAttribute
(
"
data-state
"
,
reference
);
popup
.
setAttribute
(
"
data-state
"
,
reference
);
popup
.
setAttribute
(
"
data-reference
"
,
reference
);
popup
.
setAttribute
(
"
data-reference
"
,
reference
);
...
@@ -1656,9 +1660,9 @@
...
@@ -1656,9 +1660,9 @@
promises
[
i
]
=
app
.
setContent
(
reply
.
children
[
i
],
{},
false
);
promises
[
i
]
=
app
.
setContent
(
reply
.
children
[
i
],
{},
false
);
}
}
}
}
return
RSVP
.
all
(
promises
)
return
RSVP
.
all
(
promises
);
})
})
.
then
(
function
(
content
)
{
.
then
(
function
(
content
)
{
fragment
=
document
.
createDocumentFragment
();
fragment
=
document
.
createDocumentFragment
();
for
(
j
=
0
;
j
<
content
.
length
;
j
+=
1
)
{
for
(
j
=
0
;
j
<
content
.
length
;
j
+=
1
)
{
fragment
.
appendChild
(
content
[
j
]);
fragment
.
appendChild
(
content
[
j
]);
...
@@ -1674,7 +1678,7 @@
...
@@ -1674,7 +1678,7 @@
// append
// append
popup
.
appendChild
(
fragment
);
popup
.
appendChild
(
fragment
);
})
})
.
then
(
function
()
{
.
then
(
function
()
{
// TODO: how to reposition popup right after appending?
// TODO: how to reposition popup right after appending?
$
(
popup
).
popup
(
"
reposition
"
,
{
"
positionto
"
:
"
window
"
});
$
(
popup
).
popup
(
"
reposition
"
,
{
"
positionto
"
:
"
window
"
});
})
})
...
@@ -1714,7 +1718,7 @@
...
@@ -1714,7 +1718,7 @@
"
id
"
:
spec
.
id
,
"
id
"
:
spec
.
id
,
"
className
"
:
(
spec
.
class_list
||
""
)
"
className
"
:
(
spec
.
class_list
||
""
)
},
},
{
"
data-ajax
"
:
false
,
"
autocomplete
"
:
"
off
"
},
{
"
data-ajax
"
:
false
,
"
autocomplete
"
:
"
off
"
},
{
{
"
data-depend
"
:
spec
.
depend
||
null
,
"
data-depend
"
:
spec
.
depend
||
null
,
"
data-reset
"
:
spec
.
reset
||
null
"
data-reset
"
:
spec
.
reset
||
null
...
@@ -1754,7 +1758,7 @@
...
@@ -1754,7 +1758,7 @@
// TODO: generate without referencing IDs
// TODO: generate without referencing IDs
// NOTE: scope (element id) will make the popup local
// NOTE: scope (element id) will make the popup local
factory
.
popup
=
function
(
config_dict
,
url_dict
)
{
factory
.
popup
=
function
(
config_dict
,
url_dict
)
{
var
i
,
target
,
popup
,
wrap
,
id
,
config
,
container
,
placeholder
;
var
i
,
popup
,
wrap
,
id
,
config
,
container
,
placeholder
;
if
(
config_dict
===
undefined
)
{
if
(
config_dict
===
undefined
)
{
util
.
error
({
util
.
error
({
...
@@ -1936,10 +1940,11 @@
...
@@ -1936,10 +1940,11 @@
element
.
direct
&&
element
.
type
!==
"
controlbar
"
)
{
element
.
direct
&&
element
.
type
!==
"
controlbar
"
)
{
order
=
i
===
0
?
"
ui-first-child
"
:
order
=
i
===
0
?
"
ui-first-child
"
:
(
i
===
(
config_dict
.
children
.
length
-
1
)
?
"
ui-last-child
"
:
"
"
);
(
i
===
(
config_dict
.
children
.
length
-
1
)
?
"
ui-last-child
"
:
"
"
);
element
.
direct
.
className
=
(
element
.
direct
.
className
||
""
)
+
order
+
element
.
direct
.
className
=
(
element
.
direct
.
className
||
""
)
+
(
element
.
type
===
"
a
"
?
(
"
ui-btn ui-shadow
"
+
order
+
(
element
.
type
===
"
a
"
?
(
"
ui-btn ui-shadow
"
+
factory
.
generateIconClassString
(
element
))
:
"
"
);
factory
.
generateIconClassString
(
element
))
:
"
"
);
}
}
...
@@ -1987,7 +1992,7 @@
...
@@ -1987,7 +1992,7 @@
*/
*/
// TODO: Needs pre-enhancement!
// TODO: Needs pre-enhancement!
factory
.
panel
=
function
(
config_dict
,
url_dict
)
{
factory
.
panel
=
function
(
config_dict
,
url_dict
)
{
var
i
,
element
,
config
,
id
,
panel
,
closer
,
order
,
target
;
var
i
,
element
,
config
,
id
,
panel
,
closer
,
target
;
if
(
config_dict
===
undefined
)
{
if
(
config_dict
===
undefined
)
{
util
.
error
({
util
.
error
({
...
@@ -2032,7 +2037,8 @@
...
@@ -2032,7 +2037,8 @@
if
(
config_dict
.
children
)
{
if
(
config_dict
.
children
)
{
for
(
i
=
0
;
i
<
config_dict
.
children
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
config_dict
.
children
.
length
;
i
+=
1
)
{
element
=
config_dict
.
children
[
i
];
element
=
config_dict
.
children
[
i
];
target
=
factory
.
element
(
"
div
"
,
target
=
factory
.
element
(
"
div
"
,
{
{
"
className
"
:
"
panel_element
"
+
(
i
===
0
?
"
className
"
:
"
panel_element
"
+
(
i
===
0
?
"
panel_element_first panel_header
"
:
"
panel_element_first panel_header
"
:
...
@@ -2049,7 +2055,7 @@
...
@@ -2049,7 +2055,7 @@
element
.
direct
.
className
+=
"
ui-btn
"
;
element
.
direct
.
className
+=
"
ui-btn
"
;
}
}
target
.
appendChild
(
app
.
setContent
(
element
))
target
.
appendChild
(
app
.
setContent
(
element
))
;
panel
.
appendChild
(
target
);
panel
.
appendChild
(
target
);
}
}
}
}
...
@@ -2125,10 +2131,11 @@
...
@@ -2125,10 +2131,11 @@
if
((
element
.
type
!==
"
input
"
&&
element
.
type
!==
"
select
"
)
&&
if
((
element
.
type
!==
"
input
"
&&
element
.
type
!==
"
select
"
)
&&
element
.
direct
&&
element
.
type
!==
"
controlbar
"
)
{
element
.
direct
&&
element
.
type
!==
"
controlbar
"
)
{
order
=
i
===
0
?
"
ui-first-child
"
:
order
=
i
===
0
?
"
ui-first-child
"
:
(
i
===
(
spec
.
length
-
1
)
?
"
ui-last-child
"
:
"
"
);
(
i
===
(
config_dict
.
children
.
length
-
1
)
?
"
ui-last-child
"
:
"
"
);
element
.
direct
.
className
=
(
element
.
direct
.
className
||
""
)
+
order
+
element
.
direct
.
className
=
(
element
.
direct
.
className
||
""
)
+
(
element
.
type
===
"
a
"
?
(
"
ui-btn ui-shadow
"
+
order
+
(
element
.
type
===
"
a
"
?
(
"
ui-btn ui-shadow
"
+
factory
.
generateIconClassString
(
element
))
:
"
"
);
factory
.
generateIconClassString
(
element
))
:
"
"
);
}
}
}
}
...
@@ -2158,7 +2165,7 @@
...
@@ -2158,7 +2165,7 @@
factory
.
form
=
function
(
spec
)
{
factory
.
form
=
function
(
spec
)
{
var
i
,
j
,
k
,
layout
,
element
,
container
,
area
,
field
,
overrides
,
var
i
,
j
,
k
,
layout
,
element
,
container
,
area
,
field
,
overrides
,
position
,
doc
,
config
,
value
,
stamp
,
sauce
,
encode
,
secure
,
position
,
doc
,
config
,
value
,
stamp
,
sauce
,
encode
,
secure
,
safety_box
,
noscript
,
fragment
,
wrap
,
item_id
;
safety_box
,
fragment
,
wrap
,
item_id
;
fragment
=
factory
.
util
.
wrapInForm
(
spec
);
fragment
=
factory
.
util
.
wrapInForm
(
spec
);
secure
=
spec
.
property_dict
.
secure
;
secure
=
spec
.
property_dict
.
secure
;
...
@@ -2207,12 +2214,12 @@
...
@@ -2207,12 +2214,12 @@
},
},
"
attributes
"
:
{
"
attributes
"
:
{
"
placeholder
"
:
"
Please do not fill out this field
"
,
"
placeholder
"
:
"
Please do not fill out this field
"
,
"
data-enhanced
"
:
"
true
"
,
"
data-enhanced
"
:
"
true
"
,
"
data-i18n
"
:
"
[placeholder]global.form_helpers.secure_blank
"
"
data-i18n
"
:
"
[placeholder]global.form_helpers.secure_blank
"
},
},
"
logic
"
:
{
"
logic
"
:
{
"
plain_element
"
:
true
,
"
plain_element
"
:
true
,
"
label
"
:
"
Please do not fill out this field
"
,
"
label
"
:
"
Please do not fill out this field
"
,
"
label_i18n
"
:
"
global.form_helpers.secure_blank
"
"
label_i18n
"
:
"
global.form_helpers.secure_blank
"
}
}
}
}
...
@@ -2220,8 +2227,8 @@
...
@@ -2220,8 +2227,8 @@
container
.
appendChild
(
factory
.
element
(
container
.
appendChild
(
factory
.
element
(
"
input
"
,
"
input
"
,
{
{
"
type
"
:
"
hidden
"
,
"
type
"
:
"
hidden
"
,
"
value
"
:
spec
.
property_dict
.
secret_hash
,
"
value
"
:
spec
.
property_dict
.
secret_hash
,
"
id
"
:
spec
.
id
+
"
_not_a_secret
"
"
id
"
:
spec
.
id
+
"
_not_a_secret
"
},
},
{
{
...
@@ -2238,12 +2245,12 @@
...
@@ -2238,12 +2245,12 @@
},
},
"
attributes
"
:
{
"
attributes
"
:
{
"
placeholder
"
:
"
Please leave this value unchanged
"
,
"
placeholder
"
:
"
Please leave this value unchanged
"
,
"
data-enhanced
"
:
"
true
"
,
"
data-enhanced
"
:
"
true
"
,
"
data-i18n
"
:
"
[placeholder]global.form_helpers.secure_filled
"
"
data-i18n
"
:
"
[placeholder]global.form_helpers.secure_filled
"
},
},
"
logic
"
:
{
"
logic
"
:
{
"
plain_element
"
:
true
,
"
plain_element
"
:
true
,
"
label
"
:
"
Please leave this value unchanged
"
,
"
label
"
:
"
Please leave this value unchanged
"
,
"
label_i18n
"
:
"
global.form_helpers.secure_filled
"
"
label_i18n
"
:
"
global.form_helpers.secure_filled
"
}
}
}
}
...
@@ -2255,7 +2262,7 @@
...
@@ -2255,7 +2262,7 @@
container
.
appendChild
(
factory
.
element
(
container
.
appendChild
(
factory
.
element
(
"
input
"
,
"
input
"
,
{
{
"
type
"
:
"
hidden
"
,
"
type
"
:
"
hidden
"
,
"
value
"
:
item_id
,
"
value
"
:
item_id
,
"
name
"
:
"
identifier
"
"
name
"
:
"
identifier
"
}
}
...
@@ -2408,15 +2415,15 @@
...
@@ -2408,15 +2415,15 @@
order
=
i
===
0
?
"
ui-first-child
"
:
order
=
i
===
0
?
"
ui-first-child
"
:
(
i
===
(
spec
.
children
.
length
-
1
)
?
"
ui-last-child
"
:
"
"
);
(
i
===
(
spec
.
children
.
length
-
1
)
?
"
ui-last-child
"
:
"
"
);
element
.
direct
.
className
=
(
element
.
direct
.
className
||
""
)
+
order
+
element
.
direct
.
className
=
(
element
.
direct
.
className
||
""
)
+
(
element
.
type
===
"
a
"
?
(
"
ui-btn ui-shadow
"
+
order
+
(
element
.
type
===
"
a
"
?
(
"
ui-btn ui-shadow
"
+
factory
.
generateIconClassString
(
element
))
:
"
"
);
factory
.
generateIconClassString
(
element
))
:
"
"
);
}
}
if
(
state
)
{
if
(
state
)
{
if
(
element
.
generate
===
undefined
)
{
if
(
element
.
generate
===
undefined
)
{
if
(
element
.
attributes
[
"
data-depend
"
])
{
if
(
element
.
attributes
[
"
data-depend
"
])
{
element
=
factory
.
util
.
convertDict
(
element
,
state
)
element
=
factory
.
util
.
convertDict
(
element
,
state
)
;
}
}
}
}
}
}
...
@@ -2492,12 +2499,12 @@
...
@@ -2492,12 +2499,12 @@
// class string
// class string
// TODO: needed?
// TODO: needed?
if
((
element
.
type
!==
"
input
"
&&
element
.
type
!==
"
select
"
)
&&
if
((
element
.
type
!==
"
input
"
&&
element
.
type
!==
"
select
"
)
&&
element
.
direct
&&
type
!==
"
controlbar
"
)
{
element
.
direct
)
{
order
=
i
===
0
?
"
ui-first-child
"
:
order
=
i
===
0
?
"
ui-first-child
"
:
(
i
===
(
spec
.
length
-
1
)
?
"
ui-last-child
"
:
"
"
);
(
i
===
(
spec
.
length
-
1
)
?
"
ui-last-child
"
:
"
"
);
element
.
direct
.
className
=
(
element
.
direct
.
className
||
""
)
+
order
+
element
.
direct
.
className
=
(
element
.
direct
.
className
||
""
)
+
(
element
.
type
===
"
a
"
?
(
"
ui-btn ui-shadow
"
+
order
+
(
element
.
type
===
"
a
"
?
(
"
ui-btn ui-shadow
"
+
factory
.
generateIconClassString
(
element
))
:
"
"
);
factory
.
generateIconClassString
(
element
))
:
"
"
);
}
}
...
@@ -2579,25 +2586,9 @@
...
@@ -2579,25 +2586,9 @@
// TODO: add collapsible support if needed
// TODO: add collapsible support if needed
// TODO: mesh with live data!
// TODO: mesh with live data!
factory
.
listview
=
function
(
spec
,
url_dict
,
update
)
{
factory
.
listview
=
function
(
spec
,
url_dict
,
update
)
{
var
fragment
,
var
fragment
,
config
,
list
,
i
,
item
,
props
,
divider
,
static_item
,
j
,
config
,
input_dict
,
action
,
block
,
target
,
icon
,
auto
,
last
,
list
,
ribbon_wrap
,
theme
;
i
,
item
,
props
,
divider
,
static_item
,
j
,
input_dict
,
action
,
block
,
target
,
icon
,
auto
,
last
,
ribbon
,
ribbon_wrap
,
theme
;
if
(
spec
===
undefined
)
{
if
(
spec
===
undefined
)
{
util
.
errorHanlder
({
util
.
errorHanlder
({
...
@@ -2638,7 +2629,8 @@
...
@@ -2638,7 +2629,8 @@
config
.
numbered
?
"
ol
"
:
"
ul
"
,
config
.
numbered
?
"
ol
"
:
"
ul
"
,
{
{
"
className
"
:
"
ui-listview
"
+
(
spec
.
class_list
||
""
)
+
"
className
"
:
"
ui-listview
"
+
(
spec
.
class_list
||
""
)
+
(
config
.
inset
?
"
ui-listview-inset ui-corner-all ui-shadow
"
:
""
)
(
config
.
inset
?
"
ui-listview-inset ui-corner-all ui-shadow
"
:
""
)
},
},
{
"
data-role
"
:
"
listview
"
,
"
data-enhanced
"
:
true
},
{
"
data-role
"
:
"
listview
"
,
"
data-enhanced
"
:
true
},
{
{
...
@@ -2711,7 +2703,7 @@
...
@@ -2711,7 +2703,7 @@
if
(
props
.
ribbon
)
{
if
(
props
.
ribbon
)
{
ribbon_wrap
=
factory
.
element
(
ribbon_wrap
=
factory
.
element
(
"
span
"
,
"
span
"
,
{
"
className
"
:
"
ribbon-wrapper
"
}
{
"
className
"
:
"
ribbon-wrapper
"
}
);
);
ribbon_wrap
.
appendChild
(
factory
.
element
(
ribbon_wrap
.
appendChild
(
factory
.
element
(
"
span
"
,
"
span
"
,
...
@@ -2722,6 +2714,12 @@
...
@@ -2722,6 +2714,12 @@
if
(
static_item
||
divider
)
{
if
(
static_item
||
divider
)
{
target
=
item
;
target
=
item
;
}
else
{
}
else
{
// jslint...
// TODO: remove!
if
(
props
.
href
===
undefined
)
{
util
.
errorHandler
({
"
error
"
:
"
JSLINT error, ignore
"
});
props
.
href
=
url_dict
.
href
;
}
// link
// link
target
=
factory
.
element
(
target
=
factory
.
element
(
"
a
"
,
"
a
"
,
...
@@ -2842,7 +2840,8 @@
...
@@ -2842,7 +2840,8 @@
"
type
"
:
"
input
"
,
"
type
"
:
"
input
"
,
"
direct
"
:
{
"
direct
"
:
{
"
id
"
:
"
select_
"
+
props
.
id
,
"
id
"
:
"
select_
"
+
props
.
id
,
"
name
"
:
"
select_
"
+
(
props
.
right
.
check
?
props
.
id
:
spec
.
id
),
"
name
"
:
"
select_
"
+
(
props
.
right
.
check
?
props
.
id
:
spec
.
id
),
"
className
"
:
action
?
"
action
"
:
""
"
className
"
:
action
?
"
action
"
:
""
},
},
"
attributes
"
:
input_dict
,
"
attributes
"
:
input_dict
,
...
@@ -2899,7 +2898,7 @@
...
@@ -2899,7 +2898,7 @@
{},
{},
{
{
"
data-slot
"
:
slot
?
true
:
null
,
"
data-slot
"
:
slot
?
true
:
null
,
"
data-slot-id
"
:
slot
?
slot
:
null
,
"
data-slot-id
"
:
slot
||
null
,
"
data-reference
"
:
spec
.
reference
||
null
"
data-reference
"
:
spec
.
reference
||
null
}
}
);
);
...
@@ -2934,17 +2933,12 @@
...
@@ -2934,17 +2933,12 @@
*/
*/
// NOTE: we are defaulting to fixed toolbars!
// NOTE: we are defaulting to fixed toolbars!
factory
.
page
=
function
(
content_dict
,
url_dict
,
create
)
{
factory
.
page
=
function
(
content_dict
,
url_dict
,
create
)
{
var
i
,
var
i
,
j
,
last
,
wrapper
,
split_url
,
promises
=
[],
container
,
target
,
j
,
view
,
render
;
k
,
last
,
container
=
document
.
getElementById
(
url_dict
.
id
);
element
,
target
=
document
.
createDocumentFragment
();
wrapper
,
view
=
(
url_dict
&&
url_dict
.
mode
)
?
url_dict
.
mode
:
"
default
"
;
split_url
,
promises
=
[],
container
=
document
.
getElementById
(
url_dict
.
id
),
target
=
document
.
createDocumentFragment
(),
view
=
(
url_dict
&&
url_dict
.
mode
)
?
url_dict
.
mode
:
"
default
"
,
render
=
content_dict
.
layout
[
view
];
render
=
content_dict
.
layout
[
view
];
if
(
render
)
{
if
(
render
)
{
...
@@ -2953,7 +2947,7 @@
...
@@ -2953,7 +2947,7 @@
promises
[
i
]
=
app
.
setContent
(
render
[
i
],
url_dict
,
create
);
promises
[
i
]
=
app
.
setContent
(
render
[
i
],
url_dict
,
create
);
}
}
}
else
{
}
else
{
util
.
error
Handler
({
"
error
"
:
"
factory.page: Missing view
"
});
util
.
error
({
"
error
"
:
"
factory.page: Missing view
"
});
}
}
return
RSVP
.
all
(
promises
)
return
RSVP
.
all
(
promises
)
...
@@ -3097,8 +3091,9 @@
...
@@ -3097,8 +3091,9 @@
*/
*/
// TODO: pre-enhance!
// TODO: pre-enhance!
// TODO: refactor the passing around of information. This is not nice!!!
// TODO: refactor the passing around of information. This is not nice!!!
/* Jslint: unused: true */
factory
.
table
=
function
(
spec
,
url_dict
,
update
)
{
factory
.
table
=
function
(
spec
,
url_dict
,
update
)
{
var
i
,
container
,
config
,
table
,
section
,
method
;
var
i
,
container
,
config
,
section
,
method
;
if
(
spec
===
undefined
)
{
if
(
spec
===
undefined
)
{
util
.
errorHanlder
({
util
.
errorHanlder
({
...
@@ -3118,7 +3113,7 @@
...
@@ -3118,7 +3113,7 @@
{
{
"
data-role
"
:
"
table
"
,
"
data-role
"
:
"
table
"
,
"
data-mode
"
:
config
.
mode
,
"
data-mode
"
:
config
.
mode
,
"
data-use-pop
"
:
config
.
toggle_popup
===
false
?
false
:
true
,
"
data-use-pop
"
:
config
.
toggle_popup
===
false
?
false
:
true
},
},
{
{
"
id
"
:
config
.
id
||
null
,
"
id
"
:
config
.
id
||
null
,
...
@@ -3160,9 +3155,9 @@
...
@@ -3160,9 +3155,9 @@
*/
*/
// TODO: merge check/radio on table and listview!
// TODO: merge check/radio on table and listview!
factory
.
tableRow
=
function
(
spec
,
body
)
{
factory
.
tableRow
=
function
(
spec
,
body
)
{
var
i
,
j
,
k
,
field
,
link
,
config
,
property
,
title
,
action
,
cell
,
set
,
tex
t
,
var
i
,
j
,
k
,
field
,
link
,
attributes
,
property
,
title
,
action
,
cell
,
se
t
,
column_list
,
temp
,
container
,
row
,
group
,
button
,
input_type
,
checkered
,
column_list
,
temp
,
container
,
row
,
group
,
button
,
input_type
,
global_check
,
skip
,
input_dict
,
snippet
;
global_check
,
skip
,
input_dict
,
snippet
,
logic
;
// checkbox row
// checkbox row
if
(
spec
.
config
.
check
)
{
if
(
spec
.
config
.
check
)
{
...
@@ -3176,7 +3171,7 @@
...
@@ -3176,7 +3171,7 @@
}
}
// radio row
// radio row
if
(
spec
.
config
.
radio
)
{
if
(
spec
.
config
.
radio
)
{
input_type
=
"
radio
"
;
input_type
=
"
radio
"
;
if
(
body
===
null
)
{
if
(
body
===
null
)
{
skip
=
true
;
skip
=
true
;
...
@@ -3244,31 +3239,32 @@
...
@@ -3244,31 +3239,32 @@
for
(
j
=
0
;
j
<
column_list
.
length
;
j
+=
1
)
{
for
(
j
=
0
;
j
<
column_list
.
length
;
j
+=
1
)
{
field
=
column_list
[
j
];
field
=
column_list
[
j
];
link
=
undefined
;
link
=
undefined
;
config
=
{};
attributes
=
{};
text
=
null
;
logic
=
{}
;
property
=
field
.
column
;
property
=
field
.
column
;
if
(
field
.
show
)
{
if
(
field
.
show
)
{
if
(
field
.
merge
===
undefined
)
{
if
(
field
.
merge
===
undefined
)
{
if
(
field
.
text_i18n
)
{
if
(
field
.
text_i18n
)
{
config
[
"
data-i18n
"
]
=
field
.
text_i18n
;
attributes
[
"
data-i18n
"
]
=
field
.
text_i18n
;
}
}
if
(
field
.
persist
===
undefined
)
{
if
(
field
.
persist
===
undefined
)
{
config
[
"
data-priority
"
]
=
field
.
priority
||
6
;
attributes
[
"
data-priority
"
]
=
field
.
priority
||
6
;
}
}
// set title to title or merger_title stored in temp
// set title to title or merger_title stored in temp
snippet
=
(
field
.
title
||
field
.
text
);
snippet
=
(
field
.
title
||
field
.
text
);
title
=
temp
[
property
]
?
snippet
+
"
"
+
temp
[
property
][
0
]
:
snippet
;
title
=
temp
[
property
]
?
snippet
+
"
"
+
temp
[
property
][
0
]
:
snippet
;
// cell action buttons
// cell action buttons
if
(
field
.
action_list
&&
field
.
action_list
.
length
)
{
if
(
(
field
.
action_list
&&
field
.
action_list
.
length
)
)
{
group
=
{
group
=
{
"
generate
"
:
"
widget
"
,
"
generate
"
:
"
widget
"
,
"
type
"
:
"
controlgroup
"
,
"
type
"
:
"
controlgroup
"
,
"
property_dict
"
:
{
"
direction
"
:
"
horizontal
"
},
"
property_dict
"
:
{
"
direction
"
:
"
horizontal
"
},
"
children
"
:
[]
"
children
"
:
[]
}
}
;
// can be single action or a button group!
// can be single action or a button group!
for
(
k
=
0
;
k
<
field
.
action_list
.
length
;
k
+=
1
)
{
for
(
k
=
0
;
k
<
field
.
action_list
.
length
;
k
+=
1
)
{
button
=
field
.
action_list
[
k
];
button
=
field
.
action_list
[
k
];
...
@@ -3291,9 +3287,9 @@
...
@@ -3291,9 +3287,9 @@
// hijack link variable
// hijack link variable
link
=
app
.
setContent
(
group
);
link
=
app
.
setContent
(
group
);
// links
&
sorting
// links
and/or
sorting
}
else
if
((
!
body
&&
spec
.
config
.
sortable
&&
field
.
sort
)
||
}
else
if
((
!
body
&&
spec
.
config
.
sortable
&&
field
.
sort
)
||
spec
.
config
.
linkable
&&
field
.
href
)
{
(
spec
.
config
.
linkable
&&
field
.
href
)
)
{
// header link (sorting) or href link
// header link (sorting) or href link
link
=
factory
.
element
(
link
=
factory
.
element
(
...
@@ -3310,30 +3306,33 @@
...
@@ -3310,30 +3306,33 @@
"
data-reference
"
:
field
.
href
?
null
:
spec
.
config
.
reference
,
"
data-reference
"
:
field
.
href
?
null
:
spec
.
config
.
reference
,
"
data-column-title
"
:
field
.
href
?
null
:
field
.
column
,
"
data-column-title
"
:
field
.
href
?
null
:
field
.
column
,
"
text
"
:
title
||
null
,
"
text
"
:
title
||
null
,
"
img
"
:
field
.
image
?
{
"
href
"
:
field
.
image
,
"
alt
"
:
null
,
"
alt_i18n
"
:
null
}
:
null
,
"
img
"
:
field
.
image
?
{
"
href
"
:
field
.
image
,
"
alt
"
:
null
,
"
alt_i18n
"
:
null
}
:
null
,
"
href
"
:
field
.
href
||
null
,
"
href
"
:
field
.
href
||
null
,
"
data-i18n
"
:
field
.
href
?
null
:
(
field
.
text_i18n
?
"
data-i18n
"
:
field
.
href
?
null
:
(
field
.
text_i18n
?
(
temp
[
property
]
?
temp
[
property
][
1
]
:
field
.
text_i18n
)
:
(
temp
[
property
]
?
temp
[
property
][
1
]
:
field
.
text_i18n
)
:
null
)
,
null
)
}
}
);
);
// image
// image
}
else
if
(
field
.
image
)
{
}
else
if
(
field
.
image
)
{
logic
=
{
logic
.
img
=
field
.
image
;
"
img
"
:
field
.
image
};
// default
// default
}
else
{
}
else
{
text
=
{
"
text
"
:
title
}
;
logic
.
text
=
title
;
}
}
// make the cell
// make the cell
cell
=
factory
.
element
(
cell
=
factory
.
element
(
body
?
"
td
"
:
"
th
"
,
body
?
"
td
"
:
"
th
"
,
{
"
className
"
:
link
?
""
:
"
translate plain
"
},
{
"
className
"
:
link
?
""
:
"
translate plain
"
},
config
,
attributes
,
text
logic
);
);
// add the link/action menu
// add the link/action menu
if
(
link
)
{
if
(
link
)
{
cell
.
appendChild
(
link
);
cell
.
appendChild
(
link
);
...
@@ -3342,7 +3341,8 @@
...
@@ -3342,7 +3341,8 @@
if
(
spec
.
config
.
mergeable
)
{
if
(
spec
.
config
.
mergeable
)
{
row
.
insertBefore
(
row
.
insertBefore
(
cell
,
cell
,
(
set
===
undefined
?
null
:
row
.
childNodes
[
spec
.
config
.
check
?
1
:
0
])
(
set
===
undefined
?
null
:
row
.
childNodes
[
spec
.
config
.
check
?
1
:
0
])
);
);
set
=
true
;
set
=
true
;
}
else
{
}
else
{
...
@@ -3370,7 +3370,7 @@
...
@@ -3370,7 +3370,7 @@
* @returns {object} target
* @returns {object} target
*/
*/
factory
.
tableBody
=
function
(
spec
,
update
)
{
factory
.
tableBody
=
function
(
spec
,
update
)
{
var
l
,
target
;
var
target
;
if
(
update
)
{
if
(
update
)
{
target
=
document
.
createDocumentFragment
();
target
=
document
.
createDocumentFragment
();
...
@@ -3895,7 +3895,7 @@
...
@@ -3895,7 +3895,7 @@
test_full
,
test_empty
,
test_time
,
form_to_submit
,
anti_spam
,
formData
,
test_full
,
test_empty
,
test_time
,
form_to_submit
,
anti_spam
,
formData
,
valid
,
pass_id
;
valid
,
pass_id
;
pass
=
false
pass
=
false
;
form_to_submit
=
document
.
getElementById
(
config
.
id
);
form_to_submit
=
document
.
getElementById
(
config
.
id
);
anti_spam
=
document
.
getElementById
(
form_to_submit
.
id
+
"
_not_a_secret
"
);
anti_spam
=
document
.
getElementById
(
form_to_submit
.
id
+
"
_not_a_secret
"
);
formData
=
new
FormData
();
formData
=
new
FormData
();
...
@@ -3907,7 +3907,7 @@
...
@@ -3907,7 +3907,7 @@
if
(
anti_spam
)
{
if
(
anti_spam
)
{
// fill form in < 1sec = spammer
// fill form in < 1sec = spammer
if
(
Date
.
now
()
-
parseInt
(
anti_spam
.
getAttribute
(
"
data-created
"
))
if
(
Date
.
now
()
-
parseInt
(
anti_spam
.
getAttribute
(
"
data-created
"
)
,
10
)
>
1000
)
{
>
1000
)
{
test_time
=
true
;
test_time
=
true
;
}
}
...
@@ -3916,7 +3916,7 @@
...
@@ -3916,7 +3916,7 @@
form_elements
=
form_to_submit
.
getElementsByTagName
(
"
input
"
);
form_elements
=
form_to_submit
.
getElementsByTagName
(
"
input
"
);
for
(
i
=
0
;
i
<
form_elements
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
form_elements
.
length
;
i
+=
1
)
{
form_element
=
form_elements
[
i
];
form_element
=
form_elements
[
i
];
if
(
util
.
testForString
(
"
secure_form
"
,
form_element
.
className
))
{
if
(
util
.
testForString
(
"
secure_form
"
,
form_element
.
className
))
{
if
(
form_element
.
value
===
""
)
{
if
(
form_element
.
value
===
""
)
{
test_empty
=
true
;
test_empty
=
true
;
}
}
...
@@ -3960,19 +3960,19 @@
...
@@ -3960,19 +3960,19 @@
"
response
"
:
[
obj
],
"
response
"
:
[
obj
],
"
pass
"
:
{
"
type
"
:
config
.
gadget
.
state
.
type
,
"
reply
"
:
true
}
"
pass
"
:
{
"
type
"
:
config
.
gadget
.
state
.
type
,
"
reply
"
:
true
}
})
})
.
then
(
function
(
answer
)
{
.
then
(
function
(
answer
)
{
if
(
answer
.
response
.
result
===
"
success
"
)
{
if
(
answer
.
response
.
result
===
"
success
"
)
{
pass_id
=
answer
.
response
.
id
;
pass_id
=
answer
.
response
.
id
;
switch
(
config
.
gadget
.
getAttribute
(
"
data-reset
"
))
{
switch
(
config
.
gadget
.
getAttribute
(
"
data-reset
"
))
{
case
"
login_state
"
:
case
"
login_state
"
:
app
.
setLoginStatus
(
answer
.
response
,
config
.
portal_type_source
);
app
.
setLoginStatus
(
answer
.
response
,
config
.
portal_type_source
);
break
;
break
;
};
}
util
.
loader
(
""
,
"
global_dict.status_dict.saved
"
,
"
check
"
);
util
.
loader
(
""
,
"
global_dict.status_dict.saved
"
,
"
check
"
);
return
pass_id
;
return
pass_id
;
}
}
})
})
.
then
(
function
(
id
)
{
.
then
(
function
(
id
)
{
if
(
id
&&
config
.
state
.
callback
)
{
if
(
id
&&
config
.
state
.
callback
)
{
$
.
mobile
.
changePage
(
config
.
state
.
callback
.
replace
(
"
__id__
"
,
id
));
$
.
mobile
.
changePage
(
config
.
state
.
callback
.
replace
(
"
__id__
"
,
id
));
}
}
...
@@ -4048,7 +4048,7 @@
...
@@ -4048,7 +4048,7 @@
"
attachment
"
:
config
.
id
,
"
attachment
"
:
config
.
id
,
"
pass
"
:
undefined
"
pass
"
:
undefined
})
})
.
then
(
function
(
gadget_config
)
{
.
then
(
function
(
gadget_config
)
{
// portal_type fieldlist
// portal_type fieldlist
return
app
.
fetchConfiguration
({
return
app
.
fetchConfiguration
({
"
storage
"
:
app
.
default_dict
.
storage_dict
.
settings
,
"
storage
"
:
app
.
default_dict
.
storage_dict
.
settings
,
...
@@ -4057,7 +4057,7 @@
...
@@ -4057,7 +4057,7 @@
"
pass
"
:
{
"
pass
"
:
{
"
portal_type
"
:
gadget_config
.
portal_type_source
"
portal_type
"
:
gadget_config
.
portal_type_source
}
}
})
});
})
})
.
then
(
function
(
reply
)
{
.
then
(
function
(
reply
)
{
// update gadget state
// update gadget state
...
@@ -4071,11 +4071,11 @@
...
@@ -4071,11 +4071,11 @@
// update gadget
// update gadget
app
.
setContent
(
app
.
setContent
(
{
"
generate
"
:
"
gadget
"
,
"
id
"
:
config
.
id
,
"
href
"
:
config
.
id
},
{
"
generate
"
:
"
gadget
"
,
"
id
"
:
config
.
id
,
"
href
"
:
config
.
id
},
{
"
fragment_list
"
:
config
.
state
.
fragment_list
},
{
"
fragment_list
"
:
config
.
state
.
fragment_list
},
false
false
)
)
.
then
(
function
(
reply
)
{
.
then
(
function
(
reply
)
{
factory
.
util
.
updatePageSection
(
config
.
id
,
reply
);
factory
.
util
.
updatePageSection
(
config
.
id
,
reply
);
})
})
.
fail
(
util
.
error
);
.
fail
(
util
.
error
);
...
@@ -4093,12 +4093,12 @@
...
@@ -4093,12 +4093,12 @@
// fetch profile
// fetch profile
return
hello
(
provider
).
api
(
"
/me
"
)
return
hello
(
provider
).
api
(
"
/me
"
)
.
then
(
function
(
profile
)
{
.
then
(
function
(
profile
)
{
// build query
// build query
token
=
"
person_token_
"
+
provider
;
token
=
"
person_token_
"
+
provider
;
query
=
app
.
generateQueryObject
(
query
=
app
.
generateQueryObject
(
{
"
limit
"
:
[
0
,
1
]},
{
"
limit
"
:
[
0
,
1
]},
"
Person
"
,
"
Person
"
,
token
,
token
,
profile
.
id
profile
.
id
...
@@ -4127,9 +4127,8 @@
...
@@ -4127,9 +4127,8 @@
"
response
"
:
[
user
],
"
response
"
:
[
user
],
"
pass
"
:
{
"
type
"
:
"
Person
"
}
"
pass
"
:
{
"
type
"
:
"
Person
"
}
});
});
}
else
{
util
.
error
({
"
error
"
:
"
regiser user: need account sync!
"
});
}
}
util
.
error
({
"
error
"
:
"
regiser user: need account sync!
"
});
}
}
})
})
.
fail
(
util
.
error
);
.
fail
(
util
.
error
);
...
@@ -4212,11 +4211,11 @@
...
@@ -4212,11 +4211,11 @@
// wait 500ms on multi-state sorting (table), single state trigger directly
// wait 500ms on multi-state sorting (table), single state trigger directly
app
.
timer
=
window
.
setTimeout
(
function
()
{
app
.
timer
=
window
.
setTimeout
(
function
()
{
app
.
setContent
(
app
.
setContent
(
{
"
generate
"
:
"
gadget
"
,
"
id
"
:
config
.
id
,
"
href
"
:
config
.
id
},
{
"
generate
"
:
"
gadget
"
,
"
id
"
:
config
.
id
,
"
href
"
:
config
.
id
},
{
"
fragment_list
"
:
config
.
state
.
fragment_list
},
{
"
fragment_list
"
:
config
.
state
.
fragment_list
},
false
false
)
)
.
then
(
function
(
reply
)
{
.
then
(
function
(
reply
)
{
factory
.
util
.
updatePageSection
(
config
.
id
,
reply
);
factory
.
util
.
updatePageSection
(
config
.
id
,
reply
);
})
})
.
fail
(
util
.
error
);
.
fail
(
util
.
error
);
...
@@ -4350,7 +4349,7 @@
...
@@ -4350,7 +4349,7 @@
start
=
config
.
state
.
query
.
limit
[
0
];
start
=
config
.
state
.
query
.
limit
[
0
];
records
=
parseInt
(
value
,
null
);
records
=
parseInt
(
value
,
null
);
break
;
break
;
}
;
}
if
(
start
>
config
.
state
.
total
||
start
<
0
)
{
if
(
start
>
config
.
state
.
total
||
start
<
0
)
{
return
;
return
;
...
@@ -4366,14 +4365,15 @@
...
@@ -4366,14 +4365,15 @@
// update gadget
// update gadget
app
.
setContent
(
app
.
setContent
(
{
"
generate
"
:
"
gadget
"
,
"
id
"
:
config
.
id
,
"
href
"
:
config
.
id
},
{
"
generate
"
:
"
gadget
"
,
"
id
"
:
config
.
id
,
"
href
"
:
config
.
id
},
{
"
fragment_list
"
:
config
.
state
.
fragment_list
},
{
"
fragment_list
"
:
config
.
state
.
fragment_list
},
false
false
)
)
.
then
(
function
(
reply
)
{
.
then
(
function
(
reply
)
{
factory
.
util
.
updatePageSection
(
config
.
id
,
reply
);
factory
.
util
.
updatePageSection
(
config
.
id
,
reply
);
})
})
.
fail
(
util
.
error
);
.
fail
(
util
.
error
);
}
else
{
}
else
{
util
.
error
({
"
Error
"
:
"
No state information stored for gadget
"
});
util
.
error
({
"
Error
"
:
"
No state information stored for gadget
"
});
}
}
...
@@ -4406,16 +4406,16 @@
...
@@ -4406,16 +4406,16 @@
content
=
[{
content
=
[{
"
type
"
:
"
a
"
,
"
type
"
:
"
a
"
,
"
direct
"
:
{
"
direct
"
:
{
"
href
"
:
"
#
"
,
"
href
"
:
"
#
"
,
"
className
"
:
"
ui-corner-all ui-btn ui-shadow ui-btn-inline
"
+
"
className
"
:
"
ui-corner-all ui-btn ui-shadow ui-btn-inline
"
+
"
ui-icon-chevron-sign-left ui-btn-icon-left translate
"
"
ui-icon-chevron-sign-left ui-btn-icon-left translate
"
},
},
"
attributes
"
:
{
"
attributes
"
:
{
"
data-rel
"
:
"
back
"
,
"
data-rel
"
:
"
back
"
,
"
data-i18n
"
:
"
global_dict.pagination_dict.back
"
"
data-i18n
"
:
"
global_dict.pagination_dict.back
"
},
},
"
logic
"
:
{
"
Text
"
:
"
Back
"
}
"
logic
"
:
{
"
Text
"
:
"
Back
"
}
}]
}]
;
}
}
// <p> is not flexible...
// <p> is not flexible...
...
@@ -4443,11 +4443,11 @@
...
@@ -4443,11 +4443,11 @@
* @param {object} response Object initiating the status update
* @param {object} response Object initiating the status update
* @param {string} portal_type Portal Type concerned
* @param {string} portal_type Portal Type concerned
**/
**/
app
.
setLoginStatus
=
function
(
response
,
portal_type
)
{
app
.
setLoginStatus
=
function
(
response
)
{
var
stamp
,
provider
,
auth
,
links
,
i
,
login
;
var
stamp
,
provider
,
auth
,
links
,
i
,
login
;
stamp
=
Date
.
now
();
stamp
=
Date
.
now
();
provider
=
response
.
network
?
response
.
network
.
slice
(
0
,
2
)
:
"
self
"
;
provider
=
response
.
network
?
response
.
network
.
slice
(
0
,
2
)
:
"
self
"
;
auth
=
response
.
authResponse
;
auth
=
response
.
authResponse
;
if
(
flux
.
state
===
undefined
)
{
if
(
flux
.
state
===
undefined
)
{
...
@@ -4459,7 +4459,7 @@
...
@@ -4459,7 +4459,7 @@
"
token
"
:
auth
?
auth
.
access_token
:
response
.
id
,
"
token
"
:
auth
?
auth
.
access_token
:
response
.
id
,
"
issued
"
:
stamp
,
"
issued
"
:
stamp
,
"
expires
"
:
auth
?
auth
.
expires_in
:
3600
"
expires
"
:
auth
?
auth
.
expires_in
:
3600
}
}
;
// need to update the .... button
// need to update the .... button
// TODO: make a login gadget, store dependend buttons in state
// TODO: make a login gadget, store dependend buttons in state
links
=
util
.
getHeader
().
getElementsByTagName
(
"
A
"
);
links
=
util
.
getHeader
().
getElementsByTagName
(
"
A
"
);
...
@@ -4485,14 +4485,14 @@
...
@@ -4485,14 +4485,14 @@
// TODO: make this work with a regular login, too!!!
// TODO: make this work with a regular login, too!!!
// TODO: refactor, make sure we always pass a pass!
// TODO: refactor, make sure we always pass a pass!
app
.
checkLoginStatus
=
function
(
skip
,
pass
)
{
app
.
checkLoginStatus
=
function
(
skip
,
pass
)
{
var
state
,
lookup
,
logger
,
provider
,
verify
,
url
,
influx
,
info
,
var
state
,
logger
,
provider
,
verify
,
url
,
signee
,
valid
,
auth_config
,
valid
,
auth_config
,
stamp
,
expires
,
expired
,
token
,
auth_response
,
stamp
,
expires
,
auth_response
;
signee
;
if
(
skip
===
undefined
)
{
if
(
skip
===
undefined
)
{
// TODO: name collusion! make normal pass object!
// TODO: name collusion! make normal pass object!
return
RSVP
.
resolve
({
"
pass
"
:
skip
});
return
RSVP
.
resolve
({
"
pass
"
:
skip
});
}
else
{
}
logger
=
app
.
default_dict
.
state_dict
.
login_pointer
;
logger
=
app
.
default_dict
.
state_dict
.
login_pointer
;
verify
=
app
.
default_dict
.
state_dict
.
verification_dict
;
verify
=
app
.
default_dict
.
state_dict
.
verification_dict
;
...
@@ -4523,11 +4523,10 @@
...
@@ -4523,11 +4523,10 @@
}
}
// test for timeout
// test for timeout
if
(
auth_config
.
issued
&&
auth_config
.
expires
)
{
if
(
auth_config
.
issued
&&
auth_config
.
expires
)
{
expires
=
auth_config
.
issued
+
(
auth_config
.
expires
*
1000
);
expires
=
auth_config
.
issued
+
(
auth_config
.
expires
*
1000
);
if
(
expires
>
stamp
)
{
if
(
expires
>
stamp
)
{
valid
=
true
;
valid
=
true
;
}
else
{
}
else
{
expired
=
true
;
delete
state
[
provider
];
delete
state
[
provider
];
}
}
}
}
...
@@ -4550,7 +4549,7 @@
...
@@ -4550,7 +4549,7 @@
// if we have a url, we have an access token, check if it's valid
// if we have a url, we have an access token, check if it's valid
if
(
url
)
{
if
(
url
)
{
return
util
.
ajax
({
"
url
"
:
url
})
return
util
.
ajax
({
"
url
"
:
url
})
.
then
(
function
(
answer
)
{
.
then
(
function
(
answer
)
{
auth_response
=
util
.
parseIfNeeded
(
answer
.
target
.
response
);
auth_response
=
util
.
parseIfNeeded
(
answer
.
target
.
response
);
if
(
pass
)
{
if
(
pass
)
{
pass
.
active_login
=
true
;
pass
.
active_login
=
true
;
...
@@ -4560,9 +4559,8 @@
...
@@ -4560,9 +4559,8 @@
return
RSVP
.
resolve
(
pass
);
return
RSVP
.
resolve
(
pass
);
}
}
return
auth_response
;
return
auth_response
;
return
util
.
parseIfNeeded
(
answer
.
target
.
response
);
})
})
.
fail
(
function
(
event
)
{
.
fail
(
function
(
event
)
{
// invalid session > return 400, so we are back on the then-column
// invalid session > return 400, so we are back on the then-column
if
(
event
.
target
.
status
===
400
)
{
if
(
event
.
target
.
status
===
400
)
{
auth_response
=
util
.
parseIfNeeded
(
event
.
target
.
response
);
auth_response
=
util
.
parseIfNeeded
(
event
.
target
.
response
);
...
@@ -4580,10 +4578,8 @@
...
@@ -4580,10 +4578,8 @@
return
RSVP
.
resolve
(
pass
);
return
RSVP
.
resolve
(
pass
);
}
}
return
RSVP
.
resolve
({
"
error
"
:
"
no state found/not logged in
"
});
return
RSVP
.
resolve
({
"
error
"
:
"
no state found/not logged in
"
});
}
else
{
util
.
error
({
"
error
"
:
"
loginStatus: Missing login handler.
"
});
}
}
}
util
.
error
({
"
error
"
:
"
loginStatus: Missing login handler.
"
});
};
};
/**
/**
...
@@ -4598,31 +4594,17 @@
...
@@ -4598,31 +4594,17 @@
// TODO: refactor, this is quite the crap...
// TODO: refactor, this is quite the crap...
// TODO: don't reset all 4 fields on every action!
// TODO: don't reset all 4 fields on every action!
app
.
updateInfoElement
=
function
(
element
,
options
,
total
,
selected
)
{
app
.
updateInfoElement
=
function
(
element
,
options
,
total
,
selected
)
{
var
i
,
var
i
,
j
,
l
,
selection
,
info_field
,
min
,
pointer
,
no_items
,
j
,
text_snippet
,
i18n_snippet
,
zero_no_show
,
select_counter
,
no_limit
,
k
,
slot
,
first
,
last
,
info
,
info_field_list
,
generateInfo
;
l
,
reference
,
info_field_list
=
element
.
querySelectorAll
(
"
.info
"
);
selection
,
info
=
""
;
info_field
,
min
,
pointer
,
text_snippet
,
i18n_snippet
,
zero_no_show
,
select_counter
,
no_limit
,
no_items
,
slot
,
first
,
last
,
info_field_list
=
element
.
querySelectorAll
(
"
.info
"
),
info
=
""
,
generateInfo
=
function
(
text
,
text_i18n
)
{
generateInfo
=
function
(
text
,
text_i18n
)
{
return
factory
.
element
(
return
factory
.
element
(
"
span
"
,
"
span
"
,
{
"
className
"
:
"
translate
"
},
{
"
className
"
:
"
translate
"
},
{
"
data-i18n
"
:
"
global_dict.info_dict.
"
+
text_i18n
},
{
"
data-i18n
"
:
"
global_dict.info_dict.
"
+
text_i18n
},
{
"
text
"
:
text
}
{
"
text
"
:
text
}
);
);
};
};
...
@@ -4651,7 +4633,10 @@
...
@@ -4651,7 +4633,10 @@
no_limit
=
options
.
limit
[
0
]
||
0
;
no_limit
=
options
.
limit
[
0
]
||
0
;
no_items
=
options
.
limit
[
1
]
||
0
;
no_items
=
options
.
limit
[
1
]
||
0
;
zero_no_show
=
(
no_limit
===
0
&&
total
!==
0
)
?
1
:
no_limit
;
zero_no_show
=
(
no_limit
===
0
&&
total
!==
0
)
?
1
:
no_limit
;
min
=
Math
.
min
(
total
,
((
no_limit
+
no_items
===
0
)
?
(
total
)
:
no_limit
+
no_items
));
min
=
Math
.
min
(
total
,
((
no_limit
+
no_items
===
0
)
?
total
:
no_limit
+
no_items
)
);
info
=
zero_no_show
+
"
-
"
+
min
+
"
/
"
+
total
;
info
=
zero_no_show
+
"
-
"
+
min
+
"
/
"
+
total
;
text_snippet
=
"
Records
"
;
text_snippet
=
"
Records
"
;
i18n_snippet
=
"
records
"
;
i18n_snippet
=
"
records
"
;
...
@@ -4771,16 +4756,12 @@
...
@@ -4771,16 +4756,12 @@
// WARNING: complex_queries dependency!
// WARNING: complex_queries dependency!
// TODO: make "foo" = "bar" handle more complexity passed via ... url
// TODO: make "foo" = "bar" handle more complexity passed via ... url
app
.
generateQueryObject
=
function
(
query
,
type
,
key
,
value
,
field_list
)
{
app
.
generateQueryObject
=
function
(
query
,
type
,
key
,
value
,
field_list
)
{
var
parameter
,
var
property
,
wrap
,
query_object
,
query_clean
,
default_query
,
obj
,
property
,
is_value
;
wrap
,
query_object
,
query_clean
,
default_query
=
query
||
{},
obj
=
{},
is_value
=
value
&&
value
!==
""
;
obj
.
query
=
''
;
default_query
=
query
||
{};
obj
=
{
"
query
"
:
''
};
is_value
=
value
&&
value
!==
""
;
// query string passed? parse it
// query string passed? parse it
if
(
default_query
.
query
)
{
if
(
default_query
.
query
)
{
...
@@ -4818,7 +4799,13 @@
...
@@ -4818,7 +4799,13 @@
wrap
=
""
;
wrap
=
""
;
for
(
property
in
field_list
)
{
for
(
property
in
field_list
)
{
if
(
field_list
.
hasOwnProperty
(
property
))
{
if
(
field_list
.
hasOwnProperty
(
property
))
{
if
(
!
util
.
findKey
((
query_object
||
{}),
"
query_list
"
,
"
key
"
,
property
))
{
if
(
!
util
.
findKey
(
(
query_object
||
{}),
"
query_list
"
,
"
key
"
,
property
)
)
{
wrap
+=
property
+
'
: "%
'
+
value
+
'
%" OR
'
;
wrap
+=
property
+
'
: "%
'
+
value
+
'
%" OR
'
;
}
}
}
}
...
@@ -4865,10 +4852,10 @@
...
@@ -4865,10 +4852,10 @@
* @return {object} pointer object
* @return {object} pointer object
*/
*/
app
.
generateLinkObject
=
function
(
url
)
{
app
.
generateLinkObject
=
function
(
url
)
{
var
i
,
query
,
pa
rameter
,
pa
th
,
clean_hash
,
config
,
backup
;
var
i
,
query
,
path
,
clean_hash
,
config
,
backup
;
path
=
$
.
mobile
.
path
.
parseUrl
(
url
.
replace
(
$
.
mobile
.
dialogHashKey
,
""
))
,
path
=
$
.
mobile
.
path
.
parseUrl
(
url
.
replace
(
$
.
mobile
.
dialogHashKey
,
""
))
;
clean_hash
=
path
.
hash
.
replace
(
"
#
"
,
""
)
,
clean_hash
=
path
.
hash
.
replace
(
"
#
"
,
""
)
;
backup
=
0
;
backup
=
0
;
config
=
{
config
=
{
"
url
"
:
url
"
url
"
:
url
...
@@ -4885,7 +4872,7 @@
...
@@ -4885,7 +4872,7 @@
// TODO: this should be generic and without a backup....
// TODO: this should be generic and without a backup....
for
(
i
=
0
;
i
<
query
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
query
.
length
;
i
+=
1
)
{
switch
(
query
[
i
])
{
switch
(
query
[
i
])
{
case
"
new
"
:
case
"
new
"
:
config
.
mode
=
"
new
"
;
config
.
mode
=
"
new
"
;
backup
=
1
;
backup
=
1
;
...
@@ -4897,7 +4884,7 @@
...
@@ -4897,7 +4884,7 @@
case
"
config
"
:
case
"
config
"
:
config
.
mode
=
"
config
"
;
config
.
mode
=
"
config
"
;
break
;
break
;
}
;
}
}
}
config
.
fragment_list
=
clean_hash
.
split
(
"
::
"
);
config
.
fragment_list
=
clean_hash
.
split
(
"
::
"
);
...
@@ -4967,7 +4954,7 @@
...
@@ -4967,7 +4954,7 @@
if
(
title
&&
i18n
)
{
if
(
title
&&
i18n
)
{
translation
=
map
.
actions
.
translateLookup
(
translation
=
map
.
actions
.
translateLookup
(
"
page_dict.
"
+
title
.
split
(
"
?
"
)[
0
]
+
"
.title
"
"
page_dict.
"
+
title
.
split
(
"
?
"
)[
0
]
+
"
.title
"
)
)
;
translation_failed
=
util
.
testForString
(
title
,
translation
,
true
);
translation_failed
=
util
.
testForString
(
title
,
translation
,
true
);
}
}
// return link element
// return link element
...
@@ -5048,30 +5035,36 @@
...
@@ -5048,30 +5035,36 @@
add
=
doc
.
addEventListener
?
'
addEventListener
'
:
'
attachEvent
'
,
add
=
doc
.
addEventListener
?
'
addEventListener
'
:
'
attachEvent
'
,
rem
=
doc
.
addEventListener
?
'
removeEventListener
'
:
'
detachEvent
'
,
rem
=
doc
.
addEventListener
?
'
removeEventListener
'
:
'
detachEvent
'
,
pre
=
doc
.
addEventListener
?
''
:
'
on
'
,
pre
=
doc
.
addEventListener
?
''
:
'
on
'
,
init
=
function
(
e
)
{
init
=
function
(
e
)
{
if
(
e
.
type
==
'
readystatechange
'
&&
doc
.
readyState
!
=
'
complete
'
)
{
if
(
e
.
type
==
=
'
readystatechange
'
&&
doc
.
readyState
!=
=
'
complete
'
)
{
return
;
return
;
}
}
(
e
.
type
==
'
load
'
?
win
:
doc
)[
rem
](
pre
+
e
.
type
,
init
,
false
);
(
e
.
type
===
'
load
'
?
win
:
doc
)[
rem
](
pre
+
e
.
type
,
init
,
false
);
if
(
!
done
&&
(
done
=
true
))
{
if
(
!
done
)
{
done
=
true
;
fn
.
call
(
win
,
e
.
type
||
e
);
fn
.
call
(
win
,
e
.
type
||
e
);
}
}
},
},
poll
=
function
()
{
poll
=
function
()
{
try
{
try
{
root
.
doScroll
(
'
left
'
);
root
.
doScroll
(
'
left
'
);
}
catch
(
e
)
{
}
catch
(
e
)
{
setTimeout
(
poll
,
50
);
return
;
window
.
setTimeout
(
poll
,
50
);
return
;
}
}
init
(
'
poll
'
);
init
(
'
poll
'
);
};
};
if
(
doc
.
readyState
==
'
complete
'
)
{
if
(
doc
.
readyState
==
=
'
complete
'
)
{
fn
.
call
(
win
,
'
lazy
'
);
fn
.
call
(
win
,
'
lazy
'
);
}
else
{
}
else
{
if
(
doc
.
createEventObject
&&
root
.
doScroll
)
{
if
(
doc
.
createEventObject
&&
root
.
doScroll
)
{
try
{
top
=
!
win
.
frameElement
;
}
catch
(
e
)
{
}
try
{
if
(
top
)
poll
();
top
=
!
win
.
frameElement
;
}
catch
(
ignore
)
{}
if
(
top
)
{
poll
();
}
}
}
doc
[
add
](
pre
+
'
DOMContentLoaded
'
,
init
,
false
);
doc
[
add
](
pre
+
'
DOMContentLoaded
'
,
init
,
false
);
doc
[
add
](
pre
+
'
readystatechange
'
,
init
,
false
);
doc
[
add
](
pre
+
'
readystatechange
'
,
init
,
false
);
...
@@ -5086,14 +5079,14 @@
...
@@ -5086,14 +5079,14 @@
* @return {object} response object/promise
* @return {object} response object/promise
*/
*/
app
.
generateGadgetContent
=
function
(
reply
)
{
app
.
generateGadgetContent
=
function
(
reply
)
{
var
selector
,
element
,
pass
,
constructor
,
translate
,
data
,
data_set
;
var
selector
,
element
,
pass
,
constructor
,
data
,
data_set
;
pass
=
reply
.
pass
;
pass
=
reply
.
pass
;
constructor
=
map
.
gadgets
[
pass
.
constructor
];
constructor
=
map
.
gadgets
[
pass
.
constructor
];
if
(
constructor
===
undefined
)
{
if
(
constructor
===
undefined
)
{
return
util
.
error
(
return
util
.
error
(
{
"
error
"
:
"
generateGadgetContent: Missing constructor
"
}
{
"
error
"
:
"
generateGadgetContent: Missing constructor
"
}
);
);
}
}
...
@@ -5105,14 +5098,16 @@
...
@@ -5105,14 +5098,16 @@
data
=
null
;
data
=
null
;
}
}
// overwrite depending on new and allow_new
// overwrite depending on new and allow_new
if
(
pass
.
mode
===
"
new
"
&&
(
data_set
||
pass
.
config
.
property_dict
.
allow_new
))
{
if
(
pass
.
mode
===
"
new
"
&&
(
data_set
||
pass
.
config
.
property_dict
.
allow_new
))
{
data
=
{
"
request_new
"
:
true
};
data
=
{
"
request_new
"
:
true
};
}
}
// no content? Just call constructor and DONE!
// no content? Just call constructor and DONE!
if
(
pass
.
skip
)
{
if
(
pass
.
skip
)
{
return
constructor
(
pass
.
content_dict
,
pass
.
url_dict
);
return
constructor
(
pass
.
content_dict
,
pass
.
url_dict
);
}
else
{
}
// generate content
// generate content
element
=
constructor
(
element
=
constructor
(
pass
.
config
,
pass
.
config
,
...
@@ -5155,7 +5150,7 @@
...
@@ -5155,7 +5150,7 @@
selector
.
state
=
pass
.
state
;
selector
.
state
=
pass
.
state
;
// not auth, no mojo!
// not auth, no mojo!
if
(
pass
.
no_auth
||
(
pass
.
auth
&&
pass
.
active_login
||
if
(
pass
.
no_auth
||
((
pass
.
auth
&&
pass
.
active_login
)
||
pass
.
mode
===
"
new
"
))
{
pass
.
mode
===
"
new
"
))
{
app
.
updateInfoElement
(
app
.
updateInfoElement
(
...
@@ -5166,7 +5161,6 @@
...
@@ -5166,7 +5161,6 @@
}
}
return
element
;
return
element
;
}
};
};
/**
/**
...
@@ -5221,7 +5215,7 @@
...
@@ -5221,7 +5215,7 @@
* @return {object} response object/promise
* @return {object} response object/promise
*/
*/
app
.
fetchDataTotal
=
function
(
reply
)
{
app
.
fetchDataTotal
=
function
(
reply
)
{
var
pass
=
reply
.
pass
,
reference
,
identifier
,
search_string
;
var
pass
=
reply
.
pass
,
reference
;
if
(
pass
.
skip
===
undefined
)
{
if
(
pass
.
skip
===
undefined
)
{
// create or update state object
// create or update state object
...
@@ -5265,7 +5259,7 @@
...
@@ -5265,7 +5259,7 @@
}
}
if
(
pass
.
skip
===
undefined
&&
if
(
pass
.
skip
===
undefined
&&
(
pass
.
no_auth
||
(
pass
.
auth
&&
pass
.
active_login
||
(
pass
.
no_auth
||
((
pass
.
auth
&&
pass
.
active_login
)
||
(
pass
.
mode
===
"
new
"
||
pass
.
purge
))))
{
(
pass
.
mode
===
"
new
"
||
pass
.
purge
))))
{
// skip total for single item layouts!
// skip total for single item layouts!
...
@@ -5302,7 +5296,7 @@
...
@@ -5302,7 +5296,7 @@
pass
=
reply
.
pass
;
pass
=
reply
.
pass
;
if
(
reply
.
response
)
{
if
(
reply
.
response
)
{
store
=
storage
[
"
items
"
]
;
store
=
storage
.
items
;
items
=
util
.
parseIfNeeded
(
reply
.
response
);
items
=
util
.
parseIfNeeded
(
reply
.
response
);
if
(
store
&&
items
.
length
>
0
)
{
if
(
store
&&
items
.
length
>
0
)
{
...
@@ -5330,7 +5324,7 @@
...
@@ -5330,7 +5324,7 @@
}
}
promises
[
i
]
=
store
[
method
||
"
post
"
](
obj
)
promises
[
i
]
=
store
[
method
||
"
post
"
](
obj
)
.
then
(
function
(
answer
)
{
.
then
(
function
(
answer
)
{
return
answer
;
return
answer
;
});
});
}
}
...
@@ -5372,7 +5366,7 @@
...
@@ -5372,7 +5366,7 @@
return
util
.
ajax
(
return
util
.
ajax
(
{
"
url
"
:
"
data/
"
+
pass
.
config
.
portal_type_title
+
"
_sample.json
"
}
{
"
url
"
:
"
data/
"
+
pass
.
config
.
portal_type_title
+
"
_sample.json
"
}
)
)
.
then
(
function
(
e
)
{
.
then
(
function
(
e
)
{
return
{
return
{
"
response
"
:
e
.
target
.
response
,
"
response
"
:
e
.
target
.
response
,
"
pass
"
:
pass
"
pass
"
:
pass
...
@@ -5435,7 +5429,7 @@
...
@@ -5435,7 +5429,7 @@
// fetch field definitions
// fetch field definitions
if
(
pass
.
skip
===
undefined
&&
if
(
pass
.
skip
===
undefined
&&
(
pass
.
no_auth
||
(
pass
.
auth
&&
pass
.
active_login
||
(
pass
.
no_auth
||
((
pass
.
auth
&&
pass
.
active_login
)
||
pass
.
mode
===
"
new
"
))
&&
pass
.
mode
===
"
new
"
))
&&
pass
.
config
.
portal_type_fields
)
{
pass
.
config
.
portal_type_fields
)
{
...
@@ -5475,16 +5469,16 @@
...
@@ -5475,16 +5469,16 @@
// test for authentication
// test for authentication
if
(
pass
.
auth
)
{
if
(
pass
.
auth
)
{
return
app
.
checkLoginStatus
(
true
,
pass
)
return
app
.
checkLoginStatus
(
true
,
pass
)
.
then
(
function
(
new_pass
)
{
.
then
(
function
(
new_pass
)
{
return
{
return
{
"
pass
"
:
new_pass
"
pass
"
:
new_pass
}
}
;
})
})
.
fail
(
util
.
error
);
.
fail
(
util
.
error
);
}
}
return
{
return
{
"
pass
"
:
pass
"
pass
"
:
pass
}
}
;
};
};
/**
/**
...
@@ -5499,14 +5493,14 @@
...
@@ -5499,14 +5493,14 @@
// TODO: make this always return a promise. Requires to refactor listview!
// TODO: make this always return a promise. Requires to refactor listview!
// TODO: only pass around what we need. pass.CONFIG is too much!
// TODO: only pass around what we need. pass.CONFIG is too much!
app
.
setContent
=
function
(
content_dict
,
url_dict
,
create
,
purge
)
{
app
.
setContent
=
function
(
content_dict
,
url_dict
,
create
,
purge
)
{
var
i
,
skip
,
container
,
target
,
pass
,
spec
,
dependency
;
var
pass
,
spec
;
spec
=
url_dict
||
{};
spec
=
url_dict
||
{};
switch
(
content_dict
.
generate
)
{
switch
(
content_dict
.
generate
)
{
case
"
widget
"
:
case
"
widget
"
:
return
factory
[
content_dict
.
type
](
content_dict
,
spec
,
create
)
return
factory
[
content_dict
.
type
](
content_dict
,
spec
,
create
);
case
"
gadget
"
:
case
"
gadget
"
:
// no portal_type, no dynamic data
// no portal_type, no dynamic data
...
@@ -5546,10 +5540,8 @@
...
@@ -5546,10 +5540,8 @@
})
})
.
then
(
app
.
parseConfiguration
)
.
then
(
app
.
parseConfiguration
)
.
then
(
app
.
loadFieldDefinition
)
.
then
(
app
.
loadFieldDefinition
)
// ===== SAMPLE DATA ========
.
then
(
app
.
testStorageForData
)
.
then
(
app
.
testStorageForData
)
.
then
(
app
.
retrieveSampleData
)
.
then
(
app
.
retrieveSampleData
)
// ===== SAMPLE DATA ========
.
then
(
app
.
store
)
.
then
(
app
.
store
)
.
then
(
app
.
fetchDataTotal
)
.
then
(
app
.
fetchDataTotal
)
.
then
(
app
.
fetchDataQuery
)
.
then
(
app
.
fetchDataQuery
)
...
@@ -5560,7 +5552,7 @@
...
@@ -5560,7 +5552,7 @@
switch
(
content_dict
.
type
)
{
switch
(
content_dict
.
type
)
{
case
"
input
"
:
case
"
input
"
:
case
"
select
"
:
case
"
select
"
:
return
factory
.
formElement
(
content_dict
,
false
)
return
factory
.
formElement
(
content_dict
,
false
);
default
:
default
:
return
factory
.
element
(
return
factory
.
element
(
content_dict
.
type
,
content_dict
.
type
,
...
@@ -5617,7 +5609,7 @@
...
@@ -5617,7 +5609,7 @@
"
file
"
:
parcel
.
file
,
"
file
"
:
parcel
.
file
,
"
attachment
"
:
parcel
.
attachment
,
"
attachment
"
:
parcel
.
attachment
,
"
pass
"
:
parcel
.
pass
"
pass
"
:
parcel
.
pass
})
});
}
}
// NOTE: throw to get back in success chain!!!
// NOTE: throw to get back in success chain!!!
throw
error
;
throw
error
;
...
@@ -5660,15 +5652,14 @@
...
@@ -5660,15 +5652,14 @@
if
(
url
===
undefined
)
{
if
(
url
===
undefined
)
{
if
(
property_dict
.
optional
)
{
if
(
property_dict
.
optional
)
{
return
RSVP
.
all
([]);
return
RSVP
.
all
([]);
}
else
{
util
.
error
({
"
error
"
:
"
getFromDisk: URL undefined
"
});
}
}
util
.
error
({
"
error
"
:
"
getFromDisk: URL undefined
"
});
}
}
// fetch file
// fetch file
return
util
.
ajax
({
"
url
"
:
url
})
return
util
.
ajax
({
"
url
"
:
url
})
.
then
(
function
(
e
)
{
.
then
(
function
(
e
)
{
response
=
response
=
util
.
parseIfNeeded
(
e
.
target
.
responseText
);
response
=
util
.
parseIfNeeded
(
e
.
target
.
responseText
);
// no need to store? go to next then()
// no need to store? go to next then()
if
(
property_dict
.
skip
)
{
if
(
property_dict
.
skip
)
{
...
@@ -5690,8 +5681,10 @@
...
@@ -5690,8 +5681,10 @@
})
})
.
then
(
function
()
{
.
then
(
function
()
{
return
storage_location
.
putAttachment
({
return
storage_location
.
putAttachment
({
"
_id
"
:
(
property_dict
.
file
||
app
.
default_dict
.
storage_dict
.
settings
),
"
_id
"
:
(
property_dict
.
file
||
"
_attachment
"
:
(
property_dict
.
attachment
||
app
.
default_dict
.
storage_dict
.
configuration
),
app
.
default_dict
.
storage_dict
.
settings
),
"
_attachment
"
:
(
property_dict
.
attachment
||
app
.
default_dict
.
storage_dict
.
configuration
),
"
_data
"
:
JSON
.
stringify
(
response
),
"
_data
"
:
JSON
.
stringify
(
response
),
"
_mimetype
"
:
"
application/json
"
"
_mimetype
"
:
"
application/json
"
});
});
...
@@ -5898,13 +5891,9 @@
...
@@ -5898,13 +5891,9 @@
*/
*/
// TODO: add local popups!
// TODO: add local popups!
app
.
setPageBindings
=
function
()
{
app
.
setPageBindings
=
function
()
{
var
i
,
var
i
,
j
,
form_element
,
filterable
,
captcha
,
form_list
,
filter_list
;
j
,
form_element
,
form_list
=
document
.
getElementsByTagName
(
"
form
"
);
filterable
,
captcha
,
result
,
form_list
=
document
.
getElementsByTagName
(
"
form
"
),
filter_list
=
document
.
querySelectorAll
(
"
[data-filter]
"
);
filter_list
=
document
.
querySelectorAll
(
"
[data-filter]
"
);
// disable default filtering of JQM filterable
// disable default filtering of JQM filterable
...
@@ -5927,7 +5916,7 @@
...
@@ -5927,7 +5916,7 @@
if
(
captcha
)
{
if
(
captcha
)
{
util
.
declareJS
(
util
.
declareJS
(
"
http://www.google.com/recaptcha/api/js/recaptcha_ajax.js
"
"
http://www.google.com/recaptcha/api/js/recaptcha_ajax.js
"
).
then
(
function
(
e
)
{
).
then
(
function
(
)
{
Recaptcha
.
create
(
Recaptcha
.
create
(
captcha
.
getAttribute
(
"
data-key
"
),
captcha
.
getAttribute
(
"
data-key
"
),
captcha
.
id
,
captcha
.
id
,
...
@@ -5976,96 +5965,6 @@
...
@@ -5976,96 +5965,6 @@
*/
*/
util
.
storage_dict
=
{};
util
.
storage_dict
=
{};
/**
* cookie handler
* thx: https://developer.mozilla.org/en-US/docs/Web/API/document.cookie
* @object handleCookie
**/
util
.
cookieHandler
=
{
/**
* Get a cookie
* @method getItem
* @param {string} sKey Cookie name
* @return {string} cookie value
**/
getItem
:
function
(
sKey
)
{
return
decodeURIComponent
(
document
.
cookie
.
replace
(
new
RegExp
(
"
(?:(?:^|.*;)
\\
s*
"
+
encodeURIComponent
(
sKey
).
replace
(
/
[\-\.\+\*]
/g
,
"
\\
$&
"
)
+
"
\\
s*
\\
=
\\
s*([^;]*).*$)|^.*$
"
),
"
$1
"
))
||
null
;
},
/**
* Set a cookie
* @method setItem
* @param {string} sKey Cookie name
* @param {string} sValue Cookie value
* @param {string} sPath Cookie path
* @param {string} sDomain Cookie domain
* @param {string} bSecure Cookie security flag
* @return {boolean} true/false
**/
setItem
:
function
(
sKey
,
sValue
,
vEnd
,
sPath
,
sDomain
,
bSecure
)
{
if
(
!
sKey
||
/^
(?:
expires|max
\-
age|path|domain|secure
)
$/i
.
test
(
sKey
))
{
return
false
;
}
var
sExpires
=
""
;
if
(
vEnd
)
{
switch
(
vEnd
.
constructor
)
{
case
Number
:
sExpires
=
vEnd
===
Infinity
?
"
; expires=Fri, 31 Dec 9999 23:59:59 GMT
"
:
"
; max-age=
"
+
vEnd
;
break
;
case
String
:
sExpires
=
"
; expires=
"
+
vEnd
;
break
;
case
Date
:
sExpires
=
"
; expires=
"
+
vEnd
.
toUTCString
();
break
;
}
}
document
.
cookie
=
encodeURIComponent
(
sKey
)
+
"
=
"
+
encodeURIComponent
(
sValue
)
+
sExpires
+
(
sDomain
?
"
; domain=
"
+
sDomain
:
""
)
+
(
sPath
?
"
; path=
"
+
sPath
:
""
)
+
(
bSecure
?
"
; secure
"
:
""
);
return
true
;
},
/**
* Remove a cookie
* @method removeItem
* @param {string} sKey Name of the cookie
* @param {string} sPath Cookie path
* @param {string} sDomain Cookie domain
* @return {boolean} true/falsely
**/
removeItem
:
function
(
sKey
,
sPath
,
sDomain
)
{
if
(
!
sKey
||
!
this
.
hasItem
(
sKey
))
{
return
false
;
}
document
.
cookie
=
encodeURIComponent
(
sKey
)
+
"
=; expires=Thu, 01 Jan 1970 00:00:00 GMT
"
+
(
sDomain
?
"
; domain=
"
+
sDomain
:
""
)
+
(
sPath
?
"
; path=
"
+
sPath
:
""
);
return
true
;
},
/**
* Check if a cookie exists
* @method hasItem
* @param {string} Cookie name
* @return true/false
**/
hasItem
:
function
(
sKey
)
{
return
(
new
RegExp
(
"
(?:^|;
\\
s*)
"
+
encodeURIComponent
(
sKey
).
replace
(
/
[\-\.\+\*]
/g
,
"
\\
$&
"
)
+
"
\\
s*
\\
=
"
)).
test
(
document
.
cookie
);
}
};
/**
/**
* Generate a UUID ticket for a transaction
* Generate a UUID ticket for a transaction
* @method generateUuid
* @method generateUuid
...
@@ -6095,15 +5994,16 @@
...
@@ -6095,15 +5994,16 @@
var
s
=
''
,
var
s
=
''
,
randomchar
=
function
()
{
randomchar
=
function
()
{
var
n
=
Math
.
floor
(
Math
.
random
()
*
62
);
var
n
=
Math
.
floor
(
Math
.
random
()
*
62
);
if
(
n
<
10
)
{
if
(
n
<
10
)
{
return
n
;
//1-10
return
n
;
//1-10
}
}
if
(
n
<
36
)
{
if
(
n
<
36
)
{
return
String
.
fromCharCode
(
n
+
55
);
//A-Z
return
String
.
fromCharCode
(
n
+
55
);
//A-Z
}
}
return
String
.
fromCharCode
(
n
+
61
);
//a-z
return
String
.
fromCharCode
(
n
+
61
);
//a-z
}
};
while
(
s
.
length
<
len
)
{
while
(
s
.
length
<
len
)
{
s
+=
randomchar
();
s
+=
randomchar
();
}
}
return
s
;
return
s
;
...
@@ -6206,7 +6106,7 @@
...
@@ -6206,7 +6106,7 @@
* @param {string} theme background theme
* @param {string} theme background theme
* @param {string} icon Which icon to display when overriding the loader
* @param {string} icon Which icon to display when overriding the loader
*/
*/
util
.
loader
=
function
(
message
,
msg_i18n
,
icon
,
theme
)
{
util
.
loader
=
function
(
message
,
msg_i18n
,
icon
)
{
var
text_to_display
=
i18n
&&
msg_i18n
?
var
text_to_display
=
i18n
&&
msg_i18n
?
map
.
actions
.
translateLookup
(
msg_i18n
)
:
message
;
map
.
actions
.
translateLookup
(
msg_i18n
)
:
message
;
...
@@ -6444,12 +6344,13 @@
...
@@ -6444,12 +6344,13 @@
);
);
container
=
factory
.
element
(
container
=
factory
.
element
(
"
p
"
,
{
"
class
"
:
"
responsive ui-content-element
"
}
"
p
"
,
{
"
class
"
:
"
responsive ui-content-element
"
}
);
);
container
.
appendChild
(
factory
.
element
(
container
.
appendChild
(
factory
.
element
(
"
span
"
,
"
span
"
,
{
"
class
"
:
"
translate
"
},
{
"
class
"
:
"
translate
"
},
{
"
data-i18n
"
:
"
validation.fail.browser_support
"
},
{
"
data-i18n
"
:
"
validation.fail.browser_support
"
},
{
"
text
"
:
"
Your browser does not support:
"
}
{
"
text
"
:
"
Your browser does not support:
"
}
));
));
container
.
appendChild
(
factory
.
element
(
container
.
appendChild
(
factory
.
element
(
...
@@ -6462,10 +6363,10 @@
...
@@ -6462,10 +6363,10 @@
return
false
;
return
false
;
}
}
return
true
;
return
true
;
}
else
{
}
util
.
error
({
"
error
"
:
"
testBrowserSupport: Modernizr undefined
"
});
util
.
error
({
"
error
"
:
"
testBrowserSupport: Modernizr undefined
"
});
return
false
;
return
false
;
}
};
};
/* ====================================================================== */
/* ====================================================================== */
...
@@ -6473,7 +6374,7 @@
...
@@ -6473,7 +6374,7 @@
/* ====================================================================== */
/* ====================================================================== */
/**
/**
* Capture errors, log to console and trigger bugticker
* Capture errors, log to console and trigger bugticker
* @method error
Handler
* @method error
* @param {object} err Error object
* @param {object} err Error object
*/
*/
// TODO: update global config so we know where to post a ticket to!
// TODO: update global config so we know where to post a ticket to!
...
@@ -6504,7 +6405,7 @@
...
@@ -6504,7 +6405,7 @@
app
.
getFromDisk
({
app
.
getFromDisk
({
"
url
"
:
util
.
getPathFromScriptTag
(
"
data-storage
"
),
"
url
"
:
util
.
getPathFromScriptTag
(
"
data-storage
"
),
"
optional
"
:
true
,
"
optional
"
:
true
,
"
skip
"
:
true
"
skip
"
:
true
})
})
.
then
(
app
.
setContent
)
.
then
(
app
.
setContent
)
...
...
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