ask/app/views/asks/index.html.erb

192 lines
6.2 KiB
Plaintext
Raw Normal View History

2014-10-02 06:00:35 +00:00
<% data = action_data
@ask_question = data["ask_question"]
@categories = data["categories"]
2014-10-23 07:03:21 +00:00
@tags = data["tags"]
2014-10-02 06:00:35 +00:00
@module_app = data["module_app"]
2020-07-04 13:36:32 +00:00
@switch_form = data["switch_form"]
ask_setting = data["ask_setting"]
2022-09-21 10:07:01 +00:00
set_input_name_for_ask('ask_question')
2022-03-09 17:00:05 +00:00
@default_ask_setting = data['default_ask_setting']
2022-04-12 14:17:34 +00:00
email_regex = data['email_regex']
2014-10-02 06:00:35 +00:00
%>
2020-04-30 05:18:02 +00:00
<% if data['layout_type'] != 'index' %>
<%= render template: "asks/#{data['layout_type']}",:locals => { :data => data, :ask_setting => ask_setting } %>
<% else %>
2016-11-07 02:08:04 +00:00
<style type="text/css">
#new-ask-question .form-horizontal .control-group > *{
2020-07-04 13:36:32 +00:00
font-size: 1.125em;
}
2016-11-07 02:08:04 +00:00
.default_picker label{
display: none;
}
.ask-question .control-group{
flex-wrap: wrap;
display: flex;
align-items: center;
}
.ask-question .controls > *{
display: block;
}
.ask-question .controls > script{
display: none;
}
.ask-question .form-horizontal .control-label{
width: 24%;
max-width: 15em;
2020-07-04 13:48:00 +00:00
min-width: 7em;
padding: 0;
text-align: center;
}
.ask-question .form-horizontal .control-group .controls{
margin: 0;
overflow: hidden;
position: relative;
min-width: 10em;
2021-02-25 08:04:05 +00:00
max-width: 25em;
padding-left: 0;
padding: 0.5em;
2022-05-21 13:47:42 +00:00
}
.ask-question .single-col.form-horizontal .control-group{
width: 100%;
}
.ask-question .single-col.form-horizontal .control-group .controls{
width: 100%;
display: inline-flex;
flex-wrap: wrap;
align-items: flex-start;
justify-content: flex-start;
}
2022-05-21 13:47:42 +00:00
.ask-question .ask-question-form.multi-col.form-horizontal div[data-list="fields"]{
float: left;
}
.ask-question .ask-question-form.multi-col.form-horizontal .form-actions{
float: left;
width: 100%;
}
.ask-question .form-horizontal input[type="text"],.ask-question .form-horizontal select{
width: 97%;
}
2023-02-10 05:34:07 +00:00
.ask-question .form-horizontal input[type="text"].hasDatepicker{
width: auto;
}
.ask-question .form-horizontal .form-actions{
position: relative;
padding: 1em 0 0 0;
text-align: center;
}
2022-09-05 01:28:51 +00:00
.ask-question .controls > input[type="radio"]:not(:first-child) {
margin-left: 0.5em;
}
2016-11-07 02:08:04 +00:00
</style>
2020-03-22 15:58:53 +00:00
<%# javascript_include_tag "/assets/lib/jquery-ui-1.12.1/jquery-ui.min" %>
2020-04-30 05:18:02 +00:00
<%# stylesheet_link_tag "/assets/lib/jquery-ui-1.12.1/jquery-ui.min" %>
<%= stylesheet_link_tag "custom_field" %>
2020-04-30 05:18:02 +00:00
<%# stylesheet_link_tag "jquery-ui-timepicker-addon" %>
<script type="text/javascript">
2022-03-09 17:00:05 +00:00
/*
2020-07-04 13:36:32 +00:00
$(document).ready(function(){
$('select[name="ask_question[category_id]"]').change(function(){
var category_id = $(this).val()
$(this).parents('.ask-question').eq(0).find('select[name="ask_question[category_id]"]').val(category_id)
var id
if ($('form#'+category_id).length != 0){
id = category_id
}
else{
id = 'ask-default-form'
}
if (id != $(this).parents('form').eq(0).attr('id')){
$(this).parents('.ask-question').eq(0).find('form').hide()
$(this).parents('.ask-question').eq(0).find('form#'+id).show()
}
})
2022-03-09 17:00:05 +00:00
})*/
2020-07-04 13:36:32 +00:00
var datepicker_fn = $.fn.datepicker
var datepicker = $.datepicker
$(document).ready(function(){
$('input:file').change(function(e){
var fileName = e.target.files[0].name;
$(this).parents(".file-selector").eq(0).find('.filename').html(fileName);
})
})
</script>
<%# javascript_include_tag "lib/bootstrap-datetimepicker" %>
2020-03-22 15:58:53 +00:00
<%# javascript_include_tag "jquery.ui.datepicker.monthyearpicker" %>
2014-10-02 06:00:35 +00:00
<%= javascript_include_tag 'validator' %>
<link href="/assets/ask/ask.css" media="screen" rel="stylesheet">
<div id="new-ask-question" class="ask-question">
2022-03-24 05:27:55 +00:00
<%= @switch_form.html_safe %>
2014-10-02 06:00:35 +00:00
</div>
<script type='text/javascript'>
// $(function(){
// $("#button-mail").click(function(){
// if( $("#ask_question_name").val()!='' ) $("#ask_question_name").css('border','');
// if( $("#ask_question_email").val()!='' ) $("#ask_question_email").css('border','');
// if( $("#ask_question_title").val()!='' ) $("#ask_question_title").css('border','');
// if( $("#ask_question_content").val()!='' ) $("#ask_question_content").css('border','');
// if( $("#ask_question_name").val()=='' ) $("#ask_question_name").css('border','1px solid #F00');
// if( $("#ask_question_email").val()=='' ) $("#ask_question_email").css('border','1px solid #F00');
// if( $("#ask_question_title").val()=='' ) $("#ask_question_title").css('border','1px solid #F00');
// if( $("#ask_question_content").val()=='' ) $("#ask_question_content").css('border','1px solid #F00');
// });
2020-07-04 13:36:32 +00:00
$('.ask-question .required').each(function() {
var text = $(this).text()
if (text[0]!='*'){
$(this).text('*' + text);
}
2014-10-02 06:00:35 +00:00
});
// $('#new-ask-question form') .submit(function() {
// $.post($(this).attr('action'), $(this).serializeArray());
// return false;
// });
// });
2022-04-12 14:17:34 +00:00
$(document).ready(function(){
function scrollIntoView(selector, offset = 0) {
window.scroll(0, document.querySelector(selector).offsetTop - offset);
}
2022-04-12 14:17:34 +00:00
var email_regex = "<%=email_regex%>";
if(email_regex.length != 0){
email_regex = new RegExp(email_regex);
var fv = new FormValidator($("#new_ask_question"));
fv.validate_functions.check_email = function(value){
if (email_regex.test(value)) {
return true;
}else{
return false;
}
}
2022-04-12 14:17:34 +00:00
var submit_flag = false;
$(".ask-question-form").each(function(i, form){
var $form = $(form);
2023-05-30 13:19:43 +00:00
if($form.length != 0 && $form.find('#ask_question_mail').length != 0){
2022-04-12 14:17:34 +00:00
$form.submit(function(){
2023-05-30 13:19:43 +00:00
var email_field = $(this).find('#ask_question_mail');
2022-04-12 14:17:34 +00:00
if(!submit_flag){
submit_flag = true;
if(email_regex.test(email_field.val())){
2022-04-12 14:17:34 +00:00
submit_flag = false;
}else{
email_field.css("border", "2px solid red");
scrollIntoView('#ask_question_mail');
2022-04-12 14:17:34 +00:00
alert("<%=t('ask.please_check_email_format')%>");
email_field.one("input",function(){
email_field.css("border", "");
})
2022-04-12 14:17:34 +00:00
submit_flag = false;
return false;
}
}
})
}
})
}
})
2020-04-30 05:18:02 +00:00
</script>
2023-05-30 13:19:43 +00:00
<% end %>