Permalink
Browse files

Widgets: Move initSelector out of the prototype.

  • Loading branch information...
gabrielschulhof committed Mar 27, 2013
1 parent 919a10f commit cbe643fe904654c1aa0149f87b50b1cfb02c3910
@@ -40,7 +40,7 @@ $.widget( "mobile.widget", {
},
enhanceWithin: function( target, useKeepNative ) {
- this.enhance( $( this.options.initSelector, $( target )), useKeepNative );
+ this.enhance( $( $[ this.namespace ][ this.widgetName ].initSelector, $( target ) ), useKeepNative );
},
enhance: function( targets, useKeepNative ) {
@@ -22,8 +22,7 @@ $.widget( "mobile.collapsible", $.mobile.widget, {
contentTheme: null,
inset: true,
corners: true,
- mini: false,
- initSelector: ":jqmData(role='collapsible')"
+ mini: false
},
_create: function() {
@@ -157,6 +156,8 @@ $.widget( "mobile.collapsible", $.mobile.widget, {
}
});
+$.mobile.collapsible.initSelector = ":jqmData(role='collapsible')";
+
//auto self-init widgets
$.mobile._enhancer.add( "mobile.collapsible" );
@@ -10,9 +10,6 @@ define( [ "jquery", "../jquery.mobile.widget", "./collapsible", "./addFirstLastC
(function( $, undefined ) {
$.widget( "mobile.collapsibleset", $.mobile.widget, $.extend( {
- options: {
- initSelector: ":jqmData(role='collapsible-set')"
- },
_create: function() {
var $el = this.element.addClass( "ui-collapsible-set" ),
o = this.options;
@@ -80,6 +77,8 @@ $.widget( "mobile.collapsibleset", $.mobile.widget, $.extend( {
}
}, $.mobile.behaviors.addFirstLastClasses ) );
+$.mobile.collapsibleset.initSelector = ":jqmData(role='collapsible-set')";
+
//auto self-init widgets
$.mobile._enhancer.add( "mobile.collapsibleset" );
@@ -19,8 +19,7 @@ define( [ "jquery",
corners: true,
excludeInvisible: true,
type: "vertical",
- mini: false,
- initSelector: ":jqmData(role='controlgroup')"
+ mini: false
},
_create: function() {
@@ -98,6 +97,8 @@ define( [ "jquery",
}
}, $.mobile.behaviors.addFirstLastClasses ) );
+ $.mobile.controlgroup.initSelector = ":jqmData(role='controlgroup')";
+
$.mobile._enhancer.add( "mobile.controlgroup", {
dependencies: [ "mobile.selectmenu", "mobile.button", "mobile.buttonmarkup", "mobile.checkboxradio" ]
});
View
@@ -14,8 +14,7 @@ $.widget( "mobile.dialog", $.mobile.widget, {
closeBtn: "left",
closeBtnText: "Close",
overlayTheme: "a",
- corners: true,
- initSelector: ":jqmData(role='dialog')"
+ corners: true
},
// Override the theme set by the page plugin on pageshow
@@ -157,8 +156,9 @@ $.widget( "mobile.dialog", $.mobile.widget, {
}
});
+$.mobile.dialog.initSelector = ":jqmData(role='dialog')";
//auto self-init widgets
-$.mobile.document.delegate( $.mobile.dialog.prototype.options.initSelector, "pagecreate", function() {
+$.mobile.document.delegate( $.mobile.dialog.initSelector, "pagecreate", function() {
$.mobile.dialog.prototype.enhance( this );
});
@@ -30,8 +30,7 @@ define( [ "jquery", "../jquery.mobile.widget", "../jquery.mobile.core", "../jque
// This is a plugin option like any other, so feel free to improve or overwrite it
supportBlacklist: function() {
return !$.support.fixedPosition;
- },
- initSelector: ":jqmData(position='fixed')"
+ }
},
_create: function() {
@@ -269,6 +268,8 @@ define( [ "jquery", "../jquery.mobile.widget", "../jquery.mobile.core", "../jque
});
+ $.mobile.fixedtoolbar.initSelector = ":jqmData(position='fixed')";
+
//auto self-init widgets
// NOTE: The implementation via $.mobile._enhancer removes support for
// data-fullscreen=true|false on the page element. This support was
@@ -36,8 +36,7 @@ $.widget( "mobile.button", $.mobile.widget, {
shadow: true,
iconshadow: true,
inline: null,
- mini: null,
- initSelector: "button, [type='button'], [type='submit'], [type='reset']"
+ mini: null
},
_create: function() {
@@ -156,6 +155,8 @@ $.widget( "mobile.button", $.mobile.widget, {
}
});
+$.mobile.button.initSelector = "button, [type='button'], [type='submit'], [type='reset']";
+
//auto self-init widgets
$.mobile._enhancer.add( "mobile.button" );
@@ -16,8 +16,7 @@ define( [ "jquery", "../../jquery.mobile.core", "../../jquery.mobile.widget", ".
$.widget( "mobile.checkboxradio", $.mobile.widget, $.extend( {
options: {
theme: null,
- mini: false,
- initSelector: "input[type='checkbox'],input[type='radio']"
+ mini: false
},
_create: function() {
var input = this.element,
@@ -208,6 +207,8 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, $.extend( {
}
}, $.mobile.behaviors.formReset ) );
+$.mobile.checkboxradio.initSelector = "input[type='checkbox'],input[type='radio']";
+
//auto self-init widgets
$.mobile._enhancer.add( "mobile.checkboxradio" );
@@ -14,7 +14,6 @@ define( [ "jquery", "../../jquery.mobile.core", "../../jquery.mobile.widget", ".
theme: null,
trackTheme: null,
disabled: false,
- initSelector: ":jqmData(role='rangeslider')",
mini: false,
highlight: true
},
@@ -195,6 +194,8 @@ define( [ "jquery", "../../jquery.mobile.core", "../../jquery.mobile.widget", ".
}, $.mobile.behaviors.formReset ) );
+$.mobile.rangeslider.initSelector = ":jqmData(role='rangeslider')";
+
//auto self-init widgets
$.mobile._enhancer.add( "mobile.rangeslider", { dependencies: [ "mobile.slider" ] } );
@@ -26,7 +26,6 @@ $.widget( "mobile.selectmenu", $.mobile.widget, $.extend( {
nativeMenu: true,
// This option defaults to true on iOS devices.
preventFocusZoom: /iPhone|iPad|iPod/.test( navigator.platform ) && navigator.userAgent.indexOf( "AppleWebKit" ) > -1,
- initSelector: "select:not( :jqmData(role='slider') )",
mini: false
},
@@ -286,6 +285,8 @@ $.widget( "mobile.selectmenu", $.mobile.widget, $.extend( {
}
}, $.mobile.behaviors.formReset ) );
+$.mobile.selectmenu.initSelector = "select:not( :jqmData(role='slider') )";
+
//auto self-init widgets
$.mobile._enhancer.add( "mobile.selectmenu" );
})( jQuery );
@@ -16,7 +16,6 @@ $.widget( "mobile.slider", $.mobile.widget, $.extend( {
theme: null,
trackTheme: null,
disabled: false,
- initSelector: "input[type='range'], :jqmData(type='range'), :jqmData(role='slider')",
mini: false,
highlight: false
},
@@ -504,6 +503,8 @@ $.widget( "mobile.slider", $.mobile.widget, $.extend( {
}, $.mobile.behaviors.formReset ) );
+$.mobile.slider.initSelector = "input[type='range'], :jqmData(type='range'), :jqmData(role='slider')";
+
//auto self-init widgets
$.mobile._enhancer.add( "mobile.slider" );
@@ -15,7 +15,6 @@ $.widget( "mobile.textinput", $.mobile.widget, {
mini: false,
// This option defaults to true on iOS devices.
preventFocusZoom: /iPhone|iPad|iPod/.test( navigator.platform ) && navigator.userAgent.indexOf( "AppleWebKit" ) > -1,
- initSelector: "input[type='text'], input[type='search'], :jqmData(type='search'), input[type='number'], :jqmData(type='number'), input[type='password'], input[type='email'], input[type='url'], input[type='tel'], textarea, input[type='time'], input[type='date'], input[type='month'], input[type='week'], input[type='datetime'], input[type='datetime-local'], input[type='color'], input:not([type]), input[type='file']",
clearBtn: false,
clearSearchButtonText: null, //deprecating for 1.3...
clearBtnText: "clear text",
@@ -181,6 +180,8 @@ $.widget( "mobile.textinput", $.mobile.widget, {
}
});
+$.mobile.textinput.initSelector = "input[type='text'], input[type='search'], :jqmData(type='search'), input[type='number'], :jqmData(type='number'), input[type='password'], input[type='email'], input[type='url'], input[type='tel'], textarea, input[type='time'], input[type='date'], input[type='month'], input[type='week'], input[type='datetime'], input[type='datetime-local'], input[type='color'], input:not([type]), input[type='file']";
+
//auto self-init widgets
$.mobile._enhancer.add( "mobile.textinput" );
View
@@ -26,8 +26,7 @@ $.widget( "mobile.listview", $.mobile.widget, $.extend( {
splitTheme: "b",
corners: true,
shadow: true,
- inset: false,
- initSelector: ":jqmData(role='listview')"
+ inset: false
},
_create: function() {
@@ -380,6 +379,8 @@ $.widget( "mobile.listview", $.mobile.widget, $.extend( {
}
}, $.mobile.behaviors.addFirstLastClasses ) );
+$.mobile.listview.initSelector = ":jqmData(role='listview')";
+
//auto self-init widgets
$.mobile._enhancer.add( "mobile.listview" );
View
@@ -13,8 +13,7 @@ define( [ "jquery", "../jquery.mobile.widget", "../jquery.mobile.buttonMarkup",
$.widget( "mobile.navbar", $.mobile.widget, {
options: {
iconpos: "top",
- grid: null,
- initSelector: ":jqmData(role='navbar')"
+ grid: null
},
_create: function() {
@@ -56,6 +55,8 @@ $.widget( "mobile.navbar", $.mobile.widget, {
}
});
+$.mobile.navbar.initSelector = ":jqmData(role='navbar')";
+
//auto self-init widgets
$.mobile._enhancer.add( "mobile.navbar" );
View
@@ -34,7 +34,6 @@ $.widget( "mobile.panel", $.mobile.widget, {
position: "left",
dismissible: true,
display: "reveal", //accepts reveal, push, overlay
- initSelector: ":jqmData(role='panel')",
swipeClose: true,
positionFixed: false
},
@@ -458,6 +457,8 @@ $.widget( "mobile.panel", $.mobile.widget, {
}
});
+$.mobile.panel.initSelector = ":jqmData(role='panel')";
+
//auto self-init widgets
$.mobile._enhancer.add( "mobile.panel" );
View
@@ -60,7 +60,6 @@ define( [
transition: "none",
positionTo: "origin",
tolerance: null,
- initSelector: ":jqmData(role='popup')",
closeLinkSelector: "a:jqmData(rel='back')",
closeLinkEvents: "click.popup",
navigateEvents: "navigate.popup",
@@ -868,6 +867,7 @@ define( [
}
});
+ $.mobile.popup.initSelector = ":jqmData(role='popup')";
// TODO this can be moved inside the widget
$.mobile.popup.handleLink = function( $link ) {
View
@@ -15,8 +15,7 @@ var tableClasses = {
$.widget( "mobile.table", $.mobile.widget, {
options: {
- classes: tableClasses,
- initSelector: ":jqmData(role='table')"
+ classes: tableClasses
},
_create: function() {
@@ -66,6 +65,7 @@ $.widget( "mobile.table", $.mobile.widget, {
});
$.mobile.table.classes = tableClasses;
+$.mobile.table.initSelector = ":jqmData(role='table')";
//auto self-init widgets
$.mobile._enhancer.add( "mobile.table" );

0 comments on commit cbe643f

Please sign in to comment.