Permalink
Browse files

re-generate minified version

  • Loading branch information...
1 parent f2d5a4b commit 753d7b9d19e2614ee5a0bc2b2fa030ff3d13d90c @kflorence committed Sep 28, 2010
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/jquery.tabulate.min.js
View
2 src/jquery.tabulate.min.js
@@ -16,4 +16,4 @@
* 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;};})(jQuery);(function($){$.isNumber=function(n){return!isNaN(parseFloat(n))&&isFinite(n);};})(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,options:{name:"tabulate",debug:false,results_per_page:[5,10,25],parse_key:function(){return new RegExp(/\{([^{}]+)\}/g);},paths:{tabulate:window.location.pathname,theme:"themes/default"},keys:{head:"head",body:"body",foot:"foot",count:"count"},data:{source:{ajax:undefined,json:undefined},filters:{limit:0,offset:0}},table:{rows:{},columns:{}},$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>'),table:$('<table class="tabulate-table"></table>'),head:$('<thead class="tabulate-header"></thead>'),body:$('<tbody class="tabulate-body"></tbody>'),foot:$('<tfoot class="tabulate-footer"></tfoot>'),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);this.$wrapper=$wrapper;this.$wrapper.data("tabulate",this);this.paths.theme=[this.paths.tabulate,this.paths.theme].join("/");this.data.filters.limit=this.data.filters.limit||this.results_per_page[0];this.$wrapper.append(this.$table=this.$fragments.table).append(this.$navigation=this.$fragments.navigation);$.each(this.table.columns,function(section,columns){self.$table[section]=self.$fragments[section];self.$table.append(self.$table[section]);});$.each(this.$elements,function(key,selector){self.$elements[key]=$(selector);});if(this.$elements.previous.length){this.$elements.previous.attr({src:this.paths.theme+"/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+"/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.update_filters({limit:limit});}});}$.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.update_filters({offset:((this.current_page-1)*this.data.filters.limit)});}},next:function(element){if(this.current_page<this.total_pages){this.current_page++;this.update_filters({offset:((this.current_page-1)*this.data.filters.limit)});}},go_to:function(element,page){if(page>=1&&page<=this.total_pages){this.current_page=page;this.update_filters({offset:((this.current_page-1)*this.data.filters.limit)});}},update_filters:function(filters,refresh){$.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.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){data=request.json;}this.trigger("post_load",data);}},apply_properties:function($element,settings,properties){var self=this,properties=properties||{},dataset=settings.dataset||{},key=(typeof settings.key!="undefined"?settings.key:"");$element.each(function(i,element){var $element=$(element),data=(dataset[key]?dataset[key]:dataset),name=($.isNumber(key)?parseInt(key)+1:key),$content=$(".tabulate-content",$element),args=[$element,$content,data];if(!$content.length)$content=$element;if(typeof settings.type=="string"){$element.addClass([self.name,settings.type,name].join("-"));}switch(typeof properties){case"string":{properties={content:properties};break;}case"function":{properties={content:properties.apply(self,args)};break;}}if(typeof properties=="object"){$.each(properties,function(property,value){switch(property){case"attributes":{$element.attr(value);break;}case"content":{if(typeof value=="function"){value=value.apply(self,args);}switch(typeof value){case"object":{if(value instanceof $){$content.append(value);}break;}default:{$content.append(value.replace(self.parse_key(),function(str,key){return $.getObject(key,dataset)||"";}));break;}}break;}case"class_name":{switch(typeof value){case"function":{$element.addClass(value.apply(self,args));break;}default:{$element.addClass(value);break;}}break;}case"events":{$.each(value,function(name,handler){$element.bind(name,function(event){handler.apply(self,[event].concat(args));});});break;}case"filter":{value.apply(self,args);break;}case"styles":{$element.css(value);break;}}});}});},tabulate:function(data){var self=this,data=data||{};this.$table.children().empty();$.each(this.table.columns,function(key,column){self.columns=Math.max(self.columns,$.getLength(column));self.build_section(key,self.$table[key],$.getObject(self.keys[key],data));});this.count=data[this.keys.count]||$.getLength(this.table.columns[this.keys.body])||0;this.total_pages=Math.ceil(this.count/this.data.filters.limit)||1;this.$table.find(".tabulate-cell").hover(function(){$(this).addClass("tabulate-hover");},function(){$(this).removeClass("tabulate-hover")});this.$table.body.find(".tabulate-row:odd").addClass("tabulate-odd");this.$table.body.find(".tabulate-row:even").addClass("tabulate-even");this.$table.body.find(".tabulate-row:first").addClass("tabulate-first");this.$table.body.find(".tabulate-row:last").addClass("tabulate-last");this.trigger("loading",false);this.trigger("post_tabulate",data);},build_section:function(section,$element,data){var self=this,data=data||{};if($element&&$element.length){$.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,self.table.columns[section])||{});$row.append($cell);if(empty&&$content.html())empty=false;});if(!empty){self.apply_properties($row,{key:r,type:"row",dataset:data},$.getObject(r,self.table.rows[section])||{});$row.find(".tabulate-cell:first").addClass("tabulate-first");$row.find(".tabulate-cell:last").addClass("tabulate-last");$element.append($row);}});}},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);}},error_handlers:{ajax:function(xhr,status,error){this.error(xhr,status,error);alert(xhr.status+": "+(xhr.statusText||"Unknown error."));}},toString:function(){return"[object "+this.name+"]";}};})(jQuery);
+;(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);

0 comments on commit 753d7b9

Please sign in to comment.