├── .editorconfig ├── css ├── jDatepicker.css └── style.css ├── index.php ├── js ├── jDatepicker.js ├── jFloatTop.js ├── jPaginate.js └── jReplenish.js ├── paging-ajax-demo.php └── readme.md /.editorconfig: -------------------------------------------------------------------------------- 1 | ; http://editorconfig.org 2 | ; 3 | ; Sublime: https://github.com/sindresorhus/editorconfig-sublime 4 | ; Phpstorm: https://plugins.jetbrains.com/plugin/7294-editorconfig 5 | 6 | root = true 7 | 8 | [*] 9 | indent_style = space 10 | indent_size = 2 11 | end_of_line = lf 12 | charset = utf-8 13 | trim_trailing_whitespace = true 14 | insert_final_newline = true 15 | 16 | [{*.md,*.php,composer.json,composer.lock}] 17 | indent_size = 4 18 | -------------------------------------------------------------------------------- /css/jDatepicker.css: -------------------------------------------------------------------------------- 1 | /** 2 | * jQuery-NepaliDatepicker-plugin CSS 3 | * 4 | * @author Jitendra Adhikari 5 | * @email jiten.adhikary@gmail.com 6 | * 7 | */ 8 | .jDatepicker-div { 9 | padding:3px; 10 | background:#fff; 11 | border:1px solid #e3e3e3; 12 | border-radius:5px; 13 | width:198px; 14 | display:none; 15 | z-index:2; 16 | position:absolute; 17 | } 18 | 19 | .jDatepicker-table { 20 | margin-top:0px; 21 | width:160px; 22 | } 23 | 24 | .jDatepicker-table thead tr { 25 | border:1px solid #bbb; 26 | } 27 | 28 | .jDatepicker-table th { 29 | background:#d4d4d4; 30 | font-family:Verdana, Geneva, sans-serif; 31 | font-size:14px; 32 | padding:5px 8px; 33 | } 34 | 35 | .jDatepicker-table th.disabled { 36 | background:#bbb; 37 | color:#888; 38 | } 39 | 40 | .jDatepicker-nav { 41 | background:#bbb; 42 | cursor:pointer; 43 | height:24px; 44 | border-radius:3px 3px 0 0; 45 | margin-bottom:0; 46 | width:198px; 47 | } 48 | 49 | .jDatepicker-nav span { 50 | text-align:center; 51 | width:15px; 52 | } 53 | 54 | .jDatepicker-nav span.disabled { 55 | color:#888; 56 | } 57 | 58 | .jDatepicker-prevnav { 59 | float:left; 60 | width:50px; 61 | } 62 | 63 | .jDatepicker-prevnav span { 64 | float:left; 65 | } 66 | 67 | .jDatepicker-label { 68 | text-align:center; 69 | float:left; 70 | width:90px; 71 | font-size:14px; 72 | font-weight:bold; 73 | padding-top:2px; 74 | } 75 | 76 | .jDatepicker-nextnav { 77 | display:inline; 78 | float:right; 79 | width:50px; 80 | } 81 | 82 | .jDatepicker-days td { 83 | font-weight:bold; 84 | font-size:12px; 85 | } 86 | 87 | .jDatepicker-nextnav span { 88 | float:right; 89 | } 90 | 91 | .jDatepicker-table td { 92 | background:#eee; 93 | font-size:12px; 94 | text-align:center; 95 | padding:4px auto; 96 | } 97 | 98 | .jDatepicker-table td.jDatepicker-click { 99 | cursor:pointer; 100 | border:1px solid #ddd; 101 | } 102 | 103 | .jDatepicker-table td.jDatepicker-hover { 104 | border:1px solid #aaa; 105 | } 106 | 107 | .jDatepicker-table td.jDatepicker-selected, 108 | .jDatepicker-table td.jDatepicker-today { 109 | font-weight:bold; 110 | background:none; 111 | } 112 | -------------------------------------------------------------------------------- /css/style.css: -------------------------------------------------------------------------------- 1 | /* common */ 2 | body{font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;margin:0; padding:0;} 3 | #ground{width:90%;margin:0 auto;} 4 | fieldset,legend {border:1px solid #DDD;} 5 | legend{padding:2px 8px;} 6 | legend.slide{cursor:pointer;} 7 | fieldset{margin:10px 0;} 8 | 9 | /* pagination */ 10 | .jq-pagination-wrap{width:95%;float:left;} 11 | .jq-pagination-nav{margin-top:15px;float:left;} 12 | .jq-pagination-nav a{cursor:pointer;background:#CCC;margin:0 1px;text-align:center; padding:2px 5px;font-size:14px;border-radius:3px 0;} 13 | .jq-pagination-nav a.jq-pagination-current-key{background:#DDD;color:#AAA;cursor:default;} 14 | .item{width:25%;margin:5px 0;float:left;} 15 | 16 | /* floattop */ 17 | .boxwrap{width:99%;padding:5px;} 18 | .box{border:1px solid #AAA;background:#FFF;margin:10px;padding:10px;} 19 | .box span{background:#EEE;border:1px solid #EEE;display:block;padding:5px;font-family:"Comic Sans MS", cursive;} 20 | 21 | /* replenish */ 22 | .input,.label{width:33%;float:left;} 23 | .input input,textarea,select{font-family:"Palatino Linotype", "Book Antiqua", Palatino, serif;width:50%;} 24 | input[type="submit"]{display:none;} 25 | textarea{padding:5px;resize:none;} 26 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 |" + dayNames[i] + " | "; 260 | }; 261 | 262 | out += '
---|
" + ((j > 0 && j <= max) ? npNum(j) : '') + ' | '; 272 | if (j > 0) j++; 273 | if (j == max + 1) j = 0; 274 | if (i % 7 == 0 && !tr) { 275 | out += '
itemClass not defined
'); 54 | 55 | return false; 56 | } 57 | 58 | if (isAjax) { 59 | option.ajax.baseurl = option.ajax.baseurl.replace(/[\/]+$/, '') + '/'; 60 | count = option.ajax.total; 61 | } else { 62 | var items = handle.find('.' + option.itemClass); 63 | count = items.length; 64 | 65 | if (count == 0) { 66 | handle.append('jQueryPagination error: items with class "' + option.itemClass + '" not found.'); 67 | return false; 68 | } 69 | 70 | items.wrapAll(''); 71 | wrap = $('.jq-pagination-wrap', handle); 72 | 73 | if (option.navPos == 'top') { 74 | wrap.before(''); 75 | } else { 76 | if (option.navPos == 'both') { 77 | wrap.before(''); 78 | wrap.after(''); 79 | } else { 80 | wrap.after(''); 81 | }; 82 | }; 83 | }; 84 | 85 | numPages = Math.ceil(count / option.perPage); 86 | 87 | if (option.startPage > 0 && option.startPage < Math.ceil(count / option.perPage)) { 88 | option.offset = (option.startPage - 1) * option.perPage; 89 | }; 90 | 91 | render(); 92 | 93 | $(handle).delegate('.jq-pagination-prev-key', 'click', function() { 94 | option.offset -= (option.perPage); 95 | render(); 96 | }); 97 | 98 | $(handle).delegate('.jq-pagination-next-key', 'click', function() { 99 | option.offset += (option.perPage); 100 | render(); 101 | }); 102 | 103 | $(handle).delegate('.jq-pagination-nav-key', 'click', function() { 104 | option.offset = parseInt($(this).data('pageoffset')); 105 | render(); 106 | }); 107 | 108 | function render() { 109 | var currPage = Math.floor(option.offset - option.perPage) / option.perPage + 2; 110 | 111 | if (isAjax) { 112 | $.ajax({ 113 | type: 'GET', 114 | url: option.ajax.baseurl + parseFormat(option.ajax.format), 115 | success: function(res) { 116 | (handle.find('.jq-pagination-wrap').length < 1) ? 117 | handle.append(res): handle.find('.jq-pagination-wrap').html(res); 118 | items = handle.find('.' + option.itemClass); 119 | if (items.length == 0) { 120 | handle.append('jPaginate error: items with class "' + option.itemClass + '" not found.
'); 121 | return false; 122 | } 123 | if (handle.find('.jq-pagination-wrap').length < 1) { 124 | items.wrapAll(''); 125 | wrap = $('.jq-pagination-wrap', handle); 126 | if (option.navPos == 'top') wrap.before(''); 127 | else { 128 | if (option.navPos == 'both') { 129 | wrap.before(''); 130 | wrap.after(''); 131 | } else { 132 | wrap.after(''); 133 | }; 134 | }; 135 | }; 136 | navLinks(); 137 | }, 138 | error: function(res) { 139 | handle.append('Error Loading Content.
'); 140 | } 141 | }); 142 | } else { 143 | navLinks(); 144 | items.each(function() { 145 | ($(this).index() < option.offset || $(this).index() > (option.offset + option.perPage - 1)) ? 146 | $(this).hide(): $(this).show(); 147 | }); 148 | }; 149 | }; 150 | 151 | function navLinks() { 152 | var nav = $('.jq-pagination-nav', handle), 153 | i, j, title; 154 | 155 | nav.empty(); 156 | if (option.navLinks != 'min' && currPage != 1) { 157 | nav.append('« First'); 158 | }; 159 | 160 | if (option.offset > 0) 161 | nav.append('' + option.prevLabel + ''); 162 | 163 | if (option.showCurrent && (option.navLinks == 'min' || option.navLinks == 'mod')) { 164 | title = (option.navTitle.current).replace('%i', currPage); 165 | nav.append('' + currPage + ''); 166 | }; 167 | 168 | if (option.navLinks == 'max') { 169 | if (option.maxPageLinks == 0 || numPages <= option.maxPageLinks) { 170 | for (i = 0, j = 1; i < count; i += option.perPage, j++) { 171 | if (i == option.offset) { 172 | title = (option.navTitle.current).replace('%i', j); 173 | nav.append('' + j + ''); 174 | } else { 175 | title = (option.navTitle.page).replace('%i', j); 176 | nav.append('' + j + ''); 177 | }; 178 | }; 179 | } else { 180 | var maxlc = Math.ceil(option.maxPageLinks / 2); 181 | var maxlf = Math.floor(option.maxPageLinks / 2); 182 | var left = (currPage - maxlf) > 0 ? currPage - maxlf : 1; 183 | var right = (currPage + maxlc) < numPages ? currPage + maxlc - 1 : numPages; 184 | 185 | for (i = left; i <= right; i++) { 186 | if (i == currPage) { 187 | title = (option.navTitle.current).replace('%i', i); 188 | nav.append('' + i + '') 189 | } else { 190 | title = (option.navTitle.page).replace('%i', i); 191 | nav.append('' + i + ''); 192 | }; 193 | }; 194 | }; 195 | }; 196 | 197 | if (option.offset < (count - option.perPage)) { 198 | nav.append('' + option.nextLabel + ''); 199 | } 200 | 201 | if (option.navLinks != 'min' && currPage != numPages) { 202 | nav.append('Last »'); 203 | }; 204 | }; 205 | 206 | function parseFormat(format) { 207 | format = format.replace(/^[\/]+/, ''); 208 | if (format.indexOf('&') > -1 && format[0] != '?') format = '?' + format; 209 | 210 | var isget = format.indexOf('&') > -1 && format.indexOf('/') == -1, 211 | os = (option.ajax.offset && isget) ? option.ajax.offset + '=' + option.offset : option.offset, 212 | ps = (option.ajax.perpage && isget) ? option.ajax.perpage + '=' + option.perPage : option.perPage, 213 | cs = (option.ajax.currpage && isget) ? option.ajax.currpage + '=' + currPage : currPage; 214 | 215 | return format.replace('offset', os).replace('perpage', ps).replace('currpage', cs); 216 | }; 217 | }; 218 | })(jQuery); 219 | -------------------------------------------------------------------------------- /js/jReplenish.js: -------------------------------------------------------------------------------- 1 | /** 2 | * jQuery plugin - jReplenish | Replenishes the form with relevant data, made for testers ;) 3 | * 4 | * @author adhocore | Jitendra Adhikari 5 | * @email jiten.adhikary@gmail.com 6 | */ 7 | ; 8 | (function($) { 9 | 'use strict'; 10 | $.fn.jReplenish = function(options) { 11 | options = $.extend({ 12 | allFields: true, 13 | minLen: 10, 14 | maxLen: 25, 15 | dashDot: true 16 | }, options || {}); 17 | 18 | var form = this, 19 | toFill = form.find('input, textarea').not(':submit, :button, :reset'), 20 | toSelect = form.find('select'), 21 | number = '0123456789', 22 | alpha = 'abcdefghijklmnopqrstuvwxyz', 23 | upalpha = alpha.toUpperCase(), 24 | dashdot = '.-_'; 25 | 26 | if (!options.allFields) { 27 | toFill = toFill.filter(function() { 28 | var reqd = $(this).attr('required'); 29 | return $(this).hasClass('required') || (typeof reqd !== 'undefined' && reqd !== false); 30 | }); 31 | toSelect = toSelect.filter(function() { 32 | var reqd = $(this).attr('required'); 33 | return $(this).hasClass('required') || (typeof reqd !== 'undefined' && reqd !== false); 34 | }); 35 | }; 36 | 37 | if (toFill.length + toSelect.length > 0) { 38 | var undoBtn = form.find('input[type="reset"]'); 39 | form.find('input:submit').before(''); 40 | 41 | if (undoBtn.length < 1) { 42 | form.find('input:submit').after(''); 43 | } else { 44 | undoBtn.addClass('undo-form-replenish').attr('title', 'Undo Fill'); 45 | } 46 | } 47 | 48 | function doFill() { 49 | toFill.each(function(i, e) { 50 | var minLen = $(this).attr('minlength'), 51 | maxLen = $(this).attr('maxlength'), 52 | itype = $(this).attr('type'); 53 | minLen = (typeof minLen !== 'undefined' && minLen !== false) ? 54 | minLen : options.minLen; 55 | maxLen = (typeof maxLen !== 'undefined' && maxLen !== false && maxLen != -1 && 56 | maxLen != 524288 && maxLen != 2147483647) ? maxLen : options.maxLen; 57 | 58 | if ($(this).hasClass('date') || itype == 'date') { 59 | $(this).val(date()); 60 | } else if ($(this).hasClass('url') || itype == 'url') { 61 | $(this).val(url(minLen)); 62 | } else if ($(this).hasClass('email') || itype == 'email') { 63 | $(this).val(email(minLen)); 64 | } else if ($(this).hasClass('number') || itype == 'number') { 65 | $(this).val(val('number', false, minLen, maxLen)); 66 | } else { 67 | $(this).val(val('alphanum', true, minLen, maxLen)); 68 | }; 69 | }); 70 | 71 | toSelect.each(function(i, e) { 72 | var j = 1; 73 | if ($(this).find('option[value!=""]').length == (optCount = $(this).find('option').length)) { 74 | j = 0; 75 | } 76 | $(this).find('option').eq(rand(j, optCount - 1)).attr('selected', true); 77 | }); 78 | }; 79 | 80 | $('.replenish-form-btn', form).click(function() { 81 | doFill(); 82 | $(this).val('Refill'); 83 | $('.undo-form-replenish', form).show(); 84 | }); 85 | 86 | $('.undo-form-replenish', form).click(function() { 87 | if ($(this).hasClass('replenish-undo-btn')) $(this).hide(); 88 | $('.replenish-form-btn', form).val('Fill'); 89 | }); 90 | 91 | function val(type, dash, min, max) { 92 | var ret = '', 93 | pool = '', 94 | len = rand(min, max); 95 | 96 | if (!type) type = 'alphanum'; 97 | if (type == 'alphanum') pool = number + alpha + upalpha; 98 | if (type == 'alpha') pool = alpha; 99 | if (type == 'upalpha') pool = alpha + upalpha; 100 | if (type == 'number') pool = number; 101 | if (options.dashDot && pool != number && dash) pool += dashdot; 102 | 103 | while (ret.length < len) { 104 | ret += pool[Math.floor(Math.random() * pool.length)]; 105 | }; 106 | 107 | return ret; 108 | }; 109 | 110 | function email(min) { 111 | return val('alpha', true, 5, min) + '@' + val('alpha', false, min - 5, min - 5) + '.' + val('alpha', false, 3, 4); 112 | }; 113 | 114 | function url(min) { 115 | return 'https://' + val('alpha', false, min - 3, min) + '.' + val('alpha', false, 3, 4); 116 | }; 117 | 118 | function date() { 119 | var m = rand(1, 12), 120 | d = rand(1, 28); 121 | if (m < 10) m = '0' + m; 122 | if (d < 10) d = '0' + d; 123 | 124 | return rand(1900, 2100) + '-' + m + '-' + d; 125 | }; 126 | 127 | function rand(min, max) { 128 | return Math.floor(Math.random() * (max - min + 1)) + parseInt(min, 10); 129 | }; 130 | 131 | return form; // chaining 132 | } 133 | })(jQuery); 134 | -------------------------------------------------------------------------------- /paging-ajax-demo.php: -------------------------------------------------------------------------------- 1 | ajax loaded item {$i}