init
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,11 @@
|
||||
/*! tableSorter 2.3 widgets - updated 6/21/2012 */
|
||||
;(function(b){
|
||||
b.tablesorter.storage=function(e,a,c){var d,i=!1;d={};var k=e.id||b(".tablesorter").index(b(e)),h=window.location.pathname;try{i=!!localStorage.getItem}catch(f){}b.parseJSON&&(i?d=b.parseJSON(localStorage[a])||{}:(d=document.cookie.split(/[;\s|=]/),e=b.inArray(a,d)+1,d=0!==e?b.parseJSON(d[e])||{}:{}));if(c&&JSON&&JSON.hasOwnProperty("stringify")){if(!d[h]||!d[h][k])d[h]||(d[h]={});d[h][k]=c;i?localStorage[a]=JSON.stringify(d):(e=new Date,e.setTime(e.getTime()+31536E6),document.cookie= a+"="+JSON.stringify(d).replace(/\"/g,'"')+"; expires="+e.toGMTString()+"; path=/")}else return d&&d.hasOwnProperty(h)&&d[h].hasOwnProperty(k)?d[h][k]:{}};
|
||||
b.tablesorter.addWidget({id:"uitheme",format:function(e){var a,c,d,i,k,h=b(e),f=e.config,l=f.widgetOptions,g=["ui-icon-arrowthick-2-n-s","ui-icon-arrowthick-1-s","ui-icon-arrowthick-1-n"],g=f.widgetUitheme&&f.widgetUitheme.hasOwnProperty("css")?f.widgetUitheme.css||g:l&&l.hasOwnProperty("uitheme")?l.uitheme:g;d=g.join(" ");f.debug&&(a=new Date); h.hasClass("ui-theme")||(h.addClass("ui-widget ui-widget-content ui-corner-all ui-theme"),b.each(f.headerList,function(){b(this).addClass("ui-widget-header ui-corner-all ui-state-default").append('<span class="ui-icon"/>').wrapInner('<div class="tablesorter-inner"/>').hover(function(){b(this).addClass("ui-state-hover")},function(){b(this).removeClass("ui-state-hover")})}));b.each(f.headerList,function(a){i=b(this);if(this.sortDisabled)i.find("span.ui-icon").removeClass(d+" ui-icon");else{c=i.hasClass(f.cssAsc)? g[1]:i.hasClass(f.cssDesc)?g[2]:i.hasClass(f.cssHeader)?g[0]:"";k=h.hasClass("hasStickyHeaders")?h.find("tr."+(l.stickyHeaders||"tablesorter-stickyHeader")).find("th").eq(a).add(i):i;k[c===g[0]?"removeClass":"addClass"]("ui-state-active").find("span.ui-icon").removeClass(d).addClass(c)}});f.debug&&b.tablesorter.benchmark("Applying uitheme widget",a)}});
|
||||
b.tablesorter.addWidget({id:"columns",format:function(e){var a,c,d,i,k,h,f,l,g=e.config,m=b(e).children("tbody:not(."+g.cssInfoBlock+")"),p=g.sortList, r=p.length,q=["primary","secondary","tertiary"],q=g.widgetColumns&&g.widgetColumns.hasOwnProperty("css")?g.widgetColumns.css||q:g.widgetOptions&&g.widgetOptions.hasOwnProperty("columns")?g.widgetOptions.columns||q:q;k=q.length-1;h=q.join(" ");g.debug&&(i=new Date);for(l=0;l<m.length;l++)e=b(m[l]),a=e.addClass("tablesorter-hidden").children("tr"),a.each(function(){d=b(this);if("none"!==this.style.display&&(c=d.children().removeClass(h),p&&p[0]&&(c.eq(p[0][0]).addClass(q[0]),1<r)))for(f=1;f<r;f++)c.eq(p[f][0]).addClass(q[f]|| q[k])}),e.removeClass("tablesorter-hidden");g.debug&&b.tablesorter.benchmark("Applying Columns widget",i)}});
|
||||
b.tablesorter.addWidget({id:"filter",format:function(e){if(e.config.parsers&&!b(e).hasClass("hasFilters")){var a,c,d,i,k,h,f,l,g,m,p,r,q,z,v,t,D,A,n=e.config,w=b(n.headerList),j=n.widgetOptions,s=j.filter_cssFilter||"tablesorter-filter",u=b(e).addClass("hasFilters"),B=u.children("tbody:not(."+n.cssInfoBlock+")"),C=n.parsers.length,o='<tr class="'+s+'">',E=/^\/((?:\\\/|[^\/])+)\/([mig]{0,3})?$/, I=RegExp(n.cssChildRow),x,F,y=function(){n.debug&&(x=new Date);h=u.find("thead").eq(0).children("tr").find("select."+s+", input."+s).map(function(){return b(this).val()||""}).get();k=h.join("");for(d=0;d<B.length;d++){z=b(B[d]);t=z.addClass("tablesorter-hidden").children("tr");i=t.length;for(c=0;c<i;c++)if(""===k)t[c].style.display="";else if(!I.test(t[c].className)){l=!0;q=t.eq(c).nextUntil("tr:not(."+n.cssChildRow+")");m=q.length&&(j&&j.hasOwnProperty("filter_childRows")&&"undefined"!==typeof j.filter_childRows? j.filter_childRows:1)?q.text():"";m=j.filter_ignoreCase?m.toLocaleLowerCase():m;D=t.eq(c).children("td");for(a=0;a<C;a++)if(p=b.trim(D.eq(a).text()),r=j.filter_ignoreCase?p.toLocaleLowerCase():p,""!==h[a]){g=l;f=j.filter_ignoreCase?h[a].toLocaleLowerCase():h[a];if(j.filter_functions&&j.filter_functions[a])!0===j.filter_functions[a]?g=j.filter_ignoreCase?f===r:h[a]===p:"function"===typeof j.filter_functions[a]?g=j.filter_functions[a](p,n.cache[d].normalized[c][a],h[a],a):"function"===typeof j.filter_functions[a][h[a]]&& (g=j.filter_functions[a][h[a]](p,n.cache[d].normalized[c][a],h[a],a));else if(E.test(f)){A=E.exec(f);try{g=RegExp(A[1],A[2]).test(r)}catch(e){g=!1}}else/[\"|\']$/.test(f)&&r===f.replace(/(\"|\')/g,"")?g=!0:/[\?|\*]/.test(f)?g=RegExp(f.replace(/\?/g,"\\S{1}").replace(/\*/g,"\\S*")).test(r):(p=(r+m).indexOf(f),g=!j.filter_startsWith&&0<=p||j.filter_startsWith&&0===p);l=g?l?!0:!1:!1}t[c].style.display=l?"":"none";if(q.length)q[l?"show":"hide"]()}z.removeClass("tablesorter-hidden")}n.debug&&b.tablesorter.benchmark("Completed filter widget search", x);u.trigger("applyWidgets")},G=function(a,e){var f,g=[],a=parseInt(a,10);f='<option value="">'+(w.filter('[data-column="'+a+'"]:last').attr("data-placeholder")||"")+"</option>";for(d=0;d<B.length;d++){i=n.cache[d].row.length;for(c=0;c<i;c++)(m=n.cache[d].row[c][0].cells[a])&&g.push(n.supportsTextContent?m.textContent:b(m).text())}g=g.getUnique(!0);for(d=0;d<g.length;d++)f+='<option value="'+g[d]+'">'+g[d]+"</option>";u.find("thead").find("select."+s+'[data-column="'+a+'"]')[e?"html":"append"](f)}, H=function(b){for(a=0;a<C;a++)m=w.filter('[data-column="'+a+'"]:last'),m.hasClass("filter-select")&&(!m.hasClass("filter-false")&&!(j.filter_functions&&!0===j.filter_functions[a]))&&G(a,b)};n.debug&&(x=new Date);j.filter_ignoreCase=!1!==j.filter_ignoreCase;for(a=0;a<C;a++)v=w.filter('[data-column="'+a+'"]:last'),e=j.filter_functions&&j.filter_functions[a]&&"function"!==typeof j.filter_functions[a]||v.hasClass("filter-select"),o+="<td>",o=e?o+('<select data-column="'+a+'" class="'+s):o+('<input type="search" placeholder="'+ (v.attr("data-placeholder")||"")+'" data-column="'+a+'" class="'+s),o=b.tablesorter.getData?o+("false"===b.tablesorter.getData(v[0],n.headers[a],"filter")?' disabled" disabled':'"'):o+(n.headers[a]&&n.headers[a].hasOwnProperty("filter")&&!1===n.headers[a].filter||v.hasClass("filter-false")?' disabled" disabled':'"'),o+=(e?"></select>":">")+"</td>";u.bind("addRows updateCell update appendCache",function(){H(!0);y()}).find("thead").eq(0).append(o+="</tr>").find("input."+s).bind("keyup search",function(a, b){32>a.which&&8!==a.which||37<=a.which&&40>=a.which||(!1===b?y():(clearTimeout(F),F=setTimeout(function(){y()},j.filter_searchDelay||300)))});if(j.filter_functions)for(a in j.filter_functions)if(m=w.filter('[data-column="'+a+'"]:last'),o="","string"===typeof a&&!0===j.filter_functions[a]&&!m.hasClass("filter-false"))G(a);else if("string"===typeof a&&!m.hasClass("filter-false")){for(c in j.filter_functions[a])"string"===typeof c&&(o+=""===o?"<option>"+(m.attr("data-placeholder")||"")+"</option>": "",o+="<option>"+c+"</option>");u.find("thead").find("select."+s+'[data-column="'+a+'"]').append(o)}H();u.find("select."+s).bind("change",function(){y()});n.debug&&b.tablesorter.benchmark("Applying Filter widget",x)}}});
|
||||
b.tablesorter.addWidget({id:"stickyHeaders",format:function(e){if(!b(e).hasClass("hasStickyHeaders")){var a=b(e).addClass("hasStickyHeaders"),c=e.config.widgetOptions,d=b(window),i=b(e).children("thead"),k=i.children("tr:not(.sticky-false)").children(),h=c.stickyHeaders||"tablesorter-stickyHeader", f=k.eq(0),l=a.find("tfoot"),g=i.find("tr.tablesorter-header:not(.sticky-false)").clone().removeClass("tablesorter-header").addClass(h).css({width:i.outerWidth(!0),position:"fixed",left:f.offset().left,margin:0,top:0,visibility:"hidden",zIndex:10}),m=g.children(),p="";a.bind("sortEnd",function(a,d){var c=b(d).find("thead tr"),e=c.filter("."+h).children();c.filter(":not(."+h+")").children().each(function(a){e.eq(a).attr("class",b(this).attr("class"))})}).bind("pagerComplete",function(){d.resize()}); k.each(function(a){var d=b(this);m.eq(a).bind("mouseup",function(a){d.trigger(a,!0)}).bind("mousedown",function(){this.onselectstart=function(){return!1};return!1}).find(".tablesorter-header-inner").width(d.find(".tablesorter-header-inner").width())});i.prepend(g);d.scroll(function(){var b=f.offset(),c=d.scrollTop(),e=a.height()-(f.height()+(l.height()||0)),c=c>b.top&&c<b.top+e?"visible":"hidden";g.css({left:b.left-d.scrollLeft(),visibility:c});c!==p&&(d.resize(),p=c)}).resize(function(){var a=0; g.css({left:f.offset().left-d.scrollLeft(),width:i.outerWidth()}).each(function(c){b(this).css("top",a);a+=i.find("tr").eq(c).outerHeight()});m.find(".tablesorter-header-inner").each(function(a){b(this).width(k.eq(a).find(".tablesorter-header-inner").width())})})}}});
|
||||
b.tablesorter.addWidget({id:"resizable",format:function(e){if(!b(e).hasClass("hasResizable")){b(e).addClass("hasResizable");var a,c,d=e.config,i=b(d.headerList).filter(":gt(0)"),k=0,h=null,f=null,l=function(){k=0;h=f=null;b(window).trigger("resize")}; if(c=b.tablesorter.storage?b.tablesorter.storage(e,"tablesorter-resizable"):"")for(a in c)!isNaN(a)&&a<d.headerList.length&&b(d.headerList[a]).width(c[a]);i.each(function(){b(this).append('<div class="tablesorter-resizer" style="cursor:w-resize;position:absolute;height:100%;width:20px;left:-20px;top:0;z-index:1;"></div>').wrapInner('<div style="position:relative;height:100%;width:100%"></div>')}).bind("mousemove",function(a){if(0!==k&&h){var b=a.pageX-k;h.width()<-b||f&&f.width()<=b||(f.width(f.width()+ b),k=a.pageX)}}).bind("mouseup",function(){c&&(b.tablesorter.storage&&h)&&(c[f.index()]=f.width(),b.tablesorter.storage(e,"tablesorter-resizable",c));l();return!1}).find(".tablesorter-resizer").bind("mousedown",function(a){h=b(a.target).closest("th");f=h.prev();k=a.pageX;return!1});b(e).find("thead").bind("mouseup mouseleave",function(){l()})}}});
|
||||
b.tablesorter.addWidget({id:"saveSort",init:function(b,a,c){c.format(b,!0)},format:function(e,a){var c,d,i=e.config;c={sortList:i.sortList};i.debug&&(d= new Date);b(e).hasClass("hasSaveSort")?e.hasInitialized&&b.tablesorter.storage&&(b.tablesorter.storage(e,"tablesorter-savesort",c),i.debug&&b.tablesorter.benchmark("saveSort widget: Saving last sort: "+i.sortList,d)):(b(e).addClass("hasSaveSort"),c="",b.tablesorter.storage&&(c=(c=b.tablesorter.storage(e,"tablesorter-savesort"))&&c.hasOwnProperty("sortList")&&b.isArray(c.sortList)?c.sortList:"",i.debug&&b.tablesorter.benchmark("saveSort: Last sort loaded: "+c,d)),a&&c&&0<c.length?i.sortList=c:e.hasInitialized&& (c&&0<c.length)&&b(e).trigger("sorton",[c]))}})
|
||||
})(jQuery);
|
||||
Array.prototype.getUnique=function(b){var e,a=[],c={},d,i=0,k=this.length;for(d=0;d<k;++d)e=this[d],c[e]||(c[e]={},a[i++]=e);return b?a.sort():a};
|
||||
@@ -0,0 +1,308 @@
|
||||
/*
|
||||
* jQuery treeTable Plugin VERSION
|
||||
* http://ludo.cubicphuse.nl/jquery-plugins/treeTable/doc/
|
||||
*
|
||||
* Copyright 2011, Ludo van den Boom
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
*/
|
||||
(function($) {
|
||||
// Helps to make options available to all functions
|
||||
// TODO: This gives problems when there are both expandable and non-expandable
|
||||
// trees on a page. The options shouldn't be global to all these instances!
|
||||
var options;
|
||||
var defaultPaddingLeft;
|
||||
var persistStore;
|
||||
|
||||
$.fn.treeTable = function(opts) {
|
||||
options = $.extend({}, $.fn.treeTable.defaults, opts);
|
||||
|
||||
if(options.persist) {
|
||||
persistStore = new Persist.Store(options.persistStoreName);
|
||||
}
|
||||
|
||||
return this.each(function() {
|
||||
$(this).addClass("treeTable").find("tbody tr").each(function() {
|
||||
// Skip initialized nodes.
|
||||
if (!$(this).hasClass('initialized')) {
|
||||
var isRootNode = ($(this)[0].className.search(options.childPrefix) == -1);
|
||||
|
||||
// To optimize performance of indentation, I retrieve the padding-left
|
||||
// value of the first root node. This way I only have to call +css+
|
||||
// once.
|
||||
if (isRootNode && isNaN(defaultPaddingLeft)) {
|
||||
defaultPaddingLeft = parseInt($($(this).children("td")[options.treeColumn]).css('padding-left'), 10);
|
||||
}
|
||||
|
||||
// Set child nodes to initial state if we're in expandable mode.
|
||||
if(!isRootNode && options.expandable && options.initialState == "collapsed") {
|
||||
$(this).addClass('ui-helper-hidden');
|
||||
}
|
||||
|
||||
// If we're not in expandable mode, initialize all nodes.
|
||||
// If we're in expandable mode, only initialize root nodes.
|
||||
if(!options.expandable || isRootNode) {
|
||||
initialize($(this));
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.treeTable.defaults = {
|
||||
childPrefix: "child-of-",
|
||||
clickableNodeNames: false,
|
||||
expandable: true,
|
||||
indent: 19,
|
||||
initialState: "collapsed",
|
||||
onNodeShow: null,
|
||||
onNodeHide: null,
|
||||
treeColumn: 0,
|
||||
persist: false,
|
||||
persistStoreName: 'treeTable',
|
||||
stringExpand: "Expand",
|
||||
stringCollapse: "Collapse"
|
||||
};
|
||||
|
||||
//Expand all nodes
|
||||
$.fn.expandAll = function() {
|
||||
$(this).find("tr").each(function() {
|
||||
$(this).expand();
|
||||
});
|
||||
};
|
||||
|
||||
//Collapse all nodes
|
||||
$.fn.collapseAll = function() {
|
||||
$(this).find("tr").each(function() {
|
||||
$(this).collapse();
|
||||
});
|
||||
};
|
||||
|
||||
// Recursively hide all node's children in a tree
|
||||
$.fn.collapse = function() {
|
||||
return this.each(function() {
|
||||
$(this).removeClass("expanded").addClass("collapsed");
|
||||
|
||||
if (options.persist) {
|
||||
persistNodeState($(this));
|
||||
}
|
||||
|
||||
childrenOf($(this)).each(function() {
|
||||
if(!$(this).hasClass("collapsed")) {
|
||||
$(this).collapse();
|
||||
}
|
||||
|
||||
$(this).addClass('ui-helper-hidden');
|
||||
|
||||
if($.isFunction(options.onNodeHide)) {
|
||||
options.onNodeHide.call(this);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// Recursively show all node's children in a tree
|
||||
$.fn.expand = function() {
|
||||
return this.each(function() {
|
||||
$(this).removeClass("collapsed").addClass("expanded");
|
||||
|
||||
if (options.persist) {
|
||||
persistNodeState($(this));
|
||||
}
|
||||
|
||||
childrenOf($(this)).each(function() {
|
||||
initialize($(this));
|
||||
|
||||
if($(this).is(".expanded.parent")) {
|
||||
$(this).expand();
|
||||
}
|
||||
|
||||
$(this).removeClass('ui-helper-hidden');
|
||||
|
||||
if($.isFunction(options.onNodeShow)) {
|
||||
options.onNodeShow.call(this);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// Reveal a node by expanding all ancestors
|
||||
$.fn.reveal = function() {
|
||||
$(ancestorsOf($(this)).reverse()).each(function() {
|
||||
initialize($(this));
|
||||
$(this).expand().show();
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
// Add an entire branch to +destination+
|
||||
$.fn.appendBranchTo = function(destination) {
|
||||
var node = $(this);
|
||||
var parent = parentOf(node);
|
||||
|
||||
var ancestorNames = $.map(ancestorsOf($(destination)), function(a) { return a.id; });
|
||||
|
||||
// Conditions:
|
||||
// 1: +node+ should not be inserted in a location in a branch if this would
|
||||
// result in +node+ being an ancestor of itself.
|
||||
// 2: +node+ should not have a parent OR the destination should not be the
|
||||
// same as +node+'s current parent (this last condition prevents +node+
|
||||
// from being moved to the same location where it already is).
|
||||
// 3: +node+ should not be inserted as a child of +node+ itself.
|
||||
if($.inArray(node[0].id, ancestorNames) == -1 && (!parent || (destination.id != parent[0].id)) && destination.id != node[0].id) {
|
||||
indent(node, ancestorsOf(node).length * options.indent * -1); // Remove indentation
|
||||
|
||||
if(parent) { node.removeClass(options.childPrefix + parent[0].id); }
|
||||
|
||||
node.addClass(options.childPrefix + destination.id);
|
||||
move(node, destination); // Recursively move nodes to new location
|
||||
indent(node, ancestorsOf(node).length * options.indent);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
// Add reverse() function from JS Arrays
|
||||
$.fn.reverse = function() {
|
||||
return this.pushStack(this.get().reverse(), arguments);
|
||||
};
|
||||
|
||||
// Toggle an entire branch
|
||||
$.fn.toggleBranch = function() {
|
||||
if($(this).hasClass("collapsed")) {
|
||||
$(this).expand();
|
||||
} else {
|
||||
$(this).collapse();
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
// === Private functions
|
||||
|
||||
function ancestorsOf(node) {
|
||||
var ancestors = [];
|
||||
while(node = parentOf(node)) {
|
||||
ancestors[ancestors.length] = node[0];
|
||||
}
|
||||
return ancestors;
|
||||
};
|
||||
|
||||
function childrenOf(node) {
|
||||
return $(node).siblings("tr." + options.childPrefix + node[0].id);
|
||||
};
|
||||
|
||||
function getPaddingLeft(node) {
|
||||
var paddingLeft = parseInt(node[0].style.paddingLeft, 10);
|
||||
return (isNaN(paddingLeft)) ? defaultPaddingLeft : paddingLeft;
|
||||
}
|
||||
|
||||
function indent(node, value) {
|
||||
var cell = $(node.children("td")[options.treeColumn]);
|
||||
cell[0].style.paddingLeft = getPaddingLeft(cell) + value + "px";
|
||||
|
||||
childrenOf(node).each(function() {
|
||||
indent($(this), value);
|
||||
});
|
||||
};
|
||||
|
||||
function initialize(node) {
|
||||
if(!node.hasClass("initialized")) {
|
||||
node.addClass("initialized");
|
||||
|
||||
var childNodes = childrenOf(node);
|
||||
|
||||
if(!node.hasClass("parent") && childNodes.length > 0) {
|
||||
node.addClass("parent");
|
||||
}
|
||||
|
||||
if(node.hasClass("parent")) {
|
||||
var cell = $(node.children("td")[options.treeColumn]);
|
||||
var padding = getPaddingLeft(cell) + options.indent;
|
||||
|
||||
childNodes.each(function() {
|
||||
$(this).children("td")[options.treeColumn].style.paddingLeft = padding + "px";
|
||||
});
|
||||
|
||||
if(options.expandable) {
|
||||
var newLink = '<a href="#" title="' + options.stringExpand + '" style="margin-left: -' + options.indent + 'px; padding-left: ' + options.indent + 'px" class="expander"></a>';
|
||||
|
||||
if(options.clickableNodeNames) {
|
||||
cell.wrapInner(newLink);
|
||||
} else {
|
||||
cell.html(newLink+cell.html());
|
||||
}
|
||||
|
||||
$(cell[0].firstChild).click(function() { node.toggleBranch(); return false; }).mousedown(function() { return false; });
|
||||
$(cell[0].firstChild).keydown(function(e) { if(e.keyCode == 13) { node.toggleBranch(); return false; }});
|
||||
|
||||
if(options.clickableNodeNames) {
|
||||
cell[0].style.cursor = "pointer";
|
||||
$(cell).click(function(e) {
|
||||
// Don't double-toggle if the click is on the existing expander icon
|
||||
if (e.target.className != 'expander') {
|
||||
node.toggleBranch();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (options.persist && getPersistedNodeState(node)) {
|
||||
node.addClass('expanded');
|
||||
}
|
||||
|
||||
// Check for a class set explicitly by the user, otherwise set the default class
|
||||
if(!(node.hasClass("expanded") || node.hasClass("collapsed"))) {
|
||||
node.addClass(options.initialState);
|
||||
}
|
||||
|
||||
if(node.hasClass("expanded")) {
|
||||
node.expand();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function move(node, destination) {
|
||||
node.insertAfter(destination);
|
||||
childrenOf(node).reverse().each(function() { move($(this), node[0]); });
|
||||
};
|
||||
|
||||
function parentOf(node) {
|
||||
var classNames = node[0].className.split(' ');
|
||||
|
||||
for(var key=0; key<classNames.length; key++) {
|
||||
if(classNames[key].match(options.childPrefix)) {
|
||||
return $(node).siblings("#" + classNames[key].substring(options.childPrefix.length));
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
//saving state functions, not critical, so will not generate alerts on error
|
||||
function persistNodeState(node) {
|
||||
if(node.hasClass('expanded')) {
|
||||
try {
|
||||
persistStore.set(node.attr('id'), '1');
|
||||
} catch (err) {
|
||||
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
persistStore.remove(node.attr('id'));
|
||||
} catch (err) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getPersistedNodeState(node) {
|
||||
try {
|
||||
return persistStore.get(node.attr('id')) == '1';
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,31 @@
|
||||
(function(){if(window.google&&google.gears){return;}
|
||||
var F=null;if(typeof GearsFactory!='undefined'){F=new GearsFactory();}else{try{F=new ActiveXObject('Gears.Factory');if(F.getBuildInfo().indexOf('ie_mobile')!=-1){F.privateSetGlobalObject(this);}}catch(e){if((typeof navigator.mimeTypes!='undefined')&&navigator.mimeTypes["application/x-googlegears"]){F=document.createElement("object");F.style.display="none";F.width=0;F.height=0;F.type="application/x-googlegears";document.documentElement.appendChild(F);}}}
|
||||
if(!F){return;}
|
||||
if(!window.google){google={};}
|
||||
if(!google.gears){google.gears={factory:F};}})();Persist=(function(){var VERSION='0.3.1',P,B,esc,init,empty,ec;ec=(function(){var EPOCH='Thu, 01-Jan-1970 00:00:01 GMT',RATIO=1000*60*60*24,KEYS=['expires','path','domain'],esc=escape,un=unescape,doc=document,me;var get_now=function(){var r=new Date();r.setTime(r.getTime());return r;};var cookify=function(c_key,c_val){var i,key,val,r=[],opt=(arguments.length>2)?arguments[2]:{};r.push(esc(c_key)+'='+esc(c_val));for(var idx=0;idx<KEYS.length;idx++){key=KEYS[idx];val=opt[key];if(val){r.push(key+'='+val);}}
|
||||
if(opt.secure){r.push('secure');}
|
||||
return r.join('; ');};var alive=function(){var k='__EC_TEST__',v=new Date();v=v.toGMTString();this.set(k,v);this.enabled=(this.remove(k)==v);return this.enabled;};me={set:function(key,val){var opt=(arguments.length>2)?arguments[2]:{},now=get_now(),expire_at,cfg={};if(opt.expires){var expires=opt.expires*RATIO;cfg.expires=new Date(now.getTime()+expires);cfg.expires=cfg.expires.toGMTString();}
|
||||
var keys=['path','domain','secure'];for(var i=0;i<keys.length;i++){if(opt[keys[i]]){cfg[keys[i]]=opt[keys[i]];}}
|
||||
var r=cookify(key,val,cfg);doc.cookie=r;return val;},has:function(key){key=esc(key);var c=doc.cookie,ofs=c.indexOf(key+'='),len=ofs+key.length+1,sub=c.substring(0,key.length);return((!ofs&&key!=sub)||ofs<0)?false:true;},get:function(key){key=esc(key);var c=doc.cookie,ofs=c.indexOf(key+'='),len=ofs+key.length+1,sub=c.substring(0,key.length),end;if((!ofs&&key!=sub)||ofs<0){return null;}
|
||||
end=c.indexOf(';',len);if(end<0){end=c.length;}
|
||||
return un(c.substring(len,end));},remove:function(k){var r=me.get(k),opt={expires:EPOCH};doc.cookie=cookify(k,'',opt);return r;},keys:function(){var c=doc.cookie,ps=c.split('; '),i,p,r=[];for(var idx=0;idx<ps.length;idx++){p=ps[idx].split('=');r.push(un(p[0]));}
|
||||
return r;},all:function(){var c=doc.cookie,ps=c.split('; '),i,p,r=[];for(var idx=0;idx<ps.length;idx++){p=ps[idx].split('=');r.push([un(p[0]),un(p[1])]);}
|
||||
return r;},version:'0.2.1',enabled:false};me.enabled=alive.call(me);return me;}());var index_of=(function(){if(Array.prototype.indexOf){return function(ary,val){return Array.prototype.indexOf.call(ary,val);};}else{return function(ary,val){var i,l;for(var idx=0,len=ary.length;idx<len;idx++){if(ary[idx]==val){return idx;}}
|
||||
return-1;};}})();empty=function(){};esc=function(str){return'PS'+str.replace(/_/g,'__').replace(/ /g,'_s');};var C={search_order:['localstorage','globalstorage','gears','cookie','ie','flash'],name_re:/^[a-z][a-z0-9_ \-]+$/i,methods:['init','get','set','remove','load','save','iterate'],sql:{version:'1',create:"CREATE TABLE IF NOT EXISTS persist_data (k TEXT UNIQUE NOT NULL PRIMARY KEY, v TEXT NOT NULL)",get:"SELECT v FROM persist_data WHERE k = ?",set:"INSERT INTO persist_data(k, v) VALUES (?, ?)",remove:"DELETE FROM persist_data WHERE k = ?",keys:"SELECT * FROM persist_data"},flash:{div_id:'_persist_flash_wrap',id:'_persist_flash',path:'persist.swf',size:{w:1,h:1},params:{autostart:true}}};B={gears:{size:-1,test:function(){return(window.google&&window.google.gears)?true:false;},methods:{init:function(){var db;db=this.db=google.gears.factory.create('beta.database');db.open(esc(this.name));db.execute(C.sql.create).close();},get:function(key){var r,sql=C.sql.get;var db=this.db;var ret;db.execute('BEGIN').close();r=db.execute(sql,[key]);ret=r.isValidRow()?r.field(0):null;r.close();db.execute('COMMIT').close();return ret;},set:function(key,val){var rm_sql=C.sql.remove,sql=C.sql.set,r;var db=this.db;var ret;db.execute('BEGIN').close();db.execute(rm_sql,[key]).close();db.execute(sql,[key,val]).close();db.execute('COMMIT').close();return val;},remove:function(key){var get_sql=C.sql.get,sql=C.sql.remove,r,val=null,is_valid=false;var db=this.db;db.execute('BEGIN').close();db.execute(sql,[key]).close();db.execute('COMMIT').close();return true;},iterate:function(fn,scope){var key_sql=C.sql.keys;var r;var db=this.db;r=db.execute(key_sql);while(r.isValidRow()){fn.call(scope||this,r.field(0),r.field(1));r.next();}
|
||||
r.close();}}},globalstorage:{size:5*1024*1024,test:function(){if(window.globalStorage){var domain='127.0.0.1';if(this.o&&this.o.domain){domain=this.o.domain;}
|
||||
try{var dontcare=globalStorage[domain];return true;}catch(e){if(window.console&&window.console.warn){console.warn("globalStorage exists, but couldn't use it because your browser is running on domain:",domain);}
|
||||
return false;}}else{return false;}},methods:{key:function(key){return esc(this.name)+esc(key);},init:function(){this.store=globalStorage[this.o.domain];},get:function(key){key=this.key(key);return this.store.getItem(key);},set:function(key,val){key=this.key(key);this.store.setItem(key,val);return val;},remove:function(key){var val;key=this.key(key);val=this.store.getItem[key];this.store.removeItem(key);return val;}}},localstorage:{size:-1,test:function(){try{if(window.localStorage&&window.localStorage.setItem("test",null)==undefined){if(/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){var ffVersion=RegExp.$1;if(ffVersion>=9){return true;}
|
||||
if(window.location.protocol=='file:'){return false;}}else{return true;}}else{return false;}
|
||||
return window.localStorage?true:false;}catch(e){return false;}},methods:{key:function(key){return this.name+'>'+key;},init:function(){this.store=localStorage;},get:function(key){key=this.key(key);return this.store.getItem(key);},set:function(key,val){key=this.key(key);this.store.setItem(key,val);return val;},remove:function(key){var val;key=this.key(key);val=this.store.getItem(key);this.store.removeItem(key);return val;},iterate:function(fn,scope){var l=this.store,key,keys;for(var i=0;i<l.length;i++){key=l.key(i);keys=key.split('>');if((keys.length==2)&&(keys[0]==this.name)){fn.call(scope||this,keys[1],l.getItem(key));}}}}},ie:{prefix:'_persist_data-',size:64*1024,test:function(){return window.ActiveXObject?true:false;},make_userdata:function(id){var el=document.createElement('div');el.id=id;el.style.display='none';el.addBehavior('#default#userdata');document.body.appendChild(el);return el;},methods:{init:function(){var id=B.ie.prefix+esc(this.name);this.el=B.ie.make_userdata(id);if(this.o.defer){this.load();}},get:function(key){var val;key=esc(key);if(!this.o.defer){this.load();}
|
||||
val=this.el.getAttribute(key);return val;},set:function(key,val){key=esc(key);this.el.setAttribute(key,val);if(!this.o.defer){this.save();}
|
||||
return val;},remove:function(key){var val;key=esc(key);if(!this.o.defer){this.load();}
|
||||
val=this.el.getAttribute(key);this.el.removeAttribute(key);if(!this.o.defer){this.save();}
|
||||
return val;},load:function(){this.el.load(esc(this.name));},save:function(){this.el.save(esc(this.name));}}},cookie:{delim:':',size:4000,test:function(){return P.Cookie.enabled?true:false;},methods:{key:function(key){return this.name+B.cookie.delim+key;},get:function(key,fn){var val;key=this.key(key);val=ec.get(key);return val;},set:function(key,val,fn){key=this.key(key);ec.set(key,val,this.o);return val;},remove:function(key,val){var val;key=this.key(key);val=ec.remove(key);return val;}}},flash:{test:function(){try{if(!swfobject){return false;}}catch(e){return false;}
|
||||
var major=swfobject.getFlashPlayerVersion().major;return(major>=8)?true:false;},methods:{init:function(){if(!B.flash.el){var key,el,fel,cfg=C.flash;el=document.createElement('div');el.id=cfg.div_id;fel=document.createElement('div');fel.id=cfg.id;el.appendChild(fel);document.body.appendChild(el);B.flash.el=swfobject.createSWF({id:cfg.id,data:this.o.swf_path||cfg.path,width:cfg.size.w,height:cfg.size.h},cfg.params,cfg.id);}
|
||||
this.el=B.flash.el;},get:function(key){var val;key=esc(key);val=this.el.get(this.name,key);return val;},set:function(key,val){var old_val;key=esc(key);old_val=this.el.set(this.name,key,val);return old_val;},remove:function(key){var val;key=esc(key);val=this.el.remove(this.name,key);return val;}}}};init=function(){var i,l,b,key,fns=C.methods,keys=C.search_order;for(var idx=0,len=fns.length;idx<len;idx++){P.Store.prototype[fns[idx]]=empty;}
|
||||
P.type=null;P.size=-1;for(var idx2=0,len2=keys.length;!P.type&&idx2<len2;idx2++){b=B[keys[idx2]];if(b.test()){P.type=keys[idx2];P.size=b.size;for(key in b.methods){P.Store.prototype[key]=b.methods[key];}}}
|
||||
P._init=true;};P={VERSION:VERSION,type:null,size:0,add:function(o){B[o.id]=o;C.search_order=[o.id].concat(C.search_order);init();},remove:function(id){var ofs=index_of(C.search_order,id);if(ofs<0){return;}
|
||||
C.search_order.splice(ofs,1);delete B[id];init();},Cookie:ec,Store:function(name,o){if(!C.name_re.exec(name)){throw new Error("Invalid name");}
|
||||
if(!P.type){throw new Error("No suitable storage found");}
|
||||
o=o||{};this.name=name;o.domain=o.domain||location.hostname||'localhost';o.domain=o.domain.replace(/:\d+$/,'');o.domain=(o.domain=='localhost')?'':o.domain;this.o=o;o.expires=o.expires||365*2;o.path=o.path||'/';if(this.o.search_order){C.search_order=this.o.search_order;init();}
|
||||
this.init();}};init();return P;})();
|
||||
Reference in New Issue
Block a user