source: extensions/AMenuManager/js/amm_personalisedBlocks.min.js @ 14273

Last change on this file since 14273 was 10247, checked in by grum, 14 years ago

bug:2144
Compatibility with Piwigo 2.2

  • Property svn:executable set to *
File size: 4.2 KB
Line 
1/* file: amm_personalisedBlocks.js - v1.0.2 | minified on 2011/04/10 with http://jscompress.com/ */
2function userPersonnalisedBlockManage(opt,keys,token,initValues)
3{var options={ajaxUrl:'plugins/AMenuManager/amm_ajax.php'},translatedKeys={g002_ok:'g002_ok',g002_cancel:'g002_cancel',g002_loading:'g002_loading',g002_editofpersonalised:'g002_editofpersonalised',g002_createofpersonalised:'g002_createofpersonalised'},properties={id:'',token:token},load=function()
4{$('#iList').html("<br>"+translatedKeys.g002_loading+"<br><img src='./plugins/GrumPluginClasses/icons/processing.gif'>");$.ajax({type:"POST",url:options.ajaxUrl,async:true,data:{ajaxfct:"admin.blocks.list"},success:function(msg)
5{$("#iList").html(msg);}});},edit=function(blockId)
6{properties.id=blockId;$('#iDialogEdit').dialog('option','title',(blockId=='')?translatedKeys.g002_createofpersonalised:translatedKeys.g002_editofpersonalised).dialog("open");},remove=function(blockId)
7{properties.id=blockId;$.ajax({type:"POST",url:options.ajaxUrl,async:true,data:{ajaxfct:"admin.blocks.delete",id:properties.id,token:properties.token},success:function(msg)
8{load();}});},checkValidity=function()
9{$('.error').removeClass('error');ok=true;return(ok);},updateDialog=function(items)
10{if(items=='')
11{$('#iamm_personalised_nfo').inputText('value','');$('#iamm_personalised_title').inputText('value','').inputText('languagesValues',':clear');$('#iamm_personalised_content').inputText('value','').inputText('languagesValues',':clear');$('#iamm_personalised_visible').inputRadio('value','y');}
12else
13{var tmp=$.parseJSON(items),titles={},contents={};for(var lang in tmp.langs)
14{titles[lang]=tmp.langs[lang].title;contents[lang]=tmp.langs[lang].content;}
15$('#iamm_personalised_nfo').inputText('value',tmp.nfo);$('#iamm_personalised_title').inputText('languagesValues',':clear').inputText('languagesValues',titles);$('#iamm_personalised_content').inputText('languagesValues',':clear').inputText('languagesValues',contents);$('#iamm_personalised_visible').inputRadio('value',tmp.visible);}},doUpdate=function()
16{displayProcessing(true);var langs=[],titles=$('#iamm_personalised_title').inputText('languagesValues'),contents=$('#iamm_personalised_content').inputText('languagesValues');for(var lang in titles)
17{langs.push({lang:lang,title:titles[lang],content:contents[lang]});}
18var datas={nfo:$('#iamm_personalised_nfo').inputText('value'),visible:$('#iamm_personalised_visible').inputRadio('value'),langs:langs};$.ajax({type:"POST",url:options.ajaxUrl,async:true,data:{ajaxfct:"admin.blocks.set",id:properties.id,token:properties.token,datas:datas},success:function(msg)
19{displayProcessing(false);if(msg.match(/^[0-9]+$/i)!=null)
20{$('#iDialogEdit').dialog("close");load();}
21else
22{returned=msg.split('!');$('#'+returned[0]).addClass('error');alert(returned[1]);}}});},displayProcessing=function(visible)
23{if(visible)
24{$('#iBDProcessing').css("display","block");}
25else
26{$('#iBDProcessing').css("display","none");}},init=function(initValues)
27{var buttons={};buttons[translatedKeys.g002_ok]=function()
28{if(checkValidity())doUpdate();};buttons[translatedKeys.g002_cancel]=function()
29{$('#iDialogEdit').dialog("close");};$('#iDialogEdit').dialog({autoOpen:false,width:800,height:480,modal:true,dialogClass:'gcBgTabSheet gcBorder',title:'',buttons:buttons}).bind('dialogopen',function()
30{if(properties.id!='')
31{displayProcessing(true);$.ajax({type:"POST",url:options.ajaxUrl,async:true,data:{ajaxfct:"admin.blocks.get",id:properties.id},success:function(msg)
32{updateDialog(msg);displayProcessing(false);}});}
33else
34{updateDialog('');}});$('#islang').inputList({popupMode:'mouseout',listMaxHeight:300});$('#iamm_personalised_nfo').inputText({displayChar:75,maxChar:255});$('#iamm_personalised_title').inputText({displayChar:75,maxChar:255,languages:initValues.langs,currentLanguage:initValues.userLang,languageSelector:'islang'});$('#iamm_personalised_content').inputText({multilines:true,displayChar:70,numRows:13,languages:initValues.langs,currentLanguage:initValues.userLang,languageSelector:'islang'});$('#islang').inputList('value',initValues.userLang);$('#iamm_personalised_visible').inputRadio();load();};$.extend(options,opt);$.extend(translatedKeys,keys);this.load=function(){load();};this.edit=function(linkId){edit(linkId);};this.remove=function(linkId){remove(linkId);};init(initValues);}
Note: See TracBrowser for help on using the repository browser.