[ 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 if ( customAttributes != -1 ) 15 { 16 var attributeArray = customAttributes.split("attribute_separation"); 17 var attributes = new Array(); 18 for ( var i=0;i<attributeArray.length;i++ ) 19 { 20 var attributePair = attributeArray[i].split("|"); 21 attributes[attributePair[0]] = attributePair[1]; 22 23 // attributePair[0] is attribute name 24 // attributePair[1] is value 25 found = false; 26 for( var key in this.customAttrDefaults[tagName] ) 27 { 28 if ( key == attributePair[0] ) 29 { 30 this.customAttrDefaults[tagName][key] = attributePair[1]; 31 found = true; 32 } 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 if ( attrsPresent ) 60 lastPropertyRow.style.display="none"; 61 else 62 lastPropertyRow.style.display="block"; 63 } 64 65 function addNew() 66 { 67 var tbody = document.getElementById("attributes").getElementsByTagName("tbody")[0]; 68 var row1 = document.createElement("tr"); 69 var td1 = document.createElement("td"); 70 var checkbox1 = document.createElement("<input type='checkbox' id='Selected_attribute' />"); 71 {/literal}{if ge($ezpublish_version, 3.9)}checkbox1.style.display="none";{/if}{literal} 72 td1.appendChild(checkbox1); 73 var td2 = document.createElement("td"); 74 var input1 = document.createElement("<input id='CustomAttributeName' type='text' size='10' />"); 75 td2.appendChild(input1); 76 var td3 = document.createElement("td"); 77 var input2 = document.createElement("<input id='CustomAttributeValue' type='text' size='10' />"); 78 td3.appendChild(input2); 79 row1.appendChild(td1); 80 row1.appendChild(td2); 81 row1.appendChild(td3); 82 tbody.insertBefore(row1,lastPropertyRow); 83 lastPropertyRow.style.display="none"; 84 } 85 86 function addAttribute( attrName, attrValue, isDisabled ) 87 { 88 var tbody = document.getElementById("attributes").getElementsByTagName("tbody")[0]; 89 var row1 = document.createElement("tr"); 90 var td1 = document.createElement("td"); 91 var checkbox1 = document.createElement("<input type='checkbox' id='Selected_attribute' />"); 92 if ( isDisabled == true ) 93 checkbox1.disabled = true; 94 {/literal}{if ge($ezpublish_version, 3.9)}checkbox1.style.display="none";{/if}{literal} 95 td1.appendChild(checkbox1); 96 var td2 = document.createElement("td"); 97 var input1; 98 input1 = document.createElement("<input id='CustomAttributeName' type='text' size='10' />"); 99 input1.value = attrName; 100 if ( isDisabled == true ) 101 input1.disabled = true; 102 td2.appendChild(input1); 103 var td3 = document.createElement("td"); 104 var input2 = document.createElement("<input id='CustomAttributeValue' type='text' size='10' />"); 105 input2.value = attrValue; 106 td3.appendChild(input2); 107 row1.appendChild(td1); 108 row1.appendChild(td2); 109 row1.appendChild(td3); 110 tbody.insertBefore(row1,lastPropertyRow); 111 } 112 113 function removeAttributes() 114 { 115 var tbody = document.getElementById("attributes").getElementsByTagName("tbody")[0]; 116 var tr = tbody.firstChild.nextSibling; 117 while ( tr.id != "lastPropertyRow" ) 118 { 119 next = tr.nextSibling; 120 121 // remove only custom attributes 122 if ( tr.firstChild.nextSibling.firstChild.nodeName == 'INPUT' ) 123 tbody.removeChild(tr); 124 125 if ( !next ) 126 break; 127 tr = next; 128 } 129 } 130 131 function removeSelected() 132 { 133 var tbody = document.getElementById("attributes").getElementsByTagName("tbody")[0]; 134 var tr = tbody.firstChild.nextSibling; 135 while ( tr.id != "lastPropertyRow" ) 136 { 137 next = tr.nextSibling; 138 139 // remove only custom attributes 140 if ( tr.firstChild.nextSibling.firstChild.nodeName == 'INPUT' && 141 tr.firstChild.firstChild.checked ) 142 tbody.removeChild(tr); 143 144 if ( !next ) 145 break; 146 tr = next; 147 } 148 } 149 150 function packCustomAttributes( CustomAttributeName, CustomAttributeValue ) 151 { 152 var customAttributes = new Array(); 153 if ( CustomAttributeName.length != null ) 154 { 155 var j = 0; 156 for (var i=0;i<CustomAttributeName.length;i++) 157 { 158 if ( CustomAttributeValue.length != null ) 159 { 160 if ( CustomAttributeValue[i].value != "" ) 161 customAttributes[j++]=CustomAttributeName[i].value + "|" + CustomAttributeValue[i].value; 162 } 163 else 164 { 165 if ( CustomAttributeValue.value != "" ) 166 customAttributes[j++]=CustomAttributeName[i].value + "|" + CustomAttributeValue.value 167 } 168 } 169 } 170 else 171 { 172 if ( CustomAttributeValue.value != "" ) 173 customAttributes[0]=CustomAttributeName.value + "|" + CustomAttributeValue.value; 174 } 175 176 return customAttributes; 177 } 178 179 </script> 180 181 {/literal} 182
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 |