-
Notifications
You must be signed in to change notification settings - Fork 526
/
flotr2.examples.min.js
2 lines (1 loc) · 9.09 KB
/
flotr2.examples.min.js
1
2
(function(){var e=Flotr.EventAdapter,t=Flotr._,n="click",r="example",i="mouseenter",s="mouseleave",o=".",u="flotr-examples",a="flotr-examples-container",f="flotr-examples-reset",l="flotr-examples-thumbs",c="flotr-examples-thumb",h="flotr-examples-collapsed",p="flotr-examples-highlight",d="flotr-examples-large",v="flotr-examples-medium",m="flotr-examples-small",g="flotr-examples-mobile",y='<div class="'+c+'"></div>',b='<div class="'+u+'">'+'<div class="'+f+'">View All</div>'+'<div class="'+l+'"></div>'+'<div class="'+a+'"></div>'+"</div>";Examples=function(e){if(t.isUndefined(Flotr.ExampleList))throw"Flotr.ExampleList not defined.";this.options=e,this.list=Flotr.ExampleList,this.current=null,this.single=!1,this._initNodes(),this._example=new Flotr.Examples.Example({node:this._exampleNode}),this._initExamples()},Examples.prototype={examples:function(){function s(t){var n=$(t.currentTarget),i=n.data("example"),s=t.data.orientation;s^n.hasClass(p)&&(n.toggleClass(p).css(e),r._example.executeCallback(i,n))}var e={cursor:"pointer"},t=this._thumbsNode,n=this.list.get(),r=this,i=["basic","basic-axis","basic-bars","basic-bars-horizontal","basic-bar-stacked","basic-stacked-horizontal","basic-pie","basic-radar","basic-bubble","basic-candle","basic-candle-barchart","basic-legend","mouse-tracking","mouse-zoom","mouse-drag","basic-time","negative-values","click-example","download-image","download-data","advanced-titles","color-gradients","basic-timeline","advanced-markers"];(function u(){var e=i.shift(),s=n[e];if(s.type==="profile"||s.type==="test")return;var o=$(y);o.data("example",s),t.append(o),r._example.executeCallback(s,o),o.click(function(){r._loadExample(s)}),i.length&&setTimeout(u,20)})(),t.delegate(o+c,"mouseenter",{orientation:!0},s),t.delegate(o+c,"mouseleave",{orientation:!1},s),$(window).hashchange&&$(window).hashchange(function(){r._loadHash()})},_loadExample:function(e){if(e){if(this._currentExample===e)return;this._currentExample=e,window.location.hash="!"+(this.single?"single/":"")+e.key,w||(this._thumbsNode.css({position:"absolute",height:"0px",overflow:"hidden",width:"0px"}),this._resetNode.css({top:"16px"})),this._examplesNode.addClass(h),this._exampleNode.show(),this._example.setExample(e),this._resize(),$(document).scrollTop(0)}},_reset:function(){window.location.hash="",w||this._thumbsNode.css({position:"",height:"",overflow:"",width:""}),this._examplesNode.removeClass(h),this._thumbsNode.height(""),this._exampleNode.hide()},_initNodes:function(){var e=$(this.options.node),t=this,n=$(b);t._resetNode=n.find(o+f),t._exampleNode=n.find(o+a),t._thumbsNode=n.find(o+l),t._examplesNode=n,t._resetNode.click(function(){t._reset()}),e.append(n),this._initResizer()},_initResizer:function(){function i(){var t=n.height()-(e.options.thumbPadding||0),i=n.width(),s;i>1760?(s=d,e._thumbsNode.height(t)):i>1140?(s=v,e._thumbsNode.height(t)):(s=m,e._thumbsNode.height("")),r!==s&&(r&&e._examplesNode.removeClass(r),e._examplesNode.addClass(s),r=s)}var e=this,t=e._examplesNode,n=$(window),r;$(window).resize(i),i(),this._resize=i},_initExamples:function(){var e=window.location.hash,t,n;e=e.substring(2),n=e.split("/"),n.length==1?(this.examples(),e&&this._loadHash()):n[0]=="single"&&(this.single=!0,this._loadExample(this.list.get(n[1])))},_loadHash:function(){var e=window.location.hash,t;e=e.substring(2),e?(t=this.list.get(e),this._loadExample(t)):this._reset()}};var w=function(){var e=!!(navigator.userAgent.match(/Android/i)||navigator.userAgent.match(/webOS/i)||navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPod/i)),t=!!$.browser.mozilla;return!e||t}();Flotr.Examples=Examples})(),function(){var e=Flotr._,t=".",n="flotr-example",r="flotr-example-label",i="flotr-example-title",s="flotr-example-description",o="flotr-example-editor",u="flotr-example-graph",a='<div class="'+n+'">'+'<div class="'+r+" "+i+'"></div>'+'<div class="'+s+'"></div>'+'<div class="'+o+'"></div>'+"</div>",f=function(e){this.options=e,this.example=null,this._initNodes()};f.prototype={setExample:function(e){var t=this.getSource(e),n=this._editorNode;this.example=e,Math.seedrandom(e.key),this._exampleNode.css({display:"block"}),this._titleNode.html(e.name||""),this._markupNode.html(e.description||""),this._editor?this._editor.setExample(t,e.args):this._editor=new Flotr.Examples.Editor(n,{args:e.args,example:t,teardown:function(){Flotr.EventAdapter.stopObserving($(n).find(".render")[0]),$(n).find("canvas").each(function(e,t){Flotr.EventAdapter.stopObserving(t)})}})},getSource:function(e){var t=e.callback.toString();return navigator.userAgent.search(/firefox/i)!==-1&&(t=js_beautify(t)),t},executeCallback:function(t,n){e.isElement(n)||(n=n[0]);var r=t.args?[n].concat(t.args):[n];return Math.seedrandom(t.key),t.callback.apply(this,r)},_initNodes:function(){var e=this.options.node,n=$(a);this._titleNode=n.find(t+i),this._markupNode=n.find(t+s),this._editorNode=n.find(t+o),this._exampleNode=n,e.append(n)}},Flotr.Examples.Example=f}(),function(){function Editor(e,t){function d(){a.hide(),s&&s.call(),h.render({example:r,render:u})}function v(e,t,n){var r=!1,i='<span class="error">Error: </span>',s,o;i+='<span class="message">'+e+"</span>",typeof n!="undefined"&&(i+='<span class="position">',i+='Line <span class="line">'+n+"</span>",console.log(t),t&&(i+=" of ",t==window.location?(i+='<span class="url">script</span>',r):i+='<span class="url">'+t+"</span>"),i+=".</span>"),a.show(),a.html(i)}function m(){var e="http://jsfiddle.net/api/post/jquery/1.7/",t=$('<form method="post" action="'+e+'" target="_blank"></form>'),n;resources=["https://raw.github.com/HumbleSoftware/Flotr2/master/flotr2.min.js","https://raw.github.com/HumbleSoftware/Flotr2/master/examples/examples.css"],n=$('<input type="hidden" name="resources">').attr("value",resources.join(",")),t.append(n),n=$('<input type="hidden" name="html">').attr("value",'<div id="'+c+'"></div>'),t.append(n),n=$('<input type="hidden" name="normalize_css" value="no">'),t.append(n),n=$('<input type="hidden" name="css">').attr("value","#"+c+" {\n width: 340px;\n height: 220px;"+"\n margin: 24px auto;\n}"),t.append(n),n=$('<input type="hidden" name="js">').attr("value","$(function () {\n"+r+"\n});"),t.append(n),t.append(n),$(document.body).append(t),t.submit()}var n=t.type||"javascript",r=t.example||"",i=t.noRun||!1,s=t.teardown||!1,o=$(T_CONTROLS),u=$(T_RENDER),a=$(T_ERRORS),f=$(T_SOURCE),l=$(T_EDITOR),c="editor-render-"+COUNT,h,u,p;h=new TYPES[n]({onerror:v});if(!h)throw"Invalid type: API not found for type `"+n+"`.";u.attr("id",c),a.hide(),l.append(u).append(o).append(f).addClass(n).addClass(i?"no-run":""),e=$(e),e.append(l),f.append(a),r=h.example({args:t.args,example:r,render:u}),p=CodeMirror(f[0],{value:r,readOnly:i,lineNumbers:!0,mode:h.codeMirrorType}),i||(o.delegate(".run","click",function(){r=p.getValue(),d()}),d()),o.delegate(".fiddle","click",function(){m()}),window.onerror=function(e,t,n){return v(e,t,n),console.log(e),ONERROR&&$.isFunction(ONERROR)?ONERROR(e,t,n):!1},COUNT++,this.setExample=function(e,t){r=h.example({args:t,example:e,render:u}),p.setValue(r),p.refresh(),d()}}var ONERROR=window.onerror,COUNT=0,TYPES={},T_CONTROLS='<div class="controls"><button class="fiddle btn large primary">Fiddle</button><button class="run btn large primary">Run</button></div>',T_EDITOR='<div class="editor"></div>',T_SOURCE='<div class="source"></div>',T_ERRORS='<div class="errors"></div>',T_RENDER='<div class="render"></div>',T_IFRAME="<iframe></iframe>";TYPES.javascript=function(t){this.onerror=t.onerror},TYPES.javascript.prototype={codeMirrorType:"javascript",example:function(e){var t=e.example,n=e.render,r=$(n).attr("id"),i=e.args?","+e.args.toString():"";return"("+t+')(document.getElementById("'+r+'")'+i+");"},render:function(o){eval(o.example)}},TYPES.html=function(t){this.onerror=t.onerror},TYPES.html.prototype={codeMirrorType:"htmlmixed",example:function(e){return $.trim(e.example)},render:function(e){var t=e.example,n=e.render,r=$(T_IFRAME),i=this,s,o;n.html(r),s=r[0].contentWindow,o=s.document,o.open(),s.onerror=r.onerror=function(){i.onerror.apply(null,arguments)},o.write(t),o.close()}},typeof Flotr.Examples=="undefined"&&(Flotr.Examples={}),Flotr.Examples.Editor=Editor}(),function(){var e=Flotr.DOM,t=Flotr.EventAdapter,n=Flotr._,r="click",i="example-profile",s="examples",o=function(e){if(n.isUndefined(Flotr.ExampleList))throw"Flotr.ExampleList not defined.";this.editMode="off",this.list=Flotr.ExampleList,this.current=null,this.single=!1,this.init()};o.prototype=n.extend({},Flotr.Examples.prototype,{examples:function(){var i=document.getElementById(s),o=e.node("<ul></ul>"),u;n.each(this.list.getType("profile"),function(i){u=e.node("<li>"+i.name+"</li>"),e.insert(o,u),t.observe(u,r,n.bind(function(){this.example(i)},this))},this),e.insert(i,o)},example:function(e){this._renderSource(e),this.profileStart(e),setTimeout(n.bind(function(){this._renderGraph(e),this.profileEnd()},this),50)},profileStart:function(e){var t=document.getElementById(i);this._startTime=new Date,t.innerHTML='<div>Profile started for "'+e.name+'"...</div>'},profileEnd:function(e){var t=document.getElementById(i);profileTime=new Date-this._startTime,this._startTime=null,t.innerHTML+="<div>Profile complete: "+profileTime+"ms<div>"}}),Flotr.Profile=o}()