Commit 069effe7 authored by Sven Franck's avatar Sven Franck

ext/JQM: updated to latest version (1.5pre)

parent 0209be4f
......@@ -1260,305 +1260,3 @@ $.widget( "mobile.collapsibleset", $.extend( {
})( jQuery );
/* ========================= SELECT ========================= */
(function( $, undefined ) {
$.widget( "mobile.selectmenu", $.extend( {
initSelector: "select:not( :jqmData(role='slider')):not( :jqmData(role='flipswitch') )",
options: {
theme: null,
disabled: false,
icon: "carat-d",
iconpos: "right",
inline: false,
corners: true,
shadow: true,
iconshadow: false, /* TODO: Deprecated in 1.4, remove in 1.5. */
overlayTheme: null,
dividerTheme: null,
hidePlaceholderMenuItems: true,
closeText: "Close",
nativeMenu: true,
// This option defaults to true on iOS devices.
preventFocusZoom: /iPhone|iPad|iPod/.test( navigator.platform ) && navigator.userAgent.indexOf( "AppleWebKit" ) > -1,
mini: false,
enhanced: false
},
_button: function() {
return $( "<div/>" );
},
_setDisabled: function( value ) {
this.element.attr( "disabled", value );
this.button.attr( "aria-disabled", value );
return this._setOption( "disabled", value );
},
_focusButton : function() {
var self = this;
setTimeout( function() {
self.button.focus();
}, 40);
},
_selectOptions: function() {
return this.select.find( "option" );
},
_destroy: function() {
var wrapper = this.element.parents( ".ui-select" );
if ( wrapper.length > 0 ) {
if ( wrapper.is( ".ui-btn-left, .ui-btn-right" ) ) {
this.element.addClass( wrapper.hasClass( "ui-btn-left" ) ? "ui-btn-left" : "ui-btn-right" );
}
this.element.insertAfter( wrapper );
wrapper.remove();
}
},
_enhance: function () {
// setup items that are generally necessary for select menu extension
var classes,
o = this.options,
el = this.element[0],
iconpos = o.icon ? ( o.iconpos || el.getAttribute( "data-iconpos" ) ) : false;
// TODO: move all(?) classes on wrapper or only ui-btn-left/right?
classes = el.className +
(o.mini || el.getAttribute( "data-mini" )) ? " ui-mini" : "" +
(o.inline || el.getAttribute( "data-inline" )) ? " ui-btn-inline" : "";
this.select = this.element.removeClass( "ui-btn-left ui-btn-right" ).wrap( "<div class='ui-select" + classes + "'>" );
this.selectId = this.select.attr( "id" ) || ( "select-" + this.uuid );
this.buttonId = this.selectId + "-button";
this.label = $( "label[for='"+ this.selectId +"']" );
this.button = this._button()
.insertBefore( this.select )
.attr( "id", this.buttonId )
.addClass( "ui-btn" +
( o.icon ? ( " ui-icon-" + o.icon + " ui-btn-icon-" + iconpos +
( o.iconshadow ? " ui-shadow-icon" : "" ) ) : "" ) + /* TODO: Remove in 1.5. */
( o.theme ? " ui-btn-" + o.theme : "" ) +
( o.corners ? " ui-corner-all" : "" ) +
( o.shadow ? " ui-shadow" : "" ) );
// Add button text placeholder
this.buttonText = $ ( "<span>" )
.appendTo( this.button );
this._setMultiple();
// Add counter for multi selects
if ( this.isMultiple ) {
this.buttonCount = $( "<span>" )
.addClass( "ui-li-count ui-body-inherit" )
.hide()
.appendTo( this.button.addClass( "ui-li-has-count" ) );
}
},
_setMultiple: function () {
// TODO: are multiples supported in regular select?
this.isMultiple = this.select[ 0 ].multiple;
},
_create: function() {
var self = this,
o = this.options;
if (o.enhanced) {
this.button = this.element.parent();
this.select = this.element;
this.selectId = this.select[0].id;
this.buttonId = this.button[0].id;
this.label = this.element.prev("label");
this.buttonText = this.button.find("span").first();
this._setMultiple();
if (this.isMultiple) {
this.buttonCount = this.button.find("span").last();
}
} else {
this._enhance();
}
this.setButtonText();
// Opera does not properly support opacity on select elements
// In Mini, it hides the element, but not its text
// On the desktop,it seems to do the opposite
// for these reasons, using the nativeMenu option results in a full native select in Opera
if ( o.nativeMenu && window.opera && window.opera.version ) {
this.button.addClass( "ui-select-nativeonly" );
}
// Disable if specified
if ( o.disabled || this.element.attr( "disabled" )) {
this.disable();
}
// Events on native select
this.select.change(function() {
self.refresh();
if ( !!o.nativeMenu ) {
this.blur();
}
});
this._handleFormReset();
this._on( this.button, {
keydown: "_handleKeydown"
});
this.build();
},
build: function() {
var self = this;
this.select
.appendTo( self.button )
.bind( "vmousedown", function() {
// Add active class to button
self.button.addClass( $.mobile.activeBtnClass );
})
.bind( "focus", function() {
self.button.addClass( $.mobile.focusClass );
})
.bind( "blur", function() {
self.button.removeClass( $.mobile.focusClass );
})
.bind( "focus vmouseover", function() {
self.button.trigger( "vmouseover" );
})
.bind( "vmousemove", function() {
// Remove active class on scroll/touchmove
self.button.removeClass( $.mobile.activeBtnClass );
})
.bind( "change blur vmouseout", function() {
self.button.trigger( "vmouseout" )
.removeClass( $.mobile.activeBtnClass );
});
// In many situations, iOS will zoom into the select upon tap, this prevents that from happening
self.button.bind( "vmousedown", function() {
if ( self.options.preventFocusZoom ) {
$.mobile.zoom.disable( true );
}
});
self.label.bind( "click focus", function() {
if ( self.options.preventFocusZoom ) {
$.mobile.zoom.disable( true );
}
});
self.select.bind( "focus", function() {
if ( self.options.preventFocusZoom ) {
$.mobile.zoom.disable( true );
}
});
self.button.bind( "mouseup", function() {
if ( self.options.preventFocusZoom ) {
setTimeout(function() {
$.mobile.zoom.enable( true );
}, 0 );
}
});
self.select.bind( "blur", function() {
if ( self.options.preventFocusZoom ) {
$.mobile.zoom.enable( true );
}
});
},
selected: function() {
return this._selectOptions().filter( ":selected" );
},
selectedIndices: function() {
var self = this;
return this.selected().map(function() {
return self._selectOptions().index( this );
}).get();
},
setButtonText: function() {
var self = this,
selected = this.selected(),
text = this.placeholder,
span = this.buttonText;
this.button.children( "span" ).not( ".ui-li-count" ).remove().end().end().prepend( (function() {
if ( selected.length ) {
text = selected.map(function() {
return $( this ).text();
}).get().join( ", " );
} else {
text = self.placeholder;
}
if ( text ) {
span.text( text );
} else {
span.html( "&nbsp;" );
}
// TODO possibly aggregate multiple select option classes
return this.buttonText = span
.addClass( self.select.attr( "class" ) )
.addClass( selected.attr( "class" ) )
.removeClass( "ui-screen-hidden" );
})());
},
setButtonCount: function() {
var selected = this.selected();
// multiple count inside button
if ( this.isMultiple ) {
this.buttonCount[ selected.length > 1 ? "show" : "hide" ]().text( selected.length );
}
},
_handleKeydown: function( /* event */ ) {
this._delay( "_refreshButton" );
},
_reset: function() {
this.refresh();
},
_refreshButton: function() {
this.setButtonText();
this.setButtonCount();
},
refresh: function() {
this._refreshButton();
},
// open and close preserved in native selects
// to simplify users code when looping over selects
open: $.noop,
close: $.noop,
disable: function() {
this._setDisabled( true );
this.button.addClass( "ui-state-disabled" );
},
enable: function() {
this._setDisabled( false );
this.button.removeClass( "ui-state-disabled" );
}
}, $.mobile.behaviors.formReset ) );
})( jQuery );
/*!
* jQuery Mobile 1.4.3pre
* Git HEAD hash: 77b5304ec0510824e6f014e6caf716701db6abd2 <> Date: Thu Mar 6 2014 16:14:07 UTC
* jQuery Mobile 1.5.0pre
* Git HEAD hash: 39fe09ebf3d40321b7d7c389c1b5676b01093971 <> Date: Tue May 6 2014 09:33:07 UTC
* http://jquerymobile.com
*
* Copyright 2010, 2014 jQuery Foundation, Inc. and other contributors
......@@ -2501,7 +2501,6 @@ button.ui-btn-icon-notext,
width: 78%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
}
/* ui-hide-label deprecated in 1.4. TODO: Remove in 1.5 */
......@@ -3854,7 +3853,6 @@ input.ui-slider-input {
appearance: none;
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
-ms-box-sizing: content-box;
box-sizing: content-box;
}
.ui-slider-input::-webkit-outer-spin-button,
......@@ -4077,7 +4075,6 @@ textarea.ui-input-text {
width: 100%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
outline: 0;
}
......@@ -4251,7 +4248,6 @@ textarea.ui-input-text.ui-textinput-autogrow {
border-style: solid;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
border-radius: inherit;
overflow: visible;
......@@ -4269,7 +4265,6 @@ html .ui-popup .ui-field-contain > label + .ui-flipswitch {
width: 5.875em; /* If you override the width for .ui-flipswitch you should repeat the same value here */
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
-ms-box-sizing: content-box;
box-sizing: content-box;
}
.ui-field-contain .ui-flipswitch.ui-flipswitch-active,
......
/* HACKS: #7155, #7162, #7154, #7292, #7301
/* HACKS: #7155, #7162, #7154, #7292, #7301, pre-enhance select*/
/*!
* jQuery Mobile 1.4.3pre
* Git HEAD hash: 77b5304ec0510824e6f014e6caf716701db6abd2 <> Date: Thu Mar 6 2014 16:14:07 UTC
* jQuery Mobile 1.5.0pre
* Git HEAD hash: 39fe09ebf3d40321b7d7c389c1b5676b01093971 <> Date: Tue May 6 2014 09:33:07 UTC
* http://jquerymobile.com
*
* Copyright 2010, 2014 jQuery Foundation, Inc. and other contributors
......@@ -31,7 +32,7 @@
$.extend( $.mobile, {
// Version of the jQuery Mobile Framework
version: "1.4.3pre",
version: "1.5.0pre",
// Deprecated and no longer used in 1.4 remove in 1.5
// Define the url parameter used for referencing widget-generated sub-pages.
......@@ -684,7 +685,13 @@ $.ui.plugin = {
height = compensateToolbars( page,
( typeof height === "number" ) ? height : $.mobile.getScreenHeight() );
page.css( "min-height", height - ( pageOuterHeight - pageHeight ) );
// Remove any previous min-height setting
page.css( "min-height", "" );
// Set the minimum height only if the height as determined by CSS is insufficient
if ( page.height() < height ) {
page.css( "min-height", height - ( pageOuterHeight - pageHeight ) );
}
},
loading: function() {
......@@ -1887,7 +1894,7 @@ $.mobile.widget = $.Widget;
iframe_doc.open();
// Set document.domain for the Iframe document as well, if necessary.
domain && iframe_doc.write( '<script>document.domain="' + domain + '"</script>' );
domain && iframe_doc.write( '\x3cscript>document.domain="' + domain + '"\x3c/script>' );
iframe_doc.close();
......@@ -3202,6 +3209,12 @@ if ( !$.support.boxShadow ) {
$.fn.animationComplete = function( callback, type, fallbackTime ) {
var timer, duration,
that = this,
eventBinding = function() {
// Clear the timer so we don't call callback twice
clearTimeout( timer );
callback.apply( this, arguments );
},
animationType = ( !type || type === "animation" ) ? "animation" : "transition";
// Make sure selected type is supported by browser
......@@ -3229,17 +3242,12 @@ if ( !$.support.boxShadow ) {
// Sets up the fallback if event never comes
timer = setTimeout( function() {
$( that ).off( props[ animationType ].event );
$( that ).off( props[ animationType ].event, eventBinding );
callback.apply( that );
}, duration );
// Bind the event
return $( this ).one( props[ animationType ].event, function() {
// Clear the timer so we dont call callback twice
clearTimeout( timer );
callback.call( this, arguments );
});
return $( this ).one( props[ animationType ].event, eventBinding );
} else {
// CSS animation / transitions not supported
......@@ -5117,7 +5125,7 @@ $.widget( "mobile.page", {
$.mobile.path.isEmbeddedPage(fileUrl) &&
!$.mobile.path.isFirstPageUrl(fileUrl) ) {
deferred.reject( absUrl, settings );
return;
return deferred.promise();
}
// Reset base to the default document base
......@@ -5138,7 +5146,7 @@ $.widget( "mobile.page", {
this._getBase().set(url);
}
return;
return deferred.promise();
}
triggerData = {
......@@ -5155,7 +5163,7 @@ $.widget( "mobile.page", {
// If the default behavior is prevented, stop here!
if ( pblEvent.deprecatedEvent.isDefaultPrevented() ||
pblEvent.event.isDefaultPrevented() ) {
return;
return deferred.promise();
}
if ( settings.showLoadMsg ) {
......@@ -5171,7 +5179,7 @@ $.widget( "mobile.page", {
if ( !( $.mobile.allowCrossDomainPages ||
$.mobile.path.isSameDomain($.mobile.path.documentUrl, absUrl ) ) ) {
deferred.reject( absUrl, settings );
return;
return deferred.promise();
}
// Load the new content.
......@@ -5184,6 +5192,8 @@ $.widget( "mobile.page", {
success: this._loadSuccess( absUrl, triggerData, settings, deferred ),
error: this._loadError( absUrl, triggerData, settings, deferred )
});
return deferred.promise();
},
_loadError: function( absUrl, triggerData, settings, deferred ) {
......@@ -7371,21 +7381,22 @@ $.widget( "mobile.listview", $.extend( {
corners: true,
shadow: true,
inset: false,
enhanced: true
enhanced: false
},
_create: function() {
var t = this,
o = this.options,
o = t.options,
listviewClasses = "";
if ( !o.enhanced ) {
listviewClasses += o.inset ? " ui-listview-inset" : "";
listviewClasses += t.options.inset ? " ui-listview-inset" : "";
if ( !!o.inset ) {
listviewClasses += o.corners ? " ui-corner-all" : "";
listviewClasses += o.shadow ? " ui-shadow" : "";
if ( !!t.options.inset ) {
listviewClasses += t.options.corners ? " ui-corner-all" : "";
listviewClasses += t.options.shadow ? " ui-shadow" : "";
}
// create listview markup
t.element.addClass( " ui-listview" + listviewClasses );
}
......@@ -7441,11 +7452,11 @@ $.widget( "mobile.listview", $.extend( {
$list = this.element;
if ( !o.enhanced ) {
ol = !!$.nodeName( $list[ 0 ], "ol" ),
start = $list.attr( "start" ),
itemClassDict = {},
countBubbles = $list.find( ".ui-li-count" ),
countTheme = getAttr( $list[ 0 ], "counttheme" ) || this.options.countTheme,
ol = !!$.nodeName( $list[ 0 ], "ol" );
start = $list.attr( "start" );
itemClassDict = {};
countBubbles = $list.find( ".ui-li-count" );
countTheme = getAttr( $list[ 0 ], "counttheme" ) || this.options.countTheme;
countThemeClass = countTheme ? "ui-body-" + countTheme : "ui-body-inherit";
if ( o.theme ) {
......@@ -7861,7 +7872,7 @@ $.widget( "mobile.checkboxradio", $.extend( {
// If we're inside a form
if ( form ) {
formId = form.id;
formId = form.getAttribute( "id" );
// If the form has an ID, collect radios scattered throught the document which
// nevertheless are part of the form by way of the value of their form attribute
......@@ -9035,7 +9046,9 @@ $.widget( "mobile.slider", $.mobile.slider, {
if ( o.popupEnabled && this._popup ) {
this._positionPopup();
this._popup.html( newValue );
} else if ( o.showValue && !this.options.mini ) {
}
if ( o.showValue && !this.options.mini ) {
this.handle.html( newValue );
}
},
......@@ -9829,7 +9842,8 @@ $.widget( "mobile.selectmenu", $.extend( {
nativeMenu: true,
// This option defaults to true on iOS devices.
preventFocusZoom: /iPhone|iPad|iPod/.test( navigator.platform ) && navigator.userAgent.indexOf( "AppleWebKit" ) > -1,
mini: false
mini: false,
enhanced: false
},
_button: function() {
......@@ -9897,16 +9911,24 @@ $.widget( "mobile.selectmenu", $.extend( {
},
_create: function() {
this._preExtension();
this.button = this._button();
var self = this,
var iconpos,
button,
self = this,
options = this.options;
options = this.options,
if (options.enhanced) {
this.button = this.element.parent();
this.select = this.element;
this.selectId = this.select[0].id;
this.buttonId = this.button[0].id;
this.label = this.element.prev("label");
this.buttonText = this.button.find("span").first();
} else {
this._preExtension();
iconpos = options.icon ? ( options.iconpos || this.select.jqmData( "iconpos" ) ) : false,
this.button = this._button();
iconpos = options.icon ? ( options.iconpos || this.select.jqmData( "iconpos" ) ) : false;
button = this.button
.insertBefore( this.select )
.attr( "id", this.buttonId )
......@@ -9916,6 +9938,7 @@ $.widget( "mobile.selectmenu", $.extend( {
( options.theme ? " ui-btn-" + options.theme : "" ) +
( options.corners ? " ui-corner-all" : "" ) +
( options.shadow ? " ui-shadow" : "" ) );
}
this.setButtonText();
......@@ -10182,6 +10205,14 @@ $.widget( "mobile.popup", {
history: !$.mobile.browser.oldIE
},
// When the user depresses the mouse/finger on an element inside the popup while the popup is
// open, we ignore resize events for a short while. This prevents #6961.
_handleDocumentVmousedown: function( theEvent ) {
if ( this._isOpen && $.contains( this._ui.container[ 0 ], theEvent.target ) ) {
this._ignoreResizeEvents();
}
},
_create: function() {
var theElement = this.element,
myId = theElement.attr( "id" ),
......@@ -10192,6 +10223,10 @@ $.widget( "mobile.popup", {
// it is determined whether there shall be AJAX nav.
currentOptions.history = currentOptions.history && $.mobile.ajaxEnabled && $.mobile.hashListeningEnabled;
this._on( this.document, {
"vmousedown": "_handleDocumentVmousedown"
});
// Define instance variables
$.extend( this, {
_scrollTop: 0,
......@@ -11219,7 +11254,10 @@ $.widget( "mobile.selectmenu", $.mobile.selectmenu, {
"</div>"+
"<div data-" + $.mobile.ns + "role='content'></div>"+
"</div>" );
listbox = $( "<div id='" + popupId + "' class='ui-selectmenu'></div>" ).insertAfter( this.select ).popup({ theme: o.overlayTheme });
listbox = $( "<div" + themeAttr + overlayThemeAttr + " id='" + popupId +
"' class='ui-selectmenu'></div>" )
.insertAfter( this.select )
.popup();
list = $( "<ul class='ui-selectmenu-list' id='" + menuId + "' role='listbox' aria-labelledby='" + this.buttonId + "'" + themeAttr + dividerThemeAttr + "></ul>" ).appendTo( listbox );
header = $( "<div class='ui-header ui-bar-" + ( o.theme ? o.theme : "inherit" ) + "'></div>" ).prependTo( listbox );
headerTitle = $( "<h1 class='ui-title'></h1>" ).appendTo( header );
......@@ -12982,6 +13020,7 @@ $.widget( "mobile.panel", {
_handleClick: function( e ) {
var link,
panelId = this.element.attr( "id" );
if ( e.currentTarget.href.split( "#" )[ 1 ] === panelId && panelId !== undefined ) {
e.preventDefault();
......@@ -12993,7 +13032,6 @@ $.widget( "mobile.panel", {
});
}
this.toggle();
//return false;
}
},
......@@ -13072,7 +13110,8 @@ $.widget( "mobile.panel", {
}
if ( !immediate && $.support.cssTransform3d && !!o.animate ) {
self.element.animationComplete( complete, "transition" );
( self._wrapper || self.element )
.animationComplete( complete, "transition" );
} else {
setTimeout( complete, 0 );
}
......@@ -13105,6 +13144,11 @@ $.widget( "mobile.panel", {
},
complete = function() {
// Bail if the panel was closed before the opening animation has completed
if ( !self._open ) {
return;
}
if ( o.display !== "overlay" ) {
self._wrapper.addClass( o.classes.pageContentPrefix + "-open" );
self._fixedToolbars().addClass( o.classes.pageContentPrefix + "-open" );
......@@ -13146,13 +13190,16 @@ $.widget( "mobile.panel", {
}
if ( !immediate && $.support.cssTransform3d && !!o.animate ) {
self.element.animationComplete( complete, "transition" );
( self._wrapper || self.element )
.animationComplete( complete, "transition" );
} else {
setTimeout( complete, 0 );
}
if ( self._modal ) {
self._modal.removeClass( self._modalOpenClasses );
self._modal
.removeClass( self._modalOpenClasses )
.height( "" );
}
},
complete = function() {
......@@ -13407,14 +13454,17 @@ $.widget( "mobile.table", $.mobile.table, {
// create the hide/show toggles
this.headers.not( "td" ).each( function() {
var header = $( this ),
var input,
header = $( this ),
priority = $.mobile.getAttribute( this, "priority" ),
cells = header.add( header.jqmData( "cells" ) );
if ( priority ) {
cells.addClass( opts.classes.priorityPrefix + priority );
( keep ? inputs.eq( checkboxIndex++ ) :
// Make sure the (new?) checkbox is associated with its header via .jqmData() and
// that, vice versa, the header is also associated with the checkbox
input = ( keep ? inputs.eq( checkboxIndex++ ) :
$("<label><input type='checkbox' checked />" +
( header.children( "abbr" ).first().attr( "title" ) ||
header.text() ) +
......@@ -13424,7 +13474,13 @@ $.widget( "mobile.table", $.mobile.table, {
.checkboxradio( {
theme: opts.columnPopupTheme
}) )
.jqmData( "cells", cells );
// Associate the header with the checkbox
.jqmData( "header", header )
.jqmData( "cells", cells );
// Associate the checkbox with the header
header.jqmData( "input", input );
}
});
......@@ -13498,9 +13554,33 @@ $.widget( "mobile.table", $.mobile.table, {
},
_refresh: function( create ) {
var headers, hiddenColumns, index;
// Calling _super() here updates this.headers
this._super( create );
if ( !create && this.options.mode === "columntoggle" ) {
headers = this.headers;
hiddenColumns = [];
// Find the index of the column header associated with each old checkbox among the
// post-refresh headers and, if the header is still there, make sure the corresponding
// column will be hidden if the pre-refresh checkbox indicates that the column is
// hidden by recording its index in the array of hidden columns.
this._menu.find( "input" ).each( function() {
var input = $( this ),
header = input.jqmData( "header" ),
index = headers.index( header[ 0 ] );
if ( index > -1 && !input.prop( "checked" ) ) {
// The column header associated with /this/ checkbox is still present in the
// post-refresh table and the checkbox is not checked, so the column associated
// with this column header is currently hidden. Let's record that.
hiddenColumns.push( index );
}
});
// columns not being replaced must be cleared from input toggle-locks
this._unlockCells( this.element.find( ".ui-table-cell-hidden, " +
".ui-table-cell-visible" ) );
......@@ -13508,8 +13588,14 @@ $.widget( "mobile.table", $.mobile.table, {
// update columntoggles and cells
this._addToggles( this._menu, create );
// check/uncheck
this._setToggleState();
// At this point all columns are visible, so uncheck the checkboxes that correspond to
// those columns we've found to be hidden
for ( index = hiddenColumns.length - 1 ; index > -1 ; index-- ) {
headers.eq( hiddenColumns[ index ] ).jqmData( "input" )
.prop( "checked", false )
.checkboxradio( "refresh" )
.trigger( "change" );
}
}
},
......@@ -13712,7 +13798,8 @@ $.widget( "mobile.filterable", {
// If nothing is hidden, then the decision whether to hide or show the items
// is based on the "filterReveal" option.
if ( hide.length === 0 ) {
filterItems[ opts.filterReveal ? "addClass" : "removeClass" ]( "ui-screen-hidden" );
filterItems[ ( opts.filterReveal && val.length === 0 ) ?
"addClass" : "removeClass" ]( "ui-screen-hidden" );
} else {
$( hide ).addClass( "ui-screen-hidden" );
$( show ).removeClass( "ui-screen-hidden" );
......@@ -13763,6 +13850,8 @@ $.widget( "mobile.filterable", {
this.document.find( selector );
this._on( search, {
keydown: "_onKeyDown",
keypress: "_onKeyPress",
keyup: "_onKeyUp",
change: "_onKeyUp",
input: "_onKeyUp"
......@@ -13772,6 +13861,21 @@ $.widget( "mobile.filterable", {
this._search = search;
},
// Prevent form submission
_onKeyDown: function( event ) {
if ( event.keyCode === $.ui.keyCode.ENTER ) {
event.preventDefault();
this._preventKeyPress = true;
}
},
_onKeyPress: function( event ) {
if ( this._preventKeyPress ) {
event.preventDefault();
this._preventKeyPress = false;
}
},
_setOptions: function( options ) {
var refilter = !( ( options.filterReveal === undefined ) &&
( options.filterCallback === undefined ) &&
......@@ -13875,6 +13979,8 @@ $.widget( "mobile.filterable", $.mobile.filterable, {
// Also trigger listviewbeforefilter if this widget is also a listview
this._widget._trigger( "beforefilter", event, data );
}
// Passing back the response enables calling preventDefault()
return this._super( type, event, data );
},
......@@ -13990,6 +14096,24 @@ $.widget( "mobile.filterable", $.mobile.filterable, {
}
});
// Instantiate a filterable on a listview that has the data-filter="true" attribute
// This is not necessary for static content, because the auto-enhance takes care of instantiating
// the filterable upon encountering data-filter="true". However, because of 1.3.x it is expected
// that a listview with data-filter="true" will be filterable even if you just instantiate a
// listview on it. The extension below ensures that this continues to happen in 1.4.x.
$.widget( "mobile.listview", $.mobile.listview, {
options: {
filter: false
},
_create: function() {
if ( this.options.filter === true &&
!this.element.data( "mobile-filterable" ) ) {
this.element.filterable();
}
return this._super();
}
});
})( jQuery );
/*!
......@@ -15054,3 +15178,5 @@ $.widget( "ui.tabs", {
}));
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment