All Downloads are FREE. Search and download functionalities are using the official Maven repository.

template.js.struts2.jquery.chart.struts2.min.js Maven / Gradle / Ivy

There is a newer version: 5.0.4
Show newest version
/*!
 * jquery.chart.struts2.js
 *
 * Integration of charts with struts 2
 *
 * Requires use of jquery.struts2.js
 *
 * Copyright (c) 2012 Johannes Geppert http://www.jgeppert.com
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 */
(function(a){a.struts2_jquery_chart={charts:[],chart:function(d,g){var c=this,b=[],e="_s2j_chart_topic",f;if(a.support.leadingWhitespace==false){c.require("js/flot/excanvas"+c.minSuffix+".js")}c.require("js/flot/jquery.flot"+c.minSuffix+".js");if(g.crosshair){c.require("js/flot/jquery.flot.crosshair"+c.minSuffix+".js")}if((g.xaxis&&g.xaxis.mode==="time")||(g.yaxis&&g.yaxis.mode==="time")){c.require("js/flot/jquery.flot.time"+c.minSuffix+".js")}if((g.xaxis&&g.xaxis.axisLabel)||(g.yaxis&&g.yaxis.axisLabel)){c.require("js/flot/jquery.flot.axislabels"+c.minSuffix+".js")}if(g.fill){c.require("js/flot/jquery.flot.fillbetween"+c.minSuffix+".js")}if(g.stack){c.require("js/flot/jquery.flot.stack"+c.minSuffix+".js")}if(g.series&&g.series.curvedLines){c.require("js/flot/curvedLines"+c.minSuffix+".js")}if(g.series&&g.series.pie){c.require("js/flot/jquery.flot.pie"+c.minSuffix+".js")}if(g.autoresize){c.require("js/flot/jquery.flot.resize"+c.minSuffix+".js")}c.charts[g.id]=[];a.each(g.data,function(h,j){if(j.href){j.plot=g;j.plot.data=null;b.push(j)}else{c.charts[g.id].push(j)}});if(g.onclick||g.onhover){g.grid={};if(g.onclick){g.grid.clickable=true}if(g.onhover){g.grid.hoverable=true}}f=a.plot(d,c.charts[g.id],g);if(g.onclick){d.bind("plotclick",function(i,k,h){var j={};j.plot=f;j.event=i;j.pos=k;j.item=h;c.publishTopic(d,g.onclick,j)})}if(g.onhover){d.bind("plothover",function(i,k,h){var j={};j.plot=f;j.event=i;j.pos=k;j.item=h;c.publishTopic(d,g.onhover,j)})}a.each(b,function(j,k){var h=e+g.id+j;c.subscribeTopics(d,h,"_s2j_chart",k);c.subscribeTopics(d,k.reloadtopics,"_s2j_chart",k);c.subscribeTopics(d,k.listentopics,"_s2j_chart",k);if(!k.deferredloading){d.publish(h,k)}})}};a.extend(true,a.struts2_jquery_chart,a.struts2_jquery);a.struts2_jquery_chart.debugPrefix="[struts2_jquery_chart] ";a.subscribeHandler("_s2j_chart",function(d,e){var b=a.struts2_jquery,i=a(d.target),g={},f={},h;if(e){a.extend(f,e)}if(d.data){a.extend(f,d.data)}h=f.indicatorid;b.showIndicator(h);b.publishTopic(i,f.onalw,f);b.publishTopic(i,f.onbef,f);g.complete=b.pubCom(d.target,f.onalw,f.oncom,f.targets,h,f);g.error=b.pubErr(d.target,f.onalw,f.onerr,f.errortext,"html");g.success=function(l,k,j){var c={},n=0,p=false,q=false,m=f.plot,o=[];c.data=l;c.status=k;c.request=j;if(l[f.list]!==null){if(!a.isArray(l[f.list])){p=true}a.each(l[f.list],function(r,t){var s;if(p){s=[];s.push(r);s.push(t);o.push(s)}else{if(f.listkey!==undefined&&f.listvalue!==undefined){s=[];s.push(t[f.listkey]);s.push(t[f.listvalue]);o.push(s)}else{s=[];s.push(n);s.push(l[f.list][n]);o.push(s)}}n++});f.data=o;f.data=o;f.plot=null;a.each(a.struts2_jquery_chart.charts[m.id],function(r,s){if(s&&s.id&&s.id===f.id){q=true;s.data=o}});if(!q){a.struts2_jquery_chart.charts[m.id].push(f)}a.plot(i,a.struts2_jquery_chart.charts[m.id],m)}if(f.onsuc){b.publishTopic(i,f.onsuc,c);b.publishTopic(i,f.onalw,c)}};if(f.href){g.url=f.href;g.data="";if(f.hrefparameter){g.data=f.hrefparameter}if(f.requesttype){g.type=f.requesttype}else{g.type="POST"}if(f.formids&&g.data===""){if(!b.loadAtOnce){b.require("js/plugins/jquery.form"+b.minSuffix+".js")}a.each(f.formids.split(","),function(c,k){var j=a(b.escId(k)).formSerialize();if(g.data!==""){g.data=g.data+"&"+j}else{g.data=j}})}g.dataType="json";if(!g.data){g.data={}}f.options=g;b.publishTopic(i,f.onalw,f);b.publishTopic(i,f.onbef,f);a.ajax(g)}})})(jQuery);




© 2015 - 2024 Weber Informatics LLC | Privacy Policy