$('#dateController').on('change', function() {
    //alert( this.value );
    $('body').attr('class','').addClass('last-'+this.value).addClass('theme-blush');
  });

  $('#dateController').on('change', function() {
    // اذا كان الخيار اخر 7 ايام  
    if(this.value == '7'){
        // حالات الطلب 
       $('.order-s-waiting').text(15);
       $('.order-s-complate').text(30);
       $('.order-s-consle').text(5);

        // المبيعات والعروض والتقييمات
        $('.total-pice').text('$4,516');
        $('.total-offers').text('851');
        $('.total-raitng').text('215');

    }
    // اذا كان الخيار اخر 30 ايام  
    if(this.value == '30'){
         // حالات الطلب 
       $('.order-s-waiting').text(25);
       $('.order-s-complate').text(80);
       $('.order-s-consle').text(25);

        // المبيعات والعروض والتقييمات
        $('.total-pice').text('$9,566');
        $('.total-offers').text('1251');
        $('.total-raitng').text('2515');
    }
    // اذا كان الخيار اخر سنة  
    if(this.value == '365'){
         // حالات الطلب 
       $('.order-s-waiting').text(40);
       $('.order-s-complate').text(170);
       $('.order-s-consle').text(40);

        // المبيعات والعروض والتقييمات
        $('.total-pice').text('$24,566');
        $('.total-offers').text('1951');
        $('.total-raitng').text('7515');

    }

    // اذا كان الخيار منذ البداية  
    if(this.value == '0'){
         // حالات الطلب 
       $('.order-s-waiting').text(42);
       $('.order-s-complate').text(3250);
       $('.order-s-consle').text(120);

        // المبيعات والعروض والتقييمات
        $('.total-pice').text('$34,566');
        $('.total-offers').text('2451');
        $('.total-raitng').text('9515');

    }
  });
$(document).on('mouseover', '.dropdown-toggle' , function(){
  $(this).closest('.dropdown').fadeIn(500).find('.dropdown-menu').fadeIn(500);
});
$(document).on('mouseout', '.dropdown-toggle' , function(){
  $(this).closest('.dropdown').removeAttr('style').find('.dropdown-menu').removeAttr('style')
});




  // $(window).load(function() {
  //   var width = $(window).width();
  //   if (width < 780){

  //    $('.sidebar').addClass('ls-toggle-menu');
  //    $('body').addClass('ls-toggle-menu');
  //    $('#Table').addClass('table-responsive');
  //   }
  // });


  $(document).ready(function(){
	
    var width = $(window).width();
    if (width < 780){
      $("body").addClass('ls-toggle-menu');
      $('.ls-toggle-menu section.content').css('margin-left','0');
      $('html').css('overflow-x','hidden');
      $('#Table').addClass('table-responsive');
    }

   
    });






    // for project options

    $(document).on('click' , '.text-sa-input' , function (e) {

      e.preventDefault()
      $("#the_content").append(
          '<div class="field">\n' +
          '<div class="setting">\n' +
          '                                <div class="edit" data-toggle="modal" data-target="#textModalCenter"><i class="zmdi zmdi-edit text-primary"></i></div>\n' +
          '                                <div class="delet"><i class="zmdi zmdi-delete"></i></div>\n' +
          '                            </div>'+
          '                            <div class="form-group item-input">\n' +
          '                                <label>Text</label>\n' +
          '                                <input type="text" class="form-control" placeholder="">\n' +
          '                            </div>\n' +
          '                        </div>'
      ).find('.delet').click(function () {
          e.preventDefault();
          Swal.fire({
              title: 'Are you sure?',
              text: "You won't be able to revert this!",
              icon: 'warning',
              showCancelButton: true,
              confirmButtonColor: '#3085d6',
              cancelButtonColor: '#d33',
              confirmButtonText: 'Yes, delete it!'
          }).then((result) => {
              if (result.value) {
                  Swal.fire(
                      'Deleted!',
                      'Your file has been deleted.',
                      'success'
                  );
                  $(this).closest('.field').fadeOut();
              }
          })
      });
  });

  $(document).on('dblclick' , '#the_content label' , function () {
    $(this).closest('.field').find('.setting .edit').click();
});

$(document).on('click' , '.setting .edit' , function (e) {
  $(this).closest('.field').addClass('editing').siblings().removeClass('editing');
  var titleInput =  $(this).closest('.field').find('.item-input label').text();
  var holderInput =  $(this).closest('.field').find('.form-group .form-control ').attr('placeholder');
  $('.modal-body input.title').val(titleInput);
  $('.modal-body input.PlaceHolder').val(holderInput);
});

