Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 812ce9d

Browse files
committed
Core: Integrate ui core remove keyCode and uuid function from mobile helpers
1 parent f09ed24 commit 812ce9d

File tree

7 files changed

+305
-41
lines changed

7 files changed

+305
-41
lines changed

Gruntfile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ module.exports = function( grunt ) {
7070
"!js/jquery.hashchange.js",
7171
"!js/jquery.js",
7272
"!js/jquery.ui.widget.js",
73-
"!js/widgets/jquery.ui.tabs.js"
73+
"!js/widgets/jquery.ui.tabs.js",
74+
"!js/jquery.ui.core.js"
7475
]
7576
}
7677
},

js/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
'events/throttledresize.js',
1919
'events/orientationchange.js',
2020
'jquery.hashchange.js',
21+
'jquery.ui.core.js',
2122
'jquery.mobile.defaults.js',
2223
'jquery.mobile.helpers.js',
2324
'jquery.mobile.data.js',

js/jquery.mobile.helpers.js

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//>>css.structure: ../css/structure/jquery.mobile.core.css
66
//>>css.theme: ../css/themes/default/jquery.mobile.theme.css
77

8-
define( [ "jquery", "./jquery.mobile.ns", "json!../package.json" ], function( jQuery ) {
8+
define( [ "jquery", "./jquery.mobile.ns", "./jquery.ui.core", "json!../package.json" ], function( jQuery ) {
99
//>>excludeEnd("jqmBuildExclude");
1010
(function( $, window, undefined ) {
1111

@@ -16,24 +16,7 @@ define( [ "jquery", "./jquery.mobile.ns", "json!../package.json" ], function( jQ
1616
document: $( document ),
1717

1818
//TODO: Remove once we pull in UI Core
19-
keyCode: {
20-
BACKSPACE: 8,
21-
COMMA: 188,
22-
DELETE: 46,
23-
DOWN: 40,
24-
END: 35,
25-
ENTER: 13,
26-
ESCAPE: 27,
27-
HOME: 36,
28-
LEFT: 37,
29-
PAGE_DOWN: 34,
30-
PAGE_UP: 33,
31-
PERIOD: 190,
32-
RIGHT: 39,
33-
SPACE: 32,
34-
TAB: 9,
35-
UP: 38
36-
},
19+
keyCode: $.ui.keyCode,
3720

3821
// Place to store various widget extensions
3922
behaviors: {},
@@ -189,26 +172,7 @@ define( [ "jquery", "./jquery.mobile.ns", "json!../package.json" ], function( jQ
189172
$.find.matchesSelector = function( node, expr ) {
190173
return $.find( expr, null, null, [ node ] ).length > 0;
191174
};
192-
//Needed for ui widgets
193-
//TODO: Remove once ui core is pulled in
194-
var uuid = 0,
195-
runiqueId = /^ui-id-\d+$/;
196-
$.fn.extend({
197-
uniqueId: function() {
198-
return this.each(function() {
199-
if ( !this.id ) {
200-
this.id = "ui-id-" + (++uuid);
201-
}
202-
});
203-
},
204-
removeUniqueId: function() {
205-
return this.each(function() {
206-
if ( runiqueId.test( this.id ) ) {
207-
$( this ).removeAttr( "id" );
208-
}
209-
});
210-
}
211-
});
175+
212176
})( jQuery, this );
213177
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
214178
});

js/jquery.mobile.init.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
define([
88
"jquery",
9+
"./jquery.ui.core",
910
"./jquery.mobile.defaults",
1011
"./jquery.mobile.helpers",
1112
"./jquery.mobile.data",

js/jquery.ui.core.js

Lines changed: 293 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,293 @@
1+
/*!
2+
* jQuery UI Core @VERSION
3+
* http://jqueryui.com
4+
*
5+
* Copyright 2013 jQuery Foundation and other contributors
6+
* Released under the MIT license.
7+
* http://jquery.org/license
8+
*
9+
* http://api.jqueryui.com/category/ui-core/
10+
*/
11+
(function( $, undefined ) {
12+
13+
var uuid = 0,
14+
runiqueId = /^ui-id-\d+$/;
15+
16+
// $.ui might exist from components with no dependencies, e.g., $.ui.position
17+
$.ui = $.ui || {};
18+
19+
$.extend( $.ui, {
20+
version: "@VERSION",
21+
22+
keyCode: {
23+
BACKSPACE: 8,
24+
COMMA: 188,
25+
DELETE: 46,
26+
DOWN: 40,
27+
END: 35,
28+
ENTER: 13,
29+
ESCAPE: 27,
30+
HOME: 36,
31+
LEFT: 37,
32+
PAGE_DOWN: 34,
33+
PAGE_UP: 33,
34+
PERIOD: 190,
35+
RIGHT: 39,
36+
SPACE: 32,
37+
TAB: 9,
38+
UP: 38
39+
}
40+
});
41+
42+
// plugins
43+
$.fn.extend({
44+
focus: (function( orig ) {
45+
return function( delay, fn ) {
46+
return typeof delay === "number" ?
47+
this.each(function() {
48+
var elem = this;
49+
setTimeout(function() {
50+
$( elem ).focus();
51+
if ( fn ) {
52+
fn.call( elem );
53+
}
54+
}, delay );
55+
}) :
56+
orig.apply( this, arguments );
57+
};
58+
})( $.fn.focus ),
59+
60+
scrollParent: function() {
61+
var scrollParent;
62+
if (($.ui.ie && (/(static|relative)/).test(this.css("position"))) || (/absolute/).test(this.css("position"))) {
63+
scrollParent = this.parents().filter(function() {
64+
return (/(relative|absolute|fixed)/).test($.css(this,"position")) && (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
65+
}).eq(0);
66+
} else {
67+
scrollParent = this.parents().filter(function() {
68+
return (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
69+
}).eq(0);
70+
}
71+
72+
return ( /fixed/ ).test( this.css( "position") ) || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
73+
},
74+
75+
uniqueId: function() {
76+
return this.each(function() {
77+
if ( !this.id ) {
78+
this.id = "ui-id-" + (++uuid);
79+
}
80+
});
81+
},
82+
83+
removeUniqueId: function() {
84+
return this.each(function() {
85+
if ( runiqueId.test( this.id ) ) {
86+
$( this ).removeAttr( "id" );
87+
}
88+
});
89+
}
90+
});
91+
92+
// selectors
93+
function focusable( element, isTabIndexNotNaN ) {
94+
var map, mapName, img,
95+
nodeName = element.nodeName.toLowerCase();
96+
if ( "area" === nodeName ) {
97+
map = element.parentNode;
98+
mapName = map.name;
99+
if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
100+
return false;
101+
}
102+
img = $( "img[usemap=#" + mapName + "]" )[0];
103+
return !!img && visible( img );
104+
}
105+
return ( /input|select|textarea|button|object/.test( nodeName ) ?
106+
!element.disabled :
107+
"a" === nodeName ?
108+
element.href || isTabIndexNotNaN :
109+
isTabIndexNotNaN) &&
110+
// the element and all of its ancestors must be visible
111+
visible( element );
112+
}
113+
114+
function visible( element ) {
115+
return $.expr.filters.visible( element ) &&
116+
!$( element ).parents().addBack().filter(function() {
117+
return $.css( this, "visibility" ) === "hidden";
118+
}).length;
119+
}
120+
121+
$.extend( $.expr[ ":" ], {
122+
data: $.expr.createPseudo ?
123+
$.expr.createPseudo(function( dataName ) {
124+
return function( elem ) {
125+
return !!$.data( elem, dataName );
126+
};
127+
}) :
128+
// support: jQuery <1.8
129+
function( elem, i, match ) {
130+
return !!$.data( elem, match[ 3 ] );
131+
},
132+
133+
focusable: function( element ) {
134+
return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
135+
},
136+
137+
tabbable: function( element ) {
138+
var tabIndex = $.attr( element, "tabindex" ),
139+
isTabIndexNaN = isNaN( tabIndex );
140+
return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
141+
}
142+
});
143+
144+
// support: jQuery <1.8
145+
if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
146+
$.each( [ "Width", "Height" ], function( i, name ) {
147+
var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
148+
type = name.toLowerCase(),
149+
orig = {
150+
innerWidth: $.fn.innerWidth,
151+
innerHeight: $.fn.innerHeight,
152+
outerWidth: $.fn.outerWidth,
153+
outerHeight: $.fn.outerHeight
154+
};
155+
156+
function reduce( elem, size, border, margin ) {
157+
$.each( side, function() {
158+
size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
159+
if ( border ) {
160+
size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
161+
}
162+
if ( margin ) {
163+
size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
164+
}
165+
});
166+
return size;
167+
}
168+
169+
$.fn[ "inner" + name ] = function( size ) {
170+
if ( size === undefined ) {
171+
return orig[ "inner" + name ].call( this );
172+
}
173+
174+
return this.each(function() {
175+
$( this ).css( type, reduce( this, size ) + "px" );
176+
});
177+
};
178+
179+
$.fn[ "outer" + name] = function( size, margin ) {
180+
if ( typeof size !== "number" ) {
181+
return orig[ "outer" + name ].call( this, size );
182+
}
183+
184+
return this.each(function() {
185+
$( this).css( type, reduce( this, size, true, margin ) + "px" );
186+
});
187+
};
188+
});
189+
}
190+
191+
// support: jQuery <1.8
192+
if ( !$.fn.addBack ) {
193+
$.fn.addBack = function( selector ) {
194+
return this.add( selector == null ?
195+
this.prevObject : this.prevObject.filter( selector )
196+
);
197+
};
198+
}
199+
200+
// support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
201+
if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
202+
$.fn.removeData = (function( removeData ) {
203+
return function( key ) {
204+
if ( arguments.length ) {
205+
return removeData.call( this, $.camelCase( key ) );
206+
} else {
207+
return removeData.call( this );
208+
}
209+
};
210+
})( $.fn.removeData );
211+
}
212+
213+
214+
215+
216+
217+
// deprecated
218+
$.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
219+
220+
$.support.selectstart = "onselectstart" in document.createElement( "div" );
221+
$.fn.extend({
222+
disableSelection: function() {
223+
return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
224+
".ui-disableSelection", function( event ) {
225+
event.preventDefault();
226+
});
227+
},
228+
229+
enableSelection: function() {
230+
return this.unbind( ".ui-disableSelection" );
231+
},
232+
233+
zIndex: function( zIndex ) {
234+
if ( zIndex !== undefined ) {
235+
return this.css( "zIndex", zIndex );
236+
}
237+
238+
if ( this.length ) {
239+
var elem = $( this[ 0 ] ), position, value;
240+
while ( elem.length && elem[ 0 ] !== document ) {
241+
// Ignore z-index if position is set to a value where z-index is ignored by the browser
242+
// This makes behavior of this function consistent across browsers
243+
// WebKit always returns auto if the element is positioned
244+
position = elem.css( "position" );
245+
if ( position === "absolute" || position === "relative" || position === "fixed" ) {
246+
// IE returns 0 when zIndex is not specified
247+
// other browsers return a string
248+
// we ignore the case of nested elements with an explicit value of 0
249+
// <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
250+
value = parseInt( elem.css( "zIndex" ), 10 );
251+
if ( !isNaN( value ) && value !== 0 ) {
252+
return value;
253+
}
254+
}
255+
elem = elem.parent();
256+
}
257+
}
258+
259+
return 0;
260+
}
261+
});
262+
263+
// $.ui.plugin is deprecated. Use $.widget() extensions instead.
264+
$.ui.plugin = {
265+
add: function( module, option, set ) {
266+
var i,
267+
proto = $.ui[ module ].prototype;
268+
for ( i in set ) {
269+
proto.plugins[ i ] = proto.plugins[ i ] || [];
270+
proto.plugins[ i ].push( [ option, set[ i ] ] );
271+
}
272+
},
273+
call: function( instance, name, args, allowDisconnected ) {
274+
var i,
275+
set = instance.plugins[ name ];
276+
277+
if ( !set ) {
278+
return;
279+
}
280+
281+
if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
282+
return;
283+
}
284+
285+
for ( i = 0; i < set.length; i++ ) {
286+
if ( instance.options[ set[ i ][ 0 ] ] ) {
287+
set[ i ][ 1 ].apply( instance.element, args );
288+
}
289+
}
290+
}
291+
};
292+
293+
})( jQuery );

js/requirejs.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ requirejs.config({
1414
},
1515
"widgets/jquery.ui.tabs": {
1616
deps: [ "jquery.ui.widget" ]
17+
},
18+
"widgets/jquery.ui.core": {
19+
deps: [ "jquery" ],
20+
exports: [ "$.ui" ]
1721
}
1822
}
1923
});

0 commit comments

Comments
 (0)