diff --git a/app/assets/javascripts/lib/orbit_js_1.0.1.js b/app/assets/javascripts/lib/orbit_js_1.0.1.js new file mode 100644 index 00000000..93aceaa3 --- /dev/null +++ b/app/assets/javascripts/lib/orbit_js_1.0.1.js @@ -0,0 +1,511 @@ +//Global Variables +$sidebarState = window.localStorage.getItem('sidebarState'); +$ua = navigator.userAgent; +$.extend($.support, { + touch: "ontouchend" in document +}); +if($.support.touch) { + mouseenterEvent = clickEvent = "touchstart"; +} else { + clickEvent = "click"; + mouseenterEvent = "mouseenter"; +}; + + +!function ($) { + // Focus first element + $.fn.focusFirstField = function(){ + $this = this; + $this.find(":text:visible:enabled").filter(function(){ + return $(this).parents(":hidden").size() == 0; + }).slice(0,1).focus(); + return this; + } + + + //Checked Toggle + $.fn.togglebox = function () { + var $checked = this; + $checked.each(function() { + if(!$(this).closest('div').hasClass('togglebox')) { + $(this).wrap('
'); + $('').insertAfter($(this)); + } + }) + $checked.each(function(i) { + if($(this).attr('type') == "checkbox") { + if($(this).prop('checked')) { + $(this).parent('.togglebox').addClass('disabled').closest('li').addClass('disabled'); + }; + $(this).on({ + change: function() { + $(this).parent('.togglebox').toggleClass('disabled'); + $(this).closest('tr').toggleClass('disable'); + } + }); + }; + if($(this).attr('type') == "radio") { + if(!$(this).prop('checked')) { + $(this).parent('.togglebox').addClass('disabled').closest('li').addClass('disabled'); + $(this).closest('tr').addClass('disable'); + }; + $(this).on({ + change: function() { + $checked.each(function(i) { + if(!$(this).parent('.togglebox').hasClass('disabled')) { + $(this).parent('.togglebox').toggleClass('disabled'); + $(this).closest('tr').toggleClass('disable'); + }; + }); + $(this).parent('.togglebox').toggleClass('disabled') + $(this).closest('tr').toggleClass('disable'); + } + }); + }; + if($('#sitemap').length) { + $(this).on({ + change: function() { + $(this).closest('li').toggleClass('disabled'); + if($(this).prop('checked')) { + $(this).attr('checked', 'checked'); + $(this).parents('h6') + .siblings('ul') + .find('li') + .addClass('disabled') + .find('h6 .togglebox') + .addClass('disabled') + .find('input[type="checkbox"]') + .prop('checked', true) + .attr('checked', 'checked'); + } else { + $(this).removeAttr('checked'); + $(this).parents('h6') + .siblings('ul') + .find('li') + .removeClass('disabled') + .find('h6 .togglebox') + .removeClass('disabled') + .find('input[type="checkbox"]') + .prop('checked', false) + .removeAttr('checked'); + }; + $('.toggle-check').each(function(i) { + var len = $(this).closest('ul').children('li').length, + checLen = $(this).closest('ul').children('li').find('input[checked]').length, + checLen = checLen - $(this).closest('ul').children('li').find('ul').find('input[checked]').length; + if(len == checLen) { + $(this).closest('ul') + .parent('li') + .addClass('disabled') + .children('h6') + .find('.togglebox') + .addClass('disabled') + .find('input[type="checkbox"]') + .prop('checked', true) + .attr('checked', 'checked'); + } else { + $(this).closest('ul') + .parent('li') + .removeClass('disabled') + .children('h6') + .find('.togglebox') + .removeClass('disabled') + .find('input[type="checkbox"]') + .prop('checked', false) + .removeAttr('checked'); + }; + }); + }, + }); + }; + }); + }; + + + // Search Clear + $.fn.searchClear = function (param){ + _defaultSettings = { + inputName: ':input', + inputIcon: 'inputIcon', + clearBtnIcon: 'clearBtnIcon', + liveFilter: false, + }; + _set = $.extend(_defaultSettings, param); + $this = this; + $input = this.find(_set.inputName); + $tmp = ''; + $input.wrap(''); + $this.find('.sc-field').prepend($tmp); + $searchClear = $this.find(".search-clear"); + function run(e) { + $searchClear.hide(); + $($input).each(function() { + if($(this).val().length > 0) { + $(this).prev($searchClear).show(); + }else { + $(this).prev($searchClear).hide(); + } + $(this).on("blur keyup", function(){ + if($(this).val().length > 0) { + $(this).prev($searchClear).show(); + }else { + $(this).prev($searchClear).hide(); + } + }); + if(_set.liveFilter) { + $(this).prevAll($searchClear).on({ + click: function(){ + $(this).hide(); + $(this).next($input).val(""); + $('.checkbox-card .mark').removeClass('mark') + }, + }); + } else { + $(this).prevAll($searchClear).on({ + click: function(){ + $(this).hide(); + $(this).next($input).val(""); + }, + }); + } + }); + } + + // Checking IE10 + // if Windows 8 and IE is ture. remove search clear buttom and fix text input padding-right + if(/Windows NT 6.2/g.test(navigator.userAgent)){ + if(/MSIE/g.test(navigator.userAgent)){ + $searchClear.remove(); + $input.css({ + 'padding-right': '5px', + }); + }else{run()} + }else{run()} + } + + + // Fixed Nav + fixedNav = function () { + if($('.fixed-nav').length){ + var $fixedNav = $('.fixed-nav'); + if($sidebarState){ + $fixedNav.addClass('open'); + } + $fixedNav.on(clickEvent, function() { + if($sidebarState) { + window.localStorage.removeItem('sidebarState'); + $fixedNav.removeClass('open'); + }else{ + window.localStorage.setItem('sidebarState', 1); + $fixedNav.addClass('open'); + } + $sidebarState = window.localStorage.getItem('sidebarState') + }); + } + }; + + + // Sidebar + sidebarNav = function () { + var $sidebar = $('#sidebar'), + $sidebarMenu = $('#sidebar-menu'), + $scroller = $('.scroller'), + $sidebarNav = $('.sidebar-nav'), + $el = $('.sidebar-nav').children('li'), + $elIndex = null, + $blockList = $('.sub-nav-block-list'), + $block = $('.sub-nav-block'), + $blockIndex = 0, + $arrow = $('.sub-nav-arrow'), + $wrap = $('#main-wrap'), + $wrapLeft = $wrap.css('margin-left'), + $position = 0, + $arrowHeightFormat = $('.position').height()-8; + if($('#sidebar').length>0) { + $wrap.css({'margin-left': 61}); + $wrapLeft = 61; + } + if($el.hasClass('active')) { + // Menu defaults active + $elIndex = $el.filter('.active').index(); + if($sidebarState && !$sidebarNav.hasClass('no-sub-nav')) { + $block.eq($elIndex).addClass('show'); + $blockList.css({'width': 180}); + $wrap.css({ + 'margin-left': 241, + }); + } + + // Arrow defaults position + $position = $el.eq($elIndex).offset().top-$el.eq($elIndex).height()/2+$arrowHeightFormat-$(document).scrollTop(); + $arrow.css({ + 'top': $position, + }); + } + if($.support.touch && !$sidebarNav.hasClass('no-sub-nav')) { + $el.find('a').removeAttr('href'); + }; + $el.on(mouseenterEvent, function(e) { + $block.siblings().removeClass('show').eq($(this).index()).addClass('show'); + $arrow.stop(true, false).animate({ + top: ($(this).offset().top-$(this).height()/2)+$arrowHeightFormat-$(document).scrollTop(), + },{ + duration: 500, + easing: 'easeInOutBack', + }); + if(!$sidebarState || !$el.hasClass('active')) { + $blockList.css({'width': 180}); + if($('#pageslide').length) { + if($('#pageslide').is(":hidden")) { + $wrap.css({ + 'margin-left': $blockList.width()+$sidebarNav.width(), + }); + } + }else{ + $wrap.css({ + 'margin-left': $blockList.width()+$sidebarNav.width(), + }); + } + // if($('.topnav').length) { + // $('.topnav').css({ + // 'left': $blockList.width()+$sidebarNav.width()+20, + // }); + // } + if($('.bottomnav').length) { + $('.bottomnav').css({ + 'left': $blockList.width()+$sidebarNav.width()+20, + }); + } + $sidebar.css({ + 'width': $blockList.width()+$sidebarNav.width(), + }); + } + }); + if ($sidebarNav.hasClass('no-sub-nav')) { + $sidebar.on('mouseleave', function() { + $arrow.stop(true, false).animate({ + 'top': $position, + },{ + duration: 500, + easing: 'easeInOutBack', + }); + }) + }; + // $el.on('mouseleave', function() { + // $el.hasClass('active') ? $position = $el.eq($elIndex).offset().top-$el.eq($elIndex).height()/2+$arrowHeightFormat-$(document).scrollTop() : 0; + // $(this).hasClass('active') ? '':$(this).children('span').removeClass('hover'); + // }); + $block.on({ + mouseenter: function() { + $blockIndex = $block.filter('.sub-nav-block show').index(); + $el.eq($blockIndex).hasClass('active') ? '':$el.eq($blockIndex).children('span').addClass('hover'); + }, + mouseleave: function() { + $block.removeClass('show'); + if(!$sidebarState || !$el.hasClass('active')) { + $blockList.css({'width': 0}); + if($('#pageslide').length) { + if($('#pageslide').is(":hidden")) { + $wrap.css({ + 'margin-left': $wrapLeft, + }); + // if($('.topnav').length) { + // if($sidebarState) { + // $('.topnav').css({ + // 'left': 261, + // }); + // } + // } + } + } else { + $wrap.css({ + 'margin-left': $blockList.width()+$sidebarNav.width(), + }); + } + // if($('.topnav').length) { + // $('.topnav').css({ + // 'left': $blockList.width()+$sidebarNav.width()+20, + // }); + // } + if($('.bottomnav').length) { + $('.bottomnav').css({ + 'left': $blockList.width()+$sidebarNav.width()+20, + }); + } + $sidebar.css({'width': 61}); + }else{ + $block.eq($elIndex).addClass('show'); + }; + + + if($elIndex === null) { + $position = 0; + } else { + $position = $el.eq($elIndex).offset().top-$el.eq($elIndex).height()/2+$arrowHeightFormat-$(document).scrollTop(); + } + $arrow.stop(true, false).animate({ + top: $position, + },{ + duration: 500, + easing: 'easeInOutBack', + }); + } + }); + // Touch Start + $wrap.on({ + touchstart: function() { + if(!$sidebarState || !$el.hasClass('active')) { + if($block.hasClass('show')) { + $blockIndex = $block.filter('.sub-nav-block show').index(); + $block.removeClass('show'); + $blockList.css({'width': 0}); + $wrap.css({ + 'margin-left': $wrapLeft, + }); + $sidebar.css({'width': 61}); + $arrow.stop().animate({ + top: $position, + },{ + duration: 500, + easing: 'easeInOutBack', + }); + $el.eq($blockIndex).hasClass('active') ? '':$el.eq($blockIndex).children('span').removeClass('hover'); + } + } + } + }); + // Sidebar Nav Drag + if(/MSIE 8.0/g.test($ua)){ + $sidebarMenu.addClass('nano') + .css({'position': 'relative', 'top': '0px'}) + .children('.scroller') + .addClass('content') + .removeClass('scroller'); + $sidebarMenu.nanoScroller({ scrollTop: 0 }); + } else { + if($('#sidebar').length) { + var sidebarMenu = new iScroll('sidebar-menu', { + vScrollbar: true, + scrollbarClass: 'myScrollbar', + onBeforeScrollStart: function (e) { + var target = e.target; + clearTimeout(this.hoverTimeout); + while (target.nodeName != "SPAN") target = target.parentNode; + $target = $(target.parentNode).index(); + }, + touch: function () { + if (this.hoverTarget) { + clearTimeout(this.hoverTimeout); + $('.sub-nav-block').removeClass('show') + $('.sub-nav-block').eq($target).addClass('show') + } + }, + }); + } + }; + }; + + + + // Initial State + initialState = function () { + if($('.bottomnav').length) { + var $bottomnavHeight = $('.bottomnav').outerHeight(); + $('.wrap-inner').css({ + 'padding-bottom': $bottomnavHeight, + }) + if($sidebarState) { + if(!$('.sidebar-nav').hasClass('no-sub-nav')) { + $('.bottomnav').css({ + 'left': 261, + }); + } + } + } + // if($('.topnav').length) { + // if($sidebarState) { + // $('.topnav').css({ + // 'left': 261, + // }); + // } + // } + }; +}(window.jQuery); + + +// Open Slide +function openSlide() { + var $openSlide = $('.open-slide'), + $pageslideW; + + $(window).width() > 1440 ? $pageslideW = 1024 : $pageslideW = 954; + $(window).resize(function() { + $(this).width() > 1440 ? $pageslideW = 1024 : $pageslideW = 954; + }) + $openSlide.each(function() { + if($(this).hasClass('view-page')) { + $(this).pageslide({ W: $pageslideW, iframe: true}); + } else if($('#items').length) { + $(this).pageslide({ W: 324}); + } else { + $(this).pageslide(); + }; + }); + $('.bottomnav .open-slide').on('click', function() { + $('.table tr').removeClass('active'); + $('.filter-item').removeClass('active') + }); +} + +function formTip() { + if($('.main-forms').length && $('.add-on').length) { + $('.main-forms .add-on').tooltip(); + } +} + + +// Document Ready +$(function() { + initialState(); + $('#login').on('shown', function () { + $(document.body).addClass('modalBlur'); + $('#login').focusFirstField(); + }).on("hide", function() { + $(document.body).removeClass('modalBlur'); + }); + $('#orbit-bar .searchClear').searchClear({ + inputName: '.search-query', + inputIcon: 'icon-search', + clearBtnIcon: 'icons-cross-3', + + }); + $('#filter .searchClear').searchClear({ + inputName: '.search-query', + inputIcon: 'icon-search', + clearBtnIcon: 'icons-cross-3', + liveFilter: true, + }); + $('#member-filter').on('shown', function() { + $(this).find('.nano').nanoScroller({ scrollTop: 0, iOSNativeScrolling: true }); + }); + if($('#sidebar').length) { + if(!/MSIE 8.0/g.test(navigator.userAgent)){ + document.getElementById('sidebar').addEventListener('touchmove', function (e) { e.preventDefault(); }, false); + } + demo_fu1(); + } + if($('#pageslide').length) { + openSlide(); + } + if($('.tags').length) { + $('#filter-input').fastLiveFilter('#tags-list', '.filter-item', '.tag'); + } + if($('#card-list').length) { + $('#filter-input').fastLiveFilter('#card-list', '.filter-item', '.user-name'); + } + if($('.toggle-check').length) { + $('.toggle-check').togglebox(); + } + formTip() + sidebarNav(); +}); \ No newline at end of file diff --git a/vendor/built_in_modules/archive/app/assets/stylesheets/archive/archives.css b/vendor/built_in_modules/archive/app/assets/stylesheets/archive/archives.css index 0b42c7a0..e0aa39d6 100644 --- a/vendor/built_in_modules/archive/app/assets/stylesheets/archive/archives.css +++ b/vendor/built_in_modules/archive/app/assets/stylesheets/archive/archives.css @@ -1,100 +1,117 @@ /* General style with default layout */ .o-archives {} -.o-archives-content {} -.o-archives-group { +.o-archives .o-archives-content {} +.o-archives .o-archives-group { margin: 20px 0 0 0; padding: 20px 0 0 0; border-top: dashed 1px #eee; } -.o-archives-group:first-child { +.o-archives .o-archives-group:first-child { margin: 0; padding: 0; border: 0; } -.o-archives-category { +.o-archives .o-archives-category { padding-bottom: 16px; + margin-bottom: 16px; border-bottom: solid 2px #ccc; font-weight: bold; } -.o-archives-list {} -.o-archives-list ul { +.o-archives .o-archives-list {} +.o-archives .o-archives-list ul { margin: 0; padding: 0; list-style: none; } -.o-archives-list li {} -.o-archives-title { +.o-archives .o-archives-list li {} +.o-archives .o-archives-title { border-left: solid 8px #eee; border-bottom: solid 1px #eee; padding: 0 0 0 16px; + line-height: 2em; } -.o-archives-list-item {} -.o-archives-list-item ol { - list-style-type: decimal; +.o-archives .o-archives-list-item { + padding: 12px 0; } -.o-archives-list-item li { - margin: 0 0 10px 0; +.o-archives .o-archives-list-item ol { + list-style-type: disc; + margin: 0; } -.o-archives-file {} -.o-archives-file:hover {} -.o-archives-file-type { -display: inline-block; -vertical-align: middle; -margin-left: 8px; -padding: 0 4px; -height: 15px; -font-size: 9px; -text-transform: uppercase; -line-height: 15px; -background-color: #999; -color: #FFF; -border-radius: 3px; --webkit-text-size-adjust: none; +.o-archives .o-archives-list-item li { + margin: 0 0 8px 0; +} +.o-archives .o-archives-file { + font-size: 0.85em; +} +.o-archives .o-archives-file:hover {} +.o-archives .o-archives-file-type { + display: inline-block; + vertical-align: top; + margin-left: 8px; + padding: 0 6px; + height: 16px; + font-size: 10px; + text-transform: uppercase; + line-height: 16px; + background-color: #666; + color: #fff; + border-radius: 3px; +} +.o-archives .o-archives-hot { + font-size: 11px; + font-weight: normal; + padding: 0 4px; + display: inline-block; + vertical-align: top; + margin: 0 0 0 8px; + background-color: #D83131; + color: #FFF; } /* Tag list */ -.o-archives-tag-list {} -.o-archives-tag-list ul { +.o-archives .o-archives-tag-list {} +.o-archives .o-archives-tag-list ul { margin: 0 -4px; padding: 0; list-style: none; } -.o-archives-tag-list ul:after { +.o-archives .o-archives-tag-list ul:after { content: "."; clear: both; display: block; height: 0; visibility: hidden; } -.o-archives-tag-list li { +.o-archives .o-archives-tag-list li { float: left; margin: 0 4px 8px 4px; } -.o-archives-tag { +.o-archives .o-archives-tag { display: block; border: solid 1px #ccc; - padding: 2px 6px; + padding: 4px; + font-size: 0.85em; } -.o-archives-tag:hover {} +.o-archives .o-archives-tag:hover {} /* Table layout */ .o-archives.layout-table {} -.o-archives-search { +.o-archives .o-archives-search { overflow: hidden; margin: 0 0 10px 0; } -.o-archives-search label { +.o-archives .o-archives-search label { display: inline-block; margin: 0 8px 0 0; } -.o-archives-search-option { +.o-archives .o-archives-search-option { float: right; } -.o-archives-search-option select { +.o-archives .o-archives-search-option select { width: 80px; } -.o-archives-search-keyword {} -.o-archives-search-keyword input[type=submit] { +.o-archives .o-archives-search-keyword {} +.o-archives .o-archives-search-keyword input[type=submit] { display: inline-block; vertical-align: top; margin: 0 0 0 8px; @@ -112,6 +129,8 @@ border-radius: 3px; .o-archives.layout-table .even td {} .o-archives.layout-table .column-ctrl { text-align: left; + padding: 8px 4px; + font-size: 0.85em; } .o-archives.layout-table .column-ctrl.col-title { width: 30% } .o-archives.layout-table .column-ctrl.col-file {} @@ -121,16 +140,18 @@ border-radius: 3px; font-weight: bold; border: 0; padding: 0; + line-height: 1.2em; } .o-archives.layout-table .o-archives-category { padding: 0; margin: 0; border: 0; + font-weight: normal; } .o-archives.layout-table .o-archives-tag { display: inline-block; margin-bottom: 3px; } -.o-archives.layout-table .o-archives-category { - font-weight: normal; +.o-archives.layout-table .o-archives-list-item { + padding: 0; } \ No newline at end of file diff --git a/vendor/built_in_modules/archive/app/controllers/panel/archive/back_end/archive_files_controller.rb b/vendor/built_in_modules/archive/app/controllers/panel/archive/back_end/archive_files_controller.rb index 79712fbf..10e942a0 100644 --- a/vendor/built_in_modules/archive/app/controllers/panel/archive/back_end/archive_files_controller.rb +++ b/vendor/built_in_modules/archive/app/controllers/panel/archive/back_end/archive_files_controller.rb @@ -1,48 +1,66 @@ class Panel::Archive::BackEnd::ArchiveFilesController < OrbitBackendController # before_filter :for_app_manager,:except => [:index,:show] - include OrbitControllerLib::DivisionForDisable + # include OrbitControllerLib::DivisionForDisable before_filter :force_order_for_visitor,:only=>[:index] before_filter :force_order_for_user,:except => [:index] before_filter :for_app_sub_manager,:except => [:index] - before_filter :only => [ :new,:edit,:update,:create] do |controller| - controller.get_categorys('ArchiveFileCategory') + # before_filter :only => [ :new,:edit,:update,:create] do |controller| + # controller.get_categorys('ArchiveFileCategory') + # end + + before_filter :only => [ :new, :create, :edit, :update ] do |controller| + @categories = get_categories_for_form end def index + @tags = get_tags + @categories = get_categories_for_index + @statuses = get_statuses + category_ids = @categories.collect{|t| t.id} - get_categorys("ArchiveFileCategory",params[:archive_file_category_id]) - @filter = params[:filter] - new_filter = params[:new_filter] - - if @filter && params[:clear] - @filter.delete(params[:type]) - elsif @filter && new_filter - if @filter.has_key?(new_filter[:type]) && @filter[new_filter[:type]].include?(new_filter[:id].to_s) - @filter[new_filter[:type]].delete(new_filter[:id].to_s) - elsif @filter.has_key?(new_filter[:type]) - @filter[new_filter[:type]] << new_filter[:id].to_s - else - @filter.merge!({new_filter[:type] => [new_filter[:id].to_s]}) - end - elsif new_filter - @filter = {new_filter[:type] => [new_filter[:id].to_s]} - end - @archive_filecategories = get_categories_for_index("ArchiveFileCategory") - @archive_file_category_ids = @archive_file_categories.collect{|t| t.id.to_s} + [nil] - - @archive_files = (params[:sort] || @filter) ? get_sorted_and_filtered("archive_file",:archive_file_category_id.in => @archive_file_category_ids) : get_viewable("archive_file",:archive_file_category_id.in => @archive_file_category_ids) - - @tags = get_tags - + @archive_files = get_sorted_and_filtered("archive_file", :category_id.in => category_ids) respond_to do |format| format.html # index.html.erb + format.js { } format.xml { render :xml => @archive_files } - format.js end end + # def index + + # get_categorys("ArchiveFileCategory",params[:archive_file_category_id]) + # @filter = params[:filter] + # new_filter = params[:new_filter] + + # if @filter && params[:clear] + # @filter.delete(params[:type]) + # elsif @filter && new_filter + # if @filter.has_key?(new_filter[:type]) && @filter[new_filter[:type]].include?(new_filter[:id].to_s) + # @filter[new_filter[:type]].delete(new_filter[:id].to_s) + # elsif @filter.has_key?(new_filter[:type]) + # @filter[new_filter[:type]] << new_filter[:id].to_s + # else + # @filter.merge!({new_filter[:type] => [new_filter[:id].to_s]}) + # end + # elsif new_filter + # @filter = {new_filter[:type] => [new_filter[:id].to_s]} + # end + # @archive_filecategories = get_categories_for_index("ArchiveFileCategory") + # @archive_file_category_ids = @archive_file_categories.collect{|t| t.id.to_s} + [nil] + + # @archive_files = (params[:sort] || @filter) ? get_sorted_and_filtered("archive_file",:archive_file_category_id.in => @archive_file_category_ids) : get_viewable("archive_file",:archive_file_category_id.in => @archive_file_category_ids) + + # @tags = get_tags + + # respond_to do |format| + # format.html # index.html.erb + # format.xml { render :xml => @archive_files } + # format.js + # end + # end + # GET /archive_files/1 # GET /archive_files/1.xml def show @@ -57,7 +75,12 @@ class Panel::Archive::BackEnd::ArchiveFilesController < OrbitBackendController # GET /archive_files/new # GET /archive_files/new.xml def new - @archive_file = ArchiveFile.new + if(session[:in_validate_object].blank?) + @archive_file = ArchiveFile.new + else + @archive_file = session[:in_validate_object] + session[:in_validate_object] = {} + end @tags = get_tags @@ -70,8 +93,11 @@ class Panel::Archive::BackEnd::ArchiveFilesController < OrbitBackendController # GET /archive_files/1/edit def edit @archive_file = ArchiveFile.find(params[:id]) - - @tags = get_tags + if !current_user.admin? + redirect_to :action => :index + else + @tags = get_tags + end end # POST /archive_files diff --git a/vendor/built_in_modules/archive/app/controllers/panel/archive/front_end/archive_files_controller.rb b/vendor/built_in_modules/archive/app/controllers/panel/archive/front_end/archive_files_controller.rb index 4f684926..64cf054e 100644 --- a/vendor/built_in_modules/archive/app/controllers/panel/archive/front_end/archive_files_controller.rb +++ b/vendor/built_in_modules/archive/app/controllers/panel/archive/front_end/archive_files_controller.rb @@ -21,6 +21,7 @@ class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController def index @item = Page.find(params[:page_id]) @title = @item.title + @frontend_style = @item.frontend_style if !@item.frontend_data_count.blank? @page_num = @item.frontend_data_count else @@ -28,23 +29,69 @@ class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController end date_now = Time.now - @archive_file_categorys = ArchiveFileCategory.all + # @archive_file_categorys = ArchiveFileCategory.all # @archive_files = ArchiveFile.where( :is_hidden => false ).desc(:is_top).page(params[:page]).per(@page_num) - if !params[:category_id].blank? && !params[:tag_id].blank? - @archive_files = @archive_files.default_sort(params[:sort]).can_display.where(:archive_file_category_id.in => params[:category_id], :tagged_ids.in => params[:tag_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num) - @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil - elsif !params[:category_id].blank? - @archive_files = ArchiveFile.default_sort(params[:sort]).can_display.where(:archive_file_category_id.in => params[:category_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num) - @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil - elsif !params[:tag_id].blank? - @archive_files = ArchiveFile.default_sort(params[:sort]).can_display.where(:tagged_ids.in => params[:tag_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num) + if !params[:category_id].blank? + @archive_file_categorys = @module_app.categories.enabled.any_in(:_id => params[:category_id]) + @archive_file_category_ids = @module_app.categories.enabled.any_in(:_id => params[:category_id]).collect{|a|a.id} else - @archive_files = ArchiveFile.default_sort(params[:sort]).can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num) + @archive_file_categorys = @module_app.categories.enabled + @archive_file_category_ids = @module_app.categories.enabled.collect{|a|a.id} end - - get_categorys + if @frontend_style == "1" + + if !params[:category_id].blank? && !params[:tag_id].blank? + @archive_files = ArchiveFile.can_display.where(:category_id.in => @archive_file_category_ids, :tagged_ids.in => params[:tag_id]).desc( :is_top ).default_sort(params[:sort]).page( params[:page_main] ).per(@page_num) + # @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil + elsif !params[:category_id].blank? + @archive_files = ArchiveFile.can_display.where(:category_id.in => @archive_file_category_ids).desc( :is_top ).default_sort(params[:sort]).page( params[:page_main] ).per(@page_num) + # @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil + elsif !params[:tag_id].blank? + @archive_files = ArchiveFile.can_display.where(:category_id.in => @archive_file_category_ids,:tagged_ids.in => params[:tag_id]).desc( :is_top ).default_sort(params[:sort]).page( params[:page_main] ).per(@page_num) + else + @archive_files = ArchiveFile.can_display.where(:category_id.in => @archive_file_category_ids).desc( :is_top ).default_sort(params[:sort]).page( params[:page_main] ).per(@page_num) + end + + elsif @frontend_style == "2" + + @archive_file_datas = Array.new + + @archive_file_categorys.each do |afcg| + + if !params[:category_id].blank? && !params[:tag_id].blank? + @archive_files = ArchiveFile.can_display.where(:category_id.in => [afcg.id], :tagged_ids.in => params[:tag_id]).desc( :is_top ).default_sort(params[:sort]) + elsif !params[:category_id].blank? + @archive_files = ArchiveFile.can_display.where(:category_id.in => [afcg.id]).desc( :is_top ).default_sort(params[:sort]) + elsif !params[:tag_id].blank? + @archive_files = ArchiveFile.can_display.where(:category_id => afcg.id, :tagged_ids.in => params[:tag_id]).desc( :is_top ).default_sort(params[:sort]) + else + @archive_files = ArchiveFile.can_display.where(:category_id => afcg.id).desc( :is_top ).default_sort(params[:sort]) + end + + archive_file_datas = Array.new + + @archive_files.each do |af| + + archive_file_multiple_datas = Array.new + + af.archive_file_multiples.asc(:sort_number).each do | afile | + archive_file_multiple_datas << { + "file_title" => (!afile.file_title.blank? ? afile.file_title : t('archive.download') ) , + "url" => afile.file.url, + "icon" => af.get_file_icon(afile.file.url) + } if afile.file.file and afile.choose_lang_display(I18n.locale.to_s) + end + + archive_file_datas << { "title" => af.title, "is_hot" => (!af.is_hot.blank? ? '1' : ''), "archive_file_multiples" => archive_file_multiple_datas } if !af.archive_file_multiples.blank? and !archive_file_multiple_datas.blank? + end + + @archive_file_datas << { "title" => afcg.title, "archive_files" => archive_file_datas } if !@archive_files.blank? + end + + end + # get_categorys if params[:sort] @archive_files = get_sorted_and_filtered('archive_file', nil, @archive_files) diff --git a/vendor/built_in_modules/archive/app/controllers/panel/archive/widget/archive_files_controller.rb b/vendor/built_in_modules/archive/app/controllers/panel/archive/widget/archive_files_controller.rb index abfa7d93..426ce383 100644 --- a/vendor/built_in_modules/archive/app/controllers/panel/archive/widget/archive_files_controller.rb +++ b/vendor/built_in_modules/archive/app/controllers/panel/archive/widget/archive_files_controller.rb @@ -28,17 +28,91 @@ class Panel::Archive::Widget::ArchiveFilesController < OrbitWidgetController date_now = Time.now + # if !params[:category_id].blank? + # @archive_files = ArchiveFile.default_sort(params[:sort]).all.can_display.any_in(:category_id => params[:category_id]).merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top ).page( params[:page_main] ).per(@page_num) + # @archive_file_categorys = ArchiveFileCategory.any_in(:_id => params[:category_id]).excludes('disable' => true) + # elsif !params[:tag_id].blank? + # @archive_files = ArchiveFile.default_sort(params[:sort]).all.can_display.any_in(:tagged_ids => params[:tag_id]).merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top ).page( params[:page_main] ).per(@page_num) + # get_categorys + # else + # @archive_files = ArchiveFile.default_sort(params[:sort]).all.can_display.merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top).page( params[:page_main] ).per(@page_num) + # get_categorys + # end + + # if !params[:category_id].blank? && !params[:tag_id].blank? + # @archive_files = ArchiveFile.default_sort(params[:sort]).can_display.where(:category_id.in => params[:category_id], :tagged_ids.in => params[:tag_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num) + # @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil + # elsif !params[:category_id].blank? + # @archive_files = ArchiveFile.default_sort(params[:sort]).can_display.where(:category_id.in => params[:category_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num) + # @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil + # elsif !params[:tag_id].blank? + # @archive_files = ArchiveFile.default_sort(params[:sort]).can_display.where(:tagged_ids.in => params[:tag_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num) + # else + # @archive_files = ArchiveFile.default_sort(params[:sort]).can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num) + # end + + + if !params[:category_id].blank? - @archive_files = ArchiveFile.default_sort(params[:sort]).all.can_display.any_in(:archive_file_category_id => params[:category_id]).merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top ).page( params[:page_main] ).per(@page_num) - @archive_file_categorys = ArchiveFileCategory.any_in(:_id => params[:category_id]).excludes('disable' => true) - elsif !params[:tag_id].blank? - @archive_files = ArchiveFile.default_sort(params[:sort]).all.can_display.any_in(:tagged_ids => params[:tag_id]).merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top ).page( params[:page_main] ).per(@page_num) - get_categorys + @archive_file_categorys = @module_app.categories.enabled.any_in(:_id => params[:category_id]) + @archive_file_category_ids = @module_app.categories.enabled.any_in(:_id => params[:category_id]).collect{|a|a.id} else - @archive_files = ArchiveFile.default_sort(params[:sort]).all.can_display.merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top).page( params[:page_main] ).per(@page_num) - get_categorys + @archive_file_categorys = @module_app.categories.enabled + @archive_file_category_ids = @module_app.categories.enabled.collect{|a|a.id} end + if @widget_style == "1" + + if !params[:category_id].blank? && !params[:tag_id].blank? + @archive_files = ArchiveFile.can_display.where(:category_id.in => @archive_file_category_ids, :tagged_ids.in => params[:tag_id]).desc( :is_top ).default_sort(params[:sort]).page( params[:page_main] ).per(@page_num) + elsif !params[:category_id].blank? + @archive_files = ArchiveFile.can_display.where(:category_id.in => @archive_file_category_ids).desc( :is_top ).default_sort(params[:sort]).page( params[:page_main] ).per(@page_num) + elsif !params[:tag_id].blank? + @archive_files = ArchiveFile.can_display.where(:category_id.in => @archive_file_category_ids,:tagged_ids.in => params[:tag_id]).desc( :is_top ).default_sort(params[:sort]).page( params[:page_main] ).per(@page_num) + else + @archive_files = ArchiveFile.can_display.where(:category_id.in => @archive_file_category_ids).desc( :is_top ).default_sort(params[:sort]).page( params[:page_main] ).per(@page_num) + end + + elsif @widget_style == "2" + + @archive_file_datas = Array.new + + @archive_file_categorys.each do |afcg| + + if !params[:category_id].blank? && !params[:tag_id].blank? + @archive_files = ArchiveFile.can_display.where(:category_id.in => [afcg.id], :tagged_ids.in => params[:tag_id]).desc( :is_top ).default_sort(params[:sort]).limit(@page_num) + elsif !params[:category_id].blank? + @archive_files = ArchiveFile.can_display.where(:category_id.in => [afcg.id]).desc( :is_top ).default_sort(params[:sort]).limit(@page_num) + elsif !params[:tag_id].blank? + @archive_files = ArchiveFile.can_display.where(:category_id => afcg.id, :tagged_ids.in => params[:tag_id]).desc( :is_top ).default_sort(params[:sort]).limit(@page_num) + else + @archive_files = ArchiveFile.can_display.where(:category_id => afcg.id).desc( :is_top ).default_sort(params[:sort]).limit(@page_num) + end + + archive_file_datas = Array.new + + @archive_files.each do |af| + + archive_file_multiple_datas = Array.new + + af.archive_file_multiples.asc(:sort_number).each do | afile | + archive_file_multiple_datas << { + "file_title" => (!afile.file_title.blank? ? afile.file_title : t('archive.download') ) , + "url" => afile.file.url, + "icon" => af.get_file_icon(afile.file.url) + } if afile.file.file and afile.choose_lang_display(I18n.locale.to_s) + end + + archive_file_datas << { "title" => af.title, "is_hot" => (!af.is_hot.blank? ? '1' : ''), "archive_file_multiples" => archive_file_multiple_datas } if !af.archive_file_multiples.blank? and !archive_file_multiple_datas.blank? + end + + @archive_file_datas << { "title" => afcg.title, "archive_files" => archive_file_datas } if !@archive_files.blank? + + end + + end + + if params[:sort] @archive_files = get_sorted_and_filtered('archive_file', nil, @archive_files) end diff --git a/vendor/built_in_modules/archive/app/models/archive_file.rb b/vendor/built_in_modules/archive/app/models/archive_file.rb index 5701d3b1..3e2600bc 100644 --- a/vendor/built_in_modules/archive/app/models/archive_file.rb +++ b/vendor/built_in_modules/archive/app/models/archive_file.rb @@ -1,22 +1,25 @@ # encoding: utf-8 - class ArchiveFile include Mongoid::Document include Mongoid::Timestamps include Mongoid::MultiParameterAttributes include Mongoid::Sortable + include Sunspot::Mongo + include OrbitCategory::Categorizable + include OrbitModel::LanguageRestrict include OrbitModel::Status + include OrbitModel::TimeFrame include OrbitTag::Taggable - BelongsToCategory = :archive_file_category + # BelongsToCategory = :archive_file_category - PAYMENT_TYPES = @site_valid_locales + # PAYMENT_TYPES = @site_valid_locales field :title, localize: true field :create_user_id - field :update_user_id + field :update_user_id, :class_name => "User" # belongs_to :archive_file_category @@ -31,12 +34,13 @@ class ArchiveFile # searchable do # text :titles do # title_translations.to_a.collect{|t| t[1]} - # end +# end # boolean :frontend_search do # !is_hidden # end # end + def self.search( category_id = nil ) diff --git a/vendor/built_in_modules/archive/app/models/archive_file_category.rb b/vendor/built_in_modules/archive/app/models/archive_file_category.rb index 9942c4da..97fa3900 100644 --- a/vendor/built_in_modules/archive/app/models/archive_file_category.rb +++ b/vendor/built_in_modules/archive/app/models/archive_file_category.rb @@ -4,9 +4,8 @@ class ArchiveFileCategory include Mongoid::Document include Mongoid::Timestamps include OrbitCoreLib::ObjectAuthable - include OrbitCoreLib::ObjectDisable - include Sunspot::Mongo - # include Mongoid::MultiParameterAttributes + include OrbitCoreLib::ObjectDisable + APP_NAME = 'Archive' ObjectAuthTitlesOptions = %W{submit_new fact_check} AfterObjectAuthUrl = '/panel/archive/back_end/archive_file_categorys' @@ -19,21 +18,6 @@ class ArchiveFileCategory has_many :archive_files validates :title, :at_least_one => true - - searchable do - text :titles do - title_translations.to_a.collect{|t| t[1]} - end - - boolean :frontend_search do - !disable - end - - text :files do - archive_files.can_display.collect{|t| t.title_translations.to_a.collect{|t| t[1]}} - end - - end def pp_object diff --git a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/_form.html.erb b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/_form.html.erb index 318ba6b5..69dad760 100644 --- a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/_form.html.erb +++ b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/_form.html.erb @@ -1,157 +1,196 @@ <% # encoding: utf-8 %> +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/fileupload" %> +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/bootstrap-fileupload" %> +<% end %> <%= f.error_messages %> - + +排序數 | -File | -File Name | -<%= t('呈現語系')%> | -- |
---|---|---|---|---|
-
- <%= hidden_field_tag 'archive_file_multiple_field_count', @archive_file.archive_file_multiples.count %>
- ADD/新增
-
- |
-
+ <%= hidden_field_tag 'archive_file_multiple_field_count', @archive_file.archive_file_multiples.count %> + <%= t(:add) %> +
-- | - | - | - | - | - |
---|
- | - | - | - | - |
---|