Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.50 KB | None | 0 0
  1. <!doctype html>
  2.  
  3. <html lang="en">
  4. <head>
  5.     <meta charset="utf-8" />
  6.     <title>Задача 3</title>
  7.     <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
  8.     <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
  9.     <script src="/resources/demos/external/jquery.bgiframe-2.1.2.js"></script>
  10.     <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
  11.     <style>
  12.         body { font-size: 62.5%; }
  13.         label, input { display:block; }
  14.         label {font-size: 14px;}
  15.         input.text { margin-bottom:12px; width:95%; padding: .4em; }
  16.         fieldset { padding:0; border:0; margin-top:25px; }
  17.         h1 { font-size: 1.2em; margin: .6em 0; }
  18.         div#flights-contain { width: 350px; margin: 20px 0; }
  19.         #reservations { width: 500px; margin: 20px 0; }
  20.         #res {width: 300px; margin-top: 20px;}
  21.         table { margin: 1em 0; border-collapse: collapse; width: 100%; }
  22.         table td, table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
  23.         .ui-dialog .ui-state-error { padding: .3em; }
  24.         .validateTips { border: 1px solid transparent; padding: 0.3em; }
  25.         .ui-autocomplete-category {
  26.             font-weight: bold;
  27.             padding: .2em .4em;
  28.             margin: .8em 0 .2em;
  29.             line-height: 1.5;
  30.           }
  31.     </style>
  32.     <script type="text/javascript">
  33.     var flights = [];
  34.    
  35.         $(function() {
  36.         var id = $( "#sifra" ),
  37.             airline = $( "#airline" ),
  38.             flightTo = $( "#flightTo" ),
  39.             category = $("#category");
  40.             allFields = $( [] ).add( id ).add(airline).add(flightTo).add(category),
  41.             tips = $( ".validateTips" );
  42.  
  43.         function updateTips( t ) {
  44.             tips
  45.                 .text( t )
  46.                 .addClass( "ui-state-highlight" );
  47.            // setTimeout(function() {
  48.                 tips.removeClass( "ui-state-highlight", 1500 );
  49.            // }, 0 );
  50.         }
  51.  
  52.         function checkRegexp( o, regexp, n ) {
  53.             if ( !( regexp.test( o.val() ) ) ) {
  54.                 o.addClass( "ui-state-error" );
  55.                 updateTips( n );
  56.                 return false;
  57.             } else {
  58.                 return true;
  59.             }
  60.         }
  61.  
  62.         $( "#dialog-form" ).dialog({
  63.             autoOpen: false,
  64.             height: 350,
  65.             width: 350,
  66.             modal: true,    
  67.             //$("#date").datepicker(),
  68.             buttons: {
  69.                 Додади: function() {
  70.                    
  71.                     var bValid = true;
  72.                     allFields.removeClass( "ui-state-error" );
  73.                     bValid = bValid && checkRegexp( id, /^([0-9])+$/i,"Шифрата треба да биде составена единствено од броеви." );
  74.                    
  75.                     if ( bValid ) {
  76.                    
  77.                         $( "#flights tbody" ).append( "<tr>" +
  78.                             "<td>" + id.val() + "</td>" +
  79.                             "<td>" + airline.val() + "</td>" +
  80.                             "<td>" + flightTo.val() + "</td>" +
  81.                             "<td>" + category.val() + "</td>" +
  82.                         "</tr>" );
  83.            
  84.                          flights.push({
  85.                              label: flightTo.val(),
  86.                              category: category.val(),
  87.                              id: id.val()
  88.                          });
  89.                         // dodadi vo flights listata
  90.                          
  91.  
  92.                         $( this ).dialog( "close" );
  93.                     }
  94.                 },
  95.                 "Откажи": function() {
  96.                     $( this ).dialog( "close" );
  97.                 }
  98.             },
  99.             close: function() {
  100.                 allFields.val( "" ).removeClass( "ui-state-error" );
  101.             }
  102.         });
  103.  
  104.         $( "#create-flight" )
  105.             .button()
  106.             .click(function() {
  107.                 $( "#dialog-form" ).dialog( "open" );
  108.             });
  109.        
  110.  
  111. });
  112.  
  113. $.widget( "custom.catcomplete", $.ui.autocomplete, {
  114.     _create: function() {
  115.       this._super();
  116.       this.widget().menu( "option", "items", "> :not(.ui-autocomplete-category)" );
  117.     },
  118.     _renderMenu: function( ul, items ) {
  119.       var that = this,
  120.         currentCategory = "";
  121.       $.each( items, function( index, item ) {
  122.         var li;
  123.         if ( item.category != currentCategory ) {
  124.           ul.append( "<li class='ui-autocomplete-category'>" + item.category + "</li>" );
  125.           currentCategory = item.category;
  126.         }
  127.         li = that._renderItemData( ul, item );
  128.         if ( item.category ) {
  129.           li.attr( "aria-label", item.category + " : " + item.label );
  130.         }
  131.       });
  132.     }
  133.   });
  134.  
  135.   $(function(){
  136.   $( "#search" ).catcomplete({
  137.                                delay: 0,
  138.                                source: flights
  139.                            });
  140.                              });
  141.  
  142.  
  143.     </script>
  144. </head>
  145. <body>
  146.  
  147. <div id="dialog-form" title="Create new flight">
  148.     <p class="validateTips">Сите полиња се задолжителни.</p>
  149.  
  150.     <form>
  151.     <fieldset>
  152.         <label for="sifra">Шифра</label>
  153.         <input type="text" name="sifra" id="sifra" class="text ui-widget-content ui-corner-all" />
  154.         <label for="airline">Авиопревозник</label>
  155.         <input type="text" name="airline" id="airline" value="" class="text ui-widget-content ui-corner-all" />
  156.         <label for="flightTo">До</label>
  157.         <input type="text" name="flightTo" id="flightTo" value="" class="text ui-widget-content ui-corner-all" />
  158.         <label for="category">Категорија</label>
  159.         <select id="category">
  160.             <option value="Бизнис">Бизнис</option>
  161.             <option value="Економска">Економска</option>
  162.             <option value="Прва класа">Прва класа</option>
  163.         </select>
  164.     </fieldset>
  165.     </form>
  166. </div>
  167.  
  168.  
  169. <div id="flights-contain" class="ui-widget">
  170.     <h1>Летови:</h1>
  171.     <table id="flights" class="ui-widget ui-widget-content">
  172.         <thead>
  173.             <tr class="ui-widget-header ">
  174.                 <th>Шифра</th>
  175.                 <th>Авиопревозник</th>
  176.                 <th>До</th>
  177.                 <th>Класа</th>
  178.             </tr>
  179.         </thead>
  180.         <tbody>
  181.             <tr>
  182.                 <td>12331</td>
  183.                 <td>Wizz Air</td>
  184.                 <td>London</td>
  185.                 <td>Бизнис</td>
  186.             </tr>
  187.         </tbody>
  188.     </table>
  189. </div>
  190. <button id="create-flight">Додади нова ставка</button>
  191.  
  192. <br/><br/>
  193.  
  194. <div id="res">
  195.     <label for="search">Пребарај:</label>
  196.     <input id="search" class="text ui-widget-content ui-corner-all">
  197.  
  198.     <label for="from">Датум од</label>
  199.     <input type="text" id="from" name="from" class="text ui-widget-content ui-corner-all">
  200.     <label for="to">Датум до</label>
  201.     <input type="text" id="to" name="to" class="text ui-widget-content ui-corner-all">    
  202.     <button id="reserve">Резервирај лет</button>
  203. </div>
  204.  
  205.  
  206. <br/>
  207. <table id="reservations" class="ui-widget ui-widget-content">
  208.     <thead>
  209.         <tr class="ui-widget-header">
  210.             <th>Шифра</th>
  211.             <th>Авиопревозник</th>
  212.             <th>До</th>
  213.             <th>Класа</th>
  214.             <th>Датум од</th>
  215.             <th>Датум до</th>
  216.         </tr>
  217.     </thead>
  218.     <tbody>
  219.        
  220.     </tbody>
  221. </table>
  222.  
  223. </body>
  224. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement