[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 {literal} 2 <script type="text/javascript"> 3 4 var customAttrDefaults = new Array(); 5 6 function displayAttributes( tagName, customAttributes ) 7 { 8 var defaultAttrCount = 0; 9 for( var key in this.customAttrDefaults[tagName] ) 10 { 11 defaultAttrCount++; 12 } 13 14 // display other attributes 15 if ( customAttributes != -1 ) 16 { 17 var attributeArray = customAttributes.split("attribute_separation"); 18 var attributes = new Array(); 19 for ( var i=0;i<attributeArray.length;i++ ) 20 { 21 var attributePair = attributeArray[i].split("|"); 22 attributes[attributePair[0]] = attributePair[1]; 23 24 // attributePair[0] is attribute name 25 // attributePair[1] is value 26 found = false; 27 for( var key in this.customAttrDefaults[tagName] ) 28 { 29 if ( key == attributePair[0] ) 30 { 31 this.customAttrDefaults[tagName][key] = attributePair[1]; 32 found = true; 33 } 34 } 35 if ( !found ) 36 { 37 this.customAttrDefaults[tagName][attributePair[0]] = attributePair[1]; 38 } 39 } 40 } 41 42 // Default attributes should have disabled checkboxes. 43 var attrCount = 0; 44 var isDisabled = true; 45 var attrsPresent = false; 46 for( var key in this.customAttrDefaults[tagName] ) 47 { 48 if ( attrCount >= defaultAttrCount ) 49 isDisabled = false; 50 else 51 isDisabled = true; 52 53 attrCount++; 54 55 addAttribute( key, this.customAttrDefaults[tagName][key], isDisabled ); 56 attrsPresent = true; 57 } 58 59 var lastPropertyRow = document.getElementById("lastPropertyRow"); 60 if ( attrsPresent ) 61 lastPropertyRow.style.display="none"; 62 else 63 lastPropertyRow.style.display="table-row"; 64 } 65 66 function addNew() 67 { 68 var tbody = document.getElementById("attributes").getElementsByTagName("tbody")[0]; 69 var row1 = document.createElement("tr"); 70 row1.class = 'customAttrRow'; 71 var td1 = document.createElement("td"); 72 var checkbox1 = document.createElement("input"); 73 checkbox1.setAttribute( 'name', 'Selected_attribute' ); 74 checkbox1.setAttribute( 'type', 'checkbox' ); 75 {/literal}{if ge($ezpublish_version, 3.9)}checkbox1.style.display="none";{/if}{literal} 76 td1.appendChild(checkbox1); 77 var td2 = document.createElement("td"); 78 var input1 = document.createElement("input"); 79 input1.setAttribute( 'name', 'CustomAttributeName' ); 80 input1.setAttribute( 'type', 'text' ); 81 input1.setAttribute( 'size', '10' ); 82 td2.appendChild(input1); 83 var td3 = document.createElement("td"); 84 var input2 = document.createElement("input"); 85 input2.setAttribute( 'name', 'CustomAttributeValue' ); 86 input2.setAttribute( 'type', 'text' ); 87 input2.setAttribute( 'size', '10' ); 88 td3.appendChild(input2); 89 row1.appendChild(td1); 90 row1.appendChild(td2); 91 row1.appendChild(td3); 92 var lastPropertyRow = document.getElementById("lastPropertyRow"); 93 tbody.insertBefore(row1,lastPropertyRow); 94 lastPropertyRow.style.display="none"; 95 } 96 97 function addAttribute( attrName, attrValue, isDisabled ) 98 { 99 var tbody = document.getElementById("attributes").getElementsByTagName("tbody")[0]; 100 var row1 = document.createElement("tr"); 101 row1.class = 'customAttrRow'; 102 var td1 = document.createElement("td"); 103 var checkbox1 = document.createElement("input"); 104 checkbox1.setAttribute( 'name', 'Selected_attribute' ); 105 checkbox1.setAttribute( 'type', 'checkbox' ); 106 if ( isDisabled == true ) 107 checkbox1.disabled = true; 108 {/literal}{if ge($ezpublish_version, 3.9)}checkbox1.style.display="none";{/if}{literal} 109 td1.appendChild(checkbox1); 110 var td2 = document.createElement("td"); 111 var input1 = document.createElement("input"); 112 input1.setAttribute( 'name', 'CustomAttributeName' ); 113 input1.setAttribute( 'type', 'text' ); 114 input1.setAttribute( 'size', '10' ); 115 input1.value = attrName; 116 if ( isDisabled == true ) 117 input1.setAttribute( 'readonly', true ); 118 td2.appendChild(input1); 119 var td3 = document.createElement("td"); 120 var input2 = document.createElement("input"); 121 input2.setAttribute( 'name', 'CustomAttributeValue' ); 122 input2.setAttribute( 'type', 'text' ); 123 input2.setAttribute( 'size', '10' ); 124 input2.value = attrValue; 125 td3.appendChild(input2); 126 row1.appendChild(td1); 127 row1.appendChild(td2); 128 row1.appendChild(td3); 129 var lastPropertyRow = document.getElementById("lastPropertyRow"); 130 tbody.insertBefore(row1,lastPropertyRow); 131 } 132 133 function removeAttributes() 134 { 135 var tbody = document.getElementById("attributes").getElementsByTagName("tbody")[0]; 136 var tr = tbody.firstChild.nextSibling; 137 while ( tr.id != "lastPropertyRow" ) 138 { 139 next = tr.nextSibling; 140 141 // remove only custom attributes 142 if ( tr.class == 'customAttrRow' ) 143 tbody.removeChild(tr); 144 145 if ( !next ) 146 break; 147 tr = next; 148 } 149 } 150 151 function removeSelected() 152 { 153 var tbody = document.getElementById("attributes").getElementsByTagName("tbody")[0]; 154 if ( tbody.firstChild.nextSibling == 'TR' ) 155 tr = tbody.firstChild.nextSibling; 156 else 157 tr = tbody.firstChild.nextSibling.nextSibling; 158 159 while ( tr.id != "lastPropertyRow" ) 160 { 161 if ( tr.nextSibling.nodeName == 'TR' ) 162 next = tr.nextSibling; 163 else 164 next = tr.nextSibling.nextSibling; 165 166 if ( tr.firstChild.nodeName == 'TD' ) 167 { 168 // remove only custom attributes 169 if ( tr.firstChild.nextSibling.firstChild.nodeName == 'INPUT' ) 170 { 171 if ( tr.firstChild.firstChild.checked ) 172 tbody.removeChild(tr); 173 } 174 } 175 176 if ( !next ) 177 break; 178 tr = next; 179 } 180 } 181 182 function packCustomAttributes( CustomAttributeName, CustomAttributeValue ) 183 { 184 var customAttributes = new Array(); 185 if ( CustomAttributeName.length != null ) 186 { 187 var j = 0; 188 for (var i=0;i<CustomAttributeName.length;i++) 189 { 190 if ( CustomAttributeValue.length != null ) 191 { 192 if ( CustomAttributeValue[i].value != "" ) 193 customAttributes[j++]=CustomAttributeName[i].value + "|" + CustomAttributeValue[i].value; 194 } 195 else 196 { 197 if ( CustomAttributeValue.value != "" ) 198 customAttributes[j++]=CustomAttributeName[i].value + "|" + CustomAttributeValue.value 199 } 200 } 201 } 202 else 203 { 204 if ( CustomAttributeValue.value != "" ) 205 customAttributes[0]=CustomAttributeName.value + "|" + CustomAttributeValue.value; 206 } 207 208 return customAttributes; 209 } 210 211 </script> 212 213 {/literal} 214
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |