zoukankan      html  css  js  c++  java
  • jquery插件开发示例

    /****通用部分 BEGIN *****/
    $.fn.sidebar = function(options) { var defaults = { event: 'click' }, settings = $.extend({}, defaults, options); return this.each(function() { return new Sidebar(this, settings); });/}; /****通用部分 END *****/ function Sidebar(el, settings) { this.$sidebar = $(el); this.settings=settings; this.$foldPanel =this.$sidebar.find('.fold'); this.$unFoldPanel = this.$sidebar.find('.unfold'); this.init(); } Sidebar.prototype = { init: function() { var _self=this; _self.$sidebar.on('fold', $.proxy(_self.fold, _self)); _self.$sidebar.on('unfold', $.proxy(_self.unfold, _self)); _self.$sidebar.find('.fold_btn').on(_self.settings.event, function(e) { e.preventDefault(); _self.$sidebar.trigger('fold'); }); _self.$sidebar.find('.unfold_btn').on(_self.settings.event, function(e) { e.preventDefault(); _self.$sidebar.trigger('unfold'); }); }, fold: function() { var self = this; self.$unFoldPanel.animate({ 40 }, function() { $(this).hide(); self.$foldPanel.show(); }); }, unfold: function() { var self = this; self.$foldPanel.hide(); self.$unFoldPanel.show(function() { $(this).animate({ 200 }); }); } };
  • 相关阅读:
    HDU 1159 Common Subsequence 动态规划
    poj2349 Arctic Network
    hdu1596 find the safest road
    poj 1011
    二进制枚举
    codeforces 626E Simple Skewness
    code for 1
    painting fence
    codeforces 797c minimal string
    POJ 3977
  • 原文地址:https://www.cnblogs.com/byronvis/p/5208161.html
Copyright © 2011-2022 走看看