From 72efdbd742d4f3ac8a910bd5c817cf5c74570ba5 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Thu, 19 Apr 2012 11:50:54 +0800 Subject: [PATCH 01/12] changes before Chirs and Ray's trip --- Gemfile.lock | 4 + app/assets/javascripts/site_editor.js | 3 +- app/assets/stylesheets/list.css | 300 +++++++++--------- app/assets/stylesheets/new_admin.css.erb | 2 +- app/assets/stylesheets/sidebar.css.erb | 56 +++- app/assets/stylesheets/site_items.css.erb | 4 +- app/assets/stylesheets/style.css.erb | 24 ++ app/assets/stylesheets/widgets.css | 148 +++++++++ app/helpers/admin/item_helper.rb | 14 +- app/views/admin/ad_images/_form.html.erb | 16 +- .../admin/items/_site_map_left_bar.html.erb | 2 +- app/views/layouts/admin.html.erb | 74 ++--- app/views/layouts/site_editor.html.erb | 77 ++--- 13 files changed, 473 insertions(+), 251 deletions(-) create mode 100644 app/assets/stylesheets/widgets.css diff --git a/Gemfile.lock b/Gemfile.lock index 71742974..52453b6a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -97,6 +97,7 @@ GEM railties (~> 3.0) thor (~> 0.14) json (1.6.5) + libv8 (3.3.10.4) linecache19 (0.5.12) ruby_core_source (>= 0.1.4) mail (2.3.3) @@ -209,6 +210,8 @@ GEM rack (~> 1.0) tilt (~> 1.1, != 1.3.0) subexec (0.2.1) + therubyracer (0.9.10) + libv8 (~> 3.3.10) thor (0.14.6) tilt (1.3.3) tinymce-rails (3.4.8) @@ -269,6 +272,7 @@ DEPENDENCIES sinatra spork sprockets + therubyracer tinymce-rails uglifier watchr diff --git a/app/assets/javascripts/site_editor.js b/app/assets/javascripts/site_editor.js index 98405564..1eb5e3f1 100644 --- a/app/assets/javascripts/site_editor.js +++ b/app/assets/javascripts/site_editor.js @@ -7,4 +7,5 @@ //= require jquery //= require jquery_ujs //= require page_edit -//= require side_bar_history \ No newline at end of file +//= require side_bar_history +//= require new_admin \ No newline at end of file diff --git a/app/assets/stylesheets/list.css b/app/assets/stylesheets/list.css index 11f17a55..c7785778 100644 --- a/app/assets/stylesheets/list.css +++ b/app/assets/stylesheets/list.css @@ -1,151 +1,151 @@ -.list-remove { - position: relative; - top: 2px; - left: 2px; -} -.table th.select { - border-bottom:2px solid #0088CC; -} -.main-list { - margin-bottom: 0; -} -.main-wrap>.main-list thead th { - background-color: transparent; - border-right: medium none; -} -.main-list thead th:last-child { - border-right: none; -} -.main-list .span1 { - min-width: 32px; -} -.main-list .span7 { - min-width: 300px; -} -.main-list .nav-pills > li > a { - border-radius: 5px 5px 5px 5px; - margin: 2px; - padding:5px -} -.main-list tbody .quick-edit { - position:relative; - height:20px; -} -.main-list tbody .quick-edit .nav { - /*left: -55px;*/ - position: absolute; - /*top: -3px;*/ - width: 350px; - left: -8px; -} -.main-list td { - background-color: #FFFFFF; - border-bottom: 1px solid #DDDDDD; - border-top: medium none; -} -.main-list .nav { - margin-top: 0; - margin-bottom: 3px; -} -.main-list tr.with_action:hover .hide { - display:block !important; -} -.main-list .label-group { - position: relative; - height: 40px; -} -.main-list .label-td { - background-color: rgba(255, 255, 255, 1); - height: 40px; - overflow: hidden; - position: absolute; - width: 100%; - left: 0; - z-index: 1; -} -.main-list .label-td:hover { - height: auto; - text-align: center; - padding: 5px 5px 8px; - left: -6px; - top: -6px; - border: 1px solid rgba(0, 0, 0, 0.2); - box-shadow: 0px 5px 10px rgba(0,0,0,0.2); - -moz-box-shadow: 0px 5px 10px rgba(0,0,0,0.2); - -webkit-box-shadow: 0px 5px 10px rgba(0,0,0,0.2); - border-radius: 3px; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - z-index: 5; -} -.table-label { - background-color: #F2F2F2; - position: relative; -} -.table-label .main-list thead th { - background-color: #F2F2F2; - border-right: 1px solid #DDDDDD; - border-top: 1px solid #DDDDDD !important; -} -.route-group .route { - padding: 0; -} -.route-group .route .breadcrumb { - border-width: 0!important; -} -.qe-block td { - height:auto; - padding: 0; -} -.qe-block .table td, .qe-block .table th { - padding: 8px; -} -.qe-block .form-horizontal { - margin-bottom: 0; -} -.qe-block .form-actions { - margin-bottom: 0; -} -legend { - font-size: 15px; - line-height: 30px; - margin-bottom: 15px; - padding-bottom: 5px; -} -.upload-picture { - margin-left: 20px; -} -.subnav { - -moz-border-radius: 0; - -webkit-border-radius: 0; - border-radius: 0; - border-left: none; - border-right: none; - position: fixed; - top: 30px; - z-index: 50; -} -.subnav .nav > li:first-child > a, .subnav .nav > li:first-child > a:hover { - -moz-border-radius: 0; - -webkit-border-radius: 0; - border-radius: 0; -} -.dropdown-menu.tags { - max-width: none; -} -.dropdown-menu.tags .tags-cloud { - width: 300px; - padding:10px; -} -.dropdown-menu.tags .tags-cloud .active { - background-color: #0088CC; - color: #FFFFFF; -} -.dropdown-menu.tags .tags-cloud a { - display: inline-block; - margin-bottom: 3px; -} -.dropdown-menu.tags li:last-child a { - display: block; - text-align:center; +.list-remove { + position: relative; + top: 2px; + left: 2px; +} +.table th.select { + border-bottom:2px solid #0088CC; +} +.main-list { + margin-bottom: 0; +} +.main-wrap>.main-list thead th { + background-color: transparent; + border-right: medium none; +} +.main-list thead th:last-child { + border-right: none; +} +.main-list .span1 { + min-width: 32px; +} +.main-list .span7 { + min-width: 300px; +} +.main-list .nav-pills > li > a { + border-radius: 5px 5px 5px 5px; + margin: 2px; + padding:5px +} +.main-list tbody .quick-edit { + position:relative; + height:20px; +} +.main-list tbody .quick-edit .nav { + /*left: -55px;*/ + position: absolute; + /*top: -3px;*/ + width: 350px; + left: -8px; +} +.main-list td { + background-color: #FFFFFF; + border-bottom: 1px solid #DDDDDD; + border-top: medium none; +} +.main-list .nav { + margin-top: 0; + margin-bottom: 3px; +} +.main-list tr.with_action:hover .hide { + display:block !important; +} +.main-list .label-group { + position: relative; + height: 40px; +} +.main-list .label-td { + background-color: rgba(255, 255, 255, 1); + height: 40px; + overflow: hidden; + position: absolute; + width: 100%; + left: 0; + z-index: 1; +} +.main-list .label-td:hover { + height: auto; + text-align: center; + padding: 5px 5px 8px; + left: -6px; + top: -6px; + border: 1px solid rgba(0, 0, 0, 0.2); + box-shadow: 0px 5px 10px rgba(0,0,0,0.2); + -moz-box-shadow: 0px 5px 10px rgba(0,0,0,0.2); + -webkit-box-shadow: 0px 5px 10px rgba(0,0,0,0.2); + border-radius: 3px; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + z-index: 5; +} +.table-label { + background-color: #F2F2F2; + position: relative; +} +.table-label .main-list thead th { + background-color: #F2F2F2; + border-right: 1px solid #DDDDDD; + border-top: 1px solid #DDDDDD !important; +} +.route-group .route { + padding: 0; +} +.route-group .route .breadcrumb { + border-width: 0!important; +} +.qe-block td { + height:auto; + padding: 0; +} +.qe-block .table td, .qe-block .table th { + padding: 8px; +} +.qe-block .form-horizontal { + margin-bottom: 0; +} +.qe-block .form-actions { + margin-bottom: 0; +} +legend { + font-size: 15px; + line-height: 30px; + margin-bottom: 15px; + padding-bottom: 5px; +} +.upload-picture { + margin-left: 20px; +} +.subnav { + -moz-border-radius: 0; + -webkit-border-radius: 0; + border-radius: 0; + border-left: none; + border-right: none; + position: fixed; + top: 30px; + z-index: 50; +} +.subnav .nav > li:first-child > a, .subnav .nav > li:first-child > a:hover { + -moz-border-radius: 0; + -webkit-border-radius: 0; + border-radius: 0; +} +.dropdown-menu.tags { + max-width: none; +} +.dropdown-menu.tags .tags-cloud { + width: 300px; + padding:10px; +} +.dropdown-menu.tags .tags-cloud .active { + background-color: #0088CC; + color: #FFFFFF; +} +.dropdown-menu.tags .tags-cloud a { + display: inline-block; + margin-bottom: 3px; +} +.dropdown-menu.tags li:last-child a { + display: block; + text-align:center; } \ 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 d81761bc..9d687eb6 100644 --- a/app/assets/stylesheets/new_admin.css.erb +++ b/app/assets/stylesheets/new_admin.css.erb @@ -8,7 +8,7 @@ *= require bootstrap *= require bootstrap-orbit *= require list - *= require widget + *= require widgets *= require style *= require scroll_style *= require isotope diff --git a/app/assets/stylesheets/sidebar.css.erb b/app/assets/stylesheets/sidebar.css.erb index f5a5d572..79022cac 100644 --- a/app/assets/stylesheets/sidebar.css.erb +++ b/app/assets/stylesheets/sidebar.css.erb @@ -1,13 +1,9 @@ #back_sidebar { - background: url(<%= asset_path "75.png" %>) repeat scroll left top transparent; - box-shadow: 3px 0 4px #472A12; - border-right: 1px solid #121212; - height: 100%; left: 0; position: fixed; top: 0; - width: 220px; + width: 160px; } #back_sidebar h1 { @@ -91,4 +87,54 @@ } #sidebar .translations_setup { margin-top: 42px; +} + + +#main-sidebar{ + left:0; +} +#main-sidebar .list{ +} +#main-sidebar li{ + position:relative; +} +#main-sidebar li a{ + border-bottom: 1px solid #CCCCCC; + display: block; + padding: 10px 0 10px 10px; +} +#main-sidebar ul ul li a{ + padding: 10px 0 10px 20px; +} +#main-sidebar li:hover .quick-edit{ + display:block; +} +#main-sidebar .quick-edit{ + background: none repeat scroll 0 0 #FFFFFF; + border: 1px solid #DDDDDD; + border-radius: 5px 5px 5px 5px; + display: none; + margin:-3px 0 0 3px; + padding: 3px; + z-index:1; +} +#main-sidebar .quick-edit:after{ + content: "."; + display: block; + height: 0; + clear: both; + visibility: hidden; +} +#main-sidebar .quick-edit a{ + border-bottom: medium none; + border-radius: 5px 5px 5px 5px; + font-size:12px; + float: left; + margin: 0 3px 0 0; + padding: 3px; +} + +#main-sidebar .quick-edit a:hover{ + background: none repeat scroll 0 0 #EEEEEE; + border-bottom:none; } \ No newline at end of file diff --git a/app/assets/stylesheets/site_items.css.erb b/app/assets/stylesheets/site_items.css.erb index 4e23bd4c..922bfe56 100644 --- a/app/assets/stylesheets/site_items.css.erb +++ b/app/assets/stylesheets/site_items.css.erb @@ -4,7 +4,7 @@ html, body{ padding: 0; } html{ - background: url(<%= asset_path "body.jpg" %>) no-repeat fixed 0 0 transparent; + background-size: cover; } @@ -172,8 +172,6 @@ body{ .main { background: none repeat scroll 0 0 #FFFFFF; height: 100%; - margin-left: 220px; - padding: 0 40px; position: relative; } .main_list { diff --git a/app/assets/stylesheets/style.css.erb b/app/assets/stylesheets/style.css.erb index d2e33b04..39beaec9 100644 --- a/app/assets/stylesheets/style.css.erb +++ b/app/assets/stylesheets/style.css.erb @@ -261,6 +261,10 @@ box-shadow: 0px 2px 1px rgba(0,0,0,0.1); -moz-box-shadow: 0px 2px 1px rgba(0,0,0,0.1); -webkit-box-shadow: 0px 2px 1px rgba(0,0,0,0.1); + display: none; +} +#main-sidebar .nav > li.active > .nav { + display: block; } #main-sidebar .nav > li > .nav > li > a { margin-left: 0; @@ -433,6 +437,26 @@ .filters .in { /*border-bottom: 1px solid rgba(0,0,0,0.07)*/ } +#tags { +} +#tags .tag { + line-height: 32px; + padding: 0 10px; + background-color: #FFFFFF; + border-bottom: 1px solid #DDDDDD; + border-top: medium none; +} +#tags .tag form, #tags .tag form input { + margin:0; +} +#tags .tagitem { + display: inline-block; + float: left; +} +#tags .action { + display: inline-block; + float: right; +} .sign-in { width: 360px; margin: 0 auto 70px; diff --git a/app/assets/stylesheets/widgets.css b/app/assets/stylesheets/widgets.css new file mode 100644 index 00000000..7a658f36 --- /dev/null +++ b/app/assets/stylesheets/widgets.css @@ -0,0 +1,148 @@ +.widget-size-300 { + width:298px; +} +.widget-box { + background-color: #FFF; + overflow: hidden; + min-width: 300px; + margin: 0 0 5px 5px; + position:relative; +} +.widget-box .widget-title { + color: #FFF; + padding-left: 5px; + border-radius: 5px 5px 0 0; + -moz-border-radius: 5px 5px 0 0; + -webkit-border-radius: 5px 5px 0 0; + background-image: -moz-linear-gradient(top, #B7B7B7, #9d9d9d); + background-image: -ms-linear-gradient(top, #B7B7B7, #9d9d9d); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#B7B7B7), to(#9d9d9d)); + background-image: -webkit-linear-gradient(top, #B7B7B7, #9d9d9d); + background-image: -o-linear-gradient(top, #B7B7B7, #9d9d9d); + background-image: linear-gradient(top, #B7B7B7, #9d9d9d); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#B7B7B7', endColorstr='#9d9d9d', GradientType=0); +} +.widget-box .widget-title [class^="icons-"] { + margin: 3px 5px 0 2px; +} +.widget-box .widget-content { + padding: 10px; + border-width: 0 1px 1px; + border-style: solid; + border-color: #CCCCCC; + border-radius: 0 0 5px 5px; + -moz-border-radius: 0 0 5px 5px; + -webkit-border-radius: 0 0 5px 5px; +} +.widget-box .form-horizontal .control-group > label { + width: 50px; +} +.widget-box .form-horizontal .controls { + margin-left: 60px; +} +.widget-action { + position:absolute; + right:1px; + top:6px; +} +.action { + float: left; + display:inline-block; + margin-right: 5px; + opacity: 0.8; + filter: alpha(opacity=80); +} +.action:hover { + opacity: 1; + filter: alpha(opacity=100); + cursor: pointer; +} +.select-role { + display:none; + padding: 10px 0; +} +.file-upload { + position:relative; + overflow: hidden; +} +.file-upload .file-name { + white-space: nowrap; + overflow: hidden; + border-style: solid; + border-width: 1px 1px 1px 0; + border-color: #CCC; + display: inline-block; + float: left; + padding: 4px 10px; + height: 18px; + line-height: 18px; + -webkit-border-radius: 0 3px 3px 0; + -moz-border-radius: 0 3px 3px 0; + border-radius: 0 3px 3px 0; + text-align: left; + margin: 0; + width: 182px; +} +.file-upload .upload { + margin:0; + padding:0; + position:absolute; + top: 0; + left:0; + opacity:.0; + font-size: 60px; + left: -595px/9; + filter: alpha(opacity: 0); + outline: none; +} +.file-upload .upload:focus { + position:absolute; +} +.upload-picture { + margin-bottom: 5px; + text-align: center; + width: 276px; + overflow: hidden; + height: 90px; +} +.upload-picture img { + left: 0; + margin-top: -15%; + width: 100%; +} +.widget-box .widgetInfo { + display: inline-block; + text-align: center; + width: 255px; + margin : 0px 0 5px; + padding: 5px 10px; +} +.file-upload .input-medium { + border-radius: 3px 3px 3px 3px !important; + width: 267px; + position: relative; + z-index: 5; +} +#widget-link table { + margin-bottom:0 +} +/*Date*/ +.showDate { + border-style: solid; + border-width: 1px 0 1px 1px; + border-color: #CCC; + display: inline-block; + float: left; + padding: 4px 10px; + height: 18px; + line-height: 18px; + -webkit-border-radius: 3px 0 0 3px; + -moz-border-radius: 3px 0 0 3px; + border-radius: 3px 0 0 3px; + text-align: center; +} +.calendarInput { + position: absolute; + visibility: hidden; + left: 11px; +} \ No newline at end of file diff --git a/app/helpers/admin/item_helper.rb b/app/helpers/admin/item_helper.rb index d7a3455b..c9715a71 100644 --- a/app/helpers/admin/item_helper.rb +++ b/app/helpers/admin/item_helper.rb @@ -12,12 +12,14 @@ module Admin::ItemHelper ret << "" end ret.html_safe @@ -26,11 +28,9 @@ module Admin::ItemHelper def render_children(parent) if children = parent.children ret = '' - ret << "" ret end end diff --git a/app/views/admin/ad_images/_form.html.erb b/app/views/admin/ad_images/_form.html.erb index 1089db3b..8e7f18df 100644 --- a/app/views/admin/ad_images/_form.html.erb +++ b/app/views/admin/ad_images/_form.html.erb @@ -161,13 +161,13 @@ <%= content_tag :div,:class => "tab-pane #{active_when_default_locale_eq locale}",:id=>"#{locale}" do%>
<%= f.fields_for :title,@ad_image.title do |f| %> - <%= f.text_field locale,:class=>"ad_image-title",:placeholder => "輸入標題"%> + <%= f.text_field locale,:class=>"ad_image-title post-title",:placeholder => "輸入標題"%> <% end %>
- +
<%= f.fields_for :context, @ad_image.context do |f| %> - <%= f.text_area locale,:style => "width:100%", :class => "asd_tinymce_textarea" %> + <%= f.text_area locale,:style => "width:100%", :class => "asd_tinymce_textarea post-title" %> <% end %>
@@ -177,12 +177,12 @@ +
+ + + +
-
- - - -
\ No newline at end of file diff --git a/app/views/admin/items/_site_map_left_bar.html.erb b/app/views/admin/items/_site_map_left_bar.html.erb index 8dbcb722..b2a48a19 100644 --- a/app/views/admin/items/_site_map_left_bar.html.erb +++ b/app/views/admin/items/_site_map_left_bar.html.erb @@ -1,3 +1,3 @@ -
+
<%= render_node_and_children(Item.first(:conditions => {:parent_id => nil})) %>
\ No newline at end of file diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index 4adce7a5..3c2df376 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -1,37 +1,37 @@ - - - - - <%= @title || APP_CONFIG['orbit'] %> - - - <%= stylesheet_link_tag "admin" %> - <%= javascript_include_tag "admin" %> - <%= yield :page_specific_css %> - <%= yield :page_specific_javascript %> - <%= csrf_meta_tag %> - - - - -
-
<%= yield :secondary %>
-
- <%= yield %> -
-
<%= yield :tertiary %>
- -
- - + + + + + <%= @title || APP_CONFIG['orbit'] %> + + + <%= stylesheet_link_tag "admin" %> + <%= javascript_include_tag "admin" %> + <%= yield :page_specific_css %> + <%= yield :page_specific_javascript %> + <%= csrf_meta_tag %> + + + + +
+
<%= yield :secondary %>
+
+ <%= yield %> +
+
<%= yield :tertiary %>
+ +
+ + diff --git a/app/views/layouts/site_editor.html.erb b/app/views/layouts/site_editor.html.erb index efcc54ca..e5ed9bb9 100644 --- a/app/views/layouts/site_editor.html.erb +++ b/app/views/layouts/site_editor.html.erb @@ -1,38 +1,39 @@ - - - - - <%= @title || APP_CONFIG['orbit'] %> - - - <%= stylesheet_link_tag "site_editor" %> - <%= javascript_include_tag "site_editor" %> - <%= yield :page_specific_css %> - <%= yield :page_specific_javascript %> - <%= csrf_meta_tag %> - - - - -
-
<%= yield :sidebar %>
-
- <%= yield %> -
-
<%= yield :tertiary %>
- -
- - - + + + + + <%= @title || APP_CONFIG['orbit'] %> + + + <%= stylesheet_link_tag "site_editor" %> + <%= javascript_include_tag "site_editor" %> + <%= yield :page_specific_css %> + <%= yield :page_specific_javascript %> + <%= csrf_meta_tag %> + + + +
+
<%= yield :sidebar %>
+
+ <%= yield %> +
+
<%= yield :tertiary %>
+ +
+ + + From 2f279c53ff777991802235e525e2d7077f4ffb35 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Thu, 19 Apr 2012 11:50:54 +0800 Subject: [PATCH 02/12] Apply patch from ldap --- app/assets/javascripts/inc/search.js | 39 +++++++++++++++------------- app/views/layouts/_side_bar.html.erb | 16 ++++++------ 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/app/assets/javascripts/inc/search.js b/app/assets/javascripts/inc/search.js index 979b5621..70507fc6 100644 --- a/app/assets/javascripts/inc/search.js +++ b/app/assets/javascripts/inc/search.js @@ -8,24 +8,27 @@ $.extend($.expr[':'], { return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0; } }); +var interval,sval; $(document).ready(function(){ $("#user_filter").keyup(function(){ - if($(this).val()){ - var totalfoundbyname = $("div#users_checkbox_ary label.member-name:containsi("+$(this).val()+")").length - if(totalfoundbyname!=0){ - $("div#users_checkbox_ary label.member-name:not(:containsi("+$(this).val()+"))").parent().parent().slideUp(); - //$("div#users_checkbox_ary label.member-name:not(:containsi("+$(this).val()+"))").parent().popover('hide'); - $("div#users_checkbox_ary label.member-name:containsi("+$(this).val()+")").parent().parent().slideDown(); - $("div#users_checkbox_ary label.member-name:containsi("+$(this).val()+")").parent().popover('toggle'); - }else if(totalfoundbyname==0){ - $("div#users_checkbox_ary div.for_unit:not(:containsi("+$(this).val()+"))").parent().slideUp(); - //$("div#users_checkbox_ary div.for_unit:not(:containsi("+$(this).val()+"))").popover('hide'); - $("div#users_checkbox_ary div.for_unit:containsi("+$(this).val()+")").parent().slideDown(); - $("div#users_checkbox_ary div.for_unit:containsi("+$(this).val()+")").popover('toggle'); - } - }else{ - $(".checkbox").popover('hide'); - $("div.checkblock").slideDown(); - } + sval = $(this).val(); + $(".checkbox").popover("hide"); + $("div.checkblock").hide(); + clearInterval(interval); + interval = setInterval(waitForSearch,1000); }) -}) \ No newline at end of file +}) +var waitForSearch = function(){ + if(sval){ + var totalfoundbyname = $("div#users_checkbox_ary label.member-name:containsi("+sval+")").length + if(totalfoundbyname!=0){ + $("div#users_checkbox_ary label.member-name:containsi("+sval+")").parent().parent().show(); + }else if(totalfoundbyname==0){ + $("div#users_checkbox_ary div.for_unit:containsi("+sval+")").parent().show(); + } + }else{ + $(".checkbox").popover('hide'); + $("div.checkblock").show(); + } + clearInterval(interval); +} \ No newline at end of file diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index f74f24f6..38380984 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -5,10 +5,10 @@ <%= content_tag :li, :class => active_for_controllers('bulletins', 'tags', 'bulletin_categorys', 'fact_checks') do -%> <%= link_to content_tag(:i, nil, :class => 'icons-announcement') + t('admin.announcement'), panel_announcement_back_end_bulletins_path %> <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('bulletins', 'tags', 'bulletin_categorys', 'fact_checks')) do -%> - <%= content_tag :li, link_to(t('admin.all_articles'), panel_announcement_back_end_bulletins_path), :class => active_for_action('bulletins', 'index') %> - <%= content_tag :li, link_to(t('admin.add_new'), new_panel_announcement_back_end_bulletin_path), :class => active_for_action('bulletins', 'new') %> - <%= content_tag :li, link_to(t('admin.categories'), panel_announcement_back_end_bulletin_categorys_path), :class => active_for_action('bulletin_categorys', 'index') %> - <%= content_tag :li, link_to(t('admin.tags'), panel_announcement_back_end_tags_path), :class => active_for_action('panel/bulletin/back_end/tags', 'index') %> + <%= content_tag :li, link_to(t('announcement.all_articles'), panel_announcement_back_end_bulletins_path), :class => active_for_action('bulletins', 'index') %> + <%= content_tag :li, link_to(t('announcement.add_new'), new_panel_announcement_back_end_bulletin_path), :class => active_for_action('bulletins', 'new') %> + <%= content_tag :li, link_to(t('announcement.categories'), panel_announcement_back_end_bulletin_categorys_path), :class => active_for_action('bulletin_categorys', 'index') %> + <%= content_tag :li, link_to(t('announcement.tags'), panel_announcement_back_end_tags_path), :class => active_for_action('panel/bulletin/back_end/tags', 'index') %> <%= content_tag :li, link_to(t('announcement.bulletin.fact_check_setting'), panel_announcement_back_end_fact_checks_setting_path), :class => active_for_action('fact_checks', 'setting') if (is_manager? rescue nil) %> <% end -%> @@ -41,10 +41,10 @@ <%= content_tag :li, :class => active_for_controllers('web_links', 'tags', 'web_link_categorys') do -%> <%= link_to content_tag(:i, nil, :class => 'icons-link') + t('admin.link'), panel_web_resource_back_end_web_links_path %> <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('web_links', 'tags', 'web_link_categorys')) do -%> - <%= content_tag :li, link_to(t('admin.all_articles'), panel_web_resource_back_end_web_links_path), :class => active_for_action('web_link', 'index') %> - <%= content_tag :li, link_to(t('admin.add_new'), new_panel_web_resource_back_end_web_link_path), :class => active_for_action('web_link', 'new') %> - <%= content_tag :li, link_to(t('admin.categories'), panel_web_resource_back_end_web_link_categorys_path), :class => active_for_action('web_link_categorys', 'index') %> - <%= content_tag :li, link_to(t('admin.tags'), panel_web_resource_back_end_tags_path), :class => active_for_action('panel/web_resource/back_end/tags', 'index') %> + <%= content_tag :li, link_to(t('admin.announcement.all_articles'), panel_web_resource_back_end_web_links_path), :class => active_for_action('web_link', 'index') %> + <%= content_tag :li, link_to(t('admin.announcement.add_new'), new_panel_web_resource_back_end_web_link_path), :class => active_for_action('web_link', 'new') %> + <%= content_tag :li, link_to(t('admin.announcement.categories'), panel_web_resource_back_end_web_link_categorys_path), :class => active_for_action('web_link_categorys', 'index') %> + <%= content_tag :li, link_to(t('admin.announcement.tags'), panel_web_resource_back_end_tags_path), :class => active_for_action('panel/web_resource/back_end/tags', 'index') %> <% end -%> <% end -%> From ff472714dec8cbf0e27593415e328361e51c323c Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Fri, 13 Apr 2012 17:24:30 +0800 Subject: [PATCH 03/12] AdBanner i18n vars patch --- app/controllers/admin/ad_banners_controller.rb | 6 ++++-- app/views/admin/ad_banners/_ad_banner_tab.html.erb | 6 +++--- config/locales/en.yml | 10 ++++++++++ config/locales/zh_tw.yml | 2 ++ config/routes.rb | 1 + 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/app/controllers/admin/ad_banners_controller.rb b/app/controllers/admin/ad_banners_controller.rb index 95ce7e7c..a6f4fd5f 100644 --- a/app/controllers/admin/ad_banners_controller.rb +++ b/app/controllers/admin/ad_banners_controller.rb @@ -39,8 +39,10 @@ class Admin::AdBannersController < ApplicationController redirect_to admin_ad_banners_url end - def destroy_ad_image - + def realtime_preview + @ad_banner = AdBanner.find(params[:id]) + @ad_banner.update_attributes(params[:ad_banner]) + render end def index diff --git a/app/views/admin/ad_banners/_ad_banner_tab.html.erb b/app/views/admin/ad_banners/_ad_banner_tab.html.erb index d9b1b902..10a98b52 100644 --- a/app/views/admin/ad_banners/_ad_banner_tab.html.erb +++ b/app/views/admin/ad_banners/_ad_banner_tab.html.erb @@ -1,14 +1,14 @@
" id=<%= ad_banner_tab.title %>> -

尺寸:

+

<%= t("admin.ad.banner_best_size") %>:

<%= form_for ad_banner_tab,:url=> admin_ad_banner_path(ad_banner_tab),:method => :put,:class=>"input-medium" do |f| -%> <%= f.label :ad_fx, t('admin.ad.ab_fx') %> <%= f.select :ad_fx ,AdBanner::FX_TYPES %> <%= f.label :transition_sec, t('admin.ad.transition_sec') %> <%= f.text_field :transition_sec,:placeholder=>"3秒請輸入3000",:class=> "span3" %> <%= t("admin.ad.trans_unit_sec") %> - <%= f.submit %> - <%= f.submit 'Cancel',:type=>'reset' %> + <%= f.submit t("admin.ad.update_banner") %> + <%= f.submit t("cancel"),:type=>'reset' %>
<%= render :partial => "ad_image_update", :collection => ad_banner_tab.ad_images,:as => :ad_image,:locals=>{:ad_banner => ad_banner_tab} %> <%#= render :partial => 'new_add_banner_file', :object => ad_banner_tab.ad_images.build, :locals => { :field_name => "new_ad_images[]", :f => f, :classes => "r_destroy" } %> diff --git a/config/locales/en.yml b/config/locales/en.yml index da72a4eb..9b586148 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -42,6 +42,16 @@ en: admin: action: Action ad_banner: AD Banner + ad: + ab_fx: FX + all_banners: AdBanner list + banner_best_size: Banner Best Size + new_banner: New banner + new_image: New image + title: Title + transition_sec: Transition time + trans_unit_sec: sec + update_banner: Update Banner add: Add add_item: Add item add_language: Add language diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 491d80e8..ebc6e6b3 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -42,11 +42,13 @@ zh_tw: ad: ab_fx: 轉場特效 all_banners: 輪播清單 + banner_best_size: Banner 尺寸 new_banner: 新增輪播 new_image: 新增橫幅 title: 標題 transition_sec: 轉場單位時間 trans_unit_sec: 秒 + update_banner: 更新輪播 add: 新增 add_item: 新增項目 add_language: 新增語言 diff --git a/config/routes.rb b/config/routes.rb index 99860bb6..cdf3a7f0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -26,6 +26,7 @@ Orbit::Application.routes.draw do resources :ad_banners do + match 'preview/:id' => 'ad_banners#realtime_preview',:as => :realtime_preview,:via => :put collection do match 'new_ad_image' => 'ad_images#new',:as => :new_ad_image,:via => :get match 'new_ad_image' => 'ad_images#create',:as => :create_ad_image,:via => :post From 30edc317b2f917dbd4f11f25d8dab954d7455f0c Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Fri, 13 Apr 2012 17:51:19 +0800 Subject: [PATCH 04/12] text area for ad_image --- app/views/admin/ad_images/_form.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/ad_images/_form.html.erb b/app/views/admin/ad_images/_form.html.erb index 8e7f18df..03b11b18 100644 --- a/app/views/admin/ad_images/_form.html.erb +++ b/app/views/admin/ad_images/_form.html.erb @@ -167,7 +167,7 @@
<%= f.fields_for :context, @ad_image.context do |f| %> - <%= f.text_area locale,:style => "width:100%", :class => "asd_tinymce_textarea post-title" %> + <%= f.text_area locale,:style => "width:100%", :class => "tinymce_textarea post-title" %> <% end %>
From 8cc0611c4a64a6dbae00251bbaca5f3c417699c9 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Fri, 13 Apr 2012 18:02:36 +0800 Subject: [PATCH 05/12] Ray's fix for ad_banner --- app/assets/stylesheets/widget.css | 68 ++++++++++++++++--------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/app/assets/stylesheets/widget.css b/app/assets/stylesheets/widget.css index 7a658f36..81862e25 100644 --- a/app/assets/stylesheets/widget.css +++ b/app/assets/stylesheets/widget.css @@ -66,22 +66,20 @@ overflow: hidden; } .file-upload .file-name { - white-space: nowrap; - overflow: hidden; - border-style: solid; - border-width: 1px 1px 1px 0; - border-color: #CCC; - display: inline-block; - float: left; - padding: 4px 10px; - height: 18px; - line-height: 18px; - -webkit-border-radius: 0 3px 3px 0; - -moz-border-radius: 0 3px 3px 0; - border-radius: 0 3px 3px 0; - text-align: left; - margin: 0; - width: 182px; + border-color: #CCCCCC; + border-radius: 0 3px 3px 0; + border-style: solid; + border-width: 1px 1px 1px 0; + display: inline-block; + float: left; + height: 18px; + line-height: 18px; + margin: 0; + overflow: hidden; + padding: 4px 10px; + text-align: left; + white-space: nowrap; + width: 182px; } .file-upload .upload { margin:0; @@ -111,11 +109,11 @@ width: 100%; } .widget-box .widgetInfo { - display: inline-block; - text-align: center; - width: 255px; - margin : 0px 0 5px; - padding: 5px 10px; + display: inline-block; + margin: 0 0 5px; + padding: 5px 10px; + text-align: center; + width: 255px; } .file-upload .input-medium { border-radius: 3px 3px 3px 3px !important; @@ -128,21 +126,25 @@ } /*Date*/ .showDate { - border-style: solid; - border-width: 1px 0 1px 1px; - border-color: #CCC; - display: inline-block; - float: left; - padding: 4px 10px; - height: 18px; - line-height: 18px; - -webkit-border-radius: 3px 0 0 3px; - -moz-border-radius: 3px 0 0 3px; - border-radius: 3px 0 0 3px; - text-align: center; + border-color: #CCCCCC; + border-radius: 3px 0 0 3px; + border-style: solid; + border-width: 1px 0 1px 1px; + display: inline-block; + float: left; + height: 18px; + line-height: 18px; + padding: 4px 10px; + text-align: center; } .calendarInput { position: absolute; visibility: hidden; left: 11px; +} +.file-upload .input-medium { + border-radius: 3px 3px 3px 3px !important; + position: relative; + width: 267px; + z-index: 5; } \ No newline at end of file From 1b70852ff7c707dcacd70defc41b7e7558c06d0b Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Tue, 17 Apr 2012 11:34:25 +0800 Subject: [PATCH 06/12] realtime preview is working. but save to object when preview --- app/assets/javascripts/inc/modal-preview.js | 15 ++++ app/assets/stylesheets/new_admin.css.erb | 2 +- app/assets/stylesheets/widget.css | 70 +++++++++---------- .../admin/ad_banners_controller.rb | 4 +- .../admin/ad_banners/_ad_banner_tab.html.erb | 4 +- .../admin/ad_banners/_modal_preview.html.erb | 35 ++++++++++ app/views/admin/ad_banners/index.html.erb | 8 ++- .../admin/ad_banners/realtime_preview.js.erb | 2 + config/locales/en.yml | 7 +- config/locales/zh_tw.yml | 3 + config/routes.rb | 4 +- 11 files changed, 111 insertions(+), 43 deletions(-) create mode 100644 app/assets/javascripts/inc/modal-preview.js create mode 100644 app/views/admin/ad_banners/_modal_preview.html.erb create mode 100644 app/views/admin/ad_banners/realtime_preview.js.erb diff --git a/app/assets/javascripts/inc/modal-preview.js b/app/assets/javascripts/inc/modal-preview.js new file mode 100644 index 00000000..3453c096 --- /dev/null +++ b/app/assets/javascripts/inc/modal-preview.js @@ -0,0 +1,15 @@ +//Preview need a link in form as Ex and a corresponding PUT action in controller +//Ex preview trigger: +// <%= link_to "NewPreview", realtime_preview_admin_ad_banner_path(ad_banner_tab) , :class=>'preview_trigger'%> + +$(document).ready(function() { + $("a.preview_trigger").click(function(){ + $(this).after("

"); + $.ajax({ + type:"PUT", + url:$(this).attr("href"), + data:$(this).parents("form").serialize() + }).done(function(){ $("#"+start_modal_with_id).modal('show');}); + return false;} + ); +}); \ 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 9d687eb6..2eaefd53 100644 --- a/app/assets/stylesheets/new_admin.css.erb +++ b/app/assets/stylesheets/new_admin.css.erb @@ -12,4 +12,4 @@ *= require style *= require scroll_style *= require isotope -*/ \ No newline at end of file +*/ \ No newline at end of file diff --git a/app/assets/stylesheets/widget.css b/app/assets/stylesheets/widget.css index 81862e25..3638bd4a 100644 --- a/app/assets/stylesheets/widget.css +++ b/app/assets/stylesheets/widget.css @@ -59,27 +59,29 @@ } .select-role { display:none; - padding: 10px 0; + overflow:hidden; } .file-upload { position:relative; overflow: hidden; } .file-upload .file-name { - border-color: #CCCCCC; - border-radius: 0 3px 3px 0; - border-style: solid; - border-width: 1px 1px 1px 0; - display: inline-block; - float: left; - height: 18px; - line-height: 18px; - margin: 0; - overflow: hidden; - padding: 4px 10px; - text-align: left; - white-space: nowrap; - width: 182px; + white-space: nowrap; + overflow: hidden; + border-style: solid; + border-width: 1px 1px 1px 0; + border-color: #CCC; + display: inline-block; + float: left; + padding: 4px 10px; + height: 18px; + line-height: 18px; + -webkit-border-radius: 0 3px 3px 0; + -moz-border-radius: 0 3px 3px 0; + border-radius: 0 3px 3px 0; + text-align: left; + margin: 0; + width: 182px; } .file-upload .upload { margin:0; @@ -109,11 +111,11 @@ width: 100%; } .widget-box .widgetInfo { - display: inline-block; - margin: 0 0 5px; - padding: 5px 10px; - text-align: center; - width: 255px; + display: inline-block; + text-align: center; + width: 255px; + margin : 0px 0 5px; + padding: 5px 10px; } .file-upload .input-medium { border-radius: 3px 3px 3px 3px !important; @@ -126,25 +128,21 @@ } /*Date*/ .showDate { - border-color: #CCCCCC; - border-radius: 3px 0 0 3px; - border-style: solid; - border-width: 1px 0 1px 1px; - display: inline-block; - float: left; - height: 18px; - line-height: 18px; - padding: 4px 10px; - text-align: center; + border-style: solid; + border-width: 1px 0 1px 1px; + border-color: #CCC; + display: inline-block; + float: left; + padding: 4px 10px; + height: 18px; + line-height: 18px; + -webkit-border-radius: 3px 0 0 3px; + -moz-border-radius: 3px 0 0 3px; + border-radius: 3px 0 0 3px; + text-align: center; } .calendarInput { position: absolute; visibility: hidden; left: 11px; -} -.file-upload .input-medium { - border-radius: 3px 3px 3px 3px !important; - position: relative; - width: 267px; - z-index: 5; } \ No newline at end of file diff --git a/app/controllers/admin/ad_banners_controller.rb b/app/controllers/admin/ad_banners_controller.rb index a6f4fd5f..5ce44a0d 100644 --- a/app/controllers/admin/ad_banners_controller.rb +++ b/app/controllers/admin/ad_banners_controller.rb @@ -40,9 +40,9 @@ class Admin::AdBannersController < ApplicationController end def realtime_preview - @ad_banner = AdBanner.find(params[:id]) + @ad_banner = AdBanner.find(params[:id]).clone + debugger @ad_banner.update_attributes(params[:ad_banner]) - render end def index diff --git a/app/views/admin/ad_banners/_ad_banner_tab.html.erb b/app/views/admin/ad_banners/_ad_banner_tab.html.erb index 10a98b52..7bba88c6 100644 --- a/app/views/admin/ad_banners/_ad_banner_tab.html.erb +++ b/app/views/admin/ad_banners/_ad_banner_tab.html.erb @@ -13,7 +13,9 @@ <%= render :partial => "ad_image_update", :collection => ad_banner_tab.ad_images,:as => :ad_image,:locals=>{:ad_banner => ad_banner_tab} %> <%#= render :partial => 'new_add_banner_file', :object => ad_banner_tab.ad_images.build, :locals => { :field_name => "new_ad_images[]", :f => f, :classes => "r_destroy" } %> <%= link_to 'Add AdImage',new_admin_ad_banner_ad_image_path(ad_banner_tab) %> + <%= link_to "NewPreview", realtime_preview_admin_ad_banner_path(ad_banner_tab) , :class=>'preview_trigger'%> +
<% end -%> - <%= render :partial => 'preview_block',:locals=> {:ad_banner =>ad_banner_tab} %> + <%#= render :partial => 'preview_block',:locals=> {:ad_banner =>ad_banner_tab} %>
diff --git a/app/views/admin/ad_banners/_modal_preview.html.erb b/app/views/admin/ad_banners/_modal_preview.html.erb new file mode 100644 index 00000000..27222e57 --- /dev/null +++ b/app/views/admin/ad_banners/_modal_preview.html.erb @@ -0,0 +1,35 @@ +<% if ad_banner -%> + + + +<% end -%> + + + diff --git a/app/views/admin/ad_banners/index.html.erb b/app/views/admin/ad_banners/index.html.erb index e6ebfd5d..365d020d 100644 --- a/app/views/admin/ad_banners/index.html.erb +++ b/app/views/admin/ad_banners/index.html.erb @@ -1,4 +1,10 @@ -<%= stylesheet_link_tag "admin/ad_banner_preview" %> +<% content_for :page_specific_css do -%> + <%#= stylesheet_link_tag "admin/ad_banner_preview" %> +<% end -%> +<% content_for :page_specific_css do -%> + <%= javascript_include_tag "inc/modal-preview" %> +<% end -%> +
+
+ <%= link_to t("modal.preview"), realtime_preview_admin_ad_banner_path(@ad_image.ad_banner) ,:class=>"preview_trigger btn btn-success" rescue nil%> + + +
\ No newline at end of file diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index 38380984..84d89ac4 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -32,9 +32,9 @@ <%= content_tag :li, :class => active_for_controllers('ad_banners', 'ad_images') do -%> <%= link_to content_tag(:i, nil, :class => 'icons-link') + t('admin.ad_banner'), admin_ad_banners_path %> <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('ad_banners', 'ad_images')) do -%> - <%= content_tag :li, link_to(t('admin.all_ad_banners'), admin_ad_banners_path), :class => active_for_action('ad_banners', 'index') %> - <%= content_tag :li, link_to(t('admin.new_ad_banner'), new_admin_ad_banner_path), :class => active_for_action('ad_banners', 'new') %> - <%= content_tag :li, link_to(t('admin.new_ad_image'), new_ad_image_admin_ad_banners_path), :class => active_for_action('ad_images', 'new') %> + <%= content_tag :li, link_to(t('admin.ad.all_banners'), admin_ad_banners_path), :class => active_for_action('ad_banners', 'index') %> + <%= content_tag :li, link_to(t('admin.ad.new_banner'), new_admin_ad_banner_path), :class => active_for_action('ad_banners', 'new') %> + <%= content_tag :li, link_to(t('admin.ad.new_image'), new_ad_image_admin_ad_banners_path), :class => active_for_action('ad_images', 'new') %> <% end %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index 2716588a..0d440e83 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -26,13 +26,13 @@ Orbit::Application.routes.draw do resources :ad_banners do - member do - match 'preivew' => 'ad_banners#realtime_preview',:as => :realtime_preview,:via => :put - end collection do match 'new_ad_image' => 'ad_images#new',:as => :new_ad_image,:via => :get match 'new_ad_image' => 'ad_images#create',:as => :create_ad_image,:via => :post end + member do + match 'preivew' => 'ad_banners#realtime_preview',:as => :realtime_preview,:via => :put + end resources :ad_images ,:except => [:show,:index] end resources :dashboards From 81b0046f42fe0668deec90818665fcee2d12acb3 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Tue, 17 Apr 2012 16:03:48 +0800 Subject: [PATCH 08/12] Preview now can be use at both ad_banner and ad_image,however it won't run correctly if user change its ad_banner at ad_image. --- app/assets/javascripts/inc/modal-preview.js | 2 +- app/controllers/admin/ad_banners_controller.rb | 2 +- app/models/ad_banner.rb | 1 + app/views/admin/ad_banners/_ad_banner_tab.html.erb | 3 +-- app/views/admin/ad_banners/_modal_ad_banner_form.html.erb | 3 --- app/views/admin/ad_banners/index.html.erb | 1 + app/views/admin/ad_images/_form.html.erb | 7 ++++--- config/routes.rb | 6 ++---- 8 files changed, 11 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/inc/modal-preview.js b/app/assets/javascripts/inc/modal-preview.js index 3453c096..fd62a95e 100644 --- a/app/assets/javascripts/inc/modal-preview.js +++ b/app/assets/javascripts/inc/modal-preview.js @@ -4,7 +4,7 @@ $(document).ready(function() { $("a.preview_trigger").click(function(){ - $(this).after("

"); + $(this).after(""); $.ajax({ type:"PUT", url:$(this).attr("href"), diff --git a/app/controllers/admin/ad_banners_controller.rb b/app/controllers/admin/ad_banners_controller.rb index 4d2ed213..c3d0cc58 100644 --- a/app/controllers/admin/ad_banners_controller.rb +++ b/app/controllers/admin/ad_banners_controller.rb @@ -40,7 +40,7 @@ class Admin::AdBannersController < ApplicationController end def realtime_preview - @ad_banner = AdBanner.find(params[:id]).preview_clone + @ad_banner = AdBanner.find(conditions: { title: params[:title] }).preview_clone #@ad_banner.update_attributes(params[:ad_banner]).update_attributes(params[:ad_images]) end diff --git a/app/models/ad_banner.rb b/app/models/ad_banner.rb index a2ac2096..0147c3d2 100644 --- a/app/models/ad_banner.rb +++ b/app/models/ad_banner.rb @@ -9,6 +9,7 @@ class AdBanner before_save :save_or_destroy validates_uniqueness_of :title + validates :title , :length => { :minimum => 2 } has_many :ad_images , dependent: :delete FX_TYPES = ["blindX","blindY","blindZ","cover","curtainX","curtainY","fade","fadeZoom","growX","growY","scrollUp","scrollDown","scrollLeft","scrollRight","scrollHorz","scrollVert","shuffle","slideX","slideY","toss","turnUp","turnDown","turnLeft","turnRight","uncover","wipe","zoom"] diff --git a/app/views/admin/ad_banners/_ad_banner_tab.html.erb b/app/views/admin/ad_banners/_ad_banner_tab.html.erb index 001726f4..47986323 100644 --- a/app/views/admin/ad_banners/_ad_banner_tab.html.erb +++ b/app/views/admin/ad_banners/_ad_banner_tab.html.erb @@ -1,4 +1,3 @@ -
" id=<%= ad_banner_tab.title %>>

<%= t("admin.ad.banner_best_size") %>:

@@ -13,7 +12,7 @@ <%= render :partial => "ad_image_update", :collection => ad_banner_tab.ad_images,:as => :ad_image,:locals=>{:ad_banner => ad_banner_tab} %> <%#= render :partial => 'new_add_banner_file', :object => ad_banner_tab.ad_images.build, :locals => { :field_name => "new_ad_images[]", :f => f, :classes => "r_destroy" } %> <%= link_to t("admin.ad.new_image"),new_admin_ad_banner_ad_image_path(ad_banner_tab) ,:class => "btn btn-primary"%> - <%= link_to t("modal.preview"), realtime_preview_admin_ad_banner_path(ad_banner_tab) , :class=>'preview_trigger btn btn-success'%> + <%= link_to t("modal.preview"), admin_realtime_preview_ad_banner_path(ad_banner_tab.title) , :class=>'preview_trigger btn btn-success'%>
<% end -%> diff --git a/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb b/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb index 8e8de1d9..66f8de2b 100644 --- a/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb +++ b/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb @@ -44,9 +44,6 @@ $('#new_ad_banner_tab_but').on('shown', function (e) { $('#new-a-banner').modal({show: true}); }) -$('#new-a-banner').on('shown', function (e) { - alert('show!'); -}) $('#new-a-banner').on('hidden', function (e) { $(".nav.nav-tabs a[id!='new_ad_banner_tab_but']:last").tab('show'); diff --git a/app/views/admin/ad_banners/index.html.erb b/app/views/admin/ad_banners/index.html.erb index 365d020d..4b7dfef2 100644 --- a/app/views/admin/ad_banners/index.html.erb +++ b/app/views/admin/ad_banners/index.html.erb @@ -2,6 +2,7 @@ <%#= stylesheet_link_tag "admin/ad_banner_preview" %> <% end -%> <% content_for :page_specific_css do -%> + <%= javascript_include_tag "/static/jquery.cycle.all.latest.js" %> <%= javascript_include_tag "inc/modal-preview" %> <% end -%> diff --git a/app/views/admin/ad_images/_form.html.erb b/app/views/admin/ad_images/_form.html.erb index 21dca2a0..075f01b4 100644 --- a/app/views/admin/ad_images/_form.html.erb +++ b/app/views/admin/ad_images/_form.html.erb @@ -5,6 +5,7 @@ <%= javascript_include_tag "lib/datepicker" %> <%= javascript_include_tag "lib/date.format" %> <%= javascript_include_tag "inc/modal-preview" %> + <%= javascript_include_tag "/static/jquery.cycle.all.latest.js" %> <% end %> @@ -187,9 +188,9 @@
- <%= link_to t("modal.preview"), realtime_preview_admin_ad_banner_path(@ad_image.ad_banner) ,:class=>"preview_trigger btn btn-success" rescue nil%> - - + <%= link_to t("modal.preview"), admin_realtime_preview_ad_banner_path(@ad_image.ad_banner.title) ,:class=>"preview_trigger btn btn-success" rescue nil%> + <%= f.submit t("submit"),:class=>"btn btn-primary" %> + <%= f.submit t("cancel"),:class=>"btn ",:type => 'reset' %>
\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 0d440e83..9200492d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -24,15 +24,13 @@ Orbit::Application.routes.draw do end end - + + match 'ad_banner/:title/preivew' => 'ad_banners#realtime_preview',:as => :realtime_preview_ad_banner,:via => :put resources :ad_banners do collection do match 'new_ad_image' => 'ad_images#new',:as => :new_ad_image,:via => :get match 'new_ad_image' => 'ad_images#create',:as => :create_ad_image,:via => :post end - member do - match 'preivew' => 'ad_banners#realtime_preview',:as => :realtime_preview,:via => :put - end resources :ad_images ,:except => [:show,:index] end resources :dashboards From 0c46b4da23f7b8c2c929a44222e274a406016728 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Wed, 18 Apr 2012 15:26:59 +0800 Subject: [PATCH 09/12] AdImage and AnBanner JS fixed --- app/assets/javascripts/inc/modal-preview.js | 2 +- app/controllers/admin/ad_banners_controller.rb | 15 ++++++++++----- .../admin/ad_banners/_ad_banner_tab.html.erb | 2 +- .../ad_banners/_modal_ad_banner_form.html.erb | 4 ++-- .../admin/ad_banners/create_error_msg.js.erb | 1 + .../admin/ad_banners/new_created_node.js.erb | 7 +++++++ 6 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 app/views/admin/ad_banners/create_error_msg.js.erb create mode 100644 app/views/admin/ad_banners/new_created_node.js.erb diff --git a/app/assets/javascripts/inc/modal-preview.js b/app/assets/javascripts/inc/modal-preview.js index fd62a95e..2f915f6c 100644 --- a/app/assets/javascripts/inc/modal-preview.js +++ b/app/assets/javascripts/inc/modal-preview.js @@ -6,7 +6,7 @@ $(document).ready(function() { $("a.preview_trigger").click(function(){ $(this).after(""); $.ajax({ - type:"PUT", + type:"put", url:$(this).attr("href"), data:$(this).parents("form").serialize() }).done(function(){ $("#"+start_modal_with_id).modal('show');}); diff --git a/app/controllers/admin/ad_banners_controller.rb b/app/controllers/admin/ad_banners_controller.rb index c3d0cc58..19983b66 100644 --- a/app/controllers/admin/ad_banners_controller.rb +++ b/app/controllers/admin/ad_banners_controller.rb @@ -22,9 +22,14 @@ class Admin::AdBannersController < ApplicationController def create @ad_banner = AdBanner.new(params[:ad_banner]) - @ad_banner.save - redirect_to admin_ad_banners_url - + if @ad_banner.save + @active = @ad_banner + respond_to do |format| + format.js {render 'new_created_node'} + end + else + render 'create_error_msg' + end end def edit @@ -40,8 +45,8 @@ class Admin::AdBannersController < ApplicationController end def realtime_preview - @ad_banner = AdBanner.find(conditions: { title: params[:title] }).preview_clone - #@ad_banner.update_attributes(params[:ad_banner]).update_attributes(params[:ad_images]) + @ad_banner = AdBanner.first(conditions: { title: params[:title] }).preview_clone + @ad_banner.update_attributes(params[:ad_banner]).update_attributes(params[:ad_images]) end def index diff --git a/app/views/admin/ad_banners/_ad_banner_tab.html.erb b/app/views/admin/ad_banners/_ad_banner_tab.html.erb index 47986323..530e45cb 100644 --- a/app/views/admin/ad_banners/_ad_banner_tab.html.erb +++ b/app/views/admin/ad_banners/_ad_banner_tab.html.erb @@ -1,4 +1,4 @@ -
" id=<%= ad_banner_tab.title %>> +
" id=<%= ad_banner_tab.title %>>

<%= t("admin.ad.banner_best_size") %>:

<%= form_for ad_banner_tab,:url=> admin_ad_banner_path(ad_banner_tab),:method => :put,:class=>"input-medium" do |f| -%> diff --git a/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb b/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb index 66f8de2b..36ebc4a3 100644 --- a/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb +++ b/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb @@ -4,7 +4,7 @@ <% end %> diff --git a/app/views/admin/ad_banners/create_error_msg.js.erb b/app/views/admin/ad_banners/create_error_msg.js.erb new file mode 100644 index 00000000..60f1d261 --- /dev/null +++ b/app/views/admin/ad_banners/create_error_msg.js.erb @@ -0,0 +1 @@ +alert("Error occures:<%= @ad_banner.errors.full_messages%>"); \ No newline at end of file diff --git a/app/views/admin/ad_banners/new_created_node.js.erb b/app/views/admin/ad_banners/new_created_node.js.erb new file mode 100644 index 00000000..140be0b4 --- /dev/null +++ b/app/views/admin/ad_banners/new_created_node.js.erb @@ -0,0 +1,7 @@ +$('<%= escape_javascript(content_tag(:li,link_to(@ad_banner.title,"##{@ad_banner.title}",:data=>{:toggle=>"tab"}))) %>').insertBefore("#new_ad_banner_tab_but"); +$('<%= escape_javascript(render(:partial => "ad_banner_tab",:locals => {:ad_banner_tab => @ad_banner})) %>').insertBefore($("#new-a-banner")); + +$('.modal').modal('hide'); +$('#post-body-content').find(".nav.nav-tabs").children('li.active').removeClass("active"); +$('#post-body-content').find(".nav.nav-tabs").children('li[id!="new_ad_banner_tab_but"]').last().addClass("active"); + From 8eedbc951e810e7e79e0711aba2e465450ad3206 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Wed, 18 Apr 2012 15:33:11 +0800 Subject: [PATCH 10/12] add i18n vars --- app/views/admin/ad_banners/_ad_image_update.html.erb | 2 +- config/locales/en.yml | 2 ++ config/locales/zh_tw.yml | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/views/admin/ad_banners/_ad_image_update.html.erb b/app/views/admin/ad_banners/_ad_image_update.html.erb index 583c3316..c51b5885 100644 --- a/app/views/admin/ad_banners/_ad_image_update.html.erb +++ b/app/views/admin/ad_banners/_ad_image_update.html.erb @@ -1,7 +1,7 @@
  • <%= image_tag ad_image.file rescue nil%>

    - <%= ad_image.display? ? '[Showing]' : '[NotShawing]' %> + <%= ad_image.display? ? "[#{t('admin.ad.showing')}]" : "[#{t('admin.ad.not_showing')}]" %> <%= "#{ad_image.post_date ||'NeedReset' }~#{ad_image.unpost_date || 'NeedReset'}" %>

    diff --git a/config/locales/en.yml b/config/locales/en.yml index d019de7e..f34557ca 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -48,6 +48,8 @@ en: banner_best_size: Banner Best Size new_banner: New banner new_image: New image + showing: Showing + not_showing: NotShowing title: Title transition_sec: Transition time trans_unit_sec: sec diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 708def10..2615c99c 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -45,6 +45,8 @@ zh_tw: banner_best_size: Banner 尺寸 new_banner: 新增輪播 new_image: 新增橫幅 + showing: 顯示中 + not_showing: 沒有顯示 title: 標題 transition_sec: 轉場單位時間 trans_unit_sec: 秒 From 67ba2389a2adb766a1d43664241ab7341c25f565 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Wed, 18 Apr 2012 16:24:17 +0800 Subject: [PATCH 11/12] fix js --- .../ad_banners/_modal_ad_banner_form.html.erb | 14 ++++++-------- app/views/admin/ad_banners/index.html.erb | 2 +- app/views/admin/ad_banners/new_created_node.js.erb | 1 + 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb b/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb index 36ebc4a3..235e7e15 100644 --- a/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb +++ b/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb @@ -36,17 +36,15 @@ <% end %>

  • diff --git a/app/views/admin/ad_banners/index.html.erb b/app/views/admin/ad_banners/index.html.erb index 4b7dfef2..8307885a 100644 --- a/app/views/admin/ad_banners/index.html.erb +++ b/app/views/admin/ad_banners/index.html.erb @@ -12,7 +12,7 @@ <% @ad_banners.each do |ab| %> <%= content_tag :li,link_to(ab.title,"##{ab.title}",:data=>{:toggle=>"tab"}),:class => (ab == @active ? 'active' : nil ) %> <% end -%> - <%= content_tag :li,link_to('New',"#new-a-banner",:data=>{:toggle=>"tab"}),:id=>'new_ad_banner_tab_but',:class => (@active.nil? ? 'active' : nil ) %> + <%= content_tag :li,link_to(t("admin.ad.new_banner"),"#new-a-banner",:data=>{:toggle=>"tab"}),:id=>'new_ad_banner_tab_but',:class => (@active.nil? ? 'active' : nil ) %> diff --git a/app/views/admin/ad_banners/new_created_node.js.erb b/app/views/admin/ad_banners/new_created_node.js.erb index 140be0b4..86970e6a 100644 --- a/app/views/admin/ad_banners/new_created_node.js.erb +++ b/app/views/admin/ad_banners/new_created_node.js.erb @@ -2,6 +2,7 @@ $('<%= escape_javascript(content_tag(:li,link_to(@ad_banner.title,"##{@ad_banner $('<%= escape_javascript(render(:partial => "ad_banner_tab",:locals => {:ad_banner_tab => @ad_banner})) %>').insertBefore($("#new-a-banner")); $('.modal').modal('hide'); +$('#new-a-banner').unbind(); $('#post-body-content').find(".nav.nav-tabs").children('li.active').removeClass("active"); $('#post-body-content').find(".nav.nav-tabs").children('li[id!="new_ad_banner_tab_but"]').last().addClass("active"); From 09910ca4ae855e15881a3013cca45c898c21a15a Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Mon, 23 Apr 2012 14:12:18 +0800 Subject: [PATCH 12/12] Rmove therubyraces from Gemfile.lock --- Gemfile.lock | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 52453b6a..71742974 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -97,7 +97,6 @@ GEM railties (~> 3.0) thor (~> 0.14) json (1.6.5) - libv8 (3.3.10.4) linecache19 (0.5.12) ruby_core_source (>= 0.1.4) mail (2.3.3) @@ -210,8 +209,6 @@ GEM rack (~> 1.0) tilt (~> 1.1, != 1.3.0) subexec (0.2.1) - therubyracer (0.9.10) - libv8 (~> 3.3.10) thor (0.14.6) tilt (1.3.3) tinymce-rails (3.4.8) @@ -272,7 +269,6 @@ DEPENDENCIES sinatra spork sprockets - therubyracer tinymce-rails uglifier watchr