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

Last change on this file since 16005 was 8962, checked in by grum, 13 years ago

release 3.0.0
fix bug:1716, bug:2128, bug:1296, bug:2052, bug:1910, bug:1723, bug:1709, bug:1680, bug:1477, bug:2129
rewrite plugin core, implement ajax interface, optimize JS

  • Property svn:executable set to *
File size: 2.6 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({popupMode:'mouseout'});
107
108    $('#iamm_links_title').inputText(
109      {
110        languages:initValues.langs,
111        languagesValues:initValues.titles,
112        currentLanguage:initValues.userLang,
113        languageSelector:'islang',
114        displayChar:40
115      }
116    );
117
118    $('#islang').inputList('value', initValues.userLang);
119  };
120
121  $.extend(options, opt);
122  $.extend(translatedKeys, keys);
123
124  this.submit = function () { submit(); };
125
126  init(initValues);
127}
128
129
Note: See TracBrowser for help on using the repository browser.