//click save Pob up
$(document).on('click' , '.save-add-parameter' , function (e) {
  var titleEdit =  $('.modal-body input.title').val();
  var PlaceHolderEdit =  $('.modal-body input.PlaceHolder').val();

  $('.field.editing').find('.item-input label').text(titleEdit);
  $('.field.editing').find('.form-control').attr('placeholder',PlaceHolderEdit);
});



// to select input



$(document).on('click' , '.select-sa-input' , function (e) {
  e.preventDefault()
  $("#the_content").append(
      '<div class="field editing">\n' +
      '                            <div class="setting">\n' +
      '                                <div data-toggle="modal" data-target="#selectModalCenter" class="edit"><i class="zmdi zmdi-edit text-primary"></i></div>\n' +
      '                                <div class="delet"><i class="zmdi zmdi-delete"></i></div>\n' +
      '                            </div>\n' +
      '\n' +
      '                            <div class="form-group item-input">\n' +
      '                                <label>Dropdown</label>\n' +
      '                                <select class="form-control">\n' +
      '                                    <option>Default select</option>\n' +
      '                                </select>\n' +
      '                            </div>\n' +
      '                        </div>'
  ).find('.delet').click(function (e) {
      e.preventDefault();
      Swal.fire({
          title: 'Are you sure?',
          text: "You won't be able to revert this!",
          icon: 'warning',
          showCancelButton: true,
          confirmButtonColor: '#3085d6',
          cancelButtonColor: '#d33',
          confirmButtonText: 'Yes, delete it!'
      }).then((result) => {
          if (result.value) {
              Swal.fire(
                  'Deleted!',
                  'Your file has been deleted.',
                  'success'
              );
              $(this).closest('.field').fadeOut();
          }
      })
  });
});


$(document).on('dblclick' , '#the_content label' , function () {
  $(this).closest('.field').find('.setting .edit').click();
});

$(document).on('click' , '.setting .edit' , function (e) {
  $(this).closest('.field').addClass('editing').siblings().removeClass('editing');
  var titleInput =  $(this).closest('.field').find('.item-input label').text();
  var holderInput =  $(this).closest('.field').find('.form-group .form-control ').attr('placeholder');
  $('.modal-body input.title').val(titleInput);
  $('.modal-body input.PlaceHolder').val(holderInput);
});

//click save Pob up
$(document).on('click' , '.save-add-parameter' , function (e) {
  var titleEdit =  $('.modal-body input.title').val();
  var PlaceHolderEdit =  $('.modal-body input.PlaceHolder').val();

  $('.field.editing').find('.item-input label').text(titleEdit);
  $('.field.editing').find('.form-control').attr('placeholder',PlaceHolderEdit);
});

$(document).on('click' , '.save-add-parameter-select' , function (e) {
  $('.result-add').html('');
  var titleEdit =  $('.select-modal input.title').val();
  var PlaceHolderEdit =  $('.select-modal input.PlaceHolder').val();

  $('.field.editing').find('.item-input label').text(titleEdit);
  $('.field.editing').find('.form-control').attr('placeholder',PlaceHolderEdit);
});
//add option in select pob up

$(document).on('keypress', '.options-input', function(e) {
  var op = $(this).val();
  //e.preventDefault()
  var key = e.which;
  if (key == 13)
  {

      $('.result-add').append(
          '<li>'+op+'</li>'
      );
      $('.field.editing').find('.form-control').append(
          '<option>'+op+'</option>'
      );
      $(this).val('');

  }
});






// redio



$(document).on('click' , '.single-sa-input' , function (e) {
    e.preventDefault()
    $("#the_content").append(
        ' <div class="field">\n' +
        '                                            <div class="setting">\n' +
        '                                                <div class="edit" data-toggle="modal" data-target="#singleModalCenter"><i class="zmdi zmdi-edit text-primary"></i></div>\n' +
        '                                                <div class="delet"><i class="zmdi zmdi-delete"></i></div>\n' +
        '                                            </div>                            <div class="form-group item-input">\n' +
        '                                                <label class="title-l">Text</label>\n' +
        '                                                <div class=" row list-checkbox">\n' +
        '                                                    \n' +
        '                                                    <div class="col-auto exampel">\n' +
        '                                                        <div class="radio">\n' +
        '                                                            <input id="" type="radio">\n' +
        '                                                            <label for="">\n' +
        '                                                                    option 1\n' +
        '                                                            </label>\n' +
        '                                                        </div>\n' +
        '                                                    </div>\n' +
        '                                                \n' +
        '                                                </div>\n' +
        '                                            </div>\n' +
        '                                        </div>'
    ).find('.delet').click(function (e) {
        e.preventDefault();
        Swal.fire({
            title: 'Are you sure?',
            text: "You won't be able to revert this!",
            icon: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: 'Yes, delete it!'
        }).then((result) => {
            if (result.value) {
                Swal.fire(
                    'Deleted!',
                    'Your file has been deleted.',
                    'success'
                );
                $(this).closest('.field').fadeOut();
            }
        })
    });
});


