1(function($) { 2 $.fn.extend({ 3 pureAjax: function(options) { 4 var defaults = { 5 urlAppend: "&tx_pure_pi[ajax_request_id]=", 6 urlAppendIdSelecetor: "", 7 urlAppendUserClick: "&tx_pure_pi[userclick]=true", 8 urlAppendCookieClick: "&tx_pure_pi[userclick]=false", 9 aSelector: ".pure-ajax-request a, a.ajax_request", 10 resultPageSelector: ".pure-result-page, .pure-tabs-contents", 11 resultSelector: ".pure-result", 12 loader: ".pure_loading", 13 succesFunc: function(loadedContent) {} 14 }; 15 var opts = $.extend({},defaults, options); 16 17 //Iterate over the current set of matched elements 18 return this.each(function() { 19 var obj = $(this); 20 var anchors= $(opts.aSelector, obj); 21 //Unbind and bind to click event 22 anchors.unbind("click.pureAjax"); 23 anchors.bind('click.pureAjax', function(event) { 24 //Find closest resultPage 25 var resultPage = $(this).closest(opts.resultPageSelector); 26 //Find the id, for this page. 27 var id = resultPage.attr("id"); 28 if (id) 29 id = id.substring(1); 30 else 31 id = "1:1"; 32 var result; 33 if (typeof opts.resultSelector == "string") 34 result = $(opts.resultSelector, resultPage); 35 else if (typeof opts.resultSelector == "object") 36 { 37 result = opts.resultSelector; 38 } 39 40 var loader = $(opts.loader, resultPage); 41 42 //Show loader and hide if any content showed. 43 result.slideUp("normal"); 44 loader.stop(true, true).slideDown("normal"); 45 46 //Load content. 47 var xhr = $.ajax({ 48 url: this.href 49 + (this.href.indexOf("?") > -1 ? "" : "?") 50 + opts.urlAppend + id + "&type=5055&cid=" + parseInt(id) + (typeof event.which == "undefined" ? opts.urlAppendCookieClick : opts.urlAppendUserClick), 51 cache: true, 52 success: function(html) { 53 result.hide().html(html).slideDown("normal"); 54 loader.slideUp("normal"); 55 56 if (typeof opts.succesFunc == "function") 57 opts.succesFunc(result); 58 } 59 }); 60 61 //Add the xhr to data for the result, so it can be cancelled by other. 62 $.data(resultPage.get(0), "pure-page-xhr", xhr); 63 64 //Handle click event 65 if (event.which && event.which != 1) { 66 return true; 67 } 68 event.preventDefault(); 69 return false; 70 71 });
72 }); 73 }, 74 75 pureTabs: function(options) { 76 //Set the default values 77 var defaults = { 78 urlAppend: "&tx_pure_pi[ajax_request_id]=1:1", 79 urlAppendUserClick: "&tx_pure_pi[userclick]=true", 80 urlAppendCookieClick: "&tx_pure_pi[userclick]=false", 81 cookieName: 'au_pure_tabs_', 82 succesFunc: function(loadedtab){}, 83 loader: $(".pure_loading:first") //Find a element to use. 84 }; 85 var opts = $.extend({},defaults, options); 86 87 function abort(xhr) 88 { 89 // terminate pending requests from other tabs 90 if (xhr) { 91 xhr.abort(); 92 delete xhr; 93 } 94 } 95 96 //Iterate over the current set of matched elements 97 var objs = this; 98 return this.each(function() { 99 var obj = $(this); 100 //Index of this tabs. 101 var index = $(objs).index(obj); 102 103 //All the tabs: 104 var tabs = $(".pure-tabs-ul li a.pure-tab", obj); 105 106 //Add hover events. 107 $(".pure-tabs-ul li", obj).hover( 108 function() { 109 $(this).addClass("pure-tabs-hover"); 110 }, 111 function() { 112 $(this).removeClass("pure-tabs-hover"); 113 } 114 ); 115 var loaderObj; 116 if (typeof opts.loader == "string") 117 loaderObj = obj.closest(opts.loader);//$(opts.loader, obj); 118 else if (typeof opts.loader == "object") 119 loaderObj = opts.loader.clone(); 120 loaderObj = loaderObj.stop(true, true).hide(); 121 122 //Add tab elements 123 obj.append('<div class="pure-tabs-contents"></div>'); 124 var tabContainer = $("div.pure-tabs-contents", obj); 125 tabContainer.append(loaderObj); 126 tabs.each(function() { 127 var el; 128 //Find id="#id" tabs with are corresponding div element. 129 var idIndex = $(this).attr("href").indexOf("#"); 130 if ( idIndex > -1 && $($(this).attr("href").substring(idIndex), obj).size() > 0) 131 { 132 el = $('<div class="pure-tabs-result pure-loaded"></div>'); 133 $(el).append($($(this).attr("href").substring(idIndex), obj)); 134 } 135 else 136 el = $('<div class="pure-tabs-result"><div class="pure-result"></div></div>'); 137 tabContainer.append(el.show()); 138 }); 139 140 //The tab holders 141 var tabContents = $(".pure-tabs-contents div.pure-tabs-result", obj); 142 tabContents.hide(); 143 144 var selected = -1; 145 tabs.unbind('click.pureTabs'); 146 tabs.bind('click.pureTabs', function(event) { 147 //Reset all tabs 148 tabs.closest("li").removeClass("pure-tabs-selected"); 149 150 //Abort the current xhr for this page 151 var xhr = $.data(tabContainer.get(0), "pure-page-xhr"); 152 abort(xhr); 153 154 var current = tabs.index($(this)); 155 if (current != selected) { 156 //Set selected tab 157 selected = current; 158 $(this).closest("li").addClass("pure-tabs-selected"); 159 160 //Trigger ajax if there is no cached. 161 if (!tabContents.eq(current).hasClass("pure-loaded")) 162 { 163 //Stop all running animations 164 tabContents.slideUp("normal"); 165 loaderObj.stop(true,true).slideDown("normal"); 166 167 //Load content. 168 var xhr = $.ajax({ 169 url: this.href 170 + (this.href.indexOf("?") > -1 ? "" : "?") 171 + opts.urlAppend 172 + (typeof event.which == "undefined" ? opts.urlAppendCookieClick : opts.urlAppendUserClick), 173 cache: true, 174 success: function(html) { 175 $(".pure-result",tabContents.eq(current)).html(html); 176 tabContents.eq(current).slideDown("normal");
177 loaderObj.stop(true, true).slideUp("normal"); 178 if (typeof opts.succesFunc == "function") 179 opts.succesFunc(tabContents.eq(current)); 180 tabContents.eq(current).addClass("pure-loaded"); 181 } 182 }); 183 //Set the xhr for this page. 184 $.data(tabContainer.get(0), "pure-page-xhr", xhr); 185 } 186 else 187 { 188 loaderObj.stop(true, true).hide(); 189 //tabContents.hide(); 190 //tabContents.eq(current).show(); 191 tabContents.slideUp("normal"); 192 tabContents.eq(current).slideDown("normal"); 193 } 194 195 //Save cookie 196 var cookieOptions = { expires: 30, path: window.location.pathname }; 197 jQuery.cookie(opts.cookieName + index, current, cookieOptions); 198 } 199 else { 200 //Stop all running animations and run to end. 201 tabContents.stop(true, true); 202 tabContents.eq(current).slideUp("normal"); 203 loaderObj.stop(true,true).slideUp("normal"); 204 selected = -1; 205 206 //Remove cookie 207 var cookieOptions = { expires: -1, path: window.location.pathname }; 208 jQuery.cookie(opts.cookieName + index, null, cookieOptions); 209 } 210 211 //Handle click event 212 if (event.which && event.which != 1) { 213 return true; 214 } 215 event.preventDefault(); 216 return false; 217 }); 218 219 //Get selected from cookie if any, and trigger click 220 var cokSel = $.cookie(opts.cookieName + index); 221 if (cokSel) //Trigger click event for loading. 222 tabs.eq(cokSel).trigger('click'); 223 else if (obj.hasClass("pure-tabs-foldOutFirst")) 224 tabs.eq(0).trigger('click'); 225 else //Open tabs that want to be open. 226 $(".pure-tab-open").trigger('click'); 227 }); 228 } 229 }); 230 231 $(document).ready(function() { 232 var tablesorterOptions = {widgets: ['zebra']}; 233 //testing new plugin. 234 var tabOptions = {succesFunc: function(loadedtab){ 235 var ajaxOp = { 236 succesFunc: function(loadedPage){ 237 loadedPage.pureAjax(ajaxOp); 238 $(".pure-tabs", loadedPage).pureTabs(tabOptions); 239 }, 240 resultSelector: loadedtab 241 }; 242 $(loadedtab).pureAjax(ajaxOp); 243 }}; 244 245 var ajaxOptions = {succesFunc: function(loadedPage){ 246 loadedPage.pureAjax(ajaxOptions); 247 $(".pure-tabs", loadedPage).pureTabs(tabOptions); 248 $(".pure-persons-table", loadedPage).tablesorter(tablesorterOptions); 249 } 250 }; 251 252 // Dycon disabled in .min.js by adding -dycon to selctor: $(".tx-pure-pi-dycon").pureAjax(ajaxOptions); 253 $(".pure-tabs").pureTabs(tabOptions); 254 $(".pure-persons-table").tablesorter(tablesorterOptions); 255 256 //Auto load content: 257 $(".tx-pure-pi a.ajax_request").trigger("click"); 258 259 //Search settings - show or hide 260 $(".pure_search_form").each(function() { 261 var thisSearch = this; 262 $(".pure-search-settings", thisSearch).hide(); 263 $(".pure-show-search-settings", thisSearch).show(); 264 $(".pure-show-search-settings a, .pure-hide-search-settings a", thisSearch).click(function() { 265 $(".pure-show-search-settings, .pure-hide-search-settings, .pure-search-settings", thisSearch).toggle(); 266 return false; 267 }); 268 }); 269 //Sorting toogle. 270 $(".tx-pure-sorting-body").hide(); 271 $("#au_content").on("click", ".tx-pure-sorting-head", function() 272 { 273 $(this).next(".tx-pure-sorting-body").toggle(); 274 }); 275 276 //Resize image to fill the containing box. 277 $(".pure-image-person a img").cjObjectScaler({ 278 destObj: $(".pure-image-person a img").parent("a"), //The object to resize after. 279 method: "fill" // Fill the destination object. Will crop image. 280 }); 281 //Remove the max-width/height from the images 282 $(".pure-image-person a img").css("min-height", "100%"); 283 $(".pure-image-person a img").css("max-width", "100%"); 284 285 });
286 287})(jQuery); 288 289 290/** 291 * Cookie plugin 292 * 293 * Copyright (c) 2006 Klaus Hartl (stilbuero.de) 294 * Dual licensed under the MIT and GPL licenses: 295 * http://www.opensource.org/licenses/mit-license.php 296 * http://www.gnu.org/licenses/gpl.html 297 * 298 */ 299 300/** 301 * Create a cookie with the given name and value and other optional parameters. 302 * 303 * @example $.cookie('the_cookie', 'the_value'); 304 * @desc Set the value of a cookie. 305 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true }); 306 * @desc Create a cookie with all available options. 307 * @example $.cookie('the_cookie', 'the_value'); 308 * @desc Create a session cookie. 309 * @example $.cookie('the_cookie', null); 310 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain 311 * used when the cookie was set. 312 * 313 * @param String name The name of the cookie. 314 * @param String value The value of the cookie. 315 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes. 316 * @option Number|Date expires Either an integer specifying the expiration date from now on in minutes or a Date object. 317 * If a negative value is specified (e.g. a date in the past), the cookie will be deleted. 318 * If set to null or omitted, the cookie will be a session cookie and will not be retained 319 * when the the browser exits. 320 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie). 321 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie). 322 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will 323 * require a secure protocol (like HTTPS). 324 * @type undefined 325 * 326 * @name $.cookie 327 * @cat Plugins/Cookie 328 * @author Klaus Hartl/[email protected] 329 */ 330 331/** 332 * Get the value of a cookie with the given name. 333 * 334 * @example $.cookie('the_cookie'); 335 * @desc Get the value of a cookie. 336 * 337 * @param String name The name of the cookie. 338 * @return The value of the cookie. 339 * @type String 340 * 341 * @name $.cookie 342 * @cat Plugins/Cookie 343 * @author Klaus Hartl/[email protected] 344 */ 345(function($) { 346$.cookie = function(name, value, options) { 347 if (typeof value != 'undefined') { // name and value given, set cookie 348 options = options || {}; 349 if (value === null) { 350 value = ''; 351 options.expires = -1; 352 } 353 var expires = ''; 354 if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { 355 var date; 356 if (typeof options.expires == 'number') { 357 date = new Date(); 358 date.setTime(date.getTime() + (options.expires * 60 * 1000)); 359 } else { 360 date = options.expires; 361 } 362 expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE 363 } 364 // CAUTION: Needed to parenthesize options.path and options.domain 365 // in the following expressions, otherwise they evaluate to undefined 366 // in the packed version for some reason... 367 var path = options.path ? '; path=' + (options.path) : ''; 368 var domain = options.domain ? '; domain=' + (options.domain) : ''; 369 var secure = options.secure ? '; secure' : ''; 370 document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); 371 } else { // only name given, get cookie 372 var cookieValue = null; 373 if (document.cookie && document.cookie != '') { 374 var cookies = document.cookie.split(';'); 375 for (var i = 0; i < cookies.length; i++) { 376 var cookie = $.trim(cookies[i]); 377 // Does this cookie string begin with the name we want? 378 if (cookie.substring(0, name.length + 1) == (name + '=')) { 379 cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); 380 break; 381 } 382 } 383 } 384 return cookieValue; 385 } 386}; 387})(jQuery); 388 389/* 390 * 391 * TableSorter 2.0 - Client-side table sorting with ease! 392 * Version 2.0.3 393 * @requires jQuery v1.2.3 394 * 395 * Copyright (c) 2007 Christian Bach 396 * Examples and docs at: http://tablesorter.com 397 * Dual licensed under the MIT and GPL licenses: 398 * http://www.opensource.org/licenses/mit-license.php 399 * http://www.gnu.org/licenses/gpl.html 400 * 401 */ 402/** 403 *
404 * @description Create a sortable table with multi-column sorting capabilitys 405 * 406 * @example $('table').tablesorter(); 407 * @desc Create a simple tablesorter interface. 408 * 409 * @example $('table').tablesorter({ sortList:[[0,0],[1,0]] }); 410 * @desc Create a tablesorter interface and sort on the first and secound column in ascending order. 411 * 412 * @example $('table').tablesorter({ headers: { 0: { sorter: false}, 1: {sorter: false} } }); 413 * @desc Create a tablesorter interface and disableing the first and secound column headers. 414 * 415 * @example $('table').tablesorter({ 0: {sorter:"integer"}, 1: {sorter:"currency"} }); 416 * @desc Create a tablesorter interface and set a column parser for the first and secound column. 417 * 418 * 419 * @param Object settings An object literal containing key/value pairs to provide optional settings. 420 * 421 * @option String cssHeader (optional) A string of the class name to be appended to sortable tr elements in the thead of the table. 422 * Default value: "header" 423 * 424 * @option String cssAsc (optional) A string of the class name to be appended to sortable tr elements in the thead on a ascending sort. 425 * Default value: "headerSortUp" 426 * 427 * @option String cssDesc (optional) A string of the class name to be appended to sortable tr elements in the thead on a descending sort. 428 * Default value: "headerSortDown" 429 * 430 * @option String sortInitialOrder (optional) A string of the inital sorting order can be asc or desc. 431 * Default value: "asc" 432 * 433 * @option String sortMultisortKey (optional) A string of the multi-column sort key. 434 * Default value: "shiftKey" 435 * 436 * @option String textExtraction (optional) A string of the text-extraction method to use. 437 * For complex html structures inside td cell set this option to "complex", 438 * on large tables the complex option can be slow. 439 * Default value: "simple" 440 * 441 * @option Object headers (optional) An array containing the forces sorting rules. 442 * This option let's you specify a default sorting rule. 443 * Default value: null 444 * 445 * @option Array sortList (optional) An array containing the forces sorting rules. 446 * This option let's you specify a default sorting rule. 447 * Default value: null 448 * 449 * @option Array sortForce (optional) An array containing forced sorting rules. 450 * This option let's you specify a default sorting rule, which is prepended to user-selected rules. 451 * Default value: null 452 * 453 * @option Array sortAppend (optional) An array containing forced sorting rules. 454 * This option let's you specify a default sorting rule, which is appended to user-selected rules. 455 * Default value: null 456 * 457 * @option Boolean widthFixed (optional) Boolean flag indicating if tablesorter should apply fixed widths to the table columns. 458 * This is usefull when using the pager companion plugin. 459 * This options requires the dimension jquery plugin. 460 * Default value: false 461 * 462 * @option Boolean cancelSelection (optional) Boolean flag indicating if tablesorter should cancel selection of the table headers text. 463 * Default value: true 464 * 465 * @option Boolean debug (optional) Boolean flag indicating if tablesorter should display debuging information usefull for development. 466 * 467 * @type jQuery 468 * 469 * @name tablesorter 470 * 471 * @cat Plugins/Tablesorter 472 * 473 * @author Christian Bach/[email protected] 474 */ 475 476(function($) { 477 $.extend({ 478 tablesorter: new function() { 479 480 var parsers = [], widgets = []; 481 482 this.defaults = { 483 cssHeader: "header", 484 cssAsc: "headerSortUp", 485 cssDesc: "headerSortDown", 486 sortInitialOrder: "asc", 487 sortMultiSortKey: "shiftKey", 488 sortForce: null, 489 sortAppend: null, 490 textExtraction: "simple", 491 parsers: {}, 492 widgets: [], 493 widgetZebra: {css: ["even","odd"]}, 494 headers: {}, 495 widthFixed: false, 496 cancelSelection: true, 497 sortList: [], 498 headerList: [], 499 dateFormat: "us",
500 decimal: '.', 501 debug: false 502 }; 503 504 /* debuging utils */ 505 function benchmark(s,d) { 506 log(s + "," + (new Date().getTime() - d.getTime()) + "ms"); 507 } 508 509 this.benchmark = benchmark; 510 511 function log(s) { 512 if (typeof console != "undefined" && typeof console.debug != "undefined") { 513 console.log(s); 514 } else { 515 alert(s); 516 } 517 } 518 519 /* parsers utils */ 520 function buildParserCache(table,$headers) { 521 522 if(table.config.debug) { var parsersDebug = ""; } 523 524 var rows = table.tBodies[0].rows; 525 526 if(table.tBodies[0].rows[0]) { 527 528 var list = [], cells = rows[0].cells, l = cells.length; 529 530 for (var i=0;i < l; i++) { 531 var p = false; 532 533 if($.metadata && ($($headers[i]).metadata() && $($headers[i]).metadata().sorter) ) { 534 535 p = getParserById($($headers[i]).metadata().sorter); 536 537 } else if((table.config.headers[i] && table.config.headers[i].sorter)) { 538 539 p = getParserById(table.config.headers[i].sorter); 540 } 541 if(!p) { 542 p = detectParserForColumn(table,cells[i]); 543 } 544 545 if(table.config.debug) { parsersDebug += "column:" + i + " parser:" +p.id + "\n"; } 546 547 list.push(p); 548 } 549 } 550 551 if(table.config.debug) { log(parsersDebug); } 552 553 return list; 554 }; 555 556 function detectParserForColumn(table,node) { 557 var l = parsers.length; 558 for(var i=1; i < l; i++) { 559 if(parsers[i].is($.trim(getElementText(table.config,node)),table,node)) { 560 return parsers[i]; 561 } 562 } 563 // 0 is always the generic parser (text) 564 return parsers[0]; 565 } 566 567 function getParserById(name) { 568 var l = parsers.length; 569 for(var i=0; i < l; i++) { 570 if(parsers[i].id.toLowerCase() == name.toLowerCase()) { 571 return parsers[i]; 572 } 573 } 574 return false; 575 } 576 577 /* utils */ 578 function buildCache(table) { 579 580 if(table.config.debug) { var cacheTime = new Date(); } 581 582 583 var totalRows = (table.tBodies[0] && table.tBodies[0].rows.length) || 0, 584 totalCells = (table.tBodies[0].rows[0] && table.tBodies[0].rows[0].cells.length) || 0, 585 parsers = table.config.parsers, 586 cache = {row: [], normalized: []}; 587 588 for (var i=0;i < totalRows; ++i) { 589 590 /** Add the table data to main data array */ 591 var c = table.tBodies[0].rows[i], cols = []; 592 593 cache.row.push($(c)); 594 595 for(var j=0; j < totalCells; ++j) { 596 cols.push(parsers[j].format(getElementText(table.config,c.cells[j]),table,c.cells[j])); 597 } 598 599 cols.push(i); // add position for rowCache 600 cache.normalized.push(cols); 601 cols = null; 602 }; 603 604 if(table.config.debug) { benchmark("Building cache for " + totalRows + " rows:", cacheTime); } 605 606 return cache; 607 }; 608 609 function getElementText(config,node) { 610 611 if(!node) return ""; 612 613 var t = ""; 614 615 if(config.textExtraction == "simple") { 616 if(node.childNodes[0] && node.childNodes[0].hasChildNodes()) { 617 t = node.childNodes[0].innerHTML; 618 } else { 619 t = node.innerHTML; 620 } 621 } else { 622 if(typeof(config.textExtraction) == "function") { 623 t = config.textExtraction(node); 624 } else { 625 t = $(node).text(); 626 } 627 } 628 return t; 629 } 630 631 function appendToTable(table,cache) { 632 633 if(table.config.debug) {var appendTime = new Date()} 634 635 var c = cache, 636 r = c.row, 637 n= c.normalized, 638 totalRows = n.length, 639 checkCell = (n[0].length-1), 640 tableBody = $(table.tBodies[0]), 641 rows = []; 642 643 for (var i=0;i < totalRows; i++) { 644 rows.push(r[n[i][checkCell]]); 645 if(!table.config.appender) { 646 647 var o = r[n[i][checkCell]]; 648 var l = o.length; 649 for(var j=0; j < l; j++) { 650 651 tableBody[0].appendChild(o[j]); 652 653 } 654 655 //tableBody.append(r[n[i][checkCell]]); 656 } 657 } 658 659 if(table.config.appender) { 660 661 table.config.appender(table,rows); 662 } 663 664 rows = null; 665 666 if(table.config.debug) { benchmark("Rebuilt table:", appendTime); } 667 668 //apply table widgets 669 applyWidget(table); 670 671 // trigger sortend 672 setTimeout(function() { 673 $(table).trigger("sortEnd"); 674 },0); 675 676 }; 677 678 function buildHeaders(table) { 679 680 if(table.config.debug) { var time = new Date(); } 681 682 var meta = ($.metadata) ? true : false, tableHeadersRows = []; 683 684 for(var i = 0; i < table.tHead.rows.length; i++) { tableHeadersRows[i]=0; }; 685 686 $tableHeaders = $("thead th",table); 687 688 $tableHeaders.each(function(index) { 689 690 this.count = 0; 691 this.column = index; 692 this.order = formatSortingOrder(table.config.sortInitialOrder); 693 694 if(checkHeaderMetadata(this) || checkHeaderOptions(table,index)) this.sortDisabled = true; 695 696 if(!this.sortDisabled) { 697 $(this).addClass(table.config.cssHeader); 698 } 699 700 // add cell to headerList 701 table.config.headerList[index]= this; 702 }); 703 704 if(table.config.debug) { benchmark("Built headers:", time); log($tableHeaders); } 705 706 return $tableHeaders; 707 708 }; 709 710 function checkCellColSpan(table, rows, row) { 711 var arr = [], r = table.tHead.rows, c = r[row].cells; 712 713 for(var i=0; i < c.length; i++) { 714 var cell = c[i]; 715 716 if ( cell.colSpan > 1) { 717 arr = arr.concat(checkCellColSpan(table, headerArr,row++)); 718 } else { 719 if(table.tHead.length == 1 || (cell.rowSpan > 1 || !r[row+1])) { 720 arr.push(cell); 721 } 722 //headerArr[row] = (i+row);
vendor: 10,906 bytes, lines 723-1158
723 } 724 } 725 return arr; 726 }; 727 728 function checkHeaderMetadata(cell) { 729 if(($.metadata) && ($(cell).metadata().sorter === false)) { return true; }; 730 return false; 731 } 732 733 function checkHeaderOptions(table,i) { 734 if((table.config.headers[i]) && (table.config.headers[i].sorter === false)) { return true; }; 735 return false; 736 } 737 738 function applyWidget(table) { 739 var c = table.config.widgets; 740 var l = c.length; 741 for(var i=0; i < l; i++) { 742 743 getWidgetById(c[i]).format(table); 744 } 745 746 } 747 748 function getWidgetById(name) { 749 var l = widgets.length; 750 for(var i=0; i < l; i++) { 751 if(widgets[i].id.toLowerCase() == name.toLowerCase() ) { 752 return widgets[i]; 753 } 754 } 755 }; 756 757 function formatSortingOrder(v) { 758 759 if(typeof(v) != "Number") { 760 i = (v.toLowerCase() == "desc") ? 1 : 0; 761 } else { 762 i = (v == (0 || 1)) ? v : 0; 763 } 764 return i; 765 } 766 767 function isValueInArray(v, a) { 768 var l = a.length; 769 for(var i=0; i < l; i++) { 770 if(a[i][0] == v) { 771 return true; 772 } 773 } 774 return false; 775 } 776 777 function setHeadersCss(table,$headers, list, css) { 778 // remove all header information 779 $headers.removeClass(css[0]).removeClass(css[1]); 780 781 var h = []; 782 $headers.each(function(offset) { 783 if(!this.sortDisabled) { 784 h[this.column] = $(this); 785 } 786 }); 787 788 var l = list.length; 789 for(var i=0; i < l; i++) { 790 h[list[i][0]].addClass(css[list[i][1]]); 791 } 792 } 793 794 function fixColumnWidth(table,$headers) { 795 var c = table.config; 796 if(c.widthFixed) { 797 var colgroup = $('<colgroup>'); 798 $("tr:first td",table.tBodies[0]).each(function() { 799 colgroup.append($('<col>').css('width',$(this).width())); 800 }); 801 $(table).prepend(colgroup); 802 }; 803 } 804 805 function updateHeaderSortCount(table,sortList) { 806 var c = table.config, l = sortList.length; 807 for(var i=0; i < l; i++) { 808 var s = sortList[i], o = c.headerList[s[0]]; 809 o.count = s[1]; 810 o.count++; 811 } 812 } 813 814 /* sorting methods */ 815 function multisort(table,sortList,cache) { 816 817 if(table.config.debug) { var sortTime = new Date(); } 818 819 var dynamicExp = "var sortWrapper = function(a,b) {", l = sortList.length; 820 821 for(var i=0; i < l; i++) { 822 823 var c = sortList[i][0]; 824 var order = sortList[i][1]; 825 var s = (getCachedSortType(table.config.parsers,c) == "text") ? ((order == 0) ? "sortText" : "sortTextDesc") : ((order == 0) ? "sortNumeric" : "sortNumericDesc"); 826 827 var e = "e" + i; 828 829 dynamicExp += "var " + e + " = " + s + "(a[" + c + "],b[" + c + "]); "; 830 dynamicExp += "if(" + e + ") { return " + e + "; } "; 831 dynamicExp += "else { "; 832 } 833 834 // if value is the same keep orignal order 835 var orgOrderCol = cache.normalized[0].length - 1; 836 dynamicExp += "return a[" + orgOrderCol + "]-b[" + orgOrderCol + "];"; 837 838 for(var i=0; i < l; i++) { 839 dynamicExp += "}; "; 840 } 841 842 dynamicExp += "return 0; "; 843 dynamicExp += "}; "; 844 845 eval(dynamicExp); 846 847 cache.normalized.sort(sortWrapper); 848 849 if(table.config.debug) { benchmark("Sorting on " + sortList.toString() + " and dir " + order+ " time:", sortTime); } 850 851 return cache; 852 }; 853 854 function sortText(a,b) { 855 return ((a < b) ? -1 : ((a > b) ? 1 : 0)); 856 }; 857 858 function sortTextDesc(a,b) { 859 return ((b < a) ? -1 : ((b > a) ? 1 : 0)); 860 }; 861 862 function sortNumeric(a,b) { 863 return a-b; 864 }; 865 866 function sortNumericDesc(a,b) { 867 return b-a; 868 }; 869 870 function getCachedSortType(parsers,i) { 871 return parsers[i].type; 872 }; 873 874 /* public methods */ 875 this.construct = function(settings) { 876 877 return this.each(function() { 878 879 if(!this.tHead || !this.tBodies) return; 880 881 var $this, $document,$headers, cache, config, shiftDown = 0, sortOrder; 882 883 this.config = {}; 884 885 config = $.extend(this.config, $.tablesorter.defaults, settings); 886 887 // store common expression for speed 888 $this = $(this); 889 890 // build headers 891 $headers = buildHeaders(this); 892 893 // try to auto detect column type, and store in tables config 894 this.config.parsers = buildParserCache(this,$headers); 895 896 897 // build the cache for the tbody cells 898 cache = buildCache(this); 899 900 // get the css class names, could be done else where. 901 var sortCSS = [config.cssDesc,config.cssAsc]; 902 903 // fixate columns if the users supplies the fixedWidth option 904 fixColumnWidth(this); 905 906 // apply event handling to headers 907 // this is to big, perhaps break it out? 908 $headers.click(function(e) { 909 910 $this.trigger("sortStart"); 911 912 var totalRows = ($this[0].tBodies[0] && $this[0].tBodies[0].rows.length) || 0; 913 914 if(!this.sortDisabled && totalRows > 0) { 915 916 917 // store exp, for speed 918 var $cell = $(this); 919 920 // get current column index 921 var i = this.column; 922 923 // get current column sort order 924 this.order = this.count++ % 2; 925 926 // user only whants to sort on one column 927 if(!e[config.sortMultiSortKey]) { 928 929 // flush the sort list 930 config.sortList = []; 931 932 if(config.sortForce != null) { 933 var a = config.sortForce; 934 for(var j=0; j < a.length; j++) { 935 if(a[j][0] != i) { 936 config.sortList.push(a[j]); 937 } 938 } 939 } 940 941 // add column to sort list 942 config.sortList.push([i,this.order]); 943 944 // multi column sorting 945 } else { 946 // the user has clicked on an all ready sortet column. 947 if(isValueInArray(i,config.sortList)) { 948 949 // revers the sorting direction for all tables. 950 for(var j=0; j < config.sortList.length; j++) { 951 var s = config.sortList[j], o = config.headerList[s[0]]; 952 if(s[0] == i) { 953 o.count = s[1]; 954 o.count++; 955 s[1] = o.count % 2; 956 } 957 } 958 } else { 959 // add column to sort list array 960 config.sortList.push([i,this.order]); 961 } 962 }; 963 setTimeout(function() { 964 //set css for headers 965 setHeadersCss($this[0],$headers,config.sortList,sortCSS); 966 appendToTable($this[0],multisort($this[0],config.sortList,cache)); 967 },1); 968 // stop normal event by returning false 969 return false; 970 } 971 // cancel selection 972 }).mousedown(function() { 973 if(config.cancelSelection) { 974 this.onselectstart = function() {return false}; 975 return false; 976 } 977 }); 978 979 // apply easy methods that trigger binded events 980 $this.bind("update",function() { 981 982 // rebuild parsers. 983 this.config.parsers = buildParserCache(this,$headers); 984 985 // rebuild the cache map 986 cache = buildCache(this); 987 988 }).bind("sorton",function(e,list) { 989 990 $(this).trigger("sortStart"); 991 992 config.sortList = list; 993 994 // update and store the sortlist 995 var sortList = config.sortList; 996 997 // update header count index 998 updateHeaderSortCount(this,sortList); 999 1000 //set css for headers 1001 setHeadersCss(this,$headers,sortList,sortCSS); 1002 1003 1004 // sort the table and append it to the dom 1005 appendToTable(this,multisort(this,sortList,cache)); 1006 1007 }).bind("appendCache",function() { 1008 1009 appendToTable(this,cache); 1010 1011 }).bind("applyWidgetId",function(e,id) { 1012 1013 getWidgetById(id).format(this); 1014 1015 }).bind("applyWidgets",function() { 1016 // apply widgets 1017 applyWidget(this); 1018 }); 1019 1020 if($.metadata && ($(this).metadata() && $(this).metadata().sortlist)) { 1021 config.sortList = $(this).metadata().sortlist; 1022 } 1023 // if user has supplied a sort list to constructor. 1024 if(config.sortList.length > 0) { 1025 $this.trigger("sorton",[config.sortList]); 1026 } 1027 1028 // apply widgets 1029 applyWidget(this); 1030 }); 1031 }; 1032 1033 this.addParser = function(parser) { 1034 var l = parsers.length, a = true; 1035 for(var i=0; i < l; i++) { 1036 if(parsers[i].id.toLowerCase() == parser.id.toLowerCase()) { 1037 a = false; 1038 } 1039 } 1040 if(a) { parsers.push(parser); }; 1041 }; 1042 1043 this.addWidget = function(widget) { 1044 widgets.push(widget); 1045 }; 1046 1047 this.formatFloat = function(s) { 1048 var i = parseFloat(s); 1049 return (isNaN(i)) ? 0 : i; 1050 }; 1051 this.formatInt = function(s) { 1052 var i = parseInt(s); 1053 return (isNaN(i)) ? 0 : i; 1054 }; 1055 1056 this.isDigit = function(s,config) { 1057 var DECIMAL = '\\' + config.decimal; 1058 var exp = '/(^[+]?0(' + DECIMAL +'0+)?$)|(^([-+]?[1-9][0-9]*)$)|(^([-+]?((0?|[1-9][0-9]*)' + DECIMAL +'(0*[1-9][0-9]*)))$)|(^[-+]?[1-9]+[0-9]*' + DECIMAL +'0+$)/'; 1059 return RegExp(exp).test($.trim(s)); 1060 }; 1061 1062 this.clearTableBody = function(table) { 1063 if($.browser.msie) { 1064 function empty() { 1065 while ( this.firstChild ) this.removeChild( this.firstChild ); 1066 } 1067 empty.apply(table.tBodies[0]); 1068 } else { 1069 table.tBodies[0].innerHTML = ""; 1070 } 1071 }; 1072 } 1073 }); 1074 1075 // extend plugin scope 1076 $.fn.extend({ 1077 tablesorter: $.tablesorter.construct 1078 }); 1079 1080 var ts = $.tablesorter; 1081 1082 // add default parsers 1083 ts.addParser({ 1084 id: "text", 1085 is: function(s) { 1086 return true; 1087 }, 1088 format: function(s) { 1089 return $.trim(s.toLowerCase()); 1090 }, 1091 type: "text" 1092 }); 1093 1094 ts.addParser({ 1095 id: "digit", 1096 is: function(s,table) { 1097 var c = table.config; 1098 return $.tablesorter.isDigit(s,c); 1099 }, 1100 format: function(s) { 1101 return $.tablesorter.formatFloat(s); 1102 }, 1103 type: "numeric" 1104 }); 1105 1106 ts.addParser({ 1107 id: "currency", 1108 is: function(s) { 1109 return /^[£$�.]/.test(s); 1110 }, 1111 format: function(s) { 1112 return $.tablesorter.formatFloat(s.replace(new RegExp(/[^0-9.]/g),"")); 1113 }, 1114 type: "numeric" 1115 }); 1116 1117 ts.addParser({ 1118 id: "ipAddress", 1119 is: function(s) { 1120 return /^\d{2,3}[\.]\d{2,3}[\.]\d{2,3}[\.]\d{2,3}$/.test(s); 1121 }, 1122 format: function(s) { 1123 var a = s.split("."), r = "", l = a.length; 1124 for(var i = 0; i < l; i++) { 1125 var item = a[i]; 1126 if(item.length == 2) { 1127 r += "0" + item; 1128 } else { 1129 r += item; 1130 } 1131 } 1132 return $.tablesorter.formatFloat(r); 1133 }, 1134 type: "numeric" 1135 }); 1136 1137 ts.addParser({ 1138 id: "url", 1139 is: function(s) { 1140 return /^(https?|ftp|file):\/\/$/.test(s); 1141 }, 1142 format: function(s) { 1143 return jQuery.trim(s.replace(new RegExp(/(https?|ftp|file):\/\//),'')); 1144 }, 1145 type: "text" 1146 }); 1147 1148 ts.addParser({ 1149 id: "isoDate", 1150 is: function(s) { 1151 return /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(s); 1152 }, 1153 format: function(s) { 1154 return $.tablesorter.formatFloat((s != "") ? new Date(s.replace(new RegExp(/-/g),"/")).getTime() : "0"); 1155 }, 1156 type: "numeric" 1157 }); 1158
1159 ts.addParser({ 1160 id: "percent", 1161 is: function(s) { 1162 return /\%$/.test($.trim(s)); 1163 }, 1164 format: function(s) { 1165 return $.tablesorter.formatFloat(s.replace(new RegExp(/%/g),"")); 1166 }, 1167 type: "numeric" 1168 }); 1169 1170 ts.addParser({ 1171 id: "usLongDate", 1172 is: function(s) { 1173 return s.match(new RegExp(/^[A-Za-z]{3,10}\.? [0-9]{1,2}, ([0-9]{4}|'?[0-9]{2}) (([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(AM|PM)))$/)); 1174 }, 1175 format: function(s) { 1176 return $.tablesorter.formatFloat(new Date(s).getTime()); 1177 }, 1178 type: "numeric" 1179 }); 1180 1181 ts.addParser({ 1182 id: "shortDate", 1183 is: function(s) { 1184 return /\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/.test(s); 1185 }, 1186 format: function(s,table) { 1187 var c = table.config; 1188 s = s.replace(/\-/g,"/"); 1189 if(c.dateFormat == "us") { 1190 // reformat the string in ISO format 1191 s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/, "$3/$1/$2"); 1192 } else if(c.dateFormat == "uk") { 1193 //reformat the string in ISO format 1194 s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/, "$3/$2/$1"); 1195 } else if(c.dateFormat == "dd/mm/yy" || c.dateFormat == "dd-mm-yy") { 1196 s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2})/, "$1/$2/$3"); 1197 } 1198 return $.tablesorter.formatFloat(new Date(s).getTime()); 1199 }, 1200 type: "numeric" 1201 }); 1202 1203 ts.addParser({ 1204 id: "time", 1205 is: function(s) { 1206 return /^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(am|pm)))$/.test(s); 1207 }, 1208 format: function(s) { 1209 return $.tablesorter.formatFloat(new Date("2000/01/01 " + s).getTime()); 1210 }, 1211 type: "numeric" 1212 }); 1213 1214 1215 ts.addParser({ 1216 id: "metadata", 1217 is: function(s) { 1218 return false; 1219 }, 1220 format: function(s,table,cell) { 1221 var c = table.config, p = (!c.parserMetadataName) ? 'sortValue' : c.parserMetadataName; 1222 return $(cell).metadata()[p]; 1223 }, 1224 type: "numeric" 1225 }); 1226 1227 // add default widgets 1228 ts.addWidget({ 1229 id: "zebra", 1230 format: function(table) { 1231 if(table.config.debug) { var time = new Date(); } 1232 $("tr:visible",table.tBodies[0]) 1233 .filter(':even') 1234 .removeClass(table.config.widgetZebra.css[1]).addClass(table.config.widgetZebra.css[0]) 1235 .end().filter(':odd') 1236 .removeClass(table.config.widgetZebra.css[0]).addClass(table.config.widgetZebra.css[1]); 1237 if(table.config.debug) { $.tablesorter.benchmark("Applying Zebra widget", time); } 1238 } 1239 }); 1240})(jQuery); 1241 1242/*global jQuery */ 1243/* **************************************************************************** 1244 1245 CJ Object Scaler jQuery Plug-In v2.0 1246 1247 This library is released under the BSD license: 1248 1249 Copyright (c) 2008, Doug Jones. All rights reserved. 1250 1251 Redistribution and use in source and binary forms, with or without 1252 modification, are permitted provided that the following conditions are met: 1253 1254 Redistributions of source code must retain the above copyright notice, this 1255 list of conditions and the following disclaimer. Redistributions in binary 1256 form must reproduce the above copyright notice, this list of conditions and 1257 the following disclaimer in the documentation and/or other materials 1258 provided with the distribution. Neither the name BernieCode nor 1259 the names of its contributors may be used to endorse or promote products 1260 derived from this software without specific prior written permission. 1261 1262 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 1263 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1264 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1265 ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR 1266 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1267 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 1268 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 1269 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 1270 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 1271 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 1272 DAMAGE. 1273
1274 For more information please visit www.cjboco.com. 1275 1276 Example: 1277 1278 $("#myImage").cjObjectScaler({ 1279 destObj: $("#myDiv"), // Needs to be a jQuery object 1280 method: "fit", // fit | fill (default) 1281 fade: 500 // 0 no fade, positive integer fade duration 1282 }); 1283 1284 CHANGELOG 1285 1286 v1.0 09/10/08 - Initial Release 1287 v2.0 09/22/09 - Coverted it to a jQuery plug-in 1288 v2.0.1 10/14/09 - Fixed a bug where the scaling function 1289 wasn't being triggered, do to the 1290 image already being loaded. 1291 (Discovered by Ben Visser) 1292 1293 1294**************************************************************************** */ 1295(function ($) { 1296 $.fn.cjObjectScaler = function (options) { 1297 1298 /* 1299 user variables (settings) 1300 ***************************************/ 1301 var settings = { 1302 // user editable settings 1303 destObj: null, 1304 // must be a jQuery object 1305 method: "fill", 1306 // fit|fill 1307 fade: 0 // if positive value, do hide/fadeIn 1308 }; 1309 1310 /* 1311 system variables 1312 ***************************************/ 1313 var sys = { 1314 // function parameters 1315 version: '2.0.0', 1316 elem: null 1317 }; 1318 1319 /* 1320 scale the image 1321 ***************************************/ 1322 function scale(self) { 1323 1324 // declare some local variables 1325 var dest = settings.destObj, 1326 destW = $(dest).width(), 1327 destH = $(dest).height(), 1328 ratioX, 1329 ratioY, 1330 scale, 1331 newWidth, 1332 newHeight; 1333 1334 // calculate scale ratios 1335 ratioX = destW / $(self).width(); 1336 ratioY = destH / $(self).height(); 1337 1338 // Determine which algorithm to use 1339 if (!$(self).hasClass("cf_image_scaler_fill") && ($(self).hasClass("cf_image_scaler_fit") || settings.method === "fit")) { 1340 scale = ratioX < ratioY ? ratioX : ratioY; 1341 } else if (!$(self).hasClass("cf_image_scaler_fit") && ($(self).hasClass("cf_image_scaler_fill") || settings.method === "fill")) { 1342 scale = ratioX > ratioY ? ratioX : ratioY; 1343 } 1344 1345 // calculate our new image dimensions 1346 newWidth = parseInt($(self).width() * scale, 10); 1347 newHeight = parseInt($(self).height() * scale, 10); 1348 1349 // Set new dimensions & offset 1350 $(self).css({ 1351 "width": newWidth + "px", 1352 "height": newHeight + "px", 1353 "position": "absolute", 1354 "top": parseInt((destH - newHeight) / 2, 10) + "px", 1355 "left": parseInt((destW - newWidth) / 2, 10) + "px" 1356 }).attr({ 1357 "width": newWidth, 1358 "height": newHeight 1359 }); 1360 1361 // do our fancy fade in, if user supplied a fade amount 1362 if (settings.fade > 0) { 1363 $(self).fadeIn(settings.fade); 1364 } 1365 1366 } 1367 1368 /* 1369 initialize the flipBox 1370 ***************************************/ 1371 function init() { 1372 1373 var self = $(sys.elem)[0]; 1374 1375 // check to make sure we have a valid destination object 1376 if (settings.destObj === null || typeof settings.method !== "string" || typeof $(settings.destObj)[0] !== "object") { 1377 return; 1378 } else { 1379 1380 // need to make sure the user set the parent's position 1381 // things go bonkers, if not set. 1382 if ($(settings.destObj).css("position") === "static") { 1383 $(settings.destObj).css({ 1384 "position": "relative" 1385 }); 1386 } 1387 1388 // if the user supplied a fade amount, hide our image 1389 if (settings.fade > 0) { 1390 $(self).hide(); 1391 } 1392 1393 // run our scale function. Special case for images, we need 1394 // to make sure the image has loaded in order to get the width & height 1395 if ($(self)[0].nodeName === "IMG") { 1396 // check to see if the image is already loaded 1397 if ($(self).attr("complete")) { 1398 scale($(self)[0]); 1399 } else { 1400 $(self).load(function () { 1401 scale($(self)[0]); 1402 }); 1403 } 1404 } else { 1405 scale($(self)[0]); 1406 } 1407 1408 } 1409 } 1410 1411 /* 1412 set up any user passed variables 1413 ***************************************/ 1414 if (options) { 1415 $.extend(settings, options); 1416 } 1417 1418 /* 1419 main 1420 ***************************************/ 1421 return this.each(function () { 1422 sys.elem = this; 1423 init(); 1424 }); 1425 1426 }; 1427})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.