diff --git a/app/assets/javascripts/admin/ad_banners.js b/app/assets/javascripts/admin/ad_banners.js index 4ad16d1b5..6ddfdd3aa 100644 --- a/app/assets/javascripts/admin/ad_banners.js +++ b/app/assets/javascripts/admin/ad_banners.js @@ -1,5 +1,3 @@ -//= require lib/arrow-on-list-edit - $(function() { $.pageslide.closeCallback(function(pageslide, item) { $("tr").removeClass("active"); @@ -8,14 +6,16 @@ $(function() { $.pageslide.loadComplete(function(pageslide, item) { $("tr").removeClass("active"); item.closest('tr').addClass('active'); - setSlideshow(pageslide.find('.preview'), item.data()); if(item.data('id') == 'new') { + resetForm(); pageslide.find('form').attr('action', '/admin/ad_banners/'); pageslide.find('form').attr('method', 'post'); } else { - pageslide.find('form').attr('action', '/admin/ad_banners/' + item.data('id')); + setForm(item.data('form')); + pageslide.find('form').attr('action', '/admin/ad_banners/' + item.data('id')); pageslide.find('form').attr('method', 'put'); } + setSlideshow(pageslide.find('.preview'), item.data()); }); }) \ No newline at end of file diff --git a/app/assets/javascripts/admin/categories.js b/app/assets/javascripts/admin/categories.js index 1e5958c7d..542501536 100644 --- a/app/assets/javascripts/admin/categories.js +++ b/app/assets/javascripts/admin/categories.js @@ -1 +1,19 @@ -//= require lib/arrow-on-list-edit \ No newline at end of file +$(function() { + $.pageslide.closeCallback(function(pageslide, item) { + $("tr").removeClass("active"); + }); + $.pageslide.loadComplete(function(pageslide, item) { + $("tr").removeClass("active"); + item.closest('tr').addClass('active'); + if(item.data('id') == 'new') { + resetForm(); + pageslide.find('form').attr('action', '/admin/module_apps/' + item.data('module') + '/categories/'); + pageslide.find('form').attr('method', 'post'); + } + else { + setForm(item.data('form')); + pageslide.find('form').attr('action', '/admin/module_apps/' + item.data('module') + '/categories/' + item.data('id')); + pageslide.find('form').attr('method', 'put'); + } + }); +}) \ No newline at end of file diff --git a/app/assets/javascripts/admin/module_tags.js b/app/assets/javascripts/admin/module_tags.js index fd85a18e2..ac12cb182 100644 --- a/app/assets/javascripts/admin/module_tags.js +++ b/app/assets/javascripts/admin/module_tags.js @@ -1 +1,18 @@ -//= require admin/tags \ No newline at end of file +//= require lib/tags + +$(function() { + $.pageslide.closeCallback(function(pageslide, item) { + $('.filter-item').removeClass("active"); + }); + $.pageslide.loadComplete(function(pageslide, item) { + $('.filter-item').removeClass("active"); + item.closest('li').addClass('active'); + if(item.hasClass('btn')) { + addTagsTab(); + $('#filter-default-tag').fastLiveFilter('.add-default-tags-list', '.filter-item', '.tag'); + $('.tags-groups').cardCheck({ + item: '.card', + }); + }; + }); +}) \ No newline at end of file diff --git a/app/assets/javascripts/admin/tags.js b/app/assets/javascripts/admin/tags.js index 6356444a6..540b5c2ec 100644 --- a/app/assets/javascripts/admin/tags.js +++ b/app/assets/javascripts/admin/tags.js @@ -1 +1,21 @@ -//= require lib/tags \ No newline at end of file +//= require lib/tags + +$(function() { + $.pageslide.closeCallback(function(pageslide, item) { + $('.filter-item').removeClass("active"); + }); + $.pageslide.loadComplete(function(pageslide, item) { + $('.filter-item').removeClass("active"); + item.closest('li').addClass('active'); + if(item.data('id') == 'new') { + resetForm(); + pageslide.find('form').attr('action', '/admin/tags/'); + pageslide.find('form').attr('method', 'post'); + } + else { + setForm(item.data('form')); + pageslide.find('form').attr('action', '/admin/tags/' + item.data('id')); + pageslide.find('form').attr('method', 'put'); + } + }); +}) \ No newline at end of file diff --git a/app/assets/javascripts/basic/orbit_js_1.0.1.js b/app/assets/javascripts/basic/orbit_js_1.0.1.js index 2094f044d..ace3de4b8 100644 --- a/app/assets/javascripts/basic/orbit_js_1.0.1.js +++ b/app/assets/javascripts/basic/orbit_js_1.0.1.js @@ -540,7 +540,7 @@ function changeStatusHidden() { // Document Ready $(function() { new ini(); - $('.delete').on('click', function() { + $('#main-wrap').on('click', '.delete', function() { api.modal($(this).attr('rel')); }) initialState(); diff --git a/app/assets/javascripts/lib/ad_banner/banner_preview.js b/app/assets/javascripts/lib/ad_banner/banner_preview.js index 3491e0ce7..2376b53ce 100644 --- a/app/assets/javascripts/lib/ad_banner/banner_preview.js +++ b/app/assets/javascripts/lib/ad_banner/banner_preview.js @@ -8,26 +8,11 @@ function slideshow (element, bannerEffect, bannerTime, bannerSpeed) { }); }; function setSlideshow(element, data) { - bannerName = data.name; - bannerEffect = data.fx; - bannerTime = data.time; - bannerSpeed = data.speed; - bannerW = data.w; - bannerH = data.h; - - $("#pageslide #bannerName").attr("value", bannerName); - $("#pageslide #timeout").attr("value", bannerTime); - $("#pageslide #speed").attr("value", bannerSpeed); - $("#pageslide #banner_width").attr("value", bannerW); - $("#pageslide #banner_height").attr("value", bannerH); - $("#pageslide .ad_banner_ad_fx option").each(function(i) { - if($(this).attr("value") == bannerEffect) { - this.selected = true; - $(this).hasClass('notIE') ? $('.suckIE').show() : $('.suckIE').hide(); - } + $("#pageslide .ad_banner_ad_fx").children('option:selected').each(function(index, el) { + $(this).val() == 'flipHorz' || $(this).val() == 'flipVert' ? $('.suckIE').show() : $('.suckIE').hide(); }); element.cycle('destroy'); - slideshow(element, bannerEffect, 2000, 1000); + slideshow(element, data['fx'], 2000, 1000); } function preview() { diff --git a/app/assets/javascripts/lib/arrow-on-list-edit.js b/app/assets/javascripts/lib/arrow-on-list-edit.js deleted file mode 100644 index 19ed8cb3b..000000000 --- a/app/assets/javascripts/lib/arrow-on-list-edit.js +++ /dev/null @@ -1,9 +0,0 @@ -$(function() { - $.pageslide.closeCallback(function(pageslide, item) { - $("tr").removeClass("active"); - }); - $.pageslide.loadComplete(function(pageslide, item) { - $("tr").removeClass("active"); - item.closest('tr').addClass('active'); - }); -}) \ No newline at end of file diff --git a/app/assets/javascripts/lib/pageslide.js b/app/assets/javascripts/lib/pageslide.js index c48858f9a..bb96f3601 100644 --- a/app/assets/javascripts/lib/pageslide.js +++ b/app/assets/javascripts/lib/pageslide.js @@ -323,4 +323,32 @@ $.pageslide.close(); } }); -}(window.jQuery); \ No newline at end of file +}(window.jQuery); + +function setForm(data) { + $.each(data, function(key, value) { + switch($("#pageslide form #" + key).prop("tagName")) + { + case "INPUT": + $("#pageslide form #" + key).val(value); + break; + case "SELECT": + $("#pageslide form #" + key).val(value); + break; + } + }); +} + +function resetForm() { + $("#pageslide form").find("input[type=text], input[type=number], textarea") + .val("") + .end() + .find("select") + .prop('selectedIndex', 0) + .end() + .find("input[type=checkbox]") + .prop('checked', false) + .end() + .find("input[type=radio]") + .prop('checked', false); +} \ No newline at end of file diff --git a/app/assets/javascripts/lib/tags.js.erb b/app/assets/javascripts/lib/tags.js.erb index 98d5e3f9c..92593a562 100644 --- a/app/assets/javascripts/lib/tags.js.erb +++ b/app/assets/javascripts/lib/tags.js.erb @@ -197,7 +197,6 @@ function mergerTags() { } $(function() { if($('.default-tags').length) { - // checkTagsQuantity(); checkedLength(); $('#tags-merger').on('hidden', function () { $(this).find('.filter-item').remove(); @@ -205,18 +204,4 @@ $(function() { } else { checkedLength(); }; - $.pageslide.closeCallback(function(pageslide, item) { - $('.filter-item').removeClass("active"); - }); - $.pageslide.loadComplete(function(pageslide, item) { - $('.filter-item').removeClass("active"); - item.closest('li').addClass('active'); - if(item.hasClass('btn')) { - addTagsTab(); - $('#filter-default-tag').fastLiveFilter('.add-default-tags-list', '.filter-item', '.tag'); - $('.tags-groups').cardCheck({ - item: '.card', - }); - }; - }); }); diff --git a/app/controllers/admin/categories_controller.rb b/app/controllers/admin/categories_controller.rb index 8218fbcb4..b6a5ca13d 100644 --- a/app/controllers/admin/categories_controller.rb +++ b/app/controllers/admin/categories_controller.rb @@ -31,7 +31,7 @@ class Admin::CategoriesController < OrbitBackendController def update @category = Category.find(params[:id]) if @category.update_attributes(params[:category]) - redirect_to admin_module_app_categories_url(@module_app_id) + redirect_to admin_module_app_categories_url(@module_app_id), :status => 303 else flash.now[:error] = t('update.error.category') render action: :edit diff --git a/app/controllers/admin/tags_controller.rb b/app/controllers/admin/tags_controller.rb index 768e8a3c9..acbe7c39e 100644 --- a/app/controllers/admin/tags_controller.rb +++ b/app/controllers/admin/tags_controller.rb @@ -33,7 +33,7 @@ class Admin::TagsController < OrbitBackendController def update @tag = ModuleTag.find(params[:id]) if @tag.update_attributes(params[:module_tag]) - redirect_to action: :index + redirect_to action: :index, :status => 303 else flash.now[:error] = t('update.error.tag') render :action => "edit" diff --git a/app/views/admin/ad_banners/_form.html.erb b/app/views/admin/ad_banners/_form.html.erb index 730f9bccf..2b99bd1dc 100644 --- a/app/views/admin/ad_banners/_form.html.erb +++ b/app/views/admin/ad_banners/_form.html.erb @@ -2,7 +2,7 @@ <%= f.error_messages %> <%= f.label :title, t('ad_banner.banner_name') %> -<%= f.text_field :title, class: 'input-large', placeholder: t('ad_banner.banner_name'), id: 'bannerName' %> +<%= f.text_field :title, class: 'input-large', placeholder: t('ad_banner.banner_name'), id: 'name' %> <%= t('ad_banner.name_only_english') %> <%= f.label :timeout, t('ad_banner.transition_interval') %> @@ -15,12 +15,12 @@ <%= f.label :size, t('ad_banner.size') %> -<%= f.number_field :width, in: 10..1000, step: 10, class: 'input-mini', onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;", id: 'banner_width' %> +<%= f.number_field :width, in: 10..1000, step: 10, class: 'input-mini', onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;", id: 'width' %> -<%= f.number_field :height, in: 10..1000, step: 10, class: 'input-mini', onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;", id: 'banner_height' %> +<%= f.number_field :height, in: 10..1000, step: 10, class: 'input-mini', onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;", id: 'height' %> <%= f.label :ad_fx, t('ad_banner.effect') %> -<%= f.select :ad_fx, AdBanner::FX_TYPES, {}, {class: 'ad_banner_ad_fx'} %> +<%= f.select :ad_fx, AdBanner::FX_TYPES, {}, {class: 'ad_banner_ad_fx', id: 'ad_fx'} %>