diff --git a/app/assets/javascripts/desktop.js b/app/assets/javascripts/desktop.js index 7bfcb0b5..37c654c7 100644 --- a/app/assets/javascripts/desktop.js +++ b/app/assets/javascripts/desktop.js @@ -7,6 +7,7 @@ //= require jquery //= require jquery_ujs //= require jquery-ui +//= require jquery.form //= require jquery.tinyscrollbar //= require jquery.miniColors.min //= require bootstrap diff --git a/app/assets/javascripts/inc/attribute_onoff.js b/app/assets/javascripts/inc/attribute_onoff.js new file mode 100644 index 00000000..efcbabd5 --- /dev/null +++ b/app/assets/javascripts/inc/attribute_onoff.js @@ -0,0 +1,33 @@ +function checkSwitch() { + $(".groups").each(function() { + $(this).find('.form-horizontal > .hide').length < $(this).find('.form-horizontal > div').length ? $(this).removeClass("disabled") : $(this).addClass("disabled") + }); + // $(".groups").addClass('disabled').has('.groups > .form-horizontal > div:not(.hide)').removeClass('disabled'); +} + +$(document).ready(function(){ + checkSwitch(); + $('.onoff').click(function () { + if($(this).parents("h4").length==1) { + $(this).parents(".map-block").toggleClass("disabled"); + $(this).parents(".map-block").find(".form-horizontal").toggleClass("hide"); + if($(this).parents(".map-block").hasClass("disabled")){ + $(this).text("OFF"); + }else{ + $(this).text("ON"); + } + } + if($(this).parents("legend").length==1) { + $(this).toggleClass("disabled"); + $(this).parents("legend").next("div").toggleClass("hide"); + if($(this).parents("legend").next("div").hasClass("hide")){ + $(this).text("OFF"); + }else{ + $(this).text("ON"); + } + checkSwitch(); + } + return false; + }); +}); + diff --git a/app/assets/javascripts/inc/attribute_panel_select.js b/app/assets/javascripts/inc/attribute_panel_select.js new file mode 100644 index 00000000..874c32d5 --- /dev/null +++ b/app/assets/javascripts/inc/attribute_panel_select.js @@ -0,0 +1,15 @@ +$(document).ready(function(){ + $(".status select").each(function (i) { + $(this).change(function () { + $(".status option:selected").eq(i).each(function () { + if($(this).attr("value")=="alumna") { + $(this).parents(".status").nextAll(".graduated").removeClass("hide"); + $(this).parents(".status").nextAll(".graduated").find("select").removeAttr("disabled"); + }else{ + $(this).parents(".status").nextAll(".graduated").addClass("hide"); + $(this).parents(".status").nextAll(".graduated").find("select").attr({disabled:''}); + } + }); + }) + }) +}); \ No newline at end of file diff --git a/app/assets/javascripts/inc/input_module.js.erb b/app/assets/javascripts/inc/input_module.js.erb new file mode 100644 index 00000000..5ac7b056 --- /dev/null +++ b/app/assets/javascripts/inc/input_module.js.erb @@ -0,0 +1,112 @@ +jQuery(document).ready(function($) { + // Stuff to do as soon as the DOM is ready. Use $() w/o colliding with other libs; + var current_textarea = {}; + var parent = null; + var this_modal_window = null; + var lang = <%= VALID_LOCALES.to_s %>; + +$("textarea[func=input_unit]").each(function(){ + var id = $(this).attr("id"); + current_textarea[id] = $(this).val(); +}) +console.log(current_textarea); + + // current_textarea['en'] = $("textarea[for=en]").val(); + // current_textarea['zh_tw'] = $("textarea[for=zh_tw]").val(); + + + + $("div.controls").on("click","a.edit-btn",function(){ + parent = $(this).parent(); + this_modal_window = $(this).parent().parent().parent().parent().find(".modal"); + + choosen_lang = $(this).parent().parent().find("ul li.active").attr("for"); + $(this).parents(".editMore").find(".modal_tab").removeClass("active in"); + $(this).parents(".editMore").find(".modal_tab[for="+choosen_lang+"]").addClass("active in"); + + $(this).parents(".editMore").find(".modal-body li").removeClass("active"); + $(this).parents(".editMore").find(".modal-body li[for="+choosen_lang+"]").addClass("active"); + // switch($(this).parent().parent().find("ul li.active a").attr("href")){ + // case ".tab1": + + // $("#tab3").addClass("active in"); + // $(".modal-body li").eq(0).addClass("active"); + // break; + // case ".tab2": + // $("#tab4").addClass("active in"); + // $(".modal-body li").eq(1).addClass("active"); + // break; + + + $.each(lang,function(i,value){ + // console.log(this_modal_window); + var sa = parent.find("input.street_address_"+lang[i]).val(); + var city = parent.find("input.city_"+lang[i]).val(); + var county = parent.find("input.county_"+lang[i]).val(); + var zip = parent.find("input.zip_"+lang[i]).val(); + var country = parent.find("input.country_"+lang[i]).val(); + this_modal_window.find('.tab-content div[for='+lang[i]+'] textarea[func=street_address]').val(sa); + this_modal_window.find('.tab-content div[for='+lang[i]+'] input[func=city]').val(city); + this_modal_window.find('.tab-content div[for='+lang[i]+'] input[func=county]').val(county); + this_modal_window.find('.tab-content div[for='+lang[i]+'] input[func=zip]').val(zip); + this_modal_window.find('.tab-content div[for='+lang[i]+'] input[func=country]').val(country); + var verify = sa + city + country +county + zip; + + var combined = ""; + if(verify!="") + combined = sa + "\n" + city + "\n" + county + "\n" + zip + "\n" + country+"\n"; + + var Text0 = parent.find("div."+lang[i]+" textarea[func=input_unit]").val(); + Text1 = Text0.replace(/(\r\n|\n|\r)/gm,""); + var Text2 = combined; + Text2 = Text2.replace(/(\r\n|\n|\r)/gm,""); + + if(Text1 != Text2){ + this_modal_window.find('.tab-content div[for='+lang[i]+'] textarea[func=street_address]').val(Text0); + this_modal_window.find("input").val(""); + } + }); + }); + $("textarea[func=input_unit]").change(function(){ + var id = $(this).attr("id"); + var lang = $(this).attr("for"); + if(!parent) + parent = $(this).parent().parent(); + console.log(current_textarea[id]); + if(current_textarea[id] != $(this).val()) + parent.find("input.indicator_"+lang).val("true"); + else + parent.find("input.indicator_"+lang).val("false"); + }) + + $(".address-edit").on("hidden",function(){ + $("#tab3").removeClass("active in"); + $("#tab4").removeClass("active in"); + $(".modal-body li").removeClass("active"); + $(".modal-body input, .modal-body textarea").val(""); + + }) + $(".bt-save").click(function(){ + for(i=0;i<2;i++){ + var sa = this_modal_window.find('.tab-content div[for='+lang[i]+'] textarea[func=street_address]').val(); + var city = this_modal_window.find('.tab-content div[for='+lang[i]+'] input[func=city]').val(); + var county = this_modal_window.find('.tab-content div[for='+lang[i]+'] input[func=county]').val(); + var zip = this_modal_window.find('.tab-content div[for='+lang[i]+'] input[func=zip]').val(); + var country = this_modal_window.find('.tab-content div[for='+lang[i]+'] input[func=country]').val(); + parent.find("input.street_address_"+lang[i]).val(sa); + parent.find("input.city_"+lang[i]).val(city); + parent.find("input.county_"+lang[i]).val(county); + parent.find("input.zip_"+lang[i]).val(zip); + parent.find("input.country_"+lang[i]).val(country); + var verify = sa + city + country +county + zip; + var combined = ""; + if(verify!="") + combined = sa + "\n" + city + "\n" + county + "\n" + zip + "\n" + country; + parent.find("textarea[for="+lang[i]+"]").val(combined); + parent.find("input.indicator_"+lang[i]).val("false"); + current_textarea[parent.find("textarea[for="+lang[i]+"]").attr("id")] = combined; + } + + }) + +}); diff --git a/app/assets/javascripts/inc/ploy_input_field.js b/app/assets/javascripts/inc/ploy_input_field.js new file mode 100644 index 00000000..3799c64c --- /dev/null +++ b/app/assets/javascripts/inc/ploy_input_field.js @@ -0,0 +1,37 @@ +// var $CloneTarget ; + + function checkMultipleInput() { + $(".multipleInput").each(function() { + $(this).children('.controls').length==1 ? $(this).addClass("plural") : $(this).removeClass("plural") + }); + } + function removeInput(){ + $(".removeInput").click(function (){ + $(this).parents(".controls").remove(); + checkMultipleInput(); + return false; + }); + } + $(document).ready(function(){ + var $modalNumber = 0; + checkMultipleInput(); + removeInput(); + $(".addinput").click(function (){ + $modalNumber+=1; + var $CloneTarget = $(this).parents(".controls").prev(".multipleInput").children('.controls:last'); + $(this).parents(".controls").prev(".multipleInput").append($CloneTarget.clone()); + class_to_be_removed = $(this).parents(".controls").prev(".multipleInput").attr("ext_class") + // $(this).parents(".controls").prev(".multipleInput").children('.controls:last input').val(""); + $(this).parents(".controls").prev(".multipleInput").children('.controls:last').find('input').val('') + + $(this).parents(".controls").prev(".multipleInput").children('.controls:last').find('.tab-pane').removeClass(class_to_be_removed).addClass("NewInput_"+$modalNumber) + btn = $(this).parents(".controls").prev(".multipleInput").children('.controls:last').find(".nav.nav-pills li") + $.each(btn,function(i,value){ + old_link = $(this).children("a").attr("href"); + $(this).children("a").attr("href",".NewInput_"+$modalNumber); + }); + removeInput(); + checkMultipleInput(); + return false; + }) + }); \ No newline at end of file diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index 57007b26..3ddb9775 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -2,6 +2,9 @@ //harry //Inititialize function will initialize desktop +//callback-method will be called after desktop controlled ajax call; +//container=true is the area where the view will be loaded + $.extend($.expr[':'], { 'containsi': function (elem, i, match, array) { @@ -82,7 +85,7 @@ var orbitDesktop = function(dom){ $(".docklist a").click(function(){ var target = $(this).attr("id"); var url = $(this).attr("href"); - o.data_method = $(this).attr("data-method"); + o.data_method = $(this).attr("callback-method"); if(o.currenthtml!=target){ if(o.desktopData[o.currentface] == "undefined") o.desktopData[o.currentface] = ""; @@ -95,47 +98,28 @@ var orbitDesktop = function(dom){ $(o.contentHolder).empty().load(url,function(){ if(typeof o.data_method != "undefined"){ if(o.data_method != "") - window.o[o.data_method](target,url,cache); + window.o[o.data_method](target,url,cache); } + o.sub_menu_item($(o.contentHolder).find("*[content-type=menu] a[load=true]")); }); }else{ $(o.contentHolder).html(o.desktopData[o.currentface]); + o.sub_menu_item($(o.contentHolder).find("*[content-type=menu] a[load=true]").trigger("click")); cache = true; if(typeof o.data_method != "undefined"){ if(o.data_method != "") - window.o[o.data_method](target,url,cache); + window.o[o.data_method](target,url,cache); } } }); } return false; }) + + $('body').on({ click: function(){ - if(!$(this).hasClass('active')){ - var sub_data_method = $(this).attr('data-method'); - if(sub_data_method){ - $("#panel_r").load($(this).attr("href"),function(){ - // o.simple_drop_down(); - - // o.tinyscrollbar_ext({ - // main: '.tinycanvas', - // fill: '.s_grid_con' - // }) - if(typeof o.data_method != "undefined"){ - if(o.data_method != ""){ - if(typeof sub_data_method != "undefined"){ - if(sub_data_method != ""){ - window.o[o.data_method][sub_data_method](); - } - } - } - } - }) - } - $('.s_menu a').removeClass('thmc1 thmtxt active'); - $(this).addClass('thmc1 thmtxt active'); - } + o.sub_menu_item($(this)); return false; }, mouseenter: function(){ @@ -147,7 +131,23 @@ var orbitDesktop = function(dom){ var t = $(this).hasClass('active') ? '' : 'thmc1 thmtxt'; $(this).switchClass(t,'admtxt',0); } - },'.s_menu a'); + },'*[content-type=menu] a'); + + $("body").on("submit","form[type=ajax_form]",function(){ + var callback_method = $(this).attr("callback-method"); + var options = { + success:function(responseText, statusText, xhr, $form){ + if(typeof callback_method != "undefined"){ + if(callback_method != ""){ + window.o[o.data_method][callback_method](responseText,statusText,xhr,$form); + } + } + } + } + $(this).ajaxSubmit(options); + return false; + }) + $(window).resize(function(){ var ww = $(window).width(); $("img#thmbackground").attr({"width":ww}); @@ -171,6 +171,26 @@ var orbitDesktop = function(dom){ $fn_des.stop(true, true).fadeOut(); }); }; + this.sub_menu_item = function(dom){ + if(!dom.hasClass('active')){ + var sub_data_method = dom.attr('callback-method'); + if(sub_data_method){ + $("div[container=true]").load(dom.attr("href"),function(){ + if(typeof o.data_method != "undefined"){ + if(o.data_method != ""){ + if(typeof sub_data_method != "undefined"){ + if(sub_data_method != ""){ + window.o[o.data_method][sub_data_method](); + } + } + } + } + }) + } + $('*[content-type=menu] a').removeClass('thmc1 thmtxt active'); + dom.addClass('thmc1 thmtxt active'); + } + } this.initializeDesktop = function(target,url,cache){ //this is for initializing main desktops that are sections and tiles if(!target)target = "desktop"; @@ -806,6 +826,14 @@ var orbitDesktop = function(dom){ }; this.initializeJournalPapers = function(target,url,cache){ // this init journal papers + this.initializeJournalPapers.formCallback = function(data){ + if(data.success){ + o.notify(data.msg,"success"); + o.sub_menu_item($("div[content-type=menu] a").eq(0)); + }else{ + o.notify(data.msg,"alert"); + } + } this.initializeJournalPapers.list = function(){ // to open list part in journal papers page var journalData; @@ -817,7 +845,6 @@ var orbitDesktop = function(dom){ fill: '.list_t' }) - $("#journal_selection_options a").click(function(){ switch($(this).attr("href")){ case "all": @@ -849,10 +876,26 @@ var orbitDesktop = function(dom){ } return false; }) + + $("div[container=true]").on("click",".journal_paper_edit",function(){ + $.ajax({ + url : $(this).attr("href"), + type : "get", + success : function(data){ + var prev_data = $("div[container=true]").html(); + $("div[container=true]").html(data); + $(".bt-cancel").click(function(){ + $("div[container=true]").html(prev_data); + }) + } + }) + return false; + }) + } var bindSecondaryHandlers = function(){ - $("#journal_p div#paper_list a").click(function(){ + $("#journal_p div#paper_list a.icon-check-empty").click(function(){ if($(this).hasClass("icon-check-empty")){ $(this).switchClass("icon-check-empty","icon-check",0); } else if($(this) .hasClass("icon-check")) { @@ -873,7 +916,7 @@ var orbitDesktop = function(dom){ li; $.each(journalData,function(i,journal){ $.each(journal.papers,function(j,paper){ - li = $('
  • '+journal.title+'
    '+paper.title+'
  • '); + li = $('
  • '+journal.title+'
    '+paper.title+'
    Edit
  • '); column.find("ul").append(li); if(counter%5==0){ $("#journal_p div#paper_list div.overview").append(column); @@ -902,6 +945,7 @@ var orbitDesktop = function(dom){ var img = $('
    '+thistitle+'
    '); li.append(img); }) + li.append('Edit'); column.find("ul").append(li); if(counter%5==0){ $("#journal_p div#paper_list div.overview").append(column); @@ -920,7 +964,7 @@ var orbitDesktop = function(dom){ li; $.each(journalData,function(i,journal){ $.each(journal.papers,function(j,paper){ - li = $('
  • '+paper.title+'
    '+paper.keywords+'
  • '); + li = $('
  • '+paper.title+'
    '+paper.keywords+'
    Edit
  • '); column.find("ul").append(li); if(counter%5==0){ $("#journal_p div#paper_list div.overview").append(column); @@ -940,7 +984,7 @@ var orbitDesktop = function(dom){ li; $.each(journalData,function(i,journal){ $.each(journal.papers,function(j,paper){ - li = $('
  • '+paper.title+'
  • '); + li = $('
  • '+paper.title+'
    Edit
  • '); column.find("ul").append(li); if(counter%5==0){ $("#journal_p div#paper_list div.overview").append(column); @@ -959,7 +1003,7 @@ var orbitDesktop = function(dom){ li; $.each(journalData,function(i,journal){ $.each(journal.papers,function(j,paper){ - li = $('
  • '+paper.title+'
    '+paper.abstract+'
  • '); + li = $('
  • '+paper.title+'
    '+paper.abstract+'
    Edit
  • '); column.find("ul").append(li); $("#journal_p div#paper_list div.overview").append(column); column = $('
    '); @@ -969,11 +1013,14 @@ var orbitDesktop = function(dom){ bindSecondaryHandlers(); } - $.getJSON("/desktop/journal_pages/get_journals_json",function(journals){ - journalData = eval(journals); - journalview(); - bindHandlers(); - }) + var getData = function(){ + $.getJSON("/desktop/journal_pages/get_journals_json",function(journals){ + journalData = eval(journals); + journalview(); + bindHandlers(); + }) + } + getData(); } this.initializeJournalPapers.addpaper = function(){ // to open add pages in journal papers page diff --git a/app/assets/stylesheets/member.css b/app/assets/stylesheets/member.css index add8774a..031b271c 100644 --- a/app/assets/stylesheets/member.css +++ b/app/assets/stylesheets/member.css @@ -280,7 +280,7 @@ margin-top: 8px; } .nav-tabs li a { - padding-right: 32px; + /*padding-right: 32px;*/ } .user-role { @@ -314,7 +314,8 @@ float: left; } .role-block .nav-pills { - margin-bottom: 0;g + margin-bottom: 0; + margin-left: 10px; } .role-block .nav-pills > li > a { margin-top: 0; @@ -345,7 +346,13 @@ -moz-border-radius: 0 3px 3px 0; border-radius: 0 3px 3px 0; } +.input-append > .active { + display: inline-block; +} +.input-append .active { + background-color: transparent; + border-color: transparent; +} .language-swich .tab-pane { - margin-bottom: 5px; - margin-right: 10px; + /*margin-bottom: 5px;*/ } \ No newline at end of file diff --git a/app/assets/stylesheets/site-map.css b/app/assets/stylesheets/site-map.css index 53e94c1f..c7a95b45 100644 --- a/app/assets/stylesheets/site-map.css +++ b/app/assets/stylesheets/site-map.css @@ -111,7 +111,7 @@ .role-block .form-horizontal .controls { margin-left: 120px; } -.role-block .form-horizontal .controls>.input-append { +.role-block .form-horizontal .controls .input-append { margin-bottom: 10px; } .role-block .form-horizontal legend .onoff { diff --git a/app/controllers/admin/ad_banners_controller.rb b/app/controllers/admin/ad_banners_controller.rb index 7f49faf2..cae3f19c 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 :force_order_for_visitor,:only=>[:index] - #before_filter :force_order_for_user,:except => [:index] + before_filter :force_order_for_user,:except => [:index] before_filter :for_app_sub_manager,:except => [:index] before_filter :for_app_manager,:except => [:index,:show,:update,:realtime_preview] diff --git a/app/controllers/admin/ad_images_controller.rb b/app/controllers/admin/ad_images_controller.rb index e4749ade..fc25c5d5 100644 --- a/app/controllers/admin/ad_images_controller.rb +++ b/app/controllers/admin/ad_images_controller.rb @@ -1,7 +1,13 @@ -class Admin::AdImagesController < OrbitBackendController - layout 'new_admin' - before_filter :authenticate_user! - before_filter :for_app_sub_manager +class Admin::AdImagesController < Admin::AdBannersController + + # before_filter :force_order_for_user + # before_filter :for_app_sub_manager + # before_filter :for_app_manager + + def initialize + super + @app_title = "ad_banner" + end def edit @ad_banner = AdBanner.find params[:ad_banner_id] diff --git a/app/controllers/admin/designs_controller.rb b/app/controllers/admin/designs_controller.rb index 0b94317e..a3824950 100644 --- a/app/controllers/admin/designs_controller.rb +++ b/app/controllers/admin/designs_controller.rb @@ -52,7 +52,7 @@ class Admin::DesignsController < OrbitBackendController case params[:type] when 'layout', 'css_default', 'css_reset' @object = @design.send(params[:type]) - when 'image', 'javascript', 'theme' + when 'javascripts', 'themes'#, 'images' @object = @design.send(params[:type]).find(params[:object_id]) end diff --git a/app/controllers/admin/links_controller.rb b/app/controllers/admin/links_controller.rb index 7c7b4030..5eece0ca 100644 --- a/app/controllers/admin/links_controller.rb +++ b/app/controllers/admin/links_controller.rb @@ -1,10 +1,4 @@ -class Admin::LinksController < ApplicationController - - layout "site_editor" - - before_filter :authenticate_user! - before_filter :find_parent_item - before_filter :is_admin? +class Admin::LinksController < Admin::ItemsController def show @item ||= Link.find(params[:id]) diff --git a/app/controllers/admin/page_parts_controller.rb b/app/controllers/admin/page_parts_controller.rb index ed2748c2..f78c6ae3 100644 --- a/app/controllers/admin/page_parts_controller.rb +++ b/app/controllers/admin/page_parts_controller.rb @@ -5,6 +5,8 @@ class Admin::PagePartsController < ApplicationController before_filter :authenticate_user! before_filter :is_admin? before_filter :set_current_item + + helper 'admin/items' def show @part = PagePart.find(params[:id]) diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index cf935a09..0e58a00f 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -1,11 +1,4 @@ -class Admin::PagesController < ApplicationController - - layout "site_editor" - - before_filter :authenticate_user! - before_filter :find_parent_item - before_filter :is_admin? - before_filter :set_current_item +class Admin::PagesController < Admin::ItemsController def show @item = Page.find(params[:id]) @@ -40,7 +33,7 @@ class Admin::PagesController < ApplicationController @frontend_path = @item.app_frontend_url ? @item.app_frontend_url : @module_app.widgets.keys[0] - if @module_app.widgets.any?{|b| b.class == Array} + if @module_app && @module_app.widgets && @module_app.widgets.any?{|b| b.class == Array} @frontend_style = @module_app.widgets[@frontend_path] if !@frontend_path.blank? && !@module_app.widgets.blank? end diff --git a/app/controllers/admin/users_new_interface_controller.rb b/app/controllers/admin/users_new_interface_controller.rb index a277c2e1..8c5ec93a 100644 --- a/app/controllers/admin/users_new_interface_controller.rb +++ b/app/controllers/admin/users_new_interface_controller.rb @@ -78,7 +78,7 @@ class Admin::UsersNewInterfaceController < ApplicationController # @user.attribute_values.build(value) # } # @user.rebuild_sub_roles_from_attribute_values!(attribute_values) - binding.pry + # binding.pry if @user.save flash[:notice] = t('create.success.user') redirect_to :action => :index @@ -103,6 +103,7 @@ class Admin::UsersNewInterfaceController < ApplicationController def update @user = User.find(params[:id]) + @user.update_attributes(params[:user]) attribute_values_key = params[:user].has_key?('new_attribute_values') ? 'new_attribute_values' : 'attribute_values' attribute_values = params[:user].delete(attribute_values_key) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e82365e5..23474c5c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -8,6 +8,8 @@ class ApplicationController < ActionController::Base helper :admin before_filter :set_locale, :set_site + helper_attr :site_valid_locales + def set_current_user User.current = current_or_guest_user end diff --git a/app/controllers/desktop/journal_pages_controller.rb b/app/controllers/desktop/journal_pages_controller.rb index c9d71e64..ee7a7167 100644 --- a/app/controllers/desktop/journal_pages_controller.rb +++ b/app/controllers/desktop/journal_pages_controller.rb @@ -21,6 +21,7 @@ class Desktop::JournalPagesController < ApplicationController respond_to do |format| format.html { render :layout => false} end + end def edit @@ -39,14 +40,19 @@ class Desktop::JournalPagesController < ApplicationController @writing_journal = WritingJournal.new(params[:writing_journal]) if @writing_journal.save - respond_to do |format| - format.html { redirect_to desktop_journal_pages_url, :layout => false, notice: 'User was successfully created.'} - # format.json { render json: @writing_journal, status: :created, location: @writing_journal} - # format.js - end + # respond_to do |format| + # format.html { redirect_to desktop_journal_pages_url, :layout => false, notice: 'User was successfully created.'} + # # format.json { render json: @writing_journal, status: :created, location: @writing_journal} + # # format.js + # end + render :json => {"success"=>true,"msg"=>"Paper successfully saved!"}.to_json else + render :json => {"success"=>false,"msg"=>"Saving failed!"} end - end + + end + render :json => {"success"=>true,"msg"=>"Paper successfully saved!"}.to_json + end def update @@ -74,19 +80,19 @@ class Desktop::JournalPagesController < ApplicationController if not file.nil? file_type = MIME::Types.type_for(file).first.to_s.split("/")[1] - case file_type - when "jpg", "jpeg" - type = "jpg" - when "text", "txt" - type = "txt" - when "pdf" - type = "pdf" - when "png" - type = "png" - else "readme" - end + # case file_type + # when "jpg", "jpeg" + # type = "jpg" + # when "text", "txt" + # type = "txt" + # when "pdf" + # type = "pdf" + # when "png" + # type = "png" + # else "readme" + # end - file_type = "/assets/ft-icons/#{type}/#{type}-48_32.png" + file_type = "/assets/ft-icons/#{file_type}/#{file_type}-48_32.png" else file_type = "" end diff --git a/app/controllers/orbit_backend_controller.rb b/app/controllers/orbit_backend_controller.rb index 8f78ea62..530415ba 100644 --- a/app/controllers/orbit_backend_controller.rb +++ b/app/controllers/orbit_backend_controller.rb @@ -11,7 +11,7 @@ class OrbitBackendController < ApplicationController layout 'new_admin' def setup_vars - @app_title = controller_path.split('/')[1].singularize + @app_title ||= controller_path.split('/')[1].singularize @module_app ||= ModuleApp.first(conditions: {:key => @app_title} ) end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 76f0f933..07d6b577 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -15,8 +15,11 @@ module ApplicationHelper end def create_guest_user - u = User.create(:name => "guest", :email => "guest_#{Time.now.to_i}#{rand(99)}@example.com") - u.admin = false + u = nil + User.without_callback(:create, :before, :initialize_desktop) do + u = User.create(:name => "guest", :email => "guest_#{Time.now.to_i}#{rand(99)}@example.com") + end + u.admin = false u.save(:validate => false) u end diff --git a/app/helpers/attribute_fields_helper.rb b/app/helpers/attribute_fields_helper.rb index c35c7370..ded899ad 100644 --- a/app/helpers/attribute_fields_helper.rb +++ b/app/helpers/attribute_fields_helper.rb @@ -1,12 +1,12 @@ #encoding: utf-8 -# require ActionView::Helpers::FormTagHelper - module AttributeFieldsHelper include ActionView::Helpers::FormTagHelper include ActionView::Helpers::FormOptionsHelper include ActionView::Helpers::DateHelper include ActionView::Helpers::TagHelper include ActionView::Helpers::RenderingHelper + include ActionView::Context + include OrbitBasis::RenderAnywhere def block_helper(user,index,disable = false) unless self.disabled @@ -28,37 +28,25 @@ module AttributeFieldsHelper end def render_address - #NP control_group_wrapper do |key,value| - result = '
    '.html_safe + value = (can_muti_lang_input? ? @prefiled_value[key] : @prefiled_value) rescue nil + key_field = can_muti_lang_input? ? "[#{key}]" : "" + place_holder= @panel_setting["placeholder"][key] rescue '' + result = text_area_tag(get_field_name_base + key_field, value,@markup_options.merge({:placeholder=>place_holder,:for=>key})) - if(add_more and value.is_a?(Array)) - values = value - result << values.each_with_index.collect do |value,index| - text_field_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options) - end.join.html_safe - else - result << text_field_tag(get_field_name_base + (key.nil? ? '' : "[#{key}]"), value,@markup_options) - end - - result << ('').html_safe - result << ''.html_safe - result << '
    '.html_safe - result << gen_modal_dialog + add_ext= @attribute_value.address_ext[key] rescue {} + + result << hidden_field_tag(get_basic_field_name_base+"[address_ext][#{key}][county]",add_ext["county"],:class=>"county_#{key}") + result << hidden_field_tag(get_basic_field_name_base+"[address_ext][#{key}][street_address]",add_ext["street_address"],:class=>"street_address_#{key}") + result << hidden_field_tag(get_basic_field_name_base+"[address_ext][#{key}][city]",add_ext["city"],:class=>"city_#{key}") + result << hidden_field_tag(get_basic_field_name_base+"[address_ext][#{key}][zip]",add_ext["zip"],:class=>"zip_#{key}") + result << hidden_field_tag(get_basic_field_name_base+"[address_ext][#{key}][country]",add_ext["country"],:class=>"country_#{key}") + result << hidden_field_tag(get_basic_field_name_base+"[address_ext][#{key}][indicator]",add_ext["indicator"],:class=>"indicator_#{key}") end end def render_checkbox - @prefiled_value ||=[] - # begin - # markup_value = eval(self.markup_value) - # rescue - # markup_value = self.markup_value - # ensure - # markup_value ||= {} - # end - control_group_wrapper do a = self[:option_list].collect do |key,value| label_tag(key,check_box_tag(get_field_name_base+"[#{key}]", true , (@prefiled_value.include?(key) ? true : false), {})+value[I18n.locale.to_s],@markup_options.merge(:class=>"control-label")) @@ -67,23 +55,15 @@ module AttributeFieldsHelper end def render_date - #NP control_group_wrapper{date_select(get_field_name_base,nil,@markup_options.merge(:default=>@prefiled_value),:class=>"input-small")} end def render_date_durnation #Need re-write low priority - + end def render_radio_button @prefiled_value ||=[] - # begin - # markup_value = eval(self.markup_value) - # rescue - # markup_value = self.markup_value - # ensure - # markup_value ||= {} - # end control_group_wrapper do self[:option_list].collect do |key,value| label_tag(key,radio_button_tag(get_field_name_base, key , (@prefiled_value.include?(key) ? true : false), {})+value[I18n.locale.to_s],@markup_options.merge(:class=>"control-label")) @@ -92,106 +72,148 @@ module AttributeFieldsHelper end def render_select - - prompt = @panel_setting[:prompt][I18n.locale] rescue nil + prompt = @panel_setting["initial"][I18n.locale.to_s] rescue nil @markup_options.merge!(:prompt => prompt) unless prompt.nil? - # markup_value = (self.markup_value.is_a?(Hash) ? self.markup_value : eval(self.markup_value) )rescue {} - # check self[:option_list].collect{|p| [p[1][I18n.locale.to_s],p[0]]} control_group_wrapper{select_tag( get_field_name_base,options_for_select(self.option_list.collect{|p| [p[1][I18n.locale.to_s],p[0]]},@prefiled_value),@markup_options)} rescue "" end def render_text_area control_group_wrapper do |key,value| - if(add_more and value.is_a?(Hash)) - values = value - values.each_with_index.collect do |value,index| - place_holder= @panel_setting["placeholder"][key] - text_area_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options.merge(:placeholder=>place_holder)) - end.join.html_safe - else - value = can_muti_lang_input ? @prefiled_value[key] : @prefiled_value - key = can_muti_lang_input ? "[#{key}]" : "" + value = can_muti_lang_input? ? @prefiled_value[key] : @prefiled_value + key = can_muti_lang_input? ? "[#{key}]" : "" place_holder= @panel_setting["placeholder"][I18n.locale.to_s] rescue '' text_area_tag(get_field_name_base + key, value,@markup_options.merge(:placeholder=>place_holder)) - end end end def render_text_field - control_group_wrapper do |key,value| - if(add_more) - values = value - result = "" - unless values.nil? - result = values.each_with_index.collect do |value,index| - place_holder= @panel_setting["placeholder"][key] - text_field_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options.merge(:placeholder=>place_holder)) - end.join.html_safe - end - result - else - value = (can_muti_lang_input ? @prefiled_value[key] : @prefiled_value) rescue nil - key_field = can_muti_lang_input ? "[#{key}]" : "" - place_holder= @panel_setting["placeholder"][key] rescue '' - text_field_tag(get_field_name_base + key_field, value,@markup_options.merge(:placeholder=>place_holder)) - end - end + control_group_wrapper do |key,value| + add_more_blank = can_add_more ? "[]" : "" + key_field = can_muti_lang_input? ? "[#{key}]" : "" + place_holder= @panel_setting["placeholder"][key] rescue '' + text_field_tag([get_field_name_base,add_more_blank,key_field].join, value,@markup_options.merge(:placeholder=>place_holder)) + end end protected - def lang_panel_control_wrapper(&block) - result = '
    ' - result << '
    ' - result << controls_wrapper{yield} - result << '
    ' - result << '
    ' - result.html_safe + + def lang_panel_tabbable_wrapper(add_more_params,&block) + add_more_counter = '' + content_tag :div,:class=>"tabbable" do + tmp = content_tag :div,:class=> (add_more || self.markup=='address') ? "tab-content input-append" : "tab-content" do + buff = VALID_LOCALES.collect do |key| + value = @prefiled_value[key] rescue nil + div_class_ary = ["tab-pane" ,"fade",key,get_pairing_tab_class({})] + + + if can_add_more + add_more_value = add_more_params[0][:value] + add_more_counter = add_more_params[0][:counter] + value = add_more_value[key] rescue nil + div_class_ary << "add_more_item_#{add_more_counter}" + end + + div_class = div_class_ary.join(" ") + div_class << (key == I18n.locale.to_s ? " active in" : '') + content_tag(:div,yield(key,value),:class=>div_class) + end# of VALID_LOCALES.collect for tabed input + buff << link_to((content_tag :i,'',:class=>'icon-edit'),"##{get_pairing_tab_class({})}_m_window",:class=>'btn edit-btn',:type=>'button',:data=>{:toggle=>"modal"}) if self.markup == 'address' + buff << link_to((content_tag :i,'',:class=>'icon-trash'),"#") if self.add_more + + + # buff << '' if self.add_more + buff.join("\n").html_safe + end + tmp << content_tag(:ul,:class=> 'nav nav-pills') do + VALID_LOCALES.each.collect do |key| + # link_entry = self.add_more ? "#{add_more_tab(:tab_btn,loop_counter,key)}" : "#tab"+id.to_s+"_#{key}" + link_entry_ary = [".#{get_pairing_tab_class({})}",".#{key}"] + # link_entry_ary << ".add_more_item_#{add_more_counter}" if can_add_more + link_entry = link_entry_ary.join + content_tag(:li,link_to(I18n.t("langs."+key),link_entry,:data=>{:toggle=>"tab"}),:class=>(key == I18n.locale.to_s ? "active" : nil),:for=>key) + end.join.html_safe # of VALID_LOCALES.collect for tabs + end # of content ul + end end - def controls_wrapper(&block) - result = "
    " - if can_muti_lang_input - result << "
    " - result << "
    " - - VALID_LOCALES.collect do |key| - value = @prefiled_value[key.to_s] rescue nil - div_class = ["tab-pane" ,"fade"].join(" ") - div_class << (key == I18n.locale.to_s ? " active in" : '') - result << content_tag(:div,yield(key,value),:class=>div_class,:id=>"tab"+id.to_s+"_#{key}") - end - result << "
    " - result << "" - result << "
    " - # @prefiled_value.collect do |key,value| - # result << yield(key,value) - # end + + + + if can_muti_lang_input? + result << lang_panel_tabbable_wrapper(add_more_params,&block) + result << gen_modal_dialog if self.markup == "address" else - result << yield + + value = case can_add_more + when true + add_more_params[0] + else + @prefiled_value + end + + result << yield(nil,value) end - if can_add_more - result << '' - result << ' Add' - result << '' - end - result << "
    " - result.html_safe - end + + result.html_safe + end # of controls div + end # of def controls_wrapper(&block) def control_group_wrapper(&block) - div_class = can_muti_lang_input ? "control-group language-swich" : "control-group" - temp = label + controls_wrapper(&block) + div_class = can_muti_lang_input? ? "control-group language-swich" : "control-group" + result ="" + case self.markup + when "text_field" + if can_add_more + multipleInput_ary = %w{multipleInput editMore} + add_more_seri = "add_more_group_#{id}" + multipleInputs = content_tag :div,:class=> multipleInput_ary.join(' ') ,:ext_class=>get_pairing_tab_class({}) do + @attribute_value.add_more_counter.times.collect do |t| + controls_wrapper(:value=>(@prefiled_value[t] rescue nil),:counter=>t,&block) + end.join("\n").html_safe # of add_more fields + end # of div multipleInput editMore + result = label + multipleInputs + add_more_unt + # result = label + 一堆的輸入框(要用 multipleInput editMore 包起來) + add_more btn + hidden_fields + else + temp = label + controls_wrapper(&block) + result = content_tag(:div,temp,:class=>div_class) + end + when "address" - result = content_tag(:div,temp,:class=>div_class) - result << end_block + address = content_tag :div,:class=>"multipleInput editMore" do + controls_wrapper(&block) + end # of div multipleInput editMore + result = label + address + else + temp = label + controls_wrapper(&block) + result = content_tag(:div,temp,:class=>div_class) + end + result << end_block result.html_safe end + + def add_more_unt + temp_field_name = get_basic_field_name_base + '[temp]' + add_more = content_tag :div,:class=> 'controls' do + content_tag :span,:class=> 'help-block' do + content = link_to (content_tag :i,I18n.t("admin.infos.add"),:class=>"icon-plus-sign"),"#",:class=>'addinput' + content << hidden_field_tag("#{temp_field_name}[count]",@attribute_value.add_more_counter ,:class=>"list_count") + content << hidden_field_tag("#{temp_field_name}[count]",get_basic_field_name_base,:class=>"field_name") + content + end # of span + end # of div + end + def end_block if @new_attribute hidden_field_tag(get_basic_field_name_base+"[attribute_field_id]",id,:for=>"field_#{@index}") @@ -200,6 +222,23 @@ protected end end + def add_more_tab(mode,counter,key) + case mode + when :input_field + get_pairing_tab_class(:suffix=>['','tab'+counter.to_s,key].join('-')) + when :tab_btn + ".#{get_pairing_tab_class(:suffix=>['','tab'+counter.to_s,key].join('-'))}" + end + end + + def get_pairing_tab_class(opts) + prefix = opts[:prefix] + suffix = opts[:suffix] + str = get_basic_field_name_base.gsub("[","-").gsub("]",'') + str = prefix.nil? ? str : prefix+ str + suffix.nil? ? str : str + suffix + end + def get_basic_field_name_base if @new_attribute "user[new_attribute_values][#{@index}]" @@ -216,36 +255,30 @@ protected label_tag(key,title,:class=>"control-label",:func => "field_label") end - def can_muti_lang_input - LIST[:markups][markup]["muti_lang_input_supprt"] #and locale + def can_muti_lang_input? + if self.markup == "address" + return true + else + LIST[:markups][markup]["muti_lang_input_supprt"] and !(get_data["cross_lang"] == "true") + end end def can_add_more - locale and LIST[:markups][markup]["ext_support"] && add_more + if self.markup == "address" + return false + else + locale and LIST[:markups][markup]["ext_support"] && add_more + end end -def render_anywhere(partial, assigns) - view = ActionView::Base.new(Rails::Configuration.new.view_path, assigns) - ActionView::Base.helper_modules.each { |helper| view.extend helper } - view.extend ApplicationHelper - view.render(:partial => partial) -end - -def gen_modal_dialog - result = '' - result.html_safe -end + def gen_modal_dialog + render_anywhere("shared/attribute_field/address_modal_dialog",{ + :field_name=>title, + :html_id=>"#{get_pairing_tab_class({})}_m_window", + :btn_class => "#{get_pairing_tab_class({})}", + :field_name_basic => get_basic_field_name_base + } + ) + end end \ No newline at end of file diff --git a/app/helpers/attribute_values_helper.rb b/app/helpers/attribute_values_helper.rb new file mode 100644 index 00000000..f2ea0832 --- /dev/null +++ b/app/helpers/attribute_values_helper.rb @@ -0,0 +1,68 @@ +module AttributeValuesHelper + def show_west_calender + date = get_date + case self.attribute_field["typeC"]["format"] + when 'format1' # Y/M/D h:m + date.strftime("%Y/%m/%d %H:%M") + when 'format2' # Y/M/D + date.strftime("%Y/%m/%d") + when 'format3' # Y/M + date.strftime("%Y/%m") + when 'format4' # Y + date.strftime("%Y") + end # of case west cal format + end + + def show_minguo_calendar + get_minguo + date = get_date + year_str = "" + unless date.year == 1912 + m_year = (date.year - 1912).abs.to_s + I18n.t("admin.infos.date.minguo_calendar.year") + year_str = minguo_format_year(m_year) + end + get_minguo_year + minguo_m_y_d_time + end + + def get_minguo_year + date = get_date + m_year = (date.year - 1911).abs + year_end = I18n.t("admin.infos.date.minguo_calendar.year") + case + when date.year <1912 + I18n.t("admin.infos.date.minguo_calendar.before") + (m_year+1).to_s + year_end + when date.year ==1912 + I18n.t("admin.infos.date.minguo_calendar.first_year") + when date.year >1912 + I18n.t("admin.infos.date.minguo_calendar.after")+ (m_year).to_s + year_end + end # of case tw_claendar year + end + + def minguo_m_y_d_time + date = get_date + case self.attribute_field["typeC"]["format"] + when 'format1' # Y/M/D h:m + date.strftime(" %m/%d %H:%M") + when 'format2' # Y/M/D + date.strftime(" %m/%d") + when 'format3' # Y/M + date.strftime(" %m#{I18n.t("admin.infos.date.minguo_calendar.month")}") + when 'format4' # Y + '' + end # of case + end + + def get_date_by_format + case I18n.locale + when :zh_tw + case + when self.attribute_field["typeC"]["claendar"] == "west_claendar" + show_west_calender + when self.attribute_field["typeC"]["claendar"] == "tw_claendar" + show_minguo_calendar + end #case self.attribute_field["typeC"]["claendar"] + when :en + show_west_calender + end + end +end \ No newline at end of file diff --git a/app/models/design/design.rb b/app/models/design/design.rb index 0013082d..aa43368a 100644 --- a/app/models/design/design.rb +++ b/app/models/design/design.rb @@ -11,10 +11,10 @@ class Design has_one :css_default, as: :css, :autosave => true, :dependent => :destroy has_one :layout, :autosave => true, :dependent => :destroy has_one :css_reset, :autosave => true, :dependent => :destroy - has_many :images,as: :imgs, :autosave => true, :dependent => :destroy + has_many :images, as: :imgs, :autosave => true, :dependent => :destroy has_many :javascripts, as: :js, :autosave => true, :dependent => :destroy has_many :pages - has_many :themes, as: :css, :autosave => true, :dependent => :destroy + has_many :themes, :autosave => true, :dependent => :destroy accepts_nested_attributes_for :images, :allow_destroy => true accepts_nested_attributes_for :javascripts, :allow_destroy => true diff --git a/app/models/design/stylesheet.rb b/app/models/design/stylesheet.rb index 5e9a5775..76fdff78 100644 --- a/app/models/design/stylesheet.rb +++ b/app/models/design/stylesheet.rb @@ -7,7 +7,12 @@ class Stylesheet < DesignFile # self.remove_file! # self.remove_file_orig! names = {} - images = self.css.images + case self._type + when 'Theme' + images = self.design.images + when 'CssDefault' + images = self.css.images + end content.scan(/(?<=url)(.*?)(?=\))/){ css_name = $1.gsub(' ','').gsub('(','') unless names.has_key?(css_name) diff --git a/app/models/design/theme.rb b/app/models/design/theme.rb index 61a621c0..0935fe12 100644 --- a/app/models/design/theme.rb +++ b/app/models/design/theme.rb @@ -1,6 +1,6 @@ class Theme < Stylesheet - belongs_to :css, polymorphic: true + belongs_to :design protected diff --git a/app/models/user/attribute_field.rb b/app/models/user/attribute_field.rb index a94a38a2..9442deac 100644 --- a/app/models/user/attribute_field.rb +++ b/app/models/user/attribute_field.rb @@ -1,5 +1,4 @@ class AttributeField - include Mongoid::Document include Mongoid::Timestamps include ::AttributeFieldsHelper @@ -8,28 +7,24 @@ class AttributeField field :markup ,:default=>"text_field" field :option_list ,:type => Hash,:default => {} field :markup_options,:type => Hash - # field :locale, :type => Boolean, :default => true - # field :list_options, :type => Array field :built_in, :type => Boolean, :default => false field :disabled, :type => Boolean, :default => false field :to_delete,:type=> Boolean,:default => false - field :typeA,:type=> Hash,:default=>{} + field :typeA,:type=> Hash,:default=>{:cross_lang=>false} field :typeB,:type=> Hash,:default=>{} - field :typeC,:type=> Hash,:default=>{:claendar=>"west_claendar"} - field :typeD,:type=> Hash,:default=>{} + field :typeC,:type=> Hash,:default=>{:claendar=>"west_claendar",:format=>"format3"} + field :typeD,:type=> Hash,:default=>{:cross_lang=>false} field :typeE,:type=> Hash,:default=>{} - - - #field :title, localize: true - field :title, localize: true - belongs_to :attribute - # belongs_to :role has_many :attribute_values,:autosave => true, :dependent => :destroy before_save :check_option_list - # validates_uniqueness_of :key + + def markup_value + get_data["option_list"] + end + def add_more (get_data["add_more"] == "true" ? true : false) rescue false end @@ -47,12 +42,6 @@ class AttributeField (self.attribute.role.method(self[:key].pluralize.to_sym) && self.attribute.role.method(self[:key].pluralize+"_for_"+markup)) rescue false end - def markup_value=(var) - if !self_defined_markup_options? - self[:markup_value] = (eval(var) rescue {}) - end - end - def option_list if self_defined_markup_options? #Class need to have corresponding field and value agent @@ -66,8 +55,6 @@ class AttributeField end end - - def markup_options=(var) self[:markup_options] = (eval(var) rescue {}) end @@ -82,7 +69,7 @@ class AttributeField end def role - self.attribute.role + self.attribute.role end def panel @@ -94,51 +81,18 @@ class AttributeField end - # def title_translations - # if locale - # return self.locale_title_translations - # else - # return self[:neutral_title] #Hash[VALID_LOCALES.map{|d| [d,neutral_title]}] - # end - # end - # def title_translations=(var) - # if locale - # self.locale_title_translations = var - # end - # end + def typeA=(var) + check_add_more_convert(var) + check_cross_lang_convert(var,"typeA") + self["typeA"] = var + end - # def title - # if locale - # return self.locale_title - # else - # return self.neutral_title - # end - # end + def typeD=(var) + check_cross_lang_convert(var,"typeD") + self["typeD"] = var + end - # def check_title - # if locale - # self.locale_title_translations = self[:temp_title] - # else - # self.neutral_title = self[:temp_title] - # end - # self.unset("temp_title") - # end - - # def title=(var) - # self["temp_title"] = var - # end - - # # Convert the string list_options into an array - # def select_list_options=(var) - # self.list_options = var.gsub(' ', '').split(',') - # end - - # # Convert the array list_options into a string - # def select_list_options - # self.list_options.to_a.join(', ') - # end - def is_built_in? self.built_in end @@ -149,7 +103,82 @@ class AttributeField protected def check_option_list - self[:option_list] = self[panel]["option_list"] + self[:option_list] = self[panel]["option_list"] rescue nil + end + + def add_more_convert(opt) + case opt + when :to_add_more + self.attribute_values.each do |av| + VALID_LOCALES.each do |loc| + splited_str = av[loc].split(",") rescue [] + av["val"] = [] if av["val"].nil? + splited_str.each_with_index{|value,index| av["val"][index] = av["val"][index].nil? ? {loc=>value} : av["val"][index].merge(loc=>value) } + end + av.unset_all_lang_values + av.save + end #of self.attribute_values.each + when :to_no_add_more + self.attribute_values.each do |av| + VALID_LOCALES.each do |loc| + if av["val"].kind_of? Array + av[loc] = av["val"].collect{|t| t[loc]}.join(",") + else + av[loc] = av["val"] + end + end + av.unset("val") + av.save + end #of self.attribute_values.each + end + end + + def cross_lang_convert(opt) + case opt + when :to_cross_lang + self.attribute_values.each do |av| + if add_more + av["val"] = av["val"].collect{|t| t.invert.keys.join(",")} + else + av["val"] = VALID_LOCALES.collect{|t| av[t]}.join(",") + av.unset_all_lang_values + end + av.save + end #of self.attribute_values.each + when :to_no_cross_lang + default_locale = I18n.default_locale.to_s + self.attribute_values.each do |av| + if add_more + av["val"] = av["val"].collect{|t| {default_locale => t} } #unless av["val"].nil? + else + av[default_locale] = av["val"] + av.unset("val") + end + av.save + end #of self.attribute_values.each + end + end + + def check_add_more_convert(var) + if self["typeA"]["add_more"] != var["add_more"] + case var["add_more"] + when "true" #from no-add_more to add_more + add_more_convert(:to_add_more) + else #from add_more to no-add_more + add_more_convert(:to_no_add_more) + end # of case + end # of if + end + + def check_cross_lang_convert(var,field) + if self[field]["cross_lang"] != var["cross_lang"] + case var["cross_lang"] + when "true" #from no-add_more to add_more + cross_lang_convert(:to_cross_lang) + else #from add_more to no-add_more + cross_lang_convert(:to_no_cross_lang) + end # of case + end # of if end end diff --git a/app/models/user/attribute_value.rb b/app/models/user/attribute_value.rb index d6500fbf..256fe072 100644 --- a/app/models/user/attribute_value.rb +++ b/app/models/user/attribute_value.rb @@ -1,11 +1,12 @@ class AttributeValue - include Mongoid::Document include Mongoid::Timestamps include Mongoid::MultiParameterAttributes - + include AttributeValuesHelper field :key + field :address_ext + belongs_to :attribute_field belongs_to :user @@ -13,52 +14,110 @@ class AttributeValue before_save :data_proc # NO_MULTI_TAG = ["select","date","radio_button","checkbox","date_durnation"] + - def data_proc - # binding.pry - # binding.pry if self.attribute_field.markup == 'radio_button' - # if self.attribute_field - case self.attribute_field.markup - when 'text_field','text_area' - # binding.pry - self[:temp_data].each{|key,val| - self[key] = val - } unless self[:temp_data].nil? - when 'select','date','radio_button' - self["val"] = self[:temp_data] - when 'checkbox' - self["val"] = self[:temp_data].keys rescue {} - end #end of case - else # if not locale - case self.attribute_field.markup - when 'text_field','text_area' - self["val"] = self[:temp_data] - when 'select','date','radio_button' - self["val"] = self[:temp_data] - when 'checkbox' - self["val"] = self[:temp_data].keys rescue {} - end #end of case - # end #of if self.attribute_field - self.unset('temp_data') + def add_more_counter + index_max = self["val"].count rescue 0 + index_max == 0 ? 1 : index_max end - def value - - result="" - if self.attribute_field.locale && (self.attribute_field.markup == "text_field" || self.attribute_field.markup == "text_area") - result= Hash[VALID_LOCALES.collect{|lang| [lang,self[lang.to_sym]]}] - else - result = self["val"] - end - result + def value(index = nil) + result = case self.attribute_field.markup + when 'text_field','text_area' + if self.attribute_field.add_more and (self.attribute_field.markup == "text_field") + index.nil? ? self["val"] : self["val"][index] + # self.attribute_field.get_data[:cross_lang] ? Hash[VALID_LOCALES.collect{|lang| [lang,self[lang.to_sym]]}] : self["val"] #if !self.attribute_field.get_data[:cross_lang] + else + self.attribute_field.get_data["cross_lang"] =="true" ? self["val"] : Hash[VALID_LOCALES.collect{|lang| [lang,self[lang.to_sym]]}] + end + when 'select','date','radio_button','address' + self["val"] + when 'checkbox' + self["val"] + end #end of case self.attribute_field.markup end def value=(value) #save everything to temp_data waiting for futher process - # binding self[:temp_data] = value end + + def get_value_by_locale(locale,add_more_index=nil) + + case self.attribute_field.markup + when "text_field" + case self.attribute_field.add_more + when true + add_more_index.nil? ? self.value.collect{|t| t[locale]}.join(",") : self.value(add_more_index)[locale] + when false + self.attribute_field.locale ? self[locale.to_s] : self.value + end + + when "select" + markup_values = self.attribute_field.self_defined_markup_options? ? self.attribute_field.markup_value : self.attribute_field.markup_value + markup_values[self.value][locale.to_s] rescue 'NoData' + + when "text_area" + self.attribute_field.locale ? self[locale.to_s] : self.value + + when "date" + get_date_by_format + + when "address" + self.value[locale.to_s] + + when "radio_button" + markup_values = self.attribute_field.markup_value + markup_values[self.value][locale.to_s] + + when "checkbox" + markup_values = self.attribute_field.markup_value + self.value.collect{|key| markup_values[key][locale.to_s]}.join(",") + + when "date_durnation" + self.value + + else + self.attribute_field.locale ? self[locale.to_s] : self.value + end + end + + +protected + +def unset_all_lang_values + VALID_LOCALES.each{|t| self.unset t} + end + + def data_proc + unless self[:temp_data].nil? + case self.attribute_field.markup + when "address" + self["val"] = self["temp_data"] + when 'text_field','text_area' + if self.attribute_field.add_more + self["val"] = self["temp_data"] + else # if not add_more + if self.attribute_field.can_muti_lang_input? + self[:temp_data].each do |key,val| + self[key] = val + end if(!self.attribute_field.get_data[:cross_lang]) + else + self["val"] = self[:temp_data] + end + end # of self.attribute_field.add_more + + when 'select','date','radio_button' + self["val"] = self[:temp_data] + when 'checkbox' + self["val"] = self[:temp_data].keys + end #end of case self.attribute_field.markup + end # of self[:temp_data].nil? + self.unset('temp_data') + self.unset('temp') + end #of data_proc + def check_key self.key = attribute_field.key end @@ -70,48 +129,10 @@ class AttributeValue self[(field[0].to_s.delete "=")] = field[1] end end - - def get_value_by_locale(locale) - case self.attribute_field.markup - when "text_field" - self.attribute_field.locale ? self[locale.to_s] : self.value - when "select" - markup_values = self.attribute_field.self_defined_markup_options? ? self.attribute_field.markup_value : eval(self.attribute_field.markup_value) - markup_values[self.value][locale.to_s] rescue 'NoData' - when "text_area" - self.attribute_field.locale ? self[locale.to_s] : self.value - when "date" - Date.new(self[:val]["(1i)"].to_i,self[:val]["(2i)"].to_i,self[:val]["(3i)"].to_i) rescue nil - when "addr" - self.value - when "radio_button" - markup_values = eval(self.attribute_field.markup_value) - markup_values[:value][locale.to_s] - when "checkbox" - markup_values = self.attribute_field.markup_value - self[:value].keys.collect{|key| markup_values[key][locale.to_s]}.join(",") - when "date_durnation" - self.value - else - self.attribute_field.locale ? self[locale.to_s] : self.value - end + + def get_date + Date.new(self[:val]["(1i)"].to_i,self[:val]["(2i)"].to_i,self[:val]["(3i)"].to_i) rescue nil end - # def get_values - # unless ['select','checkbox','radio_button'].include?(self.attribute_field.markup ) - # if self.attribute_field.locale && LIST[:markups][self.attribute_field.markup]["muti_lang_input_supprt"] - # return Hash[VALID_LOCALES.collect{|lang| [lang,get_value_by_locale(lang.to_sym)]}] - # else - # return get_value_by_locale("") - # end - # else - # if self.attribute_field.markup == "select" - # self[:value] - # else - # self[:value].keys rescue self[:value] - # end - # end - # end - end diff --git a/app/views/admin/attributes/edit.html.erb b/app/views/admin/attributes/edit.html.erb index da159134..90f0c750 100644 --- a/app/views/admin/attributes/edit.html.erb +++ b/app/views/admin/attributes/edit.html.erb @@ -42,14 +42,6 @@ var NewNode; $(document).ready(function(){ - // function mas(){ - // $('.site-map').masonry({ - // itemSelector: '.map-block', - // columnWidth: 450, - // isAnimated: true - // }); - // } - function checkSwitch() { $(".groups").addClass('disabled').has('.groups > .form-horizontal > div:not(.hide)').removeClass('disabled'); } diff --git a/app/views/admin/designs/edit.html.erb b/app/views/admin/designs/edit.html.erb index c49c5fb4..2a710dd0 100644 --- a/app/views/admin/designs/edit.html.erb +++ b/app/views/admin/designs/edit.html.erb @@ -34,10 +34,10 @@
    <%= render :partial => 'tab_form', :locals => {:type => :css_default, :object => @design.css_default} %>
    <%= render :partial => 'tab_form', :locals => {:type => :css_reset, :object => @design.css_reset} %>
    <% @design.themes.each do |theme| %> -
    <%= render :partial => 'tab_form', :locals => {:type => :css_reset, :object => theme} %>
    +
    <%= render :partial => 'tab_form', :locals => {:type => :themes, :object => theme} %>
    <% end %> <% @design.javascripts.each do |js| %> -
    <%= render :partial => 'tab_form', :locals => {:type => :css_reset, :object => js} %>
    +
    <%= render :partial => 'tab_form', :locals => {:type => :javascripts, :object => js} %>
    <% end %>
    <%= render :partial => 'images' %>
    diff --git a/app/views/admin/infos/_attribute_field.html.erb b/app/views/admin/infos/_attribute_field.html.erb index 95d60268..f8c7a701 100644 --- a/app/views/admin/infos/_attribute_field.html.erb +++ b/app/views/admin/infos/_attribute_field.html.erb @@ -33,8 +33,8 @@
    -
    +
    diff --git a/vendor/built_in_modules/gallery/app/assets/javascripts/cycle.js b/vendor/built_in_modules/gallery/app/assets/javascripts/cycle.js new file mode 100755 index 00000000..cd607307 --- /dev/null +++ b/vendor/built_in_modules/gallery/app/assets/javascripts/cycle.js @@ -0,0 +1,1551 @@ +/*! + * jQuery Cycle Plugin (with Transition Definitions) + * Examples and documentation at: http://jquery.malsup.com/cycle/ + * Copyright (c) 2007-2010 M. Alsup + * Version: 2.9999.8 (26-OCT-2012) + * Dual licensed under the MIT and GPL licenses. + * http://jquery.malsup.com/license.html + * Requires: jQuery v1.3.2 or later + */ +;(function($, undefined) { +"use strict"; + +var ver = '2.9999.8'; + +// if $.support is not defined (pre jQuery 1.3) add what I need +if ($.support === undefined) { + $.support = { + opacity: !($.browser.msie) + }; +} + +function debug(s) { + if ($.fn.cycle.debug) + log(s); +} +function log() { + if (window.console && console.log) + console.log('[cycle] ' + Array.prototype.join.call(arguments,' ')); +} +$.expr[':'].paused = function(el) { + return el.cyclePause; +}; + + +// the options arg can be... +// a number - indicates an immediate transition should occur to the given slide index +// a string - 'pause', 'resume', 'toggle', 'next', 'prev', 'stop', 'destroy' or the name of a transition effect (ie, 'fade', 'zoom', etc) +// an object - properties to control the slideshow +// +// the arg2 arg can be... +// the name of an fx (only used in conjunction with a numeric value for 'options') +// the value true (only used in first arg == 'resume') and indicates +// that the resume should occur immediately (not wait for next timeout) + +$.fn.cycle = function(options, arg2) { + var o = { s: this.selector, c: this.context }; + + // in 1.3+ we can fix mistakes with the ready state + if (this.length === 0 && options != 'stop') { + if (!$.isReady && o.s) { + log('DOM not ready, queuing slideshow'); + $(function() { + $(o.s,o.c).cycle(options,arg2); + }); + return this; + } + // is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready() + log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)')); + return this; + } + + // iterate the matched nodeset + return this.each(function() { + var opts = handleArguments(this, options, arg2); + if (opts === false) + return; + + opts.updateActivePagerLink = opts.updateActivePagerLink || $.fn.cycle.updateActivePagerLink; + + // stop existing slideshow for this container (if there is one) + if (this.cycleTimeout) + clearTimeout(this.cycleTimeout); + this.cycleTimeout = this.cyclePause = 0; + this.cycleStop = 0; // issue #108 + + var $cont = $(this); + var $slides = opts.slideExpr ? $(opts.slideExpr, this) : $cont.children(); + var els = $slides.get(); + + if (els.length < 2) { + log('terminating; too few slides: ' + els.length); + return; + } + + var opts2 = buildOptions($cont, $slides, els, opts, o); + if (opts2 === false) + return; + + var startTime = opts2.continuous ? 10 : getTimeout(els[opts2.currSlide], els[opts2.nextSlide], opts2, !opts2.backwards); + + // if it's an auto slideshow, kick it off + if (startTime) { + startTime += (opts2.delay || 0); + if (startTime < 10) + startTime = 10; + debug('first timeout: ' + startTime); + this.cycleTimeout = setTimeout(function(){go(els,opts2,0,!opts.backwards);}, startTime); + } + }); +}; + +function triggerPause(cont, byHover, onPager) { + var opts = $(cont).data('cycle.opts'); + if (!opts) + return; + var paused = !!cont.cyclePause; + if (paused && opts.paused) + opts.paused(cont, opts, byHover, onPager); + else if (!paused && opts.resumed) + opts.resumed(cont, opts, byHover, onPager); +} + +// process the args that were passed to the plugin fn +function handleArguments(cont, options, arg2) { + if (cont.cycleStop === undefined) + cont.cycleStop = 0; + if (options === undefined || options === null) + options = {}; + if (options.constructor == String) { + switch(options) { + case 'destroy': + case 'stop': + var opts = $(cont).data('cycle.opts'); + if (!opts) + return false; + cont.cycleStop++; // callbacks look for change + if (cont.cycleTimeout) + clearTimeout(cont.cycleTimeout); + cont.cycleTimeout = 0; + if (opts.elements) + $(opts.elements).stop(); + $(cont).removeData('cycle.opts'); + if (options == 'destroy') + destroy(cont, opts); + return false; + case 'toggle': + cont.cyclePause = (cont.cyclePause === 1) ? 0 : 1; + checkInstantResume(cont.cyclePause, arg2, cont); + triggerPause(cont); + return false; + case 'pause': + cont.cyclePause = 1; + triggerPause(cont); + return false; + case 'resume': + cont.cyclePause = 0; + checkInstantResume(false, arg2, cont); + triggerPause(cont); + return false; + case 'prev': + case 'next': + opts = $(cont).data('cycle.opts'); + if (!opts) { + log('options not found, "prev/next" ignored'); + return false; + } + $.fn.cycle[options](opts); + return false; + default: + options = { fx: options }; + } + return options; + } + else if (options.constructor == Number) { + // go to the requested slide + var num = options; + options = $(cont).data('cycle.opts'); + if (!options) { + log('options not found, can not advance slide'); + return false; + } + if (num < 0 || num >= options.elements.length) { + log('invalid slide index: ' + num); + return false; + } + options.nextSlide = num; + if (cont.cycleTimeout) { + clearTimeout(cont.cycleTimeout); + cont.cycleTimeout = 0; + } + if (typeof arg2 == 'string') + options.oneTimeFx = arg2; + go(options.elements, options, 1, num >= options.currSlide); + return false; + } + return options; + + function checkInstantResume(isPaused, arg2, cont) { + if (!isPaused && arg2 === true) { // resume now! + var options = $(cont).data('cycle.opts'); + if (!options) { + log('options not found, can not resume'); + return false; + } + if (cont.cycleTimeout) { + clearTimeout(cont.cycleTimeout); + cont.cycleTimeout = 0; + } + go(options.elements, options, 1, !options.backwards); + } + } +} + +function removeFilter(el, opts) { + if (!$.support.opacity && opts.cleartype && el.style.filter) { + try { el.style.removeAttribute('filter'); } + catch(smother) {} // handle old opera versions + } +} + +// unbind event handlers +function destroy(cont, opts) { + if (opts.next) + $(opts.next).unbind(opts.prevNextEvent); + if (opts.prev) + $(opts.prev).unbind(opts.prevNextEvent); + + if (opts.pager || opts.pagerAnchorBuilder) + $.each(opts.pagerAnchors || [], function() { + this.unbind().remove(); + }); + opts.pagerAnchors = null; + $(cont).unbind('mouseenter.cycle mouseleave.cycle'); + if (opts.destroy) // callback + opts.destroy(opts); +} + +// one-time initialization +function buildOptions($cont, $slides, els, options, o) { + var startingSlideSpecified; + // support metadata plugin (v1.0 and v2.0) + var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : $.meta ? $cont.data() : {}); + var meta = $.isFunction($cont.data) ? $cont.data(opts.metaAttr) : null; + if (meta) + opts = $.extend(opts, meta); + if (opts.autostop) + opts.countdown = opts.autostopCount || els.length; + + var cont = $cont[0]; + $cont.data('cycle.opts', opts); + opts.$cont = $cont; + opts.stopCount = cont.cycleStop; + opts.elements = els; + opts.before = opts.before ? [opts.before] : []; + opts.after = opts.after ? [opts.after] : []; + + // push some after callbacks + if (!$.support.opacity && opts.cleartype) + opts.after.push(function() { removeFilter(this, opts); }); + if (opts.continuous) + opts.after.push(function() { go(els,opts,0,!opts.backwards); }); + + saveOriginalOpts(opts); + + // clearType corrections + if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg) + clearTypeFix($slides); + + // container requires non-static position so that slides can be position within + if ($cont.css('position') == 'static') + $cont.css('position', 'relative'); + if (opts.width) + $cont.width(opts.width); + if (opts.height && opts.height != 'auto') + $cont.height(opts.height); + + if (opts.startingSlide !== undefined) { + opts.startingSlide = parseInt(opts.startingSlide,10); + if (opts.startingSlide >= els.length || opts.startSlide < 0) + opts.startingSlide = 0; // catch bogus input + else + startingSlideSpecified = true; + } + else if (opts.backwards) + opts.startingSlide = els.length - 1; + else + opts.startingSlide = 0; + + // if random, mix up the slide array + if (opts.random) { + opts.randomMap = []; + for (var i = 0; i < els.length; i++) + opts.randomMap.push(i); + opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;}); + if (startingSlideSpecified) { + // try to find the specified starting slide and if found set start slide index in the map accordingly + for ( var cnt = 0; cnt < els.length; cnt++ ) { + if ( opts.startingSlide == opts.randomMap[cnt] ) { + opts.randomIndex = cnt; + } + } + } + else { + opts.randomIndex = 1; + opts.startingSlide = opts.randomMap[1]; + } + } + else if (opts.startingSlide >= els.length) + opts.startingSlide = 0; // catch bogus input + opts.currSlide = opts.startingSlide || 0; + var first = opts.startingSlide; + + // set position and zIndex on all the slides + $slides.css({position: 'absolute', top:0, left:0}).hide().each(function(i) { + var z; + if (opts.backwards) + z = first ? i <= first ? els.length + (i-first) : first-i : els.length-i; + else + z = first ? i >= first ? els.length - (i-first) : first-i : els.length-i; + $(this).css('z-index', z); + }); + + // make sure first slide is visible + $(els[first]).css('opacity',1).show(); // opacity bit needed to handle restart use case + removeFilter(els[first], opts); + + // stretch slides + if (opts.fit) { + if (!opts.aspect) { + if (opts.width) + $slides.width(opts.width); + if (opts.height && opts.height != 'auto') + $slides.height(opts.height); + } else { + $slides.each(function(){ + var $slide = $(this); + var ratio = (opts.aspect === true) ? $slide.width()/$slide.height() : opts.aspect; + if( opts.width && $slide.width() != opts.width ) { + $slide.width( opts.width ); + $slide.height( opts.width / ratio ); + } + + if( opts.height && $slide.height() < opts.height ) { + $slide.height( opts.height ); + $slide.width( opts.height * ratio ); + } + }); + } + } + + if (opts.center && ((!opts.fit) || opts.aspect)) { + $slides.each(function(){ + var $slide = $(this); + $slide.css({ + "margin-left": opts.width ? + ((opts.width - $slide.width()) / 2) + "px" : + 0, + "margin-top": opts.height ? + ((opts.height - $slide.height()) / 2) + "px" : + 0 + }); + }); + } + + if (opts.center && !opts.fit && !opts.slideResize) { + $slides.each(function(){ + var $slide = $(this); + $slide.css({ + "margin-left": opts.width ? ((opts.width - $slide.width()) / 2) + "px" : 0, + "margin-top": opts.height ? ((opts.height - $slide.height()) / 2) + "px" : 0 + }); + }); + } + + // stretch container + var reshape = (opts.containerResize || opts.containerResizeHeight) && !$cont.innerHeight(); + if (reshape) { // do this only if container has no size http://tinyurl.com/da2oa9 + var maxw = 0, maxh = 0; + for(var j=0; j < els.length; j++) { + var $e = $(els[j]), e = $e[0], w = $e.outerWidth(), h = $e.outerHeight(); + if (!w) w = e.offsetWidth || e.width || $e.attr('width'); + if (!h) h = e.offsetHeight || e.height || $e.attr('height'); + maxw = w > maxw ? w : maxw; + maxh = h > maxh ? h : maxh; + } + if (opts.containerResize && maxw > 0 && maxh > 0) + $cont.css({width:maxw+'px',height:maxh+'px'}); + if (opts.containerResizeHeight && maxh > 0) + $cont.css({height:maxh+'px'}); + } + + var pauseFlag = false; // https://github.com/malsup/cycle/issues/44 + if (opts.pause) + $cont.bind('mouseenter.cycle', function(){ + pauseFlag = true; + this.cyclePause++; + triggerPause(cont, true); + }).bind('mouseleave.cycle', function(){ + if (pauseFlag) + this.cyclePause--; + triggerPause(cont, true); + }); + + if (supportMultiTransitions(opts) === false) + return false; + + // apparently a lot of people use image slideshows without height/width attributes on the images. + // Cycle 2.50+ requires the sizing info for every slide; this block tries to deal with that. + var requeue = false; + options.requeueAttempts = options.requeueAttempts || 0; + $slides.each(function() { + // try to get height/width of each slide + var $el = $(this); + this.cycleH = (opts.fit && opts.height) ? opts.height : ($el.height() || this.offsetHeight || this.height || $el.attr('height') || 0); + this.cycleW = (opts.fit && opts.width) ? opts.width : ($el.width() || this.offsetWidth || this.width || $el.attr('width') || 0); + + if ( $el.is('img') ) { + // sigh.. sniffing, hacking, shrugging... this crappy hack tries to account for what browsers do when + // an image is being downloaded and the markup did not include sizing info (height/width attributes); + // there seems to be some "default" sizes used in this situation + var loadingIE = ($.browser.msie && this.cycleW == 28 && this.cycleH == 30 && !this.complete); + var loadingFF = ($.browser.mozilla && this.cycleW == 34 && this.cycleH == 19 && !this.complete); + var loadingOp = ($.browser.opera && ((this.cycleW == 42 && this.cycleH == 19) || (this.cycleW == 37 && this.cycleH == 17)) && !this.complete); + var loadingOther = (this.cycleH === 0 && this.cycleW === 0 && !this.complete); + // don't requeue for images that are still loading but have a valid size + if (loadingIE || loadingFF || loadingOp || loadingOther) { + if (o.s && opts.requeueOnImageNotLoaded && ++options.requeueAttempts < 100) { // track retry count so we don't loop forever + log(options.requeueAttempts,' - img slide not loaded, requeuing slideshow: ', this.src, this.cycleW, this.cycleH); + setTimeout(function() {$(o.s,o.c).cycle(options);}, opts.requeueTimeout); + requeue = true; + return false; // break each loop + } + else { + log('could not determine size of image: '+this.src, this.cycleW, this.cycleH); + } + } + } + return true; + }); + + if (requeue) + return false; + + opts.cssBefore = opts.cssBefore || {}; + opts.cssAfter = opts.cssAfter || {}; + opts.cssFirst = opts.cssFirst || {}; + opts.animIn = opts.animIn || {}; + opts.animOut = opts.animOut || {}; + + $slides.not(':eq('+first+')').css(opts.cssBefore); + $($slides[first]).css(opts.cssFirst); + + if (opts.timeout) { + opts.timeout = parseInt(opts.timeout,10); + // ensure that timeout and speed settings are sane + if (opts.speed.constructor == String) + opts.speed = $.fx.speeds[opts.speed] || parseInt(opts.speed,10); + if (!opts.sync) + opts.speed = opts.speed / 2; + + var buffer = opts.fx == 'none' ? 0 : opts.fx == 'shuffle' ? 500 : 250; + while((opts.timeout - opts.speed) < buffer) // sanitize timeout + opts.timeout += opts.speed; + } + if (opts.easing) + opts.easeIn = opts.easeOut = opts.easing; + if (!opts.speedIn) + opts.speedIn = opts.speed; + if (!opts.speedOut) + opts.speedOut = opts.speed; + + opts.slideCount = els.length; + opts.currSlide = opts.lastSlide = first; + if (opts.random) { + if (++opts.randomIndex == els.length) + opts.randomIndex = 0; + opts.nextSlide = opts.randomMap[opts.randomIndex]; + } + else if (opts.backwards) + opts.nextSlide = opts.startingSlide === 0 ? (els.length-1) : opts.startingSlide-1; + else + opts.nextSlide = opts.startingSlide >= (els.length-1) ? 0 : opts.startingSlide+1; + + // run transition init fn + if (!opts.multiFx) { + var init = $.fn.cycle.transitions[opts.fx]; + if ($.isFunction(init)) + init($cont, $slides, opts); + else if (opts.fx != 'custom' && !opts.multiFx) { + log('unknown transition: ' + opts.fx,'; slideshow terminating'); + return false; + } + } + + // fire artificial events + var e0 = $slides[first]; + if (!opts.skipInitializationCallbacks) { + if (opts.before.length) + opts.before[0].apply(e0, [e0, e0, opts, true]); + if (opts.after.length) + opts.after[0].apply(e0, [e0, e0, opts, true]); + } + if (opts.next) + $(opts.next).bind(opts.prevNextEvent,function(){return advance(opts,1);}); + if (opts.prev) + $(opts.prev).bind(opts.prevNextEvent,function(){return advance(opts,0);}); + if (opts.pager || opts.pagerAnchorBuilder) + buildPager(els,opts); + + exposeAddSlide(opts, els); + + return opts; +} + +// save off original opts so we can restore after clearing state +function saveOriginalOpts(opts) { + opts.original = { before: [], after: [] }; + opts.original.cssBefore = $.extend({}, opts.cssBefore); + opts.original.cssAfter = $.extend({}, opts.cssAfter); + opts.original.animIn = $.extend({}, opts.animIn); + opts.original.animOut = $.extend({}, opts.animOut); + $.each(opts.before, function() { opts.original.before.push(this); }); + $.each(opts.after, function() { opts.original.after.push(this); }); +} + +function supportMultiTransitions(opts) { + var i, tx, txs = $.fn.cycle.transitions; + // look for multiple effects + if (opts.fx.indexOf(',') > 0) { + opts.multiFx = true; + opts.fxs = opts.fx.replace(/\s*/g,'').split(','); + // discard any bogus effect names + for (i=0; i < opts.fxs.length; i++) { + var fx = opts.fxs[i]; + tx = txs[fx]; + if (!tx || !txs.hasOwnProperty(fx) || !$.isFunction(tx)) { + log('discarding unknown transition: ',fx); + opts.fxs.splice(i,1); + i--; + } + } + // if we have an empty list then we threw everything away! + if (!opts.fxs.length) { + log('No valid transitions named; slideshow terminating.'); + return false; + } + } + else if (opts.fx == 'all') { // auto-gen the list of transitions + opts.multiFx = true; + opts.fxs = []; + for (var p in txs) { + if (txs.hasOwnProperty(p)) { + tx = txs[p]; + if (txs.hasOwnProperty(p) && $.isFunction(tx)) + opts.fxs.push(p); + } + } + } + if (opts.multiFx && opts.randomizeEffects) { + // munge the fxs array to make effect selection random + var r1 = Math.floor(Math.random() * 20) + 30; + for (i = 0; i < r1; i++) { + var r2 = Math.floor(Math.random() * opts.fxs.length); + opts.fxs.push(opts.fxs.splice(r2,1)[0]); + } + debug('randomized fx sequence: ',opts.fxs); + } + return true; +} + +// provide a mechanism for adding slides after the slideshow has started +function exposeAddSlide(opts, els) { + opts.addSlide = function(newSlide, prepend) { + var $s = $(newSlide), s = $s[0]; + if (!opts.autostopCount) + opts.countdown++; + els[prepend?'unshift':'push'](s); + if (opts.els) + opts.els[prepend?'unshift':'push'](s); // shuffle needs this + opts.slideCount = els.length; + + // add the slide to the random map and resort + if (opts.random) { + opts.randomMap.push(opts.slideCount-1); + opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;}); + } + + $s.css('position','absolute'); + $s[prepend?'prependTo':'appendTo'](opts.$cont); + + if (prepend) { + opts.currSlide++; + opts.nextSlide++; + } + + if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg) + clearTypeFix($s); + + if (opts.fit && opts.width) + $s.width(opts.width); + if (opts.fit && opts.height && opts.height != 'auto') + $s.height(opts.height); + s.cycleH = (opts.fit && opts.height) ? opts.height : $s.height(); + s.cycleW = (opts.fit && opts.width) ? opts.width : $s.width(); + + $s.css(opts.cssBefore); + + if (opts.pager || opts.pagerAnchorBuilder) + $.fn.cycle.createPagerAnchor(els.length-1, s, $(opts.pager), els, opts); + + if ($.isFunction(opts.onAddSlide)) + opts.onAddSlide($s); + else + $s.hide(); // default behavior + }; +} + +// reset internal state; we do this on every pass in order to support multiple effects +$.fn.cycle.resetState = function(opts, fx) { + fx = fx || opts.fx; + opts.before = []; opts.after = []; + opts.cssBefore = $.extend({}, opts.original.cssBefore); + opts.cssAfter = $.extend({}, opts.original.cssAfter); + opts.animIn = $.extend({}, opts.original.animIn); + opts.animOut = $.extend({}, opts.original.animOut); + opts.fxFn = null; + $.each(opts.original.before, function() { opts.before.push(this); }); + $.each(opts.original.after, function() { opts.after.push(this); }); + + // re-init + var init = $.fn.cycle.transitions[fx]; + if ($.isFunction(init)) + init(opts.$cont, $(opts.elements), opts); +}; + +// this is the main engine fn, it handles the timeouts, callbacks and slide index mgmt +function go(els, opts, manual, fwd) { + var p = opts.$cont[0], curr = els[opts.currSlide], next = els[opts.nextSlide]; + + // opts.busy is true if we're in the middle of an animation + if (manual && opts.busy && opts.manualTrump) { + // let manual transitions requests trump active ones + debug('manualTrump in go(), stopping active transition'); + $(els).stop(true,true); + opts.busy = 0; + clearTimeout(p.cycleTimeout); + } + + // don't begin another timeout-based transition if there is one active + if (opts.busy) { + debug('transition active, ignoring new tx request'); + return; + } + + + // stop cycling if we have an outstanding stop request + if (p.cycleStop != opts.stopCount || p.cycleTimeout === 0 && !manual) + return; + + // check to see if we should stop cycling based on autostop options + if (!manual && !p.cyclePause && !opts.bounce && + ((opts.autostop && (--opts.countdown <= 0)) || + (opts.nowrap && !opts.random && opts.nextSlide < opts.currSlide))) { + if (opts.end) + opts.end(opts); + return; + } + + // if slideshow is paused, only transition on a manual trigger + var changed = false; + if ((manual || !p.cyclePause) && (opts.nextSlide != opts.currSlide)) { + changed = true; + var fx = opts.fx; + // keep trying to get the slide size if we don't have it yet + curr.cycleH = curr.cycleH || $(curr).height(); + curr.cycleW = curr.cycleW || $(curr).width(); + next.cycleH = next.cycleH || $(next).height(); + next.cycleW = next.cycleW || $(next).width(); + + // support multiple transition types + if (opts.multiFx) { + if (fwd && (opts.lastFx === undefined || ++opts.lastFx >= opts.fxs.length)) + opts.lastFx = 0; + else if (!fwd && (opts.lastFx === undefined || --opts.lastFx < 0)) + opts.lastFx = opts.fxs.length - 1; + fx = opts.fxs[opts.lastFx]; + } + + // one-time fx overrides apply to: $('div').cycle(3,'zoom'); + if (opts.oneTimeFx) { + fx = opts.oneTimeFx; + opts.oneTimeFx = null; + } + + $.fn.cycle.resetState(opts, fx); + + // run the before callbacks + if (opts.before.length) + $.each(opts.before, function(i,o) { + if (p.cycleStop != opts.stopCount) return; + o.apply(next, [curr, next, opts, fwd]); + }); + + // stage the after callacks + var after = function() { + opts.busy = 0; + $.each(opts.after, function(i,o) { + if (p.cycleStop != opts.stopCount) return; + o.apply(next, [curr, next, opts, fwd]); + }); + if (!p.cycleStop) { + // queue next transition + queueNext(); + } + }; + + debug('tx firing('+fx+'); currSlide: ' + opts.currSlide + '; nextSlide: ' + opts.nextSlide); + + // get ready to perform the transition + opts.busy = 1; + if (opts.fxFn) // fx function provided? + opts.fxFn(curr, next, opts, after, fwd, manual && opts.fastOnEvent); + else if ($.isFunction($.fn.cycle[opts.fx])) // fx plugin ? + $.fn.cycle[opts.fx](curr, next, opts, after, fwd, manual && opts.fastOnEvent); + else + $.fn.cycle.custom(curr, next, opts, after, fwd, manual && opts.fastOnEvent); + } + else { + queueNext(); + } + + if (changed || opts.nextSlide == opts.currSlide) { + // calculate the next slide + var roll; + opts.lastSlide = opts.currSlide; + if (opts.random) { + opts.currSlide = opts.nextSlide; + if (++opts.randomIndex == els.length) { + opts.randomIndex = 0; + opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;}); + } + opts.nextSlide = opts.randomMap[opts.randomIndex]; + if (opts.nextSlide == opts.currSlide) + opts.nextSlide = (opts.currSlide == opts.slideCount - 1) ? 0 : opts.currSlide + 1; + } + else if (opts.backwards) { + roll = (opts.nextSlide - 1) < 0; + if (roll && opts.bounce) { + opts.backwards = !opts.backwards; + opts.nextSlide = 1; + opts.currSlide = 0; + } + else { + opts.nextSlide = roll ? (els.length-1) : opts.nextSlide-1; + opts.currSlide = roll ? 0 : opts.nextSlide+1; + } + } + else { // sequence + roll = (opts.nextSlide + 1) == els.length; + if (roll && opts.bounce) { + opts.backwards = !opts.backwards; + opts.nextSlide = els.length-2; + opts.currSlide = els.length-1; + } + else { + opts.nextSlide = roll ? 0 : opts.nextSlide+1; + opts.currSlide = roll ? els.length-1 : opts.nextSlide-1; + } + } + } + if (changed && opts.pager) + opts.updateActivePagerLink(opts.pager, opts.currSlide, opts.activePagerClass); + + function queueNext() { + // stage the next transition + var ms = 0, timeout = opts.timeout; + if (opts.timeout && !opts.continuous) { + ms = getTimeout(els[opts.currSlide], els[opts.nextSlide], opts, fwd); + if (opts.fx == 'shuffle') + ms -= opts.speedOut; + } + else if (opts.continuous && p.cyclePause) // continuous shows work off an after callback, not this timer logic + ms = 10; + if (ms > 0) + p.cycleTimeout = setTimeout(function(){ go(els, opts, 0, !opts.backwards); }, ms); + } +} + +// invoked after transition +$.fn.cycle.updateActivePagerLink = function(pager, currSlide, clsName) { + $(pager).each(function() { + $(this).children().removeClass(clsName).eq(currSlide).addClass(clsName); + }); +}; + +// calculate timeout value for current transition +function getTimeout(curr, next, opts, fwd) { + if (opts.timeoutFn) { + // call user provided calc fn + var t = opts.timeoutFn.call(curr,curr,next,opts,fwd); + while (opts.fx != 'none' && (t - opts.speed) < 250) // sanitize timeout + t += opts.speed; + debug('calculated timeout: ' + t + '; speed: ' + opts.speed); + if (t !== false) + return t; + } + return opts.timeout; +} + +// expose next/prev function, caller must pass in state +$.fn.cycle.next = function(opts) { advance(opts,1); }; +$.fn.cycle.prev = function(opts) { advance(opts,0);}; + +// advance slide forward or back +function advance(opts, moveForward) { + var val = moveForward ? 1 : -1; + var els = opts.elements; + var p = opts.$cont[0], timeout = p.cycleTimeout; + if (timeout) { + clearTimeout(timeout); + p.cycleTimeout = 0; + } + if (opts.random && val < 0) { + // move back to the previously display slide + opts.randomIndex--; + if (--opts.randomIndex == -2) + opts.randomIndex = els.length-2; + else if (opts.randomIndex == -1) + opts.randomIndex = els.length-1; + opts.nextSlide = opts.randomMap[opts.randomIndex]; + } + else if (opts.random) { + opts.nextSlide = opts.randomMap[opts.randomIndex]; + } + else { + opts.nextSlide = opts.currSlide + val; + if (opts.nextSlide < 0) { + if (opts.nowrap) return false; + opts.nextSlide = els.length - 1; + } + else if (opts.nextSlide >= els.length) { + if (opts.nowrap) return false; + opts.nextSlide = 0; + } + } + + var cb = opts.onPrevNextEvent || opts.prevNextClick; // prevNextClick is deprecated + if ($.isFunction(cb)) + cb(val > 0, opts.nextSlide, els[opts.nextSlide]); + go(els, opts, 1, moveForward); + return false; +} + +function buildPager(els, opts) { + var $p = $(opts.pager); + $.each(els, function(i,o) { + $.fn.cycle.createPagerAnchor(i,o,$p,els,opts); + }); + opts.updateActivePagerLink(opts.pager, opts.startingSlide, opts.activePagerClass); +} + +$.fn.cycle.createPagerAnchor = function(i, el, $p, els, opts) { + var a; + if ($.isFunction(opts.pagerAnchorBuilder)) { + a = opts.pagerAnchorBuilder(i,el); + debug('pagerAnchorBuilder('+i+', el) returned: ' + a); + } + else + a = ''+(i+1)+''; + + if (!a) + return; + var $a = $(a); + // don't reparent if anchor is in the dom + if ($a.parents('body').length === 0) { + var arr = []; + if ($p.length > 1) { + $p.each(function() { + var $clone = $a.clone(true); + $(this).append($clone); + arr.push($clone[0]); + }); + $a = $(arr); + } + else { + $a.appendTo($p); + } + } + + opts.pagerAnchors = opts.pagerAnchors || []; + opts.pagerAnchors.push($a); + + var pagerFn = function(e) { + e.preventDefault(); + opts.nextSlide = i; + var p = opts.$cont[0], timeout = p.cycleTimeout; + if (timeout) { + clearTimeout(timeout); + p.cycleTimeout = 0; + } + var cb = opts.onPagerEvent || opts.pagerClick; // pagerClick is deprecated + if ($.isFunction(cb)) + cb(opts.nextSlide, els[opts.nextSlide]); + go(els,opts,1,opts.currSlide < i); // trigger the trans +// return false; // <== allow bubble + }; + + if ( /mouseenter|mouseover/i.test(opts.pagerEvent) ) { + $a.hover(pagerFn, function(){/* no-op */} ); + } + else { + $a.bind(opts.pagerEvent, pagerFn); + } + + if ( ! /^click/.test(opts.pagerEvent) && !opts.allowPagerClickBubble) + $a.bind('click.cycle', function(){return false;}); // suppress click + + var cont = opts.$cont[0]; + var pauseFlag = false; // https://github.com/malsup/cycle/issues/44 + if (opts.pauseOnPagerHover) { + $a.hover( + function() { + pauseFlag = true; + cont.cyclePause++; + triggerPause(cont,true,true); + }, function() { + if (pauseFlag) + cont.cyclePause--; + triggerPause(cont,true,true); + } + ); + } +}; + +// helper fn to calculate the number of slides between the current and the next +$.fn.cycle.hopsFromLast = function(opts, fwd) { + var hops, l = opts.lastSlide, c = opts.currSlide; + if (fwd) + hops = c > l ? c - l : opts.slideCount - l; + else + hops = c < l ? l - c : l + opts.slideCount - c; + return hops; +}; + +// fix clearType problems in ie6 by setting an explicit bg color +// (otherwise text slides look horrible during a fade transition) +function clearTypeFix($slides) { + debug('applying clearType background-color hack'); + function hex(s) { + s = parseInt(s,10).toString(16); + return s.length < 2 ? '0'+s : s; + } + function getBg(e) { + for ( ; e && e.nodeName.toLowerCase() != 'html'; e = e.parentNode) { + var v = $.css(e,'background-color'); + if (v && v.indexOf('rgb') >= 0 ) { + var rgb = v.match(/\d+/g); + return '#'+ hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]); + } + if (v && v != 'transparent') + return v; + } + return '#ffffff'; + } + $slides.each(function() { $(this).css('background-color', getBg(this)); }); +} + +// reset common props before the next transition +$.fn.cycle.commonReset = function(curr,next,opts,w,h,rev) { + $(opts.elements).not(curr).hide(); + if (typeof opts.cssBefore.opacity == 'undefined') + opts.cssBefore.opacity = 1; + opts.cssBefore.display = 'block'; + if (opts.slideResize && w !== false && next.cycleW > 0) + opts.cssBefore.width = next.cycleW; + if (opts.slideResize && h !== false && next.cycleH > 0) + opts.cssBefore.height = next.cycleH; + opts.cssAfter = opts.cssAfter || {}; + opts.cssAfter.display = 'none'; + $(curr).css('zIndex',opts.slideCount + (rev === true ? 1 : 0)); + $(next).css('zIndex',opts.slideCount + (rev === true ? 0 : 1)); +}; + +// the actual fn for effecting a transition +$.fn.cycle.custom = function(curr, next, opts, cb, fwd, speedOverride) { + var $l = $(curr), $n = $(next); + var speedIn = opts.speedIn, speedOut = opts.speedOut, easeIn = opts.easeIn, easeOut = opts.easeOut; + $n.css(opts.cssBefore); + if (speedOverride) { + if (typeof speedOverride == 'number') + speedIn = speedOut = speedOverride; + else + speedIn = speedOut = 1; + easeIn = easeOut = null; + } + var fn = function() { + $n.animate(opts.animIn, speedIn, easeIn, function() { + cb(); + }); + }; + $l.animate(opts.animOut, speedOut, easeOut, function() { + $l.css(opts.cssAfter); + if (!opts.sync) + fn(); + }); + if (opts.sync) fn(); +}; + +// transition definitions - only fade is defined here, transition pack defines the rest +$.fn.cycle.transitions = { + fade: function($cont, $slides, opts) { + $slides.not(':eq('+opts.currSlide+')').css('opacity',0); + opts.before.push(function(curr,next,opts) { + $.fn.cycle.commonReset(curr,next,opts); + opts.cssBefore.opacity = 0; + }); + opts.animIn = { opacity: 1 }; + opts.animOut = { opacity: 0 }; + opts.cssBefore = { top: 0, left: 0 }; + } +}; + +$.fn.cycle.ver = function() { return ver; }; + +// override these globally if you like (they are all optional) +$.fn.cycle.defaults = { + activePagerClass: 'activeSlide', // class name used for the active pager link + after: null, // transition callback (scope set to element that was shown): function(currSlideElement, nextSlideElement, options, forwardFlag) + allowPagerClickBubble: false, // allows or prevents click event on pager anchors from bubbling + animIn: null, // properties that define how the slide animates in + animOut: null, // properties that define how the slide animates out + aspect: false, // preserve aspect ratio during fit resizing, cropping if necessary (must be used with fit option) + autostop: 0, // true to end slideshow after X transitions (where X == slide count) + autostopCount: 0, // number of transitions (optionally used with autostop to define X) + backwards: false, // true to start slideshow at last slide and move backwards through the stack + before: null, // transition callback (scope set to element to be shown): function(currSlideElement, nextSlideElement, options, forwardFlag) + center: null, // set to true to have cycle add top/left margin to each slide (use with width and height options) + cleartype: !$.support.opacity, // true if clearType corrections should be applied (for IE) + cleartypeNoBg: false, // set to true to disable extra cleartype fixing (leave false to force background color setting on slides) + containerResize: 1, // resize container to fit largest slide + containerResizeHeight: 0, // resize containers height to fit the largest slide but leave the width dynamic + continuous: 0, // true to start next transition immediately after current one completes + cssAfter: null, // properties that defined the state of the slide after transitioning out + cssBefore: null, // properties that define the initial state of the slide before transitioning in + delay: 0, // additional delay (in ms) for first transition (hint: can be negative) + easeIn: null, // easing for "in" transition + easeOut: null, // easing for "out" transition + easing: null, // easing method for both in and out transitions + end: null, // callback invoked when the slideshow terminates (use with autostop or nowrap options): function(options) + fastOnEvent: 0, // force fast transitions when triggered manually (via pager or prev/next); value == time in ms + fit: 0, // force slides to fit container + fx: 'fade', // name of transition effect (or comma separated names, ex: 'fade,scrollUp,shuffle') + fxFn: null, // function used to control the transition: function(currSlideElement, nextSlideElement, options, afterCalback, forwardFlag) + height: 'auto', // container height (if the 'fit' option is true, the slides will be set to this height as well) + manualTrump: true, // causes manual transition to stop an active transition instead of being ignored + metaAttr: 'cycle', // data- attribute that holds the option data for the slideshow + next: null, // element, jQuery object, or jQuery selector string for the element to use as event trigger for next slide + nowrap: 0, // true to prevent slideshow from wrapping + onPagerEvent: null, // callback fn for pager events: function(zeroBasedSlideIndex, slideElement) + onPrevNextEvent: null, // callback fn for prev/next events: function(isNext, zeroBasedSlideIndex, slideElement) + pager: null, // element, jQuery object, or jQuery selector string for the element to use as pager container + pagerAnchorBuilder: null, // callback fn for building anchor links: function(index, DOMelement) + pagerEvent: 'click.cycle', // name of event which drives the pager navigation + pause: 0, // true to enable "pause on hover" + pauseOnPagerHover: 0, // true to pause when hovering over pager link + prev: null, // element, jQuery object, or jQuery selector string for the element to use as event trigger for previous slide + prevNextEvent: 'click.cycle',// event which drives the manual transition to the previous or next slide + random: 0, // true for random, false for sequence (not applicable to shuffle fx) + randomizeEffects: 1, // valid when multiple effects are used; true to make the effect sequence random + requeueOnImageNotLoaded: true, // requeue the slideshow if any image slides are not yet loaded + requeueTimeout: 250, // ms delay for requeue + rev: 0, // causes animations to transition in reverse (for effects that support it such as scrollHorz/scrollVert/shuffle) + shuffle: null, // coords for shuffle animation, ex: { top:15, left: 200 } + skipInitializationCallbacks: false, // set to true to disable the first before/after callback that occurs prior to any transition + slideExpr: null, // expression for selecting slides (if something other than all children is required) + slideResize: 1, // force slide width/height to fixed size before every transition + speed: 1000, // speed of the transition (any valid fx speed value) + speedIn: null, // speed of the 'in' transition + speedOut: null, // speed of the 'out' transition + startingSlide: undefined,// zero-based index of the first slide to be displayed + sync: 1, // true if in/out transitions should occur simultaneously + timeout: 4000, // milliseconds between slide transitions (0 to disable auto advance) + timeoutFn: null, // callback for determining per-slide timeout value: function(currSlideElement, nextSlideElement, options, forwardFlag) + updateActivePagerLink: null,// callback fn invoked to update the active pager link (adds/removes activePagerClass style) + width: null // container width (if the 'fit' option is true, the slides will be set to this width as well) +}; + +})(jQuery); + + +/*! + * jQuery Cycle Plugin Transition Definitions + * This script is a plugin for the jQuery Cycle Plugin + * Examples and documentation at: http://malsup.com/jquery/cycle/ + * Copyright (c) 2007-2010 M. Alsup + * Version: 2.73 + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + */ +(function($) { +"use strict"; + +// +// These functions define slide initialization and properties for the named +// transitions. To save file size feel free to remove any of these that you +// don't need. +// +$.fn.cycle.transitions.none = function($cont, $slides, opts) { + opts.fxFn = function(curr,next,opts,after){ + $(next).show(); + $(curr).hide(); + after(); + }; +}; + +// not a cross-fade, fadeout only fades out the top slide +$.fn.cycle.transitions.fadeout = function($cont, $slides, opts) { + $slides.not(':eq('+opts.currSlide+')').css({ display: 'block', 'opacity': 1 }); + opts.before.push(function(curr,next,opts,w,h,rev) { + $(curr).css('zIndex',opts.slideCount + (rev !== true ? 1 : 0)); + $(next).css('zIndex',opts.slideCount + (rev !== true ? 0 : 1)); + }); + opts.animIn.opacity = 1; + opts.animOut.opacity = 0; + opts.cssBefore.opacity = 1; + opts.cssBefore.display = 'block'; + opts.cssAfter.zIndex = 0; +}; + +// scrollUp/Down/Left/Right +$.fn.cycle.transitions.scrollUp = function($cont, $slides, opts) { + $cont.css('overflow','hidden'); + opts.before.push($.fn.cycle.commonReset); + var h = $cont.height(); + opts.cssBefore.top = h; + opts.cssBefore.left = 0; + opts.cssFirst.top = 0; + opts.animIn.top = 0; + opts.animOut.top = -h; +}; +$.fn.cycle.transitions.scrollDown = function($cont, $slides, opts) { + $cont.css('overflow','hidden'); + opts.before.push($.fn.cycle.commonReset); + var h = $cont.height(); + opts.cssFirst.top = 0; + opts.cssBefore.top = -h; + opts.cssBefore.left = 0; + opts.animIn.top = 0; + opts.animOut.top = h; +}; +$.fn.cycle.transitions.scrollLeft = function($cont, $slides, opts) { + $cont.css('overflow','hidden'); + opts.before.push($.fn.cycle.commonReset); + var w = $cont.width(); + opts.cssFirst.left = 0; + opts.cssBefore.left = w; + opts.cssBefore.top = 0; + opts.animIn.left = 0; + opts.animOut.left = 0-w; +}; +$.fn.cycle.transitions.scrollRight = function($cont, $slides, opts) { + $cont.css('overflow','hidden'); + opts.before.push($.fn.cycle.commonReset); + var w = $cont.width(); + opts.cssFirst.left = 0; + opts.cssBefore.left = -w; + opts.cssBefore.top = 0; + opts.animIn.left = 0; + opts.animOut.left = w; +}; +$.fn.cycle.transitions.scrollHorz = function($cont, $slides, opts) { + $cont.css('overflow','hidden').width(); + opts.before.push(function(curr, next, opts, fwd) { + if (opts.rev) + fwd = !fwd; + $.fn.cycle.commonReset(curr,next,opts); + opts.cssBefore.left = fwd ? (next.cycleW-1) : (1-next.cycleW); + opts.animOut.left = fwd ? -curr.cycleW : curr.cycleW; + }); + opts.cssFirst.left = 0; + opts.cssBefore.top = 0; + opts.animIn.left = 0; + opts.animOut.top = 0; +}; +$.fn.cycle.transitions.scrollVert = function($cont, $slides, opts) { + $cont.css('overflow','hidden'); + opts.before.push(function(curr, next, opts, fwd) { + if (opts.rev) + fwd = !fwd; + $.fn.cycle.commonReset(curr,next,opts); + opts.cssBefore.top = fwd ? (1-next.cycleH) : (next.cycleH-1); + opts.animOut.top = fwd ? curr.cycleH : -curr.cycleH; + }); + opts.cssFirst.top = 0; + opts.cssBefore.left = 0; + opts.animIn.top = 0; + opts.animOut.left = 0; +}; + +// slideX/slideY +$.fn.cycle.transitions.slideX = function($cont, $slides, opts) { + opts.before.push(function(curr, next, opts) { + $(opts.elements).not(curr).hide(); + $.fn.cycle.commonReset(curr,next,opts,false,true); + opts.animIn.width = next.cycleW; + }); + opts.cssBefore.left = 0; + opts.cssBefore.top = 0; + opts.cssBefore.width = 0; + opts.animIn.width = 'show'; + opts.animOut.width = 0; +}; +$.fn.cycle.transitions.slideY = function($cont, $slides, opts) { + opts.before.push(function(curr, next, opts) { + $(opts.elements).not(curr).hide(); + $.fn.cycle.commonReset(curr,next,opts,true,false); + opts.animIn.height = next.cycleH; + }); + opts.cssBefore.left = 0; + opts.cssBefore.top = 0; + opts.cssBefore.height = 0; + opts.animIn.height = 'show'; + opts.animOut.height = 0; +}; + +// shuffle +$.fn.cycle.transitions.shuffle = function($cont, $slides, opts) { + var i, w = $cont.css('overflow', 'visible').width(); + $slides.css({left: 0, top: 0}); + opts.before.push(function(curr,next,opts) { + $.fn.cycle.commonReset(curr,next,opts,true,true,true); + }); + // only adjust speed once! + if (!opts.speedAdjusted) { + opts.speed = opts.speed / 2; // shuffle has 2 transitions + opts.speedAdjusted = true; + } + opts.random = 0; + opts.shuffle = opts.shuffle || {left:-w, top:15}; + opts.els = []; + for (i=0; i < $slides.length; i++) + opts.els.push($slides[i]); + + for (i=0; i < opts.currSlide; i++) + opts.els.push(opts.els.shift()); + + // custom transition fn (hat tip to Benjamin Sterling for this bit of sweetness!) + opts.fxFn = function(curr, next, opts, cb, fwd) { + if (opts.rev) + fwd = !fwd; + var $el = fwd ? $(curr) : $(next); + $(next).css(opts.cssBefore); + var count = opts.slideCount; + $el.animate(opts.shuffle, opts.speedIn, opts.easeIn, function() { + var hops = $.fn.cycle.hopsFromLast(opts, fwd); + for (var k=0; k < hops; k++) { + if (fwd) + opts.els.push(opts.els.shift()); + else + opts.els.unshift(opts.els.pop()); + } + if (fwd) { + for (var i=0, len=opts.els.length; i < len; i++) + $(opts.els[i]).css('z-index', len-i+count); + } + else { + var z = $(curr).css('z-index'); + $el.css('z-index', parseInt(z,10)+1+count); + } + $el.animate({left:0, top:0}, opts.speedOut, opts.easeOut, function() { + $(fwd ? this : curr).hide(); + if (cb) cb(); + }); + }); + }; + $.extend(opts.cssBefore, { display: 'block', opacity: 1, top: 0, left: 0 }); +}; + +// turnUp/Down/Left/Right +$.fn.cycle.transitions.turnUp = function($cont, $slides, opts) { + opts.before.push(function(curr, next, opts) { + $.fn.cycle.commonReset(curr,next,opts,true,false); + opts.cssBefore.top = next.cycleH; + opts.animIn.height = next.cycleH; + opts.animOut.width = next.cycleW; + }); + opts.cssFirst.top = 0; + opts.cssBefore.left = 0; + opts.cssBefore.height = 0; + opts.animIn.top = 0; + opts.animOut.height = 0; +}; +$.fn.cycle.transitions.turnDown = function($cont, $slides, opts) { + opts.before.push(function(curr, next, opts) { + $.fn.cycle.commonReset(curr,next,opts,true,false); + opts.animIn.height = next.cycleH; + opts.animOut.top = curr.cycleH; + }); + opts.cssFirst.top = 0; + opts.cssBefore.left = 0; + opts.cssBefore.top = 0; + opts.cssBefore.height = 0; + opts.animOut.height = 0; +}; +$.fn.cycle.transitions.turnLeft = function($cont, $slides, opts) { + opts.before.push(function(curr, next, opts) { + $.fn.cycle.commonReset(curr,next,opts,false,true); + opts.cssBefore.left = next.cycleW; + opts.animIn.width = next.cycleW; + }); + opts.cssBefore.top = 0; + opts.cssBefore.width = 0; + opts.animIn.left = 0; + opts.animOut.width = 0; +}; +$.fn.cycle.transitions.turnRight = function($cont, $slides, opts) { + opts.before.push(function(curr, next, opts) { + $.fn.cycle.commonReset(curr,next,opts,false,true); + opts.animIn.width = next.cycleW; + opts.animOut.left = curr.cycleW; + }); + $.extend(opts.cssBefore, { top: 0, left: 0, width: 0 }); + opts.animIn.left = 0; + opts.animOut.width = 0; +}; + +// zoom +$.fn.cycle.transitions.zoom = function($cont, $slides, opts) { + opts.before.push(function(curr, next, opts) { + $.fn.cycle.commonReset(curr,next,opts,false,false,true); + opts.cssBefore.top = next.cycleH/2; + opts.cssBefore.left = next.cycleW/2; + $.extend(opts.animIn, { top: 0, left: 0, width: next.cycleW, height: next.cycleH }); + $.extend(opts.animOut, { width: 0, height: 0, top: curr.cycleH/2, left: curr.cycleW/2 }); + }); + opts.cssFirst.top = 0; + opts.cssFirst.left = 0; + opts.cssBefore.width = 0; + opts.cssBefore.height = 0; +}; + +// fadeZoom +$.fn.cycle.transitions.fadeZoom = function($cont, $slides, opts) { + opts.before.push(function(curr, next, opts) { + $.fn.cycle.commonReset(curr,next,opts,false,false); + opts.cssBefore.left = next.cycleW/2; + opts.cssBefore.top = next.cycleH/2; + $.extend(opts.animIn, { top: 0, left: 0, width: next.cycleW, height: next.cycleH }); + }); + opts.cssBefore.width = 0; + opts.cssBefore.height = 0; + opts.animOut.opacity = 0; +}; + +// blindX +$.fn.cycle.transitions.blindX = function($cont, $slides, opts) { + var w = $cont.css('overflow','hidden').width(); + opts.before.push(function(curr, next, opts) { + $.fn.cycle.commonReset(curr,next,opts); + opts.animIn.width = next.cycleW; + opts.animOut.left = curr.cycleW; + }); + opts.cssBefore.left = w; + opts.cssBefore.top = 0; + opts.animIn.left = 0; + opts.animOut.left = w; +}; +// blindY +$.fn.cycle.transitions.blindY = function($cont, $slides, opts) { + var h = $cont.css('overflow','hidden').height(); + opts.before.push(function(curr, next, opts) { + $.fn.cycle.commonReset(curr,next,opts); + opts.animIn.height = next.cycleH; + opts.animOut.top = curr.cycleH; + }); + opts.cssBefore.top = h; + opts.cssBefore.left = 0; + opts.animIn.top = 0; + opts.animOut.top = h; +}; +// blindZ +$.fn.cycle.transitions.blindZ = function($cont, $slides, opts) { + var h = $cont.css('overflow','hidden').height(); + var w = $cont.width(); + opts.before.push(function(curr, next, opts) { + $.fn.cycle.commonReset(curr,next,opts); + opts.animIn.height = next.cycleH; + opts.animOut.top = curr.cycleH; + }); + opts.cssBefore.top = h; + opts.cssBefore.left = w; + opts.animIn.top = 0; + opts.animIn.left = 0; + opts.animOut.top = h; + opts.animOut.left = w; +}; + +// growX - grow horizontally from centered 0 width +$.fn.cycle.transitions.growX = function($cont, $slides, opts) { + opts.before.push(function(curr, next, opts) { + $.fn.cycle.commonReset(curr,next,opts,false,true); + opts.cssBefore.left = this.cycleW/2; + opts.animIn.left = 0; + opts.animIn.width = this.cycleW; + opts.animOut.left = 0; + }); + opts.cssBefore.top = 0; + opts.cssBefore.width = 0; +}; +// growY - grow vertically from centered 0 height +$.fn.cycle.transitions.growY = function($cont, $slides, opts) { + opts.before.push(function(curr, next, opts) { + $.fn.cycle.commonReset(curr,next,opts,true,false); + opts.cssBefore.top = this.cycleH/2; + opts.animIn.top = 0; + opts.animIn.height = this.cycleH; + opts.animOut.top = 0; + }); + opts.cssBefore.height = 0; + opts.cssBefore.left = 0; +}; + +// curtainX - squeeze in both edges horizontally +$.fn.cycle.transitions.curtainX = function($cont, $slides, opts) { + opts.before.push(function(curr, next, opts) { + $.fn.cycle.commonReset(curr,next,opts,false,true,true); + opts.cssBefore.left = next.cycleW/2; + opts.animIn.left = 0; + opts.animIn.width = this.cycleW; + opts.animOut.left = curr.cycleW/2; + opts.animOut.width = 0; + }); + opts.cssBefore.top = 0; + opts.cssBefore.width = 0; +}; +// curtainY - squeeze in both edges vertically +$.fn.cycle.transitions.curtainY = function($cont, $slides, opts) { + opts.before.push(function(curr, next, opts) { + $.fn.cycle.commonReset(curr,next,opts,true,false,true); + opts.cssBefore.top = next.cycleH/2; + opts.animIn.top = 0; + opts.animIn.height = next.cycleH; + opts.animOut.top = curr.cycleH/2; + opts.animOut.height = 0; + }); + opts.cssBefore.height = 0; + opts.cssBefore.left = 0; +}; + +// cover - curr slide covered by next slide +$.fn.cycle.transitions.cover = function($cont, $slides, opts) { + var d = opts.direction || 'left'; + var w = $cont.css('overflow','hidden').width(); + var h = $cont.height(); + opts.before.push(function(curr, next, opts) { + $.fn.cycle.commonReset(curr,next,opts); + opts.cssAfter.display = ''; + if (d == 'right') + opts.cssBefore.left = -w; + else if (d == 'up') + opts.cssBefore.top = h; + else if (d == 'down') + opts.cssBefore.top = -h; + else + opts.cssBefore.left = w; + }); + opts.animIn.left = 0; + opts.animIn.top = 0; + opts.cssBefore.top = 0; + opts.cssBefore.left = 0; +}; + +// uncover - curr slide moves off next slide +$.fn.cycle.transitions.uncover = function($cont, $slides, opts) { + var d = opts.direction || 'left'; + var w = $cont.css('overflow','hidden').width(); + var h = $cont.height(); + opts.before.push(function(curr, next, opts) { + $.fn.cycle.commonReset(curr,next,opts,true,true,true); + if (d == 'right') + opts.animOut.left = w; + else if (d == 'up') + opts.animOut.top = -h; + else if (d == 'down') + opts.animOut.top = h; + else + opts.animOut.left = -w; + }); + opts.animIn.left = 0; + opts.animIn.top = 0; + opts.cssBefore.top = 0; + opts.cssBefore.left = 0; +}; + +// toss - move top slide and fade away +$.fn.cycle.transitions.toss = function($cont, $slides, opts) { + var w = $cont.css('overflow','visible').width(); + var h = $cont.height(); + opts.before.push(function(curr, next, opts) { + $.fn.cycle.commonReset(curr,next,opts,true,true,true); + // provide default toss settings if animOut not provided + if (!opts.animOut.left && !opts.animOut.top) + $.extend(opts.animOut, { left: w*2, top: -h/2, opacity: 0 }); + else + opts.animOut.opacity = 0; + }); + opts.cssBefore.left = 0; + opts.cssBefore.top = 0; + opts.animIn.left = 0; +}; + +// wipe - clip animation +$.fn.cycle.transitions.wipe = function($cont, $slides, opts) { + var w = $cont.css('overflow','hidden').width(); + var h = $cont.height(); + opts.cssBefore = opts.cssBefore || {}; + var clip; + if (opts.clip) { + if (/l2r/.test(opts.clip)) + clip = 'rect(0px 0px '+h+'px 0px)'; + else if (/r2l/.test(opts.clip)) + clip = 'rect(0px '+w+'px '+h+'px '+w+'px)'; + else if (/t2b/.test(opts.clip)) + clip = 'rect(0px '+w+'px 0px 0px)'; + else if (/b2t/.test(opts.clip)) + clip = 'rect('+h+'px '+w+'px '+h+'px 0px)'; + else if (/zoom/.test(opts.clip)) { + var top = parseInt(h/2,10); + var left = parseInt(w/2,10); + clip = 'rect('+top+'px '+left+'px '+top+'px '+left+'px)'; + } + } + + opts.cssBefore.clip = opts.cssBefore.clip || clip || 'rect(0px 0px 0px 0px)'; + + var d = opts.cssBefore.clip.match(/(\d+)/g); + var t = parseInt(d[0],10), r = parseInt(d[1],10), b = parseInt(d[2],10), l = parseInt(d[3],10); + + opts.before.push(function(curr, next, opts) { + if (curr == next) return; + var $curr = $(curr), $next = $(next); + $.fn.cycle.commonReset(curr,next,opts,true,true,false); + opts.cssAfter.display = 'block'; + + var step = 1, count = parseInt((opts.speedIn / 13),10) - 1; + (function f() { + var tt = t ? t - parseInt(step * (t/count),10) : 0; + var ll = l ? l - parseInt(step * (l/count),10) : 0; + var bb = b < h ? b + parseInt(step * ((h-b)/count || 1),10) : h; + var rr = r < w ? r + parseInt(step * ((w-r)/count || 1),10) : w; + $next.css({ clip: 'rect('+tt+'px '+rr+'px '+bb+'px '+ll+'px)' }); + (step++ <= count) ? setTimeout(f, 13) : $curr.css('display', 'none'); + })(); + }); + $.extend(opts.cssBefore, { display: 'block', opacity: 1, top: 0, left: 0 }); + opts.animIn = { left: 0 }; + opts.animOut = { left: 0 }; +}; + +})(jQuery); \ No newline at end of file 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 cd5f7238..a1757aa5 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 @@ -45,7 +45,7 @@ var galleryAPI = function(){ }else{ var cids = "all"; } - $.getJSON("panel/gallery/front_end/get_albums",{"cid":cids,"tid":tids,"inner":true},function(categories){ + $.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') %>") diff --git a/vendor/built_in_modules/gallery/app/assets/stylesheets/gallery.css b/vendor/built_in_modules/gallery/app/assets/stylesheets/gallery.css index 0b5bdc34..86a189fd 100755 --- a/vendor/built_in_modules/gallery/app/assets/stylesheets/gallery.css +++ b/vendor/built_in_modules/gallery/app/assets/stylesheets/gallery.css @@ -90,7 +90,7 @@ -moz-transition: all, 0.3s ease; } .rgalbum .albumname { - font-size: 15px; + font-size: 18px; padding: 6px 0; display: block; transition: background 0.3s ease; @@ -105,14 +105,14 @@ .rgp .rgtitle { margin: 0 0 10px 0; } /* Photo Edit */ -.albumname_edit label, .albumname_edit .rginput, .rgphoto_edit img, .rgphoto_edit .rginput { float: left; } +.albumname_edit label, .albumname_edit .rginput, .rgphoto_edit > a, .rgphoto_edit .rginput { float: left; } .rgphoto_edit, .albumname_edit { clear: both; overflow: hidden; margin-bottom: 10px; } .albumname_edit label { - width: 120px; + width: 150px; margin: 0 10px 0 0; text-align: right; padding: 0; @@ -398,7 +398,7 @@ .rgih26 { width: 208px; } .rgih26 span { } -.rgih26 input { width: 376px; } +.rgih26 input { width: 356px; } .rgih26.focus { } .rgih26.focus span { } .rgih68 { width: 396px; } @@ -408,7 +408,7 @@ .rgih68.focus span { } .rgih98 { width: 396px; } .rgih98 span { } -.rgih98 textarea { width: 376px; height: 80px; } +.rgih98 textarea { width: 356px; height: 110px; } .rgih98.focus { } .rgih98.focus span { } @@ -476,7 +476,7 @@ .tag_search { position: absolute; left: -1px; - bottom: -32px; + bottom: -30px; width: 200px; height: 32px; background-color: #f5f5f5; @@ -552,3 +552,6 @@ padding-left: 12px; padding-right: 12px; } +.o_album_edit form { + margin-left: 8px; +} diff --git a/vendor/built_in_modules/gallery/app/assets/stylesheets/widget_gallery.css b/vendor/built_in_modules/gallery/app/assets/stylesheets/widget_gallery.css new file mode 100755 index 00000000..df7bf2c2 --- /dev/null +++ b/vendor/built_in_modules/gallery/app/assets/stylesheets/widget_gallery.css @@ -0,0 +1,66 @@ +.widget_gallery { + margin-bottom: 20px; +} +.widget_gallery:after { + display: table; + width: 100%; + content: ''; +} +.widget_gallery ul { + list-style: none; + margin: 0; + padding: 0; +} +.widget_gallery li a { + display: block; +} +.widget_gallery li a img { + height: auto; + display: block; +} + +/* widget 1 */ +.w1 ul { + margin: 0 -1%; +} +.w1 li { + float: left; + margin: 1%; +} +.w1.c2 li { width: 48%; } +.w1.c3 li { width: 31.3333%; } +.w1.c4 li { width: 23%; } +.w1.c5 li { width: 18%; } +.w1.c6 li { width: 14.6666%; } +.w1 li a:hover { + box-shadow: 0 0 20px rgba(0,0,0,0.9); + outline: solid 4px #429DFF; + position: relative; +} +.w1 li a img { + width: 100%; +} + +/* widget 2 */ +.w2 li { + width: 100%; +} +.w2 li a img { + width: 100%; + height: auto; +} +.w2 li a { + position: relative; + overflow: hidden; + color: #fff; + text-transform: capitalize; +} +.w2 li a .desc { + position: absolute; + bottom: -60px; + opacity: 0; + display: block; + width: 100%; + padding: 5%; + background-color: rgba(8, 166, 255, 0.8); +} \ No newline at end of file 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 bf32b693..2499d08f 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 @@ -1,7 +1,7 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController include AdminHelper - before_filter :force_order_for_user, :except => [:index,:get_album_json] + before_filter :force_order_for_user, :except => [:index,:get_album_json,:get_imgs_json] def index if is_manager? || is_admin? || is_sub_manager? @@ -119,38 +119,42 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController albums.each do |album| tag_names = Array.new - all_image = Array.new - - images = album.gallery_images.all - images.each do |image| - tags = Array.new - - image.tag_ids.each do |tag| - tags << GalleryTag.find(tag)[I18n.locale] - end - - all_image << { - image_title: image.title, - image_description: image.description, - image_file: { url: "http://#{request.host_with_port+image.file.url}", - thumb: "http://#{request.host_with_port+image.file.thumb.to_s}"}, - image_tag_names: tags} - end album.tag_ids.each do |tag| tag_names << GalleryTag.find(tag)[I18n.locale] end output << { - album_cover_file: "http://#{request.host_with_port+album.cover_path}", - album_name: album.name, - album_tag_names: tag_names, - images: all_image + album_cover_file: "http://#{request.host_with_port}#{album.cover_path}", + album_name: album.name, + album_tag_names: tag_names, + album_link:"http://#{request.host_with_port}#{panel_gallery_back_end_album_get_imgs_json_path(album)}" } end - #render :json=>{:images => @output, - # :tag_names => @tag_names}.to_json + render :json=>JSON.pretty_generate(output) + end + + def get_imgs_json + album = GalleryAlbum.find(params[:album_id]) + images = album.gallery_images.all + output = Array.new + + images.each do |image| + tags = Array.new + + image.tag_ids.each do |tag| + tags << GalleryTag.find(tag)[I18n.locale] + end + + output << { + image_title: image.title, + image_description: image.description, + image_file: { url: "http://#{request.host_with_port}#{image.file.url}", + thumb: "http://#{request.host_with_port}#{image.file.thumb.to_s}"}, + image_tag_names: tags} + end + render :json=>JSON.pretty_generate(output) end diff --git a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/widget/albums_controller.rb b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/widget/albums_controller.rb new file mode 100644 index 00000000..5126a16d --- /dev/null +++ b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/widget/albums_controller.rb @@ -0,0 +1,23 @@ +class Panel::Gallery::Widget::AlbumsController < OrbitWidgetController + + def widget1 + @settings = {"vertical"=>2,"horizontal"=>6} + @class = "c" + @settings["horizontal"].to_s + @total = @settings["vertical"] * @settings["horizontal"] + @rnd = Random.new + @images = [] + for i in 0..@total-1 + @sn = @rnd.rand(0...GalleryImage.count) + if @sn < 0 + @sn = @sn * -1 + end + image = GalleryImage.skip(@sn).limit(1).first + values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url} + @images << values + end + end + def widget2 + + end + +end diff --git a/vendor/built_in_modules/gallery/app/views/panel/gallery/widget/albums/widget1.html.erb b/vendor/built_in_modules/gallery/app/views/panel/gallery/widget/albums/widget1.html.erb new file mode 100644 index 00000000..70ae5363 --- /dev/null +++ b/vendor/built_in_modules/gallery/app/views/panel/gallery/widget/albums/widget1.html.erb @@ -0,0 +1,20 @@ +<%= stylesheet_link_tag "widget_gallery" %> +<%# content_for :page_specific_javascript do %> + <%#= javascript_include_tag "cycle" %> +<%# end %> +
    +

    Gallery Widget

    +

    WIDGET 1

    + +
    \ 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 8795594b..d9acd934 100644 --- a/vendor/built_in_modules/gallery/config/routes.rb +++ b/vendor/built_in_modules/gallery/config/routes.rb @@ -1,55 +1,64 @@ Rails.application.routes.draw do - namespace :panel do - namespace :gallery do - namespace :back_end do - match "get_albums" => "albums#get_albums" - match "upload_image" => "albums#upload_image" - match "save_tags" => "tags#save_tags" - match "albums/save_tags" => "tags#save_tags" - resources :albums do - match "set_cover" => "albums#set_cover" - match "imgs" => "albums#imgs" - match "upload_panel" => "albums#upload_panel" - match "images_tags" => "albums#images_tags" + + namespace :panel do + namespace :gallery do + namespace :back_end do + match "get_albums" => "albums#get_albums" + match "upload_image" => "albums#upload_image" + match "save_tags" => "tags#save_tags" + match "albums/save_tags" => "tags#save_tags" + + resources :albums do + match "set_cover" => "albums#set_cover" + match "imgs" => "albums#imgs" + match "upload_panel" => "albums#upload_panel" + match "images_tags" => "albums#images_tags" + match "get_imgs_json" => "albums#get_imgs_json" + collection do get "get_album_json" end - end + end - match "album_images/#!/:id" => "album_images#show" - - resources :album_images + match "album_images/#!/:id" => "album_images#show" + + resources :album_images resources :gallery_categories resources :tags - - end - namespace :front_end do - match "get_albums" => "albums#get_albums" - # match "orbit_galleries" => "orbit_galleries#index" - # match "gallery_category_save" => "orbit_galleries#new_category" - # match "categorylist" => "orbit_galleries#categorylist" - # match "gallery_category_delete" => "orbit_galleries#gallery_category_delete" - # match "add_album" => "orbit_galleries#add_album" - # match "create_album" => "orbit_galleries#create_album" - # match "get_albums" => "orbit_galleries#get_albums" - # match "upload_image" => "orbit_galleries#upload_image" - # match "upload_panel" => "orbit_galleries#upload_panel" - # match "get_images" => "orbit_galleries#get_images" - # match "theater" => "orbit_galleries#theater" - # match "delete_album" => "orbit_galleries#delete_album" - # match "edit_album" => "orbit_galleries#edit_album" - # match "set_cover" => "orbit_galleries#set_cover" - # match "delete_images" => "orbit_galleries#delete_images" - # match "update_album" => "orbit_galleries#update_album" - # match "save_tags" => "orbit_galleries#save_tags" - resources :albums do - member do - get "imgs" - get "theater" - end - end - resources :album_images - end - end - end + end + + namespace :front_end do + match "orbit_galleries" => "orbit_galleries#index" + match "get_albums" => "albums#get_albums" + # match "orbit_galleries" => "orbit_galleries#index" + # match "gallery_category_save" => "orbit_galleries#new_category" + # match "categorylist" => "orbit_galleries#categorylist" + # match "gallery_category_delete" => "orbit_galleries#gallery_category_delete" + # match "add_album" => "orbit_galleries#add_album" + # match "create_album" => "orbit_galleries#create_album" + # match "get_albums" => "orbit_galleries#get_albums" + # match "upload_image" => "orbit_galleries#upload_image" + # match "upload_panel" => "orbit_galleries#upload_panel" + # match "get_images" => "orbit_galleries#get_images" + # match "theater" => "orbit_galleries#theater" + # match "delete_album" => "orbit_galleries#delete_album" + # match "edit_album" => "orbit_galleries#edit_album" + # match "set_cover" => "orbit_galleries#set_cover" + # match "delete_images" => "orbit_galleries#delete_images" + # match "update_album" => "orbit_galleries#update_album" + # match "save_tags" => "orbit_galleries#save_tags" + resources :albums do + member do + get "imgs" + get "theater" + end + end + resources :album_images + end + + namespace :widget do + match "widget1" => "albums#widget1" + end + end + end end diff --git a/vendor/built_in_modules/gprs/app/controllers/panel/gprs/back_end/locations_controller.rb b/vendor/built_in_modules/gprs/app/controllers/panel/gprs/back_end/locations_controller.rb index 884e5d13..8609cce1 100644 --- a/vendor/built_in_modules/gprs/app/controllers/panel/gprs/back_end/locations_controller.rb +++ b/vendor/built_in_modules/gprs/app/controllers/panel/gprs/back_end/locations_controller.rb @@ -59,8 +59,8 @@ class Panel::Gprs::BackEnd::LocationsController < OrbitBackendController @data = Array.new locations.each do |location| - picurl = "http://#{request.host_with_port + location.file.url}", - thumburl = "http://#{request.host_with_port + location.file.thumb.url}" + picurl = location.file.blank? ? '' : "http://#{request.host_with_port + location.file.url}" + thumburl = location.file.blank? ? '' : "http://#{request.host_with_port + location.file.thumb.url}" @data << { name: location.name, pic_url: picurl, thumb_url: thumburl, diff --git a/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/index.html.erb b/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/index.html.erb index 6731688d..eb8b0485 100644 --- a/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/index.html.erb +++ b/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/index.html.erb @@ -13,7 +13,7 @@ <% @locations.each do |location| %> - + diff --git a/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_bulletins_controller.rb b/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_bulletins_controller.rb index ff3ce975..8d34e2b3 100644 --- a/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_bulletins_controller.rb +++ b/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_bulletins_controller.rb @@ -56,7 +56,7 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController @news_bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered("news_bulletin",:news_bulletin_category_id.in => @news_bulletin_category_ids) : get_viewable("news_bulletin",:news_bulletin_category_id.in => @news_bulletin_category_ids) - + @news_bulletin_link = NewsBulletinLink.new @link_url = panel_news_back_end_news_bulletins_path diff --git a/vendor/built_in_modules/news/app/helpers/panel/news/back_end/news_bulletins_helper.rb b/vendor/built_in_modules/news/app/helpers/panel/news/back_end/news_bulletins_helper.rb index 2ad6f7f9..aba740c6 100644 --- a/vendor/built_in_modules/news/app/helpers/panel/news/back_end/news_bulletins_helper.rb +++ b/vendor/built_in_modules/news/app/helpers/panel/news/back_end/news_bulletins_helper.rb @@ -17,7 +17,7 @@ module Panel::News::BackEnd::NewsBulletinsHelper end def news_show_delete_link(news_bulletin) - by_news_bulletin = (news_bulletin.create_user_id == current_user.id) + by_news_bulletin = current_user.nil? ? false : (news_bulletin.create_user_id == current_user.id) by_user = (is_manager? or is_admin?) by_news_bulletin or by_user end diff --git a/vendor/built_in_modules/personal_journal/app/controllers/panel/personal_journal/back_end/writing_journals_controller.rb b/vendor/built_in_modules/personal_journal/app/controllers/panel/personal_journal/back_end/writing_journals_controller.rb index b9e250da..27e7e53d 100644 --- a/vendor/built_in_modules/personal_journal/app/controllers/panel/personal_journal/back_end/writing_journals_controller.rb +++ b/vendor/built_in_modules/personal_journal/app/controllers/panel/personal_journal/back_end/writing_journals_controller.rb @@ -229,7 +229,7 @@ class Panel::PersonalJournal::BackEnd::WritingJournalsController < OrbitBackendC if @writing_journal.save if params[:writing_journal][:user_id] - format.html { redirect_to(admin_users_new_interface_url(:id=>params[:writing_journal][:user_id],:show_plugin_profile=>Journal)) } + format.html { redirect_to(admin_users_new_interface_url(:id=>params[:writing_journal][:user_id],:show_plugin_profile=>'Journal')) } else format.html { redirect_to(panel_personal_journal_back_end_writing_journals_url) } end
    <%= image_tag(location.file, alt: location.file, size: "50x50" )%><%= image_tag(location.file, alt: location.file, size: "50x50" ) if !location.file.blank? %> <%= location.name%> <%= location.longitude%> <%= location.latitude%>