Changeset 16012 for extensions/GrumPluginClasses/js/ui.inputList.js
- Timestamp:
- Jun 24, 2012, 9:18:26 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/GrumPluginClasses/js/ui.inputList.js
r15340 r16012 11 11 * email : grum@piwigo.com 12 12 * website : http://photos.grum.fr 13 * PWG user : http://forum.phpwebgallery.net/profile.php?id=370614 13 * 15 14 * << May the Little SpaceFrog be with you ! >> … … 24 23 * | 1.0.0 | 2010/10/10 | first release 25 24 * | | | 26 * | 1.0.1 | 2012/0 5/25 |fix bug with jquery 1.7.227 * | | | . display list now works :)25 * | 1.0.1 | 2012/06/18 | * fix bug with jquery 1.7.2 26 * | | | . display list now works :) 28 27 * | | | 28 * | | | * improve memory managment 29 29 * | | | 30 30 * | | | … … 49 49 // default values for the plugin 50 50 var $this=$(this), 51 timeStamp=new Date(), 51 52 data = $this.data('options'), 52 53 objects = $this.data('objects'), … … 55 56 { 56 57 serverUrl:'', 58 postData:{}, 57 59 autoLoad:true, 58 60 listMaxWidth:0, 59 61 listMaxHeight:0, 60 62 multiple:false, 61 downArrow:' ⇓',63 downArrow:'', //⇓ 62 64 popupMode:'click', 63 65 colsWidth:[], … … 80 82 $this.data('properties', 81 83 { 84 objectId:'il'+Math.ceil(timeStamp.getTime()*Math.random()), 82 85 index:-1, 83 86 initialized:false, … … 204 207 // default values for the plugin 205 208 var $this=$(this), 209 properties = $this.data('properties'), 206 210 objects = $this.data('objects'); 207 211 objects.container.unbind().remove(); 208 212 objects.list.children().unbind(); 209 objects.listContainer.remove(); 213 objects.listContainer.unbind().remove(); 214 $(document).unbind('focusout.'+properties.objectId+' focusin.'+properties.objectId); 210 215 $this 216 .removeData() 211 217 .unbind('.inputList') 212 218 .css( … … 216 222 } 217 223 ); 224 delete $this; 218 225 } 219 226 ); … … 328 335 } 329 336 }, // 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 330 358 331 359 cols: function () … … 747 775 privateMethods.setListMaxWidth(object, (value.listMaxWidth!=null)?value.listMaxWidth:options.listMaxWidth); 748 776 privateMethods.setListMaxHeight(object, (value.listMaxHeight!=null)?value.listMaxHeight:options.listMaxHeight); 777 privateMethods.setPostData(object, (value.postData!=null)?value.postData:options.postData); 749 778 privateMethods.setServerUrl(object, (value.serverUrl!=null)?value.serverUrl:options.serverUrl); 750 779 privateMethods.setPopupMode(object, (value.popupMode!=null)?value.popupMode:options.popupMode); … … 759 788 privateMethods.setMultiple(object, (value.multiple!=null)?value.multiple:options.multiple); // can be set only at the initialization 760 789 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 } 762 798 763 799 properties.initialized=true; … … 899 935 return(options.serverUrl); 900 936 }, 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 901 950 902 951 setMultiple : function (object, value) … … 974 1023 } 975 1024 ); 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 } 982 1031 ); 983 1032 } … … 1297 1346 }, 1298 1347 1299 load : function (object )1348 load : function (object, defaultValue) 1300 1349 { 1301 1350 // load datas from server through an asynchronous ajax call … … 1310 1359 type: "POST", 1311 1360 url: options.serverUrl, 1361 data:options.postData, 1312 1362 async: true, 1313 1363 success: function(msg) … … 1318 1368 if(options.multiple) 1319 1369 { 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 } 1321 1378 } 1322 1379 else 1323 1380 { 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 } 1325 1389 } 1326 1390 properties.initialized=true;
Note: See TracChangeset
for help on using the changeset viewer.