Changeset 1651:32a765e8db48 for plugins
- Timestamp:
- 08/27/13 18:46:14 (12 years ago)
- Branch:
- Ticket #1604
- Location:
- plugins/widgets
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/widgets/dragdrop.js
r1650 r1651 5 5 $('.js-hide').hide(); 6 6 $('.widgetSettings').hide(); 7 $('.widgets, .sortable-delete').addClass('drag'); 7 8 8 9 // move … … 82 83 }); 83 84 84 //$( "#widgets, .connected, .sortable-delete" ).disableSelection();85 86 85 }); -
plugins/widgets/style.css
r1650 r1651 19 19 padding: 4px 8px; 20 20 } 21 #widgets .js-hide { 22 display: none; 23 } 21 24 #widgets .widget-name { 22 25 min-height: 3em; … … 37 40 } 38 41 .widgets.fieldset { 42 margin-bottom: 2em; 43 } 44 .widgets.fieldset.drag { 39 45 margin-bottom: 0; 40 46 border-radius: 6px 6px 0 0; … … 99 105 } 100 106 107 .sortable-delete { 108 display: none; 109 } 101 110 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; 104 113 border-color: #999999; 105 114 border-radius: 0 0 6px 6px; … … 113 122 min-height: 25px; 114 123 padding: 4px 4px 0 24px; 124 display: block; 115 125 } 116 126 -
plugins/widgets/widgets.js
r1650 r1651 31 31 32 32 $(function() { 33 // reset 33 34 $('input[name="wreset"]').click(function() { 34 35 return window.confirm(dotclear.msg.confirm_widgets_reset); 35 36 }); 36 37 38 // plier/déplier 37 39 $('#dndnav > li, #dndextra > li, #dndcustom > li').each(function() { 38 40 dotclear.postExpander(this); 39 41 dotclear.viewPostContent(this, 'close'); 40 42 }); 43 44 // remove 45 $('input[name*=rem]').change(function () { 46 if ($(this).attr("checked")) { 47 $(this).parents('li').remove(); 48 } 49 }); 50 41 51 }); 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 elements66 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 dragEnd88 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 helper105 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 names117 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 control158 title = $('p.widget-name',items[i]).get(0);159 img_ctrl = title.firstChild;160 161 // There already an image162 if (img_ctrl.nodeName.toLowerCase() == 'img') {163 continue;164 }165 166 // Nothing to configure167 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 enough198 // 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 inside205 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.