mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-04-21 14:44:44 +00:00
moved native shared component into shared, will do the same for custom
This commit is contained in:
parent
64a9b595d3
commit
9eec8df520
3 changed files with 90 additions and 128 deletions
|
|
@ -26,7 +26,8 @@ $elements = array(
|
|||
'jquery.mobile.forms.button.js',
|
||||
'jquery.mobile.forms.slider.js',
|
||||
'jquery.mobile.forms.textinput.js',
|
||||
'jquery.mobile.forms.nativeselect.js',
|
||||
'jquery.mobile.forms.select.shared.js',
|
||||
'jquery.mobile.forms.select.native.js',
|
||||
'jquery.mobile.forms.select.js',
|
||||
'jquery.mobile.buttonMarkup.js',
|
||||
'jquery.mobile.controlGroup.js',
|
||||
|
|
|
|||
84
js/jquery.mobile.forms.select.native.js
Normal file
84
js/jquery.mobile.forms.select.native.js
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* jQuery Mobile Framework : "selectmenu" plugin
|
||||
* Copyright (c) jQuery Project
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
(function( $, undefined ) {
|
||||
|
||||
$.widget( "mobile.nativeselect", $.mobile.widget, {
|
||||
options: {
|
||||
theme: null,
|
||||
disabled: false,
|
||||
icon: "arrow-d",
|
||||
iconpos: "right",
|
||||
inline: null,
|
||||
corners: true,
|
||||
shadow: true,
|
||||
iconshadow: true,
|
||||
menuPageTheme: "b",
|
||||
overlayTheme: "a",
|
||||
hidePlaceholderMenuItems: true,
|
||||
closeText: "Close",
|
||||
nativeMenu: true,
|
||||
initSelector: "select:not(jqmData(native-menu='false')):not(:jqmData(role='slider'))"
|
||||
},
|
||||
|
||||
_shared: $.mobile.selectShared,
|
||||
|
||||
_native: function() {
|
||||
var widget = this;
|
||||
|
||||
return $.extend( this._shared(), {
|
||||
typeName: 'native',
|
||||
|
||||
button: $( "<div/>" ),
|
||||
|
||||
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 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 );
|
||||
})
|
||||
.bind( "change blur", function() {
|
||||
self.button.removeClass( "ui-btn-down-" + widget.options.theme );
|
||||
});
|
||||
},
|
||||
|
||||
refresh: function() {
|
||||
var self = this,
|
||||
selected = this.selected();
|
||||
|
||||
self.setButtonText();
|
||||
self.setButtonCount();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_create: function() {
|
||||
var self = this,
|
||||
|
||||
o = this.options,
|
||||
|
||||
menu = this._native();
|
||||
|
||||
// Expose to other methods
|
||||
$.extend( self, menu );
|
||||
}
|
||||
});
|
||||
})( jQuery );
|
||||
|
|
@ -1,31 +1,13 @@
|
|||
/*
|
||||
* jQuery Mobile Framework : "selectmenu" plugin
|
||||
* jQuery Mobile Framework : common functionality for the custom and native
|
||||
* select menus
|
||||
* Copyright (c) jQuery Project
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
(function( $, undefined ) {
|
||||
|
||||
$.widget( "mobile.nativeselect", $.mobile.widget, {
|
||||
options: {
|
||||
theme: null,
|
||||
disabled: false,
|
||||
icon: "arrow-d",
|
||||
iconpos: "right",
|
||||
inline: null,
|
||||
corners: true,
|
||||
shadow: true,
|
||||
iconshadow: true,
|
||||
menuPageTheme: "b",
|
||||
overlayTheme: "a",
|
||||
hidePlaceholderMenuItems: true,
|
||||
closeText: "Close",
|
||||
nativeMenu: true,
|
||||
initSelector: "select:not(jqmData(native-menu='false')):not(:jqmData(role='slider'))"
|
||||
},
|
||||
|
||||
_common: function(){
|
||||
$.mobile.selectShared = function(){
|
||||
var widget = this,
|
||||
select = this.element.wrap( "<div class='ui-select'>" );
|
||||
|
||||
|
|
@ -169,110 +151,5 @@ $.widget( "mobile.nativeselect", $.mobile.widget, {
|
|||
}, 40);
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
_native: function() {
|
||||
var widget = this;
|
||||
|
||||
return $.extend( this._common(), {
|
||||
typeName: 'native',
|
||||
|
||||
button: $( "<div/>" ),
|
||||
|
||||
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 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 );
|
||||
})
|
||||
.bind( "change blur", function() {
|
||||
self.button.removeClass( "ui-btn-down-" + widget.options.theme );
|
||||
});
|
||||
},
|
||||
|
||||
refresh: function() {
|
||||
var self = this,
|
||||
selected = this.selected();
|
||||
|
||||
self.setButtonText();
|
||||
self.setButtonCount();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_create: function() {
|
||||
var self = this,
|
||||
|
||||
o = this.options,
|
||||
|
||||
menu = this._native(),
|
||||
|
||||
// IE throws an exception at options.item() function when
|
||||
// there is no selected item
|
||||
// select first in this case
|
||||
selectedIndex = menu.select[ 0 ].selectedIndex == -1 ? 0 : menu.select[ 0 ].selectedIndex,
|
||||
|
||||
// TODO values buttonId and menuId are undefined here
|
||||
button = menu.button
|
||||
.text( $( menu.select[ 0 ].options.item( selectedIndex ) ).text() )
|
||||
.insertBefore( menu.select )
|
||||
.buttonMarkup( {
|
||||
theme: o.theme,
|
||||
icon: o.icon,
|
||||
iconpos: o.iconpos,
|
||||
inline: o.inline,
|
||||
corners: o.corners,
|
||||
shadow: o.shadow,
|
||||
iconshadow: o.iconshadow
|
||||
}),
|
||||
|
||||
// Multi select or not
|
||||
isMultiple = self.isMultiple = menu.select[ 0 ].multiple;
|
||||
|
||||
// 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 ) {
|
||||
menu.select.addClass( "ui-select-nativeonly" );
|
||||
}
|
||||
|
||||
// Add counter for multi selects
|
||||
if ( menu.isMultiple ) {
|
||||
self.buttonCount = $( "<span>" )
|
||||
.addClass( "ui-li-count ui-btn-up-c ui-btn-corner-all" )
|
||||
.hide()
|
||||
.appendTo( button );
|
||||
}
|
||||
|
||||
// Disable if specified
|
||||
if ( o.disabled ) {
|
||||
this.disable();
|
||||
}
|
||||
|
||||
// Events on native select
|
||||
menu.select.change( function() {
|
||||
self.refresh();
|
||||
});
|
||||
|
||||
// Expose to other methods
|
||||
$.extend( self, menu );
|
||||
|
||||
menu.build();
|
||||
}
|
||||
});
|
||||
})( jQuery );
|
||||
})(jQuery);
|
||||
Loading…
Reference in a new issue