From 9aba9a3f0be477423e412864963707d3f1b3d540 Mon Sep 17 00:00:00 2001 From: BOHUNG Date: Sun, 12 Jan 2020 21:47:55 +0800 Subject: [PATCH] edit page css to fix the layout --- app/assets/javascripts/cancer_predict.js | 32 ++++++++++++++++++++-- app/assets/stylesheets/cancer_predict.scss | 7 ++++- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/cancer_predict.js b/app/assets/javascripts/cancer_predict.js index 09cacdd..1272aaf 100644 --- a/app/assets/javascripts/cancer_predict.js +++ b/app/assets/javascripts/cancer_predict.js @@ -1,6 +1,20 @@ $(document).ready(function(){ var head_data = $.post("/cancerpredictResult",{"header":1,locale:I18n.locale}); var data = {}; + if(I18n.locale == 'en'){ + var window_width = $(window).width(); + if(window_width < 520){ + $('#cancer_table .cencer_table_name').css('max-width',''); + }else if(window_width < 768){ + $('#cancer_table .cencer_table_name').css({'max-width':'','width':'11em'}); + }else if(window_width < 860){ + $('#cancer_table .cencer_table_name').css('max-width','30%'); + }else if(window_width < 1130){ + $('#cancer_table .cencer_table_name').css('max-width','33%'); + }else{ + $('#cancer_table .cencer_table_name').css('max-width','39%'); + }; + }; head_data.done(function(){ // $('.header-nav').html(head_images.responseJSON['head_images']); // $('.navbar-brand').html(head_images.responseJSON['title']) @@ -219,10 +233,10 @@ $(document).ready(function(){ flag = 1; for(var i = 0;i < $('#cancer_table .cancer_form_field').length;i++){ if($('#cancer_table .cancer_form_field').eq(i).hasClass('num_only')){ - if($('#cancer_table .cancer_form_field').eq(i).siblings('.num_only_value').val()==""){ + if($('#cancer_table .cancer_form_field').eq(i).val()==""){ flag = 0; $('#cancer_table .cancer_form_field').eq(i).addClass('cancertable_empty'); - }else{ + }else if($('#cancer_table .cancer_form_field').eq(i).val() != "" && !$('#cancer_table .cancer_form_field').eq(i).hasClass('cancertable_empty')){ $('#cancer_table .cancer_form_field').eq(i).removeClass('cancertable_empty'); }; }else{ @@ -797,4 +811,18 @@ $(window).resize(function(){ }else{ $('#cancer_predict_result').attr('style',''); }; + if(I18n.locale == 'en'){ + var window_width = $(window).width(); + if(window_width < 520){ + $('#cancer_table .cencer_table_name').css('max-width',''); + }else if(window_width < 768){ + $('#cancer_table .cencer_table_name').css({'max-width':'','width':'11em'}); + }else if(window_width < 860){ + $('#cancer_table .cencer_table_name').css('max-width','30%'); + }else if(window_width < 1130){ + $('#cancer_table .cencer_table_name').css('max-width','33%'); + }else{ + $('#cancer_table .cencer_table_name').css('max-width','39%'); + }; + }; }); diff --git a/app/assets/stylesheets/cancer_predict.scss b/app/assets/stylesheets/cancer_predict.scss index 912dccd..a191bb1 100644 --- a/app/assets/stylesheets/cancer_predict.scss +++ b/app/assets/stylesheets/cancer_predict.scss @@ -45,11 +45,16 @@ div.num_group{ width: 16.25em; } } -@media screen and (max-width: 71em){ +@media screen and (min-width: 28.375em) and (max-width: 71em){ #cancer_table .cencer_table_name{ width: 12.25em; } } +@media screen and (max-width: 28.25em){ + #cancer_table .cencer_table_name{ + width: 7em; + } +} #cancer_predict_result_block .cencer_table_name{ width: 5em; }