$(document).on('dblclick' , '#the_content .title-l' , function () {
    $(this).closest('.field').find('.setting .edit').click();
});

$(document).on('click' , '.setting .edit' , function (e) {
    $(this).closest('.field').addClass('editing').siblings().removeClass('editing');
    var titleInput =  $(this).closest('.field').find('.item-input .title-l').text();
    var holderInput =  $(this).closest('.field').find('.form-group .form-control ').attr('placeholder');
    $('.modal-body input.title').val(titleInput);
    $('.modal-body input.PlaceHolder').val(holderInput);
});

//click save Pob up
$(document).on('click' , '#singleModalCenter .save-add-parameter-single' , function (e) {
    var titleEdit =  $('#singleModalCenter .modal-body input.title').val();
    var PlaceHolderEdit =  $('#singleModalCenter .modal-body input.PlaceHolder').val();

    $('.field.editing').find('.item-input .title-l').text(titleEdit);
    $('.field.editing').find('.form-control').attr('placeholder',PlaceHolderEdit);
});

$(document).on('click' , '#singleModalCenter .save-add-parameter-single' , function (e) {
    $('#singleModalCenter .result-addd').html('');
    var titleEdit =  $('#singleModalCenter .select-modal input.title').val();
    var PlaceHolderEdit =  $('#singleModalCenter .select-modal input.PlaceHolder').val();

    $('.field.editing').find('.item-input .title-l').text(titleEdit);
    $('.field.editing').find('.form-control').attr('placeholder',PlaceHolderEdit);
});
//add option in select pob up


$(document).on('click','#addOptionSingle',function(e){
  e.preventDefault()
  var op_title_single = $('#singleModalCenter .options-input22').val();
  var op_price_single = $('#singleModalCenter .options-input22-price').val();
  var op_thisbasic_single = $('#singleModalCenter #thisbasic');
 if((op_thisbasic_single).is(':checked')){
    op_thisbasic_single ='checked';
    $('#singleModalCenter #thisbasic').prop('checked', false).attr('disabled','');
    

  }
    
      $('#singleModalCenter .result-addd').append(
          '<li>'+op_title_single+'</li>'
      );
      $('.field.editing').find('.list-checkbox').find('.exampel').remove();
      $('.field.editing').find('.list-checkbox').append('<div class="col-auto remove-click" >\n' +
          '                                                        <div  class="radio">\n' +
          '                                                            <input id="" type="radio" ' + op_thisbasic_single
    
           + '>\n' +
          '                                                            <label for="">\n' +
          '                                                                '+op_title_single+'<span class="price ml-2 text-success">' + op_price_single + '</span>   \n' +
          '                                                            </label>\n' +
          '                                                        </div>\n' +
          '                                                    </div>').find('.remove-click').click(function(){
          var opCheckedIs =   $(this).find('input').is(':checked');
          if(opCheckedIs){
            $('#singleModalCenter #thisbasic').prop('checked', false).removeAttr('disabled');
          }
            $(this).remove();
          });


      $('#singleModalCenter .options-input22').val('');
      $('#singleModalCenter .options-input22-price').val('');
  

});


// redio



$(document).on('click' , '.multy-sa-input' , function (e) {
  e.preventDefault()
  $("#the_content").append(
      ' <div class="field">\n' +
      '                                            <div class="setting">\n' +
      '                                                <div class="edit" data-toggle="modal" data-target="#multyModalCenter"><i class="zmdi zmdi-edit text-primary"></i></div>\n' +
      '                                                <div class="delet"><i class="zmdi zmdi-delete"></i></div>\n' +
      '                                            </div>                            <div class="form-group item-input">\n' +
      '                                                <label class="title-l">Text</label>\n' +
      '                                                <div class=" row list-checkbox">\n' +
      '                                                    \n' +
      '                                                    <div class="col-auto exampel">\n' +
      '                                                        <div class="checkbox">\n' +
      '                                                            <input id="" type="checkbox">\n' +
      '                                                            <label for="">\n' +
      '                                                                    option 1\n' +
      '                                                            </label>\n' +
      '                                                        </div>\n' +
      '                                                    </div>\n' +
      '                                                \n' +
      '                                                </div>\n' +
      '                                            </div>\n' +
      '                                        </div>'
  ).find('.delet').click(function (e) {
      e.preventDefault();
      Swal.fire({
          title: 'Are you sure?',
          text: "You won't be able to revert this!",
          icon: 'warning',
          showCancelButton: true,
          confirmButtonColor: '#3085d6',
          cancelButtonColor: '#d33',
          confirmButtonText: 'Yes, delete it!'
      }).then((result) => {
          if (result.value) {
              Swal.fire(
                  'Deleted!',
                  'Your file has been deleted.',
                  'success'
              );
              $(this).closest('.field').fadeOut();
          }
      })
  });
});


