2017-08-10 35 views
0

我重構了生成器代碼並遇到了問題。我懷疑hidegui()會導致這個錯誤,雖然我不確定,特別是因爲我不知道如何解決它。無論如何,我點擊頁面上的特定按鈕,它會調用一個消息框,其中包含正確啓用/禁用的輸入框(我稱該開關和參數已啓用)。直到那一刻,一切都很順利。單擊X(關閉消息框)並調用hidegui()函數時會出現問題。我不知道,也許我在錯誤的地方解決了它?在調用hidegui()後發生Bugge開關()

var overlay = $("#overlay"); 
 
var message = $("#message"); 
 

 
/* This function shows message-box */ 
 

 
function showGUI(enabled) { 
 

 
    overlay.css("display", "block"); 
 

 
    /* Specifies which inputs are to be active after callback */ 
 

 
    switch (enabled) { 
 
    case "add-box": 
 
     $('#param1, #color, #color2, #param7, #param8, #param9').prop('disabled', true); 
 
     break; 
 

 
    case "other-box": 
 
     $('#param1, #color, #color2, #param7, #param8, #param9').prop('disabled', true); 
 
     break; 
 

 
    case "section-box": 
 
     $('#param6, #param9').prop('disabled', true); 
 
     $('#param6-form, .success').remove(); 
 
     break; 
 

 
    case "gallery-box": 
 
     $('#param1, #param2, #param3, #color, #color2, #param7, #param8').prop('disabled', true); 
 
     break; 
 
    } 
 
} 
 

 
function hideGUI() { 
 
    overlay.css("display", "none"); 
 
} 
 

 
$(".fa-times").on("click", function() { 
 
    hideGUI(); 
 
}); 
 

 
/* Parameters of inputs in message-box */ 
 

 
function params(type) { 
 

 
    param1 = $("#param1").val(); 
 
    param2 = $("#param2").val(); 
 
    param3 = $("#param3").val(); 
 
    param4 = $("#color").val(); 
 
    param5 = $("#color2").val(); 
 
    param6 = $("#param6").val(); 
 
    param7 = $("#param7").val(); 
 
    param8 = $("#param8").val(); 
 

 
    switch (type) { 
 
    case "img": 
 
     $("#additional-box").append('<img src="' + param6 + '" style="width: ' + param2 + 'px; height: ' + param3 + 'px;">'); 
 
     break; 
 

 
    case "otherimg": 
 
     $("#other-photos").append('<img src="' + param6 + '" style="width: ' + param2 + 'px; height: ' + param3 + 'px;">'); 
 
     break; 
 

 
    case "section": 
 

 
     $("#new_section").append('<div class="section" style="width: ' + param2 + 'px;"><p style="width: 100%; text-align: center; background-color: #eee; font-weight: 200; line-height: 0.92em; padding: 23px 0; font-size: 30px; margin-bottom: 0;">' + param1 + '</p><div class="section-content" style=" height:' + param3 + 'px; background: ' + param4 + '; color: ' + param5 + ';"></div></div>'); 
 
     for (count = 0; count < param8; count++) { 
 
     $(".section-content").append('<input type="text" value="" placeholder="Sample text" style="width: ' + param7 + '" />'); 
 
     } 
 

 
     break; 
 

 
    case "gallery": 
 
     $("#gallery").append('<img src="' + param6 + '" style="width: 100%;"/>'); 
 
     break; 
 
    } 
 

 
    if (param2 < 1180) { 
 
    $(".section").css("float", "left"); 
 
    } 
 

 
} 
 

 
/* Sample button calling functions */ 
 

 
$("#add_section").on("click", function() { 
 

 
    showGUI('section-box'); 
 

 
    $("#add-params").on("click", function() { 
 
    params("section"); 
 
    }); 
 

 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<div id="overlay"> 
 
<div id="message"> 
 
<div id="message-content"> 
 
<p id="m-title">Parameters <i class="fa fa-times" aria-hidden="true"></i></p> 
 
<input type="text" placeholder="Section title" name="param1" id="param1" /> 
 
<input type="text" placeholder="Element width" name="param2" id="param2" /> 
 
<input type="text" placeholder="Element height" name="param3" id="param3" /> 
 
<p class="dropdown">Choose element color <i class="fa fa-caret-down" aria-hidden="true" style="float: right;"></i></p> 
 
<div id="colorpicker"></div> 
 
<input type="text" id="color" name="param4" value="#123456" /> 
 
<p class="dropdown">Text color <i class="fa fa-caret-down" aria-hidden="true" style="float: right;"></i></p> 
 
<div id="colorpicker2"></div> 
 
<input type="text" id="color2" name="param5" value="#123456" /> 
 
<div style="position: relative; overflow: hidden;"> 
 
<a href="upload.php" target="_blank" id="uploader">Go to uploader <i style="margin-left: 5px;" class="fa fa-caret-right" aria-hidden="true"></i></a> 
 
<input type="text" placeholder="Enter source" name="param6" id="param6" /> 
 
</div> 
 
<input type="text" placeholder="Enter input width" name="param7" id="param7" /> 
 

 
<div style="position: relative;"> 
 
<input type="text" placeholder="Amount of inputs" value="" id="param8" name="param8" /> 
 
<button type="button" class="count-field plus"><i class="fa fa-plus" aria-hidden="true"></i></button> 
 
<button type="button" class="count-field minus"><i class="fa fa-minus" aria-hidden="true"></i></button> 
 
</div> 
 
<input type="text" placeholder="Image alt" name="param9" id="param9"/> 
 

 

 
<button type="button" id="add-params">Add to template</button> 
 
</div> 
 
</div> 
 
</div> 
 
\t \t 
 
<div id="new_section"> 
 
<div id="default-section">Default section</div> 
 
</div> 
 

 
<div style="clear: both;"></div> 
 

 
<button type="button" id="add_section">Add new section</button>

+1

也分享相關的HTML –

+0

是的請顯示HTML。 –

+0

完成傢伙,代碼已更新 – sc4rface

回答

0

我只看到FA-次被宣佈在我反對。嘗試將類添加到按鈕,看看是否不能解決它。

相關問題