Skip to content

Commit f00868a

Browse files
RTL support
1 parent a623c56 commit f00868a

34 files changed

+109
-50
lines changed

jquery-ui-sliderAccess.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@
3131
upText: '+',
3232
downText: '-',
3333
buttonset: true,
34-
buttonsetTag: 'span'
34+
buttonsetTag: 'span',
35+
isRTL: false
3536
}, options),
3637
$buttons = $('<'+ o.buttonsetTag +' class="ui-slider-access">'+
37-
'<button data-icon="'+ o.downIcon +'" data-step="-'+ o.step +'">'+ o.downText +'</button>'+
38-
'<button data-icon="'+ o.upIcon +'" data-step="'+ o.step +'">'+ o.upText +'</button>'+
38+
'<button data-icon="'+ o.downIcon +'" data-step="'+ (o.isRTL? o.step : o.step*-1) +'">'+ o.downText +'</button>'+
39+
'<button data-icon="'+ o.upIcon +'" data-step="'+ (o.isRTL? o.step*-1 : o.step) +'">'+ o.upText +'</button>'+
3940
'</'+ o.buttonsetTag +'>');
4041

4142
$buttons.children('button').each(function(j, jobj){
@@ -73,8 +74,8 @@
7374

7475
// adjust the width so we don't break the original layout
7576
var bOuterWidth = $buttons.css({
76-
marginLeft: (o.where == 'after'? 10:0),
77-
marginRight: (o.where == 'before'? 10:0)
77+
marginLeft: ((o.where == 'after' && !o.isRTL) || (o.where == 'before' && o.isRTL)? 10:0),
78+
marginRight: ((o.where == 'before' && !o.isRTL) || (o.where == 'after' && o.isRTL)? 10:0)
7879
}).outerWidth(true) + 5;
7980
var tOuterWidth = $t.outerWidth(true);
8081
$t.css('display','inline-block').width(tOuterWidth-bOuterWidth);

jquery-ui-timepicker-addon.js

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,8 @@
406406
size = 100 * gridSize[litem] * o[litem+'Grid'] / (max[litem] - o[litem+'Min']);
407407
$tp.find('.ui_tpicker_'+litem+' table').css({
408408
width: size + "%",
409-
marginLeft: (size / (-2 * gridSize[litem])) + "%",
409+
marginLeft: o.isRTL? '0' : ((size / (-2 * gridSize[litem])) + "%"),
410+
marginRight: o.isRTL? ((size / (-2 * gridSize[litem])) + "%") : '0',
410411
borderCollapse: 'collapse'
411412
}).find("td").click(function(e){
412413
var $t = $(this),
@@ -487,7 +488,10 @@
487488

488489
// slideAccess integration: http://trentrichardson.com/2011/11/11/jquery-ui-sliders-and-touch-accessibility/
489490
if (this._defaults.addSliderAccess) {
490-
var sliderAccessArgs = this._defaults.sliderAccessArgs;
491+
var sliderAccessArgs = this._defaults.sliderAccessArgs,
492+
rtl = this._defaults.isRTL;
493+
sliderAccessArgs.isRTL = rtl;
494+
491495
setTimeout(function() { // fix for inline mode
492496
if ($tp.find('.ui-slider-access').length === 0) {
493497
$tp.find('.ui-slider:visible').sliderAccess(sliderAccessArgs);
@@ -498,14 +502,12 @@
498502
$tp.find('table:visible').each(function() {
499503
var $g = $(this),
500504
oldWidth = $g.outerWidth(),
501-
oldMarginLeft = $g.css('marginLeft').toString().replace('%', ''),
505+
oldMarginLeft = $g.css(rtl? 'marginRight':'marginLeft').toString().replace('%', ''),
502506
newWidth = oldWidth - sliderAccessWidth,
503-
newMarginLeft = ((oldMarginLeft * newWidth) / oldWidth) + '%';
504-
505-
$g.css({
506-
width: newWidth,
507-
marginLeft: newMarginLeft
508-
});
507+
newMarginLeft = ((oldMarginLeft * newWidth) / oldWidth) + '%',
508+
css = { width: newWidth, marginRight: 0, marginLeft: 0 };
509+
css[rtl? 'marginRight':'marginLeft'] = newMarginLeft;
510+
$g.css(css);
509511
});
510512
}
511513
}
@@ -816,14 +818,15 @@
816818
// slider methods
817819
slider: {
818820
create: function(tp_inst, obj, unit, val, min, max, step){
821+
var rtl = tp_inst._defaults.isRTL; // if rtl go -60->0 instead of 0->60
819822
return obj.prop('slide', null).slider({
820823
orientation: "horizontal",
821-
value: val,
822-
min: min,
823-
max: max,
824+
value: rtl? val*-1 : val,
825+
min: rtl? max*-1 : min,
826+
max: rtl? min*-1 : max,
824827
step: step,
825828
slide: function(event, ui) {
826-
tp_inst.control.value(tp_inst, $(this), ui.value);
829+
tp_inst.control.value(tp_inst, $(this), rtl? ui.value*-1:ui.value);
827830
tp_inst._onTimeChange();
828831
},
829832
stop: function(event, ui) {
@@ -832,11 +835,34 @@
832835
});
833836
},
834837
options: function(tp_inst, obj, opts, val){
838+
if(tp_inst._defaults.isRTL){
839+
if(typeof(opts) == 'string'){
840+
if(opts == 'min' || opts == 'max'){
841+
if(val !== undefined)
842+
return obj.slider(opts, val*-1);
843+
return Math.abs(obj.slider(opts));
844+
}
845+
return obj.slider(opts);
846+
}
847+
var min = opts.min,
848+
max = opts.max;
849+
opts.min = opts.max = null;
850+
if(min !== undefined)
851+
opts.max = min * -1;
852+
if(max !== undefined)
853+
opts.min = max * -1;
854+
return obj.slider(opts);
855+
}
835856
if(typeof(opts) == 'string' && val !== undefined)
836857
return obj.slider(opts, val);
837858
return obj.slider(opts);
838859
},
839860
value: function(tp_inst, obj, val){
861+
if(tp_inst._defaults.isRTL){
862+
if(val !== undefined)
863+
return obj.slider('value', val*-1);
864+
return Math.abs(obj.slider('value'));
865+
}
840866
if(val !== undefined)
841867
return obj.slider('value', val);
842868
return obj.slider('value');

localization/jquery-ui-timepicker-af.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: 'hh:mm tt',
1515
amNames: ['AM', 'A'],
1616
pmNames: ['PM', 'P'],
17-
ampm: false
17+
ampm: false,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional['af']);
2021
})(jQuery);

localization/jquery-ui-timepicker-bg.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: 'hh:mm tt',
1515
amNames: ['AM', 'A'],
1616
pmNames: ['PM', 'P'],
17-
ampm: false
17+
ampm: false,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional['bg']);
2021
})(jQuery);

localization/jquery-ui-timepicker-ca.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: 'hh:mm',
1515
amNames: ['AM', 'A'],
1616
pmNames: ['PM', 'P'],
17-
ampm: false
17+
ampm: false,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional['ca']);
2021
})(jQuery);

