Changeset 1661:14832508668c
- Timestamp:
- 08/30/13 14:54:18 (12 years ago)
- Branch:
- Ticket #1604 - widgets
- Parents:
- 1660:98821b618690 (diff), 1634:aefa52039896 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- plugins/widgets
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/widgets/style.css
r1629 r1661 1 #listWidgets { 2 float: left; 3 width: 46%; 4 background: #eee; 5 padding: 1.5em 1% 0; 6 margin: 0 1% 0 0; 7 } 8 #widgets > div { 9 border: 1px solid #ccc; 10 margin-bottom: .5em; 11 background: #fff; 12 min-height: 3em; 13 padding: 0 0 4px 0; 14 } 15 #widgets .widget-name, #widgets .js-remove { 16 background: #fff; 17 margin-bottom: 0; 18 padding: 4px 8px; 19 } 20 #widgets .widget-name { 21 min-height: 3em; 22 padding-bottom: 0; 23 } 24 #listWidgets h3 { 25 color: #333; 26 } 1 /* 2 # -- BEGIN LICENSE BLOCK --------------------------------------- 3 # 4 # This file is part of Dotclear 2. 5 # 6 # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear 7 # Licensed under the GPL version 2.0 license. 8 # See LICENSE file or 9 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 10 # 11 # -- END LICENSE BLOCK ----------------------------------------- 12 */ 27 13 14 15 /* ------------------------------------------------------------- side bars */ 28 16 #sidebarsWidgets { 29 17 float: left; … … 32 20 padding: 0 1%; 33 21 } 34 #sidebarsControl {35 clear: left;36 }37 22 .widgets.fieldset { 38 23 margin-bottom: 2em; 39 24 } 40 #widgets, #dndnav, #dndextra, #dndcustom { 25 .widgets.fieldset.if-drag { 26 margin-bottom: 0; 27 border-radius: 6px 6px 0 0; 28 border-bottom: 1px dashed #FF0000; 29 } 30 #dndnav, #dndextra, #dndcustom { 41 31 padding: 1em 0; 32 margin: 1em 0 0; 42 33 } 43 #dndnav > div, #dndextra > div, #dndcustom > div { 34 #dndnav > li, 35 #dndextra > li, 36 #dndcustom > li, 37 .sortable-delete > li { 44 38 padding: O; 45 39 border: 1px solid #999; 46 40 margin-bottom: 1em; 41 list-style: none; 42 } 43 #dndnav > li.ui-sortable-placeholder, 44 #dndextra > li.ui-sortable-placeholder, 45 #dndcustom > li.ui-sortable-placeholder, 46 .sortable-delete > li.ui-sortable-placeholder { 47 border: 1px dashed #999; 48 height: 2rem; 49 padding: 3px; 50 } 51 52 .sortable-delete { 53 display: none; 54 } 55 .sortable-delete.if-drag { 56 border: 1px solid #999999; 57 border-top: 0; 58 border-radius: 0 0 6px 6px; 59 color: #000000; 60 font-weight: bold; 61 list-style: none outside none; 62 margin: 0 0 2em; 63 min-height: 25px; 64 padding: 4px; 65 display: block; 66 } 67 .sortable-delete > li { 68 margin-bottom: 3px; 69 } 70 .sortable-delete > li.sortable-delete-placeholder { 71 border: 0 none; 72 color: #FF0000; 73 font-size: 1rem; 74 font-weight: normal; 75 text-align: center; 47 76 } 48 77 … … 54 83 font-weight: bold; 55 84 } 56 .widget-name span {57 display: block;58 font-style: normal;59 font-size: 1.1rem;60 }61 85 .widget-name img { 62 86 cursor: pointer; 63 87 margin-bottom: -1px; 64 88 } 65 .widget-name a.aexpand, .widget-name a.aexpand:link, .widget-name a.aexpand:visited { 89 .widget-name a.aexpand, 90 .widget-name a.aexpand:link, 91 .widget-name a.aexpand:visited { 66 92 border: 0 none; 67 93 color: #000000; 68 94 text-decoration: none; 95 } 96 #dndnav .form-note, 97 #dndextra .form-note, 98 #dndcustom .form-note { 99 display: none; 69 100 } 70 101 .removeWidget { … … 72 103 margin: 0; 73 104 } 74 75 105 .widgetSettings { 76 106 border-top: 1px solid #ddd; … … 78 108 background: #f5f5f5; 79 109 } 80 #widgets .widgetSettings { 81 display: none; 110 111 #sidebarsControl { 112 clear: left; 82 113 } 83 .hideControls .widgetSettings { 84 display: none; 114 115 /* ------------------------------------------------------------- list Widgets ref */ 116 #listWidgets { 117 float: left; 118 width: 46%; 119 background: #eee; 120 padding: 1.5em 1% 0; 121 margin: 0 1% 0 0; 85 122 } 86 .hideControl { 123 #listWidgets h3 { 124 color: #333; 125 } 126 127 #widgets-ref { 128 padding: 1em 0; 129 margin: 1em 0 0; 130 } 131 #widgets-ref > li { 132 border: 1px solid #ccc; 133 margin-bottom: .5em; 134 background: #fff; 135 min-height: 3em; 136 padding: 0 0 4px 0; 137 list-style: none; 138 } 139 #widgets-ref .widget-name, 140 #widgets-ref .manual-move { 141 background: #fff; 142 margin-bottom: 0; 143 padding: 4px 8px 0; 144 } 145 #widgets-ref .widget-name { 146 min-height: 3em; 147 } 148 #widgets-ref .widget-name .form-note { 149 display: block; 150 font-style: normal; 151 font-size: 1.1rem; 152 } 153 #widgets-ref .widgetSettings { 87 154 display: none; 88 155 } 89 156 157 /* ------------------------------------------------------------- help */ 90 158 #widgets-tpl dt { 91 159 margin: 1em 0 0 0; -
plugins/widgets/widgets.js
r1629 r1661 1 var dragdrop = ToolMan.dragdrop(); 2 $(function() { 1 /* 2 # -- BEGIN LICENSE BLOCK --------------------------------------- 3 # 4 # This file is part of Dotclear 2. 5 # 6 # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear 7 # Licensed under the GPL version 2.0 license. 8 # See LICENSE file or 9 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 10 # 11 # -- END LICENSE BLOCK ----------------------------------------- 12 */ 13 14 dotclear.postExpander = function(line) { 15 var title = $(line).find('.widget-name'); 16 title.find('.form-note').remove(); 17 order = title.find('input[name*=order]'); 18 link = $('<a href="#" alt="expand" class="aexpand"/>').append(title.text()); 19 title.empty().append(order).append(link); 20 21 var img = document.createElement('img'); 22 img.src = dotclear.img_plus_src; 23 img.alt = dotclear.img_plus_alt; 24 img.className = 'expand'; 25 $(img).css('cursor','pointer'); 26 img.onclick = function() { dotclear.viewPostContent($(this).parents('li')); }; 27 link.click(function(e) { 28 e.preventDefault(); 29 dotclear.viewPostContent($(this).parents('li')); 30 }); 31 32 title.prepend(img); 33 }; 34 35 dotclear.viewPostContent = function(line,action) { 36 var action = action || 'toogle'; 37 var img = line.find('.expand'); 38 var isopen = img.attr('alt') == dotclear.img_plus_alt; 39 40 if( action == 'close' || ( action == 'toogle' && !isopen ) ) { 41 line.find('.widgetSettings').hide(); 42 img.attr('src', dotclear.img_plus_src); 43 img.attr('alt', dotclear.img_plus_alt); 44 } else if ( action == 'open' || ( action == 'toogle' && isopen ) ) { 45 line.find('.widgetSettings').show(); 46 img.attr('src', dotclear.img_minus_src); 47 img.attr('alt', dotclear.img_minus_alt); 48 } 49 50 }; 51 52 $(function() { 53 // reset 3 54 $('input[name="wreset"]').click(function() { 4 55 return window.confirm(dotclear.msg.confirm_widgets_reset); 5 56 }); 57 58 // plier/déplier 59 $('#dndnav > li, #dndextra > li, #dndcustom > li').each(function() { 60 dotclear.postExpander(this); 61 dotclear.viewPostContent($(this), 'close'); 62 }); 63 64 // remove 65 $('input[name*=rem]').change(function () { 66 if ($(this).attr("checked")) { 67 $(this).parents('li').remove(); 68 } 69 }); 70 6 71 }); 7 8 $(function() {9 var widgets = document.getElementById('widgets');10 var w_nav = document.getElementById('dndnav');11 var w_ext = document.getElementById('dndextra');12 var w_custom = document.getElementById('dndcustom');13 14 w_nav.className = 'hideControls';15 w_ext.className = 'hideControls';16 w_custom.className = 'hideControls';17 18 removeElements(document.getElementById('listWidgets'),'input');19 removeElements(widgets,'p');20 removeElements(w_nav,'p');21 removeElements(w_ext,'p');22 removeElements(w_custom,'p');23 hideElements(w_nav,'input');24 hideElements(w_ext,'input');25 hideElements(w_custom,'input');26 27 configControls(w_nav);28 configControls(w_ext);29 configControls(w_custom);30 31 dragdrop.makeListContainer(widgets,'div',setHandle);32 if (!document.all) { widgets.factory = true; }33 dragdrop.makeListContainer(w_nav,'div',setHandle);34 w_nav.onDragEnd = navDragEnd;35 dragdrop.makeListContainer(w_ext,'div',setHandle);36 w_ext.onDragEnd = extraDragEnd;37 dragdrop.makeListContainer(w_custom,'div',setHandle);38 w_custom.onDragEnd = customDragEnd;39 40 // Helper to remove some elements41 function removeElements(p,name) {42 name = name || 'div';43 $(p).find(name+'.js-remove').each(function() {44 this.parentNode.removeChild(this);45 });46 }47 48 // Helper to hide elements (but keep them)49 function hideElements(p,name) {50 name = name || 'div';51 $(p).find(name+'.js-hide').each(function() {52 $(this).toggle();53 });54 }55 56 function removeEmptyMsg(p) {57 $(p).find('p.empty-widgets').each(function() {58 this.parentNode.removeChild(this);59 });60 }61 62 // Events on dragEnd63 function navDragEnd() {64 formControls(this.parentNode,'nav');65 configControls(this.parentNode);66 removeEmptyMsg(this.parentNode);67 }68 function extraDragEnd() {69 formControls(this.parentNode,'extra');70 configControls(this.parentNode);71 removeEmptyMsg(this.parentNode);72 }73 function customDragEnd() {74 formControls(this.parentNode,'custom');75 configControls(this.parentNode);76 removeEmptyMsg(this.parentNode);77 }78 79 // dragEnd helper80 function formControls(e,pr) {81 var items = new Array();82 for (var i=0; i<e.childNodes.length; i++) {83 if (e.childNodes[i].nodeType == 1 && e.childNodes[i].nodeName.toLowerCase() == 'div') {84 items.push(e.childNodes[i]);85 }86 }87 88 var fields, itype;89 var r = new RegExp('^w\[[a-z]+]\[[0-9]+][[](.+?)]$','');90 for (i=0; i<items.length; i++) {91 // Change field names92 fields = getFormControls(items[i]);93 var j;94 var f;95 for (j=0; j<fields.length; j++) {96 if (r.test(fields[j].name)) {97 itype = fields[j].name.replace(r,'$1');98 99 $(fields[j]).attr('name','w['+pr+']['+i+']['+itype+']');100 101 if (itype == 'order') {102 fields[j].value = i;103 }104 }105 }106 }107 }108 109 function getFormControls(e) {110 var input = e.getElementsByTagName('input');111 var textarea = e.getElementsByTagName('textarea');112 var select = e.getElementsByTagName('select');113 var items = new Array();114 var i;115 for (i=0; i<input.length; i++) { items.push(input[i]); }116 for (i=0; i<select.length; i++) { items.push(select[i]); }117 for (i=0; i<textarea.length; i++) { items.push(textarea[i]); }118 119 return items;120 }121 122 function configControls(e) {123 var items = new Array();124 for (var i=0; i<e.childNodes.length; i++) {125 if (e.childNodes[i].nodeType == 1 && e.childNodes[i].nodeName.toLowerCase() == 'div') {126 items.push(e.childNodes[i]);127 }128 }129 130 var title, img_ctrl, img, space;131 for (i in items) {132 // Append config control133 title = $('p.widget-name',items[i]).get(0);134 order = $(title).find('input[name*=order]');135 link = $('<a href="#" alt="expand" class="aexpand"/>').append($(title).text());136 $(title).empty().append(order).append(link);137 img_ctrl = title.firstChild;138 139 // There already an image140 if (img_ctrl.nodeName.toLowerCase() == 'img') {141 continue;142 }143 144 // Nothing to configure145 if (title.nextSibling.childNodes.length == 0) {146 continue;147 }148 149 img = document.createElement('img');150 img.src = dotclear.img_plus_src;151 img.alt = dotclear.img_plus_alt;152 img.control = title.nextSibling;153 img.onclick = function() { widgetConfig.call(this); };154 link.click(function(e) {155 e.preventDefault();156 widgetConfig.call($(this).prevAll('img').get(0));157 });158 space = document.createTextNode(' ');159 title.insertBefore(img,img_ctrl);160 title.insertBefore(space,img_ctrl);161 }162 }163 164 function widgetConfig() {165 if (this.control.style.display == 'block') {166 this.control.style.display = 'none';167 this.src = dotclear.img_plus_src;168 this.alt = dotclear.img_plus_alt;169 } else {170 this.control.style.display = 'block';171 this.src = dotclear.img_minus_src;172 this.alt = dotclear.img_minus_alt;173 }174 }175 176 function setHandle(item) {177 //var handle = item.getElementsByTagName('h4').item(0);178 var handle = $('p.widget-name',item).get(0);179 $(handle).addClass('handler');180 item.toolManDragGroup.setHandle(handle);181 }182 });183 184 //185 // For Safari, we need to make a hard copy of the form and submit copy.186 // Yeah, a simple clone of the form is not enough187 // I hate this browser!188 //189 if (document.childNodes && !document.all && !navigator.taintEnabled)190 {191 $(function() {192 $('#sidebarsWidgets').submit(function() {193 // Create a new form and copy each element inside194 var f = document.createElement('form');195 f.action = this.action;196 f.method = this.method;197 $(f).hide();198 var fset = document.createElement('fieldset');199 f.appendChild(fset);200 201 document.body.appendChild(f);202 203 $(this).find('input').each(function() {204 var i = document.createElement('input');205 i.type = this.type;206 i.name = this.name;207 i.value = this.value;208 if (this.type == 'checkbox') {209 i.checked = this.checked;210 }211 fset.appendChild(i);212 });213 214 $(this).find('textarea').each(function() {215 var i = document.createElement('textarea');216 i.name = this.name;217 i.value = this.value;218 fset.appendChild(i);219 });220 221 $(this).find('select').each(function() {222 var i = document.createElement('input');223 i.name = this.name;224 i.value = this.value;225 fset.appendChild(i);226 });227 228 $(fset).append('<input type="hidden" name="wup" value="1"/>');229 f.submit();230 231 return false;232 });233 });234 }
Note: See TracChangeset
for help on using the changeset viewer.