Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
nexedi
ecommerce-ui
Commits
0ea54899
Commit
0ea54899
authored
11 years ago
by
Sven Franck
Browse files
Options
Download
Email Patches
Plain Diff
linting
parent
a6188c92
Changes
32
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1874 additions
and
1686 deletions
+1874
-1686
js/main.js
js/main.js
+75
-73
modules/core/app/app.js
modules/core/app/app.js
+349
-341
modules/core/config/config.js
modules/core/config/config.js
+43
-32
modules/core/extensions/extensions.js
modules/core/extensions/extensions.js
+199
-183
modules/core/overrides/overrides.js
modules/core/overrides/overrides.js
+2
-0
modules/core/storage/storage.js
modules/core/storage/storage.js
+713
-691
modules/core/utilities/utilities.js
modules/core/utilities/utilities.js
+15
-13
modules/ui/address/address.js
modules/ui/address/address.js
+16
-12
modules/ui/basket/basket.js
modules/ui/basket/basket.js
+16
-10
modules/ui/confirm/confirm.js
modules/ui/confirm/confirm.js
+15
-10
modules/ui/details/details.js
modules/ui/details/details.js
+55
-42
modules/ui/footer/footer.js
modules/ui/footer/footer.js
+14
-10
modules/ui/gallery/gallery.js
modules/ui/gallery/gallery.js
+83
-60
modules/ui/header/header.js
modules/ui/header/header.js
+13
-18
modules/ui/index/index.js
modules/ui/index/index.js
+13
-9
modules/ui/item/item.js
modules/ui/item/item.js
+79
-72
modules/ui/items/items.js
modules/ui/items/items.js
+64
-45
modules/ui/login/login.js
modules/ui/login/login.js
+16
-12
modules/ui/media/media.js
modules/ui/media/media.js
+14
-10
modules/ui/pagination/pagination.js
modules/ui/pagination/pagination.js
+80
-43
No files found.
js/main.js
View file @
0ea54899
/*jslint indent: 2, maxlen: 80, todo: true, nomen: true */
/*global document: true, require: true */
(
function
()
{
"
use strict
"
;
var
IS_LOCAL
=
/
(
:
\/\/
localhost|file:
\/\/)
/
.
test
(
document
.
location
.
href
);
require
.
config
({
waitSeconds
:
(
IS_LOCAL
?
10
:
45
)
,
paths
:
{
waitSeconds
:
(
IS_LOCAL
?
10
:
45
),
paths
:
{
// core
app
:
'
../modules/core/app/app
'
,
config
:
'
../modules/core/config/config
'
,
polyfill
:
'
../modules/core/polyfill/polyfill
'
,
overrides
:
'
../modules/core/overrides/overrides
'
,
utilities
:
'
../modules/core/utilities/utilities
'
,
extensions
:
'
../modules/core/extensions/extensions
'
,
storage
:
'
../modules/core/storage/storage
'
app
:
'
../modules/core/app/app
'
,
config
:
'
../modules/core/config/config
'
,
polyfill
:
'
../modules/core/polyfill/polyfill
'
,
overrides
:
'
../modules/core/overrides/overrides
'
,
utilities
:
'
../modules/core/utilities/utilities
'
,
extensions
:
'
../modules/core/extensions/extensions
'
,
storage
:
'
../modules/core/storage/storage
'
,
// requireJs
,
almond
:
'
../js/libs/require/almond
'
,
text
:
'
../js/libs/require/text
'
,
css
:
'
../js/plugins/require-css/require-css
'
,
normalize
:
'
../js/plugins/require-css/normalize
'
,
json
:
'
../js/plugins/requirejs-plugins/json
'
,
async
:
'
../js/plugins/requirejs-plugins/async
'
almond
:
'
../js/libs/require/almond
'
,
text
:
'
../js/libs/require/text
'
,
css
:
'
../js/plugins/require-css/require-css
'
,
normalize
:
'
../js/plugins/require-css/normalize
'
,
json
:
'
../js/plugins/requirejs-plugins/json
'
,
async
:
'
../js/plugins/requirejs-plugins/async
'
,
// support
,
modernizr
:
'
../js/plugins/modernizr
'
,
selectivzr
:
'
../js/plugins/selectivzr
'
modernizr
:
'
../js/plugins/modernizr
'
,
selectivzr
:
'
../js/plugins/selectivzr
'
,
// plugins/libs
,
jquery
:
'
../js/libs/jquery/jquery
'
,
jqm
:
'
../js/libs/jquery-mobile/jquery-mobile
'
,
i18next
:
'
../js/plugins/i18next/i18next
'
,
renderjs
:
'
../js/plugins/renderjs/renderjs
'
,
jio
:
'
../js/libs/jio/jio
'
,
md5
:
'
../js/libs/jio/md5
'
,
localstorage
:
'
../js/libs/jio/localstorage
'
,
indexstorage
:
'
../js/libs/jio/indexstorage
'
,
complex_queries
:
'
../js/libs/jio/complex_queries
'
,
validval
:
'
../js/plugins/validval/validval
'
jquery
:
'
../js/libs/jquery/jquery
'
,
jqm
:
'
../js/libs/jquery-mobile/jquery-mobile
'
,
i18next
:
'
../js/plugins/i18next/i18next
'
,
renderjs
:
'
../js/plugins/renderjs/renderjs
'
,
jio
:
'
../js/libs/jio/jio
'
,
md5
:
'
../js/libs/jio/md5
'
,
localstorage
:
'
../js/libs/jio/localstorage
'
,
indexstorage
:
'
../js/libs/jio/indexstorage
'
,
complex_queries
:
'
../js/libs/jio/complex_queries
'
,
validval
:
'
../js/plugins/validval/validval
'
,
// page gadgets
,
address
:
'
../modules/ui/address/address
'
,
basket
:
'
../modules/ui/basket/basket
'
,
pagination
:
'
../modules/ui/pagination/pagination
'
,
confirm
:
'
../modules/ui/confirm/confirm
'
,
details
:
'
../modules/ui/details/details
'
,
footer
:
'
../modules/ui/footer/footer
'
,
gallery
:
'
../modules/ui/gallery/gallery
'
,
header
:
'
../modules/ui/header/header
'
,
index
:
'
../modules/ui/index/index
'
,
item
:
'
../modules/ui/item/item
'
,
items
:
'
../modules/ui/items/items
'
,
login
:
'
../modules/ui/login/login
'
,
media
:
'
../modules/ui/media/media
'
,
payment
:
'
../modules/ui/payment/payment
'
,
refine
:
'
../modules/ui/refine/refine
'
,
register
:
'
../modules/ui/register/register
'
,
products
:
'
../modules/ui/products/products
'
,
searchbar
:
'
../modules/ui/searchbar/searchbar
'
,
seo
:
'
../modules/ui/seo/seo
'
,
shipment
:
'
../modules/ui/shipment/shipment
'
,
sorting
:
'
../modules/ui/sorting/sorting
'
,
summary
:
'
../modules/ui/summary/summary
'
,
teaser
:
'
../modules/ui/teaser/teaser
'
,
terms
:
'
../modules/ui/terms/terms
'
,
translate
:
'
../modules/ui/translate/translate
'
,
pageheader
:
'
../modules/ui/pageheader/pageheader
'
,
pagefooter
:
'
../modules/ui/pagefooter/pagefooter
'
}
,
shim
:
{
'
jqm
'
:
{
deps
:
[
'
jquery
'
],
exports
:
'
mobile
'
}
,
'
jio
'
:
{
deps
:
[
'
md5
'
]
}
,
'
localstorage
'
:
{
deps
:
[
'
jio
'
,
'
complex_queries
'
]
}
,
'
indexstorage
'
:
{
deps
:
[
'
jio
'
]
}
,
'
renderjs
'
:
{
deps
:
[
'
jquery
'
],
exports
:
'
RenderJs
'
}
,
'
app
'
:
{
deps
:
[
'
jio
'
],
exports
:
'
App
'
}
,
'
validval
'
:
{
deps
:
[
'
jquery
'
]
}
}
,
map
:
{
address
:
'
../modules/ui/address/address
'
,
basket
:
'
../modules/ui/basket/basket
'
,
pagination
:
'
../modules/ui/pagination/pagination
'
,
confirm
:
'
../modules/ui/confirm/confirm
'
,
details
:
'
../modules/ui/details/details
'
,
footer
:
'
../modules/ui/footer/footer
'
,
gallery
:
'
../modules/ui/gallery/gallery
'
,
header
:
'
../modules/ui/header/header
'
,
index
:
'
../modules/ui/index/index
'
,
item
:
'
../modules/ui/item/item
'
,
items
:
'
../modules/ui/items/items
'
,
login
:
'
../modules/ui/login/login
'
,
media
:
'
../modules/ui/media/media
'
,
payment
:
'
../modules/ui/payment/payment
'
,
refine
:
'
../modules/ui/refine/refine
'
,
register
:
'
../modules/ui/register/register
'
,
products
:
'
../modules/ui/products/products
'
,
searchbar
:
'
../modules/ui/searchbar/searchbar
'
,
seo
:
'
../modules/ui/seo/seo
'
,
shipment
:
'
../modules/ui/shipment/shipment
'
,
sorting
:
'
../modules/ui/sorting/sorting
'
,
summary
:
'
../modules/ui/summary/summary
'
,
teaser
:
'
../modules/ui/teaser/teaser
'
,
terms
:
'
../modules/ui/terms/terms
'
,
translate
:
'
../modules/ui/translate/translate
'
,
pageheader
:
'
../modules/ui/pageheader/pageheader
'
,
pagefooter
:
'
../modules/ui/pagefooter/pagefooter
'
}
,
shim
:
{
'
jqm
'
:
{
deps
:
[
'
jquery
'
],
exports
:
'
mobile
'
}
,
'
jio
'
:
{
deps
:
[
'
md5
'
]
}
,
'
localstorage
'
:
{
deps
:
[
'
jio
'
,
'
complex_queries
'
]
}
,
'
indexstorage
'
:
{
deps
:
[
'
jio
'
]
}
,
'
renderjs
'
:
{
deps
:
[
'
jquery
'
],
exports
:
'
RenderJs
'
}
,
'
app
'
:
{
deps
:
[
'
jio
'
],
exports
:
'
App
'
}
,
'
validval
'
:
{
deps
:
[
'
jquery
'
]
}
}
,
map
:
{
'
*
'
:
{
'
css
'
:
'
../js/plugins/require-css/css
'
}
...
...
@@ -86,12 +87,11 @@
});
require
([
'
app
'
,
'
config
'
],
function
(
App
,
Config
)
{
require
([
'
app
'
,
'
config
'
],
function
(
App
,
Config
)
{
var
setup
=
new
$
.
Deferred
();
var
spec
=
{};
var
i
;
var
def
;
var
i
,
setup
=
new
$
.
Deferred
(),
spec
=
{};
spec
.
app
=
App
;
spec
.
config
=
Config
;
...
...
@@ -100,16 +100,18 @@
// fallback for fast browsers...
spec
.
fallbackLoader
=
{
deferreds
:
[],
args
:
[]
,
args
:
[]
};
// expose App once everything is loaded
spec
.
setup
.
done
(
function
(
App
,
Config
)
{
spec
.
setup
.
done
(
function
(
App
,
Config
)
{
// expose configuration - settings
App
.
settings
=
Config
.
settings
;
// expose configuration - storages
App
.
storage
=
Config
.
storage
;
// expose errors
App
.
errors
=
[];
for
(
i
=
0
;
i
<
window
.
fallbackLoader
.
deferreds
.
length
;
i
+=
1
)
{
window
.
fallbackLoader
.
deferreds
[
i
]
...
...
This diff is collapsed.
Click to expand it.
modules/core/app/app.js
View file @
0ea54899
This diff is collapsed.
Click to expand it.
modules/core/config/config.js
View file @
0ea54899
/*jslint indent: 2, maxlen: 80, nomen: true */
/*global document: true, require: true, define: true, RenderJs: true */
define
([
'
app
'
,
'
storage
'
,
'
utilities
'
,
'
async
'
],
function
(
App
,
storage
)
{
'
storage
'
,
'
app
'
,
'
utilities
'
,
'
async
'
],
function
(
storage
)
{
"
use strict
"
;
var
priv
=
{}
;
var
that
=
{};
var
priv
=
{}
,
that
=
{};
// set return object
that
.
settings
=
{};
...
...
@@ -23,11 +25,11 @@ define([
spec
.
framed
=
"
medium
"
;
if
(
$
.
mobile
.
media
(
"
screen and (max-width:20em)
"
)
||
(
$
.
mobile
.
browser
.
oldIE
&&
$
(
window
).
width
()
<
o
.
lowerThresh
))
{
spec
.
framed
=
"
small
"
;
(
$
.
mobile
.
browser
.
oldIE
&&
$
(
window
).
width
()
<
spec
.
lowerThresh
))
{
spec
.
framed
=
"
small
"
;
}
else
if
(
$
.
mobile
.
media
(
"
screen and (min-width:45em)
"
)
||
(
$
.
mobile
.
browser
.
oldIE
&&
$
(
window
).
width
()
>=
o
.
upperThresh
))
{
spec
.
framed
=
"
large
"
;
(
$
.
mobile
.
browser
.
oldIE
&&
$
(
window
).
width
()
>=
spec
.
upperThresh
))
{
spec
.
framed
=
"
large
"
;
}
return
spec
.
framed
;
};
...
...
@@ -36,17 +38,24 @@ define([
if
(
spec
.
response
===
undefined
)
{
// TODO: this defaults could be set somewhere else as well
spec
.
config
.
settings
.
language_default
=
"
en-EN
"
;
spec
.
config
.
settings
.
language_current
=
spec
.
config
.
settings
.
language_default
;
spec
.
config
.
settings
.
language_current
=
spec
.
config
.
settings
.
language_default
;
spec
.
config
.
settings
.
language_selector
=
"
translate
"
;
spec
.
config
.
settings
.
language_set
=
"
false
"
;
spec
.
config
.
settings
.
item_selector
=
"
item_id
"
;
}
else
{
// create application settings
spec
.
config
.
settings
.
language_default
=
spec
.
response
.
language_default
||
"
en-EN
"
;
spec
.
config
.
settings
.
language_current
=
spec
.
response
.
language_current
||
spec
.
config
.
settings
.
language_default
;
spec
.
config
.
settings
.
language_selector
=
spec
.
response
.
selector
||
"
translate
"
;
spec
.
config
.
settings
.
language_set
=
spec
.
response
.
language_set
||
"
false
"
;
spec
.
config
.
settings
.
item_selector
=
spec
.
response
.
item_selector
||
"
item_id
"
;
spec
.
config
.
settings
.
language_default
=
spec
.
response
.
language_default
||
"
en-EN
"
;
spec
.
config
.
settings
.
language_current
=
spec
.
response
.
language_current
||
spec
.
config
.
settings
.
language_default
;
spec
.
config
.
settings
.
language_selector
=
spec
.
response
.
selector
||
"
translate
"
;
spec
.
config
.
settings
.
language_set
=
spec
.
response
.
language_set
||
"
false
"
;
spec
.
config
.
settings
.
item_selector
=
spec
.
response
.
item_selector
||
"
item_id
"
;
}
spec
.
config
.
settings
.
screen_format
=
priv
.
setScreenDimensions
();
...
...
@@ -60,7 +69,7 @@ define([
// store settings
if
(
data
!==
undefined
)
{
// add to localstorage
data
[
"
_id
"
]
=
"
config
"
;
data
.
_id
=
"
config
"
;
storage
.
queryStorage
({
"
storage
"
:
"
settings
"
,
...
...
@@ -75,15 +84,16 @@ define([
};
// fallback: collect configuration from file
$
.
getJSON
(
"
http://www.franckreich.de/members/export/x/configuration.json?callback=?
"
,
function
(
data
)
{
priv
.
config_call
(
data
);
}
"
http://www.franckreich.de/members/export/x/
"
+
"
configuration.json?callback=?
"
,
function
(
data
)
{
priv
.
config_call
(
data
);
}
);
//
require(
//
["async!http://www.franckreich.de/members/export/x/configuration.json"],
//
config_call
//
);
// require(
// ["async!http://www.franckreich.de/members/export/x/configuration.json"],
// config_call
// );
};
that
.
set
=
function
(
param
)
{
...
...
@@ -91,19 +101,20 @@ define([
spec
.
storage
=
"
settings
"
;
spec
.
method
=
"
get
"
;
spec
.
doc
=
{
"
_id
"
:
"
config
"
};
spec
.
doc
=
{
"
_id
"
:
"
config
"
};
spec
.
callback
=
function
(
err
,
response
)
{
spec
.
callback
=
function
(
err
,
response
)
{
if
(
err
)
{
priv
.
JSONPfallback
(
param
);
}
param
.
response
=
response
;
priv
.
setApplicationSetters
(
param
);
}
}
;
storage
.
queryStorage
(
spec
);
}
}
;
// return config
return
that
;
}
);
);
This diff is collapsed.
Click to expand it.
modules/core/extensions/extensions.js
View file @
0ea54899
/*jslint indent: 2, maxlen: 80, nomen: true */
/*global document: true, require: true, $: true, define: true, jQuery: true */
define
([
'
jquery
'
,
'
jqm
'
,
'
css!extensions
'
'
jquery
'
,
'
jqm
'
,
'
css!extensions
'
],
function
(
$
)
{
"
use strict
"
;
// this module adds extensions to JQM
// jslinted!
/* ========================= GALLERY WIDGET ========================= */
(
function
(
$
,
undefined
)
{
$
.
widget
(
"
mobile.carousel
"
,
{
options
:
{
bullets
:
null
,
bulletsPos
:
null
,
inset
:
null
,
captions
:
null
,
captionpos
:
null
,
captiontheme
:
null
,
carouseltransition
:
null
,
heading
:
"
h1,h2,h3,h4,h5,h6,legend
"
},
_transitionEndEvents
:
"
webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd
"
,
_create
:
function
()
{
var
el
=
this
.
element
[
0
],
o
=
this
.
options
,
getAttrFixed
=
$
.
mobile
.
getAttribute
;
// only time we read the DOM config
o
.
inset
=
getAttrFixed
(
el
,
"
inset
"
,
true
)
||
false
;
o
.
carouseltransition
=
getAttrFixed
(
el
,
"
transition
"
,
true
)
||
"
slide
"
;
o
.
bullets
=
getAttrFixed
(
el
,
"
bullets
"
,
true
)
||
true
;
o
.
captions
=
getAttrFixed
(
el
,
"
captions
"
,
true
)
||
false
;
(
function
(
$
)
{
if
(
o
.
captions
)
{
o
.
captionspos
=
getAttrFixed
(
el
,
"
captions-pos
"
,
true
)
||
"
bottom
"
;
o
.
captionstheme
=
getAttrFixed
(
el
,
"
captions-theme
"
,
true
)
||
"
a
"
;
}
if
(
o
.
bullets
)
{
o
.
bulletsPos
=
getAttrFixed
(
el
,
"
bulletsPos
"
,
true
)
||
"
bottom
"
;
}
$
.
widget
(
"
mobile.carousel
"
,
{
this
.
refresh
(
true
);
},
refresh
:
function
(
create
)
{
var
o
=
this
.
options
,
el
=
this
.
element
,
items
=
el
.
children
(),
fragment
=
document
.
createDocumentFragment
(),
classes
=
"
ui-carousel
"
,
barrel
,
label
,
radio
,
item
,
i
,
transition
,
containsLinks
,
captionsContent
,
captionsHeading
;
// loop over images
for
(
i
=
0
;
i
<
items
.
length
;
i
+=
1
)
{
var
item
=
items
[
i
];
// create captions
if
(
o
.
captions
)
{
containsLinks
=
item
.
children
.
length
===
1
&&
item
.
children
[
0
].
tagName
===
"
A
"
;
captionsContent
=
$
(
item
)
.
find
(
containsLinks
?
"
a *
"
:
"
*
"
)
.
not
(
"
img
"
)
.
wrap
(
"
<div class='ui-carousel-captions-content ui-bar-
"
+
o
.
captionstheme
+
"
ui-carousel-captions-
"
+
o
.
captionspos
+
"
'></div>
"
)
.
parent
();
captionsHeading
=
captionsContent
.
find
(
o
.
heading
).
addClass
(
"
ui-carousel-captions-heading
"
);
}
options
:
{
bullets
:
null
,
bulletsPos
:
null
,
inset
:
null
,
captions
:
null
,
captionpos
:
null
,
captiontheme
:
null
,
carouseltransition
:
null
,
heading
:
"
h1,h2,h3,h4,h5,h6,legend
"
},
// create radios
if
(
o
.
bullets
)
{
// TODO: do this in jQuery...
radio
=
document
.
createElement
(
"
input
"
);
radio
.
setAttribute
(
"
type
"
,
'
radio
'
);
radio
.
setAttribute
(
"
name
"
,
'
radio-
'
+
this
.
uuid
);
radio
.
setAttribute
(
"
value
"
,
'
radio-
'
+
this
.
uuid
+
'
-
'
+
i
);
if
(
i
===
0
)
{
radio
.
checked
=
true
;
$
(
item
).
addClass
(
"
ui-carousel-active
"
);
}
// and use data()
radio
.
reference
=
$
(
item
);
label
=
document
.
createElement
(
"
label
"
);
label
.
setAttribute
(
"
data-
"
+
$
.
mobile
.
ns
+
"
iconpos
"
,
"
notext
"
);
label
.
appendChild
(
radio
);
fragment
.
appendChild
(
label
)
}
}
_transitionEndEvents
:
"
webkitTransitionEnd oTransitionEnd
"
+
"
otransitionend transitionend msTransitionEnd
"
,
if
(
o
.
inset
)
{
classes
+=
"
ui-carousel-inset
"
;
}
_create
:
function
()
{
var
el
=
this
.
element
[
0
],
o
=
this
.
options
,
getAttrFixed
=
$
.
mobile
.
getAttribute
;
// only time we read the DOM config
o
.
inset
=
getAttrFixed
(
el
,
"
inset
"
,
true
)
||
false
;
o
.
carouseltransition
=
getAttrFixed
(
el
,
"
transition
"
,
true
)
||
"
slide
"
;
o
.
bullets
=
getAttrFixed
(
el
,
"
bullets
"
,
true
)
||
true
;
o
.
captions
=
getAttrFixed
(
el
,
"
captions
"
,
true
)
||
false
;
if
(
o
.
captions
)
{
o
.
captionspos
=
getAttrFixed
(
el
,
"
captions-pos
"
,
true
)
||
"
bottom
"
;
o
.
captionstheme
=
getAttrFixed
(
el
,
"
captions-theme
"
,
true
)
||
"
a
"
;
}
if
(
o
.
bullets
)
{
o
.
bulletsPos
=
getAttrFixed
(
el
,
"
bulletsPos
"
,
true
)
||
"
bottom
"
;
}
this
.
refresh
(
true
);
},
refresh
:
function
(
create
)
{
var
o
=
this
.
options
,
el
=
this
.
element
,
items
=
el
.
children
(),
fragment
=
document
.
createDocumentFragment
(),
classes
=
"
ui-carousel
"
,
barrel
,
label
,
radio
,
item
,
i
,
containsLinks
,
captionsHeading
,
captionsContent
;
// loop over images
for
(
i
=
0
;
i
<
items
.
length
;
i
+=
1
)
{
item
=
items
[
i
];
// create captions
if
(
o
.
captions
)
{
classes
+=
"
ui-carousel-captions
"
;
containsLinks
=
item
.
children
.
length
===
1
&&
item
.
children
[
0
].
tagName
===
"
A
"
;
captionsContent
=
$
(
item
)
.
find
(
containsLinks
?
"
a *
"
:
"
*
"
)
.
not
(
"
img
"
)
.
wrap
(
"
<div class='ui-carousel-captions-content ui-bar-
"
+
o
.
captionstheme
+
"
ui-carousel-captions-
"
+
o
.
captionspos
+
"
'></div>
"
)
.
parent
();
captionsHeading
=
captionsContent
.
find
(
o
.
heading
).
addClass
(
"
ui-carousel-captions-heading
"
);
}
// create radios
if
(
o
.
bullets
)
{
classes
+=
"
ui-carousel-bullets
"
;
barrel
=
$
(
"
<div id='ui-carousel-barrel-
"
+
this
.
uuid
+
"
' class='ui-carousel-controls ui-carousel-controls-
"
+
o
.
bulletsPos
+
"
' />
"
)
while
(
fragment
.
firstChild
)
{
// browser hangs up if calling this inside append()
$
(
fragment
.
firstChild
).
children
().
checkboxradio
();
barrel
.
append
(
fragment
.
firstChild
);
}
// remove existing barrel
if
(
create
===
undefined
)
{
$
(
"
#ui-carousel-barrel-
"
+
this
.
uuid
).
remove
();
// TODO: do this in jQuery...
radio
=
document
.
createElement
(
"
input
"
);
radio
.
setAttribute
(
"
type
"
,
'
radio
'
);
radio
.
setAttribute
(
"
name
"
,
'
radio-
'
+
this
.
uuid
);
radio
.
setAttribute
(
"
value
"
,
'
radio-
'
+
this
.
uuid
+
'
-
'
+
i
);
if
(
i
===
0
)
{
radio
.
checked
=
true
;
$
(
item
).
addClass
(
"
ui-carousel-active
"
);
}
// this always needs to go before the slider
el
[
o
.
bulletsPos
===
"
top
"
?
"
before
"
:
"
after
"
](
barrel
);
// and use data()
radio
.
reference
=
$
(
item
);
label
=
document
.
createElement
(
"
label
"
);
label
.
setAttribute
(
"
data-
"
+
$
.
mobile
.
ns
+
"
iconpos
"
,
"
notext
"
);
label
.
appendChild
(
radio
);
this
.
_on
(
barrel
.
find
(
"
input
"
),
{
change
:
"
_onChange
"
}
);
fragment
.
appendChild
(
label
);
}
}
// all set, add classes
el
.
addClass
(
classes
);
},
if
(
o
.
inset
)
{
classes
+=
"
ui-carousel-inset
"
;
}
if
(
o
.
captions
)
{
classes
+=
"
ui-carousel-captions
"
;
}
if
(
o
.
bullets
)
{
classes
+=
"
ui-carousel-bullets
"
;
barrel
=
$
(
"
<div id='ui-carousel-barrel-
"
+
this
.
uuid
+
"
' class='ui-carousel-controls ui-carousel-controls-
"
+
o
.
bulletsPos
+
"
' />
"
);
while
(
fragment
.
firstChild
)
{
// browser hangs up if calling this inside append()
$
(
fragment
.
firstChild
).
children
().
checkboxradio
();
barrel
.
append
(
fragment
.
firstChild
);
}
// remove existing barrel
if
(
create
===
undefined
)
{
$
(
"
#ui-carousel-barrel-
"
+
this
.
uuid
).
remove
();
}
// this always needs to go before the slider
el
[
o
.
bulletsPos
===
"
top
"
?
"
before
"
:
"
after
"
](
barrel
);
this
.
_on
(
barrel
.
find
(
"
input
"
),
{
change
:
"
_onChange
"
});
}
// all set, add classes
el
.
addClass
(
classes
);
},
// _handleKeydown: function( event ) {
// var index = this._value();
...
...
@@ -146,7 +157,7 @@ define([
//
// if ( !this._keySliding ) {
// this._keySliding = true;
// this.handle.addClass( "ui-state-active" );
/* TODO: We don't use this class for styling. Do we need to add it? */
// this.handle.addClass( "ui-state-active" );
// }
//
// break;
...
...
@@ -166,7 +177,6 @@ define([
// _handleKeyup: function(/* event */) {
// if ( this._keySliding ) {
// this._keySliding = false;
// this.handle.removeClass( "ui-state-active" ); /* See comment above. */
// }
// },
...
...
@@ -188,55 +198,57 @@ define([
// }
// },
_completeTransition
:
function
(
current
,
next
,
events
)
{
var
self
=
this
,
o
=
self
.
options
;
next
.
removeClass
(
"
in out
"
+
o
.
carouseltransition
)
.
off
(
events
);
current
.
on
(
events
,
self
.
_cleanupTransition
(
current
,
events
)
)
},
_cleanupTransition
:
function
(
current
,
events
)
{
var
self
=
this
,
o
=
self
.
options
;
var
classes
=
o
.
carouseltransition
+
"
out in
"
;
current
.
removeClass
(
classes
)
current
.
removeClass
(
"
ui-carousel-active
"
).
off
(
events
);
},
_onChange
:
function
(
e
)
{
var
self
=
this
,
events
=
self
.
_transitionEndEvents
,
el
=
self
.
element
,
o
=
self
.
options
,
// elements
currentActive
=
el
.
children
().
filter
(
"
.ui-carousel-active
"
),
nextActive
=
e
.
target
.
reference
,
classes
=
o
.
carouseltransition
+
"
out in
"
,
transition
=
$
.
mobile
.
_maybeDegradeTransition
(
o
.
carouseltransition
);
// click on active radio
if
(
nextActive
.
hasClass
(
"
ui-carousel-active
"
))
{
return
;
}
_completeTransition
:
function
(
current
,
next
,
events
)
{
var
self
=
this
,
o
=
self
.
options
;
next
.
removeClass
(
"
in out
"
+
o
.
carouseltransition
)
.
off
(
events
);
current
.
on
(
events
,
self
.
_cleanupTransition
(
current
,
events
));
},
// initialize
nextActive
.
on
(
events
,
self
.
_completeTransition
(
currentActive
,
nextActive
,
events
));
nextActive
.
addClass
(
transition
+
"
ui-carousel-active in
"
);
_cleanupTransition
:
function
(
current
,
events
)
{
var
self
=
this
,
o
=
self
.
options
,
classes
=
o
.
carouseltransition
+
"
out in
"
;
current
.
removeClass
(
classes
);
current
.
removeClass
(
"
ui-carousel-active
"
).
off
(
events
);
},
_onChange
:
function
(
e
)
{
var
self
=
this
,
events
=
self
.
_transitionEndEvents
,
el
=
self
.
element
,
o
=
self
.
options
,
currentActive
=
el
.
children
().
filter
(
"
.ui-carousel-active
"
),
nextActive
=
e
.
target
.
reference
,
//classes = o.carouseltransition + " out in",
transition
=
$
.
mobile
.
_maybeDegradeTransition
(
o
.
carouseltransition
);
// click on active radio
if
(
nextActive
.
hasClass
(
"
ui-carousel-active
"
))
{
return
;
}
// initialize
nextActive
.
on
(
events
,
self
.
_completeTransition
(
currentActive
,
nextActive
,
events
));
nextActive
.
addClass
(
transition
+
"
ui-carousel-active in
"
);
}
});
$
.
mobile
.
carousel
.
initSelector
=
"
:jqmData(role='carousel')
"
;
//auto self-init widgets
$
.
mobile
.
_enhancer
.
add
(
"
mobile.carousel
"
);
$
.
mobile
.
_enhancer
.
add
(
"
mobile.carousel
"
);
}
)(
jQuery
);
}
(
jQuery
)
);
/* tranistion workflow
// first slide
if (init) {
...
...
@@ -281,71 +293,75 @@ define([
*/
/* ========================= ACTION BUTTON EXTENSION ==================== */
(
function
(
$
,
undefined
)
{
(
function
()
{
$
.
widget
(
"
mobile.textinput
"
,
$
.
mobile
.
textinput
,
{
$
.
widget
(
"
mobile.textinput
"
,
$
.
mobile
.
textinput
,
{
options
:
{
actionBtn
:
false
,
actionBtnText
:
"
Search
"
,
actionBtnIcon
:
"
search
"
,
actionBtnIcon
:
"
search
"
},
_create
:
function
(){
_create
:
function
()
{
this
.
_super
();
if
(
!!
this
.
options
.
actionBtn
||
this
.
isSearch
){
if
(
!!
this
.
options
.
actionBtn
||
this
.
isSearch
)
{
this
.
_addActionBtn
();
}
},
actionButton
:
function
(){
return
$
(
"
<a href='#' class='ui-input-action ui-btn ui-icon-
"
+
this
.
options
.
actionBtnIcon
+
"
ui-btn-icon-notext ui-corner-all
"
+
"
' title='
"
+
this
.
options
.
actionBtnText
+
"
'>
"
+
this
.
options
.
actionBtnText
+
"
</a>
"
);
actionButton
:
function
()
{
return
$
(
"
<a href='#' class='ui-input-action ui-btn ui-icon-
"
+
this
.
options
.
actionBtnIcon
+
"
ui-btn-icon-notext ui-corner-all
"
+
"
' title='
"
+
this
.
options
.
actionBtnText
+
"
'>
"
+
this
.
options
.
actionBtnText
+
"
</a>
"
);
},
_addActionBtn
:
function
(){
_addActionBtn
:
function
()
{
if
(
!
this
.
options
.
enhanced
)
{
if
(
!
this
.
options
.
enhanced
)
{
this
.
_enhanceAction
();
}
$
.
extend
(
this
,
{
$
.
extend
(
this
,
{
_actionBtn
:
this
.
widget
().
find
(
"
a.ui-input-action
"
)
});
},
_enhanceAction
:
function
()
{
this
.
actionButton
().
appendTo
(
this
.
widget
()
);
this
.
widget
().
addClass
(
"
ui-input-has-action ui-input-search-no-pseudo
"
);
_enhanceAction
:
function
()
{
this
.
actionButton
().
appendTo
(
this
.
widget
());
this
.
widget
().
addClass
(
"
ui-input-has-action ui-input-search-no-pseudo
"
);
},
_setOptions
:
function
(
options
)
{
this
.
_super
(
options
);
_setOptions
:
function
(
options
)
{
this
.
_super
(
options
);
if
(
options
.
actionBtn
!==
undefined
&&
!
this
.
element
.
is
(
"
textarea, :jqmData(type='range')
"
)
)
{
if
(
options
.
actionBtn
){
if
(
options
.
actionBtn
!==
undefined
&&
!
this
.
element
.
is
(
"
textarea, :jqmData(type='range')
"
))
{
if
(
options
.
actionBtn
)
{
this
.
_addActionBtn
();
}
else
{
this
.
_destroyAction
();
}
}
if
(
options
.
clearBtnText
!==
undefined
&&
this
.
_actionBtn
!==
undefined
)
{
this
.
_actionBtn
.
text
(
options
.
clearBtnText
);
if
(
options
.
clearBtnText
!==
undefined
&&
this
.
_actionBtn
!==
undefined
)
{
this
.
_actionBtn
.
text
(
options
.
clearBtnText
);
}
},
_destroyAction
:
function
()
{
this
.
element
.
removeClass
(
"
ui-input-has-clear
"
);
_destroyAction
:
function
()
{
this
.
element
.
removeClass
(
"
ui-input-has-clear
"
);
this
.
_actionBtn
.
remove
();
},
_destroy
:
function
()
{
_destroy
:
function
()
{
this
.
_super
();
this
.
_destroyAction
();
}
...
...
@@ -353,7 +369,7 @@ define([
});
})
(
jQuery
);
}
(
));
return
undefined
;
});
\ No newline at end of file
This diff is collapsed.
Click to expand it.
modules/core/overrides/overrides.js
View file @
0ea54899
/*jslint indent: 2, maxlen: 80, nomen: true */
/*global document: true, $: true, define: true, */
define
([
'
jquery
'
],
function
(
$
)
{
"
use strict
"
;
...
...
This diff is collapsed.
Click to expand it.
modules/core/storage/storage.js
View file @
0ea54899
This diff is collapsed.
Click to expand it.
modules/core/utilities/utilities.js
View file @
0ea54899
/*jslint indent: 2, maxlen: 80, nomen: true */
/*global document: true, define: true, $: true */
define
([
'
app
'
],
function
(
App
)
{
],
function
(
App
)
{
"
use strict
"
;
// this module provides generic methods usable across all gadgets/modules
var
that
=
{};
...
...
@@ -16,20 +19,19 @@ define([
if
(
matchesSelector
)
{
while
(
elem
)
{
if
(
matchesSelector
.
bind
(
elem
)(
selector
))
{
return
elem
;
}
else
{
elem
=
elem
.
parentNode
;
return
elem
;
}
}
return
false
;
}
else
{
// opera...
fallback
=
$
(
elem
).
closest
(
selector
);
if
(
fallback
.
length
>
0
)
{
return
fallback
;
elem
=
elem
.
parentNode
;
}
return
false
;
}
// opera...
fallback
=
$
(
elem
).
closest
(
selector
);
if
(
fallback
.
length
>
0
)
{
return
fallback
;
}
return
false
;
};
// object size
that
.
objectSize
=
function
(
obj
)
{
...
...
@@ -37,7 +39,7 @@ define([
for
(
key
in
obj
)
{
if
(
obj
.
hasOwnProperty
(
key
))
{
size
++
;
size
+=
1
;
}
}
return
size
;
...
...
@@ -47,4 +49,4 @@ define([
return
undefined
;
}
);
\ No newline at end of file
);
This diff is collapsed.
Click to expand it.
modules/ui/address/address.js
View file @
0ea54899
/*jslint indent: 2, maxlen: 80 */
/*global define: true, $: true, define: true, window: true */
define
([
'
app
'
,
'
text!address.html!strip
'
,
'
validval
'
,
'
css!address
'
],
function
(
App
,
source
,
validator
)
{
var
response
=
{};
'
app
'
,
'
text!address.html!strip
'
,
'
validval
'
,
'
css!address
'
],
function
(
App
,
source
)
{
"
use strict
"
;
var
response
=
{},
def
;
response
.
data
=
source
;
response
.
after
=
function
(
self
)
{
if
(
App
===
undefined
)
{
def
=
new
$
.
Deferred
;
def
=
new
$
.
Deferred
()
;
def
.
done
(
function
(
gadget
)
{
def
.
done
(
function
(
gadget
)
{
// prefix instance-ids, pass JSON
App
.
renderGadgets
(
gadget
);
});
...
...
@@ -25,7 +29,7 @@ define([
}
};
// return response object
return
response
;
// return response object
return
response
;
}
);
);
This diff is collapsed.
Click to expand it.
modules/ui/basket/basket.js
View file @
0ea54899
/*jslint indent: 2, maxlen: 80 */
/*global define: true, define: true, $: true, window: true */
define
([
'
app
'
,
'
text!basket.html!strip
'
,
'
css!basket
'
],
'
app
'
,
'
text!basket.html!strip
'
,
'
validval
'
,
'
css!basket
'
],
function
(
App
,
source
)
{
var
response
=
{};
"
use strict
"
;
var
response
=
{},
def
;
response
.
data
=
source
;
response
.
after
=
function
(
self
)
{
if
(
App
===
undefined
)
{
def
=
new
$
.
Deferred
;
def
=
new
$
.
Deferred
()
;
def
.
done
(
function
(
gadget
)
{
def
.
done
(
function
(
gadget
)
{
// prefix instance-ids, pass JSON
App
.
renderGadgets
(
gadget
);
});
...
...
@@ -24,7 +29,8 @@ define([
}
};
// return response object
return
response
;
// return response object
return
response
;
}
);
);
This diff is collapsed.
Click to expand it.
modules/ui/confirm/confirm.js
View file @
0ea54899
/*jslint indent: 2, maxlen: 80 */
/*global define: true, define: true, $: true, window: true */
define
([
'
app
'
,
'
text!confirm.html!strip
'
,
'
css!confirm
'
],
'
app
'
,
'
text!confirm.html!strip
'
,
'
validval
'
,
'
css!confirm
'
],
function
(
App
,
source
)
{
var
response
=
{};
"
use strict
"
;
var
response
=
{},
def
;
response
.
data
=
source
;
response
.
after
=
function
(
self
)
{
if
(
App
===
undefined
)
{
def
=
new
$
.
Deferred
;
def
=
new
$
.
Deferred
()
;
def
.
done
(
function
(
gadget
)
{
def
.
done
(
function
(
gadget
)
{
// prefix instance-ids, pass JSON
App
.
renderGadgets
(
gadget
);
});
...
...
@@ -24,7 +29,7 @@ define([
}
};
// return response object
return
response
;
// return response object
return
response
;
}
);
);
This diff is collapsed.
Click to expand it.
modules/ui/details/details.js
View file @
0ea54899
/*jslint indent: 2, maxlen: 80, nomen: true */
/*global define: true, $: true, define: true, window: true, App: true */
define
([
'
app
'
,
'
text!details.html!strip
'
,
'
css!details
'
],
'
app
'
,
'
text!details.html!strip
'
,
'
css!details
'
],
function
(
App
,
source
)
{
var
that
=
{};
var
priv
=
{};
"
use strict
"
;
var
that
=
{},
priv
=
{};
// cleanup memory
priv
.
cleanupMemory
=
function
(
memory
)
{
...
...
@@ -40,30 +44,33 @@ define([
var
id
,
now
,
spec
,
module
;
// we will have an item to display. Grab it and go!
if
(
location
.
search
!==
""
)
{
if
(
window
.
location
.
search
!==
""
)
{
spec
=
{};
spec
.
pointer
=
location
.
search
.
split
(
"
=
"
)[
1
];
spec
.
storage
=
"
items
"
spec
.
method
=
"
get
"
spec
.
doc
=
{
"
_id
"
:
spec
.
pointer
}
spec
.
pointer
=
window
.
location
.
search
.
split
(
"
=
"
)[
1
];
spec
.
storage
=
"
items
"
;
spec
.
method
=
"
get
"
;
spec
.
doc
=
{
"
_id
"
:
spec
.
pointer
}
;
// TODO: should be passed via JSON?
module
=
"
storage
"
;
now
=
new
Date
().
getTime
();
}
else
{
// route to all products
$
.
mobile
.
changePage
(
"
products.html
"
,
{
"
transition
"
:
"
fade
"
});
$
.
mobile
.
changePage
(
"
products.html
"
,
{
"
transition
"
:
"
fade
"
});
}
// jio response
spec
.
callback
=
function
(
err
,
response
)
{
spec
.
callback
=
function
(
err
,
response
)
{
if
(
err
)
{
// error handling
App
.
errors
.
push
({
module
:
"
details
"
,
timestamp
:
now
,
error
:
err
});
}
else
{
id
=
response
.
_id
;
App
.
cacheItems
[
id
]
=
[
response
,
now
];
// memory
...
...
@@ -72,7 +79,7 @@ define([
// this is not response.callback(!!)
params
.
callback_mockup
(
params
.
source
);
}
}
;
// query for items
App
[
module
].
switchboard
(
spec
);
};
...
...
@@ -89,36 +96,42 @@ define([
// TODO: this should also fetch the full document along with attachments,
// while all other request should only work with the "meta" data.
//
that.before = function (source, callback_mockup) {
//
var spec = {};
// that.before = function (source, callback_mockup) {
// var spec = {};
//
// spec.gadget = RenderJs.getSelfGadget();
// // TODO: this is for page event bindings. Once JQM content replaces
// // page, remove this and make the gadget the content section to
// // be updated.
// spec.page = App.util.closest(spec.gadget.dom.get(0), "div[data-role='page']");
// spec.pageId = "#" + spec.page.id;
// spec.source = source;
// spec.callback_mockup = callback_mockup;
// spec.gadget = RenderJs.getSelfGadget();
// // TODO: this is for page event bindings. Once JQM content replaces
// // page, remove this and make the gadget the content section to
// // be updated.
// spec.page = App.util.closest(
// spec.gadget.dom.get(0),
// "div[data-role='page']"
// );
// spec.pageId = "#" + spec.page.id;
// spec.source = source;
// spec.callback_mockup = callback_mockup;
//
//
if (!spec.page.getAttribute("events_details")) {
//
spec.page.setAttribute("events_details", true);
//
$(document).on(
"pagebeforeshow.details", spec.pageId, function (e, data) {
//
// TODO: if we allow to reload, we also need to trigger r
efresh
on
//
// so we need to reload this every time a page is shown. question
//
// is how to trigger a refresh on this element ONLY
//
priv.storeItem(spec);
//
});
// //
and run intial
// if (!spec.page.getAttribute("events_details")) {
// spec.page.setAttribute("events_details", true);
// $(document).on(
//
"pageb
ef
o
resh
ow.details",
//
spec.pageId,
//
function (e, data) {
//
// TODO: if we allow to reload, we also need to trigger refresh on
//
// so we need to reload this every time a page is shown. question
// //
is how to trigger a refresh on this element ONLY
// priv.storeItem(spec);
// }
// };
// });
// // and run intial
// priv.storeItem(spec);
// }
// };
that
.
after
=
function
(
self
)
{
if
(
App
===
undefined
)
{
def
=
new
$
.
Deferred
;
var
def
=
new
$
.
Deferred
()
;
def
.
done
(
function
(
gadget
)
{
def
.
done
(
function
(
gadget
)
{
// prefix instance-ids, pass JSON
App
.
renderGadgets
(
gadget
);
});
...
...
@@ -131,7 +144,7 @@ define([
}
};
// return response object
return
that
;
// return response object
return
that
;
}
);
);
This diff is collapsed.
Click to expand it.
modules/ui/footer/footer.js
View file @
0ea54899
/*jslint indent: 2, maxlen: 80 */
/*global define: true, define: true, $: true, window: true */
define
([
'
app
'
,
'
text!footer.html!strip
'
,
'
css!footer
'
],
'
app
'
,
'
text!footer.html!strip
'
,
'
css!footer
'
],
function
(
App
,
source
)
{
var
response
=
{};
"
use strict
"
;
var
response
=
{},
def
;
response
.
data
=
source
;
response
.
after
=
function
(
self
)
{
if
(
App
===
undefined
)
{
def
=
new
$
.
Deferred
;
def
=
new
$
.
Deferred
()
;
def
.
done
(
function
(
gadget
)
{
def
.
done
(
function
(
gadget
)
{
// prefix instance-ids, pass JSON
App
.
renderGadgets
(
gadget
);
});
...
...
@@ -24,7 +28,7 @@ define([
}
};
// return response object
return
response
;
// return response object
return
response
;
}
);
);
This diff is collapsed.
Click to expand it.
modules/ui/gallery/gallery.js
View file @
0ea54899
/*jslint indent: 2, maxlen: 80, nomen: true */
/*global define: true, $: true, define: true, window: true, App: true, RenderJs: true,
document: true */
define
([
'
app
'
,
'
text!gallery.html!strip
'
,
'
css!gallery
'
],
'
app
'
,
'
text!gallery.html!strip
'
,
'
css!gallery
'
],
function
(
App
,
source
)
{
var
that
=
{};
var
priv
=
{};
"
use strict
"
;
var
that
=
{},
priv
=
{};
// ========================== ATTRIBUTES ==============================
// set response, so it's available across function calls
priv
.
response
;
priv
.
response
=
undefined
;
priv
.
generateGallery
=
function
(
response
)
{
// expose response (will be overwritten, when next item loads
...
...
@@ -21,7 +26,7 @@ define([
// TODO: zoom is missing, this should also be a feature of gallery
// TODO: 404 fallback images!
// ala photoswipe
var
i
,
j
,
item
,
img
,
gallery
,
thumbnails
=
""
,
str
,
obj
,
variations
;
var
i
,
item
,
gallery
,
thumbnails
=
""
,
variations
;
gallery
=
"
<div class='gallery_wrap'><ul data-role='carousel'
"
+
"
data-inset='true' class='ui-responsive tester'
"
+
...
...
@@ -37,15 +42,18 @@ define([
variations
=
priv
.
response
.
dimensions
[
0
].
vars
;
if
(
variations
.
length
>
1
)
{
thumbnails
+=
"
<div class='gallery_thumbnails '><ul data-role='
"
+
"
listview' data-inset='true' class='gallery_thumbnail_wrapper'>
"
;
"
listview' data-inset='true' class='gallery_thumbnail_wrapper'>
"
;
for
(
i
=
0
;
i
<
variations
.
length
;
i
+=
1
)
{
item
=
variations
[
i
];
// thumbnails - click on link should trigger the display method
thumbnails
+=
"
<li data-icon='false'><a href='#
"
+
item
.
name
+
"
' class='
"
+
"
display_item'><img src='
"
+
response
.
media
+
item
.
media
.
img
[
0
][
"
t
"
]
+
"
' alt='
"
+
item
.
name
+
"
' /><h3 class='translate gallery_header' data-i18n='
"
+
thumbnails
+=
"
<li data-icon='false'><a href='#
"
+
item
.
name
+
"
' class='display_item'><img src='
"
+
response
.
media
+
item
.
media
.
img
[
0
].
t
+
"
' alt='
"
+
item
.
name
+
"
' /><h3 class='translate gallery_header' data-i18n='
"
+
item
.
i18n
+
"
'>
"
+
item
.
name
+
"
</h3></li>
"
;
}
thumbnails
+=
"
</ul></div>
"
;
...
...
@@ -54,7 +62,7 @@ define([
gallery
+=
"
</ul></div>
"
;
return
str
=
gallery
+
thumbnails
;
return
gallery
+
thumbnails
;
};
// TODO: show some thing
...
...
@@ -79,15 +87,19 @@ define([
// generate gallery list items
priv
.
generateGalleryItems
=
function
(
name
)
{
var
i
,
j
,
item
,
img
,
str
=
""
;
item
=
priv
.
response
.
dimensions
[
0
].
vars
[
0
];
var
i
,
j
,
img
,
str
=
""
,
// TODO: should not be hardcoded to first variation!!!
item
=
priv
.
response
.
dimensions
[
0
].
vars
[
0
],
screen
=
App
.
settings
.
screen_format
,
size
=
screen
===
"
small
"
?
"
small
"
:
"
medium
"
,
shortcut
=
size
.
substring
(
0
,
1
);
// find item name or default to first variant in dimension
if
(
name
!==
undefined
)
{
for
(
i
=
0
;
i
<
priv
.
response
.
dimensions
[
0
].
vars
.
length
;
i
+=
1
)
{
item
=
priv
.
response
.
dimensions
[
0
].
vars
[
i
];
if
(
item
.
name
===
name
||
location
.
hash
===
name
)
{
if
(
item
.
name
===
name
||
window
.
location
.
hash
===
name
)
{
break
;
}
}
...
...
@@ -99,10 +111,10 @@ define([
for
(
j
=
0
;
j
<
item
.
media
.
img
.
length
;
j
+=
1
)
{
img
=
item
.
media
.
img
[
j
];
// TODO: add zoom/photoswipe later!
str
+=
"
<li class='product_img'><a href='#'><img src='
"
+
priv
.
response
.
media
+
img
[
shortcut
]
+
size
+
"
' alt='
"
+
item
.
name
+
"
' />
"
+
"
<h3 class='translate gallery_header'
data-i18n='
"
+
item
.
i18n
+
"
'></h3></a></li>
"
;
str
+=
"
<li class='product_img'><a href='#'><img src='
"
+
priv
.
response
.
media
+
img
[
shortcut
]
+
size
+
"
' alt='
"
+
item
.
name
+
"
' />
"
+
"
<h3 class='translate gallery_header'
"
+
"
data-i18n='
"
+
item
.
i18n
+
"
'></h3></a></li>
"
;
}
return
str
;
...
...
@@ -120,17 +132,12 @@ define([
// generate items to display
priv
.
generateItems
=
function
(
params
)
{
var
markup
,
spec
,
response
;
var
markup
,
spec
,
id
=
params
.
gadget
.
dom
.
attr
(
'
id
'
).
split
(
"
__
"
).
splice
(
-
1
)[
0
],
config
=
params
.
gadget
.
state
[
0
][
id
].
_config
,
module
=
config
.
datasource
.
module
,
urlPointer
=
params
.
pointer
.
length
>
1
,
jsonPointer
=
config
.
datasource
.
pointer
,
// TODO: settable options
screen
=
App
.
settings
.
screen_format
,
size
=
screen
===
"
small
"
?
"
small
"
:
"
medium
"
,
shortcut
=
size
.
substring
(
0
,
1
);
jsonPointer
=
config
.
datasource
.
pointer
;
// if we have a pointer-array passed, query that
// TODO: this is not flexible yet, because "items" and "get" are hardcoded
...
...
@@ -138,9 +145,9 @@ define([
// what is stored on the image links...
if
(
urlPointer
)
{
spec
=
{};
spec
.
storage
=
"
items
"
spec
.
method
=
"
get
"
spec
.
doc
=
{
"
_id
"
:
params
.
pointer
[
1
]}
spec
.
storage
=
"
items
"
;
spec
.
method
=
"
get
"
;
spec
.
doc
=
{
"
_id
"
:
params
.
pointer
[
1
]}
;
}
if
(
jsonPointer
)
{
...
...
@@ -149,15 +156,28 @@ define([
// in the configuration file, as it's something the user can use or not
// also - should be possible to make this fullscreen by supplying the
// carousel options!
spec
.
items
=
[
{
"
src
"
:
"
img/stella.jpg
"
,
"
caption
"
:
"
Stella
"
,
"
i18n
"
:
"
custom.teaser.stella
"
,
"
href
"
:
"
products.html?search=stella
"
},
{
"
src
"
:
"
img/nannin.jpg
"
,
"
caption
"
:
"
Nan
"
,
"
i18n
"
:
"
custom.teaser.nan
"
,
"
href
"
:
"
products.html?search=nan
"
},
{
"
src
"
:
"
img/vila.jpg
"
,
"
caption
"
:
"
Vila
"
,
"
i18n
"
:
"
custom.teaser.vila
"
,
"
href
"
:
"
products.html?search=vila
"
}
]
spec
.
items
=
[{
"
src
"
:
"
img/stella.jpg
"
,
"
caption
"
:
"
Stella
"
,
"
i18n
"
:
"
custom.teaser.stella
"
,
"
href
"
:
"
products.html?search=stella
"
},
{
"
src
"
:
"
img/nannin.jpg
"
,
"
caption
"
:
"
Nan
"
,
"
i18n
"
:
"
custom.teaser.nan
"
,
"
href
"
:
"
products.html?search=nan
"
},
{
"
src
"
:
"
img/vila.jpg
"
,
"
caption
"
:
"
Vila
"
,
"
i18n
"
:
"
custom.teaser.vila
"
,
"
href
"
:
"
products.html?search=vila
"
}];
}
// callback to generate gallery
spec
.
callback
=
function
(
err
,
response
)
{
spec
.
callback
=
function
(
err
,
response
)
{
var
str
;
if
(
err
)
{
str
=
priv
.
generateError
();
}
else
{
...
...
@@ -170,7 +190,7 @@ define([
// TODO: this should not replace the whole gadget content
markup
=
params
.
source
.
replace
(
/<!-- gallery -->/g
,
str
);
// this is not response.callback(!!)
params
.
callback_mockup
(
markup
);
};
...
...
@@ -184,7 +204,7 @@ define([
// just run callback now and generate gallery
spec
.
callback
(
undefined
,
spec
);
}
}
}
;
// response object
that
.
data
=
source
;
...
...
@@ -192,11 +212,14 @@ define([
var
spec
=
{};
spec
.
gadget
=
RenderJs
.
getSelfGadget
();
spec
.
page
=
App
.
util
.
closest
(
spec
.
gadget
.
dom
.
get
(
0
),
"
div[data-role='page']
"
);
spec
.
page
=
App
.
util
.
closest
(
spec
.
gadget
.
dom
.
get
(
0
),
"
div[data-role='page']
"
);
spec
.
pageId
=
"
#
"
+
spec
.
page
.
id
;
// TODO: retrieving pointers should be a generic method that retrieves
// pointers either from the URL or from a JSON config object passed!
spec
.
pointer
=
location
.
search
.
split
(
"
=
"
);
spec
.
pointer
=
window
.
location
.
search
.
split
(
"
=
"
);
spec
.
callback_mockup
=
callback_mockup
;
spec
.
source
=
source
;
...
...
@@ -204,24 +227,24 @@ define([
if
(
!
spec
.
page
.
getAttribute
(
"
events_gallery
"
))
{
spec
.
page
.
setAttribute
(
"
events_gallery
"
,
true
);
$
(
document
).
on
(
"
pagebeforeshow.gallery
"
,
spec
.
pageId
,
function
(
e
)
{
$
(
document
).
on
(
"
pagebeforeshow.gallery
"
,
spec
.
pageId
,
function
()
{
// the pointer in the URL may be updated
if
(
location
.
search
)
{
spec
.
pointer
=
location
.
search
.
split
(
"
=
"
);
if
(
window
.
location
.
search
)
{
spec
.
pointer
=
window
.
location
.
search
.
split
(
"
=
"
);
}
priv
.
generateItems
(
spec
,
true
);
})
.
on
(
"
click.gallery
"
,
spec
.
pageId
+
"
.display_item
"
,
function
(
e
)
{
var
target
=
e
.
target
,
color
;
if
(
e
.
target
.
tagName
===
"
A
"
)
{
color
=
target
.
href
.
split
(
"
#
"
)[
1
];
}
else
{
color
=
App
.
util
.
closest
(
target
,
"
a
"
).
href
.
split
(
"
#
"
)[
1
];
}
priv
.
swapGalleryItems
(
color
,
e
.
target
);
});
.
on
(
"
click.gallery
"
,
spec
.
pageId
+
"
.display_item
"
,
function
(
e
)
{
var
target
=
e
.
target
,
color
;
if
(
e
.
target
.
tagName
===
"
A
"
)
{
color
=
target
.
href
.
split
(
"
#
"
)[
1
];
}
else
{
color
=
App
.
util
.
closest
(
target
,
"
a
"
).
href
.
split
(
"
#
"
)[
1
];
}
priv
.
swapGalleryItems
(
color
,
e
.
target
);
});
// and run intial
priv
.
generateItems
(
spec
);
}
...
...
@@ -229,9 +252,9 @@ define([
that
.
after
=
function
(
self
)
{
if
(
App
===
undefined
)
{
def
=
new
$
.
Deferred
;
var
def
=
new
$
.
Deferred
()
;
def
.
done
(
function
(
gadget
)
{
def
.
done
(
function
(
gadget
)
{
// prefix instance-ids, pass JSON
App
.
renderGadgets
(
gadget
,
true
);
});
...
...
@@ -244,7 +267,7 @@ define([
}
};
// return response object
return
that
;
// return response object
return
that
;
}
);
);
This diff is collapsed.
Click to expand it.
modules/ui/header/header.js
View file @
0ea54899
/*jslint indent: 2, maxlen: 80 */
/*global define: true, define: true, $: true, window: true */
define
([
'
app
'
,
'
text!header.html!strip
'
,
'
css!header
'
],
'
app
'
,
'
text!header.html!strip
'
,
'
css!header
'
],
function
(
App
,
source
)
{
"
use strict
"
;
var
response
=
{},
def
;
response
.
data
=
source
;
response
.
after
=
function
(
self
)
{
// TODO: this should be inside renderJs, although its application-specific
// but the problem with using async-render-require will be everything
// being loaded at the same time, so the user should have the opportunity
// to run his callback no matter where. Still not sure where to wait
// (app-init or render-init), but it would be nice if a renderjs application
// would allow for a first page load deferred on all gadgets until some
// flag is set. In rjs2, we will not have to set globals, but we will
// have the problem of trying to access methods published by other gadgets
// BEFORE they have been published, so it's pretty much the same thing.
if
(
App
===
undefined
)
{
def
=
new
$
.
Deferred
;
def
=
new
$
.
Deferred
()
;
def
.
done
(
function
(
gadget
)
{
def
.
done
(
function
(
gadget
)
{
// prefix instance-ids, pass JSON
App
.
renderGadgets
(
gadget
);
});
...
...
@@ -33,7 +28,7 @@ define([
}
};
// return response object
return
response
;
// return response object
return
response
;
}
);
);
This diff is collapsed.
Click to expand it.
modules/ui/index/index.js
View file @
0ea54899
/*jslint indent: 2, maxlen: 80 */
/*global define: true, define: true, $: true, window: true */
define
([
'
app
'
,
'
text!index.html!strip
'
,
'
css!index
'
],
'
app
'
,
'
text!index.html!strip
'
,
'
css!index
'
],
function
(
App
,
source
)
{
"
use strict
"
;
var
response
=
{},
def
;
response
.
data
=
source
;
response
.
after
=
function
(
self
)
{
if
(
App
===
undefined
)
{
def
=
new
$
.
Deferred
;
def
=
new
$
.
Deferred
()
;
def
.
done
(
function
(
gadget
)
{
def
.
done
(
function
(
gadget
)
{
// prefix instance-ids, pass JSON
App
.
renderGadgets
(
gadget
);
});
...
...
@@ -24,7 +28,7 @@ define([
}
};
// return response object
return
response
;
// return response object
return
response
;
}
);
);
This diff is collapsed.
Click to expand it.
modules/ui/item/item.js
View file @
0ea54899
/*jslint indent: 2, maxlen: 80, nomen: true */
/*global define: true, $: true, define: true, window: true, App: true,
RenderJs: true, document: true */
define
([
'
app
'
,
'
text!item.html!strip
'
,
'
css!item
'
],
'
app
'
,
'
text!item.html!strip
'
,
'
css!item
'
],
function
(
App
,
source
)
{
var
that
=
{};
var
priv
=
{};
"
use strict
"
;
var
that
=
{},
priv
=
{};
// ========================== ATTRIBUTES ==============================
// set response, so it's available across function calls
priv
.
response
;
priv
.
response
=
undefined
;
priv
.
generateContent
=
function
(
response
)
{
var
i
,
j
,
k
,
content
,
child
,
dimension
,
dimensions
,
variation
,
var
i
,
j
,
k
,
content
,
child
,
dimension
,
dimensions
,
variation
,
price
,
sub_dimension
,
sub_dimension_i18n
,
str
,
select
,
element
,
soldout
;
// expose response (will be overwritten, when next item loads
...
...
@@ -61,7 +66,7 @@ define([
select
=
""
;
}
dimensions
+=
"
<option class='translate' data-i18n='
"
+
variation
.
i18n
+
"
'
"
+
select
+
"
value='
"
+
variation
.
name
+
variation
.
i18n
+
"
'
"
+
select
+
"
value='
"
+
variation
.
name
+
"
'>
"
+
variation
.
name
+
"
</option>
"
;
}
...
...
@@ -88,10 +93,11 @@ define([
soldout
=
"
disabled
"
;
}
child
+=
"
<option class='translate' data-i18n='
"
+
element
.
i18n
+
"
'
"
+
soldout
+
"
value ='
"
+
element
.
name
+
"
'>
"
+
+
"
</option>
"
;
"
'
"
+
soldout
+
"
value ='
"
+
element
.
name
+
"
'>
"
+
element
.
name
+
"
</option>
"
;
}
}
str
=
content
+
dimensions
+
child
+
"
</select></div>
"
;
str
=
content
+
dimensions
+
child
+
"
</select></div>
"
;
return
[
str
,
response
.
description
];
};
...
...
@@ -101,70 +107,68 @@ define([
};
// generate content items?
priv
.
generateContentItems
=
function
(
name
)
{
//
var i, j, item, img, str = "";
//
priv.generateContentItems = function (name) {
// var i, j, item, img, str = "";
//
//
item = priv.response.dimensions[0].vars[0];
// item = priv.response.dimensions[0].vars[0];
//
// // find item name or default to first variant in dimension
// if (name !== undefined) {
// for (i = 0; i < priv.response.dimensions[0].vars.length; i += 1) {
// item = priv.response.dimensions[0].vars[i];
// if (item.name === name || location.hash === name) {
// break;
// }
// // find item name or default to first variant in dimension
// if (name !== undefined) {
// for (i = 0; i < priv.response.dimensions[0].vars.length; i += 1) {
// item = priv.response.dimensions[0].vars[i];
// if (item.name === name || window.location.hash === name) {
// break;
// }
// }
// }
//
// // for every variant (colors, size?, foo?)
// // TODO: declare a variant that carries images in products JSON!
// // build string
// for (j = 0; j < item.media.img.length; j += 1) {
// img = item.media.img[j];
// // TODO: add zoom/photoswipe later!
// str += "<li class='product_img'><a href='#'><img src='" + priv.response.media +
// img[shortcut] + size + "' alt='" + item.name + "' />" +
// "<h3 class='translate gallery_header' data-i18n='" +
// item.i18n + "'></h3></a></li>";
// }
//
// return str;
};
priv
.
swapSecondaryOptions
=
function
(
name
,
element
)
{
// var newString = priv.generateContentItems(name),
// // TODO: if thumbnails are a gallery option, it should be possible
// // to reference the gallery from the thumbnail without doing this:
// wrap = App.util.closest(element, ".gallery_thumbnails").previousSibling,
// gallery = wrap.getElementsByTagName("ul");
//
// $(gallery[0]).empty().append(newString).carousel("refresh");
};
// // for every variant (colors, size?, foo?)
// // TODO: declare a variant that carries images in products JSON!
// // build string
// for (j = 0; j < item.media.img.length; j += 1) {
// img = item.media.img[j];
// // TODO: add zoom/photoswipe later!
// str += "<li class='product_img'><a href='#'><img src='" +
// priv.response.media + img[shortcut] + size + "' alt='" +
// item.name + "' />" + "<h3 class='translate gallery_header' " +
// data-i18n='" + item.i18n + "'></h3></a></li>";
// }
//
// return str;
// };
// priv.swapSecondaryOptions = function (name, element) {
// var newString = priv.generateContentItems(name),
// // TODO: if thumbnails are a gallery option, it should be possible
// // to reference the gallery from the thumbnail without doing this:
// wrap = App.util.closest(
// element,
// ".gallery_thumbnails"
// ).previousSibling,
// gallery = wrap.getElementsByTagName("ul");
//
// $(gallery[0]).empty().append(newString).carousel("refresh");
// };
// generate items to display
priv
.
generateItems
=
function
(
params
)
{
var
markup
,
spec
,
response
;
var
markup
,
spec
,
id
=
params
.
gadget
.
dom
.
attr
(
'
id
'
).
split
(
"
__
"
).
splice
(
-
1
)[
0
],
config
=
params
.
gadget
.
state
[
0
][
id
].
_config
,
module
=
config
.
datasource
.
module
,
urlPointer
=
params
.
pointer
.
length
>
1
,
jsonPointer
=
config
.
datasource
.
pointer
;
urlPointer
=
params
.
pointer
.
length
>
1
;
// if we have a pointer-array passed, query that
// TODO: this access a globally stored current_item set by details gadget!
if
(
urlPointer
)
{
spec
=
{};
spec
.
storage
=
"
items
"
spec
.
method
=
"
get
"
spec
.
doc
=
{
"
_id
"
:
params
.
pointer
[
1
]}
}
if
(
jsonPointer
)
{
spec
.
storage
=
"
items
"
;
spec
.
method
=
"
get
"
;
spec
.
doc
=
{
"
_id
"
:
params
.
pointer
[
1
]};
}
// callback to generate gallery
spec
.
callback
=
function
(
err
,
response
)
{
spec
.
callback
=
function
(
err
,
response
)
{
var
str
;
if
(
err
)
{
...
...
@@ -184,7 +188,7 @@ define([
if
(
urlPointer
)
{
App
[
module
].
switchboard
(
spec
);
}
}
}
;
// response object
that
.
data
=
source
;
...
...
@@ -192,11 +196,14 @@ define([
var
spec
=
{};
spec
.
gadget
=
RenderJs
.
getSelfGadget
();
spec
.
page
=
App
.
util
.
closest
(
spec
.
gadget
.
dom
.
get
(
0
),
"
div[data-role='page']
"
);
spec
.
page
=
App
.
util
.
closest
(
spec
.
gadget
.
dom
.
get
(
0
),
"
div[data-role='page']
"
);
spec
.
pageId
=
"
#
"
+
spec
.
page
.
id
;
// TODO: retrieving pointers should be a generic method that retrieves
// pointers either from the URL or from a JSON config object passed!
spec
.
pointer
=
location
.
search
.
split
(
"
=
"
);
spec
.
pointer
=
window
.
location
.
search
.
split
(
"
=
"
);
spec
.
callback_mockup
=
callback_mockup
;
spec
.
source
=
source
;
...
...
@@ -204,34 +211,34 @@ define([
if
(
!
spec
.
page
.
getAttribute
(
"
events_items
"
))
{
spec
.
page
.
setAttribute
(
"
events_items
"
,
true
);
$
(
document
).
on
(
"
pagebeforeshow.items
"
,
spec
.
pageId
,
function
(
e
)
{
$
(
document
).
on
(
"
pagebeforeshow.items
"
,
spec
.
pageId
,
function
()
{
// the pointer in the URL may be updated
if
(
location
.
search
)
{
spec
.
pointer
=
location
.
search
.
split
(
"
=
"
);
if
(
window
.
location
.
search
)
{
spec
.
pointer
=
window
.
location
.
search
.
split
(
"
=
"
);
}
priv
.
generateItems
(
spec
,
true
);
})
.
on
(
"
change.item
"
,
spec
.
pageId
+
"
.main_dimension
"
,
function
(
e
)
{
})
;
//
.on("change.item", spec.pageId + " .main_dimension", function (e) {
// var target = e.target,
// color;
//
//
// if (e.target.tagName === "A") {
// color = target.href.split("#")[1];
// } else {
// color = App.util.closest(target, "a").href.split("#")[1];
// }
// priv.swapSecondaryOptions(color, e.target);
});
// and run intial
//
});
// and run intial
priv
.
generateItems
(
spec
);
}
};
that
.
after
=
function
(
self
)
{
if
(
App
===
undefined
)
{
def
=
new
$
.
Deferred
;
var
def
=
new
$
.
Deferred
()
;
def
.
done
(
function
(
gadget
)
{
def
.
done
(
function
(
gadget
)
{
// prefix instance-ids, pass JSON
App
.
renderGadgets
(
gadget
,
true
);
});
...
...
@@ -244,7 +251,7 @@ define([
}
};
// return response object
return
that
;
// return response object
return
that
;
}
);
);
This diff is collapsed.
Click to expand it.
modules/ui/items/items.js
View file @
0ea54899
/*jslint indent: 2, maxlen: 80, nomen: true */
/*global define: true, $: true, define: true, window: true, App: true,
RenderJs: true, document: true */
define
([
'
app
'
,
'
text!items.html!strip
'
,
'
css!items
'
],
'
app
'
,
'
text!items.html!strip
'
,
'
css!items
'
],
function
(
App
,
source
)
{
var
that
=
{};
var
priv
=
{};
"
use strict
"
;
var
that
=
{},
priv
=
{};
// in the perfect renderjs world, the items gadget should either expose
// an API on how to pass ... query string ... or have default config
...
...
@@ -14,37 +19,44 @@ define([
// generate items to display
priv
.
generateItems
=
function
(
params
)
{
var
markup
,
spec
,
var
markup
,
spec
,
id
=
params
.
gadget
.
dom
.
attr
(
'
id
'
).
split
(
"
__
"
).
splice
(
-
1
)[
0
],
config
=
params
.
gadget
.
state
[
0
][
id
].
_config
,
module
=
config
.
datasource
.
module
,
// settable options
screen
=
App
.
settings
.
screen_format
,
size
=
screen
===
"
small
"
?
"
small
"
:
"
medium
"
,
shortcut
=
size
.
substring
(
0
,
1
),
identifier
=
App
.
settings
.
identifier
||
"
item_id
"
;
spec
=
{};
spec
.
pointer
=
config
.
datasource
.
pointer
;
spec
.
method
=
spec
.
pointer
?
undefined
:
config
.
datasource
.
method
||
"
allDocs
"
;
spec
.
storage
=
spec
.
pointer
?
undefined
:
config
.
datasource
.
storage
||
"
items
"
;
spec
.
options
=
spec
.
pointer
?
undefined
:
{
"
limit
"
:
config
.
datasource
.
limit
||
[
0
,
24
],
"
sort_on
"
:
config
.
datasource
.
sort
||
[[
"
_id
"
,
"
descending
"
]],
"
select_list
"
:
config
.
datasource
.
fields
||
undefined
};
// if we have a search tag being passed, run a search
if
(
location
.
search
!==
""
)
{
spec
.
query
=
true
;
spec
.
query_string
=
location
.
search
.
split
(
"
=
"
)[
1
].
replace
(
"
+
"
,
"
"
);
}
spec
=
{};
spec
.
pointer
=
config
.
datasource
.
pointer
;
spec
.
method
=
spec
.
pointer
?
undefined
:
config
.
datasource
.
method
||
"
allDocs
"
;
spec
.
storage
=
spec
.
pointer
?
undefined
:
config
.
datasource
.
storage
||
"
items
"
;
spec
.
options
=
spec
.
pointer
?
undefined
:
{
"
limit
"
:
config
.
datasource
.
limit
||
[
0
,
24
],
"
sort_on
"
:
config
.
datasource
.
sort
||
[[
"
_id
"
,
"
descending
"
]],
"
select_list
"
:
config
.
datasource
.
fields
||
undefined
};
// if we have a search tag being passed, run a search
if
(
window
.
location
.
search
!==
""
)
{
spec
.
query
=
true
;
spec
.
query_string
=
window
.
location
.
search
.
split
(
"
=
"
)[
1
].
replace
(
"
+
"
,
"
"
);
}
spec
.
callback
=
function
(
err
,
response
)
{
var
item
,
i
,
str
=
""
,
price
;
spec
.
callback
=
function
(
err
,
response
)
{
var
item
,
i
,
str
=
""
,
price
,
now
=
new
Date
().
getTime
();
if
(
err
)
{
App
.
errors
.
push
([
"
items
"
,
now
,
err
]);
}
// cleanup
// no results
...
...
@@ -66,11 +78,11 @@ define([
price
=
item
.
price
+
item
.
currency
;
}
else
{
price
=
"
<span class='rebate'>
"
+
item
.
price
+
item
.
currency
+
"
</span> (
"
+
item
.
original_price
+
item
.
currency
+
"
)
"
;
"
</span> (
"
+
item
.
original_price
+
item
.
currency
+
"
)
"
;
}
str
+=
"
<li data-icon='false'>
"
+
"
<a href='details.html?
"
+
identifier
+
"
=
"
+
"
<a href='details.html?
"
+
identifier
+
"
=
"
+
encodeURI
(
item
[
identifier
])
+
"
' title='
"
+
item
.
brand
+
"
,
"
+
item
.
title
+
"
'>
"
+
"
<span class='img_container_items'>
"
+
...
...
@@ -88,7 +100,7 @@ define([
// this is not response.callback(!!)
params
.
callback_mockup
(
markup
);
}
}
;
// query for items
App
[
module
].
switchboard
(
spec
);
...
...
@@ -103,22 +115,27 @@ define([
// TODO: this is for page event bindings. Once JQM content replaces
// page, remove this and make the gadget the content section to
// be updated.
spec
.
page
=
App
.
util
.
closest
(
spec
.
gadget
.
dom
.
get
(
0
),
"
div[data-role='page']
"
);
spec
.
page
=
App
.
util
.
closest
(
spec
.
gadget
.
dom
.
get
(
0
),
"
div[data-role='page']
"
);
spec
.
pageId
=
"
#
"
+
spec
.
page
.
id
;
spec
.
source
=
source
;
spec
.
callback_mockup
=
callback_mockup
;
if
(
!
spec
.
page
.
getAttribute
(
"
events_items
"
))
{
spec
.
page
.
setAttribute
(
"
events_items
"
,
true
);
$
(
document
).
on
(
"
pagebeforeshow.items
"
,
spec
.
pageId
,
function
(
e
,
data
)
{
// TODO: if we allow to reload, we also need to trigger refresh on
// so we need to reload this every time a page is shown. question
// is how to trigger a refresh on this element ONLY
// > the gadgets should tell whether they need enhancement!
//if ($.mobile.firstPage.attr('id') !== spec.pageId.replace("#","")) {
$
(
document
).
on
(
"
pagebeforeshow.items
"
,
spec
.
pageId
,
function
()
{
// TODO: if we allow reload, we also need to trigger refresh on
// so we need to reload this every time a page is shown. question
// is how to trigger a refresh on this element ONLY
// > the gadgets should tell whether they need enhancement!
priv
.
generateItems
(
spec
);
//
}
}
);
}
);
// and run intial
priv
.
generateItems
(
spec
);
}
...
...
@@ -131,7 +148,8 @@ define([
var
target
,
search
=
{};
e
.
preventDefault
();
target
=
App
.
util
.
closest
(
e
.
target
,
"
a
"
).
getAttribute
(
"
href
"
).
split
(
"
?
"
)[
1
].
split
(
"
=
"
);
target
=
App
.
util
.
closest
(
e
.
target
,
"
a
"
)
.
getAttribute
(
"
href
"
).
split
(
"
?
"
)[
1
].
split
(
"
=
"
);
search
[
target
[
0
]]
=
target
[
1
];
// show this item
...
...
@@ -142,9 +160,9 @@ define([
});
if
(
App
===
undefined
)
{
def
=
new
$
.
Deferred
;
var
def
=
new
$
.
Deferred
()
;
def
.
done
(
function
(
gadget
)
{
def
.
done
(
function
(
gadget
)
{
// prefix instance-ids, pass JSON
App
.
renderGadgets
(
gadget
,
true
);
});
...
...
@@ -157,7 +175,8 @@ define([
}
};
// return response object
return
that
;
// return response object
return
that
;
}
);
);
This diff is collapsed.
Click to expand it.
modules/ui/login/login.js
View file @
0ea54899
/*jslint indent: 2, maxlen: 80 */
/*global define: true, define: true, $: true, window: true */
define
([
'
app
'
,
'
text!login.html!strip
'
,
'
validval
'
,
'
css!login
'
],
function
(
App
,
source
,
validator
)
{
var
response
=
{};
'
app
'
,
'
text!login.html!strip
'
,
'
validval
'
,
'
css!login
'
],
function
(
App
,
source
)
{
"
use strict
"
;
var
response
=
{},
def
;
response
.
data
=
source
;
response
.
after
=
function
(
self
)
{
if
(
App
===
undefined
)
{
def
=
new
$
.
Deferred
;
def
=
new
$
.
Deferred
()
;
def
.
done
(
function
(
gadget
)
{
def
.
done
(
function
(
gadget
)
{
// prefix instance-ids, pass JSON
App
.
renderGadgets
(
gadget
);
});
...
...
@@ -25,7 +29,7 @@ define([
}
};
// return response object
return
response
;
// return response object
return
response
;
}
);
);
This diff is collapsed.
Click to expand it.
modules/ui/media/media.js
View file @
0ea54899
/*jslint indent: 2, maxlen: 80 */
/*global define: true, define: true, $: true, window: true */
define
([
'
app
'
,
'
text!media.html!strip
'
,
'
css!media
'
],
'
app
'
,
'
text!media.html!strip
'
,
'
css!media
'
],
function
(
App
,
source
)
{
var
response
=
{};
"
use strict
"
;
var
response
=
{},
def
;
response
.
data
=
source
;
response
.
after
=
function
(
self
)
{
if
(
App
===
undefined
)
{
def
=
new
$
.
Deferred
;
def
=
new
$
.
Deferred
()
;
def
.
done
(
function
(
gadget
)
{
def
.
done
(
function
(
gadget
)
{
// prefix instance-ids, pass JSON
App
.
renderGadgets
(
gadget
);
});
...
...
@@ -24,7 +28,7 @@ define([
}
};
// return response object
return
response
;
// return response object
return
response
;
}
);
);
This diff is collapsed.
Click to expand it.
modules/ui/pagination/pagination.js
View file @
0ea54899
/*jslint indent: 2, maxlen: 80, nomen: true */
/*global define: true, $: true, window: true, App: true, RenderJs: true,
document: true, define: true */
define
([
'
app
'
,
'
text!pagination.html!strip
'
,
'
css!pagination
'
],
'
app
'
,
'
text!pagination.html!strip
'
,
'
css!pagination
'
],
function
(
App
,
source
)
{
var
priv
=
{};
var
that
=
{};
"
use strict
"
;
var
priv
=
{},
that
=
{};
// get previous and next id
// TODO: this only works with id-numbers!!!
...
...
@@ -13,7 +18,7 @@ define([
// unless we want to get allDocs(includeDocs)
// TODO: this should receive the total number of results of a query/search!
priv
.
getPrevNextItem
=
function
(
arr
,
id
,
next
,
max
)
{
var
step
=
next
?
1
:
-
1
,
position
,
id
;
var
position
;
for
(
position
=
1
;
position
<=
max
;
position
+=
1
)
{
if
(
position
===
parseFloat
(
id
))
{
...
...
@@ -23,13 +28,12 @@ define([
return
false
;
}
return
arr
[
position
].
id
;
}
else
{
// less 1 is self, less 2 is previous...
if
(
arr
[
position
-
2
]
===
undefined
)
{
return
false
;
}
return
arr
[
position
-
2
].
id
;
}
// less 1 is self, less 2 is previous...
if
(
arr
[
position
-
2
]
===
undefined
)
{
return
false
;
}
return
arr
[
position
-
2
].
id
;
}
}
};
...
...
@@ -53,39 +57,65 @@ define([
config
=
params
.
gadget
.
state
[
0
][
id
].
_config
,
module
=
config
.
datasource
.
module
;
var
spec
=
{};
spec
=
{};
spec
.
pointer
=
config
.
datasource
.
pointer
;
spec
.
method
=
spec
.
pointer
?
undefined
:
config
.
datasource
.
method
||
"
allDocs
"
;
spec
.
storage
=
spec
.
pointer
?
undefined
:
config
.
datasource
.
storage
||
"
items
"
;
spec
.
options
=
spec
.
pointer
?
undefined
:
config
.
datasource
.
options
||
{
"
sort_on
"
:
[[
"
_id
"
,
"
ascending
"
]]
}
spec
.
method
=
spec
.
pointer
?
undefined
:
config
.
datasource
.
method
||
"
allDocs
"
;
spec
.
storage
=
spec
.
pointer
?
undefined
:
config
.
datasource
.
storage
||
"
items
"
;
spec
.
options
=
spec
.
pointer
?
undefined
:
config
.
datasource
.
options
||
{
"
sort_on
"
:
[[
"
_id
"
,
"
ascending
"
]]
};
spec
.
callback
=
function
(
err
,
response
)
{
var
currentId
=
location
.
href
.
split
(
"
?
"
)[
1
].
split
(
"
=
"
)[
1
],
var
next
,
prev
,
markup
,
currentId
=
window
.
location
.
href
.
split
(
"
?
"
)[
1
].
split
(
"
=
"
)[
1
],
identifier
=
App
.
settings
.
identifier
||
"
item_id
"
,
n
ext
,
prev
,
markup
;
n
ow
=
new
Date
().
getTime
()
;
// TODO: error handling
if
(
err
)
{
App
.
errors
.
push
([
"
pagination
"
,
now
,
err
]);
}
else
{
// set next
// TODO:
this is
bad, because we can only point to doc_id, no matter what
// TODO: bad, because we can only point to doc_id, no matter what
// identifier we are setting. item_id itself is... bad... fix!
next
=
priv
.
getPrevNextItem
(
response
.
rows
,
currentId
,
true
,
response
.
total_rows
);
next
=
priv
.
getPrevNextItem
(
response
.
rows
,
currentId
,
true
,
response
.
total_rows
);
if
(
!
next
)
{
markup
=
params
.
source
.
replace
(
"
translate next
"
,
"
translate next ui-state-disabled
"
);
markup
=
params
.
source
.
replace
(
"
translate next
"
,
"
translate next ui-state-disabled
"
);
}
else
{
markup
=
params
.
source
.
replace
(
identifier
+
"
=next
"
,
identifier
+
"
=
"
+
next
);
markup
=
params
.
source
.
replace
(
identifier
+
"
=next
"
,
identifier
+
"
=
"
+
next
);
}
// set previous
prev
=
priv
.
getPrevNextItem
(
response
.
rows
,
currentId
,
false
,
response
.
total_rows
);
prev
=
priv
.
getPrevNextItem
(
response
.
rows
,
currentId
,
false
,
response
.
total_rows
);
if
(
!
prev
)
{
markup
=
markup
.
replace
(
"
translate prev
"
,
"
translate prev ui-state-disabled
"
);
markup
=
markup
.
replace
(
"
translate prev
"
,
"
translate prev ui-state-disabled
"
);
}
else
{
markup
=
markup
.
replace
(
identifier
+
"
=prev
"
,
identifier
+
"
=
"
+
prev
);
markup
=
markup
.
replace
(
identifier
+
"
=prev
"
,
identifier
+
"
=
"
+
prev
);
}
}
params
.
callback_mockup
(
markup
);
...
...
@@ -95,8 +125,8 @@ define([
App
[
module
].
switchboard
(
spec
);
};
priv
.
setBindings
=
function
(
param
)
{
var
doc
=
$
(
document
);
//
priv.setBindings = function (param) {
//
var doc = $(document);
// doc
// .on("pagebeforeshow.browser", param.pageId, function (e) {
// console.log("pbs");
...
...
@@ -114,7 +144,7 @@ define([
// // changePage
// priv.displayItem(target);
// });
};
//
};
that
.
data
=
source
;
that
.
before
=
function
(
source
,
callback_mockup
)
{
...
...
@@ -124,21 +154,28 @@ define([
// TODO: this is for page event bindings. Once JQM content replaces
// page, remove this and make the gadget the content section to
// be updated.
spec
.
page
=
App
.
util
.
closest
(
spec
.
gadget
.
dom
.
get
(
0
),
"
div[data-role='page']
"
);
spec
.
page
=
App
.
util
.
closest
(
spec
.
gadget
.
dom
.
get
(
0
),
"
div[data-role='page']
"
);
spec
.
pageId
=
"
#
"
+
spec
.
page
.
id
;
spec
.
source
=
source
;
spec
.
callback_mockup
=
callback_mockup
;
if
(
!
spec
.
page
.
getAttribute
(
"
events_pagination
"
))
{
spec
.
page
.
setAttribute
(
"
events_pagination
"
,
true
);
$
(
document
).
on
(
"
pagebeforeshow.pagination
"
,
spec
.
pageId
,
function
(
e
,
data
)
{
$
(
document
).
on
(
"
pagebeforeshow.pagination
"
,
spec
.
pageId
,
function
()
{
// TODO: if we allow to reload, we also need to trigger refresh on
// so we need to reload this every time a page is shown. question
// is how to trigger a refresh on this element ONLY
// > the gadgets should tell whether they need enhancement!
// callback
priv
.
iterate
(
spec
);
});
priv
.
iterate
(
spec
);
}
);
// callback
priv
.
iterate
(
spec
);
...
...
@@ -147,22 +184,22 @@ define([
that
.
after
=
function
(
self
)
{
if
(
App
===
undefined
)
{
def
=
new
$
.
Deferred
;
var
def
=
new
$
.
Deferred
()
;
def
.
done
(
function
(
gadget
)
{
def
.
done
(
function
(
gadget
)
{
// prefix instance-ids, pass JSON
App
.
renderGadgets
(
gadget
,
true
);
App
.
renderGadgets
(
gadget
);
});
window
.
fallbackLoader
.
deferreds
.
push
(
def
);
window
.
fallbackLoader
.
args
.
push
(
self
);
}
else
{
// prefix instance-ids, pass JSON
App
.
renderGadgets
(
self
,
true
);
App
.
renderGadgets
(
self
);
}
};
// return response object
return
that
;
// return response object
return
that
;
}
);
);
This diff is collapsed.
Click to expand it.
Prev
1
2
Next
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