Changeset 9020 for extensions/GrumPluginClasses
- Timestamp:
- Jan 31, 2011, 11:31:11 PM (14 years ago)
- Location:
- extensions/GrumPluginClasses
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/GrumPluginClasses/gpc_version.inc.php
r9009 r9020 15 15 if(!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 16 16 17 if(!defined('GPC_VERSION')) define('GPC_VERSION', '3.4. 1');18 if(!defined('GPC_VERSION2')) define('GPC_VERSION2', '03.04.0 1');17 if(!defined('GPC_VERSION')) define('GPC_VERSION', '3.4.2'); 18 if(!defined('GPC_VERSION2')) define('GPC_VERSION2', '03.04.02'); 19 19 ?> -
extensions/GrumPluginClasses/js/ui.inputText.js
r8961 r9020 2 2 * ----------------------------------------------------------------------------- 3 3 * file: ui.inputText.js 4 * file version: 1.1. 04 * file version: 1.1.1 5 5 * date: 2011-01-09 6 6 * … … 29 29 * | | | * add multilanguage managment 30 30 * | | | 31 * | 1.1.1 | 2011/01/31 | * add function ':clear' for 'languageValues' method 32 * | | | 33 * | | | 34 * | | | 35 * | | | 36 * | | | 31 37 * | | | 32 38 * | | | … … 804 810 properties=object.data('properties'); 805 811 806 for(var langValue in value) 807 { 808 if(properties.languagesValues[langValue]!=null) 809 privateMethods.setLanguageValue(object, langValue, value[langValue], langValue==options.currentLanguage); 812 if(value==':clear') 813 { 814 for(var langValue in properties.languagesValues) 815 { 816 privateMethods.setLanguageValue(object, langValue, '', langValue==options.currentLanguage); 817 } 818 } 819 else if(!$.isEmptyObject(value)) 820 { 821 for(var langValue in value) 822 { 823 if(properties.languagesValues[langValue]!=null) 824 privateMethods.setLanguageValue(object, langValue, value[langValue], langValue==options.currentLanguage); 825 } 810 826 } 811 827 -
extensions/GrumPluginClasses/js/ui.inputText.min.js
r8961 r9020 1 /* file: ui.inputText.js - v1.0.0 | minified on 2011/01/27 with http://jscompress.com/ */ 2 (function($) 3 {var publicMethods={init:function(opt) 4 {return this.each(function() 5 {var $this=$(this),data=$this.data('options'),objects=$this.data('objects'),properties=$this.data('properties'),options={languages:[],currentLanguage:'',languagesValues:{},languageSelector:'',multilines:false,disabled:false,textAlign:'left',displayChar:0,maxChar:0,numRows:1,regExp:'',value:'',change:null};if(options.value==''&&$.trim($this.html())!='')options.value=$.trim($this.html());$this.data('options',options);if(!properties) 6 {$this.data('properties',{initialized:false,re:/.*/,value:0,isValid:true,languagesValues:{}});properties=$this.data('properties');} 7 if(!objects) 8 {objects={container:$('<div/>',{'class':'ui-inputText',css:{width:'100%'}}).bind('click.inputText',function() 9 {objects.input.focus();}),input:null};$this.html('').append(objects.container);$this.data('objects',objects);} 10 privateMethods.setOptions($this,opt);});},destroy:function() 11 {return this.each(function() 12 {var $this=$(this),objects=$this.data('objects');objects.input.unbind().remove();objects.container.unbind().remove();$this.unbind('.inputText').css({width:'',height:''});});},options:function(value) 13 {return(this.each(function() 14 {privateMethods.setOptions($(this),value);}));},disabled:function(value) 15 {if(value!=null) 16 {return(this.each(function() 17 {privateMethods.setDisabled($(this),value);}));} 18 else 19 {var options=this.data('options');if(options) 20 {return(options.disabled);} 21 else 22 {return('');}}},textAlign:function(value) 23 {if(value!=null) 24 {return(this.each(function() 25 {privateMethods.setTextAlign($(this),value);}));} 26 else 27 {var options=this.data('options');if(options) 28 {return(options.textAlign);} 29 else 30 {return('');}}},displayChar:function(value) 31 {if(value!=null) 32 {return(this.each(function() 33 {privateMethods.setDisplayChar($(this),value);}));} 34 else 35 {var options=this.data('options');if(options) 36 {return(options.displayChar);} 37 else 38 {return('');}}},maxChar:function(value) 39 {if(value!=null) 40 {return(this.each(function() 41 {privateMethods.setMaxChar($(this),value);}));} 42 else 43 {var options=this.data('options');if(options) 44 {return(options.maxChar);} 45 else 46 {return('');}}},numRows:function(value) 47 {if(value!=null) 48 {return(this.each(function() 49 {privateMethods.setNumRows($(this),value);}));} 50 else 51 {var options=this.data('options');if(options) 52 {return(options.numRows);} 53 else 54 {return('');}}},regExp:function(value) 55 {if(value!=null) 56 {return(this.each(function() 57 {privateMethods.setRegExp($(this),value);}));} 58 else 59 {var options=this.data('options');if(options) 60 {return(options.regExp);} 61 else 62 {return('');}}},multilines:function() 63 {var properties=this.data('properties');return(properties.multilines);},languages:function(value) 64 {if(value!=null) 65 {return(this.each(function() 66 {privateMethods.setLanguages($(this),value);}));} 67 else 68 {var options=this.data('options');return(options.languages);}},currentLanguage:function(value) 69 {if(value!=null) 70 {return(this.each(function() 71 {privateMethods.setCurrentLanguage($(this),value);}));} 72 else 73 {var options=this.data('options');return(options.currentLanguage);}},languageSelector:function(value) 74 {if(value!=null) 75 {return(this.each(function() 76 {privateMethods.setLanguageSelector($(this),value);}));} 77 else 78 {var options=this.data('options');return(options.languageSelector);}},languagesValues:function(value) 79 {if(value!=null) 80 {return(this.each(function() 81 {privateMethods.setLanguagesValues($(this),value);}));} 82 else 83 {var properties=this.data('properties');return(properties.languagesValues);}},value:function(value,language) 84 {if(value!=null) 85 {var options=this.data('options');return(this.each(function() 86 {if(language!=null) 87 {privateMethods.setLanguageValue($(this),language,value,options.currentLanguage==language);} 88 else 89 {privateMethods.setValue($(this),value,true);}}));} 90 else 91 {var properties=this.data('properties');return(properties.value);}},isValid:function(value) 92 {if(value!=null) 93 {return(this.each(function() 94 {privateMethods.setIsValid($(this),value);}));} 95 else 96 {var properties=this.data('properties');return(properties.isValid);}},change:function(value) 97 {if(value!=null&&$.isFunction(value)) 98 {return(this.each(function() 99 {privateMethods.setEventChange($(this),value);}));} 100 else 101 {var options=this.data('options');if(options) 102 {return(options.change);} 103 else 104 {return(null);}}},doTranslation:function() 105 {return(this.each(function() 106 {privateMethods.doTranslation($(this));}));}};var privateMethods={isValid:function(object,value) 107 {var properties=object.data('properties');return(properties.re.exec(value))},setOptions:function(object,value) 108 {var properties=object.data('properties'),options=object.data('options');if(!$.isPlainObject(value))return(false);properties.initialized=false;privateMethods.setMultilines(object,(value.multilines!=null)?value.multilines:options.multilines);privateMethods.setDisplayChar(object,(value.displayChar!=null)?value.displayChar:options.displayChar);privateMethods.setMaxChar(object,(value.maxChar!=null)?value.maxChar:options.maxChar);privateMethods.setNumRows(object,(value.numRows!=null)?value.numRows:options.numRows);privateMethods.setRegExp(object,(value.regExp!=null)?value.regExp:options.regExp);privateMethods.setLanguages(object,(value.languages!=null)?value.languages:options.languages);privateMethods.setLanguagesValues(object,(value.languagesValues!=null)?value.languagesValues:options.languagesValues);privateMethods.setCurrentLanguage(object,(value.currentLanguage!=null)?value.currentLanguage:options.currentLanguage);privateMethods.setLanguageSelector(object,(value.languageSelector!=null)?value.languageSelector:options.languageSelector);if((properties.languagesValues[options.currentLanguage]!=null&&properties.languagesValues[options.currentLanguage]!=''||properties.languagesValues[options.currentLanguage]==null)&&(value.value!=null&&value.value!=''||options.value!=''))privateMethods.setValue(object,(value.value!=null)?value.value:options.value,true);privateMethods.setTextAlign(object,(value.textAlign!=null)?value.textAlign:options.textAlign);privateMethods.setEventChange(object,(value.change!=null)?value.change:options.change);properties.initialized=true;},setRegExp:function(object,value) 109 {var properties=object.data('properties'),flagRE=/^\/(.*)\/(.*)$/,flags=flagRE.exec(value);if(flags==null) 110 {flags=['.*',''];} 111 delete properties.re;properties.re=new RegExp(flags[1],flags[2]);},setIsValid:function(object,value) 112 {var objects=object.data('objects'),properties=object.data('properties');if(properties.isValid!=value&&properties.initialized) 113 {properties.isValid=value;if(properties.isValid) 114 {objects.container.removeClass('ui-error');objects.input.removeClass('ui-error');} 115 else 116 {objects.container.addClass('ui-error');objects.input.addClass('ui-error');}} 117 return(properties.isValid);},setDisplayChar:function(object,value) 118 {var options=object.data('options'),objects=object.data('objects');properties=object.data('properties');if((!properties.initialized||options.displayChar!=value)&&value>=0) 119 {options.displayChar=value;if(options.displayChar>0) 120 {if(options.multilines) 121 {objects.input.attr('cols',options.displayChar);} 122 else 123 {objects.input.attr('size',options.displayChar);}} 124 else 125 {if(options.multilines) 126 {objects.input.removeAttr('size');} 127 else 128 {objects.input.removeAttr('cols');}}} 129 if(object.width()>0) 130 {objects.input.css({'width':object.width()+'px','max-width':object.width()+'px'});} 131 return(options.displayChar);},setMaxChar:function(object,value) 132 {var options=object.data('options'),objects=object.data('objects'),properties=object.data('properties');if((!properties.initialized||options.maxChar!=value)&&value>=0) 133 {options.maxChar=value;if(!options.multilines) 134 {if(options.maxChar>0) 135 {objects.input.attr('maxlength',options.maxChar);} 136 else 137 {objects.input.removeAttr('maxlength');}}} 138 return(options.maxChar);},setNumRows:function(object,value) 139 {var options=object.data('options'),objects=object.data('objects'),properties=object.data('properties');if((!properties.initialized||options.numRows!=value)&&value>0) 140 {options.numRows=value;if(options.multilines) 141 {objects.input.attr('rows',options.numRows);}} 142 return(options.numRows);},setDisabled:function(object,value) 143 {var options=object.data('options'),objects=object.data('objects'),properties=object.data('properties');if((!properties.initialized||options.disabled!=value)&&(value==true||value==false)) 144 {options.disabled=value;objects.input.attr('disabled',options.disabled);} 145 return(options.disabled);},setTextAlign:function(object,value) 146 {var options=object.data('options'),objects=object.data('objects'),properties=object.data('properties');if((!properties.initialized||options.textAlign!=value)&&(value=='left'||value=='right')) 147 {options.textAlign=value;objects.input.css('text-align',options.textAlign);} 148 return(options.textAlign);},setMultilines:function(object,value) 149 {var options=object.data('options'),objects=object.data('objects'),properties=object.data('properties');if((!properties.initialized||options.multilines!=value)&&(value==true||value==false)) 150 {options.multilines=value;if(options.multilines) 151 {objects.input=$('<textarea/>');} 152 else 153 {objects.input=$('<input>',{type:"text",value:''});} 154 objects.container.append(objects.input.bind('keyup.inputText',function(event) 155 {return(privateMethods.keyUp(object,event));}).bind('change.inputText',function(event) 156 {return(privateMethods.change(object,event));}).bind('keydown.inputText',function(event) 157 {return(privateMethods.keyDown(object,event));}));} 158 return(options.textAlign);},setLanguages:function(object,value) 159 {var properties=object.data('properties'),options=object.data('options');options.languages=value;options.languagesValues={};if(options.languages.length>0) 160 {if($.inArray(options.currentLanguage,options.languages)<0||options.currentLanguage=='')options.currentLanguage=options.languages[0];for(var i=0;i<options.languages.length;i++) 161 {properties.languagesValues[options.languages[i]]='';}} 162 else 163 {options.currentLanguage='';} 164 return(options.languages);},setLanguagesValues:function(object,value) 165 {var options=object.data('options'),properties=object.data('properties');for(var langValue in value) 166 {if(properties.languagesValues[langValue]!=null) 167 privateMethods.setLanguageValue(object,langValue,value[langValue],langValue==options.currentLanguage);} 168 return(properties.languagesValues);},setLanguageValue:function(object,language,value,updateInput) 169 {var options=object.data('options'),properties=object.data('properties');if(properties.languagesValues[language]!=null) 170 {properties.languagesValues[language]=value;if(updateInput)privateMethods.setValue(object,properties.languagesValues[options.currentLanguage],true);} 171 return(options.languagesValues);},setCurrentLanguage:function(object,value) 172 {var options=object.data('options'),properties=object.data('properties');if((!properties.initialized||options.currentLanguage!=value)&&$.inArray(value,options.languages)>=0) 173 {options.currentLanguage=value;privateMethods.setValue(object,properties.languagesValues[options.currentLanguage],true);} 174 return(options.currentLanguage);},setLanguageSelector:function(object,value) 175 {var options=object.data('options'),properties=object.data('properties');if((!properties.initialized||options.languageSelector!=value)&&value!=''&&$('#'+value).length>0) 176 {if(options.languageSelector!='')$('#'+options.languageSelector).unbind('inputListChange');options.languageSelector=value;if(options.languageSelector!='') 177 $('#'+options.languageSelector).bind('inputListChange',function(event,lang) 178 {privateMethods.setCurrentLanguage(object,lang);});} 179 return(options.currentLanguage);},setValue:function(object,value,apply) 180 {var options=object.data('options'),properties=object.data('properties'),objects=object.data('objects');if(properties.initialized&&properties.value==value) 181 {return(properties.value);} 182 privateMethods.setIsValid(object,true);properties.value=value;if(apply) 183 {objects.input.val(properties.value);} 184 if(options.currentLanguage!='')privateMethods.setLanguageValue(object,options.currentLanguage,value,false);if(options.change)object.trigger('inputTextChange',properties.value);return(properties.value);},setEventChange:function(object,value) 185 {var options=object.data('options');options.change=value;object.unbind('inputTextChange');if(value)object.bind('inputTextChange',options.change);return(options.change);},keyUp:function(object,event) 186 {var objects=object.data('objects');if(event.keyCode==9||event.keyCode==12||event.keyCode==16||event.keyCode==17||event.keyCode==18||event.keyCode==33||event.keyCode==34||event.keyCode==35||event.keyCode==36||event.keyCode==37||event.keyCode==38||event.keyCode==39||event.keyCode==40||event.keyCode==45||event.keyCode==93)return(false);return(privateMethods.setValue(object,objects.input.val(),false));},change:function(object,event) 187 {var objects=object.data('objects');return(privateMethods.setValue(object,objects.input.val(),false))},keyDown:function(object,event) 188 {var objects=object.data('objects'),options=object.data('options');if(options.maxChar>0&&objects.input.val().length>=options.maxChar&&!(event.keyCode==8||event.keyCode==9||event.keyCode==12||event.keyCode==16||event.keyCode==17||event.keyCode==18||event.keyCode==33||event.keyCode==34||event.keyCode==35||event.keyCode==36||event.keyCode==37||event.keyCode==38||event.keyCode==39||event.keyCode==40||event.keyCode==45||event.keyCode==46||event.keyCode==93||objects.input.get(0).selectionStart!=objects.input.get(0).selectionEnd))return(false);},doTranslation:function(object) 189 {var objects=object.data('objects'),properties=object.data('properties'),options=object.data('options');if(googleTranslate!=null) 190 {googleTranslate(properties.value,'',options.currentLanguage.substr(0,2),function(result) 191 {privateMethods.setValue(object,result,true);});}}};$.fn.inputText=function(method) 192 {if(publicMethods[method]) 193 {return publicMethods[method].apply(this,Array.prototype.slice.call(arguments,1));} 194 else if(typeof method==='object'||!method) 195 {return publicMethods.init.apply(this,arguments);} 196 else 197 {$.error('Method '+method+' does not exist on jQuery.inputText');}}})(jQuery); 1 /* file: ui.inputText.js - v1.1.1 | minified on 2011/01/31 with http://jscompress.com/ */ 2 /** 3 * ----------------------------------------------------------------------------- 4 * file: ui.inputText.js 5 * file version: 1.1.0 6 * date: 2011-01-09 7 * 8 * A jQuery plugin provided by the piwigo's plugin "GrumPluginClasses" 9 * 10 * ----------------------------------------------------------------------------- 11 * Author : Grum 12 * email : grum@piwigo.com 13 * website : http://photos.grum.fr 14 * PWG user : http://forum.phpwebgallery.net/profile.php?id=3706 15 * 16 * << May the Little SpaceFrog be with you ! >> 17 * ----------------------------------------------------------------------------- 18 * 19 * 20 * 21 * 22 * :: HISTORY :: 23 * 24 * | release | date | 25 * | 1.0.0 | 2010/11/04 | * first release 26 * | | | 27 * | 1.1.0 | 2011/01/09 | * if div content is not empty and text value not 28 * | | | defined, use of div content to define text value 29 * | | | 30 * | | | * add multilanguage managment 31 * | | | 32 * | | | 33 * | | | 34 * 35 */ 36 37 38 39 ( 40 function($) 41 { 42 /* 43 * plugin 'public' functions 44 */ 45 var publicMethods = 46 { 47 init : function (opt) 48 { 49 return this.each(function() 50 { 51 // default values for the plugin 52 var $this=$(this), 53 data = $this.data('options'), 54 objects = $this.data('objects'), 55 properties = $this.data('properties'), 56 options = 57 { 58 languages:[], 59 currentLanguage:'', 60 languagesValues:{}, 61 languageSelector:'', 62 multilines:false, 63 disabled:false, 64 textAlign:'left', 65 displayChar:0, 66 maxChar:0, 67 numRows:1, 68 regExp:'', 69 value:'', 70 change:null 71 }; 72 73 // if options given, merge it 74 // if(opt) $.extend(options, opt); ==> options are set by setters 75 if(options.value=='' && $.trim($this.html())!='') options.value=$.trim($this.html()); 76 77 $this.data('options', options); 78 79 if(!properties) 80 { 81 $this.data('properties', 82 { 83 initialized:false, 84 re:/.*/, 85 value:0, 86 isValid:true, 87 languagesValues:{} 88 } 89 ); 90 properties=$this.data('properties'); 91 } 92 93 if(!objects) 94 { 95 objects = 96 { 97 container:$('<div/>', 98 { 99 'class':'ui-inputText', 100 css:{ 101 width:'100%' 102 } 103 } 104 ).bind('click.inputText', 105 function () 106 { 107 objects.input.focus(); 108 } 109 ), 110 input:null 111 }; 112 113 $this 114 .html('') 115 .append(objects.container); 116 117 $this.data('objects', objects); 118 } 119 120 privateMethods.setOptions($this, opt); 121 } 122 ); 123 }, // init 124 destroy : function () 125 { 126 return this.each( 127 function() 128 { 129 // default values for the plugin 130 var $this=$(this), 131 objects = $this.data('objects'); 132 objects.input.unbind().remove(); 133 objects.container.unbind().remove(); 134 $this 135 .unbind('.inputText') 136 .css( 137 { 138 width:'', 139 height:'' 140 } 141 ); 142 } 143 ); 144 }, // destroy 145 146 options: function (value) 147 { 148 return( 149 this.each( 150 function() 151 { 152 privateMethods.setOptions($(this), value); 153 } 154 ) 155 ); 156 }, // options 157 158 disabled: function (value) 159 { 160 if(value!=null) 161 { 162 return( 163 this.each( 164 function() 165 { 166 privateMethods.setDisabled($(this), value); 167 } 168 ) 169 ); 170 } 171 else 172 { 173 var options = this.data('options'); 174 175 if(options) 176 { 177 return(options.disabled); 178 } 179 else 180 { 181 return(''); 182 } 183 } 184 }, // disabled 185 186 textAlign: function (value) 187 { 188 if(value!=null) 189 { 190 return( 191 this.each( 192 function() 193 { 194 privateMethods.setTextAlign($(this), value); 195 } 196 ) 197 ); 198 } 199 else 200 { 201 var options = this.data('options'); 202 203 if(options) 204 { 205 return(options.textAlign); 206 } 207 else 208 { 209 return(''); 210 } 211 } 212 }, // textAlign 213 214 displayChar: function (value) 215 { 216 if(value!=null) 217 { 218 return( 219 this.each( 220 function() 221 { 222 privateMethods.setDisplayChar($(this), value); 223 } 224 ) 225 ); 226 } 227 else 228 { 229 var options = this.data('options'); 230 231 if(options) 232 { 233 return(options.displayChar); 234 } 235 else 236 { 237 return(''); 238 } 239 } 240 }, // displayChar 241 242 maxChar: function (value) 243 { 244 if(value!=null) 245 { 246 return( 247 this.each( 248 function() 249 { 250 privateMethods.setMaxChar($(this), value); 251 } 252 ) 253 ); 254 } 255 else 256 { 257 var options = this.data('options'); 258 259 if(options) 260 { 261 return(options.maxChar); 262 } 263 else 264 { 265 return(''); 266 } 267 } 268 }, // maxChar 269 270 numRows: function (value) 271 { 272 if(value!=null) 273 { 274 return( 275 this.each( 276 function() 277 { 278 privateMethods.setNumRows($(this), value); 279 } 280 ) 281 ); 282 } 283 else 284 { 285 var options = this.data('options'); 286 287 if(options) 288 { 289 return(options.numRows); 290 } 291 else 292 { 293 return(''); 294 } 295 } 296 }, // numRows 297 298 regExp: function (value) 299 { 300 if(value!=null) 301 { 302 return( 303 this.each( 304 function() 305 { 306 privateMethods.setRegExp($(this), value); 307 } 308 ) 309 ); 310 } 311 else 312 { 313 var options = this.data('options'); 314 315 if(options) 316 { 317 return(options.regExp); 318 } 319 else 320 { 321 return(''); 322 } 323 } 324 }, // regExp 325 326 multilines: function () 327 { 328 // return the selected tags 329 var properties=this.data('properties'); 330 return(properties.multilines); 331 }, // multilines 332 333 languages: function (value) 334 { 335 if(value!=null) 336 { 337 // set the known languages 338 return( 339 this.each( 340 function() 341 { 342 privateMethods.setLanguages($(this), value); 343 } 344 ) 345 ); 346 } 347 else 348 { 349 // return the known languages 350 var options = this.data('options'); 351 return(options.languages); 352 } 353 }, 354 355 currentLanguage: function (value) 356 { 357 if(value!=null) 358 { 359 // set the current language 360 return( 361 this.each( 362 function() 363 { 364 privateMethods.setCurrentLanguage($(this), value); 365 } 366 ) 367 ); 368 } 369 else 370 { 371 // return the current language 372 var options = this.data('options'); 373 return(options.currentLanguage); 374 } 375 }, 376 377 languageSelector: function (value) 378 { 379 if(value!=null) 380 { 381 // set the language selector id (inputList object) 382 return( 383 this.each( 384 function() 385 { 386 privateMethods.setLanguageSelector($(this), value); 387 } 388 ) 389 ); 390 } 391 else 392 { 393 // return the language selector id 394 var options = this.data('options'); 395 return(options.languageSelector); 396 } 397 }, //languageSelector 398 399 languagesValues: function (value) 400 { 401 if(value!=null) 402 { 403 // set the languages values 404 return( 405 this.each( 406 function() 407 { 408 privateMethods.setLanguagesValues($(this), value); 409 } 410 ) 411 ); 412 } 413 else 414 { 415 // return the languages values 416 var properties=this.data('properties'); 417 return(properties.languagesValues); 418 } 419 }, 420 421 value: function (value, language) 422 { 423 if(value!=null) 424 { 425 var options=this.data('options'); 426 427 // set selected value 428 return( 429 this.each( 430 function() 431 { 432 if(language!=null) 433 { 434 privateMethods.setLanguageValue($(this), language, value, options.currentLanguage==language); 435 } 436 else 437 { 438 privateMethods.setValue($(this), value, true); 439 } 440 } 441 ) 442 ); 443 } 444 else 445 { 446 // return the selected tags 447 var properties=this.data('properties'); 448 return(properties.value); 449 } 450 }, // value 451 452 isValid: function (value) 453 { 454 if(value!=null) 455 { 456 // set selected value 457 return( 458 this.each( 459 function() 460 { 461 privateMethods.setIsValid($(this), value); 462 } 463 ) 464 ); 465 } 466 else 467 { 468 // return the selected tags 469 var properties=this.data('properties'); 470 return(properties.isValid); 471 } 472 }, // isValid 473 474 change: function (value) 475 { 476 if(value!=null && $.isFunction(value)) 477 { 478 // set selected value 479 return( 480 this.each( 481 function() 482 { 483 privateMethods.setEventChange($(this), value); 484 } 485 ) 486 ); 487 } 488 else 489 { 490 // return the selected value 491 var options=this.data('options'); 492 493 if(options) 494 { 495 return(options.change); 496 } 497 else 498 { 499 return(null); 500 } 501 } 502 }, // change 503 504 doTranslation: function () 505 { 506 // set selected value 507 return( 508 this.each( 509 function() 510 { 511 privateMethods.doTranslation($(this)); 512 } 513 ) 514 ); 515 } // doTranslation 516 517 }; // methods 518 519 520 /* 521 * plugin 'private' methods 522 */ 523 var privateMethods = 524 { 525 /** 526 * return true is given value is a valid numeric value, according to the 527 * rules defined by the object 528 * @param Object object 529 * @param value 530 * @return Bool 531 */ 532 isValid : function (object, value) 533 { 534 var properties=object.data('properties'); 535 536 return(properties.re.exec(value)) 537 }, 538 539 setOptions : function (object, value) 540 { 541 var properties=object.data('properties'), 542 options=object.data('options'); 543 544 if(!$.isPlainObject(value)) return(false); 545 546 properties.initialized=false; 547 548 privateMethods.setMultilines(object, (value.multilines!=null)?value.multilines:options.multilines); 549 privateMethods.setDisplayChar(object, (value.displayChar!=null)?value.displayChar:options.displayChar); 550 privateMethods.setMaxChar(object, (value.maxChar!=null)?value.maxChar:options.maxChar); 551 privateMethods.setNumRows(object, (value.numRows!=null)?value.numRows:options.numRows); 552 privateMethods.setRegExp(object, (value.regExp!=null)?value.regExp:options.regExp); 553 554 privateMethods.setLanguages(object, (value.languages!=null)?value.languages:options.languages); 555 privateMethods.setLanguagesValues(object, (value.languagesValues!=null)?value.languagesValues:options.languagesValues); 556 privateMethods.setCurrentLanguage(object, (value.currentLanguage!=null)?value.currentLanguage:options.currentLanguage); 557 privateMethods.setLanguageSelector(object, (value.languageSelector!=null)?value.languageSelector:options.languageSelector); 558 559 if((properties.languagesValues[options.currentLanguage]!=null && 560 properties.languagesValues[options.currentLanguage]!='' || 561 properties.languagesValues[options.currentLanguage]==null) && 562 (value.value!=null && value.value!='' || options.value!='') 563 ) privateMethods.setValue(object, (value.value!=null)?value.value:options.value, true); 564 565 privateMethods.setTextAlign(object, (value.textAlign!=null)?value.textAlign:options.textAlign); 566 567 privateMethods.setEventChange(object, (value.change!=null)?value.change:options.change); 568 569 properties.initialized=true; 570 }, 571 572 /** 573 * define the regular expression used to check validity of a numeric value 574 * @param Object object 575 */ 576 setRegExp : function (object, value) 577 { 578 var properties=object.data('properties'), 579 flagRE=/^\/(.*)\/(.*)$/, 580 flags=flagRE.exec(value); 581 582 if(flags==null) 583 { 584 flags=['.*', '']; 585 } 586 587 delete properties.re; 588 properties.re = new RegExp(flags[1],flags[2]); 589 }, 590 591 setIsValid : function (object, value) 592 { 593 var objects=object.data('objects'), 594 properties=object.data('properties'); 595 596 if(properties.isValid!=value && properties.initialized) 597 { 598 properties.isValid=value; 599 if(properties.isValid) 600 { 601 objects.container.removeClass('ui-error'); 602 objects.input.removeClass('ui-error'); 603 } 604 else 605 { 606 objects.container.addClass('ui-error'); 607 objects.input.addClass('ui-error'); 608 } 609 } 610 return(properties.isValid); 611 }, 612 613 setDisplayChar : function (object, value) 614 { 615 var options=object.data('options'), 616 objects=object.data('objects'); 617 properties=object.data('properties'); 618 619 if((!properties.initialized || options.displayChar!=value) && value>=0) 620 { 621 options.displayChar=value; 622 if(options.displayChar>0) 623 { 624 if(options.multilines) 625 { 626 objects.input.attr('cols', options.displayChar); 627 } 628 else 629 { 630 objects.input.attr('size', options.displayChar); 631 } 632 } 633 else 634 { 635 if(options.multilines) 636 { 637 objects.input.removeAttr('size'); 638 } 639 else 640 { 641 objects.input.removeAttr('cols'); 642 } 643 } 644 } 645 if(object.width()>0) 646 { 647 objects.input.css( 648 { 649 'width': object.width()+'px', 650 'max-width': object.width()+'px' 651 } 652 ); 653 } 654 return(options.displayChar); 655 }, 656 657 setMaxChar : function (object, value) 658 { 659 var options=object.data('options'), 660 objects=object.data('objects'), 661 properties=object.data('properties'); 662 663 if((!properties.initialized || options.maxChar!=value) && value>=0) 664 { 665 options.maxChar=value; 666 if(!options.multilines) 667 { 668 if(options.maxChar>0) 669 { 670 objects.input.attr('maxlength', options.maxChar); 671 } 672 else 673 { 674 objects.input.removeAttr('maxlength'); 675 } 676 } 677 } 678 return(options.maxChar); 679 }, 680 681 setNumRows : function (object, value) 682 { 683 var options=object.data('options'), 684 objects=object.data('objects'), 685 properties=object.data('properties'); 686 687 if((!properties.initialized || options.numRows!=value) && value>0) 688 { 689 options.numRows=value; 690 if(options.multilines) 691 { 692 objects.input.attr('rows', options.numRows); 693 } 694 } 695 return(options.numRows); 696 }, 697 698 setDisabled : 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.disabled!=value) && (value==true || value==false)) 705 { 706 options.disabled=value; 707 objects.input.attr('disabled', options.disabled); 708 } 709 return(options.disabled); 710 }, 711 712 setTextAlign : function (object, value) 713 { 714 var options=object.data('options'), 715 objects=object.data('objects'), 716 properties=object.data('properties'); 717 718 if((!properties.initialized || options.textAlign!=value) && (value=='left' || value=='right')) 719 { 720 options.textAlign=value; 721 objects.input.css('text-align', options.textAlign); 722 } 723 return(options.textAlign); 724 }, 725 726 727 setMultilines : function (object, value) 728 { 729 var options=object.data('options'), 730 objects=object.data('objects'), 731 properties=object.data('properties'); 732 733 if((!properties.initialized || options.multilines!=value) && (value==true || value==false)) 734 { 735 options.multilines=value; 736 737 if(options.multilines) 738 { 739 objects.input=$('<textarea/>'); 740 } 741 else 742 { 743 objects.input=$('<input>', 744 { 745 type:"text", 746 value:'' 747 } 748 ); 749 } 750 751 objects.container.append( 752 objects.input.bind('keyup.inputText', 753 function (event) 754 { 755 return(privateMethods.keyUp(object, event)); 756 } 757 ) 758 .bind('change.inputText', 759 function (event) 760 { 761 return(privateMethods.change(object, event)); 762 } 763 ) 764 .bind('keydown.inputText', 765 function (event) 766 { 767 return(privateMethods.keyDown(object, event)); 768 } 769 ) 770 ); 771 772 } 773 return(options.textAlign); 774 }, //setMultilines 775 776 setLanguages : function (object, value) 777 { 778 var properties=object.data('properties'), 779 options=object.data('options'); 780 781 options.languages=value; 782 options.languagesValues={}; 783 784 if(options.languages.length>0) 785 { 786 if($.inArray(options.currentLanguage, options.languages)<0 || 787 options.currentLanguage=='') options.currentLanguage=options.languages[0]; 788 789 for(var i=0;i<options.languages.length;i++) 790 { 791 properties.languagesValues[options.languages[i]]=''; 792 } 793 } 794 else 795 { 796 options.currentLanguage=''; 797 } 798 799 return(options.languages); 800 }, //setLanguages 801 802 setLanguagesValues : function (object, value) 803 { 804 var options=object.data('options'), 805 properties=object.data('properties'); 806 807 if(value==':clear') 808 { 809 for(var langValue in properties.languagesValues) 810 { 811 privateMethods.setLanguageValue(object, langValue, '', langValue==options.currentLanguage); 812 } 813 } 814 else if(!$.isEmptyObject(value)) 815 { 816 for(var langValue in value) 817 { 818 if(properties.languagesValues[langValue]!=null) 819 privateMethods.setLanguageValue(object, langValue, value[langValue], langValue==options.currentLanguage); 820 } 821 } 822 823 return(properties.languagesValues); 824 }, //setLanguagesValues 825 826 setLanguageValue : function (object, language, value, updateInput) 827 { 828 var options=object.data('options'), 829 properties=object.data('properties'); 830 831 if(properties.languagesValues[language]!=null) 832 { 833 properties.languagesValues[language]=value; 834 835 if(updateInput) privateMethods.setValue(object, properties.languagesValues[options.currentLanguage], true); 836 } 837 838 return(options.languagesValues); 839 }, //setLanguageValue 840 841 setCurrentLanguage : function (object, value) 842 { 843 var options=object.data('options'), 844 properties=object.data('properties'); 845 846 if((!properties.initialized || options.currentLanguage!=value) && $.inArray(value, options.languages)>=0) 847 { 848 options.currentLanguage=value; 849 850 privateMethods.setValue(object, properties.languagesValues[options.currentLanguage], true); 851 } 852 853 return(options.currentLanguage); 854 }, //setCurrentLanguage 855 856 setLanguageSelector : function (object, value) 857 { 858 var options=object.data('options'), 859 properties=object.data('properties'); 860 861 if((!properties.initialized || options.languageSelector!=value) && value!='' && $('#'+value).length>0) 862 { 863 if(options.languageSelector!='') $('#'+options.languageSelector).unbind('inputListChange'); 864 options.languageSelector=value; 865 866 if(options.languageSelector!='') 867 $('#'+options.languageSelector).bind('inputListChange', 868 function (event, lang) 869 { 870 privateMethods.setCurrentLanguage(object, lang); 871 } 872 ); 873 } 874 875 return(options.currentLanguage); 876 }, //setCurrentLanguage 877 878 setValue : function (object, value, apply) 879 { 880 var options=object.data('options'), 881 properties=object.data('properties'), 882 objects=object.data('objects'); 883 884 if(properties.initialized && properties.value==value) 885 { 886 return(properties.value); 887 } 888 889 privateMethods.setIsValid(object, true); 890 891 properties.value=value; 892 893 if(apply) 894 { 895 objects.input.val(properties.value); 896 } 897 898 if(options.currentLanguage!='') privateMethods.setLanguageValue(object, options.currentLanguage, value, false); 899 900 if(options.change) object.trigger('inputTextChange', properties.value); 901 902 return(properties.value); 903 }, //setValue 904 905 setEventChange : function (object, value) 906 { 907 var options=object.data('options'); 908 909 options.change=value; 910 object.unbind('inputTextChange'); 911 if(value) object.bind('inputTextChange', options.change); 912 return(options.change); 913 }, 914 915 keyUp : function (object, event) 916 { 917 var objects=object.data('objects'); 918 919 if(event.keyCode==9 || //DOM_VK_TAB 920 event.keyCode==12 || //DOM_VK_CLEAR 921 event.keyCode==16 || //DOM_VK_SHIFT 922 event.keyCode==17 || //DOM_VK_CONTROL 923 event.keyCode==18 || //DOM_VK_ALT 924 event.keyCode==33 || //DOM_VK_PAGE_UP 925 event.keyCode==34 || //DOM_VK_PAGE_DOWN 926 event.keyCode==35 || //DOM_VK_END 927 event.keyCode==36 || //DOM_VK_HOME 928 event.keyCode==37 || //DOM_VK_LEFT 929 event.keyCode==38 || //DOM_VK_UP 930 event.keyCode==39 || //DOM_VK_RIGHT 931 event.keyCode==40 || //DOM_VK_DOWN 932 event.keyCode==45 || //DOM_VK_INSERT 933 event.keyCode==93 //DOM_VK_CONTEXT_MENU 934 ) return(false); 935 936 return(privateMethods.setValue(object, objects.input.val(), false)); 937 }, 938 939 change : function (object, event) 940 { 941 var objects=object.data('objects'); 942 943 return(privateMethods.setValue(object, objects.input.val(), false)) 944 }, 945 946 keyDown : function (object, event) 947 { 948 var objects=object.data('objects'), 949 options=object.data('options'); 950 951 if(options.maxChar>0 && 952 objects.input.val().length>=options.maxChar && 953 !(event.keyCode==8 || //DOM_VK_BACK_SPACE 954 event.keyCode==9 || //DOM_VK_TAB 955 event.keyCode==12 || //DOM_VK_CLEAR 956 event.keyCode==16 || //DOM_VK_SHIFT 957 event.keyCode==17 || //DOM_VK_CONTROL 958 event.keyCode==18 || //DOM_VK_ALT 959 event.keyCode==33 || //DOM_VK_PAGE_UP 960 event.keyCode==34 || //DOM_VK_PAGE_DOWN 961 event.keyCode==35 || //DOM_VK_END 962 event.keyCode==36 || //DOM_VK_HOME 963 event.keyCode==37 || //DOM_VK_LEFT 964 event.keyCode==38 || //DOM_VK_UP 965 event.keyCode==39 || //DOM_VK_RIGHT 966 event.keyCode==40 || //DOM_VK_DOWN 967 event.keyCode==45 || //DOM_VK_INSERT 968 event.keyCode==46 || //DOM_VK_DELETE 969 event.keyCode==93 || //DOM_VK_CONTEXT_MENU 970 objects.input.get(0).selectionStart!=objects.input.get(0).selectionEnd 971 ) 972 ) return(false); 973 }, 974 975 /** 976 * do translation through a google translate API call (need the GPC google_translate.js file is loaded) 977 * 978 * @param String input : id of input field ; if empty, translate all localized fields 979 */ 980 doTranslation : function(object) 981 { 982 var objects=object.data('objects'), 983 properties=object.data('properties'), 984 options=object.data('options'); 985 986 if(googleTranslate!=null) 987 { 988 googleTranslate(properties.value, '', options.currentLanguage.substr(0,2), 989 function (result) 990 { 991 privateMethods.setValue(object, result, true); 992 } 993 ); 994 } 995 } 996 997 }; 998 999 1000 $.fn.inputText = function(method) 1001 { 1002 if(publicMethods[method]) 1003 { 1004 return publicMethods[method].apply( this, Array.prototype.slice.call( arguments, 1 )); 1005 } 1006 else if(typeof method === 'object' || ! method) 1007 { 1008 return publicMethods.init.apply(this, arguments); 1009 } 1010 else 1011 { 1012 $.error( 'Method ' + method + ' does not exist on jQuery.inputText' ); 1013 } 1014 } // $.fn.inputText 1015 1016 } 1017 )(jQuery); 1018 1019 -
extensions/GrumPluginClasses/main.inc.php
r9009 r9020 2 2 /* 3 3 Plugin Name: Grum Plugins Classes.3 4 Version: 3.4. 14 Version: 3.4.2 5 5 Description: Collection de classes partagées entre mes plugins (existants, ou à venir) / Partaged classes between my plugins (actuals or futures) 6 6 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=199 … … 135 135 | 3.4.1 | 2011/01/31 | * mantis bug:2156 136 136 | | | . undefined variable on RBuilder screens 137 | | | 138 | 3.4.2 | 2011/01/31 | * mantis bug:2162 139 | | | . Personalised blocks : when adding a new block, 140 | | | previous title & content are not reseted (AMM bug 141 | | | due to inputText.js ui component) 142 | | | 137 143 | | | 138 144 | | |
Note: See TracChangeset
for help on using the changeset viewer.