layout.blade.php 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. @extends('layouts.admin')
  2. @section('title')
  3. {{$section->name}} - Layout
  4. @stop
  5. @section('content')
  6. <form action="/admin/sections/layout/{{$section->id}}" method="POST" name="frmLayout" id="frmLayout">
  7. {{csrf_field()}}
  8. <input type="hidden" name="big">
  9. <input type="hidden" name="small1">
  10. <input type="hidden" name="small2">
  11. <input type="hidden" name="small3">
  12. <input type="hidden" name="small4">
  13. <input type="hidden" name="small5">
  14. <input type="hidden" name="small6">
  15. <div class="row" style="padding:40px">
  16. <div class="row">
  17. <div class="col-md-12">
  18. <div class="form-group">
  19. {!! Form::label('layout', 'Layout:') !!}
  20. <br>
  21. @for($x=1;$x<=7;$x++)
  22. <div style="padding:10px;float:left;{{@$_GET["layout"] == 'layout_' . $x || (@$_GET["layout"] == '' && $section->layout == 'layout_' . $x) ? 'background-color:red;' : ''}} " class="selImg" data-id="layout_{{$x}}">
  23. <a href="#" onclick="if (confirm('Se cambi layout la posizione delle news verrà azzerata, proseguire?')) document.location.href='/{{Request::path()}}?layout=layout_{{$x}}';"><img src="/images/layout_{{$x}}.png" style="width:150px;"></a>
  24. </div>
  25. @endfor
  26. <input name="layout" type="hidden" value="{{isset($_GET["layout"]) ? $_GET["layout"] : $section->layout}}" id="layout">
  27. </div>
  28. </div>
  29. </div>
  30. <div class="row">
  31. <br>
  32. <div class="col-md-8">
  33. @if(@$_GET["layout"] == 'layout_1' || (@$_GET["layout"] == '' && $section->layout == 'layout_1'))
  34. <div class="row">
  35. <div class="col-md-12 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'big')" style="height:300px" data-zone="big">
  36. @if(is_object($section->big))
  37. <h4 id="news{{$section->big->id}}" draggable="true" ondragstart="dragStart(event, 'big')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->big->date))}}">{{$section->big->title}} - {{date("d/m/Y", strtotime($section->big->date))}} <a class="remove" data-x="news{{$section->big->id}}">(X)</a></h4>
  38. @endif
  39. </div>
  40. </div>
  41. <div class="row">
  42. <div class="col-md-4 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small1')" style="min-height:80px" data-zone="small1">
  43. @if(is_object($section->small1))
  44. <h4 id="news{{$section->small1->id}}" draggable="true" ondragstart="dragStart(event, 'small1')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small1->date))}}">{{$section->small1->title}} - {{date("d/m/Y", strtotime($section->small1->date))}} <a class="remove" data-x="news{{$section->small1->id}}">(X)</a></h4></br>
  45. @endif
  46. </div>
  47. <div class="col-md-4 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small2')" style="min-height:80px" data-zone="small2">
  48. @if(is_object($section->small2))
  49. <h4 id="news{{$section->small2->id}}" draggable="true" ondragstart="dragStart(event, 'small2')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small2->date))}}">{{$section->small2->title}} - {{date("d/m/Y", strtotime($section->small2->date))}} <a class="remove" data-x="news{{$section->small2->id}}">(X)</a></h4></br>
  50. @endif
  51. </div>
  52. <div class="col-md-4 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small3')" style="min-height:80px" data-zone="small3">
  53. @if(is_object($section->small3))
  54. <h4 id="news{{$section->small3->id}}" draggable="true" ondragstart="dragStart(event, 'small3')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small3->date))}}">{{$section->small3->title}} - {{date("d/m/Y", strtotime($section->small3->date))}} <a class="remove" data-x="news{{$section->small3->id}}">(X)</a></h4></br>
  55. @endif
  56. </div>
  57. </div>
  58. @endif
  59. @if(@$_GET["layout"] == 'layout_2' || (@$_GET["layout"] == '' && $section->layout == 'layout_2'))
  60. <div class="row">
  61. <div class="col-md-12 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'big')" style="height:300px" data-zone="big">
  62. @if(is_object($section->big))
  63. <h4 id="news{{$section->big->id}}" draggable="true" ondragstart="dragStart(event, 'big')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->big->date))}}">{{$section->big->title}} - {{date("d/m/Y", strtotime($section->big->date))}} <a class="remove" data-x="news{{$section->big->id}}">(X)</a></h4>
  64. @endif
  65. </div>
  66. </div>
  67. <div class="row">
  68. <div class="col-md-4 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small1')" style="min-height:80px" data-zone="small1">
  69. @if(is_object($section->small1))
  70. <h4 id="news{{$section->small1->id}}" draggable="true" ondragstart="dragStart(event, 'small1')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small1->date))}}">{{$section->small1->title}} - {{date("d/m/Y", strtotime($section->small1->date))}} <a class="remove" data-x="news{{$section->small1->id}}">(X)</a></h4></br>
  71. @endif
  72. </div>
  73. <div class="col-md-4 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small2')" style="min-height:80px" data-zone="small2">
  74. @if(is_object($section->small2))
  75. <h4 id="news{{$section->small2->id}}" draggable="true" ondragstart="dragStart(event, 'small2')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small2->date))}}">{{$section->small2->title}} - {{date("d/m/Y", strtotime($section->small2->date))}} <a class="remove" data-x="news{{$section->small2->id}}">(X)</a></h4></br>
  76. @endif
  77. </div>
  78. <div class="col-md-4 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small3')" style="min-height:80px" data-zone="small3">
  79. @if(is_object($section->small3))
  80. <h4 id="news{{$section->small3->id}}" draggable="true" ondragstart="dragStart(event, 'small3')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small3->date))}}">{{$section->small3->title}} - {{date("d/m/Y", strtotime($section->small3->date))}} <a class="remove" data-x="news{{$section->small3->id}}">(X)</a></h4></br>
  81. @endif
  82. </div>
  83. </div>
  84. @endif
  85. @if(@$_GET["layout"] == 'layout_3' || (@$_GET["layout"] == '' && $section->layout == 'layout_3'))
  86. <div class="row">
  87. <div class="col-md-12 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'big')" style="height:300px" data-zone="big">
  88. @if(is_object($section->big))
  89. <h4 id="news{{$section->big->id}}" draggable="true" ondragstart="dragStart(event, 'big')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->big->date))}}">{{$section->big->title}} - {{date("d/m/Y", strtotime($section->big->date))}} <a class="remove" data-x="news{{$section->big->id}}">(X)</a></h4>
  90. @endif
  91. </div>
  92. </div>
  93. <div class="row">
  94. <div class="col-md-6 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small1')" style="min-height:80px" data-zone="small1">
  95. @if(is_object($section->small1))
  96. <h4 id="news{{$section->small1->id}}" draggable="true" ondragstart="dragStart(event, 'small1')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small1->date))}}">{{$section->small1->title}} - {{date("d/m/Y", strtotime($section->small1->date))}} <a class="remove" data-x="news{{$section->small1->id}}">(X)</a></h4></br>
  97. @endif
  98. </div>
  99. <div class="col-md-6 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small2')" style="min-height:80px" data-zone="small2">
  100. @if(is_object($section->small2))
  101. <h4 id="news{{$section->small2->id}}" draggable="true" ondragstart="dragStart(event, 'small2')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small2->date))}}">{{$section->small2->title}} - {{date("d/m/Y", strtotime($section->small2->date))}} <a class="remove" data-x="news{{$section->small2->id}}">(X)</a></h4></br>
  102. @endif
  103. </div>
  104. </div>
  105. <div class="row">
  106. <div class="col-md-6 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small3')" style="min-height:80px" data-zone="small3">
  107. @if(is_object($section->small3))
  108. <h4 id="news{{$section->small3->id}}" draggable="true" ondragstart="dragStart(event, 'small3')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small3->date))}}">{{$section->small3->title}} - {{date("d/m/Y", strtotime($section->small3->date))}} <a class="remove" data-x="news{{$section->small3->id}}">(X)</a></h4></br>
  109. @endif
  110. </div>
  111. <div class="col-md-6 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small4')" style="min-height:80px" data-zone="small4">
  112. @if(is_object($section->small4))
  113. <h4 id="news{{$section->small4->id}}" draggable="true" ondragstart="dragStart(event, 'small4')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small4->date))}}">{{$section->small4->title}} - {{date("d/m/Y", strtotime($section->small4->date))}} <a class="remove" data-x="news{{$section->small4->id}}">(X)</a></h4></br>
  114. @endif
  115. </div>
  116. </div>
  117. @endif
  118. @if(@$_GET["layout"] == 'layout_4' || (@$_GET["layout"] == '' && $section->layout == 'layout_4'))
  119. <div class="row">
  120. <div class="col-md-12 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'big')" style="height:300px" data-zone="big">
  121. @if(is_object($section->big))
  122. <h4 id="news{{$section->big->id}}" draggable="true" ondragstart="dragStart(event, 'big')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->big->date))}}">{{$section->big->title}} - {{date("d/m/Y", strtotime($section->big->date))}} <a class="remove" data-x="news{{$section->big->id}}">(X)</a></h4>
  123. @endif
  124. </div>
  125. </div>
  126. <div class="row">
  127. <div class="col-md-6 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small1')" style="min-height:80px" data-zone="small1">
  128. @if(is_object($section->small1))
  129. <h4 id="news{{$section->small1->id}}" draggable="true" ondragstart="dragStart(event, 'small1')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small1->date))}}">{{$section->small1->title}} - {{date("d/m/Y", strtotime($section->small1->date))}} <a class="remove" data-x="news{{$section->small1->id}}">(X)</a></h4></br>
  130. @endif
  131. </div>
  132. <div class="col-md-6 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small2')" style="min-height:80px" data-zone="small2">
  133. @if(is_object($section->small2))
  134. <h4 id="news{{$section->small2->id}}" draggable="true" ondragstart="dragStart(event, 'small2')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small2->date))}}">{{$section->small2->title}} - {{date("d/m/Y", strtotime($section->small2->date))}} <a class="remove" data-x="news{{$section->small2->id}}">(X)</a></h4></br>
  135. @endif
  136. </div>
  137. </div>
  138. <div class="row">
  139. <div class="col-md-6 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small3')" style="min-height:80px" data-zone="small3">
  140. @if(is_object($section->small3))
  141. <h4 id="news{{$section->small3->id}}" draggable="true" ondragstart="dragStart(event, 'small3')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small3->date))}}">{{$section->small3->title}} - {{date("d/m/Y", strtotime($section->small3->date))}} <a class="remove" data-x="news{{$section->small3->id}}">(X)</a></h4></br>
  142. @endif
  143. </div>
  144. <div class="col-md-6 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small4')" style="min-height:80px" data-zone="small4">
  145. @if(is_object($section->small4))
  146. <h4 id="news{{$section->small4->id}}" draggable="true" ondragstart="dragStart(event, 'small4')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small4->date))}}">{{$section->small4->title}} - {{date("d/m/Y", strtotime($section->small4->date))}} <a class="remove" data-x="news{{$section->small4->id}}">(X)</a></h4></br>
  147. @endif
  148. </div>
  149. </div>
  150. <div class="row">
  151. <div class="col-md-6 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small5')" style="min-height:80px" data-zone="small5">
  152. @if(is_object($section->small5))
  153. <h4 id="news{{$section->small5->id}}" draggable="true" ondragstart="dragStart(event, 'small5')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small5->date))}}">{{$section->small5->title}} - {{date("d/m/Y", strtotime($section->small5->date))}} <a class="remove" data-x="news{{$section->small5->id}}">(X)</a></h4></br>
  154. @endif
  155. </div>
  156. <div class="col-md-6 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small6')" style="min-height:80px" data-zone="small6">
  157. @if(is_object($section->small6))
  158. <h4 id="news{{$section->small6->id}}" draggable="true" ondragstart="dragStart(event, 'small6')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small6->date))}}">{{$section->small6->title}} - {{date("d/m/Y", strtotime($section->small6->date))}} <a class="remove" data-x="news{{$section->small6->id}}">(X)</a></h4></br>
  159. @endif
  160. </div>
  161. </div>
  162. @endif
  163. @if(@$_GET["layout"] == 'layout_5' || (@$_GET["layout"] == '' && $section->layout == 'layout_5'))
  164. <div class="row">
  165. <div class="col-md-12 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'big')" style="height:300px" data-zone="big">
  166. @if(is_object($section->big))
  167. <h4 id="news{{$section->big->id}}" draggable="true" ondragstart="dragStart(event, 'big')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->big->date))}}">{{$section->big->title}} - {{date("d/m/Y", strtotime($section->big->date))}} <a class="remove" data-x="news{{$section->big->id}}">(X)</a></h4>
  168. @endif
  169. </div>
  170. </div>
  171. <div class="row">
  172. <div class="col-md-6 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small1')" style="min-height:80px" data-zone="small1">
  173. @if(is_object($section->small1))
  174. <h4 id="news{{$section->small1->id}}" draggable="true" ondragstart="dragStart(event, 'small1')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small1->date))}}">{{$section->small1->title}} - {{date("d/m/Y", strtotime($section->small1->date))}} <a class="remove" data-x="news{{$section->small1->id}}">(X)</a></h4></br>
  175. @endif
  176. </div>
  177. <div class="col-md-6 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small2')" style="min-height:80px" data-zone="small2">
  178. @if(is_object($section->small2))
  179. <h4 id="news{{$section->small2->id}}" draggable="true" ondragstart="dragStart(event, 'small2')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small2->date))}}">{{$section->small2->title}} - {{date("d/m/Y", strtotime($section->small2->date))}} <a class="remove" data-x="news{{$section->small2->id}}">(X)</a></h4></br>
  180. @endif
  181. </div>
  182. </div>
  183. <div class="row">
  184. <div class="col-md-6 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small3')" style="min-height:80px" data-zone="small3">
  185. @if(is_object($section->small3))
  186. <h4 id="news{{$section->small3->id}}" draggable="true" ondragstart="dragStart(event, 'small3')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small3->date))}}">{{$section->small3->title}} - {{date("d/m/Y", strtotime($section->small3->date))}} <a class="remove" data-x="news{{$section->small3->id}}">(X)</a></h4></br>
  187. @endif
  188. </div>
  189. <div class="col-md-6 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small4')" style="min-height:80px" data-zone="small4">
  190. @if(is_object($section->small4))
  191. <h4 id="news{{$section->small4->id}}" draggable="true" ondragstart="dragStart(event, 'small4')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small4->date))}}">{{$section->small4->title}} - {{date("d/m/Y", strtotime($section->small4->date))}} <a class="remove" data-x="news{{$section->small4->id}}">(X)</a></h4></br>
  192. @endif
  193. </div>
  194. </div>
  195. @endif
  196. @if(@$_GET["layout"] == 'layout_6' || (@$_GET["layout"] == '' && $section->layout == 'layout_6'))
  197. <div class="row">
  198. <div class="col-md-6 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'big')" style="height:300px" data-zone="big">
  199. @if(is_object($section->big))
  200. <h4 id="news{{$section->big->id}}" draggable="true" ondragstart="dragStart(event, 'big')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->big->date))}}">{{$section->big->title}} - {{date("d/m/Y", strtotime($section->big->date))}} <a class="remove" data-x="news{{$section->big->id}}">(X)</a></h4>
  201. @endif
  202. </div>
  203. <div class="col-md-6 ">
  204. <div class="row">
  205. <div class="col-md-12 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small1')" style="min-height:80px" data-zone="small1">
  206. @if(is_object($section->small1))
  207. <h4 id="news{{$section->small1->id}}" draggable="true" ondragstart="dragStart(event, 'small1')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small1->date))}}">{{$section->small1->title}} - {{date("d/m/Y", strtotime($section->small1->date))}} <a class="remove" data-x="news{{$section->small1->id}}">(X)</a></h4></br>
  208. @endif
  209. </div>
  210. <div class="col-md-12 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small2')" style="min-height:80px" data-zone="small2">
  211. @if(is_object($section->small2))
  212. <h4 id="news{{$section->small2->id}}" draggable="true" ondragstart="dragStart(event, 'small2')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small2->date))}}">{{$section->small2->title}} - {{date("d/m/Y", strtotime($section->small2->date))}} <a class="remove" data-x="news{{$section->small2->id}}">(X)</a></h4></br>
  213. @endif
  214. </div>
  215. <div class="col-md-12 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small3')" style="min-height:80px" data-zone="small3">
  216. @if(is_object($section->small3))
  217. <h4 id="news{{$section->small3->id}}" draggable="true" ondragstart="dragStart(event, 'small3')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small3->date))}}">{{$section->small3->title}} - {{date("d/m/Y", strtotime($section->small3->date))}} <a class="remove" data-x="news{{$section->small3->id}}">(X)</a></h4></br>
  218. @endif
  219. </div>
  220. </div>
  221. </div>
  222. </div>
  223. @endif
  224. @if(@$_GET["layout"] == 'layout_7' || (@$_GET["layout"] == '' && $section->layout == 'layout_7'))
  225. <div class="row">
  226. <div class="col-md-12 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'big')" style="height:300px" data-zone="big">
  227. @if(is_object($section->big))
  228. <h4 id="news{{$section->big->id}}" draggable="true" ondragstart="dragStart(event, 'big')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->big->date))}}">{{$section->big->title}} - {{date("d/m/Y", strtotime($section->big->date))}} <a class="remove" data-x="news{{$section->big->id}}">(X)</a></h4>
  229. @endif
  230. </div>
  231. </div>
  232. <div class="row">
  233. <div class="col-md-6 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small1')" style="min-height:80px" data-zone="small1">
  234. @if(is_object($section->small1))
  235. <h4 id="news{{$section->small1->id}}" draggable="true" ondragstart="dragStart(event, 'small1')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small1->date))}}">{{$section->small1->title}} - {{date("d/m/Y", strtotime($section->small1->date))}} <a class="remove" data-x="news{{$section->small1->id}}">(X)</a></h4></br>
  236. @endif
  237. </div>
  238. <div class="col-md-6 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small2')" style="min-height:80px" data-zone="small2">
  239. @if(is_object($section->small2))
  240. <h4 id="news{{$section->small2->id}}" draggable="true" ondragstart="dragStart(event, 'small2')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small2->date))}}">{{$section->small2->title}} - {{date("d/m/Y", strtotime($section->small2->date))}} <a class="remove" data-x="news{{$section->small2->id}}">(X)</a></h4></br>
  241. @endif
  242. </div>
  243. </div>
  244. <div class="row">
  245. <div class="col-md-6 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small3')" style="min-height:80px" data-zone="small3">
  246. @if(is_object($section->small3))
  247. <h4 id="news{{$section->small3->id}}" draggable="true" ondragstart="dragStart(event, 'small3')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small3->date))}}">{{$section->small3->title}} - {{date("d/m/Y", strtotime($section->small3->date))}} <a class="remove" data-x="news{{$section->small3->id}}">(X)</a></h4></br>
  248. @endif
  249. </div>
  250. <div class="col-md-6 dropBox" ondragover="allowDrop(event)" ondrop="drop(event, 'small4')" style="min-height:80px" data-zone="small4">
  251. @if(is_object($section->small4))
  252. <h4 id="news{{$section->small4->id}}" draggable="true" ondragstart="dragStart(event, 'small4')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($section->small4->date))}}">{{$section->small4->title}} - {{date("d/m/Y", strtotime($section->small4->date))}} <a class="remove" data-x="news{{$section->small4->id}}">(X)</a></h4></br>
  253. @endif
  254. </div>
  255. </div>
  256. @endif
  257. </div>
  258. <div class="col-md-4" id="newsList" style="max-height:500px;overflow-y:scroll;">
  259. <input type="text" placeholder="Cerca..." id="txtSearch" onkeyup="filter(this,'newsList')">
  260. @foreach($news as $n)
  261. <h4 class="elements" id="news{{$n->id}}" draggable="true" ondragover="return false;" ondragstart="dragStart(event, '')" style="border:1px solid black;padding:10px;" order="{{date("YmdHis", strtotime($n->date))}}">{{$n->title}} - {{date("d/m/Y", strtotime($n->date))}}</h4>
  262. @endforeach
  263. </table>
  264. </div>
  265. </div>
  266. </div>
  267. <input type="button" value="SALVA" id="btSave" class="btn btn-success">
  268. {!! link_to_route('sections.index', 'Annulla', null, array('class' => 'btn btn-info')) !!}
  269. </form>
  270. @stop
  271. @section('extra_css')
  272. <style>
  273. .dropBox
  274. {
  275. border:1px solid black;
  276. padding:20px;
  277. background-color:white;
  278. }
  279. </style>
  280. @stop
  281. @section('extra_js')
  282. <script type="text/javascript">
  283. $(function(){
  284. $("#btSave").click(function(){
  285. $(".dropBox").each(function(){
  286. var zone = $(this).attr("data-zone");
  287. if ($(this).children('h4').length > 0)
  288. {
  289. var id = $(this).children('h4').attr("id");
  290. id = id.replace("news", "");
  291. $("input[name='" + zone + "']").val(id);
  292. }
  293. });
  294. $("#frmLayout").submit();
  295. });
  296. $(document).on('click', '.remove', function () {
  297. var el = $(this).parent();
  298. el.children("a").eq(0).remove();
  299. el.removeAttr("ondragstart");
  300. el.attr("ondragstart", "dragStart(event, '')");
  301. el.appendTo("#newsList");
  302. sortNews();
  303. });
  304. });
  305. var from_zone = '';
  306. var from_event = '';
  307. function dragStart (event, zone) {
  308. from_zone = zone;
  309. from_event = event;
  310. // from_event.dataTransfer.setData("text/plain", event.target.id);
  311. event.dataTransfer.setData("text/plain", event.target.id);
  312. }
  313. function dragStartList (event) {
  314. from_zone = '';
  315. from_event = null;
  316. event.dataTransfer.setData("text/plain", event.target.id);
  317. }
  318. function allowDrop (event) {
  319. event.preventDefault();
  320. // event.currentTarget.style.background = '#7f8082';
  321. }
  322. function drop (event, zone) {
  323. if($( event.target ).is('div'))
  324. {
  325. var el = $("[data-zone='" + zone + "'] > h4");
  326. if (el != undefined && from_zone == '')
  327. {
  328. el.find("a").remove();
  329. el.removeAttr("ondragstart");
  330. sortNews();
  331. event.preventDefault();
  332. event.target.innerHTML = '';
  333. const data = event.dataTransfer.getData("text/plain");
  334. const element = document.querySelector(`#${data}`);
  335. element.removeAttribute("ondragstart");
  336. element.setAttribute("ondragstart", "dragStart(event, '" + zone + "')");
  337. //element.appendTo("#newsList");
  338. if ( element.innerHTML.indexOf('remove') < 0) {
  339. element.innerHTML += ' <a class="remove" data-x="' + element.id + '">(X)</a>';
  340. }
  341. //console.log(element.innerHTML);
  342. //element.innerHTML = element.innerHTML.replace("dragStart(event, '')", "dragStart(event, '" + zone + "')");
  343. event.currentTarget.style.background = 'white'
  344. try {
  345. event.target.appendChild(element);
  346. } catch (error) {
  347. console.warn("you can't move the item to the same place")
  348. }
  349. }
  350. else
  351. {
  352. var el_from = $("[data-zone='" + from_zone + "']");
  353. const data = event.dataTransfer.getData("text/plain");
  354. const element = document.querySelector(`#${data}`);
  355. element.removeAttribute("ondragstart");
  356. element.setAttribute("ondragstart", "dragStart(event, '" + zone + "')");
  357. // var new_el = element.cloneNode(true);
  358. var f = event.target.innerHTML;
  359. f = f.replace("dragStart(event, '" + zone + "')", "dragStart(event, '" + from_zone + "')");
  360. el_from.append(f);
  361. event.target.innerHTML = '';
  362. try {
  363. event.target.appendChild(element);
  364. } catch (error) {
  365. console.warn("you can't move the item to the same place")
  366. }
  367. /*
  368. const data_bbb = event.dataTransfer.getData("text/plain");
  369. const bbb_element = document.querySelector(`#${data_bbb}`);
  370. const data_aaa = from_event.dataTransfer.getData("text/plain");
  371. console.log(data_aaa);
  372. const aaa_element = document.querySelector(`#${data_aaa}`);
  373. event.target.innerHTML = '';
  374. from_event.target.innerHTML = '';
  375. try {
  376. event.target.appendChild(bbb_element);
  377. from_event.target.appendChild(aaa_element);
  378. } catch (error) {
  379. console.warn("you can't move the item to the same place")
  380. }*/
  381. }
  382. }
  383. }
  384. $("#txtSearch").keydown(function(event) {
  385. if (event.keyCode == 13) {
  386. event.preventDefault();
  387. }
  388. });
  389. function filter (element,what) {
  390. var value = $(element).val().toLowerCase();
  391. $('.elements').hide();
  392. $('.elements:contains(' + value + ')').show();
  393. };
  394. jQuery.expr[':'].contains = function(a, i, m) {
  395. return jQuery(a).text().toLowerCase()
  396. .indexOf(m[3].toLowerCase()) >= 0;
  397. };
  398. jQuery.fn.sortElements = (function () {
  399. var sort = [].sort;
  400. return function (comparator, getSortable) {
  401. getSortable = getSortable || function () {
  402. return this;
  403. };
  404. var placements = this.map(function () {
  405. var sortElement = getSortable.call(this),
  406. parentNode = sortElement.parentNode,
  407. // Since the element itself will change position, we have
  408. // to have some way of storing its original position in
  409. // the DOM. The easiest way is to have a 'flag' node:
  410. nextSibling = parentNode.insertBefore(
  411. document.createTextNode(''),
  412. sortElement.nextSibling);
  413. return function () {
  414. if (parentNode === this) {
  415. throw new Error(
  416. "You can't sort elements if any one is a descendant of another.");
  417. }
  418. // Insert before flag:
  419. parentNode.insertBefore(this, nextSibling);
  420. // Remove flag:
  421. parentNode.removeChild(nextSibling);
  422. };
  423. });
  424. return sort.call(this, comparator).each(function (i) {
  425. placements[i].call(getSortable.call(this));
  426. });
  427. };
  428. })();
  429. function sortNews()
  430. {
  431. $('#newsList > h4').sortElements(function(a, b){
  432. return parseInt($(a).attr('order')) < parseInt($(b).attr('order')) ? 1 : -1;
  433. });
  434. }
  435. </script>
  436. @stop