Advertisement
dmilosavleski

5 - 1

Dec 25th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.32 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Прва задача</title>
  6. <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
  7. <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
  8. <script src="/resources/demos/external/jquery.bgiframe-2.1.2.js"></script>
  9. <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
  10. <link rel="stylesheet" type="text/css" href="prva.css" />
  11. <script type="text/javascript" src="prva.js"></script>
  12. </head>
  13.  
  14. <style>
  15. body {
  16. font-size: 62.5%;
  17. }
  18. label, input {
  19. display: block;
  20. }
  21. input.text {
  22. margin-bottom: 12px;
  23. width: 95%;
  24. padding: .4em;
  25. }
  26. fieldset {
  27. padding: 0;
  28. border: 0;
  29. margin-top: 25px;
  30. }
  31. h1 {
  32. font-size: 1.2em;
  33. margin: .6em 0;
  34. }
  35. div#users-contain {
  36. width: 350px;
  37. margin: 20px 0;
  38. }
  39. div#users-contain table {
  40. margin: 1em 0;
  41. border-collapse: collapse;
  42. width: 100%;
  43. }
  44. div#users-contain table td, div#users-contain table th {
  45. border: 1px solid #eee;
  46. padding: .6em 10px;
  47. text-align: left;
  48. }
  49. .ui-dialog .ui-state-error {
  50. padding: .3em;
  51. }
  52. .validateTips {
  53. border: 1px solid transparent;
  54. padding: 0.3em;
  55. }
  56. </style>
  57.  
  58.  
  59. <script>
  60. $(function() {
  61. var id = $("#sifra"),
  62. ime = $("#ime"),
  63. lokacija = $("#do"),
  64. klasa = $("#klasa"),
  65. allFields = $([]).add(id).add(ime).add(lokacija),
  66. tips = $(".validateTips");
  67.  
  68. function updateTips(t) {
  69. tips
  70. .text( t )
  71. .addClass( "ui-state-highlight" );
  72. setTimeout(function() {
  73. tips.removeClass( "ui-state-highlight", 1500 );
  74. }, 500 );
  75. }
  76.  
  77. function checkRegexp( o, regexp, n ) {
  78. if ( !( regexp.test( o.val() ) ) ) {
  79. o.addClass( "ui-state-error" );
  80. updateTips( n );
  81. return false;
  82. } else {
  83. return true;
  84. }
  85. }
  86.  
  87. $( "#dialog-form" ).dialog({
  88. autoOpen: false,
  89. height: 400,
  90. width: 350,
  91. modal: true,
  92. buttons: {
  93. "Додади": function() {
  94. var bValid = true;
  95. allFields.removeClass( "ui-state-error" );
  96. bValid = bValid && checkRegexp(id, /^([0-9])+$/i, "Шифрата треба да биде составена единствено од броеви.");
  97.  
  98. if (bValid) {
  99. $("#users tbody").append("<tr>" +
  100. "<td>" + id.val() + "</td>" +
  101. "<td>" + ime.val() + "</td>" +
  102. "<td>" + lokacija.val() + "</td>" +
  103. "<td>" + klasa.val() + "</td>" + "</tr>");
  104. $(this).dialog("close");
  105. }
  106. }, "Откажи": function() {
  107. $(this).dialog("close");
  108. }
  109. }, close: function() {
  110. allFields.val( "" ).removeClass( "ui-state-error" );
  111. }
  112. });
  113.  
  114. $( "#create-user" ).click(function() {
  115. $( "#dialog-form" ).dialog( "open" );
  116. });
  117.  
  118. });
  119. </script>
  120.  
  121. <body>
  122. <div id="dialog-form" title="Create new flight">
  123. <p class="validateTips">
  124. Сите полиња се задолжителни.
  125. </p>
  126. <form>
  127. <fieldset>
  128. <label for="sifra">Шифра</label>
  129. <input type="text" name="sifra" id="sifra" class="text ui-widget-contentui-corner-all" />
  130. <label for="ime">Авиопревозник</label>
  131. <input type="text" name="ime" id="ime" value="" class="text ui-widget-content ui-corner-all" />
  132. <label for="do">До</label>
  133. <input type="text" name="do" id="do" value="" class="text ui-widget-content ui-corner-all" />
  134. <label for="klasa">Класа</label>
  135. <select id="klasa">
  136. <option value="Бизнис">Бизнис</option>
  137. <option value="Економска">Економска</option>
  138. <option value="Прва">Прва</option>
  139. </select>
  140. </fieldset>
  141. </form>
  142. </div>
  143. <div id="users-contain" class="ui-widget">
  144. <h1>Постоечки ставки:</h1>
  145. <table id="users" class="ui-widget ui-widget-content">
  146. <thead>
  147. <tr class="ui-widget-header">
  148. <th>Шифра</th>
  149. <th>Авиопревозник</th>
  150. <th>До</th>
  151. <th>Класа</th>
  152. </tr>
  153. </thead>
  154. <tbody>
  155. <tr>
  156. <td>12331</td>
  157. <td>Wizz Air</td>
  158. <td>London</td>
  159. <td>Бизнис</td>
  160. </tr>
  161. </tbody>
  162. </table>
  163. </div>
  164. <button id="create-user">Додади нова ставка</button>
  165. </body>
  166. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement