var Counter = 1;
$(function() {
$(".scroll").click(function(){
var Hash = $(this.hash);
var HashOffset = $(Hash).offset().top;
$("html,body").animate({
scrollTop: HashOffset
}, 1000);
return false;
});
$("#sortable li:hidden").fadeIn("normal");
$("#agree_check").click(function () {
if($("input[name='agree_check']:checked").val() != undefined ){
$("#download").removeAttr('disabled');
$("#download").attr('src','img/download_btn.jpg');
}else{
$("#download").attr('disabled','disabled');
$("#download").attr('src','img/download_disabled_btn.jpg');
}
});
$(".test_send").colorbox({iframe:true, width:"550px", height:"550px"});
var tab = $('#sidemenu');
offset = tab.offset();
$(window).scroll(function () {
if($(window).scrollTop() > offset.top) {
tab.addClass('fixed');
} else {
tab.removeClass('fixed');
}
});
// フェードイン表示
$(document.body).click(function () {
$("#sortable li:hidden").fadeIn("normal");
//$("#sortable li").css("display":"block");
});
// 入力フォーム追加
$("#AddInput").click(function () {
$('#sortable').append( '
× 削除' );
DefUl();
Counter++;
});
$("#AddTextArea").click(function () {
$('#sortable').append( '× 削除' );
DefUl();
Counter++;
});
$("#AddMail").click(function () {
$('#sortable').append( '× 削除' );
DefUl();
//Counter++;
});
$("#AddAddress").click(function () {
$('#sortable').append( ' - × 削除' );
DefUl();
//Counter++;
});
$("#AddRadio").click(function () {
$('#sortable').append( '▲追加
× 削除' );
Event();
DefUl();
Counter++;
});
$("#AddCheck").click(function () {
$('#sortable').append( '▲追加
× 削除' );
Event();
DefUl();
Counter++;
});
$("#AddSelect").click(function () {
$('#sortable').append( '× 削除' );
Event();
DefUl();
Counter++;
});
// 選択肢追加
$(document).on("click", ".addradio", function(i) {
var i = $(this).parent().children("[name='form_id[]']").val();
$(this).parent().children("ul").append( ' ×' );
});
$(document).on("click", ".addcheck", function(i) {
var i = $(this).parent().children("[name='form_id[]']").val();
$(this).parent().children("ul").append( ' ×' );
});
$(document).on("click", ".addoption", function(i) {
var i = $(this).parent().parent().children("[name='form_id[]']").val();
$(this).parent().children("ul").append( ' ×' );
});
// フォームパーツの並び替え
$( "#sortable" ).sortable({
connectWith: 'this',
opacity: 0.8,
placeholder: 'ui-state-highlight',
start: function(event, ui){
ui.placeholder.height(ui.item.height());
}
}).disableSelection();
$("#sortable").sortable().disableSelection().delegate('input,textarea','click',function(ev){
ev.target.focus();
});
$("div.select").hide();
$(document).on("click", "p.selectopne", function() {
$(this).parent().children("div.select").slideToggle("fast");
$(this).parent().parent().children().css('z-index','1');
$(this).parent().css('z-index','9999');
}).disableSelection();
$("div.detail").hide();
$(document).on("click", "p.btn", function() {
$(this).parent().children("div.detail").slideToggle("fast");
if( $(this).parent().children("div.detail").height() > 10 ){
$(this).html('▼詳細設定');
}else{
$(this).html('▲詳細設定');
}
}).disableSelection();
// 削除
$(document).on("click", "#sortable li span.del", function() {
$(this).parent().remove();
DefUl();
});
DefUl();
});
function Event(){
// フォーム選択肢の並び替え
$( ".radio-list" ).sortable({
connectWith: 'this',
opacity: 0.8,
axis: 'y',
placeholder: 'ui-state-highlight',
start: function(event, ui){
ui.placeholder.height(ui.item.height());
}
}).disableSelection();
$( ".check-list" ).sortable({
connectWith: 'this',
opacity: 0.8,
axis: 'y',
placeholder: 'ui-state-highlight',
start: function(event, ui){
ui.placeholder.height(ui.item.height());
}
}).disableSelection();
$( ".select-list" ).sortable({
connectWith: 'this',
opacity: 0.8,
axis: 'y',
placeholder: 'ui-state-highlight',
start: function(event, ui){
ui.placeholder.height(ui.item.height());
}
}).disableSelection();
}
function DefUl(){
var strHTML = $("#sortable li").size();
if( strHTML != '' ){
$("#sortable").css({'padding-top':"3px","background":"none"});
}else{
$("#sortable").css({'padding-top':"200px","background":"url('img/ul_def_img.png')"});
}
}