source: extensions/GrumPluginClasses/js/ui.progressArea.js @ 16859

Last change on this file since 16859 was 16733, checked in by grum, 12 years ago

update GPC framework

File size: 32.4 KB
Line 
1/**
2 * -----------------------------------------------------------------------------
3 * file: ui.progressArea.js
4 * file version: 1.0.0
5 * date: 2012-07-13
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.piwigo.org/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   | 2012/07/13 | 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                  timeStamp=new Date(),
51                  data = $this.data('options'),
52                  objects = $this.data('objects'),
53                  properties = $this.data('properties'),
54                  options =
55                    {
56                      text:'',
57                      workInProgress:false,
58                      global:{
59                          visible:true,
60                          showPercent:true,
61                          percentDecimal:2,
62                          value:0,
63                          maxValue:100,
64                          text:'',
65                          complete:null,
66                          change:null
67                      },
68                      detail:{
69                          visible:false,
70                          showPercent:true,
71                          percentDecimal:2,
72                          value:0,
73                          maxValue:100,
74                          text:'',
75                          complete:null,
76                          change:null
77                      }
78                    };
79
80              // if options given, merge it
81              // if(opt) $.extend(options, opt); ==> options are set by setters
82
83              $this.data('options', options);
84
85
86              if(!properties)
87              {
88                $this.data('properties',
89                  {
90                    globalTime:{
91                        totalExecution:0,
92                        lastExecution:0,
93                        start:0
94                      },
95                    detailTime:{
96                        totalExecution:0,
97                        lastExecution:0,
98                        start:0
99                      }
100                  }
101                );
102                properties=$this.data('properties');
103              }
104
105              if(!objects)
106              {
107                objects =
108                  {
109                    text:$('<div/>',
110                        {
111                          'class':'ui-progressArea-text'
112                        }
113                      ),
114                    globalText:$('<div/>',
115                        {
116                          'class':'ui-progressArea-globalText'
117                        }
118                      ),
119                    detailText:$('<div/>',
120                        {
121                          'class':'ui-progressArea-detailText'
122                        }
123                      ),
124                    globalBar:$('<div/>',
125                        {
126                          'class':'ui-progressArea-globalBar'
127                        }
128                      ),
129                    detailBar:$('<div/>',
130                        {
131                          class:'ui-progressArea-detailBar'
132                        }
133                      ),
134                    globalBarProgress:$('<div/>',
135                        {
136                          class:'ui-progressArea-globalBarProgress'
137                        }
138                      ),
139                    detailBarProgress:$('<div/>',
140                        {
141                          class:'ui-progressArea-detailBarProgress'
142                        }
143                      ),
144                    globalBarText:$('<div/>',
145                        {
146                          class:'ui-progressArea-globalBarText'
147                        }
148                      ),
149                    detailBarText:$('<div/>',
150                        {
151                          class:'ui-progressArea-detailBarText'
152                        }
153                      ),
154                    workInProgress:$('<div/>',
155                        {
156                          class:'ui-progressArea-workInProgress'
157                        }
158                      )
159                  };
160
161                $this
162                  .html('')
163                  .addClass('ui-progressArea')
164                  .append(objects.text)
165                  .append(objects.globalText)
166                  .append(objects.globalBar
167                            .append(objects.globalBarProgress)
168                            .append(objects.globalBarText)
169                         )
170                  .append(objects.detailText)
171                  .append(objects.detailBar
172                            .append(objects.detailBarProgress)
173                            .append(objects.detailBarText)
174                         )
175                  .append(objects.workInProgress);
176
177                $this.data('objects', objects);
178              }
179
180              privateMethods.setOptions($this, opt);
181            }
182          );
183        }, // init
184      destroy : function ()
185        {
186          return this.each(
187            function()
188            {
189              // default values for the plugin
190              var $this=$(this),
191                  objects = $this.data('objects');
192              objects.text.remove();
193              objects.globalText.remove();
194              objects.detailText.remove();
195              objects.globalBarText.remove();
196              objects.globalBarProgress.remove();
197              objects.globalBar.remove();
198              objects.detailBarText.remove();
199              objects.detailBarProgress.remove();
200              objects.detailBar.remove();
201              objects.workInProgress.remove();
202
203              delete objects.text;
204              delete objects.globalText;
205              delete objects.detailText;
206              delete objects.globalBarText;
207              delete objects.globalBarProgress;
208              delete objects.globalBar;
209              delete objects.detailBarText;
210              delete objects.detailBarProgress;
211              delete objects.detailBar;
212              delete objects.workInProgress;
213
214              $this.removeClass('ui-progressArea');
215            }
216          );
217        }, // destroy
218
219      options: function (value)
220        {
221          return(
222            this.each(
223              function()
224              {
225                privateMethods.setOptions($(this), value);
226              }
227            )
228          );
229        }, // options
230
231      // hide progress information: progress bar and work in progress
232      hideProgress: function ()
233        {
234          return(
235            this.each(
236              function()
237              {
238                privateMethods.hideProgress($(this));
239              }
240            )
241          );
242        }, //hideProgress
243
244       // hide progress information: progress bar and work in progress
245      workInProgress: function (value)
246        {
247          if(value!=null)
248          {
249            // set selected value
250            return(
251              this.each(
252                function()
253                {
254                  privateMethods.setWorkInProgress($(this), value);
255                }
256              )
257            );
258          }
259          else
260          {
261            var options=this.data('options');
262            return(options.workInProgress);
263          }
264        }, //workInProgress
265
266      // set or return the value for global progress bar text
267      globalText: function (value)
268        {
269          if(value!=null)
270          {
271            // set selected value
272            return(
273              this.each(
274                function()
275                {
276                  privateMethods.setText($(this), 'global', value);
277                }
278              )
279            );
280          }
281          else
282          {
283            var options=this.data('options');
284            return(options.global.text);
285          }
286        }, // globalText
287
288      // set or return the value for detail progress bar text
289      detailText: function (value)
290        {
291          if(value!=null)
292          {
293            // set selected value
294            return(
295              this.each(
296                function()
297                {
298                  privateMethods.setText($(this), 'detail', value);
299                }
300              )
301            );
302          }
303          else
304          {
305            var options=this.data('options');
306            return(options.detail.text);
307          }
308        }, // detailText
309
310      // set or return the value for generic text
311      text: function (value)
312        {
313          if(value!=null)
314          {
315            // set selected value
316            return(
317              this.each(
318                function()
319                {
320                  privateMethods.setText($(this), 'generic', value);
321                }
322              )
323            );
324          }
325          else
326          {
327            var options=this.data('options');
328            return(options.text);
329          }
330        }, // text
331
332
333
334      // set or return the value for global progress bar
335      globalValue: function (value)
336        {
337          if(value!=null)
338          {
339            // set selected value
340            return(
341              this.each(
342                function()
343                {
344                  privateMethods.setGlobalValue($(this), value);
345                }
346              )
347            );
348          }
349          else
350          {
351            var options=this.data('options');
352            return(options.global.value);
353          }
354        }, // globalValue
355
356      // set or return the value for detail progress bar
357      detailValue: function (value)
358        {
359          if(value!=null)
360          {
361            // set selected value
362            return(
363              this.each(
364                function()
365                {
366                  privateMethods.setDetailValue($(this), value);
367                }
368              )
369            );
370          }
371          else
372          {
373            var options=this.data('options');
374            return(options.detail.value);
375          }
376        }, // detailValue
377
378
379      // set or return the max value for global progress bar
380      globalMaxValue: function (value)
381        {
382          if(value!=null)
383          {
384            // set selected value
385            return(
386              this.each(
387                function()
388                {
389                  privateMethods.setGlobalMaxValue($(this), value);
390                }
391              )
392            );
393          }
394          else
395          {
396            var options=this.data('options');
397            return(options.global.maxValue);
398          }
399        }, // globalMaxValue
400
401      // set or return the max value for detail progress bar
402      detailMaxValue: function (value)
403        {
404          if(value!=null)
405          {
406            // set selected value
407            return(
408              this.each(
409                function()
410                {
411                  privateMethods.setDetailMaxValue($(this), value);
412                }
413              )
414            );
415          }
416          else
417          {
418            var options=this.data('options');
419            return(options.detail.maxValue);
420          }
421        }, // detailMaxValue
422
423
424      // return the execution times
425      executionTime: function (value)
426        {
427          var properties=this.data('properties');
428          switch(value)
429          {
430            case 'resetGlobal':
431              return(
432                this.each(
433                  function()
434                  {
435                    privateMethods.resetTime($(this), 'global');
436                  }
437                )
438              );
439              break;
440            case 'resetDetail':
441              return(
442                this.each(
443                  function()
444                  {
445                    privateMethods.resetTime($(this), 'detail');
446                  }
447                )
448              );
449              break;
450            case 'global':
451              return(
452                {
453                  totalExecution:properties.globalTime.totalExecution,
454                  lastExecution:properties.globalTime.lastExecution
455                }
456              );
457              break;
458            case 'detail':
459              return(
460                {
461                  totalExecution:properties.detailTime.totalExecution,
462                  lastExecution:properties.detailTime.lastExecution
463                }
464              );
465              break;
466            default:
467              return(
468                {
469                  global:
470                    {
471                      totalExecution:properties.globalTime.totalExecution,
472                      lastExecution:properties.globalTime.lastExecution
473                    },
474                  detail:
475                    {
476                      totalExecution:properties.detailTime.totalExecution,
477                      lastExecution:properties.detailTime.lastExecution
478                    }
479                }
480              );
481              break;
482          }
483        } // executionTime
484
485    }; // methods
486
487
488    /*
489     * plugin 'private' methods
490     */
491    var privateMethods =
492    {
493      setOptions : function (object, value)
494        {
495          var properties=object.data('properties'),
496              options=object.data('options');
497
498          if(!$.isPlainObject(value)) return(false);
499
500          properties.initialized=false;
501
502          privateMethods.setText(object, 'generic', (value.text!=null)?value.text:options.text);
503          privateMethods.setWorkInProgress(object, (value.workInProgress!=null)?value.workInProgress:options.workInProgress);
504          privateMethods.setProperties(object, 'global', (value.global!=null)?value.global:options.global);
505          privateMethods.setProperties(object, 'detail', (value.detail!=null)?value.detail:options.detail);
506
507          privateMethods.resetTime(object, 'detail');
508          privateMethods.resetTime(object, 'global');
509
510          privateMethods.updateBar(object, 'global');
511          privateMethods.updateBar(object, 'detail');
512
513          privateMethods.showWorkInProgress(object);
514
515          properties.initialized=true;
516        },
517
518
519      setWorkInProgress: function (object, value)
520        {
521          var options=object.data('options'),
522              properties=object.data('properties'),
523              objects=object.data('objects');
524
525          if(!properties.initialized || value!=options.workInProgress)
526          {
527            options.workInProgress=value;
528            privateMethods.showWorkInProgress(object);
529          }
530          return(options.workInProgress);
531        }, // setWorkInProgress
532
533      setText: function (object, target, value)
534        {
535          var options=object.data('options'),
536              properties=object.data('properties'),
537              objects=object.data('objects');
538
539          switch(target)
540          {
541            case 'global':
542              if(!properties.initialized || value!=options.global.text)
543              {
544                options.global.text=value;
545                objects.globalText.html(options.global.text);
546              }
547
548              return(options.global.text);
549              break;
550            case 'detail':
551              if(!properties.initialized || value!=options.detail.text)
552              {
553                options.detail.text=value;
554                objects.detailText.html(options.detail.text);
555              }
556
557              return(options.detail.text);
558              break;
559            case 'generic':
560              if(!properties.initialized || value!=options.text)
561              {
562                options.text=value;
563                objects.text.html(options.text);
564              }
565
566              return(options.text);
567              break;
568          }
569        }, // setText
570
571
572      /**
573       * set properties for global/detail options
574       *
575       * @param String target: 'global' or 'detail'
576       */
577      setProperties: function (object, target, value)
578        {
579          var options=object.data('options'),
580              properties=object.data('properties'),
581              objects=object.data('objects'),
582              tmpValue={
583                visible:true,
584                value:0,
585                maxValue:100,
586                text:'',
587                complete:null,
588                change:null
589              };
590
591          if(!properties.initialized &&
592              (target=='global' || target=='detail') &&
593              $.isPlainObject(value)
594          )
595          {
596            if(value.visible!=null &&
597                (value.visible==true || value.visible==false)
598              )
599                tmpValue.visible=value.visible;
600
601            if(value.maxValue!=null &&
602               value.maxValue>=0)
603                tmpValue.maxValue=value.maxValue;
604
605            if(value.value!=null &&
606               value.value>=0 &&
607               value.value<=tmpValue.maxValue)
608                tmpValue.value=value.value;
609
610            if(value.text!=null)
611                tmpValue.text=value.text;
612
613            if(value.complete!=null &&
614                $.isFunction(value.complete))
615              tmpValue.complete=value.complete;
616
617            if(value.change!=null &&
618                $.isFunction(value.change))
619              tmpValue.change=value.change;
620
621            if(value.showPercent!=null &&
622                (value.showPercent==true || value.showPercent==false)
623              )
624                tmpValue.showPercent=value.showPercent;
625
626            if(value.percentDecimal!=null &&
627               value.percentDecimal>=0 && value.percentDecimal<=2)
628                tmpValue.percentDecimal=value.percentDecimal;
629          }
630
631          switch(target)
632          {
633            case 'global':
634              options.global.visible=tmpValue.visible;
635              options.global.value=tmpValue.value;
636              options.global.maxValue=tmpValue.maxValue;
637              options.global.text=tmpValue.text;
638              options.global.showPercent=tmpValue.showPercent;
639              options.global.percentDecimal=tmpValue.percentDecimal;
640
641              privateMethods.setEventComplete(object, 'global', tmpValue.complete);
642              privateMethods.setEventChange(object, 'global', tmpValue.change);
643
644              objects.globalText
645                .html(options.global.text)
646                .css('display', options.global.visible?'block':'none');
647              objects.globalBar.css('display', options.global.visible?'block':'none');
648              privateMethods.updateBar(object, 'global');
649              return(options.global);
650              break;
651            case 'detail':
652              options.detail.visible=tmpValue.visible;
653              options.detail.value=tmpValue.value;
654              options.detail.maxValue=tmpValue.maxValue;
655              options.detail.text=tmpValue.text;
656              options.detail.showPercent=tmpValue.showPercent;
657              options.detail.percentDecimal=tmpValue.percentDecimal;
658
659              privateMethods.setEventComplete(object, 'detail', tmpValue.complete);
660              privateMethods.setEventChange(object, 'detail', tmpValue.change);
661
662              objects.detailText
663                .html(options.detail.text)
664                .css('display', options.detail.visible?'block':'none');
665              objects.detailBar.css('display', options.detail.visible?'block':'none');
666              privateMethods.updateBar(object, 'detail');
667              return(options.detail);
668              break;
669            default:
670              return(null);
671              break;
672          }
673        }, // setProperties
674
675
676      setGlobalValue : function (object, value)
677        {
678          var properties=object.data('properties'),
679              options=object.data('options');
680
681          if(value!=options.global.value && value>=0 && value<=options.global.maxValue)
682          {
683
684            options.global.value=value;
685            privateMethods.updateBar(object, 'global');
686
687            properties.globalTime.lastExecution=Date.now()-properties.globalTime.start;
688            properties.globalTime.totalExecution+=properties.globalTime.lastExecution;
689            properties.globalTime.start=Date.now();
690
691            if(options.global.value==options.global.maxValue && options.global.complete!=null)
692            {
693              object.trigger('progressAreaCompleteglobal',
694                {
695                  lastExecution:properties.globalTime.lastExecution,
696                  totalExecution:properties.globalTime.totalExecution
697                }
698              );
699            }
700            else if(options.global.change!=null)
701            {
702              object.trigger('progressAreaChangeglobal',
703                {
704                  currentValue:options.global.value,
705                  lastExecution:properties.globalTime.lastExecution,
706                  totalExecution:properties.globalTime.totalExecution
707                }
708              );
709            }
710          }
711
712          return(options.global.value);
713        }, // setGlobalValue
714
715      setDetailValue : function (object, value)
716        {
717          var properties=object.data('properties'),
718              options=object.data('options');
719
720          if(value!=options.detail.value && value>=0 && value<=options.detail.maxValue)
721          {
722            options.detail.value=value;
723            privateMethods.updateBar(object, 'detail');
724
725            properties.detailTime.lastExecution=Date.now()-properties.detailTime.start;
726            properties.detailTime.totalExecution+=properties.detailTime.lastExecution;
727            properties.detailTime.start=Date.now();
728
729            properties.globalTime.lastExecution+=properties.detailTime.lastExecution;
730            properties.globalTime.totalExecution+=properties.detailTime.lastExecution;
731
732            if(options.detail.value==options.detail.maxValue && options.detail.complete!=null)
733            {
734              object.trigger('progressAreaCompletedetail',
735                {
736                  lastExecution:properties.detailTime.lastExecution,
737                  totalExecution:properties.detailTime.totalExecution,
738                  globalLastExecution:properties.globalTime.lastExecution,
739                  globalTotalExecution:properties.globalTime.totalExecution
740                }
741              );
742            }
743            else if(options.detail.change!=null)
744            {
745              object.trigger('progressAreaChangedetail',
746                {
747                  currentValue:options.detail.value,
748                  lastExecution:properties.detailTime.lastExecution,
749                  totalExecution:properties.detailTime.totalExecution,
750                  globalLastExecution:properties.globalTime.lastExecution,
751                  globalTotalExecution:properties.globalTime.totalExecution
752                }
753              );
754            }
755
756            if(options.detail.value==options.detail.maxValue)
757              privateMethods.resetTime(object, 'detail');
758          }
759
760          return(options.detail.value);
761        }, // setDetailValue
762
763
764      setGlobalMaxValue : function (object, value)
765        {
766          var properties=object.data('properties'),
767              options=object.data('options');
768
769          if(value!=options.global.maxValue && value>=0 && value>=options.global.value)
770          {
771            options.global.maxValue=value;
772            privateMethods.updateBar(object, 'global');
773          }
774
775          return(options.global.maxValue);
776        }, // setGlobalMaxValue
777
778      setDetailMaxValue : function (object, value)
779        {
780          var properties=object.data('properties'),
781              options=object.data('options');
782
783          if(value!=options.detail.maxValue && value>=0 && value>=options.detail.value)
784          {
785            options.detail.maxValue=value;
786            privateMethods.updateBar(object, 'detail');
787          }
788
789          return(options.detail.maxValue);
790        }, // setDetailMaxValue
791
792
793      setEventComplete : function (object, target, value)
794        {
795          var options=object.data('options');
796
797          object.unbind('progressAreaComplete'+target);
798          switch(target)
799          {
800            case 'global':
801              options.global.complete=value;
802              if(value) object.bind('progressAreaCompleteglobal', options.global.complete);
803              return(options.global.complete);
804              break;
805            case 'detail':
806              options.detail.complete=value;
807              if(value) object.bind('progressAreaCompletedetail', options.detail.complete);
808              return(options.detail.complete);
809              break;
810          }
811        }, //setEventComplete
812
813      setEventChange : function (object, target, value)
814        {
815          var options=object.data('options');
816
817          object.unbind('progressAreaChange'+target);
818          switch(target)
819          {
820            case 'global':
821              options.global.change=value;
822              if(value) object.bind('progressAreaChangeglobal', options.global.change);
823              return(options.global.change);
824              break;
825            case 'detail':
826              options.detail.change=value;
827              if(value) object.bind('progressAreaChangedetail', options.detail.change);
828              return(options.detail.change);
829              break;
830          }
831        }, //setEventChange
832
833
834      updateBar : function (object, target)
835        {
836          var objects=object.data('objects'),
837              options=object.data('options'),
838              properties=object.data('properties'),
839              percent=0,
840              targetObj=null,
841              barObj=null,
842              textObj=null,
843              progressObj=null;
844
845          switch(target)
846          {
847            case 'global':
848              targetObj=options.global;
849              barObj=objects.globalBar;
850              textObj=objects.globalBarText;
851              progressObj=objects.globalBarProgress;
852              break;
853            case 'detail':
854              targetObj=options.detail;
855              barObj=objects.detailBar;
856              textObj=objects.detailBarText;
857              progressObj=objects.detailBarProgress;
858              break;
859            default:
860              return(false);
861              break;
862          }
863
864          if(targetObj.maxValue>0)
865            percent=100*targetObj.value/targetObj.maxValue;
866
867          switch(targetObj.percentDecimal)
868          {
869            case 0:
870              percent=Math.round(percent);
871              break;
872            case 1:
873              percent=Math.round(percent*10)/10;
874              break;
875            case 2:
876              percent=Math.round(percent*100)/100;
877              break;
878          }
879
880          progressObj.css(
881            {
882              'width': Math.round(barObj.width()*percent/100)+'px',
883              'height': barObj.innerHeight()
884            }
885          );
886
887          if(targetObj.showPercent)
888            textObj
889              .css('width', barObj.width())
890              .html(percent.toFixed(targetObj.percentDecimal)+'%');
891        }, //updateBar
892
893
894      hideProgress : function (object)
895        {
896          var options=object.data('options'),
897              properties=object.data('properties'),
898              objects=object.data('objects');
899
900          objects.globalBar.css('display', 'none');
901          objects.globalText.css('display', 'none');
902
903          objects.detailBar.css('display', 'none');
904          objects.detailText.css('display', 'none');
905
906          objects.workInProgress.css('display', 'none');
907        }, //hideProgress
908
909      showWorkInProgress : function (object)
910        {
911          var options=object.data('options'),
912              properties=object.data('properties'),
913              objects=object.data('objects');
914
915          if(options.workInProgress)
916          {
917            bgPosition=(object.width()/2-8)+'px 8px';
918
919            objects.workInProgress.css(
920              {
921                'display': 'block',
922                'background-position': bgPosition
923              }
924            );
925          }
926          else
927          {
928            objects.workInProgress.css('display', 'none');
929          }
930        }, //showWorkInProgress
931
932
933      resetTime : function(object, target)
934        {
935          var properties=object.data('properties');
936
937          switch(target)
938          {
939            case 'global':
940              properties.globalTime.totalExecution=0;
941              properties.globalTime.lastExecution=0;
942              properties.globalTime.start=Date.now();
943              break;
944            case 'detail':
945              properties.detailTime.totalExecution=0;
946              properties.detailTime.lastExecution=0;
947              properties.detailTime.start=Date.now();
948              break;
949          }
950        } // resetTime
951
952
953    };
954
955    $.fn.progressArea = function(method)
956    {
957      if(publicMethods[method])
958      {
959        return publicMethods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
960      }
961      else if(typeof method === 'object' || ! method)
962      {
963        return publicMethods.init.apply(this, arguments);
964      }
965      else
966      {
967        $.error( 'Method ' +  method + ' does not exist on jQuery.progressArea' );
968      }
969    } // $.fn.progressArea
970
971  }
972)(jQuery);
973
974/**
975 * open a modal dialog box for progression
976 */
977$.dialogProgressArea = function (opt)
978{
979  var options=
980        {
981          width:350,
982          height:200,
983          title:'Progression',
984          buttons:
985            {
986              ok:'Ok'
987            },
988          text:'',
989          progressBar:
990            {
991              global:null,
992              detail:null
993            },
994         close:null,
995        },
996      objects=
997        {
998          dialogBox:$('<div/>'),
999          pArea:$('<div/>')
1000        },
1001      properties=
1002        {
1003          complete:null
1004        },
1005
1006  setOptions = function (opt)
1007    {
1008      if(opt.width!=null && opt.width>0) options.width=opt.width;
1009      if(opt.height!=null && opt.height>0) options.height=opt.height;
1010      if(opt.title) options.title=opt.title;
1011      if(opt.buttons && opt.buttons.ok) options.buttons.ok=opt.buttons.ok;
1012      if(opt.text) options.text=opt.text;
1013
1014      if($.isPlainObject(opt.progressBar) &&
1015         $.isPlainObject(opt.progressBar.global))
1016            options.progressBar.global=opt.progressBar.global;
1017      if($.isPlainObject(opt.progressBar) &&
1018         $.isPlainObject(opt.progressBar.detail))
1019            options.progressBar.detail=opt.progressBar.detail;
1020
1021      if(opt.close && $.isFunction(opt.close)) options.close=opt.close;
1022
1023      if($.isFunction(options.progressBar.global.complete))
1024        properties.complete=options.progressBar.global.complete;
1025
1026      options.progressBar.global.complete=function (event, value)
1027        {
1028          objects.pArea.progressArea('hideProgress');
1029          if(properties.complete) properties.complete(event, value);
1030          objects.dialogBox.parent().find('div.ui-dialog-buttonpane button').css('visibility', 'visible');
1031        }
1032    },
1033
1034  initDialog = function ()
1035    {
1036      var dialogOpt={},
1037          dialogButtons={};
1038
1039      dialogButtons[options.buttons.ok] = function (event)
1040        {
1041          if(options.close) options.close(event);
1042          $(this).dialog('close');
1043        };
1044
1045      dialogOpt=
1046          {
1047            width:options.width,
1048            height:options.height,
1049            closeOnEscape:false,
1050            closeText:'',
1051            dialogClass:'ui-dialogProgressArea',
1052            modal:true,
1053            resizable:false,
1054            title:options.title,
1055            buttons:dialogButtons,
1056            open: open= function ()
1057                    {
1058                      objects.pArea
1059                        .progressArea(
1060                          {
1061                            text:options.text,
1062                            workInProgress:true,
1063                            global:options.progressBar.global,
1064                            detail:options.progressBar.detail
1065                          }
1066                        );
1067                    },
1068            close: function ()
1069                    {
1070                      objects.pArea.progressArea('destroy').remove();
1071                      $(this).dialog('destroy').remove();
1072                    }
1073          };
1074
1075      objects.dialogBox
1076        .append(objects.pArea)
1077        .dialog(dialogOpt);
1078    };
1079
1080  setOptions(opt);
1081  initDialog();
1082
1083  return(objects.pArea);
1084} // $.dialogProgressArea
Note: See TracBrowser for help on using the repository browser.