From 199839a42a40336302f57c543dcfbe9a157a5e59 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Mon, 3 Sep 2012 21:49:35 +0800 Subject: [PATCH] frontend update --- .../app/assets/javascripts/galleryAPI.js.erb | 132 ++++---- .../javascripts/galleryAPI_frontend.js.erb | 292 +++++------------- .../gallery/back_end/albums_controller.rb | 11 - .../front_end/album_images_controller.rb | 11 + .../gallery/front_end/albums_controller.rb | 114 +++++++ .../gallery/back_end/albums/index.html.erb | 53 +--- .../gallery/back_end/albums/new.html.erb | 6 +- .../front_end/album_images/show.html.erb | 65 ++++ .../album_images/upload_panel.html.erb | 111 +++++++ .../gallery/front_end/albums/create.js.erb | 3 + .../gallery/front_end/albums/edit.html.erb | 137 ++++++++ .../gallery/front_end/albums/index.html.erb | 42 +++ .../gallery/front_end/albums/new.html.erb | 51 +++ .../gallery/front_end/albums/show.html.erb | 45 +++ .../front_end/albums/upload_panel.html.erb | 107 +++++++ .../gallery/config/locales/en.yml | 1 + .../built_in_modules/gallery/config/routes.rb | 43 +-- 17 files changed, 853 insertions(+), 371 deletions(-) create mode 100644 vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/album_images_controller.rb create mode 100644 vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/albums_controller.rb create mode 100644 vendor/built_in_modules/gallery/app/views/panel/gallery/front_end/album_images/show.html.erb create mode 100755 vendor/built_in_modules/gallery/app/views/panel/gallery/front_end/album_images/upload_panel.html.erb create mode 100644 vendor/built_in_modules/gallery/app/views/panel/gallery/front_end/albums/create.js.erb create mode 100644 vendor/built_in_modules/gallery/app/views/panel/gallery/front_end/albums/edit.html.erb create mode 100644 vendor/built_in_modules/gallery/app/views/panel/gallery/front_end/albums/index.html.erb create mode 100644 vendor/built_in_modules/gallery/app/views/panel/gallery/front_end/albums/new.html.erb create mode 100644 vendor/built_in_modules/gallery/app/views/panel/gallery/front_end/albums/show.html.erb create mode 100755 vendor/built_in_modules/gallery/app/views/panel/gallery/front_end/albums/upload_panel.html.erb 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 80c21c4b..54f5371c 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 @@ -34,48 +34,40 @@ var galleryAPI = function(){ window.location = url; } }) - - } - $("#filter .filter-clear a").click(function(){ - var loc = window.location.href; - var url = null; - var forwhat = $(this).attr("for"); - $("#filter ."+forwhat+" a.active").each(function(){ - $(this).removeClass("active"); - url = loc.replace($(this).attr("href")+"&",""); - if(url == loc) - url = loc.replace($(this).attr("href"),""); + $("#filter .filter-clear a").click(function(){ + var loc = window.location.href; + var url = null; + var forwhat = $(this).attr("for"); + $("#filter ."+forwhat+" a.active").each(function(){ + $(this).removeClass("active"); + url = loc.replace($(this).attr("href")+"&",""); + if(url == loc) + url = loc.replace($(this).attr("href"),""); - if(url.charAt(url.length-1)=="&" || url.charAt(url.length-1)=="?") - url = url.substr(0,url.length-1); - loc = url; + if(url.charAt(url.length-1)=="&" || url.charAt(url.length-1)=="?") + url = url.substr(0,url.length-1); + loc = url; + }) + window.location = url; }) - window.location = url; - }) + } + } 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(); - // }) - // } - // }) + $("form#new_gallery_album").submit(function(){ + var validated = true; + $(this).find(".error").removeClass("error"); + $(this).find(".validate").each(function(){ + if(!$(this).val()){ + validated = false; + $(this).parent().addClass("error"); + } + }) + if(!validated) + return false; + }) dom.find("#album_name_close_btn").click(function(){ rcom.modalWindowClose(); }) @@ -103,6 +95,7 @@ var galleryAPI = function(){ var cids = []; var tids = []; var href = null; + console.log(cids); var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); for(var i = 0; i < hashes.length; i++){ hash = hashes[i].split('='); @@ -123,6 +116,7 @@ var galleryAPI = function(){ $.getJSON("get_albums",{cid:cids,tid:tids},function(categories){ $.each(categories,function(x,category){ $.each(category,function(i,album){ + album.description = (album.description?album.description:"<%= I18n.t('gallery.no_description') %>") if(album.cover == "default") var $img = $("
"+album.name+""+album.category_name+"
"); else @@ -203,6 +197,7 @@ var galleryAPI = function(){ $.getJSON(id+"/imgs",function(album){ $.each(album.images,function(i,image){ var thumb = image.file.thumb.url; + image.description = (image.description?image.description:"<%= I18n.t('gallery.no_description') %>") var $img = $("
"); g.albumArea.find("#imgholder").append($img); }) @@ -473,8 +468,8 @@ var galleryAPI = function(){ $(".description_loader .edit_fn .bt-cover").click(function(){ $(".bt-cover").removeClass("setcover active btn-primary"); $(".bt-cover span").removeClass("icon-white icon-star").addClass("icon-star-empty"); - $(".bt-cover[for="+$(this).attr("for")+"]").addClass("setcover active btn-primary"); - $(".bt-cover[for="+$(this).attr("for")+"]").find("span").removeClass("icon-star-empty").addClass("icon-white icon-star"); + $(this).addClass("setcover active btn-primary"); + $(this).find("span").removeClass("icon-star-empty").addClass("icon-white icon-star"); $.post("set_cover",{"imageid":$(this).attr("for")}); }) $(".description_loader .edit_fn .bt-dels").click(function(){ @@ -573,38 +568,37 @@ var galleryAPI = function(){ if($(this).val() != tempval) g.albumArea.find(".rghead .rgfn .bt-save").show(); }) - g.albumArea.find(".rghead .rgfn .bt-delete").click(function(){ - var deleteurl = $(this).attr("href"); - var images_to_delete = new Array(); - var delete_cover = false; - var doms_to_delete = new Array(); - var thiscover = $(".description_loader .edit_fn .setcover").attr("for"); - $(".description_loader .edit_fn .bt-dels").each(function(){ - if($(this).hasClass("setdelete")){ - images_to_delete.push($(this).attr("href")); - $(".tab_content .rgphoto_edit[data-content="+$(this).attr("href")+"]").each(function(){ - doms_to_delete.push($(this)); - }) - if(thiscover == $(this).attr("href")) - delete_cover = true; - } - }) - if(confirm("Deleting "+images_to_delete.length+" image(s)?")){ - $.ajax({ - data : {"images":images_to_delete,"delete_cover":delete_cover}, - type : "DELETE", - url : deleteurl+"/"+id, // have to ask chris about delete resource - success : function(){ - for(dom in doms_to_delete){ - doms_to_delete[dom].hide("slide",function(){$(this).remove();}) - } - g.albumArea.find(".rghead .rgfn .bt-delete").hide(); - } - }) - } - }) + // g.albumArea.find(".rghead .rgfn .bt-delete").click(function(){ + // var deleteurl = $(this).attr("href"); + // var images_to_delete = new Array(); + // var delete_cover = false; + // var doms_to_delete = new Array(); + // var thiscover = $(".description_loader .edit_fn .setcover").attr("for"); + // $(".description_loader .edit_fn .bt-dels").each(function(){ + // if($(this).hasClass("setdelete")){ + // images_to_delete.push($(this).attr("href")); + // $(".tab_content .rgphoto_edit[data-content="+$(this).attr("href")+"]").each(function(){ + // doms_to_delete.push($(this)); + // }) + // if(thiscover == $(this).attr("href")) + // delete_cover = true; + // } + // }) + // if(confirm("Deleting "+images_to_delete.length+" image(s)?")){ + // $.ajax({ + // data : {"images":images_to_delete,"delete_cover":delete_cover}, + // type : "DELETE", + // url : deleteurl+"/"+id, // have to ask chris about delete resource + // success : function(){ + // for(dom in doms_to_delete){ + // doms_to_delete[dom].hide("slide",function(){$(this).remove();}) + // } + // g.albumArea.find(".rghead .rgfn .bt-delete").hide(); + // } + // }) + // } + // }) } - $("#filter").remove(); g.albumArea.addClass('o_album_edit'); var imageTagArray = null; $.getJSON("images_tags",function(data){ diff --git a/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI_frontend.js.erb b/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI_frontend.js.erb index a353b768..8c9ab040 100644 --- a/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI_frontend.js.erb +++ b/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI_frontend.js.erb @@ -9,130 +9,26 @@ var galleryAPI = function(){ this.urlVars = rcom.getUrlVars(); this.albumArea = $("#orbit_gallery"); this.loadArea = null; - this.tagList = $("ul#gallery_tag_list"); + this.tagList = $("ul#.tag_list"); // this.authenticated = false; this.initialize = function(callbackFn){ $(document).ready(function(){ - bindHandlers(); - var passid = null; - if(typeof g.urlVars['cat']!= "undefined"){ - g.loadArea = "albums"; - passid = g.urlVars['cat']; - g.loadAlbums(g.urlVars['cat']); - }else if(typeof g.urlVars['album']!= "undefined"){ - g.loadArea = "images"; - passid = g.urlVars['album']; - g.loadImages(g.urlVars['album']); - }else if(typeof g.urlVars['theater']!= "undefined"){ - g.loadArea = "theater"; - passid = g.urlVars['theater']; - g.loadTheater(g.urlVars['theater']); - }else if(typeof g.urlVars['edit']!= "undefined"){ - g.loadArea = "edit"; - passid = g.urlVars['edit']; - g.editAlbum(g.urlVars['edit']); - }else if(typeof g.urlVars['tag']!= "undefined"){ - g.loadArea = "albums"; - passid = g.urlVars['tag']; - g.loadAlbums(g.urlVars['tag']); - }else if(g.urlVars["locale"]){ - g.loadArea = "albums"; - g.loadAlbums("all"); - }else if(g.urlVars.length == 0) { - g.loadArea = "albums"; - g.loadAlbums("all"); - } - if(typeof callbackFn == "function"){ - callbackFn.call(this,g.loadArea,passid); - } + //bindHandlers(); }) var bindHandlers = function(){ - $("#filter .filter_btns a").click(function(){ - if(!$(this).hasClass("active")){ - $(this).addClass("active"); - if(g.urlVars.length == 0) - window.location = "gallery?" + $(this).attr("href"); - else - window.location = window.location.href +"&"+ $(this).attr("href"); - }else{ - $(this).removeClass("active"); - var loc = window.location.href; - var url = loc.replace($(this).attr("href")+"&",""); - if(url == loc) - url = loc.replace($(this).attr("href"),""); - - if(url.charAt(url.length-1)=="&" || url.charAt(url.length-1)=="?") - url = url.substr(0,url.length-1); - window.location = url; - } - }) } - $("#filter .filter-clear a").click(function(){ - var loc = window.location.href; - var url = null; - var forwhat = $(this).attr("for"); - $("#filter ."+forwhat+" a.active").each(function(){ - $(this).removeClass("active"); - url = loc.replace($(this).attr("href")+"&",""); - if(url == loc) - url = loc.replace($(this).attr("href"),""); - - if(url.charAt(url.length-1)=="&" || url.charAt(url.length-1)=="?") - url = url.substr(0,url.length-1); - loc = url; - }) - window.location = url; - }) - } - this.makeNewAlbum = function(){ - $.get("add_album",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("create_album",options,function(response){ - if(g.loadArea == "albums") - g.loadAlbums("all"); - rcom.modalWindowClose(); - }) - } - }) - dom.find("#album_name_close_btn").click(function(){ - rcom.modalWindowClose(); - }) - }) - - }) } this.loadAlbums = function(id){ - g.loadFooterPanel(g.loadArea,id,function(headbtn){ - headbtn = $(headbtn); - headbtn.click(function(){g.makeNewAlbum();}) - //g.albumArea.find(".rghead .rgfn").html(headbtn); - g.albumArea.find(".rghead").hide(); - }) - + g.albumArea.find(".rghead .rgfn a").click(function(){g.makeNewAlbum($(this).attr("href"))}); g.albumArea.addClass('o_gallery'); g.albumArea.find("#imgholder").empty(); - // var $addsign = $('
Add Album
'); - // $addsign.find("a").click(function(){g.makeNewAlbum();}) - if(id!="all"){ var cids = []; var tids = []; var href = null; + console.log(cids); var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); for(var i = 0; i < hashes.length; i++){ hash = hashes[i].split('='); @@ -153,107 +49,35 @@ var galleryAPI = function(){ $.getJSON("panel/gallery/front_end/get_albums",{cid:cids,tid:tids,"inner":true},function(categories){ $.each(categories,function(x,category){ $.each(category,function(i,album){ + album.description = (album.description?album.description:"<%= I18n.t('gallery.no_description') %>") if(album.cover == "default") - var $img = $("
"+album.name+" "+album.category_name+"
"); + var $img = $("
"+album.name+" "+album.category_name+"
"); else - var $img = $("
"+album.name+" "+album.category_name+"
"); + var $img = $("
"+album.name+" "+album.category_name+"
"); var tag_string = ""; for(tag in album.tag_names){ - tag_string+= '' + album.tag_names[tag] + ', '; + if(tag == album.tag_names.length-1) + tag_string+= '' + album.tag_names[tag] + ''; + else + tag_string+= '' + album.tag_names[tag] + ', '; } $img.find(".tagnames").html(tag_string); g.albumArea.find("#imgholder").append($img); }) }) - // g.albumArea.find("#imgholder").append($addsign); }) } this.loadImages = function(id){ - var panelopen = false; - g.loadFooterPanel(g.loadArea,id,function(headerPanel){ - headarea = $(headerPanel); - g.albumArea.find(".rghead .rgfn").html(headarea); - // $('.bt-tag').click(function(){ - // $(this).toggleClass("active"); - // var $tag_panel = $('#tag_panel'), - // tag_panel_position = 0; - - // if( $tag_panel.css('right') == '0px' ){ - // tag_panel_position = -200; - // } - // $tag_panel.animate({'right':tag_panel_position}, 300); - - // g.albumArea - // .delay(200) - // .animate({'margin-right':tag_panel_position+200},300); - // return false; - // }); - // g.albumArea.find("#tag_search_box").keyup(function(e){ - // sval = $(this).val(); - // if(sval == "<%= I18n.t('gallery.search_tags') %>") - // sval = ""; - // sval = sval.replace(/(^\s*)|(\s*$)/g,''); - // if(sval){ - // var re1 = new RegExp("^[\u4E00-\uFA29]*$"); //Chinese character range - // var re2 = new RegExp("^[\uE7C7-\uE7F3]*$"); - // if ((re1.test(sval) && (re2.test(sval)))){ - // $("#gallery_tag_list li span:not(:contains("+sval+"))").parent().slideUp(); - // }else{ - // $("#gallery_tag_list li span:not(:containsi("+sval+"))").parent().slideUp(); - // } - // }else{ - // $("#gallery_tag_list li").slideDown(); - // } - // }) - // g.albumArea.find("#tag_panel .bt-save").click(function(){ - // g.saveTags(id,g.loadArea); - // }) - // g.albumArea.find(".rghead .rgfn .bt-add").click(function(){ - // showUploadPanel(); - // }) - // g.albumArea.find(".rghead .rgfn .bt-del").click(function(){ - // g.deleteAlbum(id); - // }) - }) - var uploadpanel = $('
'); - var frame = $(''); - uploadpanel.find(".bt-cls").click(function(){ - uploadpanel.hide("slide"); - frame.remove(); - g.loadImages(id); - panelopen = false; - }) - var showUploadPanel = function(){ - if(!panelopen){ - uploadpanel.prepend(frame); - uploadpanel.show("slide"); - panelopen = true; - } - } - g.albumArea.addClass('o_album'); - // g.albumArea.find(".rghead .rgfn").append(uploadpanel); g.albumArea.find("#imgholder").empty(); - $("#filter").remove(); - g.albumArea.css("margin-top",""); - // var $addsign = $('
Add Album
'); - // $addsign.find("a").click(function(){showUploadPanel();}) - $.getJSON("panel/gallery/front_end/get_images",{aid:id,"inner":true},function(album){ + $.getJSON("panel/gallery/front_end/albums/"+id+"/imgs",function(album){ $.each(album.images,function(i,image){ var thumb = image.file.thumb.url; - var $img = $("
"); + image.description = (image.description?image.description:"<%= I18n.t('gallery.no_description') %>") + var $img = $("
"); g.albumArea.find("#imgholder").append($img); }) - // g.tagList.find("input").attr("checked",false); - $.each(album.tags,function(i,tag){ - - // g.tagList.find("li[data-content="+tag+"] input").attr("checked",true); - }) - // g.albumArea.find("#imgholder").append($addsign); }) - // g.albumArea.find("#imgholder").append($addsign); - // tag - } this.loadTheater = function(id){ var imageArray; @@ -288,9 +112,23 @@ var galleryAPI = function(){ }); var updatePhotoTag = function(){ var tags = imageArray[imagecount].tag_ids; - g.tagList.find("input").attr("checked",false); - for(tag in tags){ - g.tagList.find("li[data-content="+tags[tag]+"] input").attr("checked",true); + if(tags.length > 0 && g.tagList.find("li").length == 0){ + var tagnames = imageArray[imagecount].tag_names; + g.tagList.empty(); + for(i in tagnames){ + $li = $("
  • "+tagnames[i]+"
  • "); + g.tagList.append($li); + } + }else if(tags.length > 0 && g.tagList.find("li").length > 0) { + g.tagList.find("input").attr("checked",false); + for(tag in tags){ + g.tagList.find("li[data-content="+tags[tag]+"] input").attr("checked",true); + } + }else if(tags.length == 0){ + if(g.tagList.find("input").length == 0) + g.tagList.empty(); + else + g.tagList.find("input").attr("checked",false); } } g.albumArea.find("#tag_search_box").keyup(function(e){ @@ -312,7 +150,9 @@ var galleryAPI = function(){ } }) g.albumArea.find("#tag_panel .bt-save").click(function(){ - g.saveTags(imageArray[imagecount]._id,g.loadArea); + g.saveTags(imageArray[imagecount]._id,"pic",function(tagids){ + imageArray[imagecount].tag_ids = tagids; + }) }) $(".slidectrl a.togglelist").click(function(){ var rslide_h = $rslide.outerHeight(); @@ -367,8 +207,14 @@ var galleryAPI = function(){ var el = document.documentElement, rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen; rfs.call(el); - $rslide.addClass('browserFullScreen'); } + $(window).resize(function(){ + if(window.innerWidth == screen.width && window.innerHeight == screen.height) { + $rslide.addClass('browserFullScreen'); + } else { + $rslide.removeClass('browserFullScreen'); + } + }) var nextpic = function(dom){ if(imagecount == imageArray.length - 1) imagecount = 0; @@ -401,6 +247,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); @@ -409,9 +256,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(); @@ -433,15 +284,15 @@ var galleryAPI = function(){ next = imagecount + 1; prev = imagecount - 1; } - $(".navN").attr({"href":"orbit_gallery?theater="+imageArray[next]._id,"data-content":imageArray[next].file.url}); - $(".navP").attr({"href":"orbit_gallery?theater="+imageArray[prev]._id,"data-content":imageArray[prev].file.url}); + $(".navN").attr({"href":imageArray[next]._id,"data-content":imageArray[next].file.url}); + $(".navP").attr({"href":imageArray[prev]._id,"data-content":imageArray[prev].file.url}); }; if(imageArray.length > 1) updateNavigation(); } var preparestage = function(albumid){ - $.getJSON("panel/gallery/front_end/get_images",{aid:albumid,"inner":true},function(album){ + $.getJSON("../"+albumid+"/imgs",function(album){ imageArray = eval(album.images); $.each(album.images,function(i,image){ if(image._id == id) @@ -450,25 +301,26 @@ var galleryAPI = function(){ bindHandlers(); }) } - g.albumArea.find("#imgholder").load("panel/gallery/front_end/theater?pic="+id+"&inner=true",function(theater,response,xhr){ - if(xhr.status == 404){ - $(this).text("<%= I18n.t('gallery.pic_not_found') %>."); - return false; - } - $("#filter").remove(); - g.albumArea.css("margin-top",""); - var albumid = $(theater).find("#main_pic").attr("data-content"); - g.loadFooterPanel(g.loadArea,id,function(head){ - head = $(head); - g.albumArea.find(".rghead .rgfn").html(head); - g.albumArea.find(".bt-back").attr("href","gallery?album="+albumid); - - }) - g.albumArea.css("margin-bottom","0"); - picHeight = $(window).height() - ($("#orbit-bar").outerHeight() + $("#orbit_gallery .form-actions").outerHeight()); - preparestage(albumid); - - }); + 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); + g.albumArea.find(".bt-edit").attr("href","../albums/"+albumid+"/edit"); + g.albumArea.css("margin-bottom","0"); + picHeight = $(window).height() - ($("#orbit-bar").outerHeight() + $("#orbit_gallery .form-actions").outerHeight()); + preparestage(albumid); } this.editAlbum = function(id){ 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 28b20150..55145441 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 @@ -33,19 +33,8 @@ include AdminHelper 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"] album = GalleryAlbum.new(params[:gallery_album]) album.save! - # render :json=>{"success"=>true,"id"=>album.id}.to_json respond_to do |h| h.js end diff --git a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/album_images_controller.rb b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/album_images_controller.rb new file mode 100644 index 00000000..f9740225 --- /dev/null +++ b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/album_images_controller.rb @@ -0,0 +1,11 @@ +class Panel::Gallery::FrontEnd::AlbumImagesController < OrbitWidgetController + + def show + @tags = GalleryTag.all + @image = GalleryImage.find(params[:album_id]) + @albumid = @image.gallery_album_id + @album = GalleryAlbum.find(@albumid) + @images = @album.gallery_images.all + end + +end diff --git a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/albums_controller.rb b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/albums_controller.rb new file mode 100644 index 00000000..bd4ebbf0 --- /dev/null +++ b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/albums_controller.rb @@ -0,0 +1,114 @@ +class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController + + def index + + end + + def show + @album = GalleryAlbum.find(params[:id]) + @tags = Array.new + @album.tag_ids.each do |tag| + @tags << GalleryTag.find(tag)[I18n.locale] + end + end + + def new + if is_manager? || is_admin? + @categorylist = GalleryCategory.all + elsif is_sub_manager? + @categorylist = GalleryCategory.authed_for_user(current_user,"new_album") + end + @album = GalleryAlbum.new + render :layout => false + end + + def create + album = GalleryAlbum.new(params[:gallery_album]) + album.save! + respond_to do |h| + h.js + end + end + + def get_albums + @categoryids = params["cid"] + @tags = params["tid"] + @albums = Array.new + if @categoryids == "all" + if @tags + if @tags.kind_of?(Array) + @tags.each do |tag| + @albums << GalleryAlbum.where(tag_ids: tag) + end + else + @albums << GalleryAlbum.where(tag_ids: @tags) + end + else + @albums << GalleryAlbum.all + end + else + @categoryids.each do |id| + category = GalleryCategory.find(id) + if @tags + if @tags.kind_of?(Array) + @tags.each do |tag| + @albums << category.gallery_albums.where(tag_ids: tag) + end + else + @albums << category.gallery_albums.where(tag_ids: @tags) + end + else + @albums << category.gallery_albums.all + end + end + end + @output = Array.new + @albums.each do |album| + @albs = Array.new + album.each do |values| + tags = Array.new + values.tag_ids.each do |tag| + tags << GalleryTag.find(tag)[I18n.locale] + end + category = GalleryCategory.find(values.gallery_category_id).name + @albs << {"_id"=>values.id,"show_path"=>panel_gallery_front_end_album_path(values),"cover"=>values.cover,"cover_path"=>values.cover_path,"description"=>values.description,"category_name"=>category,"gallery_category_id" => values.gallery_category_id,"name"=>values.name,"tag_ids"=>values.tag_ids,"tag_names"=>tags} + end + @output << @albs + end + render :json=>@output.to_json + end + + + + def imgs + @album = GalleryAlbum.find(params[:album_id]) + @images = @album.gallery_images.all + @output = Array.new + @images.each do |values| + tags = Array.new + values.tag_ids.each do |tag| + tags << GalleryTag.find(tag)[I18n.locale] + end + @output << {"_id"=>values.id,"theater_link"=>panel_gallery_front_end_album_path(values)+"/theater","description"=>values.description,"title"=>values.title,"file"=>values.file,"gallery_album_id"=>values.gallery_album_id,"tag_ids"=>values.tag_ids,"tag_names"=>tags} + end + render :json=>{"images" => @output}.to_json + end + + def images_tags + album = GalleryAlbum.find(params[:album_id]) + tags = Array.new + images = album.gallery_images.all + images.each do |image| + tags << {"id"=>image.id, "tags" => image.tag_ids} + end + render :json=>tags.to_json + end + + +end + + + + + + diff --git a/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/albums/index.html.erb b/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/albums/index.html.erb index b77fe0be..afedbbc4 100644 --- a/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/albums/index.html.erb +++ b/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/albums/index.html.erb @@ -44,56 +44,6 @@ - -
    -
    -
    -
    -
    -
    -
    -
    - <% - @locales = Array.new - @site_valid_locales.each do |locale| - @locales << locale - end - %> -
    -
    - -
    -
    - <% if @authenticated %> - - <% end %> - -
    - - -
    <% if @authenticated %> @@ -113,6 +63,9 @@ if(typeof gallery.urlVars['cat']!= "undefined"){ gallery.loadArea = "albums"; gallery.loadAlbums(gallery.urlVars['cat']); + }else if(typeof gallery.urlVars['tag']!= "undefined"){ + gallery.loadArea = "albums"; + gallery.loadAlbums(gallery.urlVars['tag']); }else{ gallery.loadArea = "albums"; g.loadAlbums("all"); diff --git a/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/albums/new.html.erb b/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/albums/new.html.erb index 10855947..54deeda9 100644 --- a/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/albums/new.html.erb +++ b/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/albums/new.html.erb @@ -4,7 +4,7 @@
    <%= form_for @album, :url => {:action => "create"}, :remote => true do |f| %> <% end %> @@ -44,7 +44,7 @@ <% end %>
    diff --git a/vendor/built_in_modules/gallery/app/views/panel/gallery/front_end/album_images/show.html.erb b/vendor/built_in_modules/gallery/app/views/panel/gallery/front_end/album_images/show.html.erb new file mode 100644 index 00000000..37691b10 --- /dev/null +++ b/vendor/built_in_modules/gallery/app/views/panel/gallery/front_end/album_images/show.html.erb @@ -0,0 +1,65 @@ + +<%= stylesheet_link_tag "gallery_frontend" %> + + + +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "galleryAPI_frontend" %> + <%= javascript_include_tag "jquery.tinyscrollbar" %> + <%= javascript_include_tag "rss" %> +<% end %> + + + + + + + diff --git a/vendor/built_in_modules/gallery/app/views/panel/gallery/front_end/album_images/upload_panel.html.erb b/vendor/built_in_modules/gallery/app/views/panel/gallery/front_end/album_images/upload_panel.html.erb new file mode 100755 index 00000000..be4552b6 --- /dev/null +++ b/vendor/built_in_modules/gallery/app/views/panel/gallery/front_end/album_images/upload_panel.html.erb @@ -0,0 +1,111 @@ + + +<%= csrf_meta_tag %> +<%= javascript_include_tag "jquery-latest" %> +<%= stylesheet_link_tag "jquery-ui" %> +<%= stylesheet_link_tag "jquery.fileupload-ui.css" %> + + + +
    +
    +<%= form_for @album, :url => panel_gallery_back_end_album_path(@album), :html => {:class => 'clear'} do |f| %> + + +
    + + + + + +
    + + <% end %> +
    +
    +
    +
    +
    + + + +
    + + <%= javascript_include_tag "jquery-ui.min" %> + <%= javascript_include_tag "jquery.tmpl.min" %> + <%= javascript_include_tag "jquery.iframe-transport" %> + <%= javascript_include_tag "jquery.fileupload" %> + <%= javascript_include_tag "jquery.fileupload-ui" %> + <%= javascript_include_tag "upload" %> + + + + + diff --git a/vendor/built_in_modules/gallery/app/views/panel/gallery/front_end/albums/create.js.erb b/vendor/built_in_modules/gallery/app/views/panel/gallery/front_end/albums/create.js.erb new file mode 100644 index 00000000..36cfe297 --- /dev/null +++ b/vendor/built_in_modules/gallery/app/views/panel/gallery/front_end/albums/create.js.erb @@ -0,0 +1,3 @@ +var gal = new galleryAPI(); +gal.loadAlbums("all"); +rcom.modalWindowClose(); diff --git a/vendor/built_in_modules/gallery/app/views/panel/gallery/front_end/albums/edit.html.erb b/vendor/built_in_modules/gallery/app/views/panel/gallery/front_end/albums/edit.html.erb new file mode 100644 index 00000000..1052609e --- /dev/null +++ b/vendor/built_in_modules/gallery/app/views/panel/gallery/front_end/albums/edit.html.erb @@ -0,0 +1,137 @@ +<%= stylesheet_link_tag "gallery" %> +