source: extensions/GrumPluginClasses/js/ui.inputNum.js @ 8961

Last change on this file since 8961 was 8961, checked in by grum, 13 years ago

release 3.4.0
fix bug:1984, bug:2109
js file are minified, remove packed files

  • Property svn:executable set to *
File size: 31.2 KB
Line 
1/**
2 * -----------------------------------------------------------------------------
3 * file: ui.inputNum.js
4 * file version: 1.0.0
5 * date: 2010-11-02
6 *
7 * A jQuery plugin provided by the piwigo's plugin "GrumPluginClasses"
8 *
9 * -----------------------------------------------------------------------------
10 * Author     : Grum
11 *   email    : grum@piwigo.com
12 *   website  : http://photos.grum.fr
13 *   PWG user : http://forum.phpwebgallery.net/profile.php?id=3706
14 *
15 *   << May the Little SpaceFrog be with you ! >>
16 * -----------------------------------------------------------------------------
17 *
18 *
19 *
20 *
21 * :: HISTORY ::
22 *
23 * | release | date       |
24 * | 1.0.0   | 2010/10/10 | first release
25 * |         |            |
26 * |         |            |
27 * |         |            |
28 * |         |            |
29 * |         |            |
30 * |         |            |
31 *
32 */
33
34
35
36(
37  function($)
38  {
39    /*
40     * plugin 'public' functions
41     */
42    var publicMethods =
43    {
44      init : function (opt)
45        {
46          return this.each(function()
47            {
48              // default values for the plugin
49              var $this=$(this),
50                  data = $this.data('options'),
51                  objects = $this.data('objects'),
52                  properties = $this.data('properties'),
53                  options =
54                    {
55                      numDec:0,
56                      minValue:'none',
57                      maxValue:'none',
58                      stepValue:1,
59                      showSlider:'no',
60                      disabled:false,
61                      textAlign:'right',
62                      btInc:'+',
63                      btDec:'-',
64                      unitValue:'',
65                      change:null
66                    };
67
68              // if options given, merge it
69              // if(opt) $.extend(options, opt); ==> options are set by setters
70
71              $this.data('options', options);
72
73
74              if(!properties)
75              {
76                $this.data('properties',
77                  {
78                    initialized:false,
79                    re:/^\d+$/,
80                    value:0,
81                    factor:1,
82                    isSlider:false,
83                    isValid:true,
84                    mouseIsOver:false,
85                    isSliderCurrentlyVisible:false,
86                    inputMargins:0
87                  }
88                );
89                properties=$this.data('properties');
90              }
91
92              if(!objects)
93              {
94                objects =
95                  {
96                    container:$('<div/>',
97                        {
98                          'class':'ui-inputNum',
99                          css:{
100                            width:'100%'
101                          }
102                        }
103                    ).bind('click.inputNum',
104                        function ()
105                        {
106                          objects.input.focus();
107                        }
108                      )
109                    .bind('mouseenter',
110                        function ()
111                        {
112                          properties.mouseIsOver=true;
113                        }
114                      )
115                    .bind('mouseleave',
116                        function ()
117                        {
118                          properties.mouseIsOver=false;
119                        }
120                      ),
121                    input:$('<input>',
122                      {
123                        type:"text",
124                        value:''
125                      }
126                    ).bind('focusout.inputNum',
127                        function ()
128                        {
129                          privateMethods.lostFocus($this);
130                        }
131                      )
132                      .bind('focus.inputNum',
133                          function ()
134                          {
135                            privateMethods.getFocus($this);
136                          }
137                        )
138                      .bind('keydown.inputNum',
139                          function (event)
140                          {
141                            return(privateMethods.keyDown($this, event));
142                          }
143                        )
144                      .bind('keyup.inputNum',
145                          function (event)
146                          {
147                            privateMethods.keyUp($this, event);
148                          }
149                        ),
150                    slider:$('<div/>',
151                      {
152                        css:{
153                          display:'none'
154                        }
155                      }
156                    ),
157                    extraContainer:$('<div/>',
158                      {
159                        'class':'ui-inputNum-extra'
160                      }
161                    ),
162                    unit:$('<div/>',
163                        {
164                          html: "",
165                          'class':'ui-inputNum-unit',
166                          css: {
167                            display:'none'
168                          }
169                        }
170                    ),
171                    btInc:$('<div/>',
172                      {
173                        'class':'ui-inputNum-btInc',
174                        tabindex:0
175                      }
176                    ).bind('click',
177                        function (event)
178                        {
179                          privateMethods.incValue($this);
180                        }
181                      )
182                     .bind('mousedown', function () { $(this).addClass('ui-inputNum-btInc-active'); } )
183                     .bind('mouseup', function () { $(this).removeClass('ui-inputNum-btInc-active'); } ),
184                    btDec:$('<div/>',
185                      {
186                        'class':'ui-inputNum-btDec',
187                        tabindex:0
188                      }
189                    ).bind('click',
190                        function (event)
191                        {
192                          privateMethods.decValue($this);
193                        }
194                      )
195                     .bind('mousedown', function () { $(this).addClass('ui-inputNum-btDec-active'); } )
196                     .bind('mouseup', function () { $(this).removeClass('ui-inputNum-btDec-active'); } )
197                  };
198
199                $this
200                  .html('')
201                  .append(objects.container.append(objects.input).append(objects.extraContainer.append(objects.unit).append(objects.btInc).append(objects.btDec)).append(objects.slider));
202
203                properties.inputMargins=objects.input.outerWidth(true)-objects.input.width();
204
205
206                $this.data('objects', objects);
207              }
208
209              privateMethods.setOptions($this, opt);
210            }
211          );
212        }, // init
213
214      destroy : function ()
215        {
216          return this.each(
217            function()
218            {
219              // default values for the plugin
220              var $this=$(this),
221                  objects = $this.data('objects');
222              objects.input.unbind().remove();
223              objects.btInc.unbind().remove();
224              objects.btDec.unbind().remove();
225              objects.container.unbind().remove();
226              $this
227                .unbind('.inputNum')
228                .css(
229                  {
230                    width:'',
231                    height:''
232                  }
233                );
234            }
235          );
236        }, // destroy
237
238      options: function (value)
239        {
240          return this.each(function()
241            {
242              privateMethods.setOptions($(this), value);
243            }
244          );
245        }, // options
246
247      showSlider: function (value)
248        {
249          if(value!=null)
250          {
251            this.each(function()
252              {
253                privateMethods.setShowSlider($(this), value);
254              }
255            );
256          }
257          else
258          {
259            var options = this.data('options');
260
261            if(options)
262            {
263              return(options.showSlider);
264            }
265            else
266            {
267              return('');
268            }
269          }
270        }, // showSlider
271
272      minValue: function (value)
273        {
274          if(value!=null)
275          {
276            return this.each(function()
277              {
278                privateMethods.setMinValue($(this), value);
279              }
280            );
281          }
282          else
283          {
284            var options = this.data('options');
285
286            if(options)
287            {
288              return(options.minValue);
289            }
290            else
291            {
292              return('');
293            }
294          }
295        }, // minValue
296
297      maxValue: function (value)
298        {
299          if(value!=null)
300          {
301            return this.each(function()
302              {
303                privateMethods.setMaxValue($(this), value);
304              }
305            );
306          }
307          else
308          {
309            var options = this.data('options');
310
311            if(options)
312            {
313              return(options.maxValue);
314            }
315            else
316            {
317              return('');
318            }
319          }
320        }, // maxValue
321
322      stepValue: function (value)
323        {
324          if(value!=null)
325          {
326            return this.each(function()
327              {
328                privateMethods.setStepValue($(this), value);
329              }
330            );
331          }
332          else
333          {
334            var options = this.data('options');
335
336            if(options)
337            {
338              return(options.stepValue);
339            }
340            else
341            {
342              return('');
343            }
344          }
345        }, // stepValue
346
347      numDec: function (value)
348        {
349          if(value!=null)
350          {
351            return this.each(function()
352              {
353                privateMethods.setNumDec($(this), value);
354              }
355            );
356          }
357          else
358          {
359            var options = this.data('options');
360
361            if(options)
362            {
363              return(options.numDec);
364            }
365            else
366            {
367              return('');
368            }
369          }
370        }, // numDec
371
372      unitValue: function (value)
373        {
374          if(value!=null)
375          {
376            return this.each(function()
377              {
378                privateMethods.setUnitValue($(this), value);
379              }
380            );
381          }
382          else
383          {
384            var options = this.data('options');
385
386            if(options)
387            {
388              return(options.unitValue);
389            }
390            else
391            {
392              return('');
393            }
394          }
395        }, // unitValue
396
397      disabled: function (value)
398        {
399          if(value!=null)
400          {
401            return this.each(function()
402              {
403                privateMethods.setDisabled($(this), value);
404              }
405            );
406          }
407          else
408          {
409            var options = this.data('options');
410
411            if(options)
412            {
413              return(options.disabled);
414            }
415            else
416            {
417              return('');
418            }
419          }
420        }, // disabled
421
422      textAlign: function (value)
423        {
424          if(value!=null)
425          {
426            return this.each(function()
427              {
428                privateMethods.setTextAlign($(this), value);
429              }
430            );
431          }
432          else
433          {
434            var options = this.data('options');
435
436            if(options)
437            {
438              return(options.textAlign);
439            }
440            else
441            {
442              return('');
443            }
444          }
445        }, // textAlign
446
447      btInc: function (value)
448        {
449          if(value!=null)
450          {
451            return this.each(function()
452              {
453                privateMethods.setBtInc($(this), value);
454              }
455            );
456          }
457          else
458          {
459            var options = this.data('options');
460
461            if(options)
462            {
463              return(options.btInc);
464            }
465            else
466            {
467              return('');
468            }
469          }
470        }, // btInc
471
472      btDec: function (value)
473        {
474          if(value!=null)
475          {
476            return this.each(function()
477              {
478                privateMethods.setBtDec($(this), value);
479              }
480            );
481          }
482          else
483          {
484            var options = this.data('options');
485
486            if(options)
487            {
488              return(options.btDec);
489            }
490            else
491            {
492              return('');
493            }
494          }
495        }, // btDec
496
497
498      value: function (value)
499        {
500          if(value!=null)
501          {
502            // set selected value
503            return this.each(function()
504              {
505                privateMethods.setValue($(this), value, true);
506              }
507            );
508          }
509          else
510          {
511            // return the selected tags
512            var properties=this.data('properties');
513            return(properties.value);
514          }
515        }, // value
516
517      isValid: function (value)
518        {
519          if(value!=null)
520          {
521            // set selected value
522            return this.each(function()
523              {
524                privateMethods.setIsValid($(this), value);
525              }
526            );
527          }
528          else
529          {
530            // return the selected tags
531            var properties=this.data('properties');
532            return(properties.isValid);
533          }
534        }, // isValid
535
536      change: function (value)
537        {
538          if(value!=null && $.isFunction(value))
539          {
540            // set selected value
541            return this.each(function()
542              {
543                privateMethods.setEventChange($(this), value);
544              }
545            );
546          }
547          else
548          {
549            // return the selected value
550            var options=this.data('options');
551
552            if(options)
553            {
554              return(options.change);
555            }
556            else
557            {
558              return(null);
559            }
560          }
561        } // change
562
563    }; // methods
564
565
566    /*
567     * plugin 'private' methods
568     */
569    var privateMethods =
570    {
571      /**
572       * return true is given value is a valid numeric value, according to the
573       * rules defined by the object
574       * @param Object object
575       * @param value
576       * @return Bool
577       */
578      isValid : function (object, value)
579        {
580          var properties=object.data('properties');
581
582          return(properties.re.exec(value))
583        },
584
585      /**
586       * define the regular expression used to check validity of a numeric value
587       * @param Object object
588       */
589      setRE : function (object)
590        {
591          var properties=object.data('properties'),
592              options=object.data('options'),
593              tmpRe="\\d+";
594
595          if(options.numDec>0)
596          {
597            tmpRe+="(\\.\\d{0,"+options.numDec+"})?";
598          }
599          tmpRe+="$";
600
601          if(options.minValue=='none' || options.minValue!='none' && options.minValue<0 )
602          {
603            if(options.maxValue!='none' && options.maxValue<0)
604            {
605              tmpRe="\\-"+tmpRe;
606            }
607            else
608            {
609              tmpRe="(\\-)?"+tmpRe;
610            }
611          }
612          tmpRe="^"+tmpRe;
613          properties.re = new RegExp(tmpRe);
614        },
615
616      setOptions : function (object, value)
617        {
618          var properties=object.data('properties'),
619              options=object.data('options');
620
621          if(!$.isPlainObject(value)) return(false);
622
623          properties.initialized=false;
624
625          privateMethods.setNumDec(object, (value.numDec!=null)?value.numDec:options.numDec);
626          privateMethods.setStepValue(object, (value.stepValue!=null)?value.stepValue:options.stepValue);
627          privateMethods.setMinValue(object, (value.minValue!=null)?value.minValue:options.minValue);
628          privateMethods.setMaxValue(object, (value.maxValue!=null)?value.maxValue:options.maxValue);
629          privateMethods.setValue(object, (value.value!=null)?value.value:options.value, true);
630
631          privateMethods.setUnitValue(object, (value.unitValue!=null)?value.unitValue:options.unitValue);
632          privateMethods.setShowSlider(object, (value.showSlider!=null)?value.showSlider:options.showSlider);
633          privateMethods.setDisabled(object, (value.disabled!=null)?value.disabled:options.disabled);
634          privateMethods.setBtInc(object, (value.btInc!=null)?value.btInc:options.btInc);
635          privateMethods.setBtDec(object, (value.btDec!=null)?value.btDec:options.btDec);
636          privateMethods.setTextAlign(object, (value.textAlign!=null)?value.textAlign:options.textAlign);
637
638          privateMethods.setEventChange(object, (value.change!=null)?value.change:options.change);
639
640          privateMethods.calculateInputWidth(object);
641
642          properties.initialized=true;
643        },
644
645      setIsValid : function (object, value)
646        {
647          var objects=object.data('objects'),
648              properties=object.data('properties');
649
650          if(properties.isValid!=value)
651          {
652            properties.isValid=value;
653            if(properties.isValid)
654            {
655              objects.container.removeClass('ui-error');
656              objects.input.removeClass('ui-error');
657            }
658            else
659            {
660              objects.container.addClass('ui-error');
661              objects.input.addClass('ui-error');
662            }
663          }
664          return(properties.isValid);
665        },
666
667      setNumDec : function (object, value)
668        {
669          var options=object.data('options'),
670              properties=object.data('properties');
671
672          if((!properties.initialized || options.numDec!=value) && value>=0 && value<=15)
673          {
674            options.numDec=value;
675            privateMethods.setRE(object);
676            properties.factor=Math.pow(10,options.numDec);
677          }
678          return(options.numDec);
679        },
680
681      setStepValue : function (object, value)
682        {
683          var options=object.data('options'),
684              properties=object.data('properties');
685
686          if((!properties.initialized || options.stepValue!=value) && value>0 && privateMethods.isValid(object, value))
687          {
688            options.stepValue=value;
689          }
690          return(options.stepValue);
691        },
692
693      setShowSlider : function (object, value)
694        {
695          var options=object.data('options'),
696              objects=object.data('objects'),
697              properties=object.data('properties');
698
699          if((!properties.initialized || options.showSlider!=value) && (value=='no' || value=='yes' || value=='auto'))
700          {
701            options.showSlider=value;
702            privateMethods.manageSlider(object);
703          }
704          return(options.showSlider);
705        },
706
707      setMinValue : function (object, value)
708        {
709          var options=object.data('options'),
710              properties=object.data('properties');
711
712          if((!properties.initialized || options.minValue!=value) && (value=='none' || privateMethods.isValid(object, value)))
713          {
714            options.minValue=value;
715            if(options.minValue>options.maxValue) options.maxValue=options.minValue;
716            privateMethods.setRE(object);
717            privateMethods.manageSlider(object);
718          }
719          return(options.minValue);
720        },
721
722      setMaxValue : function (object, value)
723        {
724          var options=object.data('options'),
725              properties=object.data('properties');
726
727          if(
728              (!properties.initialized || options.maxValue!=value) &&
729              (value=='none' || privateMethods.isValid(object, value) &&
730                (options.minValue<=value && options.minValue!='none' || options.minValue=='none')
731              )
732            )
733          {
734            options.maxValue=value;
735            privateMethods.setRE(object);
736            privateMethods.manageSlider(object);
737          }
738          return(options.maxValue);
739        },
740
741      setUnitValue : function (object, value)
742        {
743          var options=object.data('options'),
744              objects=object.data('objects'),
745              properties=object.data('properties');
746
747          if(!properties.initialized || options.unitValue!=value)
748          {
749            options.unitValue=value;
750            objects.unit.html(options.unitValue).css('display', ($.trim(value)=='')?'none':'');
751
752            privateMethods.calculateInputWidth(object);
753          }
754          return(options.unitValue);
755        },
756
757      setBtInc : function (object, value)
758        {
759          var options=object.data('options'),
760              objects=object.data('objects'),
761              properties=object.data('properties');
762
763          if(!properties.initialized || options.btInc!=value)
764          {
765            options.btInc=value;
766            objects.btInc.html(options.btInc);
767          }
768          return(options.btInc);
769        },
770
771      setBtDec : function (object, value)
772        {
773          var options=object.data('options'),
774              objects=object.data('objects'),
775              properties=object.data('properties');
776
777          if(!properties.initialized || options.btDec!=value)
778          {
779            options.btDec=value;
780            objects.btDec.html(options.btDec);
781          }
782          return(options.btDec);
783        },
784
785      setDisabled : function (object, value)
786        {
787          var options=object.data('options'),
788              objects=object.data('objects'),
789              properties=object.data('properties');
790
791          if((!properties.initialized || options.disabled!=value) && (value==true || value==false))
792          {
793            options.disabled=value;
794            if(options.disabled)
795            {
796              objects.btDec.attr('disabled', true);
797              objects.btInc.attr('disabled', true);
798              objects.input.attr('disabled', true);
799            }
800            else
801            {
802              objects.input.attr('disabled', false);
803              privateMethods.setButtonsState(object);
804            }
805          }
806          return(options.disabled);
807        },
808
809      setTextAlign : function (object, value)
810        {
811          var options=object.data('options'),
812              objects=object.data('objects'),
813              properties=object.data('properties');
814
815          if((!properties.initialized || options.textAlign!=value) && (value=='left' || value=='right'))
816          {
817            options.textAlign=value;
818            objects.input.css('text-align', options.textAlign);
819          }
820          return(options.textAlign);
821        },
822
823      setButtonsState : function (object)
824        {
825          var options=object.data('options'),
826              objects=object.data('objects'),
827              properties=object.data('properties');
828
829          if(options.minValue!='none' && properties.value - options.stepValue < options.minValue)
830          {
831            objects.btDec.attr('disabled', true);
832          }
833          else
834          {
835            objects.btDec.attr('disabled', false);
836          }
837
838          if(options.maxValue!='none' && properties.value + options.stepValue > options.maxValue)
839          {
840            objects.btInc.attr('disabled', true);
841          }
842          else
843          {
844            objects.btInc.attr('disabled', false);
845          }
846        },
847
848      setValue : function (object, value, apply)
849        {
850          var options=object.data('options'),
851              properties=object.data('properties'),
852              objects=object.data('objects');
853
854          if(!privateMethods.isValid(object, value) ||
855              (!apply &&
856                (options.minValue!='none' && value < options.minValue ||
857                 options.maxValue!='none' && value > options.maxValue)
858              )
859            )
860          {
861            return(privateMethods.setIsValid(object, false));
862          }
863          else if(apply)
864          {
865            if(options.minValue!='none' && value < options.minValue) value=options.minValue;
866            if(options.maxValue!='none' && value > options.maxValue) value=options.maxValue;
867          }
868
869          privateMethods.setIsValid(object, true);
870
871          properties.value=value;
872          privateMethods.setButtonsState(object);
873
874          if(apply) objects.input.val(properties.value.toFixed(options.numDec));
875
876          if(properties.isSlider && properties.isSliderCurrentlyVisible) objects.slider.slider('value', properties.value);
877
878          if(options.change) object.trigger('inputNumChange', properties.value);
879
880          return(true);
881        }, //setValue
882
883      getFocus : function (object)
884        {
885          var objects=object.data('objects'),
886              options=object.data('options'),
887              properties=object.data('properties');
888
889          if(properties.isSlider && options.showSlider=='auto')
890          {
891            objects.slider
892              .css('display', 'block')
893              .css('width', (objects.container.width()-objects.slider.children('.ui-slider-handle').outerWidth(true))+'px')
894              .slider('value', properties.value);
895            properties.isSliderCurrentlyVisible=true;
896          }
897        },
898
899      lostFocus : function (object)
900        {
901          var objects=object.data('objects'),
902              options=object.data('options'),
903              properties=object.data('properties');
904
905          if(properties.mouseIsOver)
906          {
907            objects.input.focus();
908          }
909          else if(properties.isSlider && options.showSlider=='auto')
910          {
911            objects.slider.css('display', 'none');
912            properties.isSliderCurrentlyVisible=false;
913          }
914        },
915
916      setEventChange : function (object, value)
917        {
918          var options=object.data('options');
919
920          options.change=value;
921          object.unbind('inputNumChange');
922          if(value) object.bind('inputNumChange', options.change);
923          return(options.change);
924        },
925
926      keyUp : function (object, event)
927        {
928          var properties=object.data('properties'),
929              objects=object.data('objects');
930
931          if(!((event.keyCode>=48 && event.keyCode<=57) || //DOM_VK_0 - DOM_VK_9
932               (event.keyCode>=96 && event.keyCode<=105) || //DOM_VK_NUMPAD0 - DOM_VK_NUMPAD9
933                event.keyCode==190 || //DOT
934                event.keyCode==109 || //DOM_VK_SUBTRACT
935                event.keyCode==110 || //DOM_VK_DECIMAL
936                event.keyCode==8 || //DOM_VK_BACK_SPACE
937                event.keyCode==9 || //DOM_VK_TAB
938                event.keyCode==12 || //DOM_VK_CLEAR
939                event.keyCode==46 //DOM_VK_DELETE
940              )
941            ) return(false);
942
943          privateMethods.setValue(object, parseFloat(objects.input.val()), false);
944        },
945
946      keyDown : function (object, event)
947        {
948          var properties=object.data('properties'),
949              objects=object.data('objects');
950
951          if(!((event.keyCode>=48 && event.keyCode<=57) || //DOM_VK_0 - DOM_VK_9
952               (event.keyCode>=96 && event.keyCode<=105) || //DOM_VK_NUMPAD0 - DOM_VK_NUMPAD9
953                event.keyCode==190 || //DOT
954                event.keyCode==109 || //DOM_VK_SUBTRACT
955                event.keyCode==110 || //DOM_VK_DECIMAL
956                event.keyCode==8 || //DOM_VK_BACK_SPACE
957                event.keyCode==9 || //DOM_VK_TAB
958                event.keyCode==12 || //DOM_VK_CLEAR
959                event.keyCode==16 || //DOM_VK_SHIFT
960                event.keyCode==17 || //DOM_VK_CONTROL
961                event.keyCode==18 || //DOM_VK_ALT
962                event.keyCode==33 || //DOM_VK_PAGE_UP
963                event.keyCode==34 || //DOM_VK_PAGE_DOWN
964                event.keyCode==35 || //DOM_VK_END
965                event.keyCode==36 || //DOM_VK_HOME
966                event.keyCode==37 || //DOM_VK_LEFT
967                event.keyCode==38 || //DOM_VK_UP
968                event.keyCode==39 || //DOM_VK_RIGHT
969                event.keyCode==40 || //DOM_VK_DOWN
970                event.keyCode==45 || //DOM_VK_INSERT
971                event.keyCode==46 || //DOM_VK_DELETE
972                event.keyCode==93  //DOM_VK_CONTEXT_MENU
973              )
974            ) return(false);
975          return(true);
976        },
977
978      incValue : function (object)
979        {
980          var options=object.data('options'),
981              properties=object.data('properties');
982
983          nextValue=Math.round(properties.value*properties.factor+options.stepValue*properties.factor)/properties.factor;
984
985          if(options.maxValue=='none' || nextValue <= options.maxValue)
986          {
987            privateMethods.setValue(object, nextValue, true);
988          }
989        },
990
991      decValue : function (object)
992        {
993          var options=object.data('options'),
994              properties=object.data('properties');
995
996          nextValue=Math.round(properties.value*properties.factor-options.stepValue*properties.factor)/properties.factor;
997
998          if(options.minValue=='none' || nextValue >= options.minValue)
999          {
1000            privateMethods.setValue(object, nextValue, true);
1001          }
1002        },
1003
1004      manageSlider : function (object)
1005        {
1006          var options=object.data('options'),
1007              objects=object.data('objects'),
1008              properties=object.data('properties');
1009
1010          if(!properties.isSlider && options.minValue!='none' && options.maxValue!='none' && (options.showSlider=='yes' || options.showSlider=='auto'))
1011          {
1012            properties.isSlider=true;
1013            objects.slider.slider(
1014              {
1015                max:options.maxValue,
1016                min:options.minValue,
1017                step:options.stepValue,
1018                value:properties.value,
1019                slide:function (event, ui)
1020                  {
1021                    privateMethods.setValue(object, ui.value, true);
1022                  }
1023              }
1024            );
1025            objects.slider.children('.ui-slider-handle').bind('focusout', function () { privateMethods.lostFocus(object); } );
1026            if(options.showSlider=='yes')
1027            {
1028              objects.slider
1029                .css('display', 'block')
1030                .css('width', (objects.container.width()-objects.slider.children('.ui-slider-handle').outerWidth(true))+'px');
1031              properties.isSliderCurrentlyVisible=true;
1032            }
1033          }
1034          else if(properties.isSlider && (options.minValue=='none' || options.maxValue=='none' || options.showSlider=='no'))
1035          {
1036            properties.isSlider=false;
1037            properties.isSliderCurrentlyVisible=false;
1038            objects.slider.slider('destroy');
1039          }
1040        },
1041
1042      calculateInputWidth : function (object)
1043        {
1044          var objects=object.data('objects'),
1045              properties=object.data('properties');         
1046         
1047          objects.input.css('width', (objects.container.width()-objects.extraContainer.outerWidth()-properties.inputMargins)+'px');
1048        }
1049
1050    };
1051
1052
1053    $.fn.inputNum = function(method)
1054    {
1055      if(publicMethods[method])
1056      {
1057        return publicMethods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
1058      }
1059      else if(typeof method === 'object' || ! method)
1060      {
1061        return publicMethods.init.apply(this, arguments);
1062      }
1063      else
1064      {
1065        $.error( 'Method ' +  method + ' does not exist on jQuery.inputNum' );
1066      }
1067    } // $.fn.inputNum
1068
1069  }
1070)(jQuery);
1071
1072
Note: See TracBrowser for help on using the repository browser.