diff --git a/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI.js.erb b/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI.js.erb index 57d13bc55..80c21c4bd 100644 --- a/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI.js.erb +++ b/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI.js.erb @@ -56,26 +56,26 @@ var galleryAPI = function(){ this.makeNewAlbum = function(path){ $.get(path,function(html){ rcom.modalWindow({loadHtml:html,width:400,height:320,"closeBtn":false},function(dom){ - dom.find("#album_name_save_btn").click(function(){ - var options ={ - cid : dom.find("select#category_list").val(), - albumname : { - "en" : dom.find("#name_en").val(), - "zh_tw" : dom.find("#name_zh_tw").val() - }, - albumdesc : { - "en" : dom.find("#desc_en").val(), - "zh_tw" : dom.find("#desc_zh_tw").val() - } - } - if(options.cid){ - $.post("albums/create",options,function(response){ - if(g.loadArea == "albums") - g.loadAlbums("all"); - rcom.modalWindowClose(); - }) - } - }) + // dom.find("#album_name_save_btn").click(function(){ + // var options ={ + // cid : dom.find("select#category_list").val(), + // albumname : { + // "en" : dom.find("#name_en").val(), + // "zh_tw" : dom.find("#name_zh_tw").val() + // }, + // albumdesc : { + // "en" : dom.find("#desc_en").val(), + // "zh_tw" : dom.find("#desc_zh_tw").val() + // } + // } + // if(options.cid){ + // $.post("albums/create",options,function(response){ + // if(g.loadArea == "albums") + // g.loadAlbums("all"); + // rcom.modalWindowClose(); + // }) + // } + // }) dom.find("#album_name_close_btn").click(function(){ rcom.modalWindowClose(); }) @@ -87,9 +87,9 @@ var galleryAPI = function(){ if(confirm("<%= I18n.t('gallery.del_album?') %>")){ $.ajax({ type: "DELETE", - url : "albums/"+id, + url : id, success : function(){ - window.location = "albums"; + window.location = "../albums"; } }) } @@ -200,8 +200,6 @@ var galleryAPI = function(){ g.albumArea.addClass('o_album'); g.albumArea.find(".rghead .rgfn").append(uploadpanel); g.albumArea.find("#imgholder").empty(); - $("#filter").remove(); - g.albumArea.css("margin-top",""); $.getJSON(id+"/imgs",function(album){ $.each(album.images,function(i,image){ var thumb = image.file.thumb.url; @@ -390,6 +388,7 @@ var galleryAPI = function(){ } var changeImage = function(dom){ var pageurl = dom.attr('href'); + $img.fadeOut(200,function(){ $img.attr({"src":dom.attr("data-content"),"height":picHeight+"px"}); $img.fadeIn(200); @@ -398,9 +397,13 @@ var galleryAPI = function(){ } $slidelist.stop().animate({'height':'0px'}, 300); $slidelist.find("ul").hide(); - if(pageurl!=window.location){ - window.history.pushState({path:pageurl},'',pageurl); - } + if(rcom.getInternetExplorerVersion() == -1){ + if(pageurl!=window.location){ + window.history.pushState({path:pageurl},'',pageurl); + } + }else{ + window.location.hash = pageurl; + } // $(".slideinfo b.info").text(imageArray[imagecount].title); if($('.bt-tag').hasClass("active")) updatePhotoTag(); @@ -439,7 +442,19 @@ var galleryAPI = function(){ bindHandlers(); }) } - + if(rcom.getInternetExplorerVersion()!=-1){ + var url_constructor = window.location.href.split("/"); + var url = ""; + for(x=0;x<=url_constructor.length-1;x++){ + if(x == url_constructor.length-1){ + url+="#!/"+url_constructor[x]; + }else{ + url+=url_constructor[x]+"/"; + } + } + + window.location.href = url; + } var albumid = $("#main_pic").attr("data-content"); g.albumArea.find(".bt-back").attr("href","../albums/"+albumid); @@ -466,28 +481,23 @@ var galleryAPI = function(){ $(this) .toggleClass("setdelete btn-danger active") .find('span').toggleClass('icon-white'); - if($(".description_loader .edit_fn .setdelete").length > 0){ - g.albumArea.find(".rghead .rgfn .bt-delete").show(); + if($(".description_loader .edit_fn .setdelete").length > 0) + g.albumArea.find(".rghead .rgfn .bt-save").show(); + + if($(this).hasClass("active")){ + $(this).parent().parent().find("input.del_field").val(true); }else{ - g.albumArea.find(".rghead .rgfn .bt-delete").hide(); + $(this).parent().parent().find("input.del_field").val(false); } + delete_cover(); }) - g.albumArea.find(".rghead .rgfn .bt-save").click(function(){ - // var dataArray = Array(); - // $(".description_loader .en .txtchange").each(function(){ - // var thisid = $(this).attr("for"); - // dataArray.push({"id":thisid,"text":{"en":$(this).val(),"zh_tw":$(".description_loader .zh_tw .txtchange[for="+thisid+"]").val()}}); - // }) - // var albumnm = Array(); - // $(".albumname_edit .txtchange").each(function(){ - // albumnm.push($(this).val()) - // }) - // var dataArray = $("form#edit_album").serialize(); - // $.post("update_album",{"data":dataArray},function(){ - - // }) - - }) + var delete_cover = function(){ + if($(".description_loader .setcover").parent().find(".bt-dels").hasClass("active")){ + $("input.del_cover").val(true); + }else{ + $("input.del_cover").val(false); + } + } var current_element_for_tags = null; var current_element_no = null; $('.bt-tag').click(function(){ diff --git a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/albums_controller.rb b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/albums_controller.rb index e3441fad6..28b20150a 100644 --- a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/albums_controller.rb +++ b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/albums_controller.rb @@ -28,22 +28,27 @@ include AdminHelper elsif is_sub_manager? @categorylist = GalleryCategory.authed_for_user(current_user,"new_album") end + @album = GalleryAlbum.new render :layout => false end def create - category = GalleryCategory.find(params['cid']) - albumnames = params["albumname"] - albumdescs = params["albumdesc"] - album = category.gallery_albums.new - I18n.locale = :en - album.name = albumnames["en"] - album.description = albumdescs["en"] - I18n.locale = :zh_tw - album.name = albumnames["zh_tw"] - album.description = albumdescs["zh_tw"] + # category = GalleryCategory.find(params['cid']) + # albumnames = params["albumname"] + # albumdescs = params["albumdesc"] + # album = category.gallery_albums.new + # I18n.locale = :en + # album.name = albumnames["en"] + # album.description = albumdescs["en"] + # I18n.locale = :zh_tw + # album.name = albumnames["zh_tw"] + # album.description = albumdescs["zh_tw"] + album = GalleryAlbum.new(params[:gallery_album]) album.save! - render :json=>{"success"=>true,"id"=>album.id}.to_json + # render :json=>{"success"=>true,"id"=>album.id}.to_json + respond_to do |h| + h.js + end end def get_albums @@ -170,15 +175,16 @@ include AdminHelper end def update - debugger @album = GalleryAlbum.find(params[:id]) - #album.update_attributes(params[:gallery_album]) + @album.update_attributes(params[:gallery_album]) if is_manager? || is_admin? || is_sub_manager? @authenticated = true #turn this value to false for view only else @authenticated = false end - + if params['delete_cover'] == "true" + @album.update_attributes(:cover=>"default") + end @tags = GalleryTag.all render :action => :show end diff --git a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/gallery_categories_controller.rb b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/gallery_categories_controller.rb index 06432b1b4..9c2e1c348 100644 --- a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/gallery_categories_controller.rb +++ b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/gallery_categories_controller.rb @@ -2,24 +2,32 @@ class Panel::Gallery::BackEnd::GalleryCategoriesController < OrbitBackendControl def index @categorylist = GalleryCategory.all - #render :layout => false + @new_category = GalleryCategory.new + end + def edit + @category = GalleryCategory.find(params[:id]) + render :layout => false + end + def create + @category = GalleryCategory.new(params[:gallery_category]) + @category.save! + respond_to do |h| + h.js + end + end + def update + @category = GalleryCategory.find(params[:id]) + @category.update_attributes(params[:gallery_category]) + respond_to do |h| + h.js + end end - def new - names = params['category'] - category = GalleryCategory.new - I18n.locale = :en - category.name = names['en'] - I18n.locale = :zh_tw - category.name = names['zh_tw'] - category.save! - render :json=>{"success"=>true,"id"=>category.id}.to_json - end - - def delete + def destroy @category = GalleryCategory.find(params['id']) @category.delete render :json=>{"success"=>"true"}.to_json end -end \ No newline at end of file +end + diff --git a/vendor/built_in_modules/gallery/app/models/gallery_album.rb b/vendor/built_in_modules/gallery/app/models/gallery_album.rb index b16e32892..03daa383b 100644 --- a/vendor/built_in_modules/gallery/app/models/gallery_album.rb +++ b/vendor/built_in_modules/gallery/app/models/gallery_album.rb @@ -11,5 +11,6 @@ class GalleryAlbum belongs_to :gallery_category has_and_belongs_to_many :tags, :class_name => "GalleryTag" has_many :gallery_images, :autosave => true, :dependent => :destroy + accepts_nested_attributes_for :gallery_images, :allow_destroy => true end \ No newline at end of file diff --git a/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/album_images/index.html.erb b/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/album_images/index.html.erb deleted file mode 100644 index 1ad6b10bf..000000000 --- a/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/album_images/index.html.erb +++ /dev/null @@ -1,95 +0,0 @@ - -<%= stylesheet_link_tag "gallery" %> - -
+ <%= label_tag(locale, t("gallery.album_name")) %> + <%= name.text_field locale %> +
++ <%= label_tag(locale, t("gallery.album_desc")) %> + <%= desc.text_field locale %> +
+