seminar2_old/app/views/admin/seminars/sub_page_setting.html.erb

155 lines
5.3 KiB
Plaintext

<div id="sideset">
<style>
.icon-logged-in{
color: #3a87ad;
font-size: 14px;
margin-right: 3px;
vertical-align: middle;
}
</style>
<%= stylesheet_link_tag "structure" %>
<%= stylesheet_link_tag "lib/items" %>
<%= javascript_include_tag "lib/jquery.mjs.nestedSortable.js" %>
<%= stylesheet_link_tag "select2/select2" %>
<%= javascript_include_tag 'validator' %>
<%= javascript_include_tag "select2/select2.min" %>
<div id="search-bar">
<div class="search-box">
<label class="muted">Search :</label>
<input id="search-box" type="search" placeholder="Page ID or name" />
</div>
<span class="or">OR</span>
<div class="search-select">
<%= select_tag "module_type", options_for_select(@searchfilter), prompt: "------Select a module-----", :class => "module-selector" %>
</div>
</div>
<% node = @seminar_page_root %>
<% root_page = node %>
<% @page_root_id = node.id %>
<% bind_module_app = root_page.bind_module_app %>
<% @prefix_url = "" %>
<% if bind_module_app %>
<% link_page_url = Page.where(:module=>bind_module_app).first.url rescue "" %>
<% if link_page_url.present? %>
<% bind_model = root_page.bind_model %>
<% bind_uid = root_page.bind_uid %>
<% target_model = bind_model.constantize.find_by(:uid=>bind_uid) rescue nil %>
<% title = target_model.title rescue "" %>
<% @prefix_url = "/#{I18n.locale}#{link_page_url}/#{title}-#{bind_uid}"%>
<% end %>
<% end %>
<% unless node.nil? %>
<ol id='<%= node.id %>' class="sortable item-groups root">
<%= render 'node_and_children', {node: node, level: 0} %>
</ol>
<% end %>
<%= render :partial => "pages/modify_member_frontend_fields" %>
<%= render :partial => "pages/modify_plugin_frontend_fields" %>
<%##= render 'layouts/delete_modal', delete_options: {remote: true} %>
<%#= render 'form_page' %>
<%#= render 'form_link' %>
<%= javascript_include_tag "lib/pageslide.js" %>
<%= javascript_include_tag "lib/items/items" %>
<script type="text/javascript">
window.default_page_module = "page_content";
$('li .item-menu').each(function(i,v){
var li = $(v).parents("li").eq(0);
var module_title = $(v).parent(".item-title").siblings(".item-type").attr("title");
if(module_title == "PageContent"){
if($(v).find(".edit_page").length == 0){
var page_id = li.attr("id");
$(v).append("<a class=\"edit_page\" target=\"_blank\" title=\"<%=t('seminar.edit_page_content')%>\" href=\"<%=new_admin_page_content_path%>?page_id="+page_id+"\"><%=t('seminar.edit_page_content')%></a>");
}
}else{
$(v).find(".edit_page").remove();
}
})
$(document).on("document_changed",function(){
$('li .item-menu').each(function(i,v){
var li = $(v).parents("li").eq(0);
var module_title = $(v).parent(".item-title").siblings(".item-type").attr("title");
if(module_title == "PageContent"){
if($(v).find(".edit_page").length == 0){
var page_id = li.attr("id");
$(v).append("<a class=\"edit_page\" target=\"_blank\" title=\"<%=t('seminar.edit_page_content')%>\" href=\"<%=new_admin_page_content_path%>?page_id="+page_id+"\"><%=t('seminar.edit_page_content')%></a>");
}
}else{
$(v).find(".edit_page").remove();
}
})
})
$(function(){
var select = $("#module_type"),
search = $("#search-box"),
pages = $("ol.root li"),
collapsedPages = [];
select.on("change",function(){
search.val("");
var v = $(this).val();
pages.removeClass("highlight");
if(collapsedPages.length > 0){
$(collapsedPages).addClass("collapsed");
collapsedPages = [];
}
if(v != ""){
var targetPages = pages.filter("li[data-page-module=" + v + "]");
targetPages.each(function(i){
var node = $(this);
if(!node.is("visible")){
var parentNode = node.parent().parent();
collapsedPages.push(parentNode.get(0));
parentNode.removeClass("collapsed");
if(parentNode.data("level") == "2"){
parentNode = parentNode.parent().parent();
collapsedPages.push(parentNode.get(0));
parentNode.removeClass("collapsed");
}
}
node.addClass("highlight");
})
if(collapsedPages.length > 0){
var offset = targetPages.eq(0).offset().top - 100;
$("*").animate({scrollTop:offset}, '300');
}
}
})
search.on("keyup",function(e){
if(e.which == 13){
select.val("");
var v = $(this).val();
pages.removeClass("highlight");
if(collapsedPages.length > 0){
$(collapsedPages).addClass("collapsed");
collapsedPages = [];
}
if(v != ""){
var pt = pages.filter("li[data-page-title*=" + v + "]"),
pi = pages.filter("li[data-page-id=" + v + "]");
targetPages = pt.add(pi);
targetPages.each(function(i){
var node = $(this);
if(!node.is("visible")){
var parentNode = node.parent().parent();
collapsedPages.push(parentNode.get(0));
parentNode.removeClass("collapsed");
if(parentNode.data("level") == "2"){
parentNode = parentNode.parent().parent();
collapsedPages.push(parentNode.get(0));
parentNode.removeClass("collapsed");
}
}
node.addClass("highlight");
})
if(collapsedPages.length > 0){
var offset = targetPages.eq(0).offset().top - 100;
$("*").animate({scrollTop:offset}, '300');
}
}
}
})
})
</script>
</div>