main.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //CHARGEMENT DE LA PAGE
  2. function init_plugin_customiser(){
  3. switch($.urlParam('page')){
  4. default:
  5. break;
  6. }
  7. }
  8. //Enregistrement des configurations
  9. function customiser_setting_save(){
  10. var fields = [];
  11. $('input,select','#customiser-setting-form').each(function(i,element){
  12. element = $(element);
  13. var value = element.val();
  14. if(element.attr('type') == 'file'){
  15. value = element[0].files[0];
  16. }
  17. fields.push({
  18. signature : element.attr('data-signature'),
  19. instruction : element.attr('data-instruction'),
  20. value : value,
  21. type : element.attr('data-field-type'),
  22. id : element.attr('id')
  23. });
  24. });
  25. $.action({
  26. action : 'customiser_setting_save',
  27. fields : fields
  28. },function(){
  29. $.message('success','Enregistré');
  30. });
  31. }
  32. function customiser_preview(element){
  33. element = $(element);
  34. var value = element.val();
  35. if(element.attr('data-field-type')=='image'){
  36. var reader = new FileReader();
  37. reader.onload = function (e) {
  38. $(element.attr('data-signature')).css(element.attr('data-instruction'),'url('+e.target.result+')');
  39. }
  40. reader.readAsDataURL(element[0].files[0]);
  41. }else{
  42. $(element.attr('data-signature')).css(element.attr('data-instruction'),value);
  43. console.log(element.attr('data-signature'),element.attr('data-instruction'),value);
  44. }
  45. }