Got gallery update

This commit is contained in:
Harry Bomrah 2012-07-19 15:51:41 +08:00
commit 59ab1e6d17
10 changed files with 91 additions and 7 deletions

View File

@ -384,14 +384,12 @@ modalWindow : function(settings,callbackFn){
if(tempheight>maxheight) if(tempheight>maxheight)
tempheight=maxheight; tempheight=maxheight;
}else{tempheight="auto";} }else{tempheight="auto";}
if(typeof tempwidth!="undefined"){ if(typeof tempwidth!="undefined"){
if(tempwidth.charAt(tempwidth.length-1)=='%') if(tempwidth.charAt(tempwidth.length-1)=='%')
tempwidth=(rgmaskWidth*parseInt(tempwidth.substr(0,tempwidth.length)))/100; tempwidth=(rgmaskWidth*parseInt(tempwidth.substr(0,tempwidth.length)))/100;
if(tempwidth>maxwidth) if(tempwidth>maxwidth)
tempwidth=maxwidth; tempwidth=maxwidth;
}else{tempwidth="auto";} }else{tempwidth="auto";}
$rss("body").append('<div class="rgmask" id="rgsheath" style="height:'+rgmaskHeight+'px"></div>'); $rss("body").append('<div class="rgmask" id="rgsheath" style="height:'+rgmaskHeight+'px"></div>');
$rss("#rgsheath").css({background: "#000", width: "100%", position: "fixed", top: 0, left: 0,opacity:0.5,'z-index':199}); $rss("#rgsheath").css({background: "#000", width: "100%", position: "fixed", top: 0, left: 0,opacity:0.5,'z-index':199});
$rss("body").append('<div id="rgWindow"></div>'); $rss("body").append('<div id="rgWindow"></div>');
@ -400,7 +398,7 @@ modalWindow : function(settings,callbackFn){
var rgWLeft = (rgmaskWidth-20)/2; var rgWLeft = (rgmaskWidth-20)/2;
$rss("#rgWindow").css({top:rgWTop+"px", left:rgWLeft+"px"}); $rss("#rgWindow").css({top:rgWTop+"px", left:rgWLeft+"px"});
if(typeof settings.loadDiv!="undefined"){ if(typeof settings.loadDiv!="undefined"){
dhtml = $rss("#"+settings.loadDiv).html(); dhtml = $rss(settings.loadDiv).html();
$rss("#rgWindow").html(dhtml).hide(); $rss("#rgWindow").html(dhtml).hide();
prepareWindow(); prepareWindow();
} }
@ -416,7 +414,7 @@ modalWindow : function(settings,callbackFn){
if(tempheight!="auto") if(tempheight!="auto")
rgWTop = (rgmaskHeight-tempheight)/2; rgWTop = (rgmaskHeight-tempheight)/2;
else{ else{
tempheight=$rss("#rgWindow").height(); tempheight=$rss("#rgWindow").height()+30;
if(tempheight>maxheight) if(tempheight>maxheight)
tempheight=maxheight; tempheight=maxheight;
rgWTop=(rgmaskHeight-tempheight)/2; 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();});}) $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") if(typeof callbackFn=="function")
callbackFn.call(this,dhtml); callbackFn.call(this,$rss("#rgWindow"));
}); });
} }
}, },

View File

@ -1,4 +1,3 @@
class DesktopController< ApplicationController class DesktopController< ApplicationController
layout 'desktop' layout 'desktop'
before_filter :authenticate_user! before_filter :authenticate_user!

View File

@ -75,3 +75,4 @@
<%#= content_tag :li, link_to(t('admin.tags'), admin_asset_tags_path), :class => active_for_action('/admin/asset_tags', 'index') %> <%#= content_tag :li, link_to(t('admin.tags'), admin_asset_tags_path), :class => active_for_action('/admin/asset_tags', 'index') %>
<%# end -%> <%# end -%>
<%# end -%> <%# end -%>

View File

@ -0,0 +1 @@
//= require galleryAPI

View File

@ -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;
})
}
}
}

View File

@ -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

View File

@ -0,0 +1,6 @@
class GalleryCategory
include Mongoid::Document
include Mongoid::Timestamps
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
end

View File

@ -0,0 +1,29 @@
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "galleryAPI" %>
<% end %>
<div id="orbit_gallery">
</div>
<div id="gallery_panel">
<a class="btn" href="categories" >Manage Categories</a>
<a class="btn" href="albums">Manage Albums</a>
</div>
<div class="modal hide fade" id="categories">
<div class="modal-header">
<h3>Categories</h3>
</div>
<div class="modal-body">
<p>All Categories</p>
</div>
<div class="modal-footer">
New Category[English] : <input type="text" id="category_name_en"></text><br />
New Category[Chinese] : <input type="text" id="category_name_zh_tw"></text><br />
<a href="#" class="btn" data-dismiss="modal">Close</a>
<a href="#" class="btn btn-primary" id="category_save_btn">Save changes</a>
</div>
</div>
<script type="text/javascript">
var gallery = new galleryAPI();
gallery.initialize();
</script>

View File

@ -1,2 +1,14 @@
Rails.application.routes.draw do Rails.application.routes.draw do
<<<<<<< HEAD
=======
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
>>>>>>> gallery_orbit
end end