[4905] | 1 | {literal} |
---|
| 2 | <script type="text/javascript"> |
---|
| 3 | |
---|
| 4 | function init() |
---|
| 5 | { |
---|
| 6 | $("#iGroups") |
---|
| 7 | .html( |
---|
| 8 | $.ajax( |
---|
| 9 | { |
---|
| 10 | type: "POST", |
---|
| 11 | url: "{/literal}{$datas.urlRequest}{literal}", |
---|
| 12 | async: false, |
---|
[6722] | 13 | data: { ajaxfct:"admin.group.getList" } |
---|
[4905] | 14 | } |
---|
| 15 | ).responseText |
---|
| 16 | ) |
---|
| 17 | .sortable( |
---|
| 18 | { |
---|
| 19 | connectWith: '.connectedSortable', |
---|
| 20 | cursor: 'move', |
---|
| 21 | opacity:0.6, |
---|
| 22 | items: 'li.groupItems', |
---|
| 23 | axis:'y', |
---|
| 24 | tolerance:'intersect', |
---|
| 25 | start: function (event, ui) |
---|
| 26 | { |
---|
[12225] | 27 | manageGroup(event.originalEvent.target.id.substr(8), 'n'); |
---|
[4905] | 28 | }, |
---|
| 29 | update: function (event, ui) |
---|
| 30 | { |
---|
| 31 | list=""; |
---|
| 32 | $("#iGroups li").each( |
---|
| 33 | function () |
---|
| 34 | { |
---|
| 35 | if(list!="") list+=";"; |
---|
| 36 | list+=this.id.substr(8); |
---|
| 37 | } |
---|
| 38 | ); |
---|
[12225] | 39 | |
---|
[4905] | 40 | $.ajax( |
---|
| 41 | { |
---|
| 42 | type: "POST", |
---|
| 43 | url: "{/literal}{$datas.urlRequest}{literal}", |
---|
| 44 | async: false, |
---|
[6722] | 45 | data: { ajaxfct:"admin.group.setOrder", listGroup:list } |
---|
[4905] | 46 | } |
---|
| 47 | ).responseText; |
---|
| 48 | } |
---|
| 49 | } |
---|
| 50 | ); |
---|
[5088] | 51 | |
---|
| 52 | if($("#iGroups li").length == 1) |
---|
| 53 | { |
---|
| 54 | manageGroup('1', 'y'); |
---|
| 55 | } |
---|
[4905] | 56 | } |
---|
| 57 | |
---|
| 58 | function initSubList(groupId) |
---|
| 59 | { |
---|
| 60 | $("#iGroupId"+groupId+"_tags").sortable( |
---|
| 61 | { |
---|
| 62 | connectWith: '.g'+groupId+'_connectedSortableTags', |
---|
| 63 | cursor: 'move', |
---|
| 64 | opacity:0.6, |
---|
| 65 | items: 'li', |
---|
| 66 | axis:'y', |
---|
| 67 | tolerance:'pointer', |
---|
| 68 | containment: 'parent', |
---|
| 69 | update: function (event, ui) |
---|
| 70 | { |
---|
| 71 | list=""; |
---|
| 72 | $("#iGroupId"+groupId+"_tags li").each( |
---|
| 73 | function () |
---|
| 74 | { |
---|
| 75 | if(list!="") list+=";"; |
---|
| 76 | list+=this.id.substr(this.id.indexOf('t')+1); |
---|
| 77 | } |
---|
| 78 | ); |
---|
[12225] | 79 | |
---|
[4905] | 80 | $.ajax( |
---|
| 81 | { |
---|
| 82 | type: "POST", |
---|
| 83 | url: "{/literal}{$datas.urlRequest}{literal}", |
---|
| 84 | async: false, |
---|
[6722] | 85 | data: { ajaxfct:"admin.group.setOrderedTagList", id:groupId, listTag:list } |
---|
[4905] | 86 | } |
---|
| 87 | ).responseText; |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | } |
---|
| 91 | ); |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | function loadGroupTags(groupId) |
---|
| 95 | { |
---|
| 96 | $("#iGroupId"+groupId+"_tags").html( |
---|
| 97 | $.ajax( |
---|
| 98 | { |
---|
| 99 | type: "POST", |
---|
| 100 | url: "{/literal}{$datas.urlRequest}{literal}", |
---|
| 101 | async: false, |
---|
[6722] | 102 | data: { ajaxfct:"admin.group.getOrderedTagList", id:groupId } |
---|
[4905] | 103 | } |
---|
| 104 | ).responseText |
---|
| 105 | ); |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | function manageGroup(groupId, force) |
---|
| 109 | { |
---|
| 110 | if(force=='y') |
---|
| 111 | { |
---|
| 112 | currentVisibility='hidden'; |
---|
| 113 | } |
---|
| 114 | else if(force=='n') |
---|
| 115 | { |
---|
| 116 | currentVisibility='visible'; |
---|
| 117 | } |
---|
| 118 | else |
---|
| 119 | { |
---|
| 120 | currentVisibility=$("#iGroupId"+groupId+"_content").css('visibility'); |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | |
---|
| 124 | if(currentVisibility=='visible') |
---|
| 125 | { |
---|
| 126 | $("div[name=fGroupId"+groupId+"_content]").css( |
---|
| 127 | { |
---|
| 128 | visibility:"hidden", |
---|
| 129 | height:"0px" |
---|
| 130 | } |
---|
| 131 | ); |
---|
| 132 | } |
---|
| 133 | else |
---|
| 134 | { |
---|
| 135 | $("div[name=fGroupId"+groupId+"_content]").css( |
---|
| 136 | { |
---|
| 137 | visibility:"visible", |
---|
| 138 | height:"auto" |
---|
| 139 | } |
---|
| 140 | ); |
---|
| 141 | loadGroupTags(groupId); |
---|
| 142 | } |
---|
| 143 | } |
---|
| 144 | |
---|
| 145 | function deleteGroup(groupId) |
---|
| 146 | { |
---|
| 147 | if(groupId!="") |
---|
| 148 | { |
---|
| 149 | groupName=$("#iGroupName"+groupId).val(); |
---|
| 150 | $("#dialog") |
---|
| 151 | .html("") |
---|
| 152 | .dialog( |
---|
| 153 | { |
---|
| 154 | resizable: true, |
---|
[6919] | 155 | width:640, |
---|
[4905] | 156 | height:120, |
---|
| 157 | modal: true, |
---|
| 158 | draggable:true, |
---|
[5935] | 159 | dialogClass: 'gcBgTabSheet gcBorder', |
---|
[4905] | 160 | title: "{/literal}{'g003_deleting_a_group'|@translate}{literal}", |
---|
| 161 | buttons: |
---|
| 162 | { |
---|
| 163 | '{/literal}{"g003_yes"|@translate}{literal}': |
---|
| 164 | function() |
---|
| 165 | { |
---|
| 166 | $.ajax( |
---|
| 167 | { |
---|
| 168 | type: "POST", |
---|
| 169 | url: "{/literal}{$datas.urlRequest}{literal}", |
---|
| 170 | async: false, |
---|
[6722] | 171 | data: { ajaxfct:"admin.group.delete", id:groupId } |
---|
[4905] | 172 | } |
---|
| 173 | ).responseText; |
---|
| 174 | $("#iGroups").html( |
---|
| 175 | $.ajax( |
---|
| 176 | { |
---|
| 177 | type: "POST", |
---|
| 178 | url: "{/literal}{$datas.urlRequest}{literal}", |
---|
| 179 | async: false, |
---|
[6722] | 180 | data: { ajaxfct:"admin.group.getList" } |
---|
[4905] | 181 | } |
---|
| 182 | ).responseText |
---|
| 183 | ); |
---|
| 184 | $(this).dialog('destroy').html("").get(0).removeAttribute('style'); |
---|
| 185 | }, |
---|
| 186 | '{/literal}{"g003_no"|@translate}{literal}': |
---|
| 187 | function() |
---|
| 188 | { |
---|
| 189 | $(this).dialog('destroy').html("").get(0).removeAttribute('style'); |
---|
| 190 | } |
---|
| 191 | } |
---|
| 192 | } |
---|
| 193 | ) |
---|
| 194 | .html("<div class='dialogForm'>{/literal}{'g003_confirm_group_delete'|@translate}{literal}</div>".replace("%s", "<i>"+groupName+"</i>", "gi")); |
---|
| 195 | } |
---|
| 196 | } |
---|
| 197 | |
---|
| 198 | function editGroup(groupId) |
---|
| 199 | { |
---|
| 200 | if(groupId=="") |
---|
| 201 | { |
---|
| 202 | dialogTitle="{/literal}{'g003_adding_a_group'|@translate}{literal}"; |
---|
| 203 | } |
---|
| 204 | else |
---|
| 205 | { |
---|
| 206 | dialogTitle="{/literal}{'g003_editing_a_group'|@translate}{literal}"; |
---|
| 207 | } |
---|
| 208 | |
---|
| 209 | $("#dialog") |
---|
| 210 | .html("") |
---|
| 211 | .dialog( |
---|
| 212 | { |
---|
| 213 | resizable: true, |
---|
[6919] | 214 | width:640, |
---|
[4905] | 215 | height:120, |
---|
| 216 | modal: true, |
---|
| 217 | draggable:true, |
---|
[5935] | 218 | dialogClass: 'gcBgTabSheet gcBorder', |
---|
[4905] | 219 | title: dialogTitle, |
---|
| 220 | buttons: |
---|
| 221 | { |
---|
| 222 | '{/literal}{"g003_ok"|@translate}{literal}': |
---|
| 223 | function() |
---|
| 224 | { |
---|
| 225 | list=""; |
---|
| 226 | $("form.dialogForm input[type='hidden']").each( |
---|
| 227 | function () |
---|
| 228 | { |
---|
| 229 | if(list!="") list+="\n"; |
---|
| 230 | list+=this.id.substr(6)+"="+this.value; |
---|
| 231 | } |
---|
| 232 | ) |
---|
| 233 | |
---|
| 234 | $.ajax( |
---|
| 235 | { |
---|
| 236 | type: "POST", |
---|
| 237 | url: "{/literal}{$datas.urlRequest}{literal}", |
---|
| 238 | async: false, |
---|
[6722] | 239 | data: { ajaxfct:"admin.group.setNames", id:groupId, listNames:list } |
---|
[4905] | 240 | } |
---|
| 241 | ).responseText; |
---|
| 242 | $("#iGroups").html( |
---|
| 243 | $.ajax( |
---|
| 244 | { |
---|
| 245 | type: "POST", |
---|
| 246 | url: "{/literal}{$datas.urlRequest}{literal}", |
---|
| 247 | async: false, |
---|
[6722] | 248 | data: { ajaxfct:"admin.group.getList" } |
---|
[4905] | 249 | } |
---|
| 250 | ).responseText |
---|
| 251 | ); |
---|
| 252 | $(this).dialog('destroy').html("").get(0).removeAttribute('style'); |
---|
| 253 | }, |
---|
| 254 | '{/literal}{"g003_cancel"|@translate}{literal}': |
---|
| 255 | function() |
---|
| 256 | { |
---|
| 257 | $(this).dialog('destroy').html("").get(0).removeAttribute('style'); |
---|
| 258 | } |
---|
| 259 | } |
---|
| 260 | } |
---|
| 261 | ) |
---|
| 262 | .html( |
---|
| 263 | $.ajax( |
---|
| 264 | { |
---|
| 265 | type: "POST", |
---|
| 266 | url: "{/literal}{$datas.urlRequest}{literal}", |
---|
| 267 | async: false, |
---|
[6722] | 268 | data: { ajaxfct:"admin.group.getNames", id:groupId } |
---|
[4905] | 269 | } |
---|
| 270 | ).responseText |
---|
| 271 | ); |
---|
| 272 | } |
---|
| 273 | |
---|
| 274 | |
---|
| 275 | function editGroupList(groupId) |
---|
| 276 | { |
---|
| 277 | $("#dialog") |
---|
| 278 | .html("") |
---|
| 279 | .dialog( |
---|
| 280 | { |
---|
| 281 | resizable: false, |
---|
[6919] | 282 | width:640, |
---|
| 283 | height:480, |
---|
[4905] | 284 | modal: true, |
---|
| 285 | draggable:true, |
---|
[5935] | 286 | dialogClass: 'gcBgTabSheet gcBorder', |
---|
[4905] | 287 | title: '{/literal}{"g003_add_delete_tags"|@translate}{literal}', |
---|
| 288 | open: function(event, ui) |
---|
| 289 | { |
---|
| 290 | bH=$("div.ui-dialog-buttonpane").get(0).clientHeight; |
---|
| 291 | $("#dialog").css('height', (this.clientHeight-bH)+"px"); |
---|
| 292 | }, |
---|
| 293 | buttons: |
---|
| 294 | { |
---|
| 295 | '{/literal}{"g003_ok"|@translate}{literal}': |
---|
| 296 | function() |
---|
| 297 | { |
---|
| 298 | list=""; |
---|
| 299 | $("#dialog table input").each( |
---|
| 300 | function () |
---|
| 301 | { |
---|
| 302 | if(this.checked) |
---|
| 303 | { |
---|
| 304 | if(list!="") list+=","; |
---|
| 305 | list+=this.id.substr(6); |
---|
| 306 | } |
---|
| 307 | } |
---|
| 308 | ) |
---|
| 309 | |
---|
| 310 | $.ajax( |
---|
| 311 | { |
---|
| 312 | type: "POST", |
---|
| 313 | url: "{/literal}{$datas.urlRequest}{literal}", |
---|
| 314 | async: false, |
---|
[6722] | 315 | data: { ajaxfct:"admin.group.setTagList", id:groupId, listTag:list } |
---|
[4905] | 316 | } |
---|
| 317 | ).responseText; |
---|
[5935] | 318 | |
---|
[4905] | 319 | $(this).dialog('destroy').html("").get(0).removeAttribute('style'); |
---|
| 320 | loadGroupTags(groupId); |
---|
| 321 | }, |
---|
| 322 | '{/literal}{"g003_cancel"|@translate}{literal}': |
---|
| 323 | function() |
---|
| 324 | { |
---|
| 325 | $(this).dialog('destroy').html("").get(0).removeAttribute('style'); |
---|
| 326 | } |
---|
| 327 | } |
---|
| 328 | } |
---|
| 329 | ) |
---|
[5935] | 330 | .html("<br>{/literal}{'g003_loading'|@translate}{literal}<br><img src='./plugins/GrumPluginClasses/icons/processing.gif'>"); |
---|
| 331 | |
---|
| 332 | $.ajax( |
---|
| 333 | { |
---|
| 334 | type: "POST", |
---|
| 335 | url: "{/literal}{$datas.urlRequest}{literal}", |
---|
| 336 | async: true, |
---|
[6722] | 337 | data: { ajaxfct:"admin.group.getTagList", id:groupId }, |
---|
[5935] | 338 | success: |
---|
| 339 | function(msg) |
---|
| 340 | { |
---|
| 341 | $("#dialog").html(msg); |
---|
| 342 | } |
---|
| 343 | } |
---|
[4905] | 344 | ); |
---|
| 345 | } |
---|
| 346 | |
---|
| 347 | </script> |
---|
| 348 | {/literal} |
---|
| 349 | |
---|
| 350 | |
---|
[5959] | 351 | <h2>{'g003_display_management'|@translate}</h2> |
---|
[4905] | 352 | |
---|
[6950] | 353 | <div class='helps'> |
---|
| 354 | <p>{'g003_display_page_help'|@translate}</p> |
---|
| 355 | </div> |
---|
| 356 | |
---|
[4905] | 357 | <div class="addGroup"> |
---|
| 358 | <a onclick="editGroup('');">{'g003_add_a_group'|@translate}</a> |
---|
| 359 | </div> |
---|
| 360 | |
---|
| 361 | |
---|
| 362 | <div id="dialog"></div> |
---|
| 363 | |
---|
| 364 | |
---|
| 365 | <div id="iGroupContainer"> |
---|
| 366 | <ul class="connectedSortable" id="iGroups"> |
---|
| 367 | </ul> |
---|
| 368 | </div> |
---|
| 369 | |
---|
| 370 | |
---|
| 371 | <script type="text/javascript"> |
---|
| 372 | init(); |
---|
| 373 | {foreach from=$datas.groups key=name item=data} |
---|
| 374 | initSubList({$data.id}); |
---|
| 375 | {/foreach} |
---|
| 376 | </script> |
---|