Add setForm and resetForm to pageslide.js
Category, AdBanner and Tag are using js to load the values in the form
This commit is contained in:
parent
8e168b0fe1
commit
f9f2232259
|
@ -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());
|
||||
});
|
||||
})
|
|
@ -1 +1,19 @@
|
|||
//= require lib/arrow-on-list-edit
|
||||
$(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');
|
||||
}
|
||||
});
|
||||
})
|
|
@ -1 +1,18 @@
|
|||
//= require admin/tags
|
||||
//= 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',
|
||||
});
|
||||
};
|
||||
});
|
||||
})
|
|
@ -1 +1,21 @@
|
|||
//= 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');
|
||||
}
|
||||
});
|
||||
})
|
|
@ -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();
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
})
|
|
@ -324,3 +324,31 @@
|
|||
}
|
||||
});
|
||||
}(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);
|
||||
}
|
|
@ -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',
|
||||
});
|
||||
};
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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' %>
|
||||
<span class="help-block"><%= t('ad_banner.name_only_english') %></span>
|
||||
|
||||
<%= f.label :timeout, t('ad_banner.transition_interval') %>
|
||||
|
@ -15,12 +15,12 @@
|
|||
|
||||
<%= f.label :size, t('ad_banner.size') %>
|
||||
<span class="banner_set">W:</span>
|
||||
<%= 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' %>
|
||||
<span class="banner_set">H:</span>
|
||||
<%= 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'} %>
|
||||
<p class="suckIE hide"><i class="icons-warning"></i> <%= t('ad_banner.no_ie_10_effect_support') %></p>
|
||||
<div class="preview">
|
||||
<%= image_tag "slideshow_preview_A.png", width: 200, height: 80 %>
|
||||
|
|
|
@ -2,16 +2,20 @@
|
|||
objects @ad_banners
|
||||
quick_edit_link type: 'edit',
|
||||
class: 'open-slide',
|
||||
data: "{"
|
||||
.concat("title: t('ad_banner.edit_banner')")
|
||||
.concat(", w: object.width")
|
||||
.concat(", h: object.height")
|
||||
.concat(", fx: object.ad_fx")
|
||||
.concat(", id: object.id.to_s")
|
||||
data: "{form: {"
|
||||
.concat("width: object.width")
|
||||
.concat(", height: object.height")
|
||||
.concat(", ad_fx: object.ad_fx")
|
||||
.concat(", name: object.title")
|
||||
.concat(", time: object.timeout")
|
||||
.concat(", timeout: object.timeout")
|
||||
.concat(", speed: object.speed")
|
||||
.concat("}.to_json")
|
||||
.concat(", title: t('ad_banner.edit_banner')")
|
||||
.concat(", id: object.id.to_s")
|
||||
.concat(", fx: object.ad_fx")
|
||||
.concat("}")
|
||||
|
||||
# '{"#first":{"equal":"Yes"}}'
|
||||
quick_edit_link type: 'detail'
|
||||
quick_edit_link type: 'delete',
|
||||
link: 'admin_ad_banner_path'
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<div class="quick-edit">
|
||||
<ul class="nav nav-pills">
|
||||
<% if is_admin?%>
|
||||
<li><%= link_to t(:edit), edit_admin_module_app_category_path(@module_app_id, category), class: "open-slide", data: {title: t(:edit_category)} %></li>
|
||||
<li><%= link_to show_toggle_archive_btn(category) , toggle_admin_module_app_category_path(@module_app_id, category), method: :post, remote: true, class: "archive_toggle" %></li>
|
||||
<li><%= link_to t(:edit), '#', class: "open-slide", data: {title: t(:edit_category), id: category.id.to_s, module: @module_app_id.to_s, form: category.title_translations} %></li>
|
||||
<li><%= link_to show_toggle_archive_btn(category), toggle_admin_module_app_category_path(@module_app_id, category), method: :post, remote: true, class: "archive_toggle" %></li>
|
||||
<% end %>
|
||||
<% if is_manager? || is_admin? %>
|
||||
<li><%= link_to t(:category_auth), admin_authorizations_path(@module_app.key, 'category_authorization', category.id) %></li>
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
<%= f.fields_for :title_translations do |f| %>
|
||||
<% @site_valid_locales.each do |locale| %>
|
||||
<%= label_tag "name-#{locale}", "#{t(:name)} (#{I18nVariable.from_locale(locale)})" %>
|
||||
<%= f.text_field locale, :class => 'input-large', :value => (@category.title_translations[locale] rescue ''), placeholder: t(:name) %>
|
||||
<%= f.text_field locale, :class => 'input-large', :value => (@category.title_translations[locale] rescue ''), placeholder: t(:name), id: locale %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
<div class="bottomnav clearfix">
|
||||
<div class="action pull-right">
|
||||
<%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), new_admin_module_app_category_path(@module_app_id), class: "btn btn-primary open-slide", data: {title: t(:add_category)} %>
|
||||
<%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), '#', class: "btn btn-primary open-slide", data: {title: t(:add_category), id: 'new', module: @module_app_id.to_s } %>
|
||||
</div>
|
||||
<div class="pagination pagination-centered">
|
||||
<%= paginate @categories unless @categories.blank? %>
|
||||
|
|
|
@ -1,3 +1,27 @@
|
|||
<div id="categories_index">
|
||||
<%= render 'index' %>
|
||||
</div>
|
||||
|
||||
<div id="pageslide">
|
||||
<div class="page-title clearfix">
|
||||
<a class="pull-right" href="javascript:$.pageslide.close()">
|
||||
<i class="icons-arrow-left-2"></i>
|
||||
</a>
|
||||
<span></span>
|
||||
</div>
|
||||
<div class="view-page">
|
||||
<div class="nano">
|
||||
<div class="content">
|
||||
<%= form_for :category, url: nil, remote: true do |f| %>
|
||||
<fieldset>
|
||||
<%= render :partial => "form", :locals => { :f => f } %>
|
||||
<div class="form-actions">
|
||||
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
|
||||
<%= f.submit t(:submit), class: 'btn btn-primary btn-small' %>
|
||||
</div>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -4,6 +4,6 @@
|
|||
<%= f.fields_for :name_translations do |f| %>
|
||||
<% @site_valid_locales.each do |locale| %>
|
||||
<%= f.label :locale, "#{t(:name)} #{I18nVariable.from_locale(locale)}" %>
|
||||
<%= f.text_field locale, class: 'input-large', placeholder: "#{t(:name)} #{I18nVariable.from_locale(locale)}", value: (@tag.name_translations[locale] rescue nil) %>
|
||||
<%= f.text_field locale, class: 'input-large', placeholder: "#{t(:name)} #{I18nVariable.from_locale(locale)}", value: (@tag.name_translations[locale] rescue nil), id: locale %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<%= link_to t(:delete), '#', id: "deleteTags", class: "btn btn-danger toggable hide", rel: '' %>
|
||||
<%= link_to t(:merge), '#', id: "mergerTags", class: "btn btn-success toggable hide", rel: merge_admin_tags_path %>
|
||||
<%= link_to t(:add_to_default), add_to_default_admin_tags_path, id: "addDefault", class: "btn btn-info toggable hide", method: :post, remote: true %>
|
||||
<%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), new_admin_tag_path, class: "btn btn-primary open-slide", data: {title: t('new.tag')} %>
|
||||
<%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), '#', class: "btn btn-primary open-slide", data: {title: t('new.tag'), id: 'new'} %>
|
||||
</div>
|
||||
</div>
|
||||
<!-- footer:end -->
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<%= show_names_slash(tag) %>
|
||||
</a>
|
||||
<% else %>
|
||||
<%= link_to edit_admin_tag_path(tag), class: "open-slide", data: {title: t('editing.tag')} do %>
|
||||
<%= link_to '#', class: "open-slide", data: {title: t('editing.tag'), id: tag.id.to_s, form: tag.name_translations} do %>
|
||||
<span class="amount"><%= get_tagging_count(tag) %></span>
|
||||
<%= show_names_slash(tag) %>
|
||||
<% end %>
|
||||
|
|
|
@ -7,3 +7,27 @@
|
|||
<div id="tags_index">
|
||||
<%= render 'index' %>
|
||||
</div>
|
||||
|
||||
<div id="pageslide">
|
||||
<div class="page-title clearfix">
|
||||
<a class="pull-right" href="javascript:$.pageslide.close()">
|
||||
<i class="icons-arrow-left-2"></i>
|
||||
</a>
|
||||
<span></span>
|
||||
</div>
|
||||
<div class="view-page">
|
||||
<div class="nano">
|
||||
<div class="content">
|
||||
<%= form_for :module_tag, url: nil, remote: true do |f| %>
|
||||
<fieldset>
|
||||
<%= render :partial => "form", :locals => { :f => f } %>
|
||||
<div class="form-actions">
|
||||
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
|
||||
<%= f.submit t(:submit), class: 'btn btn-primary btn-small' %>
|
||||
</div>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Reference in New Issue