Dotclear

Changeset 1651:32a765e8db48 for plugins


Ignore:
Timestamp:
08/27/13 18:46:14 (12 years ago)
Author:
Lepeltier kévin
Branch:
Ticket #1604
Message:

Ticket #1604 finition

Location:
plugins/widgets
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • plugins/widgets/dragdrop.js

    r1650 r1651  
    55     $('.js-hide').hide(); 
    66     $('.widgetSettings').hide(); 
     7     $('.widgets, .sortable-delete').addClass('drag'); 
    78      
    89     // move 
     
    8283     }); 
    8384      
    84      //$( "#widgets, .connected, .sortable-delete" ).disableSelection(); 
    85       
    8685}); 
  • plugins/widgets/style.css

    r1650 r1651  
    1919     padding: 4px 8px;  
    2020} 
     21#widgets .js-hide { 
     22     display: none; 
     23} 
    2124#widgets .widget-name { 
    2225     min-height: 3em; 
     
    3740} 
    3841.widgets.fieldset { 
     42     margin-bottom: 2em; 
     43} 
     44.widgets.fieldset.drag { 
    3945     margin-bottom: 0; 
    4046     border-radius: 6px 6px 0 0; 
     
    99105} 
    100106 
     107.sortable-delete { 
     108    display: none; 
     109} 
    101110 
    102 .sortable-delete { 
    103     background: url("index.php?pf=pages/icon.png") no-repeat scroll 6px 8px #FFBABA; 
     111.sortable-delete.drag { 
     112    background: url("style/JsToolbar/bt_clean.png") no-repeat scroll 2px 5px #FFBABA; 
    104113    border-color: #999999; 
    105114    border-radius: 0 0 6px 6px; 
     
    113122    min-height: 25px; 
    114123    padding: 4px 4px 0 24px; 
     124    display: block; 
    115125} 
    116126 
  • plugins/widgets/widgets.js

    r1650 r1651  
    3131 
    3232$(function() {  
     33     // reset 
    3334     $('input[name="wreset"]').click(function() { 
    3435          return window.confirm(dotclear.msg.confirm_widgets_reset); 
    3536     }); 
    3637      
     38     // plier/déplier 
    3739     $('#dndnav > li, #dndextra > li, #dndcustom > li').each(function() { 
    3840          dotclear.postExpander(this); 
    3941          dotclear.viewPostContent(this, 'close'); 
    4042     }); 
     43      
     44     // remove 
     45     $('input[name*=rem]').change(function () { 
     46         if ($(this).attr("checked")) { 
     47             $(this).parents('li').remove(); 
     48         } 
     49     }); 
     50      
    4151}); 
    42       
    43      /*var widgets = document.getElementById('widgets'); 
    44      var w_nav = document.getElementById('dndnav'); 
    45      var w_ext = document.getElementById('dndextra'); 
    46      var w_custom = document.getElementById('dndcustom'); 
    47       
    48      $('#dndnav').addClass('hideControls'); 
    49      $('#dndextra').addClass('hideControls'); 
    50      $('#dndcustom').addClass('hideControls'); 
    51       
    52      removeElements(document.getElementById('listWidgets'),'input'); 
    53      removeElements(widgets,'p'); 
    54      removeElements(w_nav,'p'); 
    55      removeElements(w_ext,'p'); 
    56      removeElements(w_custom,'p'); 
    57      hideElements(w_nav,'input'); 
    58      hideElements(w_ext,'input'); 
    59      hideElements(w_custom,'input'); 
    60       
    61      configControls(w_nav); 
    62      configControls(w_ext); 
    63      configControls(w_custom); 
    64       
    65      // Helper to remove some elements 
    66      function removeElements(p,name) { 
    67           name = name || 'div'; 
    68           $(p).find(name+'.js-remove').each(function() { 
    69                this.parentNode.removeChild(this); 
    70           }); 
    71      } 
    72       
    73      // Helper to hide elements (but keep them) 
    74      function hideElements(p,name) { 
    75           name = name || 'div'; 
    76           $(p).find(name+'.js-hide').each(function() { 
    77                $(this).toggle(); 
    78           }); 
    79      }     
    80       
    81      function removeEmptyMsg(p) { 
    82           $(p).find('p.empty-widgets').each(function() { 
    83                this.parentNode.removeChild(this); 
    84           }); 
    85      } 
    86       
    87      // Events on dragEnd 
    88      function navDragEnd() { 
    89           formControls(this.parentNode,'nav'); 
    90           configControls(this.parentNode); 
    91           removeEmptyMsg(this.parentNode); 
    92      } 
    93      function extraDragEnd() { 
    94           formControls(this.parentNode,'extra'); 
    95           configControls(this.parentNode); 
    96           removeEmptyMsg(this.parentNode); 
    97      } 
    98      function customDragEnd() { 
    99           formControls(this.parentNode,'custom'); 
    100           configControls(this.parentNode); 
    101           removeEmptyMsg(this.parentNode); 
    102      } 
    103       
    104      // dragEnd helper 
    105      function formControls(e,pr) { 
    106           var items = new Array(); 
    107           for (var i=0; i<e.childNodes.length; i++) { 
    108                if (e.childNodes[i].nodeType == 1 && e.childNodes[i].nodeName.toLowerCase() == 'div') { 
    109                     items.push(e.childNodes[i]); 
    110                } 
    111           } 
    112            
    113           var fields, itype; 
    114           var r = new RegExp('^w\[[a-z]+]\[[0-9]+][[](.+?)]$',''); 
    115           for (i=0; i<items.length; i++) { 
    116                // Change field names 
    117                fields = getFormControls(items[i]); 
    118                var j; 
    119                var f; 
    120                for (j=0; j<fields.length; j++) { 
    121                     if (r.test(fields[j].name)) { 
    122                          itype = fields[j].name.replace(r,'$1'); 
    123                           
    124                          $(fields[j]).attr('name','w['+pr+']['+i+']['+itype+']'); 
    125                           
    126                          if (itype == 'order') { 
    127                               fields[j].value = i; 
    128                          } 
    129                     } 
    130                } 
    131           } 
    132      } 
    133       
    134      function getFormControls(e) { 
    135           var input = e.getElementsByTagName('input'); 
    136           var textarea = e.getElementsByTagName('textarea'); 
    137           var select = e.getElementsByTagName('select'); 
    138           var items = new Array(); 
    139           var i; 
    140           for (i=0; i<input.length; i++) { items.push(input[i]); } 
    141           for (i=0; i<select.length; i++) { items.push(select[i]); } 
    142           for (i=0; i<textarea.length; i++) { items.push(textarea[i]); } 
    143            
    144           return items; 
    145      } 
    146       
    147      function configControls(e) { 
    148           var items = new Array(); 
    149           for (var i=0; i<e.childNodes.length; i++) { 
    150                if (e.childNodes[i].nodeType == 1 && e.childNodes[i].nodeName.toLowerCase() == 'div') { 
    151                     items.push(e.childNodes[i]); 
    152                } 
    153           } 
    154            
    155           var title, img_ctrl, img, space; 
    156           for (i in items) { 
    157                // Append config control 
    158                title = $('p.widget-name',items[i]).get(0); 
    159                img_ctrl = title.firstChild; 
    160                 
    161                // There already an image 
    162                if (img_ctrl.nodeName.toLowerCase() == 'img') { 
    163                     continue; 
    164                } 
    165                 
    166                // Nothing to configure 
    167                if (title.nextSibling.childNodes.length == 0) { 
    168                     continue; 
    169                } 
    170                 
    171                img = document.createElement('img'); 
    172                img.src = dotclear.img_plus_src; 
    173                img.alt = dotclear.img_plus_alt; 
    174                img.control = title.nextSibling; 
    175                img.onclick = function() { widgetConfig.call(this); }; 
    176                space = document.createTextNode(' '); 
    177                title.insertBefore(img,img_ctrl); 
    178                title.insertBefore(space,img_ctrl); 
    179           } 
    180      } 
    181       
    182      function widgetConfig() { 
    183           if (this.control.style.display == 'block') { 
    184                this.control.style.display = 'none'; 
    185                this.src = dotclear.img_plus_src; 
    186                this.alt = dotclear.img_plus_alt; 
    187           } else { 
    188                this.control.style.display = 'block'; 
    189                this.src = dotclear.img_minus_src; 
    190                this.alt = dotclear.img_minus_alt; 
    191           } 
    192      } 
    193 }); 
    194  
    195 // 
    196 // For Safari, we need to make a hard copy of the form and submit copy. 
    197 // Yeah, a simple clone of the form is not enough 
    198 // I hate this browser! 
    199 // 
    200 if (document.childNodes && !document.all && !navigator.taintEnabled) 
    201 { 
    202      $(function() { 
    203           $('#sidebarsWidgets').submit(function() { 
    204                // Create a new form and copy each element inside 
    205                var f = document.createElement('form'); 
    206                f.action = this.action; 
    207                f.method = this.method; 
    208                $(f).hide(); 
    209                var fset = document.createElement('fieldset'); 
    210                f.appendChild(fset); 
    211                 
    212                document.body.appendChild(f); 
    213                 
    214                $(this).find('input').each(function() { 
    215                     var i = document.createElement('input'); 
    216                     i.type = this.type; 
    217                     i.name = this.name; 
    218                     i.value = this.value; 
    219                     if (this.type == 'checkbox') { 
    220                          i.checked = this.checked; 
    221                     } 
    222                     fset.appendChild(i); 
    223                }); 
    224                 
    225                $(this).find('textarea').each(function() { 
    226                     var i = document.createElement('textarea'); 
    227                     i.name = this.name; 
    228                     i.value = this.value; 
    229                     fset.appendChild(i); 
    230                }); 
    231                 
    232                $(this).find('select').each(function() { 
    233                     var i = document.createElement('input'); 
    234                     i.name = this.name; 
    235                     i.value = this.value; 
    236                     fset.appendChild(i); 
    237                }); 
    238                 
    239                $(fset).append('<input type="hidden" name="wup" value="1"/>'); 
    240                f.submit(); 
    241                 
    242                return false; 
    243           }); 
    244      }); 
    245 }*/ 
Note: See TracChangeset for help on using the changeset viewer.

Sites map