localization/jquery-ui-timepicker-cs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: 'h:m',
1515
amNames: ['dop.', 'AM', 'A'],
1616
pmNames: ['odp.', 'PM', 'P'],
17-
ampm: false
17+
ampm: false,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional['cs']);
2021
})(jQuery);

localization/jquery-ui-timepicker-de.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: 'hh:mm tt',
1515
amNames: ['vorm.', 'AM', 'A'],
1616
pmNames: ['nachm.', 'PM', 'P'],
17-
ampm: false
17+
ampm: false,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional['de']);
2021
})(jQuery);

localization/jquery-ui-timepicker-el.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: 'hh:mm',
1515
amNames: ['π.μ.', 'AM', 'A'],
1616
pmNames: ['μ.μ.', 'PM', 'P'],
17-
ampm: false
17+
ampm: false,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional['el']);
2021
})(jQuery);

localization/jquery-ui-timepicker-es.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: 'hh:mm',
1515
amNames: ['a.m.', 'AM', 'A'],
1616
pmNames: ['p.m.', 'PM', 'P'],
17-
ampm: false
17+
ampm: false,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional['es']);
2021
})(jQuery);

localization/jquery-ui-timepicker-et.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: 'hh:mm tt',
1515
amNames: ['AM', 'A'],
1616
pmNames: ['PM', 'P'],
17-
ampm: false
17+
ampm: false,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional['et']);
2021
})(jQuery);

localization/jquery-ui-timepicker-fi.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: 'hh:mm',
1515
amNames: ['ap.', 'AM', 'A'],
1616
pmNames: ['ip.', 'PM', 'P'],
17-
ampm: false
17+
ampm: false,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional['fi']);
2021
})(jQuery);

localization/jquery-ui-timepicker-fr.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: 'hh:mm',
1515
amNames: ['AM', 'A'],
1616
pmNames: ['PM', 'P'],
17-
ampm: false
17+
ampm: false,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional['fr']);
2021
})(jQuery);

localization/jquery-ui-timepicker-gl.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: 'hh:mm',
1515
amNames: ['a.m.', 'AM', 'A'],
1616
pmNames: ['p.m.', 'PM', 'P'],
17-
ampm: false
17+
ampm: false,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional['gl']);
2021
})(jQuery);

localization/jquery-ui-timepicker-he.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: "hh:mm tt",
1515
amNames: ['לפנה"צ', 'AM', 'A'],
1616
pmNames: ['אחה"צ', 'PM', 'P'],
17-
ampm: false
17+
ampm: false,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional["he"]);
2021
})(jQuery);

localization/jquery-ui-timepicker-hu.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: 'hh:mm tt',
1515
amNames: ['de.', 'AM', 'A'],
1616
pmNames: ['du.', 'PM', 'P'],
17-
ampm: false
17+
ampm: false,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional['hu']);
2021
})(jQuery);

localization/jquery-ui-timepicker-id.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: 'hh:mm tt',
1515
amNames: ['AM', 'A'],
1616
pmNames: ['PM', 'P'],
17-
ampm: false
17+
ampm: false,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional['id']);
2021
})(jQuery);

localization/jquery-ui-timepicker-it.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: 'hh:mm',
1515
amNames: ['m.', 'AM', 'A'],
1616
pmNames: ['p.', 'PM', 'P'],
17-
ampm: false
17+
ampm: false,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional['it']);
2021
})(jQuery);

localization/jquery-ui-timepicker-ja.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: 'hh:mm tt',
1515
amNames: ['午前', 'AM', 'A'],
1616
pmNames: ['午後', 'PM', 'P'],
17-
ampm: false
17+
ampm: false,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional['ja']);
2021
})(jQuery);

localization/jquery-ui-timepicker-ko.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: 'tt h:mm',
1515
amNames: ['오전', 'AM', 'A'],
1616
pmNames: ['오후', 'PM', 'P'],
17-
ampm: true
17+
ampm: true,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional['ko']);
2021
})(jQuery);

localization/jquery-ui-timepicker-lt.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: 'hh:mm',
1515
amNames: ['priešpiet', 'AM', 'A'],
1616
pmNames: ['popiet', 'PM', 'P'],
17-
ampm: false
17+
ampm: false,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional['lt']);
2021
})(jQuery);

localization/jquery-ui-timepicker-nl.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: 'hh:mm tt',
1515
amNames: ['AM', 'A'],
1616
pmNames: ['PM', 'P'],
17-
ampm: false
17+
ampm: false,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional['nl']);
2021
})(jQuery);

localization/jquery-ui-timepicker-no.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: 'hh:mm',
1515
amNames: ['am', 'AM', 'A'],
1616
pmNames: ['pm', 'PM', 'P'],
17-
ampm: false
17+
ampm: false,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional['no']);
2021
})(jQuery);

localization/jquery-ui-timepicker-pl.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: 'hh:mm tt',
1515
amNames: ['AM', 'A'],
1616
pmNames: ['PM', 'P'],
17-
ampm: false
17+
ampm: false,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional['pl']);
2021
})(jQuery);

localization/jquery-ui-timepicker-pt-BR.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: 'hh:mm',
1515
amNames: ['a.m.', 'AM', 'A'],
1616
pmNames: ['p.m.', 'PM', 'P'],
17-
ampm: false
17+
ampm: false,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional['pt-BR']);
2021
})(jQuery);

localization/jquery-ui-timepicker-pt.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: 'hh:mm',
1515
amNames: ['a.m.', 'AM', 'A'],
1616
pmNames: ['p.m.', 'PM', 'P'],
17-
ampm: false
17+
ampm: false,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional['pt']);
2021
})(jQuery);

localization/jquery-ui-timepicker-ro.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: 'hh:mm',
1515
amNames: ['AM', 'A'],
1616
pmNames: ['PM', 'P'],
17-
ampm: false
17+
ampm: false,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional['ro']);
2021
})(jQuery);

localization/jquery-ui-timepicker-ru.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: 'hh:mm tt',
1515
amNames: ['AM', 'A'],
1616
pmNames: ['PM', 'P'],
17-
ampm: false
17+
ampm: false,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional['ru']);
2021
})(jQuery);

localization/jquery-ui-timepicker-sk.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: 'h:m',
1515
amNames: ['dop.', 'AM', 'A'],
1616
pmNames: ['pop.', 'PM', 'P'],
17-
ampm: false
17+
ampm: false,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional['sk']);
2021
})(jQuery);

localization/jquery-ui-timepicker-sv.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
timeFormat: 'hh:mm',
1515
amNames: ['AM', 'A'],
1616
pmNames: ['PM', 'P'],
17-
ampm: false
17+
ampm: false,
18+
isRTL: false
1819
};
1920
$.timepicker.setDefaults($.timepicker.regional['sv']);
2021
})(jQuery);

0 commit comments

Comments
 (0)