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

Last change on this file since 26803 was 16012, checked in by grum, 12 years ago

feature:2634- compatibility with Piwigo 2.4
+add some objects on js framework

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