Changeset 3977

Show
Ignore:
Timestamp:
06/30/09 22:36:33 (5 months ago)
Author:
plim
Message:

This is additional logic used when adding an asset to an entry using the insert file or insert image buttons of the editor. This adds the html to the text editor, adds the asset listing to the bottom of the left sidebar in the same way edit_entry.tmpl expects the asset listing to be displayed. BugId: 100892

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/slapshot/tmpl/cms/dialog/asset_insert.tmpl

    r2784 r3977  
    55<script type="text/javascript"> 
    66/* <![CDATA[ */ 
     7 
     8// remove the no assets text if it's there 
     9var Node = window.parent.document.getElementById("empty-asset-list"); 
     10if (Node) { 
     11    Node.parentNode.removeChild(Node); 
     12}  
     13 
     14// make sure the asset isn't there already 
     15var Asset = window.parent.document.getElementById("list-asset-<mt:AssetID>"); 
     16if (Asset) { 
     17    // do nothing 
     18} 
     19else { 
     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> ')); 
     28 
     29    // create the remove link icon 
     30    var myRemoveIcon = window.document.createElement('img'); 
     31    myRemoveIcon.setAttribute('src', '<mt:StaticWebPath>images/status_icons/view.gif'); 
     32 
     33    // create the remove link for this asset 
     34    var myRemoveLink = window.document.createElement('a'); 
     35    myRemoveLink.setAttribute('href', 'javascript:removeAssetFromList(<mt:AssetID>)'); 
     36    myRemoveLink.appendChild(myRemoveIcon); 
     37 
     38    // create the asset list item 
     39    var myElement = window.document.createElement('li'); 
     40    myElement.setAttribute('id', 'list-asset-<mt:AssetID>'); 
     41    <mt:If tag="AssetType" eq="image"> 
     42        myElement.setAttribute('onmouseover', 'javascript:displayImage("list-image-<mt:AssetID>")'); 
     43        myElement.setAttribute('onmouseout','javascript:hideImage("list-image-<mt:AssetID>")'); 
     44    </mt:If> 
     45    myElement.appendChild(myAssetLink); 
     46    myElement.appendChild(myRemoveLink); 
     47    window.parent.document.getElementById("asset-list").appendChild(myElement); 
     48 
     49    // create the image thumbnail if it exists 
     50    <mt:If tag="AssetType" eq="image"> 
     51        var myImageElement = window.document.createElement('img'); 
     52        myImageElement.setAttribute('id', 'list-image-<mt:AssetID>'); 
     53        myImageElement.setAttribute('src', '<mt:AssetThumbnailURL height="100">'); 
     54        myImageElement.setAttribute('style', 'display:none'); 
     55        window.parent.document.getElementById("asset-list").appendChild(myImageElement); 
     56    </mt:If> 
     57} 
     58 
    759<mt:var name="insert_script"> 
    860closeDialog();