diff --git a/app/assets/images/ajax-loader.gif b/app/assets/images/ajax-loader.gif new file mode 100644 index 00000000..5f117fd8 Binary files /dev/null and b/app/assets/images/ajax-loader.gif differ diff --git a/app/assets/javascripts/inc/ajax_setting.js b/app/assets/javascripts/inc/ajax_setting.js new file mode 100644 index 00000000..c23a73bf --- /dev/null +++ b/app/assets/javascripts/inc/ajax_setting.js @@ -0,0 +1,7 @@ +jQuery(document).ajaxStart(function(){ + $('').appendTo('body'); +}); + +jQuery(document).ajaxComplete(function(){ + $("#sys_modal").hide().remove(); +}); diff --git a/app/assets/javascripts/lib/contenteditable.js.erb b/app/assets/javascripts/lib/contenteditable.js.erb index 515be3e6..40c19dd3 100644 --- a/app/assets/javascripts/lib/contenteditable.js.erb +++ b/app/assets/javascripts/lib/contenteditable.js.erb @@ -40,11 +40,11 @@ $(".nav-tabs").find(".icons-pencil").click(function(){ data: { body: content_holder.html() }, success: function(json) { $(selector).attr("contenteditable",false) - alert("<%= I18n.t("admin.contenteditable.update_done") %>"); + alert("<%= I18n.t('admin.contenteditable.update_done') %>"); //content_holder.effect('highlight', {'color': '#0f0'}, 3000); }, error: function() { - alert("<%= I18n.t("admin.contenteditable.update_failed") %>"); + alert("<%= I18n.t('admin.contenteditable.update_failed') %>"); //content_holder.effect('highlight', {'color': '#f00'}, 3000); content_holder.html(content); } diff --git a/app/assets/javascripts/new_admin.js b/app/assets/javascripts/new_admin.js index f5fed368..949753a9 100644 --- a/app/assets/javascripts/new_admin.js +++ b/app/assets/javascripts/new_admin.js @@ -17,3 +17,4 @@ //= require side_bar_history //= require rss //= require ajax_form +//= require inc/ajax_setting diff --git a/app/assets/javascripts/page_edit.js.erb b/app/assets/javascripts/page_edit.js.erb index 7c0f6923..d7aaccd0 100644 --- a/app/assets/javascripts/page_edit.js.erb +++ b/app/assets/javascripts/page_edit.js.erb @@ -34,6 +34,10 @@ $('.part_kind').live('click', function() { }); $(document).ready(function(){ + bindTreeDragHandle(); +}); + +var bindTreeDragHandle = function(){ $('ol.sortable').nestedSortable({ disableNesting: 'no-nest', forcePlaceholderSize: true, @@ -52,4 +56,4 @@ $(document).ready(function(){ $.post("<%= Rails.application.routes.url_helpers.admin_update_position_path %>", { id: ui.item.attr('id'), parent_id: ui.item.parent().closest('li').attr('id'), position: ui.item.index() } ); } }); -}); \ No newline at end of file +} \ No newline at end of file diff --git a/app/assets/javascripts/side_bar_history.js b/app/assets/javascripts/side_bar_history.js index ad29b497..f23fd6cc 100644 --- a/app/assets/javascripts/side_bar_history.js +++ b/app/assets/javascripts/side_bar_history.js @@ -1,14 +1,5 @@ var history_edited = false; -$('#back_sidebar a, #back_main a.nav').live('click', - function () { - $.getScript(this.href); - history.pushState(null, document.title, this.href); - history_edited = true; - return false; - } -); - $('#back_main a.reload').live('click', function () { $.getScript(this.href); @@ -18,7 +9,7 @@ $('#back_main a.reload').live('click', } ); -$('#back_main .form').live('submit', function () { +$('#back_main form').live('submit', function () { $.post(this.action, $(this).serialize(), null, 'script'); history_edited = true; return false; diff --git a/app/assets/stylesheets/sidebar.css.erb b/app/assets/stylesheets/sidebar.css.erb index 1e4b4010..1a77e0e7 100644 --- a/app/assets/stylesheets/sidebar.css.erb +++ b/app/assets/stylesheets/sidebar.css.erb @@ -18,6 +18,18 @@ padding: 3px 0px; display: block; } +.nav-list>li>ol { + margin-left: 0; +} +.nav-list>li>.with_action { + padding-left: 0; +} +.nav-list>li>.with_action>.quick-edit { + margin: 0 0 0 3px !important; +} +.nav-list>li>.with_action>i { + display: none; +} /* #back_sidebar h1 { background: url(<%= asset_path "h1_bg.png" %>) repeat-x scroll left top transparent; @@ -126,7 +138,7 @@ background: none repeat scroll 0 0 #FFFFFF; border: 1px solid #DDDDDD; border-radius: 5px 5px 5px 5px; - margin: 0 0 0 3px; + margin: 0 0 0 20px; padding: 0; z-index:1; position: absolute; @@ -155,7 +167,7 @@ ol.nav>li>.icons-moves { } .sortable i { position: absolute; - left: -20px; + left: 0px; top: 6px; margin-right: 0; opacity: 0.3; @@ -166,6 +178,9 @@ ol.nav>li>.icons-moves { opacity: 0.7; filter: alpha(opacity=70); } +.with_action { + padding-left: 20px; +} .placeholder { background-color: rgba(0,136,204,.6); border-radius: 3px; diff --git a/app/controllers/admin/ad_banners_controller.rb b/app/controllers/admin/ad_banners_controller.rb index cd436a12..f43c19e5 100644 --- a/app/controllers/admin/ad_banners_controller.rb +++ b/app/controllers/admin/ad_banners_controller.rb @@ -1,7 +1,7 @@ class Admin::AdBannersController < OrbitBackendController layout "new_admin" before_filter :authenticate_user! - before_filter :for_app_manager,:except => [:index,:show] + before_filter :for_app_manager,:except => [:index,:show,:update,:realtime_preview] before_filter :for_app_sub_manager def rename diff --git a/app/controllers/admin/ad_images_controller.rb b/app/controllers/admin/ad_images_controller.rb index 945629ed..e3cef303 100644 --- a/app/controllers/admin/ad_images_controller.rb +++ b/app/controllers/admin/ad_images_controller.rb @@ -1,8 +1,8 @@ -class Admin::AdImagesController < ApplicationController +class Admin::AdImagesController < OrbitBackendController layout 'new_admin' before_filter :authenticate_user! - before_filter :is_admin? - + before_filter :for_app_sub_manager + def edit @ad_banner = AdBanner.find params[:ad_banner_id] @ad_image = @ad_banner.ad_images.find params[:id] diff --git a/app/controllers/admin/links_controller.rb b/app/controllers/admin/links_controller.rb index 533ff829..c233c18f 100644 --- a/app/controllers/admin/links_controller.rb +++ b/app/controllers/admin/links_controller.rb @@ -65,9 +65,11 @@ class Admin::LinksController < ApplicationController end def delete + @item = Link.find(params[:id]) + @item.destroy respond_to do |format| format.html {} - format.js { destroy } + format.js { @item = @item.parent } end end diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index 44bda4aa..5fc6cb77 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -51,7 +51,7 @@ class Admin::PagesController < ApplicationController def create @item = Page.new(params[:page]) - if @item.module_app.key == 'page_content' + if @item.module_app && @item.module_app.key == 'page_content' @item.page_contexts.build(:create_user_id => current_user.id, :update_user_id => current_user.id ) end @@ -99,14 +99,16 @@ class Admin::PagesController < ApplicationController format.html { redirect_to admin_items_url( :parent_id => @item.parent_id ) } - format.js {} + format.js { redirect_to admin_items_url } end end def delete + @item = Page.find(params[:id]) + @item.destroy respond_to do |format| format.html {} - format.js { destroy } + format.js { @item = @item.parent } end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1455619a..5fd9de5c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -157,7 +157,7 @@ class ApplicationController < ActionController::Base end def get_homepage - Item.first(:conditions => {:parent_id => nil}) + Page.root end def layout_by_resource diff --git a/app/controllers/orbit_backend_controller.rb b/app/controllers/orbit_backend_controller.rb index 98882ec3..339f7ede 100644 --- a/app/controllers/orbit_backend_controller.rb +++ b/app/controllers/orbit_backend_controller.rb @@ -32,13 +32,8 @@ class OrbitBackendController< ApplicationController end def get_sorted_and_filtered(object_class, query=nil) + objects = get_objects(object_class, query) object_class = object_class.classify.constantize - if query - objects = object_class.all.where(query) - else - objects = object_class.all - end - if !params[:sort].blank? options = params[:sort_options] options = [options] if !options.class.eql?(Array) @@ -79,7 +74,7 @@ class OrbitBackendController< ApplicationController when 'categories' a = Array.new objects.each do |object| - a << object if value.include?(object.send("#{object.class.to_s.underscore}_category").id.to_s) + a << object if (value.include?(object.send("#{object.class.to_s.underscore}_category").id.to_s) rescue nil) end objects = a.uniq when 'tags' @@ -93,7 +88,7 @@ class OrbitBackendController< ApplicationController end if value.size > 0 end end - Kaminari.paginate_array(objects).page(params[:page]).per(10) + Kaminari.paginate_array(filter_authorized_objects(objects)).page(params[:page]).per(10) end def get_string_value_from_object(object) @@ -104,9 +99,9 @@ class OrbitBackendController< ApplicationController if s case s.class.to_s when "String" - s.downcase + s.downcase rescue '' when "I18nVariable" - s[I18n.locale].downcase + s[I18n.locale].downcase rescue '' else nil end @@ -157,5 +152,38 @@ class OrbitBackendController< ApplicationController a = params[:direction].eql?('asc') ? (sorted_tmp + sorted_objects) : (sorted_objects + sorted_tmp) a.flatten end + + + def get_viewable(object_class) + objects = get_objects(object_class) + Kaminari.paginate_array(objects).page(params[:page]).per(10) + end + + def get_objects(object_class, query=nil) + object_class = object_class.classify.constantize + if query + objects = object_class.all.where(query) + else + objects = object_class.all + end + objects + end + + def filter_authorized_objects(objects) + if(!is_admin? || !is_manager?) + objects.delete_if{ |object| + if object.is_pending == true + if check_permission(:manager) + object.create_user_id != current_user.id + else + !object.send("#{object.class.to_s.underscore}_category").authed_users('fact_check').include?(current_user) rescue false + end + else + false + end + } + end + objects + end end \ No newline at end of file diff --git a/app/helpers/admin/item_helper.rb b/app/helpers/admin/item_helper.rb index b5ab255e..78e911b9 100644 --- a/app/helpers/admin/item_helper.rb +++ b/app/helpers/admin/item_helper.rb @@ -11,14 +11,14 @@ module Admin::ItemHelper no_nested = 'no-nest' end ret << "
  • " - ret << "" - ret << "
    " - ret << (link_to node.i18n_variable[I18n.locale], dest) + # ret << "" + ret << "
    " + ret << (link_to node.i18n_variable[I18n.locale], dest, :class => 'js_history') ret << "
    " - ret << (link_to t('admin.edit'), eval("edit_admin_#{node._type.downcase}_path(node)")) if node._type.eql?('Page') - ret << (link_to t('admin.new_page'), new_admin_page_path(:parent_id => node.id), :class => 'new_page') if node._type.eql?('Page') - ret << (link_to t('admin.new_link'), new_admin_link_path(:parent_id => node.id), :class => 'new_link') if node._type.eql?('Page') - ret << (link_to t(:delete), eval("delete_admin_#{node._type.downcase}_path(node, :authenticity_token => form_authenticity_token)"), :confirm => t('sure?'), :class => 'delete') + ret << (link_to t('admin.edit'), eval("edit_admin_#{node._type.downcase}_path(node)"), :class => 'js_history') if node._type.eql?('Page') + ret << (link_to t('admin.new_page'), new_admin_page_path(:parent_id => node.id), :class => 'new_page js_history') if node._type.eql?('Page') + ret << (link_to t('admin.new_link'), new_admin_link_path(:parent_id => node.id), :class => 'new_link js_history') if node._type.eql?('Page') + ret << (link_to t(:delete), eval("delete_admin_#{node._type.downcase}_path(node, :authenticity_token => form_authenticity_token)"), :confirm => t('sure?'), :class => 'delete js_history') ret << "
    " ret << "
    " ret << render_children(node) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8f651392..e5d5e374 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -204,4 +204,12 @@ module ApplicationHelper is_manager? || is_admin? end + def display_date_time(object) + object.strftime("%Y-%m-%d %H:%M") + end + + def display_date(object) + object.strftime("%Y-%m-%d") + end + end diff --git a/app/models/asset.rb b/app/models/asset.rb index 22c4ae2d..e20fcb9e 100644 --- a/app/models/asset.rb +++ b/app/models/asset.rb @@ -34,10 +34,10 @@ class Asset protected def set_key - if title.new_record? + if title && title.new_record? title.key = 'title' end - if description.new_record? + if description && description.new_record? description.key = 'description' end end diff --git a/app/models/item.rb b/app/models/item.rb index cdf0f2fb..8dd5c0b4 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -10,16 +10,18 @@ class Item field :is_published, :type => Boolean, :default => false field :enabled_for, :type => Array, :default => nil field :menu_enabled_for, :type => Array, :default => nil + + has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy validates_format_of :name, :with => /^[0-9a-zA-Z\-_]+$/ validates :name, :exclusion => { :in => LIST[:forbidden_item_names] } validates_uniqueness_of :name, :scope => :parent_id validates_presence_of :name - validates_associated :parent, :children + + before_destroy :destroy_children after_rearrange :rebuild_path - has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy def self.find_by_name(item_name) Item.first(:conditions => { :name => item_name, :is_published => true }) diff --git a/app/models/link.rb b/app/models/link.rb index 5b8c15a6..ccd79c89 100644 --- a/app/models/link.rb +++ b/app/models/link.rb @@ -13,7 +13,7 @@ class Link < Item protected def add_http - unless self.url[/^http?s:\/\//] + unless self.url[/^http:\/\//] || self.url[/^https:\/\//] self.url = 'http://' + self.url end end 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 ca98e42e..d65a17e0 100644 --- a/app/views/admin/ad_banners/_ad_banner_tab.html.erb +++ b/app/views/admin/ad_banners/_ad_banner_tab.html.erb @@ -7,6 +7,10 @@ <%= f.select :ad_fx ,AdBanner::FX_TYPES %> <%= f.label :transition_sec, t('admin.ad.transition_sec') %> <%= f.text_field :transition_sec,:placeholder=>t('admin.ad.sec_place_holder'),:class=> "span3" %> <%= t("admin.ad.trans_unit_sec") %> + <%if at_least_module_manager%> + <%= f.label :best_size, t('admin.ad.best_size') %> + <%= f.text_field :best_size %> Ex: 500px x 300px + <% end -%>
    <%= f.submit t("admin.ad.update_banner"), :class => 'btn' %> <%= f.submit t("cancel"),:type=>'reset', :class => 'btn' %> 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 cbc4de8e..68e0a9c6 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 @@ -21,6 +21,13 @@ <%= f.text_field :transition_sec %> <%= t("admin.ad.trans_unit_sec") %>
    + +
    + <%= f.label :best_size, t('admin.ad.best_size'),:class => "control-label" %> +
    + <%= f.text_field :best_size %> Ex: 500px x 300px +
    +
    <%= f.label :ad_fx, t('admin.ad.ab_fx') %> diff --git a/app/views/admin/ad_banners/index.html.erb b/app/views/admin/ad_banners/index.html.erb index b4be090f..92c78f5b 100644 --- a/app/views/admin/ad_banners/index.html.erb +++ b/app/views/admin/ad_banners/index.html.erb @@ -13,11 +13,16 @@ diff --git a/app/views/admin/ad_images/_form.html.erb b/app/views/admin/ad_images/_form.html.erb index 1513fa05..edbb2563 100644 --- a/app/views/admin/ad_images/_form.html.erb +++ b/app/views/admin/ad_images/_form.html.erb @@ -80,7 +80,10 @@ <%= image_tag @ad_image.file rescue ''%>
    - <%= t("admin.ad.widget_info_for_ad_image_size",:best_size=> @ad_image.ad_banner.best_size) if !@ad_image.ad_banner.best_size.empty?%> + <% if !@ad_image.ad_banner.best_size.empty?%> + <%= t("admin.ad.widget_info_for_ad_image_size",:best_size=> @ad_image.ad_banner.best_size) %> + + <% end -%>