dat.gui/build/dat.gui.min.js

16 lines
65 KiB
JavaScript
Raw Normal View History

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.dat=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){var common=require("../utils/common.js");var toString=require("./toString.js");var math=require("./math.js");var interpret=require("./interpret.js");module.exports=Color;function Color(){this.__state=interpret.apply(this,arguments);if(this.__state===false){throw"Failed to interpret color arguments"}this.__state.a=this.__state.a||1}Color.COMPONENTS=["r","g","b","h","s","v","hex","a"];common.extend(Color.prototype,{toString:function(){return toString(this)},toOriginal:function(){return this.__state.conversion.write(this)}});defineRGBComponent(Color.prototype,"r",2);defineRGBComponent(Color.prototype,"g",1);defineRGBComponent(Color.prototype,"b",0);defineHSVComponent(Color.prototype,"h");defineHSVComponent(Color.prototype,"s");defineHSVComponent(Color.prototype,"v");Object.defineProperty(Color.prototype,"a",{get:function(){return this.__state.a},set:function(v){this.__state.a=v}});Object.defineProperty(Color.prototype,"hex",{get:function(){if(!this.__state.space!=="HEX"){this.__state.hex=math.rgb_to_hex(this.r,this.g,this.b)}return this.__state.hex},set:function(v){this.__state.space="HEX";this.__state.hex=v}});function defineRGBComponent(target,component,componentHexIndex){Object.defineProperty(target,component,{get:function(){if(this.__state.space==="RGB"){return this.__state[component]}recalculateRGB(this,component,componentHexIndex);return this.__state[component]},set:function(v){if(this.__state.space!=="RGB"){recalculateRGB(this,component,componentHexIndex);this.__state.space="RGB"}this.__state[component]=v}})}function defineHSVComponent(target,component){Object.defineProperty(target,component,{get:function(){if(this.__state.space==="HSV")return this.__state[component];recalculateHSV(this);return this.__state[component]},set:function(v){if(this.__state.space!=="HSV"){recalculateHSV(this);this.__state.space="HSV"}this.__state[component]=v}})}function recalculateRGB(color,component,componentHexIndex){if(color.__state.space==="HEX"){color.__state[component]=math.component_from_hex(color.__state.hex,componentHexIndex)}else if(color.__state.space==="HSV"){common.extend(color.__state,math.hsv_to_rgb(color.__state.h,color.__state.s,color.__state.v))}else{throw"Corrupted color state"}}function recalculateHSV(color){var result=math.rgb_to_hsv(color.r,color.g,color.b);common.extend(color.__state,{s:result.s,v:result.v});if(!common.isNaN(result.h)){color.__state.h=result.h}else if(common.isUndefined(color.__state.h)){color.__state.h=0}}},{"../utils/common.js":18,"./interpret.js":2,"./math.js":3,"./toString.js":4}],2:[function(require,module,exports){module.exports=createInterpert();function createInterpert(){var common=require("../utils/common.js");var toString=require("./toString.js");var result,toReturn;var interpret=function(){toReturn=false;var original=arguments.length>1?common.toArray(arguments):arguments[0];common.each(INTERPRETATIONS,function(family){if(family.litmus(original)){common.each(family.conversions,function(conversion,conversionName){result=conversion.read(original);if(toReturn===false&&result!==false){toReturn=result;result.conversionName=conversionName;result.conversion=conversion;return common.BREAK}});return common.BREAK}});return toReturn};var INTERPRETATIONS=[{litmus:common.isString
elem.dispatchEvent(evt)},bind:function(elem,event,func,bool){bool=bool||false;if(elem.addEventListener)elem.addEventListener(event,func,bool);else if(elem.attachEvent)elem.attachEvent("on"+event,func);return dom},unbind:function(elem,event,func,bool){bool=bool||false;if(elem.removeEventListener)elem.removeEventListener(event,func,bool);else if(elem.detachEvent)elem.detachEvent("on"+event,func);return dom},addClass:function(elem,className){if(elem.className===undefined){elem.className=className}else if(elem.className!==className){var classes=elem.className.split(/ +/);if(classes.indexOf(className)==-1){classes.push(className);elem.className=classes.join(" ").replace(/^\s+/,"").replace(/\s+$/,"")}}return dom},removeClass:function(elem,className){if(className){if(elem.className===undefined){}else if(elem.className===className){elem.removeAttribute("class")}else{var classes=elem.className.split(/ +/);var index=classes.indexOf(className);if(index!=-1){classes.splice(index,1);elem.className=classes.join(" ")}}}else{elem.className=undefined}return dom},hasClass:function(elem,className){return new RegExp("(?:^|\\s+)"+className+"(?:\\s+|$)").test(elem.className)||false},getWidth:function(elem){var style=getComputedStyle(elem);return cssValueToPixels(style["border-left-width"])+cssValueToPixels(style["border-right-width"])+cssValueToPixels(style["padding-left"])+cssValueToPixels(style["padding-right"])+cssValueToPixels(style["width"])},getHeight:function(elem){var style=getComputedStyle(elem);return cssValueToPixels(style["border-top-width"])+cssValueToPixels(style["border-bottom-width"])+cssValueToPixels(style["padding-top"])+cssValueToPixels(style["padding-bottom"])+cssValueToPixels(style["height"])},getOffset:function(elem){var offset={left:0,top:0};if(elem.offsetParent){do{offset.left+=elem.offsetLeft;offset.top+=elem.offsetTop}while(elem=elem.offsetParent)}return offset},isActive:function(elem){return elem===document.activeElement&&(elem.type||elem.href)}};module.exports=dom},{"../utils/common.js":18}],17:[function(require,module,exports){var css=require("../utils/css.js");var saveDialogueContents='<div id="dg-save" class="dg dialogue">\n\n Here\'s the new load parameter for your <code>GUI</code>\'s constructor:\n\n <textarea id="dg-new-constructor"></textarea>\n\n <div id="dg-save-locally">\n\n <input id="dg-local-storage" type="checkbox"/> Automatically save\n values to <code>localStorage</code> on exit.\n\n <div id="dg-local-explain">The values saved to <code>localStorage</code> will\n override those passed to <code>dat.GUI</code>\'s constructor. This makes it\n easier to work incrementally, but <code>localStorage</code> is fragile,\n and your friends may not see the same values you do.\n \n </div>\n \n </div>\n\n</div>';var styleSheet=".dg {\n /** Clear list styles */\n /* Auto-place container */\n /* Auto-placed GUI's */\n /* Line items that don't contain folders. */\n /** Folder names */\n /** Hides closed items */\n /** Controller row */\n /** Name-half (left) */\n /** Controller-half (right) */\n /** Controller placement */\n /** Shorter number boxes when slider is present. */\n /** Ensure the entire boolean and function row shows a hand */ }\n .dg ul {\n list-style: none;\n margin: 0;\n padding: 0;\n width: 100%;\n clear: both; }\n .dg.ac {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n height: 0;\n z-index: 0; }\n .dg:not(.ac) .main {\n /** Exclude mains in ac so that we don't hide close button */\n overflow: hidden; }\n .dg.main {\n -webkit-transition: opacity 0.1s linear;\n -o-transition: opacity 0.1s linear;\n -moz-transition: opacity 0.1s linear;\n transition: opacity 0.1s linear; }\n .dg.main.taller-than-window {\n overflow-y: auto; }\n .dg.main.taller-than-window .close-button {\n opacity: 1;\n /* TODO, these are style notes */\n margin-top: -1px;\n border-top: 1px solid #2c2c2c; }\n .dg.main ul.closed .close-button {\n opacity: 1 !important; }\n
return obj.constructor===Array},isObject:function(obj){return obj===Object(obj)},isNumber:function(obj){return obj===obj+0},isString:function(obj){return obj===obj+""},isBoolean:function(obj){return obj===false||obj===true},isFunction:function(obj){return Object.prototype.toString.call(obj)==="[object Function]"}}}},{}],19:[function(require,module,exports){module.exports=css();function css(){return{load:function(url,doc){doc=doc||document;var link=doc.createElement("link");link.type="text/css";link.rel="stylesheet";link.href=url;doc.getElementsByTagName("head")[0].appendChild(link)},inject:function(css,doc){doc=doc||document;var injected=document.createElement("style");injected.type="text/css";injected.innerHTML=css;doc.getElementsByTagName("head")[0].appendChild(injected)}}}},{}],20:[function(require,module,exports){module.exports=raf();function raf(){return window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(callback,element){window.setTimeout(callback,1e3/60)}}},{}],21:[function(require,module,exports){/** @license
* dat-gui JavaScript Controller Library
* http://code.google.com/p/dat-gui
*
* Copyright 2011 Data Arts Team, Google Creative Lab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*/
module.exports={color:{math:require("./dat/color/math.js"),interpret:require("./dat/color/interpret.js"),Color:require("./dat/color/Color.js")},dom:{dom:require("./dat/dom/dom.js")},controllers:{Controller:require("./dat/controllers/Controller.js"),BooleanController:require("./dat/controllers/BooleanController.js"),OptionController:require("./dat/controllers/OptionController.js"),StringController:require("./dat/controllers/StringController.js"),NumberController:require("./dat/controllers/NumberController.js"),NumberControllerBox:require("./dat/controllers/NumberControllerBox.js"),NumberControllerSlider:require("./dat/controllers/NumberControllerSlider.js"),FunctionController:require("./dat/controllers/FunctionController.js"),ColorController:require("./dat/controllers/ColorController.js")},gui:{GUI:require("./dat/gui/GUI.js")},GUI:require("./dat/gui/GUI.js")}},{"./dat/color/Color.js":1,"./dat/color/interpret.js":2,"./dat/color/math.js":3,"./dat/controllers/BooleanController.js":5,"./dat/controllers/ColorController.js":6,"./dat/controllers/Controller.js":7,"./dat/controllers/FunctionController.js":8,"./dat/controllers/NumberController.js":9,"./dat/controllers/NumberControllerBox.js":10,"./dat/controllers/NumberControllerSlider.js":11,"./dat/controllers/OptionController.js":12,"./dat/controllers/StringController.js":13,"./dat/dom/dom.js":16,"./dat/gui/GUI.js":17}]},{},[21])(21)});