Advertisement
rahuldev345

Plugins

Mar 17th, 2015
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 4.18 KB | None | 0 0
  1. /*!
  2.  * Jquery Navigation
  3.  */
  4. $(function() {
  5.    
  6.     var Menu = {
  7.  
  8.         Bind: function()
  9.         {
  10.             $(window).resize(this.AdjustView);
  11.             $('.file_buttons').on('click', o.FileBrowseAction);
  12.             $('input[type="file"]').on('change', o.FileBrowse);
  13.             $('.mainmenu-toggle').on('click', o.MenuToggle);
  14.             $('.sf-menu').bind('resize', this.ScrollAdjust);
  15.             o.AdjustView();
  16.         },
  17.  
  18.         ScrollAdjust: function()
  19.         {
  20.             var height = $(window).height();
  21.         },
  22.  
  23.         MenuToggle: function()
  24.         {
  25.             if( $('body').hasClass('menu-toggle') )
  26.             {
  27.                 $('body').removeClass('menu-toggle');
  28.                 $('body').addClass('opened');
  29.             } else {
  30.                 $('body').addClass('menu-toggle');
  31.                 $('body').removeClass('opened');
  32.             }
  33.         },
  34.  
  35.         AdjustView: function()
  36.         {
  37.             o.width = $(window).width();
  38.             o.height = $(window).height();
  39.  
  40.             if( o.width > 765 )
  41.             {
  42.                 $('.navbar .navbar-header').css("width","240px");
  43.                 if( $('body').hasClass('menu-toggle') )
  44.                 {
  45.                     $('body').removeClass('menu-toggle');
  46.                 }
  47.             } else {
  48.                 $('.navbar .navbar-header').css({
  49.                     width: 'auto',
  50.                     height: '50px',
  51.                     overflow: 'hidden',
  52.                 });
  53.  
  54.                 if( $('body').hasClass('opened') )
  55.                 {
  56.                     return;
  57.                 }
  58.  
  59.                 if( ! $('body').hasClass('menu-toggle') )
  60.                 {
  61.                     $('body').addClass('menu-toggle');
  62.                 }
  63.             }
  64.         },
  65.  
  66.         init: function()
  67.         {
  68.             o = $.extend({}, this);
  69.             o.Bind();
  70.         }
  71.     }
  72.  
  73.     $.fn.Menu = function(){
  74.  
  75.         return this.each(function(){
  76.             var menu = Object.create(Menu);
  77.             menu.init();
  78.         });
  79.     }
  80. });
  81.  
  82. $(function() {
  83.    
  84.     var Navigation = {
  85.  
  86.         bindEvents: function()
  87.         {
  88.             $li = o.navigation.children('li');
  89.             $sel = $li.children('ul').prev('a').addClass('dropdown');
  90.             $sel.bind('click', this.toggleNav)
  91.                     .append('<span class="fa fa-angle-right normal"></span>');
  92.         },
  93.  
  94.         toggleNav: function( e )
  95.         {
  96.             e.preventDefault();
  97.             $this = $(this);
  98.             if($this.hasClass('dropdown'))
  99.             {
  100.                 o.show($this);
  101.                 console.log(o.navigation.height());
  102.             }
  103.         },
  104.  
  105.         show: function( $li )
  106.         {
  107.             $ul = $li.next('ul');
  108.             if( $ul.hasClass('active') ) {
  109.                 $ul.slideUp('fast').removeClass('active');
  110.                 $ul.prev('a').removeClass('active').children('span').removeClass('rotate');
  111.             }
  112.             else {
  113.                 o.destroy();
  114.                 $ul.prev('a').addClass('active');
  115.                 $ul.prev('a').children('span').addClass('rotate');
  116.                 o.$active = $ul.slideDown('fast').addClass('active');
  117.             }
  118.         },
  119.  
  120.         destroy: function()
  121.         {
  122.             $(o.$active).prev('a').removeClass('active');
  123.             $(o.$active).prev('a').children('span').removeClass('rotate');
  124.             $(o.$active).slideUp('fast').removeClass('active');
  125.         },
  126.  
  127.         init: function() {
  128.             o = $.extend({}, this);
  129.             o.navigation = $('.sf-menu');
  130.             o.bindEvents();
  131.         },
  132.     }
  133.  
  134.     $.fn.Navigation = function(){
  135.  
  136.         return this.each(function(){
  137.             var nav = Object.create(Navigation);
  138.             nav.init();
  139.         });
  140.     }
  141.  
  142. });
  143.  
  144. $(function() {
  145.    
  146.     var Dreamline = {
  147.         bind: function()
  148.         {
  149.             o.add_family_details.on('keyup', o.addNominee);
  150.             o.add_applicant_name.on('keyup', o.addBankAccountName);
  151.         },
  152.  
  153.         addNominee: function()
  154.         {
  155.             $this = $(this);
  156.             var html = "";
  157.  
  158.                         ===============================
  159.                         // Please refer image for Result
  160.                         ===============================
  161.             $.each(o.add_family_details, function(index, val) {
  162.                 var option = $(val).val();
  163.                 if( option.length )
  164.                     html += '<option value="' + index + '">' + $(val).val() + '</option>';
  165.             });
  166.             $('select[name="nominee_id"]').html(html);
  167.         },
  168.  
  169.         addBankAccountName: function()
  170.         {
  171.             var text = $(this).val();
  172.             $('input[name="bank_account_name"]').val(text);
  173.         },
  174.  
  175.         init: function()
  176.         {
  177.             var o = $.extend({}, this);
  178.  
  179.             o.add_family_details = $('.family_details');
  180.             o.add_applicant_name = $('input[name="applicant_name"]');
  181.  
  182.             o.addNominee();
  183.             o.bind();
  184.         }
  185.     }
  186.  
  187.     $.fn.Dreamline = function(){
  188.  
  189.         return this.each(function(){
  190.             var dream = Object.create(Dreamline);
  191.             dream.init();
  192.         });
  193.     }
  194.  
  195. });
  196.  
  197. jQuery(document).ready(function($) {
  198.    
  199.     $(document).Menu();
  200.     $(document).Navigation();
  201.         $(document).Dreamline();
  202. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement