From 63d7810b353c411d9302ca03a7f6de6e97c60cc9 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Thu, 23 Feb 2012 15:48:23 +0800 Subject: [PATCH] Add isotope, categories for announcement page, sort for announcement --- app/assets/javascripts/jquery.isotope.min.js | 11 + app/assets/javascripts/new_admin.js | 1 + app/assets/javascripts/orbit-1.0.js | 16 +- app/assets/javascripts/page_edit.js | 2 +- app/assets/stylesheets/isotope.css | 109 ++++ app/assets/stylesheets/new_admin.css.erb | 1 + .../admin/module_apps_controller.rb | 1 + app/controllers/admin/pages_controller.rb | 1 + app/helpers/application_helper.rb | 11 + app/views/admin/dashboards/index.html.erb | 465 +++++++++++++++++- .../module_apps/reload_frontend_pages.js.erb | 3 +- app/views/admin/pages/_form.html.erb | 3 +- lib/parsers/parser_back_end.rb | 5 +- lib/parsers/parser_front_end.rb | 6 +- .../back_end/bulletins_controller.rb | 35 +- .../front_end/bulletins_controller.rb | 9 +- .../back_end/bulletins/_bulletins.html.erb | 36 ++ .../bulletins/_quick_edit_picture.html.erb | 2 +- .../back_end/bulletins/index.html.erb | 29 +- .../back_end/bulletins/index.js.erb | 1 + 20 files changed, 704 insertions(+), 43 deletions(-) create mode 100644 app/assets/javascripts/jquery.isotope.min.js create mode 100644 app/assets/stylesheets/isotope.css create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletins.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.js.erb diff --git a/app/assets/javascripts/jquery.isotope.min.js b/app/assets/javascripts/jquery.isotope.min.js new file mode 100644 index 00000000..1c280990 --- /dev/null +++ b/app/assets/javascripts/jquery.isotope.min.js @@ -0,0 +1,11 @@ +/** + * Isotope v1.5.11 + * An exquisite jQuery plugin for magical layouts + * http://isotope.metafizzy.co + * + * Commercial use requires one-time license fee + * http://metafizzy.co/#licenses + * + * Copyright 2012 David DeSandro / Metafizzy + */ +(function(a,b,c){var d=a.document,e=a.Modernizr,f=function(a){return a.charAt(0).toUpperCase()+a.slice(1)},g="Moz Webkit O Ms".split(" "),h=function(a){var b=d.documentElement.style,c;if(typeof b[a]=="string")return a;a=f(a);for(var e=0,h=g.length;e"+d+"{#modernizr{height:3px}}"+"").appendTo("head"),f=b('
').appendTo("html");a=f.height()===3,f.remove(),e.remove()}return a},csstransitions:function(){return!!j}},l;if(e)for(l in k)e.hasOwnProperty(l)||e.addTest(l,k[l]);else{e=a.Modernizr={_version:"1.6ish: miniModernizr for Isotope"};var m=" ",n;for(l in k)n=k[l](),e[l]=n,m+=" "+(n?"":"no-")+l;b("html").addClass(m)}if(e.csstransforms){var o=e.csstransforms3d?{translate:function(a){return"translate3d("+a[0]+"px, "+a[1]+"px, 0) "},scale:function(a){return"scale3d("+a+", "+a+", 1) "}}:{translate:function(a){return"translate("+a[0]+"px, "+a[1]+"px) "},scale:function(a){return"scale("+a+") "}},p=function(a,c,d){var e=b.data(a,"isoTransform")||{},f={},g,h={},j;f[c]=d,b.extend(e,f);for(g in e)j=e[g],h[g]=o[g](j);var k=h.translate||"",l=h.scale||"",m=k+l;b.data(a,"isoTransform",e),a.style[i]=m};b.cssNumber.scale=!0,b.cssHooks.scale={set:function(a,b){p(a,"scale",b)},get:function(a,c){var d=b.data(a,"isoTransform");return d&&d.scale?d.scale:1}},b.fx.step.scale=function(a){b.cssHooks.scale.set(a.elem,a.now+a.unit)},b.cssNumber.translate=!0,b.cssHooks.translate={set:function(a,b){p(a,"translate",b)},get:function(a,c){var d=b.data(a,"isoTransform");return d&&d.translate?d.translate:[0,0]}}}var q,r;e.csstransitions&&(q={WebkitTransitionProperty:"webkitTransitionEnd",MozTransitionProperty:"transitionend",OTransitionProperty:"oTransitionEnd",transitionProperty:"transitionEnd"}[j],r=h("transitionDuration"));var s=b.event,t;s.special.smartresize={setup:function(){b(this).bind("resize",s.special.smartresize.handler)},teardown:function(){b(this).unbind("resize",s.special.smartresize.handler)},handler:function(a,b){var c=this,d=arguments;a.type="smartresize",t&&clearTimeout(t),t=setTimeout(function(){jQuery.event.handle.apply(c,d)},b==="execAsap"?0:100)}},b.fn.smartresize=function(a){return a?this.bind("smartresize",a):this.trigger("smartresize",["execAsap"])},b.Isotope=function(a,c,d){this.element=b(c),this._create(a),this._init(d)};var u=["overflow","position","width","height"],v=b(a);b.Isotope.settings={resizable:!0,layoutMode:"masonry",containerClass:"isotope",itemClass:"isotope-item",hiddenClass:"isotope-hidden",hiddenStyle:{opacity:0,scale:.001},visibleStyle:{opacity:1,scale:1},animationEngine:"best-available",animationOptions:{queue:!1,duration:800},sortBy:"original-order",sortAscending:!0,resizesContainer:!0,transformsEnabled:!b.browser.opera,itemPositionDataEnabled:!1},b.Isotope.prototype={_create:function(a){this.options=b.extend({},b.Isotope.settings,a),this.styleQueue=[],this.elemCount=0;var c=this.element[0].style;this.originalStyle={};for(var d=0,e=u.length;dg?1:f0&&(i=function(a,b){b.$el[d](b.style,f).one(q,k)},j=!1)}}b.each(this.styleQueue,i),j&&k(),this.styleQueue=[]},resize:function(){this["_"+this.options.layoutMode+"ResizeChanged"]()&&this.reLayout()},reLayout:function(a){this["_"+this.options.layoutMode+"Reset"](),this.layout(this.$filteredAtoms,a)},addItems:function(a,b){var c=this._getAtoms(a);this.$allAtoms=this.$allAtoms.add(c),b&&b(c)},insert:function(a,b){this.element.append(a);var c=this;this.addItems(a,function(a){var d=c._filter(a);c._addHideAppended(d),c._sort(),c.reLayout(),c._revealAppended(d,b)})},appended:function(a,b){var c=this;this.addItems(a,function(a){c._addHideAppended(a),c.layout(a),c._revealAppended(a,b)})},_addHideAppended:function(a){this.$filteredAtoms=this.$filteredAtoms.add(a),a.addClass("no-transition"),this._isInserting=!0,this.styleQueue.push({$el:a,style:this.options.hiddenStyle})},_revealAppended:function(a,b){var c=this;setTimeout(function(){a.removeClass("no-transition"),c.styleQueue.push({$el:a,style:c.options.visibleStyle}),c._isInserting=!1,c._processStyleQueue(a,b)},10)},reloadItems:function(){this.$allAtoms=this._getAtoms(this.element.children())},remove:function(a,b){var c=this,d=function(){c.$allAtoms=c.$allAtoms.not(a),a.remove()};a.filter(":not(."+this.options.hiddenClass+")").length?(this.styleQueue.push({$el:a,style:this.options.hiddenStyle}),this.$filteredAtoms=this.$filteredAtoms.not(a),this._sort(),this.reLayout(d,b)):(d(),b&&b.call(this.element))},shuffle:function(a){this.updateSortData(this.$allAtoms),this.options.sortBy="random",this._sort(),this.reLayout(a)},destroy:function(){var a=this.usingTransforms,b=this.options;this.$allAtoms.removeClass(b.hiddenClass+" "+b.itemClass).each(function(){var b=this.style;b.position="",b.top="",b.left="",b.opacity="",a&&(b[i]="")});var c=this.element[0].style;for(var d=0,e=u.length;dd&&(e.x=0,e.y=e.height),c._pushPosition(a,e.x,e.y),e.height=Math.max(e.y+g,e.height),e.x+=f})},_fitRowsGetContainerSize:function(){return{height:this.fitRows.height}},_fitRowsResizeChanged:function(){return!0},_cellsByRowReset:function(){this.cellsByRow={index:0},this._getSegments(),this._getSegments(!0)},_cellsByRowLayout:function(a){var c=this,d=this.cellsByRow;a.each(function(){var a=b(this),e=d.index%d.cols,f=Math.floor(d.index/d.cols),g=Math.round((e+.5)*d.columnWidth-a.outerWidth(!0)/2),h=Math.round((f+.5)*d.rowHeight-a.outerHeight(!0)/2);c._pushPosition(a,g,h),d.index++})},_cellsByRowGetContainerSize:function(){return{height:Math.ceil(this.$filteredAtoms.length/this.cellsByRow.cols)*this.cellsByRow.rowHeight+this.offset.top}},_cellsByRowResizeChanged:function(){return this._checkIfSegmentsChanged()},_straightDownReset:function(){this.straightDown={y:0}},_straightDownLayout:function(a){var c=this;a.each(function(a){var d=b(this);c._pushPosition(d,0,c.straightDown.y),c.straightDown.y+=d.outerHeight(!0)})},_straightDownGetContainerSize:function(){return{height:this.straightDown.y}},_straightDownResizeChanged:function(){return!0},_masonryHorizontalReset:function(){this.masonryHorizontal={},this._getSegments(!0);var a=this.masonryHorizontal.rows;this.masonryHorizontal.rowXs=[];while(a--)this.masonryHorizontal.rowXs.push(0)},_masonryHorizontalLayout:function(a){var c=this,d=c.masonryHorizontal;a.each(function(){var a=b(this),e=Math.ceil(a.outerHeight(!0)/d.rowHeight);e=Math.min(e,d.rows);if(e===1)c._masonryHorizontalPlaceBrick(a,d.rowXs);else{var f=d.rows+1-e,g=[],h,i;for(i=0;id&&(e.x=e.width,e.y=0),c._pushPosition(a,e.x,e.y),e.width=Math.max(e.x+f,e.width),e.y+=g})},_fitColumnsGetContainerSize:function(){return{width:this.fitColumns.width}},_fitColumnsResizeChanged:function(){return!0},_cellsByColumnReset:function(){this.cellsByColumn={index:0},this._getSegments(),this._getSegments(!0)},_cellsByColumnLayout:function(a){var c=this,d=this.cellsByColumn;a.each(function(){var a=b(this),e=Math.floor(d.index/d.rows),f=d.index%d.rows,g=Math.round((e+.5)*d.columnWidth-a.outerWidth(!0)/2),h=Math.round((f+.5)*d.rowHeight-a.outerHeight(!0)/2);c._pushPosition(a,g,h),d.index++})},_cellsByColumnGetContainerSize:function(){return{width:Math.ceil(this.$filteredAtoms.length/this.cellsByColumn.rows)*this.cellsByColumn.columnWidth}},_cellsByColumnResizeChanged:function(){return this._checkIfSegmentsChanged(!0)},_straightAcrossReset:function(){this.straightAcross={x:0}},_straightAcrossLayout:function(a){var c=this;a.each(function(a){var d=b(this);c._pushPosition(d,c.straightAcross.x,0),c.straightAcross.x+=d.outerWidth(!0)})},_straightAcrossGetContainerSize:function(){return{width:this.straightAcross.x}},_straightAcrossResizeChanged:function(){return!0}},b.fn.imagesLoaded=function(a){function i(a){a.target.src!==f&&b.inArray(this,g)===-1&&(g.push(this),--e<=0&&(setTimeout(h),d.unbind(".imagesLoaded",i)))}function h(){a.call(c,d)}var c=this,d=c.find("img").add(c.filter("img")),e=d.length,f="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==",g=[];e||h(),d.bind("load.imagesLoaded error.imagesLoaded",i).each(function(){var a=this.src;this.src=f,this.src=a});return c};var w=function(b){a.console&&a.console.error(b)};b.fn.isotope=function(a,c){if(typeof a=="string"){var d=Array.prototype.slice.call(arguments,1);this.each(function(){var c=b.data(this,"isotope");if(!c)w("cannot call methods on isotope prior to initialization; attempted to call method '"+a+"'");else{if(!b.isFunction(c[a])||a.charAt(0)==="_"){w("no such method '"+a+"' for isotope instance");return}c[a].apply(c,d)}})}else this.each(function(){var d=b.data(this,"isotope");d?(d.option(a),d._init(c)):b.data(this,"isotope",new b.Isotope(a,this,c))});return this}})(window,jQuery); diff --git a/app/assets/javascripts/new_admin.js b/app/assets/javascripts/new_admin.js index 002715b5..cd15fc39 100644 --- a/app/assets/javascripts/new_admin.js +++ b/app/assets/javascripts/new_admin.js @@ -7,6 +7,7 @@ //= require jquery //= require jquery_ujs //= require bootstrap +//= require jquery.isotope.min //= require jquery.tinyscrollbar.min //= require orbit-1.0 //= require tinymce-jquery \ No newline at end of file diff --git a/app/assets/javascripts/orbit-1.0.js b/app/assets/javascripts/orbit-1.0.js index b9f03c95..44183d11 100644 --- a/app/assets/javascripts/orbit-1.0.js +++ b/app/assets/javascripts/orbit-1.0.js @@ -46,15 +46,25 @@ $(document).ready(function(){ $(this).parents('tr').next('.qe-block').find('#qe-' + $(this).attr('rel')).toggleClass('hide'); }); + $(document).on('click', '.sort-header > .sort', function() { + $.getScript($(this).attr('rel')); + }); + /*tinyscrollbar&windows-Size*/ resize(); $('#main-sidebar').css("height", viewportheight-40); - //$('#content-wrap .viewport').css("height", viewportheight-44); - //$('#content-wrap').css("width", viewportwidth-186); $('#main-sidebar .viewport').css("height", viewportheight-40); $('.post-title').css("width", viewportwidth-495); $('#main-sidebar').tinyscrollbar(); - $('#main-sidebar').tinyscrollbar({ size:(viewportheight-44)}); + $('.detal-list').tinyscrollbar(); + $('#main-sidebar').tinyscrollbar({size:(viewportheight-44)}); + + /*isotope*/ + var $container = $('#isotope'); + $container.isotope({ + itemSelector : '.item', + layoutMode : 'masonry', + }); }); diff --git a/app/assets/javascripts/page_edit.js b/app/assets/javascripts/page_edit.js index e151b4bf..31a7d600 100644 --- a/app/assets/javascripts/page_edit.js +++ b/app/assets/javascripts/page_edit.js @@ -2,7 +2,7 @@ $("div.editable").live("mouseenter mouseleave", function (event) { $(this).children('.edit_link').toggle(); }); -$("#page_design_id").live('change', function() { +$("#page_design").live('change', function() { $.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_themes'); }); diff --git a/app/assets/stylesheets/isotope.css b/app/assets/stylesheets/isotope.css new file mode 100644 index 00000000..1d659c5e --- /dev/null +++ b/app/assets/stylesheets/isotope.css @@ -0,0 +1,109 @@ +#isotope { + margin-top: 2px; + background-color:#f4f4f4; +} +.isotope-item { + z-index: 2; +} + +.isotope-hidden.isotope-item { + pointer-events: none; + z-index: 1; +} + +/**** Isotope CSS3 transitions ****/ + +.isotope, +.isotope .isotope-item { + -webkit-transition-duration: 0.8s; + -moz-transition-duration: 0.8s; + -o-transition-duration: 0.8s; + transition-duration: 0.8s; +} + +.isotope { + -webkit-transition-property: height, width; + -moz-transition-property: height, width; + -o-transition-property: height, width; + transition-property: height, width; +} + +.isotope .isotope-item { + -webkit-transition-property: -webkit-transform, opacity; + -moz-transition-property: -moz-transform, opacity; + -o-transition-property: top, left, opacity; + transition-property: transform, opacity; +} + +/**** disabling Isotope CSS3 transitions ****/ + +.isotope.no-transition, +.isotope.no-transition .isotope-item, +.isotope .isotope-item.no-transition { + -webkit-transition-duration: 0s; + -moz-transition-duration: 0s; + -o-transition-duration: 0s; + transition-duration: 0s; +} +.w-a { + width: 388px; +} +.w-b { + width: 802px; +} +.h-a { + height: 315px; +} +.h-b { + height: 699px; +} +.item { + margin: 5px 0 15px 15px; +} +.item h3 { + margin: 5px 0; +} +.item h3 [class^="icons-"] { + margin: 3px 5px 0 3px; +} +.item .detail { + padding: 5px; + border: 1px solid rgba(0, 0, 0, 0.1); + background-color: #FFFFFF; + border-radius: 5px; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + box-shadow: 0 3px 3px rgba(0, 0, 0, 0.1); + -webkit-box-shadow: 0 3px 3px rgba(0, 0, 0, 0.1); + -moz-box-shadow: 0 3px 3px rgba(0, 0, 0, 0.1); +} +.item .detail .totle { + font-size: 50px; + padding:10px 5px 20px 0; + margin: 0px; + text-align: right; + border-bottom:1px solid #d9d9d9; +} +.item .detail .totle span { + display: block; + font-size:18px; + color: #333; + padding-left: 5px; + text-align:left; +} +.item .detail .table th, .item .detail .table td { + border-top: none; + border-bottom: 1px solid #DDDDDD; +} +.item .detail .table tr td:first-child { + color: #666;; +} +.item .detail .table tr td:last-child { + text-align:right; +} +.item .h-a .my_scroll .viewport { + height: 248px; +} +.item .h-b .my_scroll .viewport { + height: 632px; +} \ No newline at end of file diff --git a/app/assets/stylesheets/new_admin.css.erb b/app/assets/stylesheets/new_admin.css.erb index 589b95b9..d81761bc 100644 --- a/app/assets/stylesheets/new_admin.css.erb +++ b/app/assets/stylesheets/new_admin.css.erb @@ -11,4 +11,5 @@ *= require widget *= require style *= require scroll_style + *= require isotope */ \ No newline at end of file diff --git a/app/controllers/admin/module_apps_controller.rb b/app/controllers/admin/module_apps_controller.rb index 56c2523f..e80d4023 100644 --- a/app/controllers/admin/module_apps_controller.rb +++ b/app/controllers/admin/module_apps_controller.rb @@ -11,6 +11,7 @@ class Admin::ModuleAppsController < ApplicationController def reload_frontend_pages @module_app = ModuleApp.find(params[:id]) + @categories = @module_app.key.eql?('announcement') ? BulletinCategory.all : nil respond_to do |format| format.js {} end diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index 45994ebd..13909a27 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -31,6 +31,7 @@ class Admin::PagesController < ApplicationController @designs = Design.all.entries @design = @item.design ? @item.design : @designs.first @app_frontend_urls = @item.module_app.app_pages if @item.module_app + @categories = BulletinCategory.all if @item.module_app && @item.module_app.key.eql?('announcement') end def create diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ad2309f9..237a0bdd 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -73,6 +73,17 @@ module ApplicationHelper {:sort => column, :direction => direction} end + def is_sort_active?(name) + res = '' + res << ' select' if params[:sort].eql?(name) + res << ' active' if params[:sort].eql?(name) && params[:direction].eql?('asc') + res + end + + def is_sort?(name) + ' web-symbol' if params[:sort].eql?(name) + end + def add_filter(param_name, value) filter = params[:filter] rescue nil if filter && filter.has_key(param_name) diff --git a/app/views/admin/dashboards/index.html.erb b/app/views/admin/dashboards/index.html.erb index f690d262..d038b63d 100644 --- a/app/views/admin/dashboards/index.html.erb +++ b/app/views/admin/dashboards/index.html.erb @@ -1 +1,464 @@ -Dashboard \ No newline at end of file +
+
+

Member

+
+

Quantity9,517

+
+
+
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
University2,304
Master783
Doctor45
Staff62
Teacher52
Professor20
Assistant Professor41
Substitute teacher37
Lecturer41
Part-time teacher20
+
+
+
+
+
+
+

Content

+
+

Quantity9,517

+
+
+
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
University2,304
Master783
Doctor45
Staff62
Teacher52
Professor20
Assistant Professor41
Substitute teacher37
Lecturer41
Part-time teacher20
+
+
+
+
+
+
+

Asset

+
+

Quantity9,517

+
+
+
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
University2,304
Master783
Doctor45
Staff62
Teacher52
Professor20
Assistant Professor41
Substitute teacher37
Lecturer41
Part-time teacher20
+
+
+
+
+
+
+

Traffic

+
+

Quantity9,517

+
+
+
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
University2,304
Master783
Doctor45
Staff62
Teacher52
Professor20
Assistant Professor41
Substitute teacher37
Lecturer41
Part-time teacher20
Staff62
Teacher52
Professor20
Assistant Professor41
Substitute teacher37
Lecturer41
Part-time teacher20
Staff62
Teacher52
Professor20
Assistant Professor41
Substitute teacher37
Lecturer41
Part-time teacher20
Staff62
Teacher52
Professor20
Assistant Professor41
Substitute teacher37
Lecturer41
Part-time teacher20
+
+
+
+
+
+
+

Site info

+
+

Quantity9,517

+
+
+
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
University2,304
Master783
Doctor45
Staff62
Teacher52
Professor20
Assistant Professor41
Substitute teacher37
Lecturer41
Part-time teacher20
+
+
+
+
+
+
+

Connection

+
+

Quantity9,517

+
+
+
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
University2,304
Master783
Doctor45
Staff62
Teacher52
Professor20
Assistant Professor41
Substitute teacher37
Lecturer41
Part-time teacher20
+
+
+
+
+
+
\ No newline at end of file diff --git a/app/views/admin/module_apps/reload_frontend_pages.js.erb b/app/views/admin/module_apps/reload_frontend_pages.js.erb index d9589cc9..3feb17cf 100644 --- a/app/views/admin/module_apps/reload_frontend_pages.js.erb +++ b/app/views/admin/module_apps/reload_frontend_pages.js.erb @@ -1 +1,2 @@ -$('#app_page_url').html("<%= escape_javascript(select 'page','app_frontend_url', @module_app.app_pages) %>"); \ No newline at end of file +$('#app_page_url').html("<%= escape_javascript(select 'page', 'app_frontend_url', @module_app.app_pages) %>"); +$('#app_page_category').html("<%= escape_javascript(select 'page', 'category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}) if @categories %>"); \ No newline at end of file diff --git a/app/views/admin/pages/_form.html.erb b/app/views/admin/pages/_form.html.erb index c0cb433d..a45dbbd2 100644 --- a/app/views/admin/pages/_form.html.erb +++ b/app/views/admin/pages/_form.html.erb @@ -26,7 +26,8 @@

<%= t('admin.module_app') %> <%= render :partial => "admin/module_apps/app_selector", :locals => { :f => f } %> - <%= select('page','app_frontend_url', @app_frontend_urls ) rescue ''%> + <%= select('page','app_frontend_url', @app_frontend_urls ) rescue ''%> + <%= select('page','category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]} ) rescue ''%>

<%= f.label :is_published, "#{t('admin.is_published')} ?" %> diff --git a/lib/parsers/parser_back_end.rb b/lib/parsers/parser_back_end.rb index dddc27a9..10d9d4a2 100644 --- a/lib/parsers/parser_back_end.rb +++ b/lib/parsers/parser_back_end.rb @@ -98,8 +98,9 @@ module ParserBackEnd c.define_tag 'content' do |tag| ret = '' if (tag.attributes["main"] == "true" && !page.module_app.nil?) - # ret << "

" - ret << "
" + ret << "
" else part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } ret << "
" diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb index 2b9f3a4f..2ddbb84c 100644 --- a/lib/parsers/parser_front_end.rb +++ b/lib/parsers/parser_front_end.rb @@ -76,6 +76,7 @@ module ParserFrontEnd res << "" res << "" res << "" + res << "" res << "" res << "" page.design.javascripts.each do |js| @@ -124,8 +125,9 @@ module ParserFrontEnd if (tag.attributes["main"] == "true" && !page.module_app.nil?) ret << "
" - ret << "?inner=true&page_id=#{page.id}'>
" + ret << "?inner=true&page_id=#{page.id}" + ret << "&bulletin_category_id=#{page.category}" if page.category + ret << "'>
" else part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } rescue nil case part.kind diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index 20870a7c..919fc387 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -12,7 +12,9 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController # @bulletins = Bulletin.where("bulletin_category_id" => params[:bulletin_category_id]).desc("postdate") if params[:bulletin_category_id] - @bulletins = Bulletin.search(params[:search], params[:category_id]).order_by([params[:sort], params[:direction]]) + # @bulletins = Bulletin.search(params[:search], params[:category_id]) + # @bulletins = Bulletin.all.order_by([params[:sort], params[:direction]]) + @bulletins = params[:sort] ? get_sorted_bulletins : Bulletin.all @bulletin_categories = BulletinCategory.all module_app = ModuleApp.first(:conditions => {:key => 'announcement'}) @@ -20,6 +22,7 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController respond_to do |format| format.html # index.html.erb + format.js format.xml { render :xml => @bulletins } end end @@ -145,6 +148,36 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController def get_categorys(id = nil) @bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true)) end + + def get_sorted_bulletins + bulletins = Bulletin.all + case params[:sort] + when 'postdate', 'deadline' + bulletins.order_by([params[:sort], params[:direction]]) + when 'category' + category_ids = bulletins.distinct(:bulletin_category_id) + categories = BulletinCategory.find(category_ids) if category_ids + if categories + h = Hash.new + categories.each { |category| h[category.i18n_variable[I18n.locale]] = category.id } + sorted = params[:direction].eql?('asc') ? h.sort : h.sort.reverse! + sorted_categorys = sorted.collect {|a| bulletins.where(:bulletin_category_id => a[1]).entries } + sorted_categorys.flatten + else + nil + end + when 'title' + h = Hash.new + bulletins.each { |bulletin| h[bulletin.title[I18n.locale]] = bulletin } + sorted = params[:direction].eql?('asc') ? h.sort : h.sort.reverse! + sorted.collect {|a| a[1] } + when 'status' + # a << bulletins.order_by(:is_top, params[:direction]).order_by + # a << bulletins.where(:is_hot => true).entries + # a << bulletins.where(:is_hidden => true).entries + # a.flatten.uniq + end + end end diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb index 28a3ec5b..eb429e4d 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb @@ -10,9 +10,12 @@ class Panel::Announcement::FrontEnd::BulletinsController < ObitWidgetController def index - date_now = Time.now - - @bulletins = Bulletin.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(1) + date_now = Time.now + if params[:bulletin_category_id] + @bulletins = Bulletin.where(:bulletin_category_id => params[:bulletin_category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(1) + else + @bulletins = Bulletin.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(1) + end get_categorys end diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletins.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletins.html.erb new file mode 100644 index 00000000..e5559f46 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletins.html.erb @@ -0,0 +1,36 @@ + + + + + + + + <%= link_to (t('bulletin.status') + content_tag(:b, nil)), panel_announcement_back_end_bulletins_path(sortable('status')) %> + + + <%= t('bulletin.category') %> + <%= content_tag(:b, nil, :class => is_sort?('category')) %> + + + <%= t('bulletin.title') %> + <%= content_tag(:b, nil, :class => is_sort?('title')) %> + + + <%= t('bulletin.start_date') %> + <%= content_tag(:b, nil, :class => is_sort?('postdate')) %> + + + <%= t('bulletin.end_date') %> + <%= content_tag(:b, nil, :class => is_sort?('deadline')) %> + + + <%= link_to (t('bulletin.tags') + content_tag(:b, nil)), panel_announcement_back_end_bulletins_path(sortable('tags')) %> + + + <%= link_to (t('bulletin.last_modified') + content_tag(:b, nil)), panel_announcement_back_end_bulletins_path(sortable('update_user_id')) %> + + + + + <%= render :partial => 'bulletin', :collection => @bulletins %> + \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_picture.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_picture.html.erb index c2503fde..6e7c656a 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_picture.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_picture.html.erb @@ -3,7 +3,7 @@
- +