Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

remove minified version, it will be included in version tags from now on

  • Loading branch information...
commit 6d0330076300ac9571cf04dce950f3714f46afef 1 parent b3fd4b8
@kflorence authored
Showing with 0 additions and 19 deletions.
  1. +0 −19 src/jquery.tabulate.min.js
View
19 src/jquery.tabulate.min.js
@@ -1,19 +0,0 @@
-/*
- * jQuery.tabulate Plugin
- * Copyright (C) 2010 Kyle Florence <kyle.florence@gmail.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-;(function(a,c){var $=a.jQuery||a.Cowboy||(a.Cowboy={}),b;$.getObject=b=function(g,d,f){if(typeof g==="string"){g=g.split(".")}if(typeof d!=="boolean"){f=d;d=c}f=f||a;var e;while(f&&g.length){e=g.shift();if(f[e]===c&&d){f[e]={}}f=f[e]}return f};$.setObject=function(d,f,e){var h=d.split("."),i=h.pop(),g=b(h,true,e);return g&&typeof g==="object"&&i?(g[i]=f):c};$.exists=function(d,e){return b(d,e)!==c}})(this);(function($){$.getLength=function(a){if($.isArray(a)||typeof a==="string")return a.length;else if(typeof a==="object"){var len=0;$.each(a,function(){len++;});return len;}else return undefined;};$.isNumber=function(n){return!isNaN(parseFloat(n))&&isFinite(n);};$.isEmpty=function(o){if($.isArray(o)||typeof o==="string"){return(o.length?false:true);}else if(typeof o==="object"){for(var p in o){if(o.hasOwnProperty(p)){return false;}}return true;}else return(o?false:true);};})(jQuery);(function($){$.fn.tabulate=function(options){return this.each(function(){var $this=$(this);if(!$this.data("tabulate")){var tabulate=$.extend(true,{},$.tabulate);$this.data("tabulate",tabulate);tabulate.init($this,options);}});};$.tabulate={count:0,total_pages:1,current_page:1,columns:0,filters:{limit:0,offset:0},options:{name:"tabulate",debug:false,results_per_page:[5,10,25],parse_key:function(){return new RegExp(/\{([^{}]+)\}/g);},paths:{tabulate:window.location.pathname,theme:"src/themes/default"},keys:{count:"count"},data:{source:{},filters:{}},table:{body:{key:"body",rows:{},cells:{},$section:$('<tbody class="tabulate-body"></tbody>')}},elements:{loading:".tabulate-loading",previous:".tabulate-prev",next:".tabulate-next",count:".tabulate-count",total_pages:".tabulate-total-pages",current_page:".tabulate-current-page",results_per_page:".tabulate-results-per-page"},$fragments:{link:$('<a />'),image:$('<img />'),option:$('<option />'),row:$('<tr class="tabulate-row"></tr>'),cell:$('<td class="tabulate-cell"></td>'),content:$('<div class="tabulate-content"></div>'),container:$('<table class="tabulate-container"></table>'),navigation:$(['<div class="tabulate-navigation clearfix">',' <div class="tabulate-partition tabulate-partition-first tabulate-pagination">',' <img class="tabulate-prev" />',' page <input class="tabulate-current-page" type="text" />',' of <span class="tabulate-total-pages"></span>',' <img class="tabulate-next" />',' </div>',' <div class="tabulate-partition tabulate-partition-no-input">',' <span class="tabulate-count">0</span> total results',' </div>',' <div class="tabulate-partition tabulate-partition-no-input">',' <div class="tabulate-loading"><span>Loading...</span></div>',' </div>',' <div class="tabulate-partition tabulate-partition-last">',' <select class="tabulate-results-per-page"></select> results per page',' </div>','</div>',].join(""))},event_handlers:{},error_handlers:{}},init:function($wrapper,options){var self=this;$.extend(true,this.options,options||{});$.extend(true,this,this.options);$.extend(this,{$elements:this.elements,$navigation:this.$fragments.navigation,$container:this.$fragments.container,$wrapper:$wrapper});this.$wrapper.data("tabulate",this);this.$wrapper.append(this.$container).append(this.$navigation);$.each(this.$elements,function(key,selector){self.$elements[key]=$(selector);});$.each(this.paths,function(key,path){self.paths[key]=path.replace(/\/$/,'');});this.paths.theme=[this.paths.tabulate,this.paths.theme].join("/");this.filters.limit=this.filters.limit||this.results_per_page[0];if(this.$elements.previous.length){this.$elements.previous.attr({src:this.paths.theme+"/images/prev.gif",alt:"Previous Page",title:"Previous Page"}).click(function(){self.previous(this);return false;});}if(this.$elements.next.length){this.$elements.next.attr({src:this.paths.theme+"/images/next.gif",alt:"Next Page",title:"Next Page"}).click(function(){self.next(this);return false;});}if(this.$elements.current_page.length){this.$elements.current_page.keyup(function(event){var page=parseInt($(this).val());if(!isNaN(page)&&event.which==13){self.go_to(this,page);}});}if(this.$elements.results_per_page.length){$.each(this.results_per_page,function(i,value){self.$elements.results_per_page.append(self.$fragments.option.clone().val(value).text(value));});this.$elements.results_per_page.change(function(){var limit=parseInt($(this).val());if(!isNaN(limit)){self.filters.limit=limit;self.trigger("refresh");}});}$.each(this.event_handlers,function(name,handler){self.$wrapper.bind([name,self.name].join("."),function(){handler.apply(self,arguments);});});this.trigger("post_init");},previous:function(element){if(this.current_page>1){this.current_page--;this.filters.offset=((this.current_page-1)*this.filters.limit);this.trigger("refresh");}},next:function(element){if(this.current_page<this.total_pages){this.current_page++;this.filters.offset=((this.current_page-1)*this.filters.limit);this.trigger("refresh");}},go_to:function(element,page){if(page>=1&&page<=this.total_pages){this.current_page=page;this.filters.offset=((this.current_page-1)*this.filters.limit);this.trigger("refresh");}},update_filters:function(filters,overwrite,refresh){filters=filters||{};if(overwrite!==false){this.data.filters=filters;}else{$.extend(true,this.data.filters,filters||{});}if(refresh!==false){this.trigger("refresh");}},error:function(){if(this.debug&&window.console&&window.console.log){window.console.log("jquery.tabulate [error]: ",arguments);}},trigger:function(name,args){args=args||[];this.$wrapper.triggerHandler([name,this.name].join("."),($.isArray(args)?args:[args]));},gather_data:function(request,filters){var self=this,data={},request=request||{},filters=filters||{};this.trigger("loading",true);if(request.ajax){filters=$.extend(true,{},this.filters,this.data.filters,filters);var request=$.extend(true,{},request.ajax,{data:filters,success:function(data){$.extend(true,data,request.json||{});self.trigger("post_load",data);},error:function(){self.error_handlers.ajax.apply(self,arguments);}});$.ajax(request);}else if(request.json){this.trigger("post_load",request.json);}},tabulate:function(data){var self=this,data=data||{};this.count=data[this.keys.count]||$.getLength(data[this.table.body.key])||0;this.total_pages=Math.ceil(this.count/this.filters.limit)||1;this.current_page=Math.floor(this.filters.offset/this.filters.limit)+1;this.$container.children().empty();$.each(this.table,function(section,options){self.build_section(section,options,data);});this.$container.find(".tabulate-cell").hover(function(){$(this).addClass("tabulate-hover");},function(){$(this).removeClass("tabulate-hover")});this.$container.body.find(".tabulate-row:odd").addClass("tabulate-odd");this.$container.body.find(".tabulate-row:even").addClass("tabulate-even");this.$container.body.find(".tabulate-row:first").addClass("tabulate-first");this.$container.body.find(".tabulate-row:last").addClass("tabulate-last");this.trigger("loading",false);this.trigger("post_tabulate",data);},build_section:function(section,options,data){if(!options.key||!options.$section||!options.$section.length)return;var self=this,data=$.getObject(options.key,data)||{};this.$container.append(this.$container[section]=options.$section);$.each(data,function(r,row){var empty=true,r=r.toString(),$row=self.$fragments.row.clone();$.each(row,function(c,column){var c=c.toString(),$cell=self.$fragments.cell.clone(),$content=self.$fragments.content.clone();$cell.append($content);self.apply_properties($cell,{key:c,type:"column",dataset:data[r]},$.getObject(c,options.cells));$row.append($cell);if(empty&&$content.html())empty=false;});if(!empty){self.apply_properties($row,{key:r,type:"row",dataset:data},$.getObject(r,options.rows));$row.find(".tabulate-cell:first").addClass("tabulate-first");$row.find(".tabulate-cell:last").addClass("tabulate-last");self.$container[section].append($row);}});this.columns=Math.max(this.columns,data.length);},apply_properties:function($element,settings,properties){var self=this,dataset=settings.dataset||{},key=(typeof settings.key!=="undefined"?settings.key:"");$element.each(function(i,element){var $element=$(element),$content=$(".tabulate-content",$element),data=(dataset[key]?dataset[key]:dataset),name=($.isNumber(key)?parseInt(key)+1:key),args=($content.length?[$element,$content,data]:[$element,data]),props=(properties?(typeof properties==="object"?properties:{content:properties}):(typeof data==="object"?{}:{content:data}));if(typeof settings.type=="string"){$element.addClass([self.name,settings.type,name].join("-"));}$.each(props,function(property,value){switch(property){case"content":{if($content.length){if(value instanceof $){$content.append(value);}else{$content.append((typeof value==="function"?value.apply(self,args):value).replace(self.parse_key(),function(str,key){return $.getObject(key,dataset)||"";}));}}break;}case"filter":{value.apply(self,args);break;}}});});},event_handlers:{refresh:function(event,request,filters){this.gather_data(request||this.data.source,filters||{});},loading:function(event,bool){if(typeof bool=="boolean"){this.$elements.loading[(bool?"addClass":"removeClass")]("loading");}else{this.$elements.loading.toggleClass("loading");}},post_init:function(event){this.gather_data(this.data.source);},post_load:function(even,data){this.tabulate(data);},post_tabulate:function(event,data){this.$elements.count.text(this.count);this.$elements.total_pages.text(this.total_pages);this.$elements.current_page.val(this.current_page);if(this.count===0){this.$container.body.append(this.$fragments.row.clone().addClass("tabulate-row-no-results").append(this.$fragments.cell.clone().attr("colSpan",this.columns).append(this.$fragments.content.clone().text("No results found"))));}}},error_handlers:{ajax:function(xhr,status,error){this.error(xhr,status,error);}},toString:function(){return"[object "+this.name+"]";}};})(jQuery);
Please sign in to comment.
Something went wrong with that request. Please try again.