formStory.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php
  2. use yii\helpers\Html;
  3. use yii\widgets\ActiveForm;
  4. use kartik\datetime\DateTimePicker;
  5. use app\widgets\CropperjsWidget;
  6. $form = ActiveForm::begin([
  7. 'id' => 'story-form',
  8. 'options' => ['class' => 'form-horizontal', 'enctype' => 'multipart/form-data']]);
  9. $brightness = 60;
  10. if( trim($model->ext) != ''){
  11. $ext = json_decode(trim($model->ext));
  12. if( isset($ext->brightness) ){
  13. $brightness = $ext->brightness;
  14. }
  15. }
  16. ?>
  17. <input type="hidden" name="Story[id]" value="<?=$model->id?>">
  18. <input type="hidden" name="Story[ext]" id="ext" value='<?=$model->ext?>'>
  19. <style>
  20. #image {
  21. width: 100%;
  22. height: 56%;
  23. background: URL(/img/image.svg) no-repeat 50% 50%;
  24. background-size: contain;
  25. background-color: #fff;
  26. cursor: pointer;
  27. padding: 0px 100px 8px 0px;
  28. filter: brightness(<?=$brightness?>%);
  29. }
  30. .cont {
  31. position: relative;
  32. overflow: hidden;
  33. }
  34. .itext {
  35. position: absolute;
  36. bottom: 0;
  37. left: 0;
  38. padding: 30px;
  39. max-width: 608px;
  40. font: 36px/43px "Golos Text",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Ubuntu,Arial,sans-serif;
  41. color: #fff;
  42. margin-bottom: 50px;
  43. }
  44. .itext p{
  45. font: 700 16px/19px "Golos Text",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Ubuntu,Arial,sans-serif;
  46. color: #fff;
  47. line-height: 23px;
  48. }
  49. </style>
  50. <?
  51. if($model->id){
  52. $imageSrc = "/story-images/".$model->id."_sizehd.jpg?r=".rand();
  53. }else{
  54. $imageSrc = '/img/e.gif';
  55. }
  56. ?>
  57. <div class="cont">
  58. <img id="image" src="<?=$imageSrc?>" onClick="$('#modal').modal('show');document.getElementById('inputImage').click();" >
  59. <div class="itext">
  60. Образец текста<br><br>
  61. <p>
  62. Когда вода становится святой на Крещение<br>и смывает ли грехи купание в проруби<br>
  63. ==============================================================ТЕСТ=============================================================================
  64. </p>
  65. </div>
  66. </div>
  67. <?
  68. echo CropperjsWidget::widget(['image' => 'image', 'file' => 'Story[photo]', 'post' => 'cropping', 'aspectRatio' => '13 / 5']);
  69. ?>
  70. <div class="form-group">
  71. <label for="formControlRange">Затенение</label>
  72. <input type="range" class="form-control-range" id="formControlRange" name="Story[brightness]" min="10" max="100" value="<?=$brightness?>" step="1" oninput="test(this)">
  73. </div>
  74. <?
  75. echo $form->field($model, 'url')->textInput([
  76. 'maxlength' => true,
  77. 'class' => 'form-control js-word-count-input',
  78. 'placeholder' => 'URL'
  79. ])->label('URL часть адреса рездела');
  80. echo $form->field($model, 'title')->textInput([
  81. 'maxlength' => true,
  82. 'class' => 'form-control js-word-count-input',
  83. 'placeholder' => 'Заголовок',
  84. // 'id' => 'js-news-content'
  85. ])->label('Заголовок сюжета');
  86. echo $form->field($model, 'meta_title')->textInput([
  87. 'maxlength' => true,
  88. 'class' => 'form-control js-word-count-input',
  89. 'placeholder' => 'Заголовок SEO'
  90. ])->label('Заголовок SEO');
  91. echo $form->field($model, 'description')->textarea([
  92. 'maxlength' => true,
  93. 'class' => 'form-control js-word-count-input',
  94. 'placeholder' => 'description'
  95. ])->label('Описание раздела кратко');
  96. echo $form->field($model, 'keywords')->textarea([
  97. 'maxlength' => true,
  98. 'class' => 'form-control js-word-count-input',
  99. 'placeholder' => 'ключевые слова'
  100. ])->label('ключевые слова через запятую');
  101. ?>
  102. <div class="form-group form-check">
  103. <?
  104. echo $form->field($model, 'active')->checkbox([
  105. 'class' => 'form-check-input',
  106. 'label' => 'Активный'
  107. ]);
  108. //($model->show == 'Y')?true:false,
  109. echo $form->field($model, 'show')->checkbox([
  110. 'class' => 'form-check-input',
  111. 'label' => 'Показывать везде',
  112. 'uncheck' => 'N',
  113. 'checked' => ($model->show == 'Y')?true:false
  114. ]);
  115. ?></div><div class="form-group"><?
  116. echo Html::submitButton('Send', ['class' => 'btn btn-success']);
  117. ?>
  118. </div>
  119. <script>
  120. var ext ='';
  121. var extx='<?=json_decode(trim($model->ext))?trim($model->ext):""?>';
  122. if( extx != '' ){
  123. var ext = JSON.parse(extx);
  124. }
  125. $('#story-form').on('beforeValidate',
  126. function (event){
  127. console.log(JSON.stringify(ext));
  128. if( ext != '' ){
  129. $('#ext').val(JSON.stringify(ext));
  130. }
  131. return;
  132. }
  133. );
  134. function test(e){
  135. $('#image').css( "filter", "brightness("+$(e).val()+"%)" );
  136. if( ext == '' ){
  137. ext = new Object();
  138. }
  139. ext.brightness = $(e).val();
  140. }
  141. </script>
  142. <?
  143. ActiveForm::end();