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

{% block title %}{{ title }} test | {% trans 'Public Project Site Admin' %}{% endblock %}


{% block extrastyle %}
  <link rel="stylesheet" href="/static/css/lib/font-awesome-3.1.1.css" type="text/css" />
<style type="text/css">
.mce-tinymce {
   margin-left:106px !important;
}
.icon-home {
	color:#444 !important;
}
.icon-cogs, .icon-cog {
	color:#0d9434 !important;
}
.icon-bullseye {
	color:#875513 !important;
}
.icon-question-sign {
	color: #941bbf !important;
}
.icon-group {
	color:#3e3ec7 !important;
}
.icon-user {
	color:#3e3ec7 !important;
}
.icon-time {
	color:#c91a1a !important;
}
.icon-inbox {
	color:#b88f00 !important;
}
.admin_model_help_box {
   float:right;
   width:270px;
   border:1px solid #ccc;
   font-size:12px;
   padding:10px;
   background-color:#fff9c8; 
}
</style>
{% endblock %}

{% block extrahead %}
<script src="/static/js/lib/jquery-1.8.1.min.js" type="text/javascript"></script>
<script src="/static/js/lib/tinymce-4.0.0/tinymce.min.js"></script>
<script>
  tinymce.init({
    selector:'textarea.htmleditor',
    body_id: 'htmleditor_body',
    content_css: '/static/css/tinymce_editor-0.1.0.css',
    width: 570,
    height: 350,
    plugins: "link image code",
    menubar: false,
    valid_elements: "p[style],br,strong/b,em,blockquote,ul,ol,li,a[href|target|style],img[src|alt|width|height|style],h3[style],h4[style]",
    //valid_elements : "a[href|target=_blank,style],strong/b,div[align,style],br",
    toolbar: "undo redo | bold italic | alignleft aligncenter alignright alignjustify blockquote | bullist numlist | link image | code",
    image_list: [
    {% for image in uploaded_images_list %}
      {title: '{{ image.title|escapejs }}', value: '{{ image.image.url }}'},
    {% endfor %}
    ],
  });
  
  $('document').ready(function() {
    
      //Changes on dashboard
      if($('body.dashboard').length > 0) {
        var p_a = $('#content-main a[href*="/public_project/participant/"]:first');
        var p_tr = p_a.parent().parent();
        var pp_table = p_tr.parent().parent();
        var pp_module = pp_table.parent();
        var content_div = pp_module.parent();
        
        pp_module.detach();
        pp_module.prependTo(content_div);
        pp_module.css('margin-bottom', '20px');
        
        var pt_a = $('#content-main a[href*="/public_project/participanttype/"]:first');
        var pt_tr = pt_a.parent().parent();
        var i_a = $('#content-main a[href*="/public_project/image/"]:first');
        var i_tr = i_a.parent().parent();
        var d_a = $('#content-main a[href*="/public_project/document/"]:first');
        var d_tr = d_a.parent().parent();
        var e_a = $('#content-main a[href*="/public_project/event/"]:first');
        var e_tr = e_a.parent().parent();
        var q_a = $('#content-main a[href*="/public_project/question/"]:first');
        var q_tr = q_a.parent().parent();
        var c_a = $('#content-main a[href*="/public_project/comment/"]:first');
        var c_tr = c_a.parent().parent();
        var g_a = $('#content-main a[href*="/public_project/projectgoalgroup/"]:first');
        var g_tr = g_a.parent().parent();
        var a_a = $('#content-main a[href*="/public_project/activitylog/"]:first');
        var a_tr = a_a.parent().parent();
        var r_a = $('#content-main a[href*="/public_project/researchrequest/"]:first');
        var r_tr = r_a.parent().parent();
        var t_a = $('#content-main a[href*="/public_project/projectpart/"]:first');
        var t_tr = t_a.parent().parent();
        var scat_a = $('#content-main a[href*="/public_project/sitecategory/"]:first');
        var scat_tr = scat_a.parent().parent();
        var sconf_a = $('#content-main a[href*="/public_project/siteconfig/"]:first');
        var sconf_tr = sconf_a.parent().parent();
        
        p_tr.detach();
        pt_tr.detach();
        i_tr.detach();
        d_tr.detach();
        e_tr.detach();
        q_tr.detach();
        c_tr.detach();
        g_tr.detach();
        a_tr.detach();
        r_tr.detach();
        t_tr.detach();
        scat_tr.detach();
        sconf_tr.detach();
        
        sconf_tr.appendTo(pp_table);
        scat_tr.appendTo(pp_table);
        pt_tr.appendTo(pp_table);
        a_tr.appendTo(pp_table);
        i_tr.appendTo(pp_table);
        t_tr.appendTo(pp_table);
        g_tr.appendTo(pp_table);
        q_tr.appendTo(pp_table);
        p_tr.appendTo(pp_table);
        e_tr.appendTo(pp_table);
        d_tr.appendTo(pp_table);
        c_tr.appendTo(pp_table);
        r_tr.appendTo(pp_table);
        
        pp_table.parent().css('border', '1px solid #bbb');
        pp_table.find('caption').css('font-size', '16px');
        
        pp_table.find('th').css('font-size', '14px');
        pp_table.find('tr').css('line-height', '18px');
        pp_table.find('th').css('line-height', '18px');
        pp_table.find('td').css('line-height', '18px');
        
        var html = '<div class="module" style="padding:5px;font-size:11px;background-color:#f7f7f7;color:#111;">';
        html += '<div style="padding:5px;">';
        html += '{% trans "Administration for the creation and maintenance of a Public Project Website" %}';
        html += '</div>';
        html += '<div style="padding:5px;">';
        html += '<a href="/" target="_blank">{% trans "Open main page" %}</a>';
        html += '</div>';
        html += '</div>'
        $(html).prependTo('#content-related');
        
        scat_tr.find('td, th').css('border-bottom', '1px solid #e0e0e0');
        i_tr.find('td, th').css('border-bottom', '1px solid #e0e0e0');
        t_tr.css('background-color', '#f7f7f7');
        g_tr.css('background-color', '#f7f7f7');
        q_tr.css('background-color', '#f7f7f7');
        p_tr.css('background-color', '#f7f7f7');
        e_tr.css('background-color', '#f7f7f7');
        d_tr.css('background-color', '#f7f7f7');
        d_tr.find('td, th').css('border-bottom', '1px solid #e0e0e0');
        
        sconf_a.before('<i class="icon-wrench"></i>&nbsp; ');
        scat_a.before('<i class="icon-sitemap"></i>&nbsp; ');
        pt_a.before('<i class="icon-group" style="color:#000 !important;"></i>&nbsp; ');
        a_a.before('<i class="icon-dashboard"></i>&nbsp; ');
        i_a.before('<i class="icon-picture"></i>&nbsp; ');
        t_a.before('<i class="icon-cogs"></i>&nbsp; ');
        g_a.before('<i class="icon-bullseye"></i>&nbsp; ');
        q_a.before('<i class="icon-question-sign"></i>&nbsp; ');
        p_a.before('<i class="icon-group"></i>&nbsp; ');
        e_a.before('<i class="icon-time"></i>&nbsp; ');
        d_a.before('<i class="icon-inbox"></i>&nbsp; ')
        c_a.before('<i class="icon-comments"></i>&nbsp; ');
        r_a.before('<i class="icon-eye-open"></i>&nbsp; ');
        
        sconf_a.attr('title', '{% trans "General settings (e.g. page title) and common introductory texts (e.g. about text)" %}');
        scat_a.attr('title', '{% trans "Introductory texts and documents and web sources for the site categories (e.g. Events category), one entry per category" %}');
        pt_a.attr('title', '{% trans "Type or category for sorting of participants" %}');
        a_a.attr('title', '{% trans "Log of activities throughout the system, shown on main page, entries can be deleted safely" %}');
        i_a.attr('title', '{% trans "Images for introductory texts, images must be uploaded here first before they can be embedded in a text" %}');
        t_a.attr('title', '{% trans "Topics to structure the project, can be divided into main and sub topics" %}');
        g_a.attr('title', '{% trans "Target settings during project development" %}');
        q_a.attr('title', '{% trans "Questions around the project" %}');
        p_a.attr('title', '{% trans "Single persons, groups or institutions related to the project" %}');
        e_a.attr('title', '{% trans "Events being related to the project" %}');
        d_a.attr('title', '{% trans "Documents from within or about the project" %}');
        c_a.attr('title', '{% trans "Comments from users being entered on the front-end website" %}');
        r_a.attr('title', '{% trans "Research requests for crowdsourcing certain tasks regarding project questions, can be entered on the front-end website on a questions page when being logged in" %}');
      }  
      
      if($('#projectpart_form').length > 0) {
          var html = '<div class="admin_model_help_box">';
          html += '{% trans "ADMIN_PROJECT_PART_FORM_HELP" %}';
          html += '</div>';
          $('.field-name:first > div').prepend(html);
      }
      
      if($('#participant_form').length > 0) {
          var html = '<div class="admin_model_help_box">';
          html += '{% trans "ADMIN_PARTICIPANT_FORM_HELP" %}';
          html += '</div>';
          $('.field-name:first > div').prepend(html);
      }
      if($('#researchrequest_form').length > 0) {
          var html = '<div class="admin_model_help_box">';
          html += '{% trans "ADMIN_RESEARCH_REQUEST_FORM_HELP" %}';
          html += '</div>';
          $('.field-nr:first > div').prepend(html);
      }
  });
</script>

{% endblock %}

{% block branding %}
<h1 id="site-name">
    {% trans 'Public Project Administration' %}
    
</h1>
{% endblock %}

{% block nav-global %}{% endblock %}
