Monday, 2 January 2017

Create Jquery function for check element exist

jQuery.fn.exists = function(){return this.length>0;}


Example :

if($(".spl_req").exists()){   console.log("Element Exist");}else{
 console.log("Element Not Exist");
} 

Friday, 30 December 2016

Select tag in rails form to disply selected value OR accessing Table value in form object

 
= f.select :traveler_id
  ,options_for_select( 
                  @individual_trips.map{|d| [d.individual.full_name,d.individual_id]}
                 ,f.object.traveler_id
                )
 
 
OR
 
 
Accessing Values by form object 
 
 
f.object.id
f.object.name 

Friday, 16 December 2016

Custome Scrollbar in HTML Files mcustomscrollbars

DropZone Js with ajax & Multiple photo and file upload functionality

HTML=======>
 
%form.uploadform.dropzone.no-margin.dz-clickable{:action => ""}
  .dz-default.dz-message    %span Drop your Cover Picture here
  .event_photo_upload_btn#event_photo_upload_btn Upload



JAVASCRIPT====>>
Dropzone.autoDiscover = false; // keep this line if you have multiple dropzones in the same page

$(".uploadform").dropzone({  autoProcessQueue: false, // To stop auto upload  acceptedFiles: "image/jpeg",  url: 'file_photo_upload',  //maxFiles: 1, // Number of files at a time  //maxFilesize: 1, //in MB  maxfilesexceeded: function(file)  {    alert('You have uploaded more than 1 Image. Only the first file will be uploaded!');  },  init: function () {     var submitButton = document.querySelector("#event_photo_upload_btn")         myDropzone = this; // closure
     submitButton.addEventListener("click", function() {         //var status_message = $("#status_txtbox_post").val().trim();         var files = myDropzone.files.length;         console.log("No of files ="+files);         if(files > 0){           myDropzone.processQueue(); // To upload files         }else{              $("#my-dropzone").attr('style','border-color:red !important');         }     });
    this.on("sending", function(file, xhr, data) {      var event_id = $("#event_id").val();
      data.append("attachable_id", event_id);      data.append("event_id", event_id);      data.append("trip_id", trip_id);      data.append("isPhoto", true);      data.append("isDoc", false);      data.append("attachable_type", 'DailyItinerary');    });  },  success: function (response) {    var x = JSON.parse(response.xhr.responseText);    $('.icon').hide(); // Hide Cloud icon    //$('#uploader').modal('hide'); // On successful upload hide the modal window    $('.img').attr('src',x.img); // Set src for the image    $('.thumb').attr('src',x.thumb); // Set src for the thumbnail    $('img').addClass('imgdecoration');    //this.removeAllFiles(); // This removes all files after upload to reset dropzone for next upload    console.log('Image -> '+x.img+', Thumb -> '+x.thumb); // Just to return the JSON to the console.  },  addRemoveLinks: true,  removedfile: function(file) {    var _ref; // Remove file on clicking the 'Remove file' button    return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;  }}); 

Wednesday, 14 December 2016

PHP Laravel start with project

composer create-project --prefer-dist laravel/laravel blog

New project for particular version ====>
composer create-project laravel/laravel=4.1.27 your-project-name --prefer-dist
2) Create database connection ==>
 update details in project/.env file 


3) After Create Auth by:
  php artisan make:auth
  php artisan migrate 
  php artisan config:cache


4) Resister a user & login

5)   

Tuesday, 13 December 2016

Sub Drop-Down bolck Bootstrap


    <!-- Styles -->
    <style>

        .dropdown-submenu {
            position: relative;
        }

        .dropdown-submenu>.dropdown-menu {
            top: 0;
            left: 100%;
            margin-top: -6px;
            margin-left: -1px;
            -webkit-border-radius: 0 6px 6px 6px;
            -moz-border-radius: 0 6px 6px;
            border-radius: 0 6px 6px 6px;
        }

        .dropdown-submenu:hover>.dropdown-menu {
            display: block;
        }

        .dropdown-submenu>a:after {
            display: block;
            content: " ";
            float: right;
            width: 0;
            height: 0;
            border-color: transparent;
            border-style: solid;
            border-width: 5px 0 5px 5px;
            border-left-color: #ccc;
            margin-top: 5px;
            margin-right: -10px;
        }

        .dropdown-submenu:hover>a:after {
            border-left-color: #fff;
        }

        .dropdown-submenu.pull-left {
            float: none;
        }

        .dropdown-submenu.pull-left>.dropdown-menu {
            left: -100%;
            margin-left: 10px;
            -webkit-border-radius: 6px 0 6px 6px;
            -moz-border-radius: 6px 0 6px 6px;
            border-radius: 6px 0 6px 6px;
        }
    </style>


<ul class="nav navbar-nav navbar-right">
  <li class="dropdown">
        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
                                    Main
                                </a>
                                 <ul class="dropdown-menu" role="menu">

                                    <li>
                                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
                                            Login
                                        </a>
                                    </li>

                                    <li class="dropdown-submenu">
                                        <a href="#">Even More..</a>

                                        <ul class="dropdown-menu">
                                            <li><a href="#">3rd level</a></li>

                                           <li class="dropdown-submenu">
                                              <a href="#">Even More..</a>
                                              <ul class="dropdown-menu">
                                                  <li><a href="#">4rd level</a></li>
                                                   <li class="dropdown-submenu">
                                                      <a href="#">Even More..</a>
                                                      <ul class="dropdown-menu">
                                                          <li><a href="#">5rd level</a></li>
                                                          <li><a href="#">5rd level</a></li>
                                                      </ul>
                                                   </li>
                                              </ul>
                                           </li>


                                        </ul>

                                    </li>

                                </ul>
                            </li>

</ul>