|
406 | 406 | size = 100 * gridSize[litem] * o[litem+'Grid'] / (max[litem] - o[litem+'Min']); |
407 | 407 | $tp.find('.ui_tpicker_'+litem+' table').css({ |
408 | 408 | 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', |
410 | 411 | borderCollapse: 'collapse' |
411 | 412 | }).find("td").click(function(e){ |
412 | 413 | var $t = $(this), |
|
487 | 488 |
|
488 | 489 | // slideAccess integration: http://trentrichardson.com/2011/11/11/jquery-ui-sliders-and-touch-accessibility/ |
489 | 490 | 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 | + |
491 | 495 | setTimeout(function() { // fix for inline mode |
492 | 496 | if ($tp.find('.ui-slider-access').length === 0) { |
493 | 497 | $tp.find('.ui-slider:visible').sliderAccess(sliderAccessArgs); |
|
498 | 502 | $tp.find('table:visible').each(function() { |
499 | 503 | var $g = $(this), |
500 | 504 | oldWidth = $g.outerWidth(), |
501 | | - oldMarginLeft = $g.css('marginLeft').toString().replace('%', ''), |
| 505 | + oldMarginLeft = $g.css(rtl? 'marginRight':'marginLeft').toString().replace('%', ''), |
502 | 506 | 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); |
509 | 511 | }); |
510 | 512 | } |
511 | 513 | } |
|
816 | 818 | // slider methods |
817 | 819 | slider: { |
818 | 820 | 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 |
819 | 822 | return obj.prop('slide', null).slider({ |
820 | 823 | 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, |
824 | 827 | step: step, |
825 | 828 | 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); |
827 | 830 | tp_inst._onTimeChange(); |
828 | 831 | }, |
829 | 832 | stop: function(event, ui) { |
|
832 | 835 | }); |
833 | 836 | }, |
834 | 837 | 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 | + } |
835 | 856 | if(typeof(opts) == 'string' && val !== undefined) |
836 | 857 | return obj.slider(opts, val); |
837 | 858 | return obj.slider(opts); |
838 | 859 | }, |
839 | 860 | 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 | + } |
840 | 866 | if(val !== undefined) |
841 | 867 | return obj.slider('value', val); |
842 | 868 | return obj.slider('value'); |
|
0 commit comments