fixed issue 1507, menu links problems with mobile user agent, thanks Paolo Valleri
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.6.0-development+timestamp.2013.09.02.20.32.13
|
Version 2.6.0-development+timestamp.2013.09.02.20.41.19
|
||||||
|
|||||||
+10
-2
@@ -2457,15 +2457,23 @@ class MENU(DIV):
|
|||||||
def serialize_mobile(self, data, select=None, prefix=''):
|
def serialize_mobile(self, data, select=None, prefix=''):
|
||||||
if not select:
|
if not select:
|
||||||
select = SELECT(**self.attributes)
|
select = SELECT(**self.attributes)
|
||||||
|
custom_items = []
|
||||||
for item in data:
|
for item in data:
|
||||||
if len(item) <= 4 or item[4] == True:
|
# Custom item aren't serialized as mobile
|
||||||
|
if len(item) >= 3 and (not item[0]) or (isinstance(item[0], DIV) and not (item[2])):
|
||||||
|
# ex: ('', False,A('title',_href=URL(...),_title="title"))
|
||||||
|
# ex: (A('title',_href=URL(...),_title="title"), False, None)
|
||||||
|
custom_items.append(item)
|
||||||
|
elif len(item) <= 4 or item[4] == True:
|
||||||
select.append(OPTION(CAT(prefix, item[0]),
|
select.append(OPTION(CAT(prefix, item[0]),
|
||||||
_value=item[2], _selected=item[1]))
|
_value=item[2], _selected=item[1]))
|
||||||
if len(item) > 3 and len(item[3]):
|
if len(item) > 3 and len(item[3]):
|
||||||
self.serialize_mobile(
|
self.serialize_mobile(
|
||||||
item[3], select, prefix=CAT(prefix, item[0], '/'))
|
item[3], select, prefix=CAT(prefix, item[0], '/'))
|
||||||
select['_onchange'] = 'window.location=this.value'
|
select['_onchange'] = 'window.location=this.value'
|
||||||
return select
|
# avoid to wrap the select if no custom items are present
|
||||||
|
html = DIV(select, self.serialize(custom_items)) if len( custom_items) else select
|
||||||
|
return html
|
||||||
|
|
||||||
def xml(self):
|
def xml(self):
|
||||||
if self['mobile']:
|
if self['mobile']:
|
||||||
|
|||||||
Reference in New Issue
Block a user