Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Pages 1.3.5 - Stylesheet indentation back to spaces

  • Loading branch information...
commit 67b2ac8885a34c83a69daaef935d7bd5b9b3b40d 1 parent f20d58f
@draeton authored
View
2  stitches/build/stitches/js/stitches-1.3.5.js
@@ -268,4 +268,4 @@ var requirejs,require,define;(function(global){function isFunction(e){return ost
* [GruntJS](http://gruntjs.com/), for helping this all make sense.
*/
-define("wrap/jquery",[],function(){return jQuery}),define("wrap/modernizr",[],function(){return Modernizr}),function(){function o(){try{return r in t&&t[r]}catch(e){return!1}}var e={},t=window,n=t.document,r="localStorage",i="__storejs__",s;e.disabled=!1,e.set=function(e,t){},e.get=function(e){},e.remove=function(e){},e.clear=function(){},e.transact=function(t,n,r){var i=e.get(t);r==null&&(r=n,n=null),typeof i=="undefined"&&(i=n||{}),r(i),e.set(t,i)},e.setAll=function(){},e.getAll=function(){},e.serialize=function(e){return JSON.stringify(e)},e.deserialize=function(e){if(typeof e!="string")return undefined;try{return JSON.parse(e)}catch(t){return e||undefined}};if(o())s=t[r],e.set=function(t,n){return typeof t=="object"?e.setAll(t):n===undefined?e.remove(t):(s.setItem(t,e.serialize(n)),n)},e.get=function(t){return t===undefined?e.getAll():e.deserialize(s.getItem(t))},e.remove=function(e){s.removeItem(e)},e.clear=function(){s.clear()},e.setAll=function(t){for(var n in t)t[n]=e.set(n,t[n])},e.getAll=function(){var t={};for(var n=0;n<s.length;++n){var r=s.key(n);t[r]=e.get(r)}return t};else if(n.documentElement.addBehavior){var u,a;try{a=new ActiveXObject("htmlfile"),a.open(),a.write('<script>document.w=window</script><iframe src="/favicon.ico"></frame>'),a.close(),u=a.w.frames[0].document,s=u.createElement("div")}catch(f){s=n.createElement("div"),u=n.body}function l(t){return function(){var n=Array.prototype.slice.call(arguments,0);n.unshift(s),u.appendChild(s),s.addBehavior("#default#userData"),s.load(r);var i=t.apply(e,n);return u.removeChild(s),i}}var c=new RegExp("[!\"#$%&'()*+,/\\\\:;<=>?@[\\]^`{|}~]","g");function h(e){return e.replace(c,"___")}e.set=l(function(t,n,i){return typeof n=="object"?e.setAll(n):(n=h(n),i===undefined?e.remove(n):(t.setAttribute(n,e.serialize(i)),t.save(r),i))}),e.get=l(function(t,n){return n===undefined?e.getAll():(n=h(n),e.deserialize(t.getAttribute(n)))}),e.remove=l(function(e,t){t=h(t),e.removeAttribute(t),e.save(r)}),e.clear=l(function(e){var t=e.XMLDocument.documentElement.attributes;e.load(r);for(var n=0,i;i=t[n];n++)e.removeAttribute(i.name);e.save(r)}),e.setAll=l(function(t,n){for(var r in n)n[r]=e.set(r,n[r]);return n}),e.getAll=l(function(t){var n=t.XMLDocument.documentElement.attributes;t.load(r);var i={};for(var s=0,o;o=n[s];++s)i[o]=e.get(o);return i})}try{e.set(i,i),e.get(i)!=i&&(e.disabled=!0),e.remove(i)}catch(f){e.disabled=!0}e.enabled=!e.disabled,typeof module!="undefined"&&typeof module!="function"?module.exports=e:typeof define=="function"&&define.amd?define("module/../../../libs/store/store",e):this.store=e}(),define("util/util",["wrap/jquery"],function(e){return{inherit:function(t,n,r){t.prototype=new n,t.prototype.constructor=n,e.each(r,function(e,n){t.prototype[e]=n}),t.prototype._super=function(e,t,r){var i=n.prototype[e];return i.apply(t,r)}},debounce:function(e,t,n){var r;return function(){var i=this,s=arguments,o=function(){n||e.apply(i,s),r=null};r?window.clearTimeout(r):n&&e.apply(i,s),r=setTimeout(o,t||50)}},noop:function(e){e&&(e.preventDefault(),e.stopPropagation())},toPx:function(e){return e?e+"px":"0"}}}),function(){var e=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"],t=/^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im,n=/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im,r=[],i={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g},s=function(e,t){var n=i,r="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(n.interpolate,function(e,t){return"',"+t.replace(/\\'/g,"'")+",'"}).replace(n.evaluate||null,function(e,t){return"');"+t.replace(/\\'/g,"'").replace(/[\r\n\t]/g," ")+"; __p.push('"}).replace(/\r/g,"").replace(/\n/g,"").replace(/\t/g,"")+"');}return __p.join('');";return r};define("tpl",[],function(){var i,o,u;return typeof window!="undefined"&&window.navigator&&window.document?o=function(e,t){var n=i.createXhr();n.open("GET",e,!0),n.onreadystatechange=function(e){n.readyState===4&&t(n.responseText)},n.send(null)}:typeof process!="undefined"&&process.versions&&!!process.versions.node&&(u=require.nodeRequire("fs"),o=function(e,t){t(u.readFileSync(e,"utf8"))}),i={version:"0.24.0",strip:function(e){if(e){e=e.replace(t,"");var r=e.match(n);r&&(e=r[1])}else e="";return e},jsEscape:function(e){return e.replace(/(['\\])/g,"\\$1").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"").replace(/[\t]/g,"").replace(/[\r]/g,"")},createXhr:function(){var t,n,r;if(typeof XMLHttpRequest!="undefined")return new XMLHttpRequest;for(n=0;n<3;n++){r=e[n];try{t=new ActiveXObject(r)}catch(i){}if(t){e=[r];break}}if(!t)throw new Error("require.getXhr(): XMLHttpRequest not available");return t},get:o,load:function(e,t,n,o){var u=!1,a,f=e.indexOf("."),l=e.substring(0,f),c=e.substring(f+1,e.length);f=c.indexOf("!"),f!==-1&&(u=c.substring(f+1,c.length),u=u==="strip",c=c.substring(0,f)),a="nameToUrl"in t?t.nameToUrl(l,"."+c):t.toUrl(l+"."+c),i.get(a,function(t){t=s(t),o.isBuild||(t=new Function("obj",t)),t=u?i.strip(t):t,o.isBuild&&o.inlineText&&(r[e]=t),n(t)})},write:function(e,t,n){if(t in r){var s=i.jsEscape(r[t]);n("define('"+e+"!"+t+"', function() {return function(obj) { "+s.replace(/(\\')/g,"'").replace(/(\\\\)/g,"\\")+"}});\n")}}}})}(),define("tpl!util/../../templates/stitches.tpl",function(){return function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div class="stitches"> <!-- .stitches-toolbar --> <div class="stitches-toolbar btn-toolbar"> <div class="btn-group"> <a href="http://draeton.github.io/stitches/" class="btn btn-small btn-link"> <strong>Stitches</strong> </a> <button data-action="open" class="btn btn-small btn-info files" title="Open"> <i class="icon-folder-open icon-white"></i> <span class="hidden-phone">Open</span><input class="file" type="file" multiple="multiple"> </button> <button data-action="settings" class="btn btn-small btn-info" title="Set layout, style prefix, padding, etc."> <i class="icon-cog icon-white"></i> <span class="hidden-phone">Settings</span> </button> <button data-action="clear" class="btn btn-small btn-info disabled" title="Clear sprites from the canvas"> <i class="icon-remove icon-white"></i> <span class="hidden-phone">Clear</span> </button> </div> <div class="btn-group"> <button data-action="downloads" class="btn btn-small btn-success disabled" title="Get the generated sprite sheet and stylesheet"> <i class="icon-download-alt icon-white"></i> <span class="hidden-phone">Downloads</span> </button> </div> <div class="btn-group"> <button data-action="about" class="btn btn-small btn-info" title="About Stitches"> <i class="icon-info-sign icon-white"></i> <span class="hidden-phone">About</span> </button> </div> </div> <!-- /.stitches-toolbar --> <!-- .stitches-progress --> <div class="stitches-progress collapse"> <div class="progress progress-warning"> <div class="bar" style="width: 0%;"></div> </div> </div> <!-- /.stitches-progress --> <!-- .stitches-drop-box --> <div class="stitches-drop-box"> <div class="stitches-overlay"></div> <div class="stitches-wrap"> <!-- .stitches-canvas --> <div class="stitches-canvas"></div> <!-- /.stitches-canvas --> </div> <!-- .stitches-palettes --> <div class="stitches-palettes"> <!-- .stitches-settings --> <div class="stitches-palette stitches-settings fade"> <div class="stitches-palette-header"> <button type="button" class="close" data-action="close" title="Close">&times;</button> <h4>Settings</h4> </div> <div class="stitches-palette-body"> <ul class="nav nav-tabs"> <li class="active"><a href="#general" data-toggle="tab">General</a></li> <li><a href="#import" data-toggle="tab">Import</a></li> </ul> <form class="form-horizontal"> <div class="tab-content"> <div class="tab-pane active" id="general"> <div class="control-group hide"> <label class="control-label">Position</label> <div class="controls"> <label class="checkbox"> <input name="position" type="checkbox" value="auto"/> Auto </label> </div> </div> <div class="control-group"> <label class="control-label">Layout</label> <div class="controls"> <label class="radio inline"> <input name="layout" type="radio" value="compact"/> Compact </label> <label class="radio inline"> <input name="layout" type="radio" value="vertical"/> Vertical </label> <label class="radio inline"> <input name="layout" type="radio" value="horizontal"/> Horizontal </label> </div> </div> <div class="control-group"> <label class="control-label">CSS/LESS</label> <div class="controls"> <label class="radio inline"> <input name="stylesheet" type="radio" value="css"/> CSS </label> <label class="radio inline"> <input name="stylesheet" type="radio" value="less"/> LESS </label> </div> </div> <div class="control-group"> <label class="control-label">Style prefix</label> <div class="controls"> <input name="prefix" type="text" placeholder="Style class prefix&hellip;"> </div> </div> <div class="control-group"> <label class="control-label">Padding</label> <div class="controls"> <div class="input-append"> <input name="padding" type="number" min="0" required placeholder="Sprite padding&hellip;"> <span class="add-on">px</span> </div> </div> </div> <div class="control-group"> <label class="control-label">Data URI</label> <div class="controls"> <label class="checkbox"> <input name="uri" type="checkbox" value="true"/> Include encoded image in CSS </label> </div> </div> </div> <div class="tab-pane" id="import"> <div class="control-group"> <label class="control-label">Paste import here</label> <div class="controls"> <textarea name="import" rows="10"></textarea> </div> </div> </div> </div> </form> </div> <div class="stitches-palette-footer"> <div class="btn-toolbar"> <div class="btn-group"> <a href="#" class="downloads-export btn btn-small btn-success" download="stitches"><i class="icon-download-alt icon-white"></i> Export</a> </div> <div class="btn-group"> <button class="btn btn-small btn-info" data-action="close" title="Save"><span>Save</span></button> <button class="btn btn-small btn-info" data-action="close" title="Close"><span>Close</span></button> </div> </div> </div> </div> <!-- /.stitches-settings --> <!-- .stitches-properties --> <div class="stitches-palette stitches-properties fade"> <div class="stitches-palette-header"> <button type="button" class="close" data-action="close" title="Close">&times;</button> <h4>Sprite Properties</h4> </div> <div class="stitches-palette-body"> <form class="form-horizontal"> <div class="control-group"> <label class="control-label">Name</label> <div class="controls"> <input name="name" type="text" required placeholder="Sprite name&hellip;"> </div> </div> <div class="control-group"> <label class="control-label">Coordinates (x, y)</label> <div class="controls"> <div class="input-append"> <input name="x" required disabled placeholder="From left&hellip;" class="input-mini"> <span class="add-on">px</span> </div> <div class="input-append"> <input name="y" required disabled placeholder="From top&hellip;" class="input-mini"> <span class="add-on">px</span> </div> </div> </div> </form> </div> <div class="stitches-palette-footer"> <div class="btn-toolbar"> <div class="btn-group"> <button class="btn btn-small btn-danger" data-action="remove" title="Delete"><span>Delete</span></button> <button class="btn btn-small btn-info" data-action="close" title="Save"><span>Save</span></button> <button class="btn btn-small btn-info" data-action="close" title="Close"><span>Close</span></button> </div> </div> </div> </div> <!-- /.stitches-properties --> <!-- .stitches-about --> <div class="stitches-palette stitches-about fade in"> <div class="stitches-palette-header"> <button type="button" class="close" data-action="close" title="Close">&times;</button> <h4>About Stitches</h4> </div> <div class="stitches-palette-body"> <p><a href="http://draeton.github.io/stitches/">Stitches<a/> is an HTML5 <a href="http://en.wikipedia.org/wiki/Sprite_(computer_graphics)#Sprites_by_CSS">sprite sheet</a> generator.</p> <p>Drag &amp; drop image files onto the space below, or use the &ldquo;Open&rdquo; link to load images using the file browser. Then, click &ldquo;Generate&rdquo; to create a sprite sheet and stylesheet. <em>This demo uses a couple of HTML5 APIs, and it is only currently compatible with WebKit and Firefox browsers.</em></p> <p>Stitches is developed by <a href="http://draeton.github.io">Matthew Cobbs</a> in concert with the lovely open-source community at <a href="http://github.io">Github</a>. Thanks are owed to the developers at Twitter for <a href="http://twitter.github.io/bootstrap">Bootstrap</a>, and <a href="http://glyphicons.com/">Glyphicons</a> for some cool little icons.</p> <p class="text-right"><small>Copyright &copy; 2013 Matthew Cobbs<br/> Licensed under the MIT license.</small></p> </div> <div class="stitches-palette-footer"> <div class="btn-toolbar"> <div class="btn-group"> <button class="btn btn-small btn-info" data-action="close" title="Close"><span>Close</span></button> </div> </div> </div> </div> <!-- /.stitches-about --> <!-- .stitches-downloads --> <div class="stitches-palette stitches-downloads fade"> <div class="stitches-palette-header"> <button type="button" class="close" data-action="close" title="Close">&times;</button> <h4>Downloads</h4> </div> <div class="stitches-palette-body"> <section></section> </div> <div class="stitches-palette-footer"> <div class="btn-toolbar"> <div class="btn-group"> <a href="#" class="downloads-spritesheet btn btn-small btn-success" download="spritesheet"><i class="icon-download-alt icon-white"></i> Spritesheet</a> <a href="#" class="downloads-stylesheet btn btn-small btn-success" download="stylesheet"><i class="icon-download-alt icon-white"></i> Stylesheet</a> <button class="btn btn-small btn-info" data-action="close" title="Close"><span>Close</span></button> </div> </div> </div> </div> <!-- /.stitches-downloads --> </div> <!-- /.stitches-palettes --> </div> <!-- /.stitches-drop-box --></div>');return __p.join("")}}),define("tpl!util/../../templates/downloads.tpl",function(){return function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<ul class="nav nav-tabs"> <li class="active"><a href="#spritesheet" data-toggle="tab">PNG</a></li> <li><a href="#stylesheet" data-toggle="tab">',stylesheetType.toUpperCase(),'</a></li> <li><a href="#markup" data-toggle="tab">HTML</a></li> <li><a href="#example" data-toggle="tab"><strong>Example</strong></a></li></ul><div class="tab-content"> <div class="tab-pane active" id="spritesheet"> <p><img src="',spritesheet,'" class="thumbnail"/></p> </div> <div class="tab-pane" id="stylesheet"> <p><textarea rows="',stylesheetLines,'">',stylesheet,'</textarea></p> </div> <div class="tab-pane" id="markup"> <p><textarea rows="',markupLines,'">',markup,'</textarea></p> </div> <div class="tab-pane stitches-example" id="example"> <style type="text/',stylesheetType,'">',stylesheetWithUri,"</style> <div>",markupTooltip,'</div> <script src="//cdnjs.cloudflare.com/ajax/libs/less.js/1.3.3/less.min.js"></script> </div></div>');return __p.join("")}}),define("tpl!util/../../templates/sprite.tpl",function(){return function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div class="stitches-sprite" style="top: ',y,"px; left: ",x,'px;"> <img src="',image.src,'"/></div>');return __p.join("")}}),define("tpl!util/../../templates/css.tpl",function(){return function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push(".",prefix," {\\nbackground-image: url(",backgroundImage,");\\nbackground-repeat: no-repeat;\\ndisplay: block;\\n}\\n"),$.map(sprites,function(e){__p.push("\\n.",prefix,"-",e.name," {\\nwidth: ",e.image.width,"px;\\nheight: ",e.image.height,"px;\\nbackground-position: ",e.left(!0)," ",e.top(!0),";\\n}\\n")}),__p.push("");return __p.join("")}}),define("tpl!util/../../templates/css-markup.tpl",function(){return function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push(""),$.map(sprites,function(e){__p.push(""),tooltip?__p.push('<i class="',prefix," ",prefix,"-",e.name,'" data-toggle="tooltip" title=".',prefix,".",prefix,"-",e.name,'"></i>\\n'):__p.push('<i class="',prefix," ",prefix,"-",e.name,'"></i>\\n'),__p.push("")}),__p.push("");return __p.join("")}}),define("tpl!util/../../templates/less.tpl",function(){return function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push(".stitches-",prefix,"(@x: 0, @y: 0, @width: 0, @height: 0) {\\nbackground-position: @x @y;\\nwidth: @width;\\nheight: @height;\\n}\\n\\n.",prefix," {\\nbackground-image: url(",backgroundImage,");background-repeat: no-repeat;\\ndisplay: block;\\n"),$.map(sprites,function(e){__p.push("\\n&.",prefix,"-",e.name," {\\n.stitches-",prefix,"(",e.left(!0),", ",e.top(!0),", ",e.image.width,"px, ",e.image.height,"px);\\n}\\n")}),__p.push("}\\n");return __p.join("")}}),define("tpl!util/../../templates/less-markup.tpl",function(){return function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push(""),$.map(sprites,function(e){__p.push(""),tooltip?__p.push('<i class="',prefix," ",prefix,"-",e.name,'" data-toggle="tooltip" title=".',prefix,".",prefix,"-",e.name,'"></i>'):__p.push('<i class="',prefix," ",prefix,"-",e.name,'"></i>\\n'),__p.push("")}),__p.push("");return __p.join("")}}),define("util/templates",["tpl!../../templates/stitches.tpl","tpl!../../templates/downloads.tpl","tpl!../../templates/sprite.tpl","tpl!../../templates/css.tpl","tpl!../../templates/css-markup.tpl","tpl!../../templates/less.tpl","tpl!../../templates/less-markup.tpl"],function(e,t,n,r,i,s,o){return{stitches:function(){return e.apply(this,arguments)},downloads:function(){return t.apply(this,arguments)},sprite:function(){return n.apply(this,arguments)},css:function(){return r.apply(this,arguments)},cssMarkup:function(){return i.apply(this,arguments)},less:function(){return s.apply(this,arguments)},lessMarkup:function(){return o.apply(this,arguments)}}}),define("manager/file",["wrap/jquery","util/util"],function(e,t){return{total:0,processed:0,queue:[],set:function(e){e=e||{},this.onload=e.onload||t.noop,this.onprogress=e.onprogress||t.noop,this.onerror=e.onerror||t.noop},processFiles:function(t){var n=this;this.total=t.length,this.processed=0,this.queue=[],e.map(t,function(e){/jpeg|png|gif/.test(e.type)&&n.processFile(e)}),this.onprogress(0,"info")},processFile:function(e){var t=this,n;try{n=new FileReader,n.onloadend=function(n){var r=e.name,i=n.target.result,s=++t.processed/t.total;t.onprogress(s),t.queue.push([r,i]),t.queue.length===t.total&&t.processQueue()},n.readAsDataURL(e)}catch(r){this.onerror(r)}},processQueue:function(){var t=this;e.map(this.queue,function(e){t.onload.apply(t,e)})}}}),define("layout/base",["wrap/jquery"],function(e){var t={maxPass:2},n=function(n){this.settings=e.extend({},t,n)};return n.prototype={constructor:n,getDimensions:function(e,t){},placeSprite:function(e,t,n){},intersection:function(t,n){var r,i,s,o,u=[],a;return e.map(n,function(e){r=e.x<t.x+t.width,s=e.y<t.y+t.height,i=e.x+e.width>t.x,o=e.y+e.height>t.y,r&&i&&s&&o&&u.push(e)}),u.length&&(a=u.pop()),a}},n}),define("layout/compact",["wrap/jquery","util/util","layout/base"],function(e,t,n){var r={maxPass:2},i=function(t){this.settings=e.extend({},r,t)};return t.inherit(i,n,{getDimensions:function(t,n){var r=0,i=0,s=0,o=0;return e.map(t,function(e){r=e.width>r?e.width:r,i=e.height>i?e.height:i,s+=e.area}),o=Math.ceil(Math.sqrt(s)),r=r>o?r:o,i=i>o?i:o,{width:r||n.width,height:i||n.height}},placeSprite:function(e,t,n){var r,i=0,s=0,o=0;while(i++<this.settings.maxPass){for(o=0;o<=n.height-e.height;o++){for(s=0;s<=n.width-e.width;s++){e.x=s,e.y=o,r=this.intersection(e,t);if(!r)return t.push(e),e.show(),!0;s=r.x+r.width-1}o=r.y+r.height-1}n.width+=e.width,n.height+=e.height}}}),i}),define("layout/vertical",["wrap/jquery","util/util","layout/base"],function(e,t,n){var r={maxPass:2},i=function(t){this.settings=e.extend({},r,t)};return t.inherit(i,n,{getDimensions:function(t,n){var r=0,i=0;return e.map(t,function(e){r=e.width>r?e.width:r,i+=e.height}),{width:r||n.width,height:i||n.height}},placeSprite:function(e,t,n){var r,i=0,s=0,o=0;while(i++<this.settings.maxPass){for(o=0;o<=n.height-e.height;o++){e.x=s,e.y=o,r=this.intersection(e,t);if(!r)return t.push(e),e.show(),!0;o=r.y+r.height-1}n.width+=e.width,n.height+=e.height}return!1}}),i}),define("layout/horizontal",["wrap/jquery","util/util","layout/base"],function(e,t,n){var r={maxPass:2},i=function(t){this.settings=e.extend({},r,t)};return t.inherit(i,n,{getDimensions:function(t,n){var r=0,i=0;return e.map(t,function(e){i=e.height>i?e.height:i,r+=e.width}),{width:r||n.width,height:i||n.height}},placeSprite:function(e,t,n){var r,i=0,s=0,o=0;while(i++<this.settings.maxPass){for(s=0;s<=n.width-e.width;s++){e.x=s,e.y=o,r=this.intersection(e,t);if(!r)return t.push(e),e.show(),!0;s=r.x+r.width-1}n.width+=e.width,n.height+=e.height}return!1}}),i}),define("manager/layout",["wrap/jquery","layout/compact","layout/vertical","layout/horizontal"],function(e,t,n,r){var i={compact:t,vertical:n,horizontal:r};return{set:function(e){var t=i[e]||i.compact;this.manager=new t},getDimensions:function(e,t){return this.manager.getDimensions(e,t)},placeSprites:function(t,n,r,i){var s=this;i(0,"info"),e.map(t,function(e){e.placed||(e.placed=s.manager.placeSprite(e,n,r)),i(n.length/t.length)}),t=e.map(t,function(e){return e.placed?null:e})},trim:function(t,n){var r=0,i=0;e.map(t,function(e){r=r>e.x+e.width?r:e.x+e.width,i=i>e.y+e.height?i:e.y+e.height}),n.width=r||n.width,n.height=i||n.height},getSpritesheet:function(t){var n=t.sprites,r=t.dimensions,i,s,o;i=document.createElement("canvas"),i.width=r.width,i.height=r.height;try{s=i.getContext("2d"),e.map(n,function(e){var t=e.left(),n=e.top();s.drawImage(e.image,t,n)}),o=i.toDataURL("image/png")}catch(u){this.$element.trigger("error",[u])}return o}}}),define("stylesheet/base",["wrap/jquery"],function(e){var t={filename:"spritesheet.png"},n=function(n){this.settings=e.extend({},t,n)};return n.prototype={constructor:n,template:null,get:function(e,t,n,r){},markup:function(e,t,n){return this.template({prefix:t,sprites:e,tooltip:n})}},n}),define("stylesheet/css",["wrap/jquery","util/util","util/templates","stylesheet/base"],function(e,t,n,r){var i={filename:"spritesheet.png"},s=function(t){this.settings=e.extend({},i,t)};return t.inherit(s,r,{template:n.cssMarkup,get:function(e,t,r,i){var s=i?t:this.settings.filename;return n.css({prefix:r,backgroundImage:s,sprites:e})}}),s}),define("stylesheet/less",["wrap/jquery","util/util","util/templates","stylesheet/base"],function(e,t,n,r){var i={filename:"spritesheet.png"},s=function(t){this.settings=e.extend({},i,t)};return t.inherit(s,r,{template:n.lessMarkup,get:function(e,t,r,i){var s=i?t:this.settings.filename;return n.less({prefix:r,backgroundImage:s,sprites:e})}}),s}),define("manager/stylesheet",["wrap/jquery","stylesheet/css","stylesheet/less"],function(e,t,n){var r={css:t,less:n};return{set:function(e){var t;this.type=e||"css",t=r[this.type],this.manager=new t},getStylesheet:function(e){var t=e.sprites,n=e.spritesheet,r=e.prefix,i=e.uri,s=this.manager.get(t,n,r,i);return s=s.replace(/\\n/g,"\n"),s},getMarkup:function(e){var t=e.sprites,n=e.prefix,r=e.tooltip||!1,i=this.manager.markup(t,n,r);return i=i.replace(/\\n/g,"\n"),i}}}),define("module/drop-box",["wrap/jquery","util/util"],function(e,t){var n={},r=function(t,r){this.$element=e(t),this.$overlay=this.$element.find(".stitches-overlay"),this.settings=e.extend({},n,r),this.init()};return r.classname=".stitches-drop-box",r.prototype={constructor:r,init:function(){this.bind()},bind:function(){var n=this.$element.get(0),r=this.$overlay.get(0);n.addEventListener("dragenter",e.proxy(this.dragStart,this),!1),r.addEventListener("dragleave",e.proxy(this.dragStop,this),!1),r.addEventListener("dragexit",e.proxy(this.dragStop,this),!1),r.addEventListener("dragover",t.noop,!1),r.addEventListener("drop",e.proxy(this.drop,this),!1)},dragStart:function(e){this.$element.trigger("close-palettes"),this.$element.trigger("show-overlay")},dragStop:function(t){e.contains(this.$element,t.target)&&this.$element.trigger("hide-overlay")},drop:function(e){var t=e.files||e.dataTransfer.files;e.stopPropagation(),e.preventDefault(),t.length?this.$element.trigger("process-files",[t]):this.$element.trigger("hide-overlay")}},r}),define("util/array",["wrap/jquery"],function(e){return{remove:function(t,n){return e(t).filter(function(){return this!==n})}}}),define("module/sprite",["wrap/jquery","util/util","util/templates"],function(e,t,n){var r={name:"",src:"",padding:0},i=function(n,i){this.settings=e.extend({},r,n),this.$element=null,this.name=this.cleanName(this.settings.name),this.src=this.settings.src,this.padding=parseInt(this.settings.padding,10),this.active=!1,this.placed=!1,this.onload=i.onload||t.noop,this.init()};return i.classname=".stitches-sprite",i.prototype={constructor:i,init:function(){this.load()},load:function(){var e=this;this.image=new Image,this.image.onload=function(){e.x=0,e.y=0,e.width=e.image.width+e.padding*2,e.height=e.image.height+e.padding*2,e.area=e.width*e.height,e.render(),e.bind(),e.toDataURL(),e.onload(e)},this.image.src=this.src},render:function(){var t=n.sprite(this);this.$element=e(t),this.$element.data("sprite",this)},bind:function(){this.$element.on("click",e.proxy(this.click,this))},toDataURL:function(){var e,t,n;e=document.createElement("canvas"),e.width=this.image.width,e.height=this.image.height;try{t=e.getContext("2d"),t.drawImage(this.image,0,0),n=e.toDataURL("image/png")}catch(r){this.$element.trigger("error",[r])}this.src=n},reset:function(){this.x=0,this.y=0,this.placed=!1,this.$element.removeClass("placed")},show:function(){this.$element.css({left:this.x+"px",top:this.y+"px",padding:this.padding+"px"}).addClass("placed")},click:function(e){var t=!this.active;t?(this.$element.trigger("clear-active",[this]),this.$element.trigger("open-properties",[this])):this.$element.trigger("close-properties"),this.active=t,this.$element.toggleClass("active",t)},configure:function(e){e.padding&&(this.padding=parseInt(e.padding,10),this.width=this.image.width+this.padding*2,this.height=this.image.height+this.padding*2,this.area=this.width*this.height)},cleanName:function(e){return e=e.replace(/\.\w+$/i,""),e=e.replace(/[\s.]+/gi,"-"),e=e.replace(/[^a-z0-9\-]/gi,"_"),e},left:function(e){var n=this.x+this.padding;return e?t.toPx(-n):n},top:function(e){var n=this.y+this.padding;return e?t.toPx(-n):n},toJSON:function(){return{name:this.name,src:this.src}}},i}),define("module/canvas",["wrap/jquery","util/util","util/array","manager/layout","module/sprite"],function(e,t,n,r,i){var s={images:null,dimensions:{width:400,height:400}},o=function(n,r,i){this.$element=e(n),this.settings=e.extend({},s,r),this.images=this.settings.images,this.dimensions=this.settings.dimensions,this.sprites=[],this.names=[],this.onprogress=i.onprogress||t.noop};return o.classname=".stitches-canvas",o.prototype={constructor:o,init:function(){this.reset=t.debounce(this.reset,500),this.bind(),this.setup(),this.reset()},bind:function(){this.$element.on("clear-active",e.proxy(this.clearActive,this))},setup:function(){var t=this;e(this.images).each(function(){var n=e(this),r=n.data("name"),i=n.attr("src");t.createSprite(r,i)}).remove()},reset:function(){this.$element.trigger("show-overlay"),this.measure(this.sprites),this.place(this.sprites),this.cut(this.sprites),this.$element.trigger("generate-sheets"),this.$element.trigger("hide-overlay")},measure:function(e){this.dimensions=r.getDimensions(e,this.settings.dimensions)},place:function(t){var n=[];e.map(t,function(e){e.reset()}),t=t.sort(function(e,t){return e.name===t.name?0:e.name>t.name?1:-1}),r.placeSprites(t,n,this.dimensions,this.onprogress)},cut:function(e){r.trim(e,this.dimensions),this.$element.css({width:this.dimensions.width+"px",height:this.dimensions.height+"px"})},add:function(e){this.sprites.push(e),this.names.push(e.name),this.$element.trigger("show-overlay"),e.$element.appendTo(this.$element),this.$element.trigger("update-toolbar"),this.reset()},remove:function(e){this.sprites=n.remove(this.sprites,e),this.names=n.remove(this.names,e.name),this.$element.trigger("show-overlay"),e.$element.fadeOut("fast").remove(),this.$element.trigger("update-toolbar"),this.$element.trigger("close-properties"),this.reset()},clear:function(){this.empty(),this.$element.trigger("show-overlay"),this.$element.trigger("update-toolbar"),this.$element.trigger("close-properties"),this.$element.trigger("open-settings"),this.reset()},empty:function(){this.sprites=[],this.names=[],this.$element.empty()},createSprite:function(e,t){var n=this,r=new i({name:e,src:t,padding:this.settings.padding},{onload:function(e){n.add(e)}})},clearActive:function(t,n){this.$element.find(".active").each(function(){var t=e(this),r=t.data("sprite");n&&r!==n&&(t.removeClass("active"),r.active=!1)})},toJSON:function(){return{sprites:this.sprites}}},o}),define("module/toolbar",["wrap/jquery"],function(e){var t={name:"",actions:{}},n=function(n,r){this.$element=e(n),this.settings=e.extend({},t,r),this.name=this.settings.name,this.actions=this.settings.actions,this.init()};return n.classname=".stitches-toolbar",n.prototype={constructor:n,init:function(){this.bind()},bind:function(){var t=this;e.each(this.actions,function(n,r){e.each(r,function(e,r){var i="[data-action="+n+"]",s=t.getHandler(t,r);n==="instance"?t.$element.on(e,t.getHandler(t,s)):t.$element.on(e,i,s)})})},getHandler:function(t,n){return function(r){var i=e(r.currentTarget);i.is(".disabled")?(r.stopPropagation(),r.preventDefault()):n.apply(t,arguments)}},toggleActions:function(t,n){var r=this;typeof t=="string"&&(t=t.split(" ")),e.map(t,function(e){var t=r.$element.find("[data-action="+e+"]");t.toggleClass("disabled",n)})},enable:function(e){this.toggleActions(e,!1)},disable:function(e){this.toggleActions(e,!0)}},n}),define("module/palette",["wrap/jquery","util/util","module/toolbar"],function(e,t,n){var r={name:"",visible:!1,actions:{},fields:{}},i=function(t,n){this.$element=e(t),this.settings=e.extend({},r,n),this.name=this.settings.name,this.visible=this.settings.visible,this.actions=this.settings.actions,this.fields=this.settings.fields,this.source=null,this.init()};return i.classname=".stitches-palette",t.inherit(i,n,{init:function(){this._super("init",this,arguments),this.$element.toggleClass("in",this.visible)},bind:function(){var t=this;this._super("bind",this,arguments),e.each(this.fields,function(n,r){e.each(r,function(e,r){var i="[name="+n+"]",s=t.getHandler(t,r);t.$element.on(e,i,s)})})},open:function(){this.$element.addClass("in"),this.visible=!0},close:function(){this.$element.removeClass("in"),this.visible=!1},configure:function(t){var n=this;this.source=t.source,e.each(t.inputs,function(e,t){var r="[name="+e+"]",i=n.$element.find(r),s=i.attr("type");switch(s){case"radio":case"checkbox":i=i.removeAttr("checked").filter("[value="+t+"]"),i.attr("checked","checked");break;default:i.val(t)}})}}),i}),define("module/stitches",["wrap/jquery","wrap/modernizr","../../../libs/store/store","util/util","util/templates","manager/file","manager/layout","manager/stylesheet","module/drop-box","module/canvas","module/toolbar","module/palette"],function(e,t,n,r,i,s,o,u,a,f,l,c){var h={layout:"compact",prefix:"sprite",padding:5,uri:!1,stylesheet:"css"},p=function(t,n){this.$element=e(t),this.settings=e.extend({},h,n),this.init()};return p.prototype={constructor:p,init:function(){this.configure(),this.render(),this.test(),this.bind(),this.setDropBox(),this.setToolbar(),this.setImages(),this.setCanvas(),this.setManagers(),this.setPalettes(),this.canvas.init()},configure:function(){var t;n&&!n.disabled&&(t=n.get("stitches-settings")),t&&(this.settings=e.extend(this.settings,t))},render:function(){var e=i.stitches({});this.$element.append(e),this.$overlay=this.$element.find(".stitches-overlay"),this.$dropBox=this.$element.find(".stitches-drop-box"),this.$toolbar=this.$element.find(".stitches-toolbar"),this.$canvas=this.$element.find(".stitches-canvas"),this.$progress=this.$element.find(".stitches-progress .progress"),this.$progressBar=this.$element.find(".stitches-progress .bar"),this.$about=this.$element.find(".stitches-about"),this.$downloads=this.$element.find(".stitches-downloads"),this.$settings=this.$element.find(".stitches-settings"),this.$properties=this.$element.find(".stitches-properties")},test:function(){this.hasFileInput=this.$element.find("input.file").length},bind:function(){this.$element.on("show-overlay",e.proxy(this.showOverlay,this)),this.$element.on("hide-overlay",e.proxy(this.hideOverlay,this)),this.$element.on("open-about",e.proxy(this.openAbout,this)),this.$element.on("close-about",e.proxy(this.closeAbout,this)),this.$element.on("open-downloads",e.proxy(this.openDownloads,this)),this.$element.on("close-downloads",e.proxy(this.closeDownloads,this)),this.$element.on("open-settings",e.proxy(this.openSettings,this)),this.$element.on("close-settings",e.proxy(this.closeSettings,this)),this.$element.on("open-properties",e.proxy(this.openProperties,this)),this.$element.on("close-properties",e.proxy(this.closeProperties,this)),this.$element.on("close-palettes",e.proxy(this.closePalettes,this)),this.$element.on("process-files",e.proxy(this.processFiles,this)),this.$element.on("update-toolbar",e.proxy(this.updateToolbar,this)),this.$element.on("update-settings",e.proxy(this.updateSettingsPalette,this)),this.$element.on("update-downloads",e.proxy(this.updateDownloadsPalette,this)),this.$element.on("generate-sheets",e.proxy(this.generateSheets,this)),this.$element.on("error",e.proxy(this.errorHandler,this))},setDropBox:function(){this.dropBox=new a(this.$dropBox)},setManagers:function(){s.set({onload:e.proxy(this.canvas.createSprite,this.canvas),onprogress:e.proxy(this.updateProgress,this)}),o.set(this.settings.layout),u.set(this.settings.stylesheet)},setImages:function(){this.images=this.$element.find("> img").get()},setCanvas:function(){this.canvas=new f(this.$canvas,{images:this.images,padding:this.settings.padding},{onprogress:e.proxy(this.updateProgress,this)})},setToolbar:function(){var e=this;this.toolbar=new l(this.$toolbar,{name:"toolbar",actions:{open:{change:function(t){var n=e.$toolbar.find("input[type=file]"),r=n.clone(!0).val(""),i=t.target.files;e.$element.trigger("process-files",[i]),n.replaceWith(r)}},settings:{click:function(t){e.$element.trigger("open-settings")}},reset:{click:function(t){e.canvas.reset()}},clear:{click:function(t){e.canvas.clear()}},downloads:{click:function(t){e.$element.trigger("open-downloads")}},about:{click:function(t){e.$element.trigger("open-about")}}}})},setPalettes:function(){var t=this,n=new c(this.$about,{name:"about",visible:!0,actions:{close:{click:function(e){this.close()}}}}),r=new c(this.$downloads,{name:"downloads",visible:!1,actions:{close:{click:function(e){this.close()}}}}),i=new c(this.$settings,{name:"settings",visible:!1,actions:{close:{click:function(e){t.$element.trigger("close-settings")}}},fields:{layout:{change:function(e){var n=this.$element.find("input[name=layout]:checked"),r=n.val();this.source.layout=r,o.set(r),t.updateSettings()}},stylesheet:{change:function(e){var n=this.$element.find("input[name=stylesheet]:checked"),r=n.val();t.settings.stylesheet=r,u.set(r),t.updateSettings()}},prefix:{"input blur":function(n){var r=e(n.currentTarget).val();this.source.prefix=r,t.updateSettings()}},padding:{"input blur":function(n){var r=e(n.currentTarget).val();this.source.padding=r,t.canvas.padding=r,e.map(t.canvas.sprites,function(e){e.configure({padding:r})}),t.updateSettings()}},uri:{change:function(n){var r=e(n.currentTarget).is(":checked");this.source.uri=r,t.updateSettings()}},"import":{blur:function(n){var r=e(n.currentTarget),i=r.parents(".control-group"),s=r.val(),o;i.removeClass("error");if(s)try{o=JSON.parse(s),t.importData(o)}catch(u){i.addClass("error"),t.$element.trigger("error",[u])}else t.updateProgress(1,"success")}}}}),s=new c(this.$properties,{name:"properties",visible:!1,actions:{close:{click:function(e){t.$element.trigger("close-properties")}},remove:{click:function(e){var n=this.source;t.canvas.remove(n)}}},fields:{name:{"input blur":function(t){var n=e(t.currentTarget),r=this.source,i=n.val(),s=r.cleanName(i);this.source.name=s,i!==s&&n.val(s)}}}});this.palettes={about:n,downloads:r,settings:i,properties:s}},updateSettings:function(){this.showOverlay(),this.canvas.reset(),n&&!n.disabled&&n.set("stitches-settings",this.settings)},showOverlay:function(e){this.$overlay.fadeTo("fast",.4)},hideOverlay:function(e){this.$overlay.fadeOut("fast")},openAbout:function(e){this.closePalettes(),this.palettes.about.open()},closeAbout:function(e){this.palettes.about.visible&&this.palettes.about.close()},openDownloads:function(e){this.closePalettes(),this.palettes.downloads.open()},closeDownloads:function(e){this.palettes.downloads.visible&&this.palettes.downloads.close()},openSettings:function(e){this.closePalettes(),this.palettes.settings.configure({source:this.settings,inputs:{layout:this.settings.layout,stylesheet:this.settings.stylesheet,prefix:this.settings.prefix,padding:this.settings.padding,uri:this.settings.uri}}),this.palettes.settings.open()},closeSettings:function(e){var t=this.$settings.find("ul.nav-tabs"),n=t.find("li:first-child a"),r=this.$settings.find(":input[name=import]"),i=r.parents(".control-group");n.click(),r.val(""),i.removeClass("error"),this.palettes.settings.visible&&this.palettes.settings.close()},openProperties:function(e,t){this.closePalettes(),this.palettes.properties.configure({source:t,inputs:{name:t.name,x:t.left(),y:t.top()}}),this.palettes.properties.open()},closeProperties:function(e){this.palettes.properties.visible&&(this.palettes.properties.close(),this.canvas.$element.trigger("clear-active",[!0]))},closePalettes:function(e){this.closeAbout(),this.closeDownloads(),this.closeSettings(),this.closeProperties()},processFiles:function(e,t){s.processFiles(t)},updateToolbar:function(e){var t=this.toolbar,n=this.canvas;n.sprites.length?t.enable("reset clear downloads"):t.disable("reset clear downloads"),this.hasFileInput?t.enable("open"):t.disable("open")},updateSettingsPalette:function(e){var t=this.$settings.find(".downloads-export");t.attr({href:"data:text/plain,"+encodeURIComponent(JSON.stringify(this)),target:"_blank"})},updateDownloadsPalette:function(t){var n=this.$downloads.find("section"),r=this.$downloads.find(".downloads-spritesheet"),s=this.$downloads.find(".downloads-stylesheet"),o=i.downloads({prefix:this.settings.prefix,spritesheet:this.spritesheet,stylesheet:this.stylesheet,stylesheetWithUri:this.stylesheetWithUri,stylesheetType:u.type,stylesheetLines:this.stylesheet.split("\n").length,markup:this.markup,markupLines:this.markup.split("\n").length,markupTooltip:this.markupTooltip});n.html(o),r.attr({href:this.spritesheet,target:"_blank"}),s.attr({href:"data:text/plain,"+encodeURIComponent(this.stylesheet),target:"_blank"}),e.fn.tooltip&&n.find("[data-toggle=tooltip]").tooltip()},updateProgress:function(e,t){var n=Math.ceil(e*100);n===100&&t!=="danger"&&t!=="warning"&&(t="success"),t&&this.$progress.attr({"class":"progress progress-"+t}),this.$progressBar.css({width:n+"%"})},generateSheets:function(e){this.spritesheet=o.getSpritesheet({sprites:this.canvas.sprites,dimensions:this.canvas.dimensions}),this.stylesheetWithUri=u.getStylesheet({sprites:this.canvas.sprites,spritesheet:this.spritesheet,prefix:this.settings.prefix,uri:!0}),this.markup=u.getMarkup({sprites:this.canvas.sprites,prefix:this.settings.prefix}),this.markupTooltip=u.getMarkup({sprites:this.canvas.sprites,prefix:this.settings.prefix,tooltip:!0}),this.settings.uri?this.stylesheet=this.stylesheetWithUri:this.stylesheet=u.getStylesheet({sprites:this.canvas.sprites,spritesheet:this.spritesheet,prefix:this.settings.prefix,uri:this.settings.uri}),this.$element.trigger("update-toolbar"),this.$element.trigger("update-settings"),this.$element.trigger("update-downloads"),this.updateProgress(1,"success")},errorHandler:function(e,t,n){this.updateProgress(1,n||"warning")},toJSON:function(){return{settings:this.settings,canvas:this.canvas.toJSON()}},importData:function(t){var n=this,r=t.settings||{},i=t.canvas||{},s=i.sprites||[];this.settings=e.extend({},h,r),o.set(this.settings.layout),u.set(this.settings.stylesheet),this.updateSettings(),this.canvas.clear(),this.canvas.settings.padding=this.settings.padding,e.map(s,function(e){n.canvas.createSprite(e.name,e.src)}),this.updateProgress(1,"success")}},p}),require({paths:{tpl:"../tpl"}},["wrap/jquery","module/stitches"],function(e,t){e(document).ready(function(){var n=".stitches";e(n).each(function(){var e=new t(this)})})}),define("stitches",function(){});
+define("wrap/jquery",[],function(){return jQuery}),define("wrap/modernizr",[],function(){return Modernizr}),function(){function o(){try{return r in t&&t[r]}catch(e){return!1}}var e={},t=window,n=t.document,r="localStorage",i="__storejs__",s;e.disabled=!1,e.set=function(e,t){},e.get=function(e){},e.remove=function(e){},e.clear=function(){},e.transact=function(t,n,r){var i=e.get(t);r==null&&(r=n,n=null),typeof i=="undefined"&&(i=n||{}),r(i),e.set(t,i)},e.setAll=function(){},e.getAll=function(){},e.serialize=function(e){return JSON.stringify(e)},e.deserialize=function(e){if(typeof e!="string")return undefined;try{return JSON.parse(e)}catch(t){return e||undefined}};if(o())s=t[r],e.set=function(t,n){return typeof t=="object"?e.setAll(t):n===undefined?e.remove(t):(s.setItem(t,e.serialize(n)),n)},e.get=function(t){return t===undefined?e.getAll():e.deserialize(s.getItem(t))},e.remove=function(e){s.removeItem(e)},e.clear=function(){s.clear()},e.setAll=function(t){for(var n in t)t[n]=e.set(n,t[n])},e.getAll=function(){var t={};for(var n=0;n<s.length;++n){var r=s.key(n);t[r]=e.get(r)}return t};else if(n.documentElement.addBehavior){var u,a;try{a=new ActiveXObject("htmlfile"),a.open(),a.write('<script>document.w=window</script><iframe src="/favicon.ico"></frame>'),a.close(),u=a.w.frames[0].document,s=u.createElement("div")}catch(f){s=n.createElement("div"),u=n.body}function l(t){return function(){var n=Array.prototype.slice.call(arguments,0);n.unshift(s),u.appendChild(s),s.addBehavior("#default#userData"),s.load(r);var i=t.apply(e,n);return u.removeChild(s),i}}var c=new RegExp("[!\"#$%&'()*+,/\\\\:;<=>?@[\\]^`{|}~]","g");function h(e){return e.replace(c,"___")}e.set=l(function(t,n,i){return typeof n=="object"?e.setAll(n):(n=h(n),i===undefined?e.remove(n):(t.setAttribute(n,e.serialize(i)),t.save(r),i))}),e.get=l(function(t,n){return n===undefined?e.getAll():(n=h(n),e.deserialize(t.getAttribute(n)))}),e.remove=l(function(e,t){t=h(t),e.removeAttribute(t),e.save(r)}),e.clear=l(function(e){var t=e.XMLDocument.documentElement.attributes;e.load(r);for(var n=0,i;i=t[n];n++)e.removeAttribute(i.name);e.save(r)}),e.setAll=l(function(t,n){for(var r in n)n[r]=e.set(r,n[r]);return n}),e.getAll=l(function(t){var n=t.XMLDocument.documentElement.attributes;t.load(r);var i={};for(var s=0,o;o=n[s];++s)i[o]=e.get(o);return i})}try{e.set(i,i),e.get(i)!=i&&(e.disabled=!0),e.remove(i)}catch(f){e.disabled=!0}e.enabled=!e.disabled,typeof module!="undefined"&&typeof module!="function"?module.exports=e:typeof define=="function"&&define.amd?define("module/../../../libs/store/store",e):this.store=e}(),define("util/util",["wrap/jquery"],function(e){return{inherit:function(t,n,r){t.prototype=new n,t.prototype.constructor=n,e.each(r,function(e,n){t.prototype[e]=n}),t.prototype._super=function(e,t,r){var i=n.prototype[e];return i.apply(t,r)}},debounce:function(e,t,n){var r;return function(){var i=this,s=arguments,o=function(){n||e.apply(i,s),r=null};r?window.clearTimeout(r):n&&e.apply(i,s),r=setTimeout(o,t||50)}},noop:function(e){e&&(e.preventDefault(),e.stopPropagation())},toPx:function(e){return e?e+"px":"0"}}}),function(){var e=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"],t=/^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im,n=/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im,r=[],i={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g},s=function(e,t){var n=i,r="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(n.interpolate,function(e,t){return"',"+t.replace(/\\'/g,"'")+",'"}).replace(n.evaluate||null,function(e,t){return"');"+t.replace(/\\'/g,"'").replace(/[\r\n\t]/g," ")+"; __p.push('"}).replace(/\r/g,"").replace(/\n/g,"").replace(/\t/g,"")+"');}return __p.join('');";return r};define("tpl",[],function(){var i,o,u;return typeof window!="undefined"&&window.navigator&&window.document?o=function(e,t){var n=i.createXhr();n.open("GET",e,!0),n.onreadystatechange=function(e){n.readyState===4&&t(n.responseText)},n.send(null)}:typeof process!="undefined"&&process.versions&&!!process.versions.node&&(u=require.nodeRequire("fs"),o=function(e,t){t(u.readFileSync(e,"utf8"))}),i={version:"0.24.0",strip:function(e){if(e){e=e.replace(t,"");var r=e.match(n);r&&(e=r[1])}else e="";return e},jsEscape:function(e){return e.replace(/(['\\])/g,"\\$1").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"").replace(/[\t]/g,"").replace(/[\r]/g,"")},createXhr:function(){var t,n,r;if(typeof XMLHttpRequest!="undefined")return new XMLHttpRequest;for(n=0;n<3;n++){r=e[n];try{t=new ActiveXObject(r)}catch(i){}if(t){e=[r];break}}if(!t)throw new Error("require.getXhr(): XMLHttpRequest not available");return t},get:o,load:function(e,t,n,o){var u=!1,a,f=e.indexOf("."),l=e.substring(0,f),c=e.substring(f+1,e.length);f=c.indexOf("!"),f!==-1&&(u=c.substring(f+1,c.length),u=u==="strip",c=c.substring(0,f)),a="nameToUrl"in t?t.nameToUrl(l,"."+c):t.toUrl(l+"."+c),i.get(a,function(t){t=s(t),o.isBuild||(t=new Function("obj",t)),t=u?i.strip(t):t,o.isBuild&&o.inlineText&&(r[e]=t),n(t)})},write:function(e,t,n){if(t in r){var s=i.jsEscape(r[t]);n("define('"+e+"!"+t+"', function() {return function(obj) { "+s.replace(/(\\')/g,"'").replace(/(\\\\)/g,"\\")+"}});\n")}}}})}(),define("tpl!util/../../templates/stitches.tpl",function(){return function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div class="stitches"> <!-- .stitches-toolbar --> <div class="stitches-toolbar btn-toolbar"> <div class="btn-group"> <a href="http://draeton.github.io/stitches/" class="btn btn-small btn-link"> <strong>Stitches</strong> </a> <button data-action="open" class="btn btn-small btn-info files" title="Open"> <i class="icon-folder-open icon-white"></i> <span class="hidden-phone">Open</span><input class="file" type="file" multiple="multiple"> </button> <button data-action="settings" class="btn btn-small btn-info" title="Set layout, style prefix, padding, etc."> <i class="icon-cog icon-white"></i> <span class="hidden-phone">Settings</span> </button> <button data-action="clear" class="btn btn-small btn-info disabled" title="Clear sprites from the canvas"> <i class="icon-remove icon-white"></i> <span class="hidden-phone">Clear</span> </button> </div> <div class="btn-group"> <button data-action="downloads" class="btn btn-small btn-success disabled" title="Get the generated sprite sheet and stylesheet"> <i class="icon-download-alt icon-white"></i> <span class="hidden-phone">Downloads</span> </button> </div> <div class="btn-group"> <button data-action="about" class="btn btn-small btn-info" title="About Stitches"> <i class="icon-info-sign icon-white"></i> <span class="hidden-phone">About</span> </button> </div> </div> <!-- /.stitches-toolbar --> <!-- .stitches-progress --> <div class="stitches-progress collapse"> <div class="progress progress-warning"> <div class="bar" style="width: 0%;"></div> </div> </div> <!-- /.stitches-progress --> <!-- .stitches-drop-box --> <div class="stitches-drop-box"> <div class="stitches-overlay"></div> <div class="stitches-wrap"> <!-- .stitches-canvas --> <div class="stitches-canvas"></div> <!-- /.stitches-canvas --> </div> <!-- .stitches-palettes --> <div class="stitches-palettes"> <!-- .stitches-settings --> <div class="stitches-palette stitches-settings fade"> <div class="stitches-palette-header"> <button type="button" class="close" data-action="close" title="Close">&times;</button> <h4>Settings</h4> </div> <div class="stitches-palette-body"> <ul class="nav nav-tabs"> <li class="active"><a href="#general" data-toggle="tab">General</a></li> <li><a href="#import" data-toggle="tab">Import</a></li> </ul> <form class="form-horizontal"> <div class="tab-content"> <div class="tab-pane active" id="general"> <div class="control-group hide"> <label class="control-label">Position</label> <div class="controls"> <label class="checkbox"> <input name="position" type="checkbox" value="auto"/> Auto </label> </div> </div> <div class="control-group"> <label class="control-label">Layout</label> <div class="controls"> <label class="radio inline"> <input name="layout" type="radio" value="compact"/> Compact </label> <label class="radio inline"> <input name="layout" type="radio" value="vertical"/> Vertical </label> <label class="radio inline"> <input name="layout" type="radio" value="horizontal"/> Horizontal </label> </div> </div> <div class="control-group"> <label class="control-label">CSS/LESS</label> <div class="controls"> <label class="radio inline"> <input name="stylesheet" type="radio" value="css"/> CSS </label> <label class="radio inline"> <input name="stylesheet" type="radio" value="less"/> LESS </label> </div> </div> <div class="control-group"> <label class="control-label">Style prefix</label> <div class="controls"> <input name="prefix" type="text" placeholder="Style class prefix&hellip;"> </div> </div> <div class="control-group"> <label class="control-label">Padding</label> <div class="controls"> <div class="input-append"> <input name="padding" type="number" min="0" required placeholder="Sprite padding&hellip;"> <span class="add-on">px</span> </div> </div> </div> <div class="control-group"> <label class="control-label">Data URI</label> <div class="controls"> <label class="checkbox"> <input name="uri" type="checkbox" value="true"/> Include encoded image in CSS </label> </div> </div> </div> <div class="tab-pane" id="import"> <div class="control-group"> <label class="control-label">Paste import here</label> <div class="controls"> <textarea name="import" rows="10"></textarea> </div> </div> </div> </div> </form> </div> <div class="stitches-palette-footer"> <div class="btn-toolbar"> <div class="btn-group"> <a href="#" class="downloads-export btn btn-small btn-success" download="stitches"><i class="icon-download-alt icon-white"></i> Export</a> </div> <div class="btn-group"> <button class="btn btn-small btn-info" data-action="close" title="Save"><span>Save</span></button> <button class="btn btn-small btn-info" data-action="close" title="Close"><span>Close</span></button> </div> </div> </div> </div> <!-- /.stitches-settings --> <!-- .stitches-properties --> <div class="stitches-palette stitches-properties fade"> <div class="stitches-palette-header"> <button type="button" class="close" data-action="close" title="Close">&times;</button> <h4>Sprite Properties</h4> </div> <div class="stitches-palette-body"> <form class="form-horizontal"> <div class="control-group"> <label class="control-label">Name</label> <div class="controls"> <input name="name" type="text" required placeholder="Sprite name&hellip;"> </div> </div> <div class="control-group"> <label class="control-label">Coordinates (x, y)</label> <div class="controls"> <div class="input-append"> <input name="x" required disabled placeholder="From left&hellip;" class="input-mini"> <span class="add-on">px</span> </div> <div class="input-append"> <input name="y" required disabled placeholder="From top&hellip;" class="input-mini"> <span class="add-on">px</span> </div> </div> </div> </form> </div> <div class="stitches-palette-footer"> <div class="btn-toolbar"> <div class="btn-group"> <button class="btn btn-small btn-danger" data-action="remove" title="Delete"><span>Delete</span></button> <button class="btn btn-small btn-info" data-action="close" title="Save"><span>Save</span></button> <button class="btn btn-small btn-info" data-action="close" title="Close"><span>Close</span></button> </div> </div> </div> </div> <!-- /.stitches-properties --> <!-- .stitches-about --> <div class="stitches-palette stitches-about fade in"> <div class="stitches-palette-header"> <button type="button" class="close" data-action="close" title="Close">&times;</button> <h4>About Stitches</h4> </div> <div class="stitches-palette-body"> <p><a href="http://draeton.github.io/stitches/">Stitches<a/> is an HTML5 <a href="http://en.wikipedia.org/wiki/Sprite_(computer_graphics)#Sprites_by_CSS">sprite sheet</a> generator.</p> <p>Drag &amp; drop image files onto the space below, or use the &ldquo;Open&rdquo; link to load images using the file browser. Then, click &ldquo;Generate&rdquo; to create a sprite sheet and stylesheet. <em>This demo uses a couple of HTML5 APIs, and it is only currently compatible with WebKit and Firefox browsers.</em></p> <p>Stitches is developed by <a href="http://draeton.github.io">Matthew Cobbs</a> in concert with the lovely open-source community at <a href="http://github.io">Github</a>. Thanks are owed to the developers at Twitter for <a href="http://twitter.github.io/bootstrap">Bootstrap</a>, and <a href="http://glyphicons.com/">Glyphicons</a> for some cool little icons.</p> <p class="text-right"><small>Copyright &copy; 2013 Matthew Cobbs<br/> Licensed under the MIT license.</small></p> </div> <div class="stitches-palette-footer"> <div class="btn-toolbar"> <div class="btn-group"> <button class="btn btn-small btn-info" data-action="close" title="Close"><span>Close</span></button> </div> </div> </div> </div> <!-- /.stitches-about --> <!-- .stitches-downloads --> <div class="stitches-palette stitches-downloads fade"> <div class="stitches-palette-header"> <button type="button" class="close" data-action="close" title="Close">&times;</button> <h4>Downloads</h4> </div> <div class="stitches-palette-body"> <section></section> </div> <div class="stitches-palette-footer"> <div class="btn-toolbar"> <div class="btn-group"> <a href="#" class="downloads-spritesheet btn btn-small btn-success" download="spritesheet"><i class="icon-download-alt icon-white"></i> Spritesheet</a> <a href="#" class="downloads-stylesheet btn btn-small btn-success" download="stylesheet"><i class="icon-download-alt icon-white"></i> Stylesheet</a> <button class="btn btn-small btn-info" data-action="close" title="Close"><span>Close</span></button> </div> </div> </div> </div> <!-- /.stitches-downloads --> </div> <!-- /.stitches-palettes --> </div> <!-- /.stitches-drop-box --></div>');return __p.join("")}}),define("tpl!util/../../templates/downloads.tpl",function(){return function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<ul class="nav nav-tabs"> <li class="active"><a href="#spritesheet" data-toggle="tab">PNG</a></li> <li><a href="#stylesheet" data-toggle="tab">',stylesheetType.toUpperCase(),'</a></li> <li><a href="#markup" data-toggle="tab">HTML</a></li> <li><a href="#example" data-toggle="tab"><strong>Example</strong></a></li></ul><div class="tab-content"> <div class="tab-pane active" id="spritesheet"> <p><img src="',spritesheet,'" class="thumbnail"/></p> </div> <div class="tab-pane" id="stylesheet"> <p><textarea rows="',stylesheetLines,'">',stylesheet,'</textarea></p> </div> <div class="tab-pane" id="markup"> <p><textarea rows="',markupLines,'">',markup,'</textarea></p> </div> <div class="tab-pane stitches-example" id="example"> <style type="text/',stylesheetType,'">',stylesheetWithUri,"</style> <div>",markupTooltip,'</div> <script src="//cdnjs.cloudflare.com/ajax/libs/less.js/1.3.3/less.min.js"></script> </div></div>');return __p.join("")}}),define("tpl!util/../../templates/sprite.tpl",function(){return function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div class="stitches-sprite" style="top: ',y,"px; left: ",x,'px;"> <img src="',image.src,'"/></div>');return __p.join("")}}),define("tpl!util/../../templates/css.tpl",function(){return function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push(".",prefix," {\\n background-image: url(",backgroundImage,");\\n background-repeat: no-repeat;\\n display: block;\\n}\\n"),$.map(sprites,function(e){__p.push("\\n.",prefix,"-",e.name," {\\n width: ",e.image.width,"px;\\n height: ",e.image.height,"px;\\n background-position: ",e.left(!0)," ",e.top(!0),";\\n}\\n")}),__p.push("");return __p.join("")}}),define("tpl!util/../../templates/css-markup.tpl",function(){return function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push(""),$.map(sprites,function(e){__p.push(""),tooltip?__p.push('<i class="',prefix," ",prefix,"-",e.name,'" data-toggle="tooltip" title=".',prefix,".",prefix,"-",e.name,'"></i>\\n'):__p.push('<i class="',prefix," ",prefix,"-",e.name,'"></i>\\n'),__p.push("")}),__p.push("");return __p.join("")}}),define("tpl!util/../../templates/less.tpl",function(){return function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push(".stitches-",prefix,"(@x: 0, @y: 0, @width: 0, @height: 0) {\\n background-position: @x @y;\\n width: @width;\\n height: @height;\\n}\\n\\n.",prefix," {\\n background-image: url(",backgroundImage,"); background-repeat: no-repeat;\\n display: block;\\n"),$.map(sprites,function(e){__p.push("\\n &.",prefix,"-",e.name," {\\n .stitches-",prefix,"(",e.left(!0),", ",e.top(!0),", ",e.image.width,"px, ",e.image.height,"px);\\n }\\n")}),__p.push("}\\n");return __p.join("")}}),define("tpl!util/../../templates/less-markup.tpl",function(){return function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push(""),$.map(sprites,function(e){__p.push(""),tooltip?__p.push('<i class="',prefix," ",prefix,"-",e.name,'" data-toggle="tooltip" title=".',prefix,".",prefix,"-",e.name,'"></i>'):__p.push('<i class="',prefix," ",prefix,"-",e.name,'"></i>\\n'),__p.push("")}),__p.push("");return __p.join("")}}),define("util/templates",["tpl!../../templates/stitches.tpl","tpl!../../templates/downloads.tpl","tpl!../../templates/sprite.tpl","tpl!../../templates/css.tpl","tpl!../../templates/css-markup.tpl","tpl!../../templates/less.tpl","tpl!../../templates/less-markup.tpl"],function(e,t,n,r,i,s,o){return{stitches:function(){return e.apply(this,arguments)},downloads:function(){return t.apply(this,arguments)},sprite:function(){return n.apply(this,arguments)},css:function(){return r.apply(this,arguments)},cssMarkup:function(){return i.apply(this,arguments)},less:function(){return s.apply(this,arguments)},lessMarkup:function(){return o.apply(this,arguments)}}}),define("manager/file",["wrap/jquery","util/util"],function(e,t){return{total:0,processed:0,queue:[],set:function(e){e=e||{},this.onload=e.onload||t.noop,this.onprogress=e.onprogress||t.noop,this.onerror=e.onerror||t.noop},processFiles:function(t){var n=this;this.total=t.length,this.processed=0,this.queue=[],e.map(t,function(e){/jpeg|png|gif/.test(e.type)&&n.processFile(e)}),this.onprogress(0,"info")},processFile:function(e){var t=this,n;try{n=new FileReader,n.onloadend=function(n){var r=e.name,i=n.target.result,s=++t.processed/t.total;t.onprogress(s),t.queue.push([r,i]),t.queue.length===t.total&&t.processQueue()},n.readAsDataURL(e)}catch(r){this.onerror(r)}},processQueue:function(){var t=this;e.map(this.queue,function(e){t.onload.apply(t,e)})}}}),define("layout/base",["wrap/jquery"],function(e){var t={maxPass:2},n=function(n){this.settings=e.extend({},t,n)};return n.prototype={constructor:n,getDimensions:function(e,t){},placeSprite:function(e,t,n){},intersection:function(t,n){var r,i,s,o,u=[],a;return e.map(n,function(e){r=e.x<t.x+t.width,s=e.y<t.y+t.height,i=e.x+e.width>t.x,o=e.y+e.height>t.y,r&&i&&s&&o&&u.push(e)}),u.length&&(a=u.pop()),a}},n}),define("layout/compact",["wrap/jquery","util/util","layout/base"],function(e,t,n){var r={maxPass:2},i=function(t){this.settings=e.extend({},r,t)};return t.inherit(i,n,{getDimensions:function(t,n){var r=0,i=0,s=0,o=0;return e.map(t,function(e){r=e.width>r?e.width:r,i=e.height>i?e.height:i,s+=e.area}),o=Math.ceil(Math.sqrt(s)),r=r>o?r:o,i=i>o?i:o,{width:r||n.width,height:i||n.height}},placeSprite:function(e,t,n){var r,i=0,s=0,o=0;while(i++<this.settings.maxPass){for(o=0;o<=n.height-e.height;o++){for(s=0;s<=n.width-e.width;s++){e.x=s,e.y=o,r=this.intersection(e,t);if(!r)return t.push(e),e.show(),!0;s=r.x+r.width-1}o=r.y+r.height-1}n.width+=e.width,n.height+=e.height}}}),i}),define("layout/vertical",["wrap/jquery","util/util","layout/base"],function(e,t,n){var r={maxPass:2},i=function(t){this.settings=e.extend({},r,t)};return t.inherit(i,n,{getDimensions:function(t,n){var r=0,i=0;return e.map(t,function(e){r=e.width>r?e.width:r,i+=e.height}),{width:r||n.width,height:i||n.height}},placeSprite:function(e,t,n){var r,i=0,s=0,o=0;while(i++<this.settings.maxPass){for(o=0;o<=n.height-e.height;o++){e.x=s,e.y=o,r=this.intersection(e,t);if(!r)return t.push(e),e.show(),!0;o=r.y+r.height-1}n.width+=e.width,n.height+=e.height}return!1}}),i}),define("layout/horizontal",["wrap/jquery","util/util","layout/base"],function(e,t,n){var r={maxPass:2},i=function(t){this.settings=e.extend({},r,t)};return t.inherit(i,n,{getDimensions:function(t,n){var r=0,i=0;return e.map(t,function(e){i=e.height>i?e.height:i,r+=e.width}),{width:r||n.width,height:i||n.height}},placeSprite:function(e,t,n){var r,i=0,s=0,o=0;while(i++<this.settings.maxPass){for(s=0;s<=n.width-e.width;s++){e.x=s,e.y=o,r=this.intersection(e,t);if(!r)return t.push(e),e.show(),!0;s=r.x+r.width-1}n.width+=e.width,n.height+=e.height}return!1}}),i}),define("manager/layout",["wrap/jquery","layout/compact","layout/vertical","layout/horizontal"],function(e,t,n,r){var i={compact:t,vertical:n,horizontal:r};return{set:function(e){var t=i[e]||i.compact;this.manager=new t},getDimensions:function(e,t){return this.manager.getDimensions(e,t)},placeSprites:function(t,n,r,i){var s=this;i(0,"info"),e.map(t,function(e){e.placed||(e.placed=s.manager.placeSprite(e,n,r)),i(n.length/t.length)}),t=e.map(t,function(e){return e.placed?null:e})},trim:function(t,n){var r=0,i=0;e.map(t,function(e){r=r>e.x+e.width?r:e.x+e.width,i=i>e.y+e.height?i:e.y+e.height}),n.width=r||n.width,n.height=i||n.height},getSpritesheet:function(t){var n=t.sprites,r=t.dimensions,i,s,o;i=document.createElement("canvas"),i.width=r.width,i.height=r.height;try{s=i.getContext("2d"),e.map(n,function(e){var t=e.left(),n=e.top();s.drawImage(e.image,t,n)}),o=i.toDataURL("image/png")}catch(u){this.$element.trigger("error",[u])}return o}}}),define("stylesheet/base",["wrap/jquery"],function(e){var t={filename:"spritesheet.png"},n=function(n){this.settings=e.extend({},t,n)};return n.prototype={constructor:n,template:null,get:function(e,t,n,r){},markup:function(e,t,n){return this.template({prefix:t,sprites:e,tooltip:n})}},n}),define("stylesheet/css",["wrap/jquery","util/util","util/templates","stylesheet/base"],function(e,t,n,r){var i={filename:"spritesheet.png"},s=function(t){this.settings=e.extend({},i,t)};return t.inherit(s,r,{template:n.cssMarkup,get:function(e,t,r,i){var s=i?t:this.settings.filename;return n.css({prefix:r,backgroundImage:s,sprites:e})}}),s}),define("stylesheet/less",["wrap/jquery","util/util","util/templates","stylesheet/base"],function(e,t,n,r){var i={filename:"spritesheet.png"},s=function(t){this.settings=e.extend({},i,t)};return t.inherit(s,r,{template:n.lessMarkup,get:function(e,t,r,i){var s=i?t:this.settings.filename;return n.less({prefix:r,backgroundImage:s,sprites:e})}}),s}),define("manager/stylesheet",["wrap/jquery","stylesheet/css","stylesheet/less"],function(e,t,n){var r={css:t,less:n};return{set:function(e){var t;this.type=e||"css",t=r[this.type],this.manager=new t},getStylesheet:function(e){var t=e.sprites,n=e.spritesheet,r=e.prefix,i=e.uri,s=this.manager.get(t,n,r,i);return s=s.replace(/\\n/g,"\n"),s},getMarkup:function(e){var t=e.sprites,n=e.prefix,r=e.tooltip||!1,i=this.manager.markup(t,n,r);return i=i.replace(/\\n/g,"\n"),i}}}),define("module/drop-box",["wrap/jquery","util/util"],function(e,t){var n={},r=function(t,r){this.$element=e(t),this.$overlay=this.$element.find(".stitches-overlay"),this.settings=e.extend({},n,r),this.init()};return r.classname=".stitches-drop-box",r.prototype={constructor:r,init:function(){this.bind()},bind:function(){var n=this.$element.get(0),r=this.$overlay.get(0);n.addEventListener("dragenter",e.proxy(this.dragStart,this),!1),r.addEventListener("dragleave",e.proxy(this.dragStop,this),!1),r.addEventListener("dragexit",e.proxy(this.dragStop,this),!1),r.addEventListener("dragover",t.noop,!1),r.addEventListener("drop",e.proxy(this.drop,this),!1)},dragStart:function(e){this.$element.trigger("close-palettes"),this.$element.trigger("show-overlay")},dragStop:function(t){e.contains(this.$element,t.target)&&this.$element.trigger("hide-overlay")},drop:function(e){var t=e.files||e.dataTransfer.files;e.stopPropagation(),e.preventDefault(),t.length?this.$element.trigger("process-files",[t]):this.$element.trigger("hide-overlay")}},r}),define("util/array",["wrap/jquery"],function(e){return{remove:function(t,n){return e(t).filter(function(){return this!==n})}}}),define("module/sprite",["wrap/jquery","util/util","util/templates"],function(e,t,n){var r={name:"",src:"",padding:0},i=function(n,i){this.settings=e.extend({},r,n),this.$element=null,this.name=this.cleanName(this.settings.name),this.src=this.settings.src,this.padding=parseInt(this.settings.padding,10),this.active=!1,this.placed=!1,this.onload=i.onload||t.noop,this.init()};return i.classname=".stitches-sprite",i.prototype={constructor:i,init:function(){this.load()},load:function(){var e=this;this.image=new Image,this.image.onload=function(){e.x=0,e.y=0,e.width=e.image.width+e.padding*2,e.height=e.image.height+e.padding*2,e.area=e.width*e.height,e.render(),e.bind(),e.toDataURL(),e.onload(e)},this.image.src=this.src},render:function(){var t=n.sprite(this);this.$element=e(t),this.$element.data("sprite",this)},bind:function(){this.$element.on("click",e.proxy(this.click,this))},toDataURL:function(){var e,t,n;e=document.createElement("canvas"),e.width=this.image.width,e.height=this.image.height;try{t=e.getContext("2d"),t.drawImage(this.image,0,0),n=e.toDataURL("image/png")}catch(r){this.$element.trigger("error",[r])}this.src=n},reset:function(){this.x=0,this.y=0,this.placed=!1,this.$element.removeClass("placed")},show:function(){this.$element.css({left:this.x+"px",top:this.y+"px",padding:this.padding+"px"}).addClass("placed")},click:function(e){var t=!this.active;t?(this.$element.trigger("clear-active",[this]),this.$element.trigger("open-properties",[this])):this.$element.trigger("close-properties"),this.active=t,this.$element.toggleClass("active",t)},configure:function(e){e.padding&&(this.padding=parseInt(e.padding,10),this.width=this.image.width+this.padding*2,this.height=this.image.height+this.padding*2,this.area=this.width*this.height)},cleanName:function(e){return e=e.replace(/\.\w+$/i,""),e=e.replace(/[\s.]+/gi,"-"),e=e.replace(/[^a-z0-9\-]/gi,"_"),e},left:function(e){var n=this.x+this.padding;return e?t.toPx(-n):n},top:function(e){var n=this.y+this.padding;return e?t.toPx(-n):n},toJSON:function(){return{name:this.name,src:this.src}}},i}),define("module/canvas",["wrap/jquery","util/util","util/array","manager/layout","module/sprite"],function(e,t,n,r,i){var s={images:null,dimensions:{width:400,height:400}},o=function(n,r,i){this.$element=e(n),this.settings=e.extend({},s,r),this.images=this.settings.images,this.dimensions=this.settings.dimensions,this.sprites=[],this.names=[],this.onprogress=i.onprogress||t.noop};return o.classname=".stitches-canvas",o.prototype={constructor:o,init:function(){this.reset=t.debounce(this.reset,500),this.bind(),this.setup(),this.reset()},bind:function(){this.$element.on("clear-active",e.proxy(this.clearActive,this))},setup:function(){var t=this;e(this.images).each(function(){var n=e(this),r=n.data("name"),i=n.attr("src");t.createSprite(r,i)}).remove()},reset:function(){this.$element.trigger("show-overlay"),this.measure(this.sprites),this.place(this.sprites),this.cut(this.sprites),this.$element.trigger("generate-sheets"),this.$element.trigger("hide-overlay")},measure:function(e){this.dimensions=r.getDimensions(e,this.settings.dimensions)},place:function(t){var n=[];e.map(t,function(e){e.reset()}),t=t.sort(function(e,t){return e.name===t.name?0:e.name>t.name?1:-1}),r.placeSprites(t,n,this.dimensions,this.onprogress)},cut:function(e){r.trim(e,this.dimensions),this.$element.css({width:this.dimensions.width+"px",height:this.dimensions.height+"px"})},add:function(e){this.sprites.push(e),this.names.push(e.name),this.$element.trigger("show-overlay"),e.$element.appendTo(this.$element),this.$element.trigger("update-toolbar"),this.reset()},remove:function(e){this.sprites=n.remove(this.sprites,e),this.names=n.remove(this.names,e.name),this.$element.trigger("show-overlay"),e.$element.fadeOut("fast").remove(),this.$element.trigger("update-toolbar"),this.$element.trigger("close-properties"),this.reset()},clear:function(){this.empty(),this.$element.trigger("show-overlay"),this.$element.trigger("update-toolbar"),this.$element.trigger("close-properties"),this.$element.trigger("open-settings"),this.reset()},empty:function(){this.sprites=[],this.names=[],this.$element.empty()},createSprite:function(e,t){var n=this,r=new i({name:e,src:t,padding:this.settings.padding},{onload:function(e){n.add(e)}})},clearActive:function(t,n){this.$element.find(".active").each(function(){var t=e(this),r=t.data("sprite");n&&r!==n&&(t.removeClass("active"),r.active=!1)})},toJSON:function(){return{sprites:this.sprites}}},o}),define("module/toolbar",["wrap/jquery"],function(e){var t={name:"",actions:{}},n=function(n,r){this.$element=e(n),this.settings=e.extend({},t,r),this.name=this.settings.name,this.actions=this.settings.actions,this.init()};return n.classname=".stitches-toolbar",n.prototype={constructor:n,init:function(){this.bind()},bind:function(){var t=this;e.each(this.actions,function(n,r){e.each(r,function(e,r){var i="[data-action="+n+"]",s=t.getHandler(t,r);n==="instance"?t.$element.on(e,t.getHandler(t,s)):t.$element.on(e,i,s)})})},getHandler:function(t,n){return function(r){var i=e(r.currentTarget);i.is(".disabled")?(r.stopPropagation(),r.preventDefault()):n.apply(t,arguments)}},toggleActions:function(t,n){var r=this;typeof t=="string"&&(t=t.split(" ")),e.map(t,function(e){var t=r.$element.find("[data-action="+e+"]");t.toggleClass("disabled",n)})},enable:function(e){this.toggleActions(e,!1)},disable:function(e){this.toggleActions(e,!0)}},n}),define("module/palette",["wrap/jquery","util/util","module/toolbar"],function(e,t,n){var r={name:"",visible:!1,actions:{},fields:{}},i=function(t,n){this.$element=e(t),this.settings=e.extend({},r,n),this.name=this.settings.name,this.visible=this.settings.visible,this.actions=this.settings.actions,this.fields=this.settings.fields,this.source=null,this.init()};return i.classname=".stitches-palette",t.inherit(i,n,{init:function(){this._super("init",this,arguments),this.$element.toggleClass("in",this.visible)},bind:function(){var t=this;this._super("bind",this,arguments),e.each(this.fields,function(n,r){e.each(r,function(e,r){var i="[name="+n+"]",s=t.getHandler(t,r);t.$element.on(e,i,s)})})},open:function(){this.$element.addClass("in"),this.visible=!0},close:function(){this.$element.removeClass("in"),this.visible=!1},configure:function(t){var n=this;this.source=t.source,e.each(t.inputs,function(e,t){var r="[name="+e+"]",i=n.$element.find(r),s=i.attr("type");switch(s){case"radio":case"checkbox":i=i.removeAttr("checked").filter("[value="+t+"]"),i.attr("checked","checked");break;default:i.val(t)}})}}),i}),define("module/stitches",["wrap/jquery","wrap/modernizr","../../../libs/store/store","util/util","util/templates","manager/file","manager/layout","manager/stylesheet","module/drop-box","module/canvas","module/toolbar","module/palette"],function(e,t,n,r,i,s,o,u,a,f,l,c){var h={layout:"compact",prefix:"sprite",padding:5,uri:!1,stylesheet:"css"},p=function(t,n){this.$element=e(t),this.settings=e.extend({},h,n),this.init()};return p.prototype={constructor:p,init:function(){this.configure(),this.render(),this.test(),this.bind(),this.setDropBox(),this.setToolbar(),this.setImages(),this.setCanvas(),this.setManagers(),this.setPalettes(),this.canvas.init()},configure:function(){var t;n&&!n.disabled&&(t=n.get("stitches-settings")),t&&(this.settings=e.extend(this.settings,t))},render:function(){var e=i.stitches({});this.$element.append(e),this.$overlay=this.$element.find(".stitches-overlay"),this.$dropBox=this.$element.find(".stitches-drop-box"),this.$toolbar=this.$element.find(".stitches-toolbar"),this.$canvas=this.$element.find(".stitches-canvas"),this.$progress=this.$element.find(".stitches-progress .progress"),this.$progressBar=this.$element.find(".stitches-progress .bar"),this.$about=this.$element.find(".stitches-about"),this.$downloads=this.$element.find(".stitches-downloads"),this.$settings=this.$element.find(".stitches-settings"),this.$properties=this.$element.find(".stitches-properties")},test:function(){this.hasFileInput=this.$element.find("input.file").length},bind:function(){this.$element.on("show-overlay",e.proxy(this.showOverlay,this)),this.$element.on("hide-overlay",e.proxy(this.hideOverlay,this)),this.$element.on("open-about",e.proxy(this.openAbout,this)),this.$element.on("close-about",e.proxy(this.closeAbout,this)),this.$element.on("open-downloads",e.proxy(this.openDownloads,this)),this.$element.on("close-downloads",e.proxy(this.closeDownloads,this)),this.$element.on("open-settings",e.proxy(this.openSettings,this)),this.$element.on("close-settings",e.proxy(this.closeSettings,this)),this.$element.on("open-properties",e.proxy(this.openProperties,this)),this.$element.on("close-properties",e.proxy(this.closeProperties,this)),this.$element.on("close-palettes",e.proxy(this.closePalettes,this)),this.$element.on("process-files",e.proxy(this.processFiles,this)),this.$element.on("update-toolbar",e.proxy(this.updateToolbar,this)),this.$element.on("update-settings",e.proxy(this.updateSettingsPalette,this)),this.$element.on("update-downloads",e.proxy(this.updateDownloadsPalette,this)),this.$element.on("generate-sheets",e.proxy(this.generateSheets,this)),this.$element.on("error",e.proxy(this.errorHandler,this))},setDropBox:function(){this.dropBox=new a(this.$dropBox)},setManagers:function(){s.set({onload:e.proxy(this.canvas.createSprite,this.canvas),onprogress:e.proxy(this.updateProgress,this)}),o.set(this.settings.layout),u.set(this.settings.stylesheet)},setImages:function(){this.images=this.$element.find("> img").get()},setCanvas:function(){this.canvas=new f(this.$canvas,{images:this.images,padding:this.settings.padding},{onprogress:e.proxy(this.updateProgress,this)})},setToolbar:function(){var e=this;this.toolbar=new l(this.$toolbar,{name:"toolbar",actions:{open:{change:function(t){var n=e.$toolbar.find("input[type=file]"),r=n.clone(!0).val(""),i=t.target.files;e.$element.trigger("process-files",[i]),n.replaceWith(r)}},settings:{click:function(t){e.$element.trigger("open-settings")}},reset:{click:function(t){e.canvas.reset()}},clear:{click:function(t){e.canvas.clear()}},downloads:{click:function(t){e.$element.trigger("open-downloads")}},about:{click:function(t){e.$element.trigger("open-about")}}}})},setPalettes:function(){var t=this,n=new c(this.$about,{name:"about",visible:!0,actions:{close:{click:function(e){this.close()}}}}),r=new c(this.$downloads,{name:"downloads",visible:!1,actions:{close:{click:function(e){this.close()}}}}),i=new c(this.$settings,{name:"settings",visible:!1,actions:{close:{click:function(e){t.$element.trigger("close-settings")}}},fields:{layout:{change:function(e){var n=this.$element.find("input[name=layout]:checked"),r=n.val();this.source.layout=r,o.set(r),t.updateSettings()}},stylesheet:{change:function(e){var n=this.$element.find("input[name=stylesheet]:checked"),r=n.val();t.settings.stylesheet=r,u.set(r),t.updateSettings()}},prefix:{"input blur":function(n){var r=e(n.currentTarget).val();this.source.prefix=r,t.updateSettings()}},padding:{"input blur":function(n){var r=e(n.currentTarget).val();this.source.padding=r,t.canvas.padding=r,e.map(t.canvas.sprites,function(e){e.configure({padding:r})}),t.updateSettings()}},uri:{change:function(n){var r=e(n.currentTarget).is(":checked");this.source.uri=r,t.updateSettings()}},"import":{blur:function(n){var r=e(n.currentTarget),i=r.parents(".control-group"),s=r.val(),o;i.removeClass("error");if(s)try{o=JSON.parse(s),t.importData(o)}catch(u){i.addClass("error"),t.$element.trigger("error",[u])}else t.updateProgress(1,"success")}}}}),s=new c(this.$properties,{name:"properties",visible:!1,actions:{close:{click:function(e){t.$element.trigger("close-properties")}},remove:{click:function(e){var n=this.source;t.canvas.remove(n)}}},fields:{name:{"input blur":function(t){var n=e(t.currentTarget),r=this.source,i=n.val(),s=r.cleanName(i);this.source.name=s,i!==s&&n.val(s)}}}});this.palettes={about:n,downloads:r,settings:i,properties:s}},updateSettings:function(){this.showOverlay(),this.canvas.reset(),n&&!n.disabled&&n.set("stitches-settings",this.settings)},showOverlay:function(e){this.$overlay.fadeTo("fast",.4)},hideOverlay:function(e){this.$overlay.fadeOut("fast")},openAbout:function(e){this.closePalettes(),this.palettes.about.open()},closeAbout:function(e){this.palettes.about.visible&&this.palettes.about.close()},openDownloads:function(e){this.closePalettes(),this.palettes.downloads.open()},closeDownloads:function(e){this.palettes.downloads.visible&&this.palettes.downloads.close()},openSettings:function(e){this.closePalettes(),this.palettes.settings.configure({source:this.settings,inputs:{layout:this.settings.layout,stylesheet:this.settings.stylesheet,prefix:this.settings.prefix,padding:this.settings.padding,uri:this.settings.uri}}),this.palettes.settings.open()},closeSettings:function(e){var t=this.$settings.find("ul.nav-tabs"),n=t.find("li:first-child a"),r=this.$settings.find(":input[name=import]"),i=r.parents(".control-group");n.click(),r.val(""),i.removeClass("error"),this.palettes.settings.visible&&this.palettes.settings.close()},openProperties:function(e,t){this.closePalettes(),this.palettes.properties.configure({source:t,inputs:{name:t.name,x:t.left(),y:t.top()}}),this.palettes.properties.open()},closeProperties:function(e){this.palettes.properties.visible&&(this.palettes.properties.close(),this.canvas.$element.trigger("clear-active",[!0]))},closePalettes:function(e){this.closeAbout(),this.closeDownloads(),this.closeSettings(),this.closeProperties()},processFiles:function(e,t){s.processFiles(t)},updateToolbar:function(e){var t=this.toolbar,n=this.canvas;n.sprites.length?t.enable("reset clear downloads"):t.disable("reset clear downloads"),this.hasFileInput?t.enable("open"):t.disable("open")},updateSettingsPalette:function(e){var t=this.$settings.find(".downloads-export");t.attr({href:"data:text/plain,"+encodeURIComponent(JSON.stringify(this)),target:"_blank"})},updateDownloadsPalette:function(t){var n=this.$downloads.find("section"),r=this.$downloads.find(".downloads-spritesheet"),s=this.$downloads.find(".downloads-stylesheet"),o=i.downloads({prefix:this.settings.prefix,spritesheet:this.spritesheet,stylesheet:this.stylesheet,stylesheetWithUri:this.stylesheetWithUri,stylesheetType:u.type,stylesheetLines:this.stylesheet.split("\n").length,markup:this.markup,markupLines:this.markup.split("\n").length,markupTooltip:this.markupTooltip});n.html(o),r.attr({href:this.spritesheet,target:"_blank"}),s.attr({href:"data:text/plain,"+encodeURIComponent(this.stylesheet),target:"_blank"}),e.fn.tooltip&&n.find("[data-toggle=tooltip]").tooltip()},updateProgress:function(e,t){var n=Math.ceil(e*100);n===100&&t!=="danger"&&t!=="warning"&&(t="success"),t&&this.$progress.attr({"class":"progress progress-"+t}),this.$progressBar.css({width:n+"%"})},generateSheets:function(e){this.spritesheet=o.getSpritesheet({sprites:this.canvas.sprites,dimensions:this.canvas.dimensions}),this.stylesheetWithUri=u.getStylesheet({sprites:this.canvas.sprites,spritesheet:this.spritesheet,prefix:this.settings.prefix,uri:!0}),this.markup=u.getMarkup({sprites:this.canvas.sprites,prefix:this.settings.prefix}),this.markupTooltip=u.getMarkup({sprites:this.canvas.sprites,prefix:this.settings.prefix,tooltip:!0}),this.settings.uri?this.stylesheet=this.stylesheetWithUri:this.stylesheet=u.getStylesheet({sprites:this.canvas.sprites,spritesheet:this.spritesheet,prefix:this.settings.prefix,uri:this.settings.uri}),this.$element.trigger("update-toolbar"),this.$element.trigger("update-settings"),this.$element.trigger("update-downloads"),this.updateProgress(1,"success")},errorHandler:function(e,t,n){this.updateProgress(1,n||"warning")},toJSON:function(){return{settings:this.settings,canvas:this.canvas.toJSON()}},importData:function(t){var n=this,r=t.settings||{},i=t.canvas||{},s=i.sprites||[];this.settings=e.extend({},h,r),o.set(this.settings.layout),u.set(this.settings.stylesheet),this.updateSettings(),this.canvas.clear(),this.canvas.settings.padding=this.settings.padding,e.map(s,function(e){n.canvas.createSprite(e.name,e.src)}),this.updateProgress(1,"success")}},p}),require({paths:{tpl:"../tpl"}},["wrap/jquery","module/stitches"],function(e,t){e(document).ready(function(){var n=".stitches";e(n).each(function(){var e=new t(this)})})}),define("stitches",function(){});
View
2  stitches/build/stitches/js/stitches-1.3.5.min.js
@@ -1,2 +1,2 @@
var requirejs,require,define;(function(global){function isFunction(e){return"[object Function]"===ostring.call(e)}function isArray(e){return"[object Array]"===ostring.call(e)}function each(e,t){if(e){var i;for(i=0;e.length>i&&(!e[i]||!t(e[i],i,e));i+=1);}}function eachReverse(e,t){if(e){var i;for(i=e.length-1;i>-1&&(!e[i]||!t(e[i],i,e));i-=1);}}function hasProp(e,t){return hasOwn.call(e,t)}function getOwn(e,t){return hasProp(e,t)&&e[t]}function eachProp(e,t){var i;for(i in e)if(hasProp(e,i)&&t(e[i],i))break}function mixin(e,t,i,s){return t&&eachProp(t,function(t,n){(i||!hasProp(e,n))&&(s&&"string"!=typeof t?(e[n]||(e[n]={}),mixin(e[n],t,i,s)):e[n]=t)}),e}function bind(e,t){return function(){return t.apply(e,arguments)}}function scripts(){return document.getElementsByTagName("script")}function getGlobal(e){if(!e)return e;var t=global;return each(e.split("."),function(e){t=t[e]}),t}function makeError(e,t,i,s){var n=Error(t+"\nhttp://requirejs.org/docs/errors.html#"+e);return n.requireType=e,n.requireModules=s,i&&(n.originalError=i),n}function newContext(e){function t(e){var t,i;for(t=0;e[t];t+=1)if(i=e[t],"."===i)e.splice(t,1),t-=1;else if(".."===i){if(1===t&&(".."===e[2]||".."===e[0]))break;t>0&&(e.splice(t-1,2),t-=2)}}function i(e,i,s){var n,r,a,o,l,c,p,h,u,d,f,g=i&&i.split("/"),m=g,v=k.map,b=v&&v["*"];if(e&&"."===e.charAt(0)&&(i?(m=getOwn(k.pkgs,i)?g=[i]:g.slice(0,g.length-1),e=m.concat(e.split("/")),t(e),r=getOwn(k.pkgs,n=e[0]),e=e.join("/"),r&&e===n+"/"+r.main&&(e=n)):0===e.indexOf("./")&&(e=e.substring(2))),s&&(g||b)&&v){for(o=e.split("/"),l=o.length;l>0;l-=1){if(p=o.slice(0,l).join("/"),g)for(c=g.length;c>0;c-=1)if(a=getOwn(v,g.slice(0,c).join("/")),a&&(a=getOwn(a,p))){h=a,u=l;break}if(h)break;!d&&b&&getOwn(b,p)&&(d=getOwn(b,p),f=l)}!h&&d&&(h=d,u=f),h&&(o.splice(0,u,h),e=o.join("/"))}return e}function s(e){isBrowser&&each(scripts(),function(t){return t.getAttribute("data-requiremodule")===e&&t.getAttribute("data-requirecontext")===x.contextName?(t.parentNode.removeChild(t),!0):void 0})}function n(e){var t=getOwn(k.paths,e);return t&&isArray(t)&&t.length>1?(s(e),t.shift(),x.require.undef(e),x.require([e]),!0):void 0}function r(e){var t,i=e?e.indexOf("!"):-1;return i>-1&&(t=e.substring(0,i),e=e.substring(i+1,e.length)),[t,e]}function a(e,t,s,n){var a,o,l,c,p=null,h=t?t.name:null,u=e,d=!0,f="";return e||(d=!1,e="_@r"+(P+=1)),c=r(e),p=c[0],e=c[1],p&&(p=i(p,h,n),o=getOwn(j,p)),e&&(p?f=o&&o.normalize?o.normalize(e,function(e){return i(e,h,n)}):i(e,h,n):(f=i(e,h,n),c=r(f),p=c[0],f=c[1],s=!0,a=x.nameToUrl(f))),l=!p||o||s?"":"_unnormalized"+(M+=1),{prefix:p,name:f,parentMap:t,unnormalized:!!l,url:a,originalName:u,isDefine:d,id:(p?p+"!"+f:f)+l}}function o(e){var t=e.id,i=getOwn(S,t);return i||(i=S[t]=new x.Module(e)),i}function l(e,t,i){var s=e.id,n=getOwn(S,s);!hasProp(j,s)||n&&!n.defineEmitComplete?o(e).on(t,i):"defined"===t&&i(j[s])}function c(e,t){var i=e.requireModules,s=!1;t?t(e):(each(i,function(t){var i=getOwn(S,t);i&&(i.error=e,i.events.error&&(s=!0,i.emit("error",e)))}),s||req.onError(e))}function p(){globalDefQueue.length&&(apsp.apply(_,[_.length-1,0].concat(globalDefQueue)),globalDefQueue=[])}function h(e){delete S[e]}function u(e,t,i){var s=e.map.id;e.error?e.emit("error",e.error):(t[s]=!0,each(e.depMaps,function(s,n){var r=s.id,a=getOwn(S,r);a&&!e.depMatched[n]&&!i[r]&&(getOwn(t,r)?(e.defineDep(n,j[r]),e.check()):u(a,t,i))}),i[s]=!0)}function d(){var e,t,i,r,a=1e3*k.waitSeconds,o=a&&x.startTime+a<(new Date).getTime(),l=[],p=[],h=!1,f=!0;if(!b)return b=!0,eachProp(S,function(i){if(e=i.map,t=e.id,i.enabled&&(e.isDefine||p.push(i),!i.error))if(!i.inited&&o)n(t)?(r=!0,h=!0):(l.push(t),s(t));else if(!i.inited&&i.fetched&&e.isDefine&&(h=!0,!e.prefix))return f=!1}),o&&l.length?(i=makeError("timeout","Load timeout for modules: "+l,null,l),i.contextName=x.contextName,c(i)):(f&&each(p,function(e){u(e,{},{})}),(!o||r)&&h&&(isBrowser||isWebWorker)&&!$&&($=setTimeout(function(){$=0,d()},50)),b=!1,void 0)}function f(e){hasProp(j,e[0])||o(a(e[0],null,!0)).init(e[1],e[2])}function g(e,t,i,s){e.detachEvent&&!isOpera?s&&e.detachEvent(s,t):e.removeEventListener(i,t,!1)}function m(e){var t=e.currentTarget||e.srcElement;return g(t,x.onScriptLoad,"load","onreadystatechange"),g(t,x.onScriptError,"error"),{node:t,id:t&&t.getAttribute("data-requiremodule")}}function v(){var e;for(p();_.length;){if(e=_.shift(),null===e[0])return c(makeError("mismatch","Mismatched anonymous define() module: "+e[e.length-1]));f(e)}}var b,y,x,w,$,k={waitSeconds:7,baseUrl:"./",paths:{},pkgs:{},shim:{},map:{},config:{}},S={},q={},_=[],j={},E={},P=1,M=1;return w={require:function(e){return e.require?e.require:e.require=x.makeRequire(e.map)},exports:function(e){return e.usingExports=!0,e.map.isDefine?e.exports?e.exports:e.exports=j[e.map.id]={}:void 0},module:function(e){return e.module?e.module:e.module={id:e.map.id,uri:e.map.url,config:function(){return k.config&&getOwn(k.config,e.map.id)||{}},exports:j[e.map.id]}}},y=function(e){this.events=getOwn(q,e.id)||{},this.map=e,this.shim=getOwn(k.shim,e.id),this.depExports=[],this.depMaps=[],this.depMatched=[],this.pluginMaps={},this.depCount=0},y.prototype={init:function(e,t,i,s){s=s||{},this.inited||(this.factory=t,i?this.on("error",i):this.events.error&&(i=bind(this,function(e){this.emit("error",e)})),this.depMaps=e&&e.slice(0),this.errback=i,this.inited=!0,this.ignore=s.ignore,s.enabled||this.enabled?this.enable():this.check())},defineDep:function(e,t){this.depMatched[e]||(this.depMatched[e]=!0,this.depCount-=1,this.depExports[e]=t)},fetch:function(){if(!this.fetched){this.fetched=!0,x.startTime=(new Date).getTime();var e=this.map;return this.shim?(x.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],bind(this,function(){return e.prefix?this.callPlugin():this.load()})),void 0):e.prefix?this.callPlugin():this.load()}},load:function(){var e=this.map.url;E[e]||(E[e]=!0,x.load(this.map.id,e))},check:function(){if(this.enabled&&!this.enabling){var e,t,i=this.map.id,s=this.depExports,n=this.exports,r=this.factory;if(this.inited){if(this.error)this.emit("error",this.error);else if(!this.defining){if(this.defining=!0,1>this.depCount&&!this.defined){if(isFunction(r)){if(this.events.error)try{n=x.execCb(i,r,s,n)}catch(a){e=a}else n=x.execCb(i,r,s,n);if(this.map.isDefine&&(t=this.module,t&&void 0!==t.exports&&t.exports!==this.exports?n=t.exports:void 0===n&&this.usingExports&&(n=this.exports)),e)return e.requireMap=this.map,e.requireModules=[this.map.id],e.requireType="define",c(this.error=e)}else n=r;this.exports=n,this.map.isDefine&&!this.ignore&&(j[i]=n,req.onResourceLoad&&req.onResourceLoad(x,this.map,this.depMaps)),delete S[i],this.defined=!0}this.defining=!1,this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0)}}else this.fetch()}},callPlugin:function(){var e=this.map,t=e.id,s=a(e.prefix);this.depMaps.push(s),l(s,"defined",bind(this,function(s){var n,r,p,u=this.map.name,d=this.map.parentMap?this.map.parentMap.name:null,f=x.makeRequire(e.parentMap,{enableBuildCallback:!0});return this.map.unnormalized?(s.normalize&&(u=s.normalize(u,function(e){return i(e,d,!0)})||""),r=a(e.prefix+"!"+u,this.map.parentMap),l(r,"defined",bind(this,function(e){this.init([],function(){return e},null,{enabled:!0,ignore:!0})})),p=getOwn(S,r.id),p&&(this.depMaps.push(r),this.events.error&&p.on("error",bind(this,function(e){this.emit("error",e)})),p.enable()),void 0):(n=bind(this,function(e){this.init([],function(){return e},null,{enabled:!0})}),n.error=bind(this,function(e){this.inited=!0,this.error=e,e.requireModules=[t],eachProp(S,function(e){0===e.map.id.indexOf(t+"_unnormalized")&&h(e.map.id)}),c(e)}),n.fromText=bind(this,function(i,s){var r=e.name,l=a(r),p=useInteractive;s&&(i=s),p&&(useInteractive=!1),o(l),hasProp(k.config,t)&&(k.config[r]=k.config[t]);try{req.exec(i)}catch(h){return c(makeError("fromtexteval","fromText eval for "+t+" failed: "+h,h,[t]))}p&&(useInteractive=!0),this.depMaps.push(l),x.completeLoad(r),f([r],n)}),s.load(e.name,f,n,k),void 0)})),x.enable(s,this),this.pluginMaps[s.id]=s},enable:function(){this.enabled=!0,this.enabling=!0,each(this.depMaps,bind(this,function(e,t){var i,s,n;if("string"==typeof e){if(e=a(e,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap),this.depMaps[t]=e,n=getOwn(w,e.id),n)return this.depExports[t]=n(this),void 0;this.depCount+=1,l(e,"defined",bind(this,function(e){this.defineDep(t,e),this.check()})),this.errback&&l(e,"error",this.errback)}i=e.id,s=S[i],!hasProp(w,i)&&s&&!s.enabled&&x.enable(e,this)})),eachProp(this.pluginMaps,bind(this,function(e){var t=getOwn(S,e.id);t&&!t.enabled&&x.enable(e,this)})),this.enabling=!1,this.check()},on:function(e,t){var i=this.events[e];i||(i=this.events[e]=[]),i.push(t)},emit:function(e,t){each(this.events[e],function(e){e(t)}),"error"===e&&delete this.events[e]}},x={config:k,contextName:e,registry:S,defined:j,urlFetched:E,defQueue:_,Module:y,makeModuleMap:a,nextTick:req.nextTick,configure:function(e){e.baseUrl&&"/"!==e.baseUrl.charAt(e.baseUrl.length-1)&&(e.baseUrl+="/");var t=k.pkgs,i=k.shim,s={paths:!0,config:!0,map:!0};eachProp(e,function(e,t){s[t]?"map"===t?mixin(k[t],e,!0,!0):mixin(k[t],e,!0):k[t]=e}),e.shim&&(eachProp(e.shim,function(e,t){isArray(e)&&(e={deps:e}),(e.exports||e.init)&&!e.exportsFn&&(e.exportsFn=x.makeShimExports(e)),i[t]=e}),k.shim=i),e.packages&&(each(e.packages,function(e){var i;e="string"==typeof e?{name:e}:e,i=e.location,t[e.name]={name:e.name,location:i||e.name,main:(e.main||"main").replace(currDirRegExp,"").replace(jsSuffixRegExp,"")}}),k.pkgs=t),eachProp(S,function(e,t){!e.inited&&!e.map.unnormalized&&(e.map=a(t))}),(e.deps||e.callback)&&x.require(e.deps||[],e.callback)},makeShimExports:function(e){function t(){var t;return e.init&&(t=e.init.apply(global,arguments)),t||e.exports&&getGlobal(e.exports)}return t},makeRequire:function(t,s){function n(i,r,l){var p,h,u;return s.enableBuildCallback&&r&&isFunction(r)&&(r.__requireJsBuild=!0),"string"==typeof i?isFunction(r)?c(makeError("requireargs","Invalid require call"),l):t&&hasProp(w,i)?w[i](S[t.id]):req.get?req.get(x,i,t):(h=a(i,t,!1,!0),p=h.id,hasProp(j,p)?j[p]:c(makeError("notloaded",'Module name "'+p+'" has not been loaded yet for context: '+e+(t?"":". Use require([])")))):(v(),x.nextTick(function(){v(),u=o(a(null,t)),u.skipMap=s.skipMap,u.init(i,r,l,{enabled:!0}),d()}),n)}return s=s||{},mixin(n,{isBrowser:isBrowser,toUrl:function(e){var s,n,r=e.lastIndexOf("."),a=e.split("/")[0],o="."===a||".."===a;return-1!==r&&(!o||r>1)&&(s=e.substring(r,e.length),e=e.substring(0,r)),n=x.nameToUrl(i(e,t&&t.id,!0),s||".fake"),s?n:n.substring(0,n.length-5)},defined:function(e){return hasProp(j,a(e,t,!1,!0).id)},specified:function(e){return e=a(e,t,!1,!0).id,hasProp(j,e)||hasProp(S,e)}}),t||(n.undef=function(e){p();var i=a(e,t,!0),s=getOwn(S,e);delete j[e],delete E[i.url],delete q[e],s&&(s.events.defined&&(q[e]=s.events),h(e))}),n},enable:function(e){var t=getOwn(S,e.id);t&&o(e).enable()},completeLoad:function(e){var t,i,s,r=getOwn(k.shim,e)||{},a=r.exports;for(p();_.length;){if(i=_.shift(),null===i[0]){if(i[0]=e,t)break;t=!0}else i[0]===e&&(t=!0);f(i)}if(s=getOwn(S,e),!t&&!hasProp(j,e)&&s&&!s.inited){if(k.enforceDefine&&(!a||!getGlobal(a))){if(n(e))return;return c(makeError("nodefine","No define call for "+e,null,[e]))}f([e,r.deps||[],r.exportsFn])}d()},nameToUrl:function(e,t){var i,s,n,r,a,o,l,c,p;if(req.jsExtRegExp.test(e))c=e+(t||"");else{for(i=k.paths,s=k.pkgs,a=e.split("/"),o=a.length;o>0;o-=1){if(l=a.slice(0,o).join("/"),n=getOwn(s,l),p=getOwn(i,l),p){isArray(p)&&(p=p[0]),a.splice(0,o,p);break}if(n){r=e===n.name?n.location+"/"+n.main:n.location,a.splice(0,o,r);break}}c=a.join("/"),c+=t||(/\?/.test(c)?"":".js"),c=("/"===c.charAt(0)||c.match(/^[\w\+\.\-]+:/)?"":k.baseUrl)+c}return k.urlArgs?c+((-1===c.indexOf("?")?"?":"&")+k.urlArgs):c},load:function(e,t){req.load(x,e,t)},execCb:function(e,t,i,s){return t.apply(s,i)},onScriptLoad:function(e){if("load"===e.type||readyRegExp.test((e.currentTarget||e.srcElement).readyState)){interactiveScript=null;var t=m(e);x.completeLoad(t.id)}},onScriptError:function(e){var t=m(e);return n(t.id)?void 0:c(makeError("scripterror","Script error",e,[t.id]))}},x.require=x.makeRequire(),x}function getInteractiveScript(){return interactiveScript&&"interactive"===interactiveScript.readyState?interactiveScript:(eachReverse(scripts(),function(e){return"interactive"===e.readyState?interactiveScript=e:void 0}),interactiveScript)}var req,s,head,baseElement,dataMain,src,interactiveScript,currentlyAddingScript,mainScript,subPath,version="2.1.4",commentRegExp=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/gm,cjsRequireRegExp=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,jsSuffixRegExp=/\.js$/,currDirRegExp=/^\.\//,op=Object.prototype,ostring=op.toString,hasOwn=op.hasOwnProperty,ap=Array.prototype,apsp=ap.splice,isBrowser="undefined"!=typeof window&&!!navigator&&!!document,isWebWorker=!isBrowser&&"undefined"!=typeof importScripts,readyRegExp=isBrowser&&"PLAYSTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/,defContextName="_",isOpera="undefined"!=typeof opera&&"[object Opera]"==""+opera,contexts={},cfg={},globalDefQueue=[],useInteractive=!1;if(void 0===define){if(requirejs!==void 0){if(isFunction(requirejs))return;cfg=requirejs,requirejs=void 0}require!==void 0&&!isFunction(require)&&(cfg=require,require=void 0),req=requirejs=function(e,t,i,s){var n,r,a=defContextName;return!isArray(e)&&"string"!=typeof e&&(r=e,isArray(t)?(e=t,t=i,i=s):e=[]),r&&r.context&&(a=r.context),n=getOwn(contexts,a),n||(n=contexts[a]=req.s.newContext(a)),r&&n.configure(r),n.require(e,t,i)},req.config=function(e){return req(e)},req.nextTick="undefined"!=typeof setTimeout?function(e){setTimeout(e,4)}:function(e){e()},require||(require=req),req.version=version,req.jsExtRegExp=/^\/|:|\?|\.js$/,req.isBrowser=isBrowser,s=req.s={contexts:contexts,newContext:newContext},req({}),each(["toUrl","undef","defined","specified"],function(e){req[e]=function(){var t=contexts[defContextName];return t.require[e].apply(t,arguments)}}),isBrowser&&(head=s.head=document.getElementsByTagName("head")[0],baseElement=document.getElementsByTagName("base")[0],baseElement&&(head=s.head=baseElement.parentNode)),req.onError=function(e){throw e},req.load=function(e,t,i){var s,n=e&&e.config||{};return isBrowser?(s=n.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script"),s.type=n.scriptType||"text/javascript",s.charset="utf-8",s.async=!0,s.setAttribute("data-requirecontext",e.contextName),s.setAttribute("data-requiremodule",t),!s.attachEvent||s.attachEvent.toString&&0>(""+s.attachEvent).indexOf("[native code")||isOpera?(s.addEventListener("load",e.onScriptLoad,!1),s.addEventListener("error",e.onScriptError,!1)):(useInteractive=!0,s.attachEvent("onreadystatechange",e.onScriptLoad)),s.src=i,currentlyAddingScript=s,baseElement?head.insertBefore(s,baseElement):head.appendChild(s),currentlyAddingScript=null,s):(isWebWorker&&(importScripts(i),e.completeLoad(t)),void 0)},isBrowser&&eachReverse(scripts(),function(e){return head||(head=e.parentNode),dataMain=e.getAttribute("data-main"),dataMain?(cfg.baseUrl||(src=dataMain.split("/"),mainScript=src.pop(),subPath=src.length?src.join("/")+"/":"./",cfg.baseUrl=subPath,dataMain=mainScript),dataMain=dataMain.replace(jsSuffixRegExp,""),cfg.deps=cfg.deps?cfg.deps.concat(dataMain):[dataMain],!0):void 0}),define=function(e,t,i){var s,n;"string"!=typeof e&&(i=t,t=e,e=null),isArray(t)||(i=t,t=[]),!t.length&&isFunction(i)&&i.length&&((""+i).replace(commentRegExp,"").replace(cjsRequireRegExp,function(e,i){t.push(i)}),t=(1===i.length?["require"]:["require","exports","module"]).concat(t)),useInteractive&&(s=currentlyAddingScript||getInteractiveScript(),s&&(e||(e=s.getAttribute("data-requiremodule")),n=contexts[s.getAttribute("data-requirecontext")])),(n?n.defQueue:globalDefQueue).push([e,t,i])},define.amd={jQuery:!0},req.exec=function(text){return eval(text)},req(cfg)}})(this),define("wrap/jquery",[],function(){return jQuery}),define("wrap/modernizr",[],function(){return Modernizr}),function(){function e(){try{return o in r&&r[o]}catch(e){return!1}}function t(e){return function(){var t=Array.prototype.slice.call(arguments,0);t.unshift(s),c.appendChild(s),s.addBehavior("#default#userData"),s.load(o);var i=e.apply(n,t);return c.removeChild(s),i}}function i(e){return e.replace(u,"___")}var s,n={},r=window,a=r.document,o="localStorage",l="__storejs__";if(n.disabled=!1,n.set=function(){},n.get=function(){},n.remove=function(){},n.clear=function(){},n.transact=function(e,t,i){var s=n.get(e);null==i&&(i=t,t=null),s===void 0&&(s=t||{}),i(s),n.set(e,s)},n.setAll=function(){},n.getAll=function(){},n.serialize=function(e){return JSON.stringify(e)},n.deserialize=function(e){if("string"!=typeof e)return void 0;try{return JSON.parse(e)}catch(t){return e||void 0}},e())s=r[o],n.set=function(e,t){return"object"==typeof e?n.setAll(e):void 0===t?n.remove(e):(s.setItem(e,n.serialize(t)),t)},n.get=function(e){return void 0===e?n.getAll():n.deserialize(s.getItem(e))},n.remove=function(e){s.removeItem(e)},n.clear=function(){s.clear()},n.setAll=function(e){for(var t in e)e[t]=n.set(t,e[t])},n.getAll=function(){for(var e={},t=0;s.length>t;++t){var i=s.key(t);e[i]=n.get(i)}return e};else if(a.documentElement.addBehavior){var c,p;try{p=new ActiveXObject("htmlfile"),p.open(),p.write('<script>document.w=window</script><iframe src="/favicon.ico"></frame>'),p.close(),c=p.w.frames[0].document,s=c.createElement("div")}catch(h){s=a.createElement("div"),c=a.body}var u=RegExp("[!\"#$%&'()*+,/\\\\:;<=>?@[\\]^`{|}~]","g");n.set=t(function(e,t,s){return"object"==typeof t?n.setAll(t):(t=i(t),void 0===s?n.remove(t):(e.setAttribute(t,n.serialize(s)),e.save(o),s))}),n.get=t(function(e,t){return void 0===t?n.getAll():(t=i(t),n.deserialize(e.getAttribute(t)))}),n.remove=t(function(e,t){t=i(t),e.removeAttribute(t),e.save(o)}),n.clear=t(function(e){var t=e.XMLDocument.documentElement.attributes;e.load(o);for(var i,s=0;i=t[s];s++)e.removeAttribute(i.name);e.save(o)}),n.setAll=t(function(e,t){for(var i in t)t[i]=n.set(i,t[i]);return t}),n.getAll=t(function(e){var t=e.XMLDocument.documentElement.attributes;e.load(o);for(var i,s={},r=0;i=t[r];++r)s[i]=n.get(i);return s})}try{n.set(l,l),n.get(l)!=l&&(n.disabled=!0),n.remove(l)}catch(h){n.disabled=!0}n.enabled=!n.disabled,"undefined"!=typeof module&&"function"!=typeof module?module.exports=n:"function"==typeof define&&define.amd?define("module/../../../libs/store/store",n):this.store=n}(),define("util/util",["wrap/jquery"],function(e){return{inherit:function(t,i,s){t.prototype=new i,t.prototype.constructor=i,e.each(s,function(e,i){t.prototype[e]=i}),t.prototype._super=function(e,t,s){var n=i.prototype[e];return n.apply(t,s)}},debounce:function(e,t,i){var s;return function(){var n=this,r=arguments,a=function(){i||e.apply(n,r),s=null};s?window.clearTimeout(s):i&&e.apply(n,r),s=setTimeout(a,t||50)}},noop:function(e){e&&(e.preventDefault(),e.stopPropagation())},toPx:function(e){return e?e+"px":"0"}}}),function(){var e=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"],t=/^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im,i=/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im,s=[],n={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g},r=function(e){var t=n,i="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(t.interpolate,function(e,t){return"',"+t.replace(/\\'/g,"'")+",'"}).replace(t.evaluate||null,function(e,t){return"');"+t.replace(/\\'/g,"'").replace(/[\r\n\t]/g," ")+"; __p.push('"}).replace(/\r/g,"").replace(/\n/g,"").replace(/\t/g,"")+"');}return __p.join('');";return i};define("tpl",[],function(){var n,a,o;return"undefined"!=typeof window&&window.navigator&&window.document?a=function(e,t){var i=n.createXhr();i.open("GET",e,!0),i.onreadystatechange=function(){4===i.readyState&&t(i.responseText)},i.send(null)}:"undefined"!=typeof process&&process.versions&&!!process.versions.node&&(o=require.nodeRequire("fs"),a=function(e,t){t(o.readFileSync(e,"utf8"))}),n={version:"0.24.0",strip:function(e){if(e){e=e.replace(t,"");var s=e.match(i);s&&(e=s[1])}else e="";return e},jsEscape:function(e){return e.replace(/(['\\])/g,"\\$1").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"").replace(/[\t]/g,"").replace(/[\r]/g,"")},createXhr:function(){var t,i,s;if("undefined"!=typeof XMLHttpRequest)return new XMLHttpRequest;for(i=0;3>i;i++){s=e[i];try{t=new ActiveXObject(s)}catch(n){}if(t){e=[s];break}}if(!t)throw Error("require.getXhr(): XMLHttpRequest not available");return t},get:a,load:function(e,t,i,a){var o,l=!1,c=e.indexOf("."),p=e.substring(0,c),h=e.substring(c+1,e.length);c=h.indexOf("!"),-1!==c&&(l=h.substring(c+1,h.length),l="strip"===l,h=h.substring(0,c)),o="nameToUrl"in t?t.nameToUrl(p,"."+h):t.toUrl(p+"."+h),n.get(o,function(t){t=r(t),a.isBuild||(t=Function("obj",t)),t=l?n.strip(t):t,a.isBuild&&a.inlineText&&(s[e]=t),i(t)})},write:function(e,t,i){if(t in s){var r=n.jsEscape(s[t]);i("define('"+e+"!"+t+"', function() {return function(obj) { "+r.replace(/(\\')/g,"'").replace(/(\\\\)/g,"\\")+"}});\n")}}}})}(),define("tpl!util/../../templates/stitches.tpl",function(){return function(obj){var __p=[];with(obj||{})__p.push('<div class="stitches"> <!-- .stitches-toolbar --> <div class="stitches-toolbar btn-toolbar"> <div class="btn-group"> <a href="http://draeton.github.io/stitches/" class="btn btn-small btn-link"> <strong>Stitches</strong> </a> <button data-action="open" class="btn btn-small btn-info files" title="Open"> <i class="icon-folder-open icon-white"></i> <span class="hidden-phone">Open</span><input class="file" type="file" multiple="multiple"> </button> <button data-action="settings" class="btn btn-small btn-info" title="Set layout, style prefix, padding, etc."> <i class="icon-cog icon-white"></i> <span class="hidden-phone">Settings</span> </button> <button data-action="clear" class="btn btn-small btn-info disabled" title="Clear sprites from the canvas"> <i class="icon-remove icon-white"></i> <span class="hidden-phone">Clear</span> </button> </div> <div class="btn-group"> <button data-action="downloads" class="btn btn-small btn-success disabled" title="Get the generated sprite sheet and stylesheet"> <i class="icon-download-alt icon-white"></i> <span class="hidden-phone">Downloads</span> </button> </div> <div class="btn-group"> <button data-action="about" class="btn btn-small btn-info" title="About Stitches"> <i class="icon-info-sign icon-white"></i> <span class="hidden-phone">About</span> </button> </div> </div> <!-- /.stitches-toolbar --> <!-- .stitches-progress --> <div class="stitches-progress collapse"> <div class="progress progress-warning"> <div class="bar" style="width: 0%;"></div> </div> </div> <!-- /.stitches-progress --> <!-- .stitches-drop-box --> <div class="stitches-drop-box"> <div class="stitches-overlay"></div> <div class="stitches-wrap"> <!-- .stitches-canvas --> <div class="stitches-canvas"></div> <!-- /.stitches-canvas --> </div> <!-- .stitches-palettes --> <div class="stitches-palettes"> <!-- .stitches-settings --> <div class="stitches-palette stitches-settings fade"> <div class="stitches-palette-header"> <button type="button" class="close" data-action="close" title="Close">&times;</button> <h4>Settings</h4> </div> <div class="stitches-palette-body"> <ul class="nav nav-tabs"> <li class="active"><a href="#general" data-toggle="tab">General</a></li> <li><a href="#import" data-toggle="tab">Import</a></li> </ul> <form class="form-horizontal"> <div class="tab-content"> <div class="tab-pane active" id="general"> <div class="control-group hide"> <label class="control-label">Position</label> <div class="controls"> <label class="checkbox"> <input name="position" type="checkbox" value="auto"/> Auto </label> </div> </div> <div class="control-group"> <label class="control-label">Layout</label> <div class="controls"> <label class="radio inline"> <input name="layout" type="radio" value="compact"/> Compact </label> <label class="radio inline"> <input name="layout" type="radio" value="vertical"/> Vertical </label> <label class="radio inline"> <input name="layout" type="radio" value="horizontal"/> Horizontal </label> </div> </div> <div class="control-group"> <label class="control-label">CSS/LESS</label> <div class="controls"> <label class="radio inline"> <input name="stylesheet" type="radio" value="css"/> CSS </label> <label class="radio inline"> <input name="stylesheet" type="radio" value="less"/> LESS </label> </div> </div> <div class="control-group"> <label class="control-label">Style prefix</label> <div class="controls"> <input name="prefix" type="text" placeholder="Style class prefix&hellip;"> </div> </div> <div class="control-group"> <label class="control-label">Padding</label> <div class="controls"> <div class="input-append"> <input name="padding" type="number" min="0" required placeholder="Sprite padding&hellip;"> <span class="add-on">px</span> </div> </div> </div> <div class="control-group"> <label class="control-label">Data URI</label> <div class="controls"> <label class="checkbox"> <input name="uri" type="checkbox" value="true"/> Include encoded image in CSS </label> </div> </div> </div> <div class="tab-pane" id="import"> <div class="control-group"> <label class="control-label">Paste import here</label> <div class="controls"> <textarea name="import" rows="10"></textarea> </div> </div> </div> </div> </form> </div> <div class="stitches-palette-footer"> <div class="btn-toolbar"> <div class="btn-group"> <a href="#" class="downloads-export btn btn-small btn-success" download="stitches"><i class="icon-download-alt icon-white"></i> Export</a> </div> <div class="btn-group"> <button class="btn btn-small btn-info" data-action="close" title="Save"><span>Save</span></button> <button class="btn btn-small btn-info" data-action="close" title="Close"><span>Close</span></button> </div> </div> </div> </div> <!-- /.stitches-settings --> <!-- .stitches-properties --> <div class="stitches-palette stitches-properties fade"> <div class="stitches-palette-header"> <button type="button" class="close" data-action="close" title="Close">&times;</button> <h4>Sprite Properties</h4> </div> <div class="stitches-palette-body"> <form class="form-horizontal"> <div class="control-group"> <label class="control-label">Name</label> <div class="controls"> <input name="name" type="text" required placeholder="Sprite name&hellip;"> </div> </div> <div class="control-group"> <label class="control-label">Coordinates (x, y)</label> <div class="controls"> <div class="input-append"> <input name="x" required disabled placeholder="From left&hellip;" class="input-mini"> <span class="add-on">px</span> </div> <div class="input-append"> <input name="y" required disabled placeholder="From top&hellip;" class="input-mini"> <span class="add-on">px</span> </div> </div> </div> </form> </div> <div class="stitches-palette-footer"> <div class="btn-toolbar"> <div class="btn-group"> <button class="btn btn-small btn-danger" data-action="remove" title="Delete"><span>Delete</span></button> <button class="btn btn-small btn-info" data-action="close" title="Save"><span>Save</span></button> <button class="btn btn-small btn-info" data-action="close" title="Close"><span>Close</span></button> </div> </div> </div> </div> <!-- /.stitches-properties --> <!-- .stitches-about --> <div class="stitches-palette stitches-about fade in"> <div class="stitches-palette-header"> <button type="button" class="close" data-action="close" title="Close">&times;</button> <h4>About Stitches</h4> </div> <div class="stitches-palette-body"> <p><a href="http://draeton.github.io/stitches/">Stitches<a/> is an HTML5 <a href="http://en.wikipedia.org/wiki/Sprite_(computer_graphics)#Sprites_by_CSS">sprite sheet</a> generator.</p> <p>Drag &amp; drop image files onto the space below, or use the &ldquo;Open&rdquo; link to load images using the file browser. Then, click &ldquo;Generate&rdquo; to create a sprite sheet and stylesheet. <em>This demo uses a couple of HTML5 APIs, and it is only currently compatible with WebKit and Firefox browsers.</em></p> <p>Stitches is developed by <a href="http://draeton.github.io">Matthew Cobbs</a> in concert with the lovely open-source community at <a href="http://github.io">Github</a>. Thanks are owed to the developers at Twitter for <a href="http://twitter.github.io/bootstrap">Bootstrap</a>, and <a href="http://glyphicons.com/">Glyphicons</a> for some cool little icons.</p> <p class="text-right"><small>Copyright &copy; 2013 Matthew Cobbs<br/> Licensed under the MIT license.</small></p> </div> <div class="stitches-palette-footer"> <div class="btn-toolbar"> <div class="btn-group"> <button class="btn btn-small btn-info" data-action="close" title="Close"><span>Close</span></button> </div> </div> </div> </div> <!-- /.stitches-about --> <!-- .stitches-downloads --> <div class="stitches-palette stitches-downloads fade"> <div class="stitches-palette-header"> <button type="button" class="close" data-action="close" title="Close">&times;</button> <h4>Downloads</h4> </div> <div class="stitches-palette-body"> <section></section> </div> <div class="stitches-palette-footer"> <div class="btn-toolbar"> <div class="btn-group"> <a href="#" class="downloads-spritesheet btn btn-small btn-success" download="spritesheet"><i class="icon-download-alt icon-white"></i> Spritesheet</a> <a href="#" class="downloads-stylesheet btn btn-small btn-success" download="stylesheet"><i class="icon-download-alt icon-white"></i> Stylesheet</a> <button class="btn btn-small btn-info" data-action="close" title="Close"><span>Close</span></button> </div> </div> </div> </div> <!-- /.stitches-downloads --> </div> <!-- /.stitches-palettes --> </div> <!-- /.stitches-drop-box --></div>');
-return __p.join("")}}),define("tpl!util/../../templates/downloads.tpl",function(){return function(obj){var __p=[];with(obj||{})__p.push('<ul class="nav nav-tabs"> <li class="active"><a href="#spritesheet" data-toggle="tab">PNG</a></li> <li><a href="#stylesheet" data-toggle="tab">',stylesheetType.toUpperCase(),'</a></li> <li><a href="#markup" data-toggle="tab">HTML</a></li> <li><a href="#example" data-toggle="tab"><strong>Example</strong></a></li></ul><div class="tab-content"> <div class="tab-pane active" id="spritesheet"> <p><img src="',spritesheet,'" class="thumbnail"/></p> </div> <div class="tab-pane" id="stylesheet"> <p><textarea rows="',stylesheetLines,'">',stylesheet,'</textarea></p> </div> <div class="tab-pane" id="markup"> <p><textarea rows="',markupLines,'">',markup,'</textarea></p> </div> <div class="tab-pane stitches-example" id="example"> <style type="text/',stylesheetType,'">',stylesheetWithUri,"</style> <div>",markupTooltip,'</div> <script src="//cdnjs.cloudflare.com/ajax/libs/less.js/1.3.3/less.min.js"></script> </div></div>');return __p.join("")}}),define("tpl!util/../../templates/sprite.tpl",function(){return function(obj){var __p=[];with(obj||{})__p.push('<div class="stitches-sprite" style="top: ',y,"px; left: ",x,'px;"> <img src="',image.src,'"/></div>');return __p.join("")}}),define("tpl!util/../../templates/css.tpl",function(){return function(obj){var __p=[];with(obj||{})__p.push(".",prefix," {\\nbackground-image: url(",backgroundImage,");\\nbackground-repeat: no-repeat;\\ndisplay: block;\\n}\\n"),$.map(sprites,function(e){__p.push("\\n.",prefix,"-",e.name," {\\nwidth: ",e.image.width,"px;\\nheight: ",e.image.height,"px;\\nbackground-position: ",e.left(!0)," ",e.top(!0),";\\n}\\n")}),__p.push("");return __p.join("")}}),define("tpl!util/../../templates/css-markup.tpl",function(){return function(obj){var __p=[];with(obj||{})__p.push(""),$.map(sprites,function(e){__p.push(""),tooltip?__p.push('<i class="',prefix," ",prefix,"-",e.name,'" data-toggle="tooltip" title=".',prefix,".",prefix,"-",e.name,'"></i>\\n'):__p.push('<i class="',prefix," ",prefix,"-",e.name,'"></i>\\n'),__p.push("")}),__p.push("");return __p.join("")}}),define("tpl!util/../../templates/less.tpl",function(){return function(obj){var __p=[];with(obj||{})__p.push(".stitches-",prefix,"(@x: 0, @y: 0, @width: 0, @height: 0) {\\nbackground-position: @x @y;\\nwidth: @width;\\nheight: @height;\\n}\\n\\n.",prefix," {\\nbackground-image: url(",backgroundImage,");background-repeat: no-repeat;\\ndisplay: block;\\n"),$.map(sprites,function(e){__p.push("\\n&.",prefix,"-",e.name," {\\n.stitches-",prefix,"(",e.left(!0),", ",e.top(!0),", ",e.image.width,"px, ",e.image.height,"px);\\n}\\n")}),__p.push("}\\n");return __p.join("")}}),define("tpl!util/../../templates/less-markup.tpl",function(){return function(obj){var __p=[];with(obj||{})__p.push(""),$.map(sprites,function(e){__p.push(""),tooltip?__p.push('<i class="',prefix," ",prefix,"-",e.name,'" data-toggle="tooltip" title=".',prefix,".",prefix,"-",e.name,'"></i>'):__p.push('<i class="',prefix," ",prefix,"-",e.name,'"></i>\\n'),__p.push("")}),__p.push("");return __p.join("")}}),define("util/templates",["tpl!../../templates/stitches.tpl","tpl!../../templates/downloads.tpl","tpl!../../templates/sprite.tpl","tpl!../../templates/css.tpl","tpl!../../templates/css-markup.tpl","tpl!../../templates/less.tpl","tpl!../../templates/less-markup.tpl"],function(e,t,i,s,n,r,a){return{stitches:function(){return e.apply(this,arguments)},downloads:function(){return t.apply(this,arguments)},sprite:function(){return i.apply(this,arguments)},css:function(){return s.apply(this,arguments)},cssMarkup:function(){return n.apply(this,arguments)},less:function(){return r.apply(this,arguments)},lessMarkup:function(){return a.apply(this,arguments)}}}),define("manager/file",["wrap/jquery","util/util"],function(e,t){return{total:0,processed:0,queue:[],set:function(e){e=e||{},this.onload=e.onload||t.noop,this.onprogress=e.onprogress||t.noop,this.onerror=e.onerror||t.noop},processFiles:function(t){var i=this;this.total=t.length,this.processed=0,this.queue=[],e.map(t,function(e){/jpeg|png|gif/.test(e.type)&&i.processFile(e)}),this.onprogress(0,"info")},processFile:function(e){var t,i=this;try{t=new FileReader,t.onloadend=function(t){var s=e.name,n=t.target.result,r=++i.processed/i.total;i.onprogress(r),i.queue.push([s,n]),i.queue.length===i.total&&i.processQueue()},t.readAsDataURL(e)}catch(s){this.onerror(s)}},processQueue:function(){var t=this;e.map(this.queue,function(e){t.onload.apply(t,e)})}}}),define("layout/base",["wrap/jquery"],function(e){var t={maxPass:2},i=function(i){this.settings=e.extend({},t,i)};return i.prototype={constructor:i,getDimensions:function(){},placeSprite:function(){},intersection:function(t,i){var s,n,r,a,o,l=[];return e.map(i,function(e){s=e.x<t.x+t.width,r=e.y<t.y+t.height,n=e.x+e.width>t.x,a=e.y+e.height>t.y,s&&n&&r&&a&&l.push(e)}),l.length&&(o=l.pop()),o}},i}),define("layout/compact",["wrap/jquery","util/util","layout/base"],function(e,t,i){var s={maxPass:2},n=function(t){this.settings=e.extend({},s,t)};return t.inherit(n,i,{getDimensions:function(t,i){var s=0,n=0,r=0,a=0;return e.map(t,function(e){s=e.width>s?e.width:s,n=e.height>n?e.height:n,r+=e.area}),a=Math.ceil(Math.sqrt(r)),s=s>a?s:a,n=n>a?n:a,{width:s||i.width,height:n||i.height}},placeSprite:function(e,t,i){for(var s,n=0,r=0,a=0;n++<this.settings.maxPass;){for(a=0;i.height-e.height>=a;a++){for(r=0;i.width-e.width>=r;r++){if(e.x=r,e.y=a,s=this.intersection(e,t),!s)return t.push(e),e.show(),!0;r=s.x+s.width-1}a=s.y+s.height-1}i.width+=e.width,i.height+=e.height}}}),n}),define("layout/vertical",["wrap/jquery","util/util","layout/base"],function(e,t,i){var s={maxPass:2},n=function(t){this.settings=e.extend({},s,t)};return t.inherit(n,i,{getDimensions:function(t,i){var s=0,n=0;return e.map(t,function(e){s=e.width>s?e.width:s,n+=e.height}),{width:s||i.width,height:n||i.height}},placeSprite:function(e,t,i){for(var s,n=0,r=0,a=0;n++<this.settings.maxPass;){for(a=0;i.height-e.height>=a;a++){if(e.x=r,e.y=a,s=this.intersection(e,t),!s)return t.push(e),e.show(),!0;a=s.y+s.height-1}i.width+=e.width,i.height+=e.height}return!1}}),n}),define("layout/horizontal",["wrap/jquery","util/util","layout/base"],function(e,t,i){var s={maxPass:2},n=function(t){this.settings=e.extend({},s,t)};return t.inherit(n,i,{getDimensions:function(t,i){var s=0,n=0;return e.map(t,function(e){n=e.height>n?e.height:n,s+=e.width}),{width:s||i.width,height:n||i.height}},placeSprite:function(e,t,i){for(var s,n=0,r=0,a=0;n++<this.settings.maxPass;){for(r=0;i.width-e.width>=r;r++){if(e.x=r,e.y=a,s=this.intersection(e,t),!s)return t.push(e),e.show(),!0;r=s.x+s.width-1}i.width+=e.width,i.height+=e.height}return!1}}),n}),define("manager/layout",["wrap/jquery","layout/compact","layout/vertical","layout/horizontal"],function(e,t,i,s){var n={compact:t,vertical:i,horizontal:s};return{set:function(e){var t=n[e]||n.compact;this.manager=new t},getDimensions:function(e,t){return this.manager.getDimensions(e,t)},placeSprites:function(t,i,s,n){var r=this;n(0,"info"),e.map(t,function(e){e.placed||(e.placed=r.manager.placeSprite(e,i,s)),n(i.length/t.length)}),t=e.map(t,function(e){return e.placed?null:e})},trim:function(t,i){var s=0,n=0;e.map(t,function(e){s=s>e.x+e.width?s:e.x+e.width,n=n>e.y+e.height?n:e.y+e.height}),i.width=s||i.width,i.height=n||i.height},getSpritesheet:function(t){var i,s,n,r=t.sprites,a=t.dimensions;i=document.createElement("canvas"),i.width=a.width,i.height=a.height;try{s=i.getContext("2d"),e.map(r,function(e){var t=e.left(),i=e.top();s.drawImage(e.image,t,i)}),n=i.toDataURL("image/png")}catch(o){this.$element.trigger("error",[o])}return n}}}),define("stylesheet/base",["wrap/jquery"],function(e){var t={filename:"spritesheet.png"},i=function(i){this.settings=e.extend({},t,i)};return i.prototype={constructor:i,template:null,get:function(){},markup:function(e,t,i){return this.template({prefix:t,sprites:e,tooltip:i})}},i}),define("stylesheet/css",["wrap/jquery","util/util","util/templates","stylesheet/base"],function(e,t,i,s){var n={filename:"spritesheet.png"},r=function(t){this.settings=e.extend({},n,t)};return t.inherit(r,s,{template:i.cssMarkup,get:function(e,t,s,n){var r=n?t:this.settings.filename;return i.css({prefix:s,backgroundImage:r,sprites:e})}}),r}),define("stylesheet/less",["wrap/jquery","util/util","util/templates","stylesheet/base"],function(e,t,i,s){var n={filename:"spritesheet.png"},r=function(t){this.settings=e.extend({},n,t)};return t.inherit(r,s,{template:i.lessMarkup,get:function(e,t,s,n){var r=n?t:this.settings.filename;return i.less({prefix:s,backgroundImage:r,sprites:e})}}),r}),define("manager/stylesheet",["wrap/jquery","stylesheet/css","stylesheet/less"],function(e,t,i){var s={css:t,less:i};return{set:function(e){var t;this.type=e||"css",t=s[this.type],this.manager=new t},getStylesheet:function(e){var t=e.sprites,i=e.spritesheet,s=e.prefix,n=e.uri,r=this.manager.get(t,i,s,n);return r=r.replace(/\\n/g,"\n")},getMarkup:function(e){var t=e.sprites,i=e.prefix,s=e.tooltip||!1,n=this.manager.markup(t,i,s);return n=n.replace(/\\n/g,"\n")}}}),define("module/drop-box",["wrap/jquery","util/util"],function(e,t){var i={},s=function(t,s){this.$element=e(t),this.$overlay=this.$element.find(".stitches-overlay"),this.settings=e.extend({},i,s),this.init()};return s.classname=".stitches-drop-box",s.prototype={constructor:s,init:function(){this.bind()},bind:function(){var i=this.$element.get(0),s=this.$overlay.get(0);i.addEventListener("dragenter",e.proxy(this.dragStart,this),!1),s.addEventListener("dragleave",e.proxy(this.dragStop,this),!1),s.addEventListener("dragexit",e.proxy(this.dragStop,this),!1),s.addEventListener("dragover",t.noop,!1),s.addEventListener("drop",e.proxy(this.drop,this),!1)},dragStart:function(){this.$element.trigger("close-palettes"),this.$element.trigger("show-overlay")},dragStop:function(t){e.contains(this.$element,t.target)&&this.$element.trigger("hide-overlay")},drop:function(e){var t=e.files||e.dataTransfer.files;e.stopPropagation(),e.preventDefault(),t.length?this.$element.trigger("process-files",[t]):this.$element.trigger("hide-overlay")}},s}),define("util/array",["wrap/jquery"],function(e){return{remove:function(t,i){return e(t).filter(function(){return this!==i})}}}),define("module/sprite",["wrap/jquery","util/util","util/templates"],function(e,t,i){var s={name:"",src:"",padding:0},n=function(i,n){this.settings=e.extend({},s,i),this.$element=null,this.name=this.cleanName(this.settings.name),this.src=this.settings.src,this.padding=parseInt(this.settings.padding,10),this.active=!1,this.placed=!1,this.onload=n.onload||t.noop,this.init()};return n.classname=".stitches-sprite",n.prototype={constructor:n,init:function(){this.load()},load:function(){var e=this;this.image=new Image,this.image.onload=function(){e.x=0,e.y=0,e.width=e.image.width+2*e.padding,e.height=e.image.height+2*e.padding,e.area=e.width*e.height,e.render(),e.bind(),e.toDataURL(),e.onload(e)},this.image.src=this.src},render:function(){var t=i.sprite(this);this.$element=e(t),this.$element.data("sprite",this)},bind:function(){this.$element.on("click",e.proxy(this.click,this))},toDataURL:function(){var e,t,i;e=document.createElement("canvas"),e.width=this.image.width,e.height=this.image.height;try{t=e.getContext("2d"),t.drawImage(this.image,0,0),i=e.toDataURL("image/png")}catch(s){this.$element.trigger("error",[s])}this.src=i},reset:function(){this.x=0,this.y=0,this.placed=!1,this.$element.removeClass("placed")},show:function(){this.$element.css({left:this.x+"px",top:this.y+"px",padding:this.padding+"px"}).addClass("placed")},click:function(){var e=!this.active;e?(this.$element.trigger("clear-active",[this]),this.$element.trigger("open-properties",[this])):this.$element.trigger("close-properties"),this.active=e,this.$element.toggleClass("active",e)},configure:function(e){e.padding&&(this.padding=parseInt(e.padding,10),this.width=this.image.width+2*this.padding,this.height=this.image.height+2*this.padding,this.area=this.width*this.height)},cleanName:function(e){return e=e.replace(/\.\w+$/i,""),e=e.replace(/[\s.]+/gi,"-"),e=e.replace(/[^a-z0-9\-]/gi,"_")},left:function(e){var i=this.x+this.padding;return e?t.toPx(-i):i},top:function(e){var i=this.y+this.padding;return e?t.toPx(-i):i},toJSON:function(){return{name:this.name,src:this.src}}},n}),define("module/canvas",["wrap/jquery","util/util","util/array","manager/layout","module/sprite"],function(e,t,i,s,n){var r={images:null,dimensions:{width:400,height:400}},a=function(i,s,n){this.$element=e(i),this.settings=e.extend({},r,s),this.images=this.settings.images,this.dimensions=this.settings.dimensions,this.sprites=[],this.names=[],this.onprogress=n.onprogress||t.noop};return a.classname=".stitches-canvas",a.prototype={constructor:a,init:function(){this.reset=t.debounce(this.reset,500),this.bind(),this.setup(),this.reset()},bind:function(){this.$element.on("clear-active",e.proxy(this.clearActive,this))},setup:function(){var t=this;e(this.images).each(function(){var i=e(this),s=i.data("name"),n=i.attr("src");t.createSprite(s,n)}).remove()},reset:function(){this.$element.trigger("show-overlay"),this.measure(this.sprites),this.place(this.sprites),this.cut(this.sprites),this.$element.trigger("generate-sheets"),this.$element.trigger("hide-overlay")},measure:function(e){this.dimensions=s.getDimensions(e,this.settings.dimensions)},place:function(t){var i=[];e.map(t,function(e){e.reset()}),t=t.sort(function(e,t){return e.name===t.name?0:e.name>t.name?1:-1}),s.placeSprites(t,i,this.dimensions,this.onprogress)},cut:function(e){s.trim(e,this.dimensions),this.$element.css({width:this.dimensions.width+"px",height:this.dimensions.height+"px"})},add:function(e){this.sprites.push(e),this.names.push(e.name),this.$element.trigger("show-overlay"),e.$element.appendTo(this.$element),this.$element.trigger("update-toolbar"),this.reset()},remove:function(e){this.sprites=i.remove(this.sprites,e),this.names=i.remove(this.names,e.name),this.$element.trigger("show-overlay"),e.$element.fadeOut("fast").remove(),this.$element.trigger("update-toolbar"),this.$element.trigger("close-properties"),this.reset()},clear:function(){this.empty(),this.$element.trigger("show-overlay"),this.$element.trigger("update-toolbar"),this.$element.trigger("close-properties"),this.$element.trigger("open-settings"),this.reset()},empty:function(){this.sprites=[],this.names=[],this.$element.empty()},createSprite:function(e,t){var i=this;new n({name:e,src:t,padding:this.settings.padding},{onload:function(e){i.add(e)}})},clearActive:function(t,i){this.$element.find(".active").each(function(){var t=e(this),s=t.data("sprite");i&&s!==i&&(t.removeClass("active"),s.active=!1)})},toJSON:function(){return{sprites:this.sprites}}},a}),define("module/toolbar",["wrap/jquery"],function(e){var t={name:"",actions:{}},i=function(i,s){this.$element=e(i),this.settings=e.extend({},t,s),this.name=this.settings.name,this.actions=this.settings.actions,this.init()};return i.classname=".stitches-toolbar",i.prototype={constructor:i,init:function(){this.bind()},bind:function(){var t=this;e.each(this.actions,function(i,s){e.each(s,function(e,s){var n="[data-action="+i+"]",r=t.getHandler(t,s);"instance"===i?t.$element.on(e,t.getHandler(t,r)):t.$element.on(e,n,r)})})},getHandler:function(t,i){return function(s){var n=e(s.currentTarget);n.is(".disabled")?(s.stopPropagation(),s.preventDefault()):i.apply(t,arguments)}},toggleActions:function(t,i){var s=this;"string"==typeof t&&(t=t.split(" ")),e.map(t,function(e){var t=s.$element.find("[data-action="+e+"]");t.toggleClass("disabled",i)})},enable:function(e){this.toggleActions(e,!1)},disable:function(e){this.toggleActions(e,!0)}},i}),define("module/palette",["wrap/jquery","util/util","module/toolbar"],function(e,t,i){var s={name:"",visible:!1,actions:{},fields:{}},n=function(t,i){this.$element=e(t),this.settings=e.extend({},s,i),this.name=this.settings.name,this.visible=this.settings.visible,this.actions=this.settings.actions,this.fields=this.settings.fields,this.source=null,this.init()};return n.classname=".stitches-palette",t.inherit(n,i,{init:function(){this._super("init",this,arguments),this.$element.toggleClass("in",this.visible)},bind:function(){var t=this;this._super("bind",this,arguments),e.each(this.fields,function(i,s){e.each(s,function(e,s){var n="[name="+i+"]",r=t.getHandler(t,s);t.$element.on(e,n,r)})})},open:function(){this.$element.addClass("in"),this.visible=!0},close:function(){this.$element.removeClass("in"),this.visible=!1},configure:function(t){var i=this;this.source=t.source,e.each(t.inputs,function(e,t){var s="[name="+e+"]",n=i.$element.find(s),r=n.attr("type");switch(r){case"radio":case"checkbox":n=n.removeAttr("checked").filter("[value="+t+"]"),n.attr("checked","checked");break;default:n.val(t)}})}}),n}),define("module/stitches",["wrap/jquery","wrap/modernizr","../../../libs/store/store","util/util","util/templates","manager/file","manager/layout","manager/stylesheet","module/drop-box","module/canvas","module/toolbar","module/palette"],function(e,t,i,s,n,r,a,o,l,c,p,h){var u={layout:"compact",prefix:"sprite",padding:5,uri:!1,stylesheet:"css"},d=function(t,i){this.$element=e(t),this.settings=e.extend({},u,i),this.init()};return d.prototype={constructor:d,init:function(){this.configure(),this.render(),this.test(),this.bind(),this.setDropBox(),this.setToolbar(),this.setImages(),this.setCanvas(),this.setManagers(),this.setPalettes(),this.canvas.init()},configure:function(){var t;i&&!i.disabled&&(t=i.get("stitches-settings")),t&&(this.settings=e.extend(this.settings,t))},render:function(){var e=n.stitches({});this.$element.append(e),this.$overlay=this.$element.find(".stitches-overlay"),this.$dropBox=this.$element.find(".stitches-drop-box"),this.$toolbar=this.$element.find(".stitches-toolbar"),this.$canvas=this.$element.find(".stitches-canvas"),this.$progress=this.$element.find(".stitches-progress .progress"),this.$progressBar=this.$element.find(".stitches-progress .bar"),this.$about=this.$element.find(".stitches-about"),this.$downloads=this.$element.find(".stitches-downloads"),this.$settings=this.$element.find(".stitches-settings"),this.$properties=this.$element.find(".stitches-properties")},test:function(){this.hasFileInput=this.$element.find("input.file").length},bind:function(){this.$element.on("show-overlay",e.proxy(this.showOverlay,this)),this.$element.on("hide-overlay",e.proxy(this.hideOverlay,this)),this.$element.on("open-about",e.proxy(this.openAbout,this)),this.$element.on("close-about",e.proxy(this.closeAbout,this)),this.$element.on("open-downloads",e.proxy(this.openDownloads,this)),this.$element.on("close-downloads",e.proxy(this.closeDownloads,this)),this.$element.on("open-settings",e.proxy(this.openSettings,this)),this.$element.on("close-settings",e.proxy(this.closeSettings,this)),this.$element.on("open-properties",e.proxy(this.openProperties,this)),this.$element.on("close-properties",e.proxy(this.closeProperties,this)),this.$element.on("close-palettes",e.proxy(this.closePalettes,this)),this.$element.on("process-files",e.proxy(this.processFiles,this)),this.$element.on("update-toolbar",e.proxy(this.updateToolbar,this)),this.$element.on("update-settings",e.proxy(this.updateSettingsPalette,this)),this.$element.on("update-downloads",e.proxy(this.updateDownloadsPalette,this)),this.$element.on("generate-sheets",e.proxy(this.generateSheets,this)),this.$element.on("error",e.proxy(this.errorHandler,this))},setDropBox:function(){this.dropBox=new l(this.$dropBox)},setManagers:function(){r.set({onload:e.proxy(this.canvas.createSprite,this.canvas),onprogress:e.proxy(this.updateProgress,this)}),a.set(this.settings.layout),o.set(this.settings.stylesheet)},setImages:function(){this.images=this.$element.find("> img").get()},setCanvas:function(){this.canvas=new c(this.$canvas,{images:this.images,padding:this.settings.padding},{onprogress:e.proxy(this.updateProgress,this)})},setToolbar:function(){var e=this;this.toolbar=new p(this.$toolbar,{name:"toolbar",actions:{open:{change:function(t){var i=e.$toolbar.find("input[type=file]"),s=i.clone(!0).val(""),n=t.target.files;e.$element.trigger("process-files",[n]),i.replaceWith(s)}},settings:{click:function(){e.$element.trigger("open-settings")}},reset:{click:function(){e.canvas.reset()}},clear:{click:function(){e.canvas.clear()}},downloads:{click:function(){e.$element.trigger("open-downloads")}},about:{click:function(){e.$element.trigger("open-about")}}}})},setPalettes:function(){var t=this,i=new h(this.$about,{name:"about",visible:!0,actions:{close:{click:function(){this.close()}}}}),s=new h(this.$downloads,{name:"downloads",visible:!1,actions:{close:{click:function(){this.close()}}}}),n=new h(this.$settings,{name:"settings",visible:!1,actions:{close:{click:function(){t.$element.trigger("close-settings")}}},fields:{layout:{change:function(){var e=this.$element.find("input[name=layout]:checked"),i=e.val();this.source.layout=i,a.set(i),t.updateSettings()}},stylesheet:{change:function(){var e=this.$element.find("input[name=stylesheet]:checked"),i=e.val();t.settings.stylesheet=i,o.set(i),t.updateSettings()}},prefix:{"input blur":function(i){var s=e(i.currentTarget).val();this.source.prefix=s,t.updateSettings()}},padding:{"input blur":function(i){var s=e(i.currentTarget).val();this.source.padding=s,t.canvas.padding=s,e.map(t.canvas.sprites,function(e){e.configure({padding:s})}),t.updateSettings()}},uri:{change:function(i){var s=e(i.currentTarget).is(":checked");this.source.uri=s,t.updateSettings()}},"import":{blur:function(i){var s,n=e(i.currentTarget),r=n.parents(".control-group"),a=n.val();if(r.removeClass("error"),a)try{s=JSON.parse(a),t.importData(s)}catch(o){r.addClass("error"),t.$element.trigger("error",[o])}else t.updateProgress(1,"success")}}}}),r=new h(this.$properties,{name:"properties",visible:!1,actions:{close:{click:function(){t.$element.trigger("close-properties")}},remove:{click:function(){var e=this.source;t.canvas.remove(e)}}},fields:{name:{"input blur":function(t){var i=e(t.currentTarget),s=this.source,n=i.val(),r=s.cleanName(n);this.source.name=r,n!==r&&i.val(r)}}}});this.palettes={about:i,downloads:s,settings:n,properties:r}},updateSettings:function(){this.showOverlay(),this.canvas.reset(),i&&!i.disabled&&i.set("stitches-settings",this.settings)},showOverlay:function(){this.$overlay.fadeTo("fast",.4)},hideOverlay:function(){this.$overlay.fadeOut("fast")},openAbout:function(){this.closePalettes(),this.palettes.about.open()},closeAbout:function(){this.palettes.about.visible&&this.palettes.about.close()},openDownloads:function(){this.closePalettes(),this.palettes.downloads.open()},closeDownloads:function(){this.palettes.downloads.visible&&this.palettes.downloads.close()},openSettings:function(){this.closePalettes(),this.palettes.settings.configure({source:this.settings,inputs:{layout:this.settings.layout,stylesheet:this.settings.stylesheet,prefix:this.settings.prefix,padding:this.settings.padding,uri:this.settings.uri}}),this.palettes.settings.open()},closeSettings:function(){var e=this.$settings.find("ul.nav-tabs"),t=e.find("li:first-child a"),i=this.$settings.find(":input[name=import]"),s=i.parents(".control-group");t.click(),i.val(""),s.removeClass("error"),this.palettes.settings.visible&&this.palettes.settings.close()},openProperties:function(e,t){this.closePalettes(),this.palettes.properties.configure({source:t,inputs:{name:t.name,x:t.left(),y:t.top()}}),this.palettes.properties.open()},closeProperties:function(){this.palettes.properties.visible&&(this.palettes.properties.close(),this.canvas.$element.trigger("clear-active",[!0]))},closePalettes:function(){this.closeAbout(),this.closeDownloads(),this.closeSettings(),this.closeProperties()},processFiles:function(e,t){r.processFiles(t)},updateToolbar:function(){var e=this.toolbar,t=this.canvas;t.sprites.length?e.enable("reset clear downloads"):e.disable("reset clear downloads"),this.hasFileInput?e.enable("open"):e.disable("open")},updateSettingsPalette:function(){var e=this.$settings.find(".downloads-export");e.attr({href:"data:text/plain,"+encodeURIComponent(JSON.stringify(this)),target:"_blank"})},updateDownloadsPalette:function(){var t=this.$downloads.find("section"),i=this.$downloads.find(".downloads-spritesheet"),s=this.$downloads.find(".downloads-stylesheet"),r=n.downloads({prefix:this.settings.prefix,spritesheet:this.spritesheet,stylesheet:this.stylesheet,stylesheetWithUri:this.stylesheetWithUri,stylesheetType:o.type,stylesheetLines:this.stylesheet.split("\n").length,markup:this.markup,markupLines:this.markup.split("\n").length,markupTooltip:this.markupTooltip});t.html(r),i.attr({href:this.spritesheet,target:"_blank"}),s.attr({href:"data:text/plain,"+encodeURIComponent(this.stylesheet),target:"_blank"}),e.fn.tooltip&&t.find("[data-toggle=tooltip]").tooltip()},updateProgress:function(e,t){var i=Math.ceil(100*e);100===i&&"danger"!==t&&"warning"!==t&&(t="success"),t&&this.$progress.attr({"class":"progress progress-"+t}),this.$progressBar.css({width:i+"%"})},generateSheets:function(){this.spritesheet=a.getSpritesheet({sprites:this.canvas.sprites,dimensions:this.canvas.dimensions}),this.stylesheetWithUri=o.getStylesheet({sprites:this.canvas.sprites,spritesheet:this.spritesheet,prefix:this.settings.prefix,uri:!0}),this.markup=o.getMarkup({sprites:this.canvas.sprites,prefix:this.settings.prefix}),this.markupTooltip=o.getMarkup({sprites:this.canvas.sprites,prefix:this.settings.prefix,tooltip:!0}),this.stylesheet=this.settings.uri?this.stylesheetWithUri:o.getStylesheet({sprites:this.canvas.sprites,spritesheet:this.spritesheet,prefix:this.settings.prefix,uri:this.settings.uri}),this.$element.trigger("update-toolbar"),this.$element.trigger("update-settings"),this.$element.trigger("update-downloads"),this.updateProgress(1,"success")},errorHandler:function(e,t,i){this.updateProgress(1,i||"warning")},toJSON:function(){return{settings:this.settings,canvas:this.canvas.toJSON()}},importData:function(t){var i=this,s=t.settings||{},n=t.canvas||{},r=n.sprites||[];this.settings=e.extend({},u,s),a.set(this.settings.layout),o.set(this.settings.stylesheet),this.updateSettings(),this.canvas.clear(),this.canvas.settings.padding=this.settings.padding,e.map(r,function(e){i.canvas.createSprite(e.name,e.src)}),this.updateProgress(1,"success")}},d}),require({paths:{tpl:"../tpl"}},["wrap/jquery","module/stitches"],function(e,t){e(document).ready(function(){var i=".stitches";e(i).each(function(){new t(this)})})}),define("stitches",function(){});
+return __p.join("")}}),define("tpl!util/../../templates/downloads.tpl",function(){return function(obj){var __p=[];with(obj||{})__p.push('<ul class="nav nav-tabs"> <li class="active"><a href="#spritesheet" data-toggle="tab">PNG</a></li> <li><a href="#stylesheet" data-toggle="tab">',stylesheetType.toUpperCase(),'</a></li> <li><a href="#markup" data-toggle="tab">HTML</a></li> <li><a href="#example" data-toggle="tab"><strong>Example</strong></a></li></ul><div class="tab-content"> <div class="tab-pane active" id="spritesheet"> <p><img src="',spritesheet,'" class="thumbnail"/></p> </div> <div class="tab-pane" id="stylesheet"> <p><textarea rows="',stylesheetLines,'">',stylesheet,'</textarea></p> </div> <div class="tab-pane" id="markup"> <p><textarea rows="',markupLines,'">',markup,'</textarea></p> </div> <div class="tab-pane stitches-example" id="example"> <style type="text/',stylesheetType,'">',stylesheetWithUri,"</style> <div>",markupTooltip,'</div> <script src="//cdnjs.cloudflare.com/ajax/libs/less.js/1.3.3/less.min.js"></script> </div></div>');return __p.join("")}}),define("tpl!util/../../templates/sprite.tpl",function(){return function(obj){var __p=[];with(obj||{})__p.push('<div class="stitches-sprite" style="top: ',y,"px; left: ",x,'px;"> <img src="',image.src,'"/></div>');return __p.join("")}}),define("tpl!util/../../templates/css.tpl",function(){return function(obj){var __p=[];with(obj||{})__p.push(".",prefix," {\\n background-image: url(",backgroundImage,");\\n background-repeat: no-repeat;\\n display: block;\\n}\\n"),$.map(sprites,function(e){__p.push("\\n.",prefix,"-",e.name," {\\n width: ",e.image.width,"px;\\n height: ",e.image.height,"px;\\n background-position: ",e.left(!0)," ",e.top(!0),";\\n}\\n")}),__p.push("");return __p.join("")}}),define("tpl!util/../../templates/css-markup.tpl",function(){return function(obj){var __p=[];with(obj||{})__p.push(""),$.map(sprites,function(e){__p.push(""),tooltip?__p.push('<i class="',prefix," ",prefix,"-",e.name,'" data-toggle="tooltip" title=".',prefix,".",prefix,"-",e.name,'"></i>\\n'):__p.push('<i class="',prefix," ",prefix,"-",e.name,'"></i>\\n'),__p.push("")}),__p.push("");return __p.join("")}}),define("tpl!util/../../templates/less.tpl",function(){return function(obj){var __p=[];with(obj||{})__p.push(".stitches-",prefix,"(@x: 0, @y: 0, @width: 0, @height: 0) {\\n background-position: @x @y;\\n width: @width;\\n height: @height;\\n}\\n\\n.",prefix," {\\n background-image: url(",backgroundImage,"); background-repeat: no-repeat;\\n display: block;\\n"),$.map(sprites,function(e){__p.push("\\n &.",prefix,"-",e.name," {\\n .stitches-",prefix,"(",e.left(!0),", ",e.top(!0),", ",e.image.width,"px, ",e.image.height,"px);\\n }\\n")}),__p.push("}\\n");return __p.join("")}}),define("tpl!util/../../templates/less-markup.tpl",function(){return function(obj){var __p=[];with(obj||{})__p.push(""),$.map(sprites,function(e){__p.push(""),tooltip?__p.push('<i class="',prefix," ",prefix,"-",e.name,'" data-toggle="tooltip" title=".',prefix,".",prefix,"-",e.name,'"></i>'):__p.push('<i class="',prefix," ",prefix,"-",e.name,'"></i>\\n'),__p.push("")}),__p.push("");return __p.join("")}}),define("util/templates",["tpl!../../templates/stitches.tpl","tpl!../../templates/downloads.tpl","tpl!../../templates/sprite.tpl","tpl!../../templates/css.tpl","tpl!../../templates/css-markup.tpl","tpl!../../templates/less.tpl","tpl!../../templates/less-markup.tpl"],function(e,t,i,s,n,r,a){return{stitches:function(){return e.apply(this,arguments)},downloads:function(){return t.apply(this,arguments)},sprite:function(){return i.apply(this,arguments)},css:function(){return s.apply(this,arguments)},cssMarkup:function(){return n.apply(this,arguments)},less:function(){return r.apply(this,arguments)},lessMarkup:function(){return a.apply(this,arguments)}}}),define("manager/file",["wrap/jquery","util/util"],function(e,t){return{total:0,processed:0,queue:[],set:function(e){e=e||{},this.onload=e.onload||t.noop,this.onprogress=e.onprogress||t.noop,this.onerror=e.onerror||t.noop},processFiles:function(t){var i=this;this.total=t.length,this.processed=0,this.queue=[],e.map(t,function(e){/jpeg|png|gif/.test(e.type)&&i.processFile(e)}),this.onprogress(0,"info")},processFile:function(e){var t,i=this;try{t=new FileReader,t.onloadend=function(t){var s=e.name,n=t.target.result,r=++i.processed/i.total;i.onprogress(r),i.queue.push([s,n]),i.queue.length===i.total&&i.processQueue()},t.readAsDataURL(e)}catch(s){this.onerror(s)}},processQueue:function(){var t=this;e.map(this.queue,function(e){t.onload.apply(t,e)})}}}),define("layout/base",["wrap/jquery"],function(e){var t={maxPass:2},i=function(i){this.settings=e.extend({},t,i)};return i.prototype={constructor:i,getDimensions:function(){},placeSprite:function(){},intersection:function(t,i){var s,n,r,a,o,l=[];return e.map(i,function(e){s=e.x<t.x+t.width,r=e.y<t.y+t.height,n=e.x+e.width>t.x,a=e.y+e.height>t.y,s&&n&&r&&a&&l.push(e)}),l.length&&(o=l.pop()),o}},i}),define("layout/compact",["wrap/jquery","util/util","layout/base"],function(e,t,i){var s={maxPass:2},n=function(t){this.settings=e.extend({},s,t)};return t.inherit(n,i,{getDimensions:function(t,i){var s=0,n=0,r=0,a=0;return e.map(t,function(e){s=e.width>s?e.width:s,n=e.height>n?e.height:n,r+=e.area}),a=Math.ceil(Math.sqrt(r)),s=s>a?s:a,n=n>a?n:a,{width:s||i.width,height:n||i.height}},placeSprite:function(e,t,i){for(var s,n=0,r=0,a=0;n++<this.settings.maxPass;){for(a=0;i.height-e.height>=a;a++){for(r=0;i.width-e.width>=r;r++){if(e.x=r,e.y=a,s=this.intersection(e,t),!s)return t.push(e),e.show(),!0;r=s.x+s.width-1}a=s.y+s.height-1}i.width+=e.width,i.height+=e.height}}}),n}),define("layout/vertical",["wrap/jquery","util/util","layout/base"],function(e,t,i){var s={maxPass:2},n=function(t){this.settings=e.extend({},s,t)};return t.inherit(n,i,{getDimensions:function(t,i){var s=0,n=0;return e.map(t,function(e){s=e.width>s?e.width:s,n+=e.height}),{width:s||i.width,height:n||i.height}},placeSprite:function(e,t,i){for(var s,n=0,r=0,a=0;n++<this.settings.maxPass;){for(a=0;i.height-e.height>=a;a++){if(e.x=r,e.y=a,s=this.intersection(e,t),!s)return t.push(e),e.show(),!0;a=s.y+s.height-1}i.width+=e.width,i.height+=e.height}return!1}}),n}),define("layout/horizontal",["wrap/jquery","util/util","layout/base"],function(e,t,i){var s={maxPass:2},n=function(t){this.settings=e.extend({},s,t)};return t.inherit(n,i,{getDimensions:function(t,i){var s=0,n=0;return e.map(t,function(e){n=e.height>n?e.height:n,s+=e.width}),{width:s||i.width,height:n||i.height}},placeSprite:function(e,t,i){for(var s,n=0,r=0,a=0;n++<this.settings.maxPass;){for(r=0;i.width-e.width>=r;r++){if(e.x=r,e.y=a,s=this.intersection(e,t),!s)return t.push(e),e.show(),!0;r=s.x+s.width-1}i.width+=e.width,i.height+=e.height}return!1}}),n}),define("manager/layout",["wrap/jquery","layout/compact","layout/vertical","layout/horizontal"],function(e,t,i,s){var n={compact:t,vertical:i,horizontal:s};return{set:function(e){var t=n[e]||n.compact;this.manager=new t},getDimensions:function(e,t){return this.manager.getDimensions(e,t)},placeSprites:function(t,i,s,n){var r=this;n(0,"info"),e.map(t,function(e){e.placed||(e.placed=r.manager.placeSprite(e,i,s)),n(i.length/t.length)}),t=e.map(t,function(e){return e.placed?null:e})},trim:function(t,i){var s=0,n=0;e.map(t,function(e){s=s>e.x+e.width?s:e.x+e.width,n=n>e.y+e.height?n:e.y+e.height}),i.width=s||i.width,i.height=n||i.height},getSpritesheet:function(t){var i,s,n,r=t.sprites,a=t.dimensions;i=document.createElement("canvas"),i.width=a.width,i.height=a.height;try{s=i.getContext("2d"),e.map(r,function(e){var t=e.left(),i=e.top();s.drawImage(e.image,t,i)}),n=i.toDataURL("image/png")}catch(o){this.$element.trigger("error",[o])}return n}}}),define("stylesheet/base",["wrap/jquery"],function(e){var t={filename:"spritesheet.png"},i=function(i){this.settings=e.extend({},t,i)};return i.prototype={constructor:i,template:null,get:function(){},markup:function(e,t,i){return this.template({prefix:t,sprites:e,tooltip:i})}},i}),define("stylesheet/css",["wrap/jquery","util/util","util/templates","stylesheet/base"],function(e,t,i,s){var n={filename:"spritesheet.png"},r=function(t){this.settings=e.extend({},n,t)};return t.inherit(r,s,{template:i.cssMarkup,get:function(e,t,s,n){var r=n?t:this.settings.filename;return i.css({prefix:s,backgroundImage:r,sprites:e})}}),r}),define("stylesheet/less",["wrap/jquery","util/util","util/templates","stylesheet/base"],function(e,t,i,s){var n={filename:"spritesheet.png"},r=function(t){this.settings=e.extend({},n,t)};return t.inherit(r,s,{template:i.lessMarkup,get:function(e,t,s,n){var r=n?t:this.settings.filename;return i.less({prefix:s,backgroundImage:r,sprites:e})}}),r}),define("manager/stylesheet",["wrap/jquery","stylesheet/css","stylesheet/less"],function(e,t,i){var s={css:t,less:i};return{set:function(e){var t;this.type=e||"css",t=s[this.type],this.manager=new t},getStylesheet:function(e){var t=e.sprites,i=e.spritesheet,s=e.prefix,n=e.uri,r=this.manager.get(t,i,s,n);return r=r.replace(/\\n/g,"\n")},getMarkup:function(e){var t=e.sprites,i=e.prefix,s=e.tooltip||!1,n=this.manager.markup(t,i,s);return n=n.replace(/\\n/g,"\n")}}}),define("module/drop-box",["wrap/jquery","util/util"],function(e,t){var i={},s=function(t,s){this.$element=e(t),this.$overlay=this.$element.find(".stitches-overlay"),this.settings=e.extend({},i,s),this.init()};return s.classname=".stitches-drop-box",s.prototype={constructor:s,init:function(){this.bind()},bind:function(){var i=this.$element.get(0),s=this.$overlay.get(0);i.addEventListener("dragenter",e.proxy(this.dragStart,this),!1),s.addEventListener("dragleave",e.proxy(this.dragStop,this),!1),s.addEventListener("dragexit",e.proxy(this.dragStop,this),!1),s.addEventListener("dragover",t.noop,!1),s.addEventListener("drop",e.proxy(this.drop,this),!1)},dragStart:function(){this.$element.trigger("close-palettes"),this.$element.trigger("show-overlay")},dragStop:function(t){e.contains(this.$element,t.target)&&this.$element.trigger("hide-overlay")},drop:function(e){var t=e.files||e.dataTransfer.files;e.stopPropagation(),e.preventDefault(),t.length?this.$element.trigger("process-files",[t]):this.$element.trigger("hide-overlay")}},s}),define("util/array",["wrap/jquery"],function(e){return{remove:function(t,i){return e(t).filter(function(){return this!==i})}}}),define("module/sprite",["wrap/jquery","util/util","util/templates"],function(e,t,i){var s={name:"",src:"",padding:0},n=function(i,n){this.settings=e.extend({},s,i),this.$element=null,this.name=this.cleanName(this.settings.name),this.src=this.settings.src,this.padding=parseInt(this.settings.padding,10),this.active=!1,this.placed=!1,this.onload=n.onload||t.noop,this.init()};return n.classname=".stitches-sprite",n.prototype={constructor:n,init:function(){this.load()},load:function(){var e=this;this.image=new Image,this.image.onload=function(){e.x=0,e.y=0,e.width=e.image.width+2*e.padding,e.height=e.image.height+2*e.padding,e.area=e.width*e.height,e.render(),e.bind(),e.toDataURL(),e.onload(e)},this.image.src=this.src},render:function(){var t=i.sprite(this);this.$element=e(t),this.$element.data("sprite",this)},bind:function(){this.$element.on("click",e.proxy(this.click,this))},toDataURL:function(){var e,t,i;e=document.createElement("canvas"),e.width=this.image.width,e.height=this.image.height;try{t=e.getContext("2d"),t.drawImage(this.image,0,0),i=e.toDataURL("image/png")}catch(s){this.$element.trigger("error",[s])}this.src=i},reset:function(){this.x=0,this.y=0,this.placed=!1,this.$element.removeClass("placed")},show:function(){this.$element.css({left:this.x+"px",top:this.y+"px",padding:this.padding+"px"}).addClass("placed")},click:function(){var e=!this.active;e?(this.$element.trigger("clear-active",[this]),this.$element.trigger("open-properties",[this])):this.$element.trigger("close-properties"),this.active=e,this.$element.toggleClass("active",e)},configure:function(e){e.padding&&(this.padding=parseInt(e.padding,10),this.width=this.image.width+2*this.padding,this.height=this.image.height+2*this.padding,this.area=this.width*this.height)},cleanName:function(e){return e=e.replace(/\.\w+$/i,""),e=e.replace(/[\s.]+/gi,"-"),e=e.replace(/[^a-z0-9\-]/gi,"_")},left:function(e){var i=this.x+this.padding;return e?t.toPx(-i):i},top:function(e){var i=this.y+this.padding;return e?t.toPx(-i):i},toJSON:function(){return{name:this.name,src:this.src}}},n}),define("module/canvas",["wrap/jquery","util/util","util/array","manager/layout","module/sprite"],function(e,t,i,s,n){var r={images:null,dimensions:{width:400,height:400}},a=function(i,s,n){this.$element=e(i),this.settings=e.extend({},r,s),this.images=this.settings.images,this.dimensions=this.settings.dimensions,this.sprites=[],this.names=[],this.onprogress=n.onprogress||t.noop};return a.classname=".stitches-canvas",a.prototype={constructor:a,init:function(){this.reset=t.debounce(this.reset,500),this.bind(),this.setup(),this.reset()},bind:function(){this.$element.on("clear-active",e.proxy(this.clearActive,this))},setup:function(){var t=this;e(this.images).each(function(){var i=e(this),s=i.data("name"),n=i.attr("src");t.createSprite(s,n)}).remove()},reset:function(){this.$element.trigger("show-overlay"),this.measure(this.sprites),this.place(this.sprites),this.cut(this.sprites),this.$element.trigger("generate-sheets"),this.$element.trigger("hide-overlay")},measure:function(e){this.dimensions=s.getDimensions(e,this.settings.dimensions)},place:function(t){var i=[];e.map(t,function(e){e.reset()}),t=t.sort(function(e,t){return e.name===t.name?0:e.name>t.name?1:-1}),s.placeSprites(t,i,this.dimensions,this.onprogress)},cut:function(e){s.trim(e,this.dimensions),this.$element.css({width:this.dimensions.width+"px",height:this.dimensions.height+"px"})},add:function(e){this.sprites.push(e),this.names.push(e.name),this.$element.trigger("show-overlay"),e.$element.appendTo(this.$element),this.$element.trigger("update-toolbar"),this.reset()},remove:function(e){this.sprites=i.remove(this.sprites,e),this.names=i.remove(this.names,e.name),this.$element.trigger("show-overlay"),e.$element.fadeOut("fast").remove(),this.$element.trigger("update-toolbar"),this.$element.trigger("close-properties"),this.reset()},clear:function(){this.empty(),this.$element.trigger("show-overlay"),this.$element.trigger("update-toolbar"),this.$element.trigger("close-properties"),this.$element.trigger("open-settings"),this.reset()},empty:function(){this.sprites=[],this.names=[],this.$element.empty()},createSprite:function(e,t){var i=this;new n({name:e,src:t,padding:this.settings.padding},{onload:function(e){i.add(e)}})},clearActive:function(t,i){this.$element.find(".active").each(function(){var t=e(this),s=t.data("sprite");i&&s!==i&&(t.removeClass("active"),s.active=!1)})},toJSON:function(){return{sprites:this.sprites}}},a}),define("module/toolbar",["wrap/jquery"],function(e){var t={name:"",actions:{}},i=function(i,s){this.$element=e(i),this.settings=e.extend({},t,s),this.name=this.settings.name,this.actions=this.settings.actions,this.init()};return i.classname=".stitches-toolbar",i.prototype={constructor:i,init:function(){this.bind()},bind:function(){var t=this;e.each(this.actions,function(i,s){e.each(s,function(e,s){var n="[data-action="+i+"]",r=t.getHandler(t,s);"instance"===i?t.$element.on(e,t.getHandler(t,r)):t.$element.on(e,n,r)})})},getHandler:function(t,i){return function(s){var n=e(s.currentTarget);n.is(".disabled")?(s.stopPropagation(),s.preventDefault()):i.apply(t,arguments)}},toggleActions:function(t,i){var s=this;"string"==typeof t&&(t=t.split(" ")),e.map(t,function(e){var t=s.$element.find("[data-action="+e+"]");t.toggleClass("disabled",i)})},enable:function(e){this.toggleActions(e,!1)},disable:function(e){this.toggleActions(e,!0)}},i}),define("module/palette",["wrap/jquery","util/util","module/toolbar"],function(e,t,i){var s={name:"",visible:!1,actions:{},fields:{}},n=function(t,i){this.$element=e(t),this.settings=e.extend({},s,i),this.name=this.settings.name,this.visible=this.settings.visible,this.actions=this.settings.actions,this.fields=this.settings.fields,this.source=null,this.init()};return n.classname=".stitches-palette",t.inherit(n,i,{init:function(){this._super("init",this,arguments),this.$element.toggleClass("in",this.visible)},bind:function(){var t=this;this._super("bind",this,arguments),e.each(this.fields,function(i,s){e.each(s,function(e,s){var n="[name="+i+"]",r=t.getHandler(t,s);t.$element.on(e,n,r)})})},open:function(){this.$element.addClass("in"),this.visible=!0},close:function(){this.$element.removeClass("in"),this.visible=!1},configure:function(t){var i=this;this.source=t.source,e.each(t.inputs,function(e,t){var s="[name="+e+"]",n=i.$element.find(s),r=n.attr("type");switch(r){case"radio":case"checkbox":n=n.removeAttr("checked").filter("[value="+t+"]"),n.attr("checked","checked");break;default:n.val(t)}})}}),n}),define("module/stitches",["wrap/jquery","wrap/modernizr","../../../libs/store/store","util/util","util/templates","manager/file","manager/layout","manager/stylesheet","module/drop-box","module/canvas","module/toolbar","module/palette"],function(e,t,i,s,n,r,a,o,l,c,p,h){var u={layout:"compact",prefix:"sprite",padding:5,uri:!1,stylesheet:"css"},d=function(t,i){this.$element=e(t),this.settings=e.extend({},u,i),this.init()};return d.prototype={constructor:d,init:function(){this.configure(),this.render(),this.test(),this.bind(),this.setDropBox(),this.setToolbar(),this.setImages(),this.setCanvas(),this.setManagers(),this.setPalettes(),this.canvas.init()},configure:function(){var t;i&&!i.disabled&&(t=i.get("stitches-settings")),t&&(this.settings=e.extend(this.settings,t))},render:function(){var e=n.stitches({});this.$element.append(e),this.$overlay=this.$element.find(".stitches-overlay"),this.$dropBox=this.$element.find(".stitches-drop-box"),this.$toolbar=this.$element.find(".stitches-toolbar"),this.$canvas=this.$element.find(".stitches-canvas"),this.$progress=this.$element.find(".stitches-progress .progress"),this.$progressBar=this.$element.find(".stitches-progress .bar"),this.$about=this.$element.find(".stitches-about"),this.$downloads=this.$element.find(".stitches-downloads"),this.$settings=this.$element.find(".stitches-settings"),this.$properties=this.$element.find(".stitches-properties")},test:function(){this.hasFileInput=this.$element.find("input.file").length},bind:function(){this.$element.on("show-overlay",e.proxy(this.showOverlay,this)),this.$element.on("hide-overlay",e.proxy(this.hideOverlay,this)),this.$element.on("open-about",e.proxy(this.openAbout,this)),this.$element.on("close-about",e.proxy(this.closeAbout,this)),this.$element.on("open-downloads",e.proxy(this.openDownloads,this)),this.$element.on("close-downloads",e.proxy(this.closeDownloads,this)),this.$element.on("open-settings",e.proxy(this.openSettings,this)),this.$element.on("close-settings",e.proxy(this.closeSettings,this)),this.$element.on("open-properties",e.proxy(this.openProperties,this)),this.$element.on("close-properties",e.proxy(this.closeProperties,this)),this.$element.on("close-palettes",e.proxy(this.closePalettes,this)),this.$element.on("process-files",e.proxy(this.processFiles,this)),this.$element.on("update-toolbar",e.proxy(this.updateToolbar,this)),this.$element.on("update-settings",e.proxy(this.updateSettingsPalette,this)),this.$element.on("update-downloads",e.proxy(this.updateDownloadsPalette,this)),this.$element.on("generate-sheets",e.proxy(this.generateSheets,this)),this.$element.on("error",e.proxy(this.errorHandler,this))},setDropBox:function(){this.dropBox=new l(this.$dropBox)},setManagers:function(){r.set({onload:e.proxy(this.canvas.createSprite,this.canvas),onprogress:e.proxy(this.updateProgress,this)}),a.set(this.settings.layout),o.set(this.settings.stylesheet)},setImages:function(){this.images=this.$element.find("> img").get()},setCanvas:function(){this.canvas=new c(this.$canvas,{images:this.images,padding:this.settings.padding},{onprogress:e.proxy(this.updateProgress,this)})},setToolbar:function(){var e=this;this.toolbar=new p(this.$toolbar,{name:"toolbar",actions:{open:{change:function(t){var i=e.$toolbar.find("input[type=file]"),s=i.clone(!0).val(""),n=t.target.files;e.$element.trigger("process-files",[n]),i.replaceWith(s)}},settings:{click:function(){e.$element.trigger("open-settings")}},reset:{click:function(){e.canvas.reset()}},clear:{click:function(){e.canvas.clear()}},downloads:{click:function(){e.$element.trigger("open-downloads")}},about:{click:function(){e.$element.trigger("open-about")}}}})},setPalettes:function(){var t=this,i=new h(this.$about,{name:"about",visible:!0,actions:{close:{click:function(){this.close()}}}}),s=new h(this.$downloads,{name:"downloads",visible:!1,actions:{close:{click:function(){this.close()}}}}),n=new h(this.$settings,{name:"settings",visible:!1,actions:{close:{click:function(){t.$element.trigger("close-settings")}}},fields:{layout:{change:function(){var e=this.$element.find("input[name=layout]:checked"),i=e.val();this.source.layout=i,a.set(i),t.updateSettings()}},stylesheet:{change:function(){var e=this.$element.find("input[name=stylesheet]:checked"),i=e.val();t.settings.stylesheet=i,o.set(i),t.updateSettings()}},prefix:{"input blur":function(i){var s=e(i.currentTarget).val();this.source.prefix=s,t.updateSettings()}},padding:{"input blur":function(i){var s=e(i.currentTarget).val();this.source.padding=s,t.canvas.padding=s,e.map(t.canvas.sprites,function(e){e.configure({padding:s})}),t.updateSettings()}},uri:{change:function(i){var s=e(i.currentTarget).is(":checked");this.source.uri=s,t.updateSettings()}},"import":{blur:function(i){var s,n=e(i.currentTarget),r=n.parents(".control-group"),a=n.val();if(r.removeClass("error"),a)try{s=JSON.parse(a),t.importData(s)}catch(o){r.addClass("error"),t.$element.trigger("error",[o])}else t.updateProgress(1,"success")}}}}),r=new h(this.$properties,{name:"properties",visible:!1,actions:{close:{click:function(){t.$element.trigger("close-properties")}},remove:{click:function(){var e=this.source;t.canvas.remove(e)}}},fields:{name:{"input blur":function(t){var i=e(t.currentTarget),s=this.source,n=i.val(),r=s.cleanName(n);this.source.name=r,n!==r&&i.val(r)}}}});this.palettes={about:i,downloads:s,settings:n,properties:r}},updateSettings:function(){this.showOverlay(),this.canvas.reset(),i&&!i.disabled&&i.set("stitches-settings",this.settings)},showOverlay:function(){this.$overlay.fadeTo("fast",.4)},hideOverlay:function(){this.$overlay.fadeOut("fast")},openAbout:function(){this.closePalettes(),this.palettes.about.open()},closeAbout:function(){this.palettes.about.visible&&this.palettes.about.close()},openDownloads:function(){this.closePalettes(),this.palettes.downloads.open()},closeDownloads:function(){this.palettes.downloads.visible&&this.palettes.downloads.close()},openSettings:function(){this.closePalettes(),this.palettes.settings.configure({source:this.settings,inputs:{layout:this.settings.layout,stylesheet:this.settings.stylesheet,prefix:this.settings.prefix,padding:this.settings.padding,uri:this.settings.uri}}),this.palettes.settings.open()},closeSettings:function(){var e=this.$settings.find("ul.nav-tabs"),t=e.find("li:first-child a"),i=this.$settings.find(":input[name=import]"),s=i.parents(".control-group");t.click(),i.val(""),s.removeClass("error"),this.palettes.settings.visible&&this.palettes.settings.close()},openProperties:function(e,t){this.closePalettes(),this.palettes.properties.configure({source:t,inputs:{name:t.name,x:t.left(),y:t.top()}}),this.palettes.properties.open()},closeProperties:function(){this.palettes.properties.visible&&(this.palettes.properties.close(),this.canvas.$element.trigger("clear-active",[!0]))},closePalettes:function(){this.closeAbout(),this.closeDownloads(),this.closeSettings(),this.closeProperties()},processFiles:function(e,t){r.processFiles(t)},updateToolbar:function(){var e=this.toolbar,t=this.canvas;t.sprites.length?e.enable("reset clear downloads"):e.disable("reset clear downloads"),this.hasFileInput?e.enable("open"):e.disable("open")},updateSettingsPalette:function(){var e=this.$settings.find(".downloads-export");e.attr({href:"data:text/plain,"+encodeURIComponent(JSON.stringify(this)),target:"_blank"})},updateDownloadsPalette:function(){var t=this.$downloads.find("section"),i=this.$downloads.find(".downloads-spritesheet"),s=this.$downloads.find(".downloads-stylesheet"),r=n.downloads({prefix:this.settings.prefix,spritesheet:this.spritesheet,stylesheet:this.stylesheet,stylesheetWithUri:this.stylesheetWithUri,stylesheetType:o.type,stylesheetLines:this.stylesheet.split("\n").length,markup:this.markup,markupLines:this.markup.split("\n").length,markupTooltip:this.markupTooltip});t.html(r),i.attr({href:this.spritesheet,target:"_blank"}),s.attr({href:"data:text/plain,"+encodeURIComponent(this.stylesheet),target:"_blank"}),e.fn.tooltip&&t.find("[data-toggle=tooltip]").tooltip()},updateProgress:function(e,t){var i=Math.ceil(100*e);100===i&&"danger"!==t&&"warning"!==t&&(t="success"),t&&this.$progress.attr({"class":"progress progress-"+t}),this.$progressBar.css({width:i+"%"})},generateSheets:function(){this.spritesheet=a.getSpritesheet({sprites:this.canvas.sprites,dimensions:this.canvas.dimensions}),this.stylesheetWithUri=o.getStylesheet({sprites:this.canvas.sprites,spritesheet:this.spritesheet,prefix:this.settings.prefix,uri:!0}),this.markup=o.getMarkup({sprites:this.canvas.sprites,prefix:this.settings.prefix}),this.markupTooltip=o.getMarkup({sprites:this.canvas.sprites,prefix:this.settings.prefix,tooltip:!0}),this.stylesheet=this.settings.uri?this.stylesheetWithUri:o.getStylesheet({sprites:this.canvas.sprites,spritesheet:this.spritesheet,prefix:this.settings.prefix,uri:this.settings.uri}),this.$element.trigger("update-toolbar"),this.$element.trigger("update-settings"),this.$element.trigger("update-downloads"),this.updateProgress(1,"success")},errorHandler:function(e,t,i){this.updateProgress(1,i||"warning")},toJSON:function(){return{settings:this.settings,canvas:this.canvas.toJSON()}},importData:function(t){var i=this,s=t.settings||{},n=t.canvas||{},r=n.sprites||[];this.settings=e.extend({},u,s),a.set(this.settings.layout),o.set(this.settings.stylesheet),this.updateSettings(),this.canvas.clear(),this.canvas.settings.padding=this.settings.padding,e.map(r,function(e){i.canvas.createSprite(e.name,e.src)}),this.updateProgress(1,"success")}},d}),require({paths:{tpl:"../tpl"}},["wrap/jquery","module/stitches"],function(e,t){e(document).ready(function(){var i=".stitches";e(i).each(function(){new t(this)})})}),define("stitches",function(){});
Please sign in to comment.
Something went wrong with that request. Please try again.