| 14 | | // make sure the asset isn't there already |
| 15 | | var Asset = window.parent.document.getElementById("list-asset-<mt:AssetID>"); |
| 16 | | if (Asset) { |
| 17 | | // do nothing |
| | 25 | // make sure asset list is present in an entry edit page |
| | 26 | var AssetList = window.parent.document.getElementById("asset-list"); |
| | 27 | |
| | 28 | if (AssetList) { |
| | 29 | // make sure the asset isn't there already and that we're in the edit entry page |
| | 30 | var Asset = window.parent.document.getElementById("list-asset-<mt:AssetID>"); |
| | 31 | |
| | 32 | if (Asset) { |
| | 33 | // do nothing |
| | 34 | } |
| | 35 | else { |
| | 36 | // add the asset's id to the include_asset_ids hidden input |
| | 37 | var asset_ids = window.parent.document.getElementById("include_asset_ids").value; |
| | 38 | window.parent.document.getElementById("include_asset_ids").value = asset_ids + ",<mt:AssetID>"; |
| | 39 | |
| | 40 | // create the link to the asset page with asset name as label |
| | 41 | var myAssetLink = window.document.createElement('a'); |
| | 42 | myAssetLink.setAttribute('href', '<mt:CGIPath><mt:AdminScript>?__mode=view&_type=asset&blog_id=<mt:var name="blog_id">&id=<mt:AssetID>'); |
| | 43 | myAssetLink.appendChild(document.createTextNode('<mt:AssetFileName encode_js="1">')); |
| | 44 | |
| | 45 | // create the remove link icon |
| | 46 | var myRemoveIcon = window.document.createElement('img'); |
| | 47 | myRemoveIcon.setAttribute('src', '<mt:StaticWebPath>images/status_icons/close.gif'); |
| | 48 | myRemoveIcon.setAttribute('alt', 'Remove asset'); |
| | 49 | |
| | 50 | // create the remove link for this asset |
| | 51 | var myRemoveLink = window.document.createElement('a'); |
| | 52 | myRemoveLink.setAttribute('href', 'javascript:removeAssetFromList(<mt:AssetID>)'); |
| | 53 | myRemoveLink.setAttribute('class', 'remove-asset'); |
| | 54 | myRemoveLink.appendChild(myRemoveIcon); |
| | 55 | |
| | 56 | // create the asset list item |
| | 57 | var myElement = window.document.createElement('li'); |
| | 58 | myElement.setAttribute('id', 'list-asset-<mt:AssetID>'); |
| | 59 | <mt:If tag="AssetType" eq="image"> |
| | 60 | myElement.setAttribute('onmouseover', 'show(\'list-image-<mt:AssetID>\', window.parent.document)'); |
| | 61 | myElement.setAttribute('onmouseout','hide(\'list-image-<mt:AssetID>\', window.parent.document)'); |
| | 62 | </mt:If> |
| | 63 | myElement.appendChild(myAssetLink); |
| | 64 | myElement.appendChild(myRemoveLink); |
| | 65 | |
| | 66 | // I HATE IE! |
| | 67 | if (document.attachEvent) { |
| | 68 | var oldLis = window.parent.document.getElementById("asset-list").innerHTML; |
| | 69 | var newLi = '<li id="list-asset-<mt:AssetID>" onmouseover="show(\'list-image-<mt:AssetID>\', window.parent.document)" onmouseout="hide(\'list-image-<mt:AssetID>\', window.parent.document)">' |
| | 70 | + myElement.innerHTML + '</li>'; |
| | 71 | window.parent.document.getElementById("asset-list").innerHTML = oldLis + newLi; |
| | 72 | } |
| | 73 | else { |
| | 74 | window.parent.document.getElementById("asset-list").appendChild(myElement); |
| | 75 | } |
| | 76 | |
| | 77 | // create the image thumbnail if it exists |
| | 78 | <mt:If tag="AssetType" eq="image"> |
| | 79 | var myImageElement = window.document.createElement('img'); |
| | 80 | myImageElement.setAttribute('id', 'list-image-<mt:AssetID>'); |
| | 81 | myImageElement.setAttribute('src', '<mt:AssetThumbnailURL width="100" encode_js="1">'); |
| | 82 | myImageElement.setAttribute('class', 'list-image hidden'); |
| | 83 | myElement.appendChild(myImageElement); |
| | 84 | </mt:If> |
| | 85 | } |
| 19 | | else { |
| 20 | | // add the asset's id to the include_asset_ids hidden input |
| 21 | | var asset_ids = window.parent.document.getElementById("include_asset_ids").value; |
| 22 | | window.parent.document.getElementById("include_asset_ids").value = asset_ids + ",<mt:AssetID>"; |
| 23 | | |
| 24 | | // create the link to the asset page with asset name as label |
| 25 | | var myAssetLink = window.document.createElement('a'); |
| 26 | | myAssetLink.setAttribute('href', '<mt:CGIPath><mt:AdminScript>?__mode=view&_type=asset&blog_id=<mt:var name="blog_id">&id=<mt:AssetID>'); |
| 27 | | myAssetLink.appendChild(document.createTextNode('<mt:AssetFileName encode_js="1">')); |
| 28 | | |
| 29 | | // create the remove link icon |
| 30 | | var myRemoveIcon = window.document.createElement('img'); |
| 31 | | myRemoveIcon.setAttribute('src', '<mt:StaticWebPath>images/status_icons/close.gif'); |
| 32 | | myRemoveIcon.setAttribute('alt', 'Remove asset'); |
| 33 | | |
| 34 | | // create the remove link for this asset |
| 35 | | var myRemoveLink = window.document.createElement('a'); |
| 36 | | myRemoveLink.setAttribute('href', 'javascript:removeAssetFromList(<mt:AssetID>)'); |
| 37 | | myRemoveLink.setAttribute('class', 'remove-asset'); |
| 38 | | myRemoveLink.appendChild(myRemoveIcon); |
| 39 | | |
| 40 | | // create the asset list item |
| 41 | | var myElement = window.document.createElement('li'); |
| 42 | | myElement.setAttribute('id', 'list-asset-<mt:AssetID>'); |
| 43 | | <mt:If tag="AssetType" eq="image"> |
| 44 | | myElement.setAttribute('onmouseover', 'show(\'list-image-<mt:AssetID>\', window.parent.document)'); |
| 45 | | myElement.setAttribute('onmouseout','hide(\'list-image-<mt:AssetID>\', window.parent.document)'); |
| 46 | | </mt:If> |
| 47 | | myElement.appendChild(myAssetLink); |
| 48 | | myElement.appendChild(myRemoveLink); |
| 49 | | |
| 50 | | // I HATE IE! |
| 51 | | if (document.attachEvent) { |
| 52 | | var oldLis = window.parent.document.getElementById("asset-list").innerHTML; |
| 53 | | var newLi = '<li id="list-asset-<mt:AssetID>" onmouseover="show(\'list-image-<mt:AssetID>\', window.parent.document)" onmouseout="hide(\'list-image-<mt:AssetID>\', window.parent.document)">' |
| 54 | | + myElement.innerHTML + '</li>'; |
| 55 | | window.parent.document.getElementById("asset-list").innerHTML = oldLis + newLi; |
| 56 | | } |
| 57 | | else { |
| 58 | | window.parent.document.getElementById("asset-list").appendChild(myElement); |
| 59 | | } |
| 60 | | |
| 61 | | // create the image thumbnail if it exists |
| 62 | | <mt:If tag="AssetType" eq="image"> |
| 63 | | var myImageElement = window.document.createElement('img'); |
| 64 | | myImageElement.setAttribute('id', 'list-image-<mt:AssetID>'); |
| 65 | | myImageElement.setAttribute('src', '<mt:AssetThumbnailURL width="100" encode_js="1">'); |
| 66 | | myImageElement.setAttribute('class', 'list-image hidden'); |
| 67 | | myElement.appendChild(myImageElement); |
| 68 | | </mt:If> |
| 69 | | } |
| 70 | | <mt:if name="upload_html"> |
| 71 | | <mt:var name="insert_script"> |
| 72 | | </mt:if> |
| 73 | | |
| 74 | | <mt:unless name="extension_message"> |
| 75 | | closeDialog(); |
| 76 | | </mt:unless> |