{% extends "base.html" %}
{% load i18n %}

{% block js_declaration %}
{{block.super}}
<script type="text/javascript">
$(document).ready(function(){

	$('.ldt_link').nyroModal({
           	type: 'iframe',
           	forceType: 'iframe',
       		height:662, 
       		width:1022,
       		bgColor: 'rgb(239, 239, 239)',
       		padding: 5,
       		titleFromIframe: false
          	});
        	
     $('.ldt_link_create').nyroModal({
            type: 'iframe',
            forceType: 'iframe',
            height:662, 
            width:1022,
            bgColor: 'rgb(239, 239, 239)',
            padding: 5,
            titleFromIframe: false,
            beforeHideContent: function(elts, settings, callback){
	             try {
		              var res = $('#ldtInitSwf',$('#nyroModalIframe').contents());
		              if(res.length > 0)
		              {
		              	   res.get(0).forceSave();
		              }
	             }
	             catch(err)
	             {
	              // do nothing
	             }                   
	             callback();
            }
        });

 	 $('.ldt_link_embed').click(function(e) {
 		e.preventDefault();
 		link = $(e.target);
 		json_url = link.attr("href");
 		player_id = link.attr("id");
 		/*$.nyroModalSettings({
 		 	ajax: { data: ({ json_url:json_url, player_id:player_id }) }
     	});*/
 	    $.nyroModalManual({
            type: 'iframe',
            forceType: 'iframe',
            titleFromIframe: false,
 	    	height:662, 
 	   		width:650,
 	   		bgColor: 'rgb(239, 239, 239)',
 	   		padding: 5,
	 	    url: '{% url eulalie.views.popup_embed %}?json_url='+escape(json_url)+'&player_id='+escape(player_id),
 	    });
 	    return false;
      });    
});
</script>

{% endblock %}

{% block css_import %}
{{block.super}}
    <link rel="stylesheet" href="{{BASE_URL}}static/css/workspace.css" type="text/css"/>
{% endblock %}

{% block content %}

<div class="span-24 last" id="contentsdiv">
<h1>{% trans "content list" %}</h1>
<table>
{% for content in contents %}
    <tr>
        <td>{{ content.title }}</td>
        <td><a href="{% url ldt.ldt_utils.views.index content.iri_id %}" class="ldt_link">{% trans "open ldt" %}</a></td>
        <td><a href="{% url ldt.ldt_utils.views.create_project content.iri_id %}" class="ldt_link_create">{% trans "create project" %}</a></td>
        {% url ldt.ldt_utils.views.project_json_externalid content.external_id as json_url_externalid %}
        <td><a href="{{json_url_externalid}}" class="ldt_link_embed" id="player_project_{{content.iri_id}}">{% trans "link json by externalid" %}</a>
        </td>
    </tr>
{% endfor %}
</table>
</div>

<div class="span-24 last" id="projectsdiv">
<h1>{% trans "project list" %}</h1>
<table>
{% for project in projects %}
    <tr>
        <td>{{ project.title }}</td>
        <td><a href="{% url ldt.ldt_utils.views.indexProject project.ldt_id %}" class="ldt_link">{% trans "open ldt" %}</a></td>
        <td><a href="{% url ldt.ldt_utils.views.copy_project project.ldt_id %}" class="ldt_link_create">{% trans "copy project" %}</a></td>
        {% url ldt.ldt_utils.views.project_json_id project.ldt_id as json_url_id %}
        <td><a href="{{json_url_id}}" class="ldt_link_embed" id="player_project_{{project.ldt_id}}">{% trans "link json by id" %}</a>
    </tr>
{% endfor %}
</table>
</div>

{% endblock %}
