123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 |
- {{javascript}}
- <script type="text/javascript">
- {% if is_allowed_to_edit %}
- var sec_token = '{{sec_token}}';
- {% endif %}
- $(function() {
- $('.collapsible .head').click(function(e) {
- $(this).toggleClass('collapsed');
- $(this).next().toggle();
- return true;
- });
- {% if is_allowed_to_edit %}
- $(".categories.sortable" ).sortable({
- axis: 'y',
- handle: '.handle',
- //placeholder: 'ui-state-highlight',
- update: function(event, ui) {
- var c_id = 0;
- var ids = [];
- var items;
- items = $(this).children('li');
- items.each(function(index, li){
- li = $(li);
- var id;
- id = li.attr('data-id');
- c_id = li.attr('data-c_id');
- ids.push(id);
- });
- LinkCategory.sort(c_id, ids, message.update);
- }
- });
- $(".categories.sortable" ).disableSelection();
- $(".links.sortable" ).sortable({
- axis: 'y',
- placeholder: 'ui-state-highlight',
- update: function(event, ui) {
- var c_id = 0;
- var ids = [];
- var items;
- items = $(this).children('li');
- items.each(function(index, li){
- li = $(li);
- var id;
- id = li.attr('data-id');
- c_id = li.attr('data-c_id');
- ids.push(id);
- });
- Link.sort(c_id, ids, message.update);
- }
- });
- $(".links.sortable" ).disableSelection();
- {% endif %}
- });
- function expand_all(){
- $('.collapsible .head').removeClass('collapsed').next().show();
- }
- function collapse_all(){
- $('.collapsible .head').addClass('collapsed').next().hide();
- }
- function delete_category(name){
- if(!confirm("{{'ConfirmYourChoice'|get_lang}}")){
- return false;
- }
- var item = $('#'+name);
- var id = item.attr('data-id');
- var c_id = item.attr('data-c_id');
- var f = function(data){
- if(data.success){
- item.remove();
- }
- message.update(data);
- };
- LinkCategory.del(c_id, id, f);
- }
- function delete_all(){
- if(!confirm("{{'ConfirmYourChoice'|get_lang}}")){
- return false;
- }
- var f = function(data){
- if(data.success){
- var item = $('.data');
- item.remove();
- }
- message.update(data);
- };
- Link.delete_by_course({{c_id}}, {{session_id}}, f);
- }
- function delete_link(name, btn){
- if(!confirm("{{'ConfirmYourChoice'|get_lang}}")){
- return false;
- }
- var item = $('#'+name);
- var id = item.attr('data-id');
- var c_id = item.attr('data-c_id');
- var f = function(data){
- if(data.success){
- item.remove();
- }else{
- $(btn).removeClass("loading");
- }
- message.update(data);
- };
- $(btn).addClass("loading");
- Link.del(c_id, id, f);
- }
- function switch_li_visibility(name, btn)
- {
- var li = $('#'+name);
- var id = li.attr('data-id');
- var c_id = li.attr('data-c_id');
- var is_visible = !li.hasClass('text-muted')
- var f = function(data){
- if(data.success){
- var btn = $('.btn.visibility', li);
- if(is_visible){
- btn.addClass('show');
- btn.removeClass('hide');
- li.addClass('text-muted');
- li.removeClass('visible');
- }else{
- btn.removeClass('show');
- btn.addClass('hide');
- li.removeClass('text-muted');
- li.addClass('visible');
- }
- }
- message.update(data);
- $(btn).removeClass("loading");
- };
- if(is_visible){
- Link.hide(c_id, id, f);
- }else{
- Link.show(c_id, id, f);
- }
- $(btn).addClass("loading");
- }
- function validate_link(name, btn){
- var li = $('#'+name);
- var id = li.attr('data-id');
- var c_id = li.attr('data-c_id');
- var f = function(data){
- if(data.success){
- li.addClass('valid');
- li.removeClass('invalid');
- }else{
- li.addClass('invalid');
- li.removeClass('valid');
- }
- message.update(data);
- $(btn).removeClass("loading");
- };
- $(btn).addClass("loading");
- Link.validate(c_id, id, f);
- }
- </script>
- <div id="messages">
- {% for message in messages %}
- {{ message }}
- {% endfor %}
- </div>
- <div class="btn-toolbar actions-bar" >
- {% if is_allowed_to_edit %}
- <div class="btn-group edit">
- <a href="{{root}}&action=add_category" class="btn new_folder" title="{{'AddCategory'|get_lang}}">
- <em class="size-32 icon-new-folder"></em>
- </a>
- <a href="{{root}}&action=add_link" class="btn new_link" title="{{'AddLink'|get_lang}}">
- <em class="size-32 icon-new-link"></em>
- </a>
- <a href="javascript:void(0)" onclick="delete_all();return false;" class="btn btn-default" title="{{'DeleteAll'|get_lang}}">
- <em class="size-32 icon-delete-all"></em>
- </a>
- <a href="{{root}}&action=import_csv" class="btn import_csv" title="{{'ImportCSV'|get_lang}}">
- <em class="size-32 icon-import-csv"></em>
- </a>
- <a href="{{root}}&action=export_csv" class="btn" title="{{'ExportAsCSV'|get_lang}}">
- <em class="size-32 icon-export-csv"></em>
- </a>
- </div>
- {% endif %}
- <div class="btn-group">
- <a href="javascript:void(0)" onclick="expand_all();return false;" class="btn btn-default" title="{{'ShowAll'|get_lang}}">
- <em class="size-32 icon-expand"></em>
- </a>
- <a href="javascript:void(0)" onclick="collapse_all();return false;" class="btn btn-default" title="{{'ShowNone'|get_lang}}">
- <em class="size-32 icon-collapse"></em>
- </a>
- </div>
- </div>
- <div class="data">
- <ul style="list-style: none; margin-left:0;" class="links sortable">
- {% for link in links %}
- {% set link_class %}
- {% if loop.first %}first{% endif %}
- {% if loop.last %}last{% endif %}
- {% if loop.index is odd %}odd{% else %}even{% endif %}
- {% if link.is_visible() %}visible{% else %}invisible{% endif %}
- {% endset %}
- <li id="link_{{link.id}}" class="link {{link_class}}" data-id="{{link.id}}" data-c_id="{{link.c_id}}" data-type="link" >
- <a class="icon" target="{{link.target}}" href="{{root}}&action=go&id={{link.id}}&c_id={{link.c_id}}">
- {{ 'link.png' |icon(22)}}
- </a>
- <a class="title" target="{{link.target}}" href="{{root}}&action=go&id={{link.id}}&c_id={{link.c_id}}">
- {%if link.title %}{{link.title}}{% else %}{{link.url}}{%endif%}
- </a>
- {% if link.session_id %}
- {{session_image}}
- {% endif %}
- <div class="status" style="display:inline-block;"> </div>
- {% if is_allowed_to_edit %}
- <div style="float:right;">
- <a href="javascript:void(0)" onclick="validate_link('link_{{link.id}}', this);return false;"
- title="{{'CheckURL'|get_lang}}"
- class="btn validate_link">
- </a>
- <a href="{{root}}&action=edit_link&id={{link.id}}&c_id={{link.c_id}}"
- title="{{'Edit'|get_lang}}"
- class="">
- <em class="size-22 icon-edit"></em>
- </a>
- <a href="javascript:void(0)" onclick="switch_li_visibility('link_{{link.id}}', this);return false;"
- class="btn visibility {%if link.visibility == 1%}hide{%else%}show{%endif%}">
- </a>
- <a href="javascript:void(0)" onclick="delete_link('link_{{link.id}}', this);return false;" title="{{'Delete'|get_lang}}" class="">
- <em class="size-22 icon-delete"></em>
- </a>
- </div>
- {% endif %}
- <div class="description">{{link.description}}</div>
- </li>
- {% endfor%}
- </ul>
- <ul id="link_categories" class="categories sortable" style="list-style: none; margin-left:0;">
- {% for category in categories %}
- <li id="category_{{category.id}}" class="link_category collapsible" data-id="{{category.id}}" data-c_id="{{category.c_id}}" data-type="category" >
- <div class="head handle collapsed">
- {% if is_allowed_to_edit %}
- <div style="float:right;">
- <a href="{{root}}&action=edit_category&id={{category.id}}&c_id={{category.c_id}}"
- onclick="event.stopPropagation();"
- title="{{'Edit'|get_lang}}"
- class="">
- <em class="size-22 icon-edit"></em>
- </a>
- <a href="javascript:void(0)"
- onclick="delete_category('category_{{category.id}}');event.stopPropagation();return false;"
- title="{{'Delete'|get_lang}}"
- class="">
- <em class="size-22 icon-delete"></em>
- </a>
- </div>
- {% endif %}
- <h3>
- <a href="{{root}}&action=view&id={{category.id}}&c_id={{category.c_id}}">{{category.category_title|escape}}</a>
- </h3>
- {{category.description}}
- </div>
- <div class="body" style="display:none;">
- <ul style="list-style: none; margin-left:0;" class="links sortable">
- {% for link in category.links %}
- {% set link_class %}
- {% if loop.first %}first{% endif %}
- {% if loop.last %}last{% endif %}
- {% if loop.index is odd %}odd{% else %}even{% endif %}
- {% if link.is_visible() %}visible{% else %}invisible{% endif %}
- {% endset %}
- <li id="link_{{link.id}}" class="link {{link_class}}" data-id="{{link.id}}" data-c_id="{{link.c_id}}" data-type="link" >
- <a class="icon" target="{{link.target}}" href="{{root}}&action=go&id={{link.id}}&c_id={{link.c_id}}">
- {{ 'link.png' |icon(22) }}
- </a>
- <a class ="title" target="{{link.target}}" href="{{root}}&action=go&id={{link.id}}&c_id={{link.c_id}}">
- {%if link.title %}{{link.title}}{% else %}{{link.url}}{%endif%}
- </a>
- {% if link.session_id %}
- {{session_image}}
- {% endif %}
- <div class="status" style="display:inline-block;"> </div>
- {% if is_allowed_to_edit %}
- <div style="float:right;">
- <a href="javascript:void(0)" onclick="validate_link('link_{{link.id}}', this);return false;"
- title="{{'CheckURL'|get_lang}}"
- class="btn validate_link"></a>
- <a href="{{root}}&action=edit_link&id={{link.id}}&c_id={{link.c_id}}"
- onclick=""
- title="{{'Edit'|get_lang}}"
- class="">
- <em class="size-22 icon-edit"></em>
- </a>
- <a href="javascript:void(0)"
- onclick="switch_li_visibility('link_{{link.id}}', this);return false;"
- class="btn visibility {%if link.visibility == 1%}hide{%else%}show{%endif%}"></a>
- <a href="javascript:void(0)"
- onclick="delete_link('link_{{link.id}}', this);return false;"
- title="{{'Delete'|get_lang}}"
- class="">
- <em class="size-22 icon-delete"></em>
- </a>
- </div>
- {% endif %}
- </li>
- {% endfor%}
- </ul>
- </div>
- <div class="details "></div>
- </li>
- {% endfor%}
- </ul>
- </div>
|