$(document).on('dblclick' , '#the_content .title-l' , function () {
  $(this).closest('.field').find('.setting .edit').click();
});

$(document).on('click' , '.setting .edit' , function (e) {
  $(this).closest('.field').addClass('editing').siblings().removeClass('editing');
  var titleInput =  $(this).closest('.field').find('.item-input .title-l').text();
  var holderInput =  $(this).closest('.field').find('.form-group .form-control ').attr('placeholder');
  $('.modal-body input.title').val(titleInput);
  $('.modal-body input.PlaceHolder').val(holderInput);
});

//click save Pob up
$(document).on('click' , '#multyModalCenter .save-add-parameter-multy' , function (e) {
  var titleEdit =  $('#multyModalCenter .modal-body input.title').val();
  var PlaceHolderEdit =  $('#multyModalCenter .modal-body input.PlaceHolder').val();

  $('.field.editing').find('.item-input .title-l').text(titleEdit);
  $('.field.editing').find('.form-control').attr('placeholder',PlaceHolderEdit);
});

$(document).on('click' , '#multyModalCenter .save-add-parameter-multy' , function (e) {
  $('#multyModalCenter .result-addd').html('');
  var titleEdit =  $('#multyModalCenter .select-modal input.title').val();
  var PlaceHolderEdit =  $('#multyModalCenter .select-modal input.PlaceHolder').val();

  $('.field.editing').find('.item-input .title-l').text(titleEdit);
  $('.field.editing').find('.form-control').attr('placeholder',PlaceHolderEdit);
});
//add option in select pob up




$(document).on('click','#addOptionMylty',function(e){
  e.preventDefault()
  var op_title_mylty = $('#multyModalCenter .options-input22').val();
  var op_price_mylty = $('#multyModalCenter .options-input22-price').val();
  var op_thisbasic_mylty = $('#multyModalCenter #thisbasic_Mylty');
 if((op_thisbasic_mylty).is(':checked')){
    op_thisbasic_mylty ='checked';
    $('#multyModalCenter #thisbasic_Mylty').prop('checked', false).attr('disabled','');
    

  }
    
      $('#multyModalCenter .result-addd').append(
          '<li>'+op_title_mylty+'</li>'
      );
      $('.field.editing').find('.list-checkbox').find('.exampel').remove();
      $('.field.editing').find('.list-checkbox').append('<div class="col-auto remove-click " >\n' +
          '                                                        <div  class="checkbox ">\n' +
          '                                                            <input id="" type="checkbox" ' + op_thisbasic_mylty
    
           + '>\n' +
          '                                                            <label for="">\n' +
          '                                                                '+op_title_mylty+'<span class="price ml-2 text-success">' + op_price_mylty + '</span>   \n' +
          '                                                            </label>\n' +
          '                                                        </div>\n' +
          '                                                    </div>').find('.remove-click').click(function(){
            var opCheckedIs =   $(this).find('input').is(':checked');
            if(opCheckedIs){
              $('#multyModalCenter #thisbasic_Mylty').prop('checked', false).removeAttr('disabled');
            }
            $(this).remove();
          });
      $('#multyModalCenter .options-input22').val('');
      $('#multyModalCenter .options-input22-price').val('');

});



// click farma



// steps 


$(document).on('click' , '.all-steps > li' , function () {

  var step1 = $(this).hasClass('card-li');
  var step2 = $(this).hasClass('address-li');

  if(step1){
      $(this).addClass('active').siblings().removeClass('active');
      $('.all-content .cart-content').addClass('active').siblings().removeClass('active');
   
  }
  if(step2){
  
      $(this).addClass('active').siblings().removeClass('active');
      $('.all-content .address-content').addClass('active').siblings().removeClass('active');
  }

});
$(document).ready(function () {
  $('#next').addClass('next-cart');
  $('#prev').hide();
});
$(document).on('click' , '#next.next-cart' , function (e) {
  e.preventDefault();
  $('.address-li').addClass('active').siblings().removeClass('active');
  $('.all-content .address-content').addClass('active').siblings().removeClass('active');
  $(this).removeClass('next-cart').addClass('next-address');
  $('#prev').show().addClass('prev-address');
});

$(document).on('click' , '#next.next-address' , function (e) {
  e.preventDefault();
  $('.summary-li').addClass('active').siblings().removeClass('active');
  $('.all-content .summary-content').addClass('active').siblings().removeClass('active');
  $(this).removeClass('next-address').addClass('next-summary');
  $('#prev').show().addClass('prev-summary');
});

