Changeset 482368
- Timestamp:
- 12/30/2011 02:53:11 PM (14 years ago)
- Location:
- easycommentspaginate/trunk
- Files:
-
- 2 edited
-
easycommentspaginate.php (modified) (2 diffs)
-
jquery.easyPaginate.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
easycommentspaginate/trunk/easycommentspaginate.php
r481478 r482368 196 196 $nextButtonStatut = get_option('easycommentspaginate_nextButton'); 197 197 198 $output = " $(document).ready(function() {198 $output = "jQuery(document).ready(function($) { 199 199 $('".get_option('easycommentspaginate_paginateContainer')."').easyPaginate({ 200 200 paginateElement: '".get_option('easycommentspaginate_paginateElement')."', … … 217 217 218 218 function setScripts() { 219 wp_deregister_script(array('jquery')); 220 wp_enqueue_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'); 221 wp_enqueue_script('jquery_easycommentspaginate', '/wp-content/plugins/easyCommentsPaginate/jquery.easyPaginate.js', array('jquery')); 219 wp_enqueue_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'); 220 wp_enqueue_script('jquery_easycommentspaginate', '/wp-content/plugins/easyCommentsPaginate/jquery.easyPaginate.js', array('jquery'), '1.0'); 222 221 } 223 222 -
easycommentspaginate/trunk/jquery.easyPaginate.js
r481478 r482368 1 (function($){ 2 $.fn.easyPaginate = function (options) { 3 var defaults = { 4 paginateElement: 'li', 5 hashPage: 'page', 6 elementsPerPage: 50, 7 effect: 'default', 8 slideOffset: 200, 9 firstButton: true, 10 firstButtonText: '<<', 11 lastButton: true, 12 lastButtonText: '>>', 13 prevButton: true, 14 prevButtonText: '<', 15 nextButton: true, 16 nextButtonText: '>', 17 onSomeEvent: function() {} 18 } 1 /* 2 * jQuery easyShare plugin 3 * Update on 28 december 2011 4 * Version 1.0 5 * 6 * Licensed under GPL <http://en.wikipedia.org/wiki/GNU_General_Public_License> 7 * Copyright (c) 2008, Stéphane Litou <[email protected]> 8 * All rights reserved. 9 * 10 This program is free software: you can redistribute it and/or modify 11 it under the terms of the GNU General Public License as published by 12 the Free Software Foundation, either version 3 of the License, or 13 (at your option) any later version. 14 15 This program is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License for more details. 19 20 You should have received a copy of the GNU General Public License 21 along with this program. If not, see <http://www.gnu.org/licenses/>. 22 */ 23 24 jQuery(document).ready(function($) { 25 $.fn.easyPaginate = function (options) { 26 var defaults = { 27 paginateElement: 'li', 28 hashPage: 'page', 29 elementsPerPage: 50, 30 effect: 'default', 31 slideOffset: 200, 32 firstButton: true, 33 firstButtonText: '<<', 34 lastButton: true, 35 lastButtonText: '>>', 36 prevButton: true, 37 prevButtonText: '<', 38 nextButton: true, 39 nextButtonText: '>', 40 onSomeEvent: function() {} 41 } 42 43 return this.each (function (instance) { 44 45 var plugin = Object; 46 plugin.el = $(this); 47 plugin.el.addClass('easyPaginateList'); 48 49 plugin.settings = { 50 pages: 0, 51 objElements: Object, 52 currentPage: 1 53 } 54 55 var getNbOfPages = function() { 56 return Math.ceil(plugin.settings.objElements.length / plugin.settings.elementsPerPage); 57 }; 58 59 var displayNav = function() { 60 htmlNav = '<div class="easyPaginateNav">'; 61 62 if(plugin.settings.firstButton) { 63 htmlNav += '<a href="#'+plugin.settings.hashPage+':1" title="First page" rel="1" class="first">'+plugin.settings.firstButtonText+'</a>'; 64 } 65 66 if(plugin.settings.prevButton) { 67 htmlNav += '<a href="" title="Previous" rel="" class="prev">'+plugin.settings.prevButtonText+'</a>'; 68 } 69 70 for(i = 1;i <= plugin.settings.pages;i++) { 71 htmlNav += '<a href="#'+plugin.settings.hashPage+':'+i+'" title="Page '+i+'" rel="'+i+'" class="page">'+i+'</a>'; 72 }; 73 74 if(plugin.settings.nextButton) { 75 htmlNav += '<a href="" title="Next" rel="" class="next">'+plugin.settings.nextButtonText+'</a>'; 76 } 77 78 if(plugin.settings.lastButton) { 79 htmlNav += '<a href="#'+plugin.settings.hashPage+':'+plugin.settings.pages+'" title="Last page" rel="'+plugin.settings.pages+'" class="last">'+plugin.settings.lastButtonText+'</a>'; 80 } 81 82 htmlNav += '</div>'; 83 plugin.nav = $(htmlNav); 84 plugin.nav.css({ 85 'width': plugin.el.width(), 86 'margin-left': 'auto', 87 }); 88 plugin.el.after(plugin.nav); 89 90 $('.easyPaginateNav a.page, .easyPaginateNav a.first, .easyPaginateNav a.last', plugin).live('click', function(e) { 91 e.preventDefault(); 92 displayPage($(this).attr('rel')); 93 }); 94 95 $('.easyPaginateNav a.prev', plugin).live('click', function(e) { 96 e.preventDefault(); 97 page = plugin.settings.currentPage > 1?parseInt(plugin.settings.currentPage) - 1:1; 98 displayPage(page); 99 }); 100 101 $('.easyPaginateNav a.next', plugin).live('click', function(e) { 102 e.preventDefault(); 103 page = plugin.settings.currentPage < plugin.settings.pages?parseInt(plugin.settings.currentPage) + 1:plugin.settings.pages; 104 displayPage(page); 105 }); 106 }; 107 108 var displayPage = function(page, forceEffect) { 109 if(plugin.settings.currentPage != page) { 110 plugin.settings.currentPage = parseInt(page); 111 offsetStart = (page - 1) * plugin.settings.elementsPerPage; 112 offsetEnd = page * plugin.settings.elementsPerPage; 113 if(typeof(forceEffect) != 'undefined') { 114 eval("transition_"+forceEffect+"("+offsetStart+", "+offsetEnd+")"); 115 }else { 116 eval("transition_"+plugin.settings.effect+"("+offsetStart+", "+offsetEnd+")"); 117 } 118 119 plugin.nav.find('.current').removeClass('current'); 120 plugin.nav.find('a.page:eq('+(page - 1)+')').addClass('current'); 121 122 switch(plugin.settings.currentPage) { 123 case 1: 124 $('.easyPaginateNav a', plugin).removeClass('disabled'); 125 $('.easyPaginateNav a.first, .easyPaginateNav a.prev', plugin).addClass('disabled'); 126 break; 127 case plugin.settings.pages: 128 $('.easyPaginateNav a', plugin).removeClass('disabled'); 129 $('.easyPaginateNav a.last, .easyPaginateNav a.next', plugin).addClass('disabled'); 130 break; 131 default: 132 $('.easyPaginateNav a', plugin).removeClass('disabled'); 133 break; 134 } 135 } 136 }; 137 138 var transition_default = function(offsetStart, offsetEnd) { 139 plugin.currentElements.hide(); 140 plugin.currentElements = plugin.settings.objElements.slice(offsetStart, offsetEnd).clone(); 141 plugin.el.html(plugin.currentElements); 142 plugin.currentElements.show(); 143 }; 144 145 var transition_fade = function(offsetStart, offsetEnd) { 146 plugin.currentElements.fadeOut(); 147 plugin.currentElements = plugin.settings.objElements.slice(offsetStart, offsetEnd).clone(); 148 plugin.el.html(plugin.currentElements); 149 plugin.currentElements.fadeIn(); 150 }; 151 152 var transition_slide = function(offsetStart, offsetEnd) { 153 plugin.currentElements.animate({ 154 'margin-left': plugin.settings.slideOffset * -1, 155 'opacity': 0 156 }, function() { 157 $(this).remove(); 158 }); 159 160 plugin.currentElements = plugin.settings.objElements.slice(offsetStart, offsetEnd).clone(); 161 plugin.currentElements.css({ 162 'margin-left': plugin.settings.slideOffset, 163 'display': 'block', 164 'opacity': 0, 165 'min-width': plugin.el.width() / 2 166 }); 167 plugin.el.html(plugin.currentElements); 168 plugin.currentElements.animate({ 169 'margin-left': 0, 170 'opacity': 1 171 }); 172 }; 173 174 var transition_climb = function(offsetStart, offsetEnd) { 175 plugin.currentElements.each(function(i) { 176 var $objThis = $(this); 177 setTimeout(function() { 178 $objThis.animate({ 179 'margin-left': plugin.settings.slideOffset * -1, 180 'opacity': 0 181 }, function() { 182 $(this).remove(); 183 }); 184 }, i * 200); 185 }); 186 187 plugin.currentElements = plugin.settings.objElements.slice(offsetStart, offsetEnd).clone(); 188 plugin.currentElements.css({ 189 'margin-left': plugin.settings.slideOffset, 190 'display': 'block', 191 'opacity': 0, 192 'min-width': plugin.el.width() / 2 193 }); 194 plugin.el.html(plugin.currentElements); 195 plugin.currentElements.each(function(i) { 196 var $objThis = $(this); 197 setTimeout(function() { 198 $objThis.animate({ 199 'margin-left': 0, 200 'opacity': 1 201 }); 202 }, i * 200); 203 }); 204 }; 205 206 plugin.settings = $.extend({}, defaults, options); 207 208 plugin.currentElements = $([]); 209 plugin.settings.objElements = plugin.el.find(plugin.settings.paginateElement); 210 plugin.settings.pages = getNbOfPages(); 211 if(plugin.settings.pages > 1) { 212 plugin.el.html(); 19 213 20 return this.each (function (instance) { 21 22 var plugin = Object; 23 plugin.el = $(this); 24 plugin.el.addClass('easyPaginateList'); 25 26 plugin.settings = { 27 pages: 0, 28 objElements: Object, 29 currentPage: 1 30 } 31 32 var getNbOfPages = function() { 33 return Math.ceil(plugin.settings.objElements.length / plugin.settings.elementsPerPage); 34 }; 35 36 var displayNav = function() { 37 htmlNav = '<div class="easyPaginateNav">'; 38 39 if(plugin.settings.firstButton) { 40 htmlNav += '<a href="#'+plugin.settings.hashPage+':1" title="First page" rel="1" class="first">'+plugin.settings.firstButtonText+'</a>'; 214 // Here we go 215 displayNav(); 216 217 page = 1; 218 if(document.location.hash.indexOf('#'+plugin.settings.hashPage+':') != -1) { 219 page = parseInt(document.location.hash.replace('#'+plugin.settings.hashPage+':', '')); 220 if(page.length <= 0 || page < 1 || page > plugin.settings.pages) { 221 page = 1; 222 } 223 } 224 225 displayPage(page, 'default'); 41 226 } 42 43 if(plugin.settings.prevButton) { 44 htmlNav += '<a href="" title="Previous" rel="" class="prev">'+plugin.settings.prevButtonText+'</a>'; 45 } 46 47 for(i = 1;i <= plugin.settings.pages;i++) { 48 htmlNav += '<a href="#'+plugin.settings.hashPage+':'+i+'" title="Page '+i+'" rel="'+i+'" class="page">'+i+'</a>'; 49 }; 50 51 if(plugin.settings.nextButton) { 52 htmlNav += '<a href="" title="Next" rel="" class="next">'+plugin.settings.nextButtonText+'</a>'; 53 } 54 55 if(plugin.settings.lastButton) { 56 htmlNav += '<a href="#'+plugin.settings.hashPage+':'+plugin.settings.pages+'" title="Last page" rel="'+plugin.settings.pages+'" class="last">'+plugin.settings.lastButtonText+'</a>'; 57 } 58 59 htmlNav += '</div>'; 60 plugin.nav = $(htmlNav); 61 plugin.nav.css({ 62 'width': plugin.el.width(), 63 'margin-left': 'auto', 64 }); 65 plugin.el.after(plugin.nav); 66 67 $('.easyPaginateNav a.page, .easyPaginateNav a.first, .easyPaginateNav a.last', plugin).live('click', function(e) { 68 e.preventDefault(); 69 displayPage($(this).attr('rel')); 70 }); 71 72 $('.easyPaginateNav a.prev', plugin).live('click', function(e) { 73 e.preventDefault(); 74 page = plugin.settings.currentPage > 1?parseInt(plugin.settings.currentPage) - 1:1; 75 displayPage(page); 76 }); 77 78 $('.easyPaginateNav a.next', plugin).live('click', function(e) { 79 e.preventDefault(); 80 page = plugin.settings.currentPage < plugin.settings.pages?parseInt(plugin.settings.currentPage) + 1:plugin.settings.pages; 81 displayPage(page); 82 }); 83 }; 84 85 var displayPage = function(page, forceEffect) { 86 plugin.settings.currentPage = parseInt(page); 87 offsetStart = (page - 1) * plugin.settings.elementsPerPage; 88 offsetEnd = page * plugin.settings.elementsPerPage; 89 if(typeof(forceEffect) != 'undefined') { 90 eval("transition_"+forceEffect+"("+offsetStart+", "+offsetEnd+")"); 91 }else { 92 eval("transition_"+plugin.settings.effect+"("+offsetStart+", "+offsetEnd+")"); 93 } 94 95 plugin.nav.find('.current').removeClass('current'); 96 plugin.nav.find('a.page:eq('+(page - 1)+')').addClass('current'); 97 98 switch(plugin.settings.currentPage) { 99 case 1: 100 $('.easyPaginateNav a', plugin).removeClass('disabled'); 101 $('.easyPaginateNav a.first, .easyPaginateNav a.prev', plugin).addClass('disabled'); 102 break; 103 case plugin.settings.pages: 104 $('.easyPaginateNav a', plugin).removeClass('disabled'); 105 $('.easyPaginateNav a.last, .easyPaginateNav a.next', plugin).addClass('disabled'); 106 break; 107 default: 108 $('.easyPaginateNav a', plugin).removeClass('disabled'); 109 break; 110 } 111 }; 112 113 var transition_default = function(offsetStart, offsetEnd) { 114 plugin.currentElements.hide(); 115 plugin.currentElements = plugin.settings.objElements.slice(offsetStart, offsetEnd).clone(); 116 plugin.el.html(plugin.currentElements); 117 plugin.currentElements.show(); 118 }; 119 120 var transition_fade = function(offsetStart, offsetEnd) { 121 plugin.currentElements.fadeOut(); 122 plugin.currentElements = plugin.settings.objElements.slice(offsetStart, offsetEnd).clone(); 123 plugin.el.html(plugin.currentElements); 124 plugin.currentElements.fadeIn(); 125 }; 126 127 var transition_slide = function(offsetStart, offsetEnd) { 128 plugin.currentElements.animate({ 129 'margin-left': plugin.settings.slideOffset * -1, 130 'opacity': 0 131 }, function() { 132 $(this).remove(); 133 }); 134 135 plugin.currentElements = plugin.settings.objElements.slice(offsetStart, offsetEnd).clone(); 136 plugin.currentElements.css({ 137 'margin-left': plugin.settings.slideOffset, 138 'display': 'block', 139 'opacity': 0, 140 'min-width': plugin.el.width() / 2 141 }); 142 plugin.el.html(plugin.currentElements); 143 plugin.currentElements.animate({ 144 'margin-left': 0, 145 'opacity': 1 146 }); 147 }; 148 149 var transition_climb = function(offsetStart, offsetEnd) { 150 plugin.currentElements.each(function(i) { 151 var $objThis = $(this); 152 setTimeout(function() { 153 $objThis.animate({ 154 'margin-left': plugin.settings.slideOffset * -1, 155 'opacity': 0 156 }, function() { 157 $(this).remove(); 158 }); 159 }, i * 200); 160 }); 161 162 plugin.currentElements = plugin.settings.objElements.slice(offsetStart, offsetEnd).clone(); 163 plugin.currentElements.css({ 164 'margin-left': plugin.settings.slideOffset, 165 'display': 'block', 166 'opacity': 0, 167 'min-width': plugin.el.width() / 2 168 }); 169 plugin.el.html(plugin.currentElements); 170 plugin.currentElements.each(function(i) { 171 var $objThis = $(this); 172 setTimeout(function() { 173 $objThis.animate({ 174 'margin-left': 0, 175 'opacity': 1 176 }); 177 }, i * 200); 178 }); 179 }; 180 181 plugin.settings = $.extend({}, defaults, options); 182 183 plugin.currentElements = $([]); 184 plugin.settings.objElements = plugin.el.find(plugin.settings.paginateElement); 185 plugin.settings.pages = getNbOfPages(); 186 if(plugin.settings.pages > 1) { 187 plugin.el.html(); 188 189 // Here we go 190 displayNav(); 191 192 page = 1; 193 if(document.location.hash.indexOf('#'+plugin.settings.hashPage+':') != -1) { 194 page = parseInt(document.location.hash.replace('#'+plugin.settings.hashPage+':', '')); 195 if(page.length <= 0 || page < 1 || page > plugin.settings.pages) { 196 page = 1; 197 } 198 } 199 200 displayPage(page, 'default'); 201 } 202 }); 203 }; 204 })(jQuery); 227 }); 228 }; 229 });
Note: See TracChangeset
for help on using the changeset viewer.