source: extensions/AMenuManager/js/amm_linksConfig.js @ 16744

Last change on this file since 16744 was 16744, checked in by grum, 12 years ago

bug:2696 fixed

  • Property svn:executable set to *
File size: 2.7 KB
Line 
1/**
2 * userLinksConfig
3 *
4 * release 1.0.0
5 */
6function userLinksConfig(opt, keys, token, initValues)
7{
8  var options = {
9          ajaxUrl:'plugins/AMenuManager/amm_ajax.php'
10        },
11      translatedKeys= {
12        },
13      properties = {
14          token:token
15        },
16
17
18  /**
19   * submit config
20   */
21  submit = function ()
22    {
23      if(!checkValidity()) return(false);
24
25      displayProcessing(true);
26
27      // build datas
28      var datas = {
29        title:[],
30        showIcons:$('#iamm_links_show_icons').inputRadio('value')
31      };
32
33      list=$('#iamm_links_title').inputText('languagesValues');
34      for(var id in list)
35      {
36        datas.title.push({id:id, value:list[id]});
37      }
38
39      $.ajax(
40        {
41          type: "POST",
42          url: options.ajaxUrl,
43          async: true,
44          data: { ajaxfct:"admin.links.setConfig", token:properties.token, datas:datas },
45          success:
46            function(msg)
47            {
48              displayProcessing(false);
49
50              returned=msg.split('!');
51
52              if(returned[0]=='OK')
53              {
54                $('#iConfigState')
55                  .html(returned[1])
56                  .removeClass('errors')
57                  .addClass('infos')
58                  .css('display', 'block');
59              }
60              else
61              {
62                $('#iConfigState')
63                  .html(returned[1])
64                  .removeClass('infos')
65                  .addClass('errors')
66                  .css('display', 'block');
67              }
68            }
69        }
70      );
71    },
72
73  /**
74   * check validity of form
75   */
76  checkValidity = function ()
77    {
78      $('.error').removeClass('error');
79      ok=true;
80      return(ok);
81    },
82
83  /**
84   * display or hide the processing flower
85   */
86  displayProcessing = function (visible)
87    {
88      if(visible)
89      {
90        $('#iBDProcessing').css("display", "block");
91      }
92      else
93      {
94        $('#iBDProcessing').css("display", "none");
95      }
96    },
97
98  /**
99   * initialize the object
100   */
101  init = function (initValues)
102  {
103    $('#iamm_links_show_icons').inputRadio();
104    $('#iamm_links_show_icons').inputRadio('value', initValues.showIcons);
105
106    $('#islang').inputList(
107      {
108        popupMode:'mouseout',
109        listMaxHeight:250
110      }
111    );
112
113    $('#iamm_links_title').inputText(
114      {
115        languages:initValues.langs,
116        languagesValues:initValues.titles,
117        currentLanguage:initValues.userLang,
118        languageSelector:'islang',
119        displayChar:40
120      }
121    );
122
123    $('#islang').inputList('value', initValues.userLang);
124  };
125
126  $.extend(options, opt);
127  $.extend(translatedKeys, keys);
128
129  this.submit = function () { submit(); };
130
131  init(initValues);
132}
133
134
Note: See TracBrowser for help on using the repository browser.