Dotclear


Ignore:
Timestamp:
07/09/11 20:55:09 (14 years ago)
Author:
Franck <carnet.franck.paul@…>
Branch:
themes
Message:

Mise en place drag'n'drop js

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/simpleMenu/index.php

    r539 r540  
    300300          $order = array_keys($order); 
    301301     } elseif (!empty($_POST['im_order'])) { 
    302           $order = explode(',',$_POST['im_order']); 
     302          $order = $_POST['im_order']; 
     303          if (substr($order,-1) == ',') { 
     304               $order = substr($order,0,strlen($order)-1); 
     305          } 
     306          $order = explode(',',$order); 
    303307     } 
    304308 
     
    335339     <?php 
    336340          echo 
    337                dcPage::jsToolMan(); //. 
    338 //             dcPage::jsLoad('index.php?pf=simpleMenu/dragdrop.js'); 
     341               dcPage::jsToolMan(); 
    339342     ?> 
     343       <?php  
     344          $core->auth->user_prefs->addWorkspace('accessibility');  
     345          $user_dm_nodragdrop = $core->auth->user_prefs->accessibility->nodragdrop; 
     346       ?> 
     347       <?php if (!$user_dm_nodragdrop) : ?> 
     348       <script type="text/javascript"> 
     349       //<![CDATA[ 
     350 
     351       var dragsort = ToolMan.dragsort(); 
     352       $(function() { 
     353          dragsort.makeTableSortable($("#menuitemslist").get(0), 
     354          dotclear.sortable.setHandle,dotclear.sortable.saveOrder); 
     355 
     356          $('.checkboxes-helpers').each(function() { 
     357               dotclear.checkboxesHelpers(this); 
     358          }); 
     359       }); 
     360 
     361       dotclear.sortable = { 
     362            setHandle: function(item) { 
     363               var handle = $(item).find('td.handle').get(0); 
     364               while (handle.firstChild) { 
     365                    handle.removeChild(handle.firstChild); 
     366               } 
     367 
     368               item.toolManDragGroup.setHandle(handle); 
     369               handle.className = handle.className+' handler'; 
     370            }, 
     371 
     372            saveOrder: function(item) { 
     373               var group = item.toolManDragGroup; 
     374               var order = document.getElementById('im_order'); 
     375               group.register('dragend', function() { 
     376                    order.value = ''; 
     377                    items = item.parentNode.getElementsByTagName('tr'); 
     378 
     379                    for (var i=0; i<items.length; i++) { 
     380                         order.value += items[i].id.substr(2)+','; 
     381                    } 
     382               }); 
     383            } 
     384       }; 
     385       //]]> 
     386       </script> 
     387       <?php endif; ?> 
    340388     <!-- 
    341389     <link rel="stylesheet" type="text/css" href="index.php?pf=simpleMenu/style.css" /> 
     
    437485     // Entête table 
    438486     echo  
    439           '<table id="menuitemslist">'. 
     487          '<table class="maximal dragable">'. 
    440488          '<caption>'.__('Menu items list').'</caption>'. 
    441489          '<thead>'. 
    442490          '<tr>'; 
    443491     if (!$step) { 
     492          if (count($menu) > 1) { 
     493               echo '<th scope="col"></th>'; 
     494          } 
    444495          echo '<th scope="col"></th>'; 
    445           if (count($menu) > 1) { 
    446                echo '<th scope="col">'.__('Order').'</th>'; 
    447           } 
    448496     } 
    449497     echo 
     
    453501          '</tr>'. 
    454502          '</thead>'. 
    455           '<tbody>'; 
     503          '<tbody id="menuitemslist">'; 
    456504     $count = 0; 
    457505     foreach ($menu as $i => $m) { 
    458           echo '<tr>'; 
     506          echo '<tr class="line" id="l_'.$i.'">'; 
    459507          if (!$step) { 
    460508               $count++; 
    461                echo '<td>'.form::checkbox(array('items_selected[]','ims-'.$i),$i).'</td>'; 
    462509               if (count($menu) > 1) { 
    463                     echo '<td>'.form::field(array('order['.$i.']'),2,3,$count,'position','',false,'title="'.sprintf(__('position of %s'),__($m['label'])).'"'). 
     510                    echo '<td class="handle minimal">'.form::field(array('order['.$i.']'),2,3,$count,'position','',false,'title="'.sprintf(__('position of %s'),__($m['label'])).'"'). 
    464511                         form::hidden(array('dynorder[]','dynorder-'.$i),$i).'</td>'; 
    465512               } 
     513               echo '<td class="minimal">'.form::checkbox(array('items_selected[]','ims-'.$i),$i).'</td>'; 
    466514               echo '<td class="nowrap" scope="row">'.form::field(array('items_label[]','iml-'.$i),20,255,__($m['label'])).'</td>'; 
    467515               echo '<td class="nowrap">'.form::field(array('items_descr[]','imd-'.$i),30,255,__($m['descr'])).'</td>'; 
     
    477525          '</table>'; 
    478526     if (!$step) { 
    479           echo '<p>'.form::hidden('im_order','').$core->formNonce(); 
     527          echo '<div class="two-cols">'; 
     528          echo '<p class="col">'.form::hidden('im_order','').$core->formNonce(); 
    480529          if (count($menu) > 1) { 
    481530               echo '<input type="submit" name="saveorder" value="'.__('Save order').'" /> '; 
    482531          } 
    483           echo 
    484                '<input type="submit" name="updateaction" value="'.__('Update menu items').'" /> '. 
    485                '<input type="submit" class="delete" name="removeaction" '. 
     532          echo '<input type="submit" name="updateaction" value="'.__('Update menu items').'" />'.'</p>'; 
     533          echo '<p class="col right">'.'<input type="submit" class="delete" name="removeaction" '. 
    486534                    'value="'.__('Delete selected menu items').'" '. 
    487535                    'onclick="return window.confirm(\''.html::escapeJS(__('Are you sure you want to remove selected menu items?')).'\');" />'. 
    488536               '</p>'; 
     537          echo '</div>'; 
    489538          echo '</form>'; 
    490539     } 
Note: See TracChangeset for help on using the changeset viewer.

Sites map