From 37f6037333c1aae74d5ea6817db8d68bc9f209f8 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Thu, 19 Jul 2012 15:44:44 +0800 Subject: [PATCH] Gallery started. --- app/assets/javascripts/rss.js | 8 ++--- app/controllers/desktop_controller.rb | 1 - app/views/layouts/_side_bar.html.erb | 1 + .../gallery/app/assets/javascripts/gallery.js | 1 + .../app/assets/javascripts/gallery/.gitkeep | 0 .../app/assets/javascripts/galleryAPI.js | 27 +++++++++++++++++ .../back_end/orbit_galleries_controller.rb | 11 +++++++ .../gallery/app/models/gallery_category.rb | 6 ++++ .../back_end/orbit_galleries/index.html.erb | 29 +++++++++++++++++++ .../built_in_modules/gallery/config/routes.rb | 9 ++++++ 10 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 vendor/built_in_modules/gallery/app/assets/javascripts/gallery.js delete mode 100644 vendor/built_in_modules/gallery/app/assets/javascripts/gallery/.gitkeep create mode 100644 vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI.js create mode 100644 vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/orbit_galleries_controller.rb create mode 100644 vendor/built_in_modules/gallery/app/models/gallery_category.rb create mode 100644 vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/orbit_galleries/index.html.erb diff --git a/app/assets/javascripts/rss.js b/app/assets/javascripts/rss.js index 737b08b71..5c17622f3 100644 --- a/app/assets/javascripts/rss.js +++ b/app/assets/javascripts/rss.js @@ -384,14 +384,12 @@ modalWindow : function(settings,callbackFn){ if(tempheight>maxheight) tempheight=maxheight; }else{tempheight="auto";} - if(typeof tempwidth!="undefined"){ if(tempwidth.charAt(tempwidth.length-1)=='%') tempwidth=(rgmaskWidth*parseInt(tempwidth.substr(0,tempwidth.length)))/100; if(tempwidth>maxwidth) tempwidth=maxwidth; }else{tempwidth="auto";} - $rss("body").append('
'); $rss("#rgsheath").css({background: "#000", width: "100%", position: "fixed", top: 0, left: 0,opacity:0.5,'z-index':199}); $rss("body").append('
'); @@ -400,7 +398,7 @@ modalWindow : function(settings,callbackFn){ var rgWLeft = (rgmaskWidth-20)/2; $rss("#rgWindow").css({top:rgWTop+"px", left:rgWLeft+"px"}); if(typeof settings.loadDiv!="undefined"){ - dhtml = $rss("#"+settings.loadDiv).html(); + dhtml = $rss(settings.loadDiv).html(); $rss("#rgWindow").html(dhtml).hide(); prepareWindow(); } @@ -416,7 +414,7 @@ modalWindow : function(settings,callbackFn){ if(tempheight!="auto") rgWTop = (rgmaskHeight-tempheight)/2; else{ - tempheight=$rss("#rgWindow").height(); + tempheight=$rss("#rgWindow").height()+30; if(tempheight>maxheight) tempheight=maxheight; rgWTop=(rgmaskHeight-tempheight)/2; @@ -451,7 +449,7 @@ modalWindow : function(settings,callbackFn){ $rss("#rgWindow").animate({top:x+"px", left:y+"px","width":"50px","height":"50px"},300,function(){$rss(this).fadeOut(100).remove();$rss("#rgsheath").fadeOut(500).remove();});}) if(typeof callbackFn=="function") - callbackFn.call(this,dhtml); + callbackFn.call(this,$rss("#rgWindow")); }); } }, diff --git a/app/controllers/desktop_controller.rb b/app/controllers/desktop_controller.rb index 93816d713..286ec1c46 100644 --- a/app/controllers/desktop_controller.rb +++ b/app/controllers/desktop_controller.rb @@ -1,4 +1,3 @@ - class DesktopController< ApplicationController layout 'desktop' before_filter :authenticate_user! diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index 73b5191ae..e00289386 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -75,3 +75,4 @@ <%#= content_tag :li, link_to(t('admin.tags'), admin_asset_tags_path), :class => active_for_action('/admin/asset_tags', 'index') %> <%# end -%> <%# end -%> + diff --git a/vendor/built_in_modules/gallery/app/assets/javascripts/gallery.js b/vendor/built_in_modules/gallery/app/assets/javascripts/gallery.js new file mode 100644 index 000000000..a683941f9 --- /dev/null +++ b/vendor/built_in_modules/gallery/app/assets/javascripts/gallery.js @@ -0,0 +1 @@ +//= require galleryAPI \ No newline at end of file diff --git a/vendor/built_in_modules/gallery/app/assets/javascripts/gallery/.gitkeep b/vendor/built_in_modules/gallery/app/assets/javascripts/gallery/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI.js b/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI.js new file mode 100644 index 000000000..e05fb2eb9 --- /dev/null +++ b/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI.js @@ -0,0 +1,27 @@ +var galleryAPI = function(){ + g = this; + + this.initialize = function(){ + $(document).ready(function(){ + bindHandlers() + }) + var bindHandlers = function(){ + $("#gallery_panel a.btn").click(function(){ + rcom.modalWindow({loadDiv:"#"+$(this).attr("href"),width:"400"},function(dom){ + console.log(dom) + dom.find("#category_save_btn").click(function(){ + var lang = { + "en" : dom.find("#category_name_en").val(), + "zh_tw" : dom.find("#category_name_zh_tw").val() + } + $.post("gallery_category_save",{"category":lang},function(){ + + }) + return false; + }) + }); + return false; + }) + } + } +} \ No newline at end of file diff --git a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/orbit_galleries_controller.rb b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/orbit_galleries_controller.rb new file mode 100644 index 000000000..cbe9880b7 --- /dev/null +++ b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/orbit_galleries_controller.rb @@ -0,0 +1,11 @@ +class Panel::Gallery::BackEnd::OrbitGalleriesController < OrbitBackendController + + def index + end + + def new_category + GalleryCategory.create(language_value: params["category"]) + render :json=>{"success"=>"true"}.to_json + end + +end \ No newline at end of file diff --git a/vendor/built_in_modules/gallery/app/models/gallery_category.rb b/vendor/built_in_modules/gallery/app/models/gallery_category.rb new file mode 100644 index 000000000..17e982720 --- /dev/null +++ b/vendor/built_in_modules/gallery/app/models/gallery_category.rb @@ -0,0 +1,6 @@ +class GalleryCategory + include Mongoid::Document + include Mongoid::Timestamps + + has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy +end \ No newline at end of file diff --git a/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/orbit_galleries/index.html.erb b/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/orbit_galleries/index.html.erb new file mode 100644 index 000000000..2228143c7 --- /dev/null +++ b/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/orbit_galleries/index.html.erb @@ -0,0 +1,29 @@ +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "galleryAPI" %> +<% end %> + + + + + \ No newline at end of file diff --git a/vendor/built_in_modules/gallery/config/routes.rb b/vendor/built_in_modules/gallery/config/routes.rb index 1daf9a412..ae516d3f6 100644 --- a/vendor/built_in_modules/gallery/config/routes.rb +++ b/vendor/built_in_modules/gallery/config/routes.rb @@ -1,2 +1,11 @@ Rails.application.routes.draw do + namespace :panel do + namespace :gallery do + namespace :back_end do + match "orbit_gallery" => "orbit_galleries#index" + match "gallery_category_save" => "orbit_galleries#new_category" + + end + end + end end