Ignore:
Timestamp:
Jun 24, 2012, 9:18:26 PM (12 years ago)
Author:
grum
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/GrumPluginClasses/js/ui.inputList.js

    r15340 r16012  
    1111 *   email    : grum@piwigo.com
    1212 *   website  : http://photos.grum.fr
    13  *   PWG user : http://forum.phpwebgallery.net/profile.php?id=3706
    1413 *
    1514 *   << May the Little SpaceFrog be with you ! >>
     
    2423 * | 1.0.0   | 2010/10/10 | first release
    2524 * |         |            |
    26  * | 1.0.1   | 2012/05/25 | fix bug with jquery 1.7.2
    27  * |         |            |  . display list now works :)
     25 * | 1.0.1   | 2012/06/18 | * fix bug with jquery 1.7.2
     26 * |         |            |   . display list now works :)
    2827 * |         |            |
     28 * |         |            | * improve memory managment
    2929 * |         |            |
    3030 * |         |            |
     
    4949              // default values for the plugin
    5050              var $this=$(this),
     51                  timeStamp=new Date(),
    5152                  data = $this.data('options'),
    5253                  objects = $this.data('objects'),
     
    5556                    {
    5657                      serverUrl:'',
     58                      postData:{},
    5759                      autoLoad:true,
    5860                      listMaxWidth:0,
    5961                      listMaxHeight:0,
    6062                      multiple:false,
    61                       downArrow:'&dArr;',
     63                      downArrow:'', //&dArr;
    6264                      popupMode:'click',
    6365                      colsWidth:[],
     
    8082                $this.data('properties',
    8183                  {
     84                    objectId:'il'+Math.ceil(timeStamp.getTime()*Math.random()),
    8285                    index:-1,
    8386                    initialized:false,
     
    204207              // default values for the plugin
    205208              var $this=$(this),
     209                  properties = $this.data('properties'),
    206210                  objects = $this.data('objects');
    207211              objects.container.unbind().remove();
    208212              objects.list.children().unbind();
    209               objects.listContainer.remove();
     213              objects.listContainer.unbind().remove();
     214              $(document).unbind('focusout.'+properties.objectId+' focusin.'+properties.objectId);
    210215              $this
     216                .removeData()
    211217                .unbind('.inputList')
    212218                .css(
     
    216222                  }
    217223                );
     224              delete $this;
    218225            }
    219226          );
     
    328335          }
    329336        }, // serverUrl
     337
     338      postData: function (value)
     339        {
     340          if(value!=null)
     341          {
     342            // set selected value
     343            return(
     344              this.each(
     345                function()
     346                {
     347                  privateMethods.setPostData($(this), value, true);
     348                }
     349              )
     350            );
     351          }
     352          else
     353          {
     354            var options=this.data('options');
     355            return(options.postData);
     356          }
     357        }, // postData
    330358
    331359      cols: function ()
     
    747775          privateMethods.setListMaxWidth(object, (value.listMaxWidth!=null)?value.listMaxWidth:options.listMaxWidth);
    748776          privateMethods.setListMaxHeight(object, (value.listMaxHeight!=null)?value.listMaxHeight:options.listMaxHeight);
     777          privateMethods.setPostData(object, (value.postData!=null)?value.postData:options.postData);
    749778          privateMethods.setServerUrl(object, (value.serverUrl!=null)?value.serverUrl:options.serverUrl);
    750779          privateMethods.setPopupMode(object, (value.popupMode!=null)?value.popupMode:options.popupMode);
     
    759788          privateMethods.setMultiple(object, (value.multiple!=null)?value.multiple:options.multiple); // can be set only at the initialization
    760789
    761           if(options.autoLoad) privateMethods.load(object);
     790          if(options.autoLoad && options.serverUrl!='')
     791          {
     792            privateMethods.load(object, (value.value!=null)?value.value:null);
     793          }
     794          else
     795          {
     796            privateMethods.setValue(object, (value.value!=null)?value.value:null);
     797          }
    762798
    763799          properties.initialized=true;
     
    899935          return(options.serverUrl);
    900936        },
     937
     938      setPostData : function (object, value)
     939        {
     940          var properties=object.data('properties'),
     941              options=object.data('options');
     942
     943          if(!properties.initialized || value!=options.postData)
     944          {
     945            options.postData=value;
     946          }
     947
     948          return(options.postData);
     949        }, // setPostData
    901950
    902951      setMultiple : function (object, value)
     
    9741023                  }
    9751024                );
    976               $(document).bind('focusout focusin',
    977                 function (event)
    978                 {
    979                   if(!properties.mouseOver) privateMethods.displaySelector(object, false);
    980                   event.stopPropagation();
    981                 }
     1025                $(document).bind('focusout.'+properties.objectId+' focusin.'+properties.objectId,
     1026                  function (event)
     1027                  {
     1028                    if($.isPlainObject(properties) && !properties.mouseOver) privateMethods.displaySelector(object, false);
     1029                    event.stopPropagation();
     1030                  }
    9821031              );
    9831032            }
     
    12971346        },
    12981347
    1299       load : function (object)
     1348      load : function (object, defaultValue)
    13001349        {
    13011350          // load datas from server through an asynchronous ajax call
     
    13101359              type: "POST",
    13111360              url: options.serverUrl,
     1361              data:options.postData,
    13121362              async: true,
    13131363              success: function(msg)
     
    13181368                  if(options.multiple)
    13191369                  {
    1320                     privateMethods.setValue(object, ':none');
     1370                    if(defaultValue!=null)
     1371                    {
     1372                      privateMethods.setValue(object, defaultValue);
     1373                    }
     1374                    else
     1375                    {
     1376                      privateMethods.setValue(object, ':none');
     1377                    }
    13211378                  }
    13221379                  else
    13231380                  {
    1324                     privateMethods.setValue(object, ':first');
     1381                    if(defaultValue!=null)
     1382                    {
     1383                      privateMethods.setValue(object, defaultValue);
     1384                    }
     1385                    else
     1386                    {
     1387                      privateMethods.setValue(object, ':first');
     1388                    }
    13251389                  }
    13261390                  properties.initialized=true;
Note: See TracChangeset for help on using the changeset viewer.