Skip to content

Commit bd1e993

Browse files
committed
Merge branch 'master' into grid
2 parents 4642f45 + bc71499 commit bd1e993

File tree

10 files changed

+103
-18
lines changed

10 files changed

+103
-18
lines changed

demos/datepicker/localization.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<script src="../../ui/jquery.ui.datepicker.js"></script>
1111
<script src="../../ui/i18n/jquery.ui.datepicker-af.js"></script>
1212
<script src="../../ui/i18n/jquery.ui.datepicker-ar.js"></script>
13+
<script src="../../ui/i18n/jquery.ui.datepicker-ar-DZ.js"></script>
1314
<script src="../../ui/i18n/jquery.ui.datepicker-az.js"></script>
1415
<script src="../../ui/i18n/jquery.ui.datepicker-bg.js"></script>
1516
<script src="../../ui/i18n/jquery.ui.datepicker-bs.js"></script>
@@ -87,6 +88,7 @@
8788
<select id="locale">
8889
<option value="af">Afrikaans</option>
8990
<option value="sq">Albanian (Gjuha shqipe)</option>
91+
<option value="ar-DZ">Algerian Arabic</option>
9092
<option value="ar">Arabic (&#8235;(&#1604;&#1593;&#1585;&#1576;&#1610;</option>
9193
<option value="hy">Armenian (&#1344;&#1377;&#1397;&#1381;&#1408;&#1381;&#1398;)</option>
9294
<option value="az">Azerbaijani (Az&#601;rbaycan dili)</option>

demos/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
<script src="../ui/jquery.effects.transfer.js"></script>
4545
<script src="../ui/i18n/jquery.ui.datepicker-af.js"></script>
4646
<script src="../ui/i18n/jquery.ui.datepicker-ar.js"></script>
47+
<script src="../ui/i18n/jquery.ui.datepicker-ar-DZ.js"></script>
4748
<script src="../ui/i18n/jquery.ui.datepicker-az.js"></script>
4849
<script src="../ui/i18n/jquery.ui.datepicker-bs.js"></script>
4950
<script src="../ui/i18n/jquery.ui.datepicker-bg.js"></script>

tests/unit/widget/widget_core.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,47 @@ test( "widget creation", function() {
2626
"option method copied over from base widget" );
2727
});
2828

29+
test( "element normalization", function() {
30+
expect( 10 );
31+
var elem;
32+
$.widget( "ui.testWidget", {} );
33+
34+
$.ui.testWidget.prototype._create = function() {
35+
ok( this.element.is( "div" ), "generated div" );
36+
same( this.element.data( "testWidget" ), this, "intance stored in .data()" );
37+
};
38+
$.ui.testWidget();
39+
40+
$.ui.testWidget.prototype.defaultElement = "<span data-test='pass'>";
41+
$.ui.testWidget.prototype._create = function() {
42+
ok( this.element.is( "span[data-test=pass]" ), "generated span with properties" );
43+
same( this.element.data( "testWidget" ), this, "instace stored in .data()" );
44+
};
45+
$.ui.testWidget();
46+
47+
elem = $( "<input>" );
48+
$.ui.testWidget.prototype._create = function() {
49+
same( this.element[ 0 ], elem[ 0 ], "from element" );
50+
same( elem.data( "testWidget" ), this, "instace stored in .data()" );
51+
};
52+
$.ui.testWidget( {}, elem[ 0 ] );
53+
54+
elem = $( "<div>" );
55+
$.ui.testWidget.prototype._create = function() {
56+
same( this.element[ 0 ], elem[ 0 ], "from jQuery object" );
57+
same( elem.data( "testWidget" ), this, "instace stored in .data()" );
58+
};
59+
$.ui.testWidget( {}, elem );
60+
61+
elem = $( "<div id='element-normalization-selector'></div>" )
62+
.appendTo( "#main" );
63+
$.ui.testWidget.prototype._create = function() {
64+
same( this.element[ 0 ], elem[ 0 ], "from selector" );
65+
same( elem.data( "testWidget" ), this, "instace stored in .data()" );
66+
};
67+
$.ui.testWidget( {}, "#element-normalization-selector" );
68+
});
69+
2970
test( "jQuery usage", function() {
3071
expect( 11 );
3172

ui/i18n/jquery.ui.datepicker-ar-DZ.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* Algerian Arabic Translation for jQuery UI date picker plugin. (can be used for Tunisia)*/
2+
/* Mohamed Cherif BOUCHELAGHEM -- cherifbouchelaghem@yahoo.fr */
3+
4+
jQuery(function($){
5+
$.datepicker.regional['ar-DZ'] = {
6+
closeText: 'إغلاق',
7+
prevText: '&#x3c;السابق',
8+
nextText: 'التالي&#x3e;',
9+
currentText: 'اليوم',
10+
monthNames: ['جانفي', 'فيفري', 'مارس', 'أفريل', 'ماي', 'جوان',
11+
'جويلية', 'أوت', 'سبتمبر','أكتوبر', 'نوفمبر', 'ديسمبر'],
12+
monthNamesShort: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'],
13+
dayNames: ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
14+
dayNamesShort: ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
15+
dayNamesMin: ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
16+
weekHeader: 'أسبوع',
17+
dateFormat: 'dd/mm/yy',
18+
firstDay: 6,
19+
isRTL: true,
20+
showMonthAfterYear: false,
21+
yearSuffix: ''};
22+
$.datepicker.setDefaults($.datepicker.regional['ar-DZ']);
23+
});

ui/jquery.ui.autocomplete.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
(function( $, undefined ) {
1717

1818
$.widget( "ui.autocomplete", {
19+
defaultElement: "<input>",
1920
options: {
2021
appendTo: "body",
2122
delay: 300,

ui/jquery.ui.button.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ var lastActive,
4343
};
4444

4545
$.widget( "ui.button", {
46+
defaultElement: "<button>",
4647
options: {
4748
disabled: null,
4849
text: true,

ui/jquery.ui.menu.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
var idIncrement = 0;
1717

1818
$.widget("ui.menu", {
19+
defaultElement: "<ul>",
1920
_create: function() {
2021
var self = this;
2122
this.menuId = this.element.attr( "id" ) || "ui-menu-" + idIncrement++;

ui/jquery.ui.sortable.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ $.widget("ui.sortable", $.ui.mouse, {
359359

360360
if(this.dragging) {
361361

362-
this._mouseUp();
362+
this._mouseUp({ target: null });
363363

364364
if(this.options.helper == "original")
365365
this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
@@ -377,21 +377,23 @@ $.widget("ui.sortable", $.ui.mouse, {
377377

378378
}
379379

380-
//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
381-
if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
382-
if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove();
383-
384-
$.extend(this, {
385-
helper: null,
386-
dragging: false,
387-
reverting: false,
388-
_noFinalSort: null
389-
});
380+
if (this.placeholder) {
381+
//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
382+
if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
383+
if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove();
390384

391-
if(this.domPosition.prev) {
392-
$(this.domPosition.prev).after(this.currentItem);
393-
} else {
394-
$(this.domPosition.parent).prepend(this.currentItem);
385+
$.extend(this, {
386+
helper: null,
387+
dragging: false,
388+
reverting: false,
389+
_noFinalSort: null
390+
});
391+
392+
if(this.domPosition.prev) {
393+
$(this.domPosition.prev).after(this.currentItem);
394+
} else {
395+
$(this.domPosition.parent).prepend(this.currentItem);
396+
}
395397
}
396398

397399
return this;

ui/jquery.ui.spinner.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
(function($) {
1515

1616
$.widget('ui.spinner', {
17+
defaultElement: "<input>",
1718
options: {
1819
incremental: true,
1920
max: null,

ui/jquery.ui.widget.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ $.widget = function( name, base, prototype ) {
3737

3838
$[ namespace ] = $[ namespace ] || {};
3939
$[ namespace ][ name ] = function( options, element ) {
40+
// allow instantiation without "new" keyword
41+
if ( !this._createWidget ) {
42+
return new $[ namespace ][ name ]( options, element );
43+
}
44+
4045
// allow instantiation without initializing for simple inheritance
46+
// must use "new" keyword (the code above always passes args)
4147
if ( arguments.length ) {
4248
this._createWidget( options, element );
4349
}
@@ -97,7 +103,7 @@ $.widget.bridge = function( name, object ) {
97103
if ( instance ) {
98104
instance.option( options || {} )._init();
99105
} else {
100-
$.data( this, name, new object( options, this ) );
106+
object( options, this );
101107
}
102108
});
103109
}
@@ -107,7 +113,13 @@ $.widget.bridge = function( name, object ) {
107113
};
108114

109115
$.Widget = function( options, element ) {
116+
// allow instantiation without "new" keyword
117+
if ( !this._createWidget ) {
118+
return new $[ namespace ][ name ]( options, element );
119+
}
120+
110121
// allow instantiation without initializing for simple inheritance
122+
// must use "new" keyword (the code above always passes args)
111123
if ( arguments.length ) {
112124
this._createWidget( options, element );
113125
}
@@ -116,12 +128,12 @@ $.Widget = function( options, element ) {
116128
$.Widget.prototype = {
117129
widgetName: "widget",
118130
widgetEventPrefix: "",
131+
defaultElement: "<div>",
119132
options: {
120133
disabled: false
121134
},
122135
_createWidget: function( options, element ) {
123-
// $.widget.bridge stores the plugin instance, but we do it anyway
124-
// so that it's stored even before the _create function runs
136+
element = $( element || this.defaultElement )[ 0 ];
125137
$.data( element, this.widgetName, this );
126138
this.element = $( element );
127139
this.options = $.extend( true, {},

0 commit comments

Comments
 (0)