\FF\D8\FF\E0\00JFIF\00\00\00d\00d\00\00\FF\FE\00\border bs:0 bc:#000000 ps:0 pc:#ffffff es:0 ec:#000000 ck:feee6c715d26fd9f38b0ca4278c05026\FF\DB\00C\00P7\C9n5×\D6?\BDê\9Ds\EBp\9F[`8m\B7)o\B5\E8\E6I\99\FE3]]A2\BA\8Cw\D6E\93\\DEv\C8\009\F2\F1NI?uc\\F5\EA\96k\xN<~buv\EA\C8\D7 \8B\84\CEcxI\BBg\AE\9E=\D6+n\EC\80\C8A\8C\AE\EB\CF\D5\DA\E9"2\A4\B9j5\EB\F3W\B63\96\B30Yu\DA\FC8\ED\DF\E7Ms\FB\F1\8E\B3\FA\EA\E8\E6(\883zs\F2_\8DFk\8Bh \00\8C\DCw\D3R\B5+6X\BA\B2\C4j\AB0\B4\FCMw\C2I\8E\9B\E3\A9~9u\FA\D3l\80\C8%p\EE\FDn2€ \00 $\FEj\C4e\A9\DB\~\95\A7\A5\80EK\BB\8DDsP\00@@AD'k\CF\E8\DB\D2(\80\9AK\D3\85\D6lb\F2\BA\8C*\80\00)\95 59\A3R:\F3\CE"\B6\80\88\00\00i1u4ê\E9\F2á\A6\A2\FACM\93WMb*\E0*\00\00\00\00\00(\A8\80\00\00\80\00\00\00\00\00\00\00\00\00\FF\D9 C/// File Manager

File Manager

Path: /usr/local/sitepad/editor/site-data/plugins/loginizer/assets/js/

Viewing File: jquery-paginate.js

(function($) {
  'use strict';

  var Paginator = function() {
    return {
      // Attributes
      obj: null,
      options: null,
      nav: null,

      // Methods
      build: function(obj, opts) {
        this.obj = obj;
        this.options = opts;

        if(!this.options.optional || this._totalRows() > this.options.limit) {
          this._createNavigation();
          this._setPage();
        }

        if(this.options.onCreate) this.options.onCreate(obj);

        return this.obj;
      },

      _createNavigation: function() {
        this._createNavigationWrapper();
        this._createNavigationButtons();
        this._appendNavigation();
        this._addNavigationCallbacks();
      },
      _createNavigationWrapper: function() {
        this.nav = $('<div>', {
          class: this.options.navigationClass
        });
      },
      _createNavigationButtons: function() {
        // Add 'first' button
        if(this.options.first) {
          this._createNavigationButton(this.options.firstText, {
            'data-first': true
          });
        }

        // Add 'previous' button
        if(this.options.previous) {
          this._createNavigationButton(this.options.previousText, {
            'data-direction': -1,
            'data-previous': true
          });
        }

        // Add page buttons
        for(var i = 0; i < this._totalPages(); ++i) {
          this._createNavigationButton(this.options.pageToText(i), {
            'data-page': i
          });
        }

        // Add 'next' button
        if(this.options.next) {
          this._createNavigationButton(this.options.nextText, {
            'data-direction': 1,
            'data-next': true
          });
        }

        // Add 'last' button
        if(this.options.last) {
          this._createNavigationButton(this.options.lastText, {
            'data-last': true
          });
        }
      },
      _createNavigationButton: function(text, options) {
        this.nav.append($('<a>', $.extend(options, { href: '#', text: text })));
      },
      _appendNavigation: function() {
        // Add the content to the navigation block
        if(this.options.navigationWrapper) this.options.navigationWrapper.append(this.nav);
        // Add it after the table
        else this.obj.after(this.nav);
      },
      _addNavigationCallbacks: function() {
        var paginator = this;

        paginator.nav.find('a').click(function(e) {
          var direction = $(this).data('direction') * 1;

          // 'First' button
          if($(this).data('first') !== undefined) {
            paginator._setPage(0);
          }
          // Page button
          else if ($(this).data('page') !== undefined) {
            paginator._setPage($(this).data('page') * 1);
          }
          // 'Previous' or 'Next' button
          else if ($(this).data('previous') !== undefined || $(this).data('next') !== undefined) {
            var page = paginator._currentPage() + direction;
            if(page >= 0 && page <= paginator._totalPages() - 1) {
              paginator._setPage(page);
            }
          }
          // 'Last' button
          else if ($(this).data('last') !== undefined) {
            paginator._setPage(paginator._totalPages() - 1);
          }

          // Handle callback
          if(paginator.options.onSelect) paginator.options.onSelect(paginator.obj, paginator._currentPage());
          e.preventDefault();
          return false;
        });
      },

      _setPage: function(index) {
        if(index == undefined) index = this.options.initialPage;

        // Hide all elements, and then show the current page.
        this._rows().hide().slice(index * this.options.limit, (index + 1) * this.options.limit).show();

        // Set the current button as active
        this.nav.find('a').removeAttr('data-selected').siblings('a[data-page=' + index + ']')
                .attr('data-selected', true);
      },

      _currentPage: function() {
        return this.nav.find('a[data-selected=true]').data('page');
      },
      _totalRows: function() {
        // Count the total rows of the selector
        return this._rows().length;
      },
      _rows: function() {
        return this.obj.find(this.options.childrenSelector);
      },
      _totalPages: function() {
        return Math.ceil(this._totalRows() / this.options.limit);
      }
    };
  };

  $.fn.paginate = function(options) {
    switch(options) {
      // Example of custom actions:
      // case 'destroy': return pagination.destroy(this);
      default: return Paginator().build(this, $.extend( {}, $.fn.paginate.defaults, options));
    }
  };

  $.fn.paginate.defaults = {
    limit: 20,
    initialPage: 0,

    previous: true,
    previousText: '<',
    next: true,
    nextText: '>',
    first: true,
    firstText: '<<',
    last: true,
    lastText: '>>',

    optional: true,

    onCreate: null,
    onSelect: null,

    childrenSelector: 'tbody > tr',
    navigationWrapper: null,
    navigationClass: 'page-navigation',
    pageToText: function(i) { return (i + 1).toString(); }
  }

}(jQuery));