├── .gitignore ├── README.md ├── Rakefile ├── demo ├── css │ └── box-flex.css └── index.html ├── dist └── flexie.min.js ├── src └── flexie.js ├── test ├── css │ ├── demo.css │ └── test.css └── index.html └── vendor ├── google-compiler ├── COPYING ├── README └── compiler.jar └── yuicompressor ├── README └── yuicompressor-2.4.2.jar /.gitignore: -------------------------------------------------------------------------------- 1 | *.tmproj 2 | dist/flexie.js -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### Flexie enables the 2009 Flexbox model. You're probably looking for the updated spec. There is currently no polyfill for the new spec.* 2 | 3 | __* I've been [working on one](http://github.com/doctyper/reflexie) in my off-time. It's a beast.__ 4 | 5 | 6 | Cross-browser support for the [CSS3 Flexible Box Model](http://www.w3.org/TR/css3-flexbox/). Check out [The Playground](http://flexiejs.com/playground/) to see it in action. 7 | # Flexie v1.0.3 [![](http://stillmaintained.com/doctyper/flexie.png)](http://stillmaintained.com/doctyper/flexie) 8 | 9 | ## Browser Support 10 | * IE 6-9 11 | * Opera 10.0+ 12 | 13 | The Flexible Box Model is [supported natively](http://www.caniuse.com/#feat=flexbox) by these browsers: 14 | 15 | * Firefox 3.0+ 16 | * Safari 3.2+ 17 | * Chrome 5.0+ 18 | 19 | In addition, Flexie attempts to normailze browser inconsistencies with the flexible box model. 20 | 21 | ### Currently Supported Properties 22 | * box-orient 23 | * box-align 24 | * box-direction 25 | * box-pack 26 | * box-flex 27 | * box-flex-group 28 | * box-ordinal-group 29 | 30 | ## Why? 31 | I *really* wanted to use the CSS3 Flexible Box Model. 32 | 33 | ## How? 34 | It works like [Selectivizr](http://selectivizr.com). In fact, it uses Selectivizr's engine to traverse your style sheets and looks for `display: box` elements. After that, it looks for any of the currently supported properties. 35 | 36 | Note: Flexie looks for non-vendor-prefixed properties. For example, it will ignore `-moz-box-pack`, but not `box-pack`. For best results, make sure to use a non-vendor-prefixed property _in addition to_ your prefixed properties. But you were already doing that to future-proof your code, weren't you? 37 | 38 | No setup on your end, just stick Flexie in your markup after your [selector engine of choice](http://selectivizr.com/#things). 39 | 40 | ## Requirements 41 | See the [things you need to know](http://selectivizr.com/#things) 42 | 43 | ## Caveats 44 | * For older browsers (IE < 8), please remember that some advanced selectors (child, adjacent, pseudo-selectors) will fail. Flexie does not attempt to bridge this gap, so if you must support legacy browsers, class names and ID selectors are your best bets. 45 | 46 | * As of FF 4.0 / Chrome 7 / Safari 5, Gecko and Webkit differ slightly in their flexbox implementations. Of note is their default values. Webkit will default to `box-align: start`, while Gecko defaults to the spec-defined `box-align: stretch`. Make sure your flexbox CSS works on both these browsers before adding Flexie. 47 | * As of version 0.7, Flexie normalizes the `box-align` property across Webkit browsers. 48 | * As of version 0.8, Flexie normalizes the `box-pack` property in Gecko. 49 | 50 | * Be careful of pseudo-selectors (i.e., `:nth-child`, `:first-child`). While native flexbox does not modify the DOM, Flexie must. Thus, your CSS properties might not apply as intended. For example, if you use a combination of `box-direction: reverse` and a `:first-child` selector, that selector will target the wrong element. And if you followed all of that, congratulations. 51 | 52 | * There may be cases where the floats used to mimic the flexbox layout drop in Internet Explorer browsers. If possible, you can try the [overflow fix](http://css-tricks.com/all-about-floats/) to snap these into place _(Flexie assumes it cannot use this as a workaround due to the impact this may have in your layouts)_. 53 | 54 | * As of YUI 2.8.2r1, YUI's selector engine does not recognize dashed attributes (i.e. [data-name="foo"]). Flexie uses several [data- attributes](http://ejohn.org/blog/html-5-data-attributes/) as element flags. A bug report [has been filed](http://yuilibrary.com/projects/yui2/ticket/2529254) about this issue, but in the meantime YUI remains incompatible with Flexie. 55 | 56 | ## Asynchronous API 57 | You can run Flexie asynchronously in case you cannot purely on style sheets. All parameters are optional, unless otherwise stated: 58 | 59 | ### Creating a new Flexie Object 60 | var box = new Flexie.box({ 61 | target : document.getElementById("foo"), 62 | orient : "horizontal", 63 | align : "stretch", 64 | direction : "normal", 65 | pack : "start", 66 | flexMatrix : [1, 1, 1, 1], 67 | ordinalMatrix : [0, 0, 0, 0] 68 | }); 69 | 70 | * **target** 71 | (required) The flexbox parent element. This must be a DOM node. 72 | * **orient** 73 | (optional) Possible values: `horizontal`, `vertical` 74 | * **align** 75 | (optional) Possible values: `stretch`, `start`, `end`, `center` 76 | * **direction** 77 | (optional) Possible values: `normal`, `reverse` 78 | * **pack** 79 | (optional) Possible values: `start`, `end`, `center`, `justify` 80 | * **flexMatrix** 81 | (optional) An array of values to apply to the parent's children. e.g.: 82 | flexMatrix : [1, 0, 0] // Three child nodes contained, the parent's first child has a box-flex value of 1 83 | flexMatrix : [1, 0, 1] // Three child nodes contained, the parent's first and last child have a box-flex value of 1 84 | flexMatrix : [1, 1, 1] // Three child nodes contained, all children have a box-flex value of 1 85 | * **ordinalMatrix** 86 | (optional) An array of values to apply to the parent's children. See `flexMatrix` for an example. 87 | 88 | ### Flexie.updateInstance(target, params) 89 | Used to redraw currently active Flexie objects (i.e., after dynamically updating a flexbox element). All parameters optional. 90 | 91 | _Note: Calling this method without parameters will update all instances._ 92 | 93 | * **target** 94 | (optional) The flexbox element to update. 95 | * **params** 96 | (optional) An object of flexbox properties to update. See Creating a new Flexie Object for accepted parameters. 97 | 98 | ### Flexie.getInstance(target) 99 | Returns the target instance 100 | 101 | * **target** 102 | (optional) The flexbox instance to retrieve. 103 | 104 | ### Flexie.destroyInstance(target) 105 | Destroys the target instance. 106 | 107 | _Note: Calling this method without parameters will destroy all instances._ 108 | 109 | * **target** 110 | (optional) The flexbox instance to retrieve. 111 | 112 | ### Flexie.flexboxSupported 113 | An exposed object detailing the level of flexbox support. Returns false for no support. 114 | 115 | ## Acknowledgements 116 | Selectivizr, for their fantastic CSS parsing engine. 117 | 118 | ## Copyright and Software License 119 | The MIT License 120 | 121 | Copyright (c) 2010 Richard Herrera 122 | 123 | Permission is hereby granted, free of charge, to any person obtaining a copy 124 | of this software and associated documentation files (the "Software"), to deal 125 | in the Software without restriction, including without limitation the rights 126 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 127 | copies of the Software, and to permit persons to whom the Software is 128 | furnished to do so, subject to the following conditions: 129 | 130 | The above copyright notice and this permission notice shall be included in 131 | all copies or substantial portions of the Software. 132 | 133 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 134 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 135 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 136 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 137 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 138 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 139 | THE SOFTWARE. 140 | 141 | ## Contact 142 | * rich {at} doctyper {dot} com 143 | * [@doctyper](http://twitter.com/doctyper) on Twitter 144 | * 145 | 146 | ## Links 147 | * Flexie on GitHub: 148 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'rake' 2 | require 'rake/packagetask' 3 | 4 | FLEXIE_VERSION = "1.0.1" 5 | 6 | FLEXIE_ROOT = File.expand_path(File.dirname(__FILE__)) 7 | FLEXIE_SRC_DIR = File.join(FLEXIE_ROOT, 'src') 8 | FLEXIE_DIST_DIR = File.join(FLEXIE_ROOT, 'dist') 9 | FLEXIE_PKG_DIR = File.join(FLEXIE_ROOT, 'pkg') 10 | 11 | FLEXIE_FILES = [ 12 | File.join(FLEXIE_SRC_DIR,'flexie.js') 13 | ] 14 | 15 | task :default => [:clean, :concat, :dist] 16 | 17 | desc "Clean the distribution directory." 18 | task :clean do 19 | rm_rf FLEXIE_DIST_DIR 20 | mkdir FLEXIE_DIST_DIR 21 | end 22 | 23 | desc "Concatenate Flexie core and plugins to build a distributable flexie.js file" 24 | task :concat do 25 | File.open(File.join(FLEXIE_DIST_DIR,'flexie.js'),"w") do |f| 26 | f.puts FLEXIE_FILES.map{ |s| IO.read(s) } 27 | end 28 | end 29 | 30 | def google_compiler(src, target) 31 | puts "Minifying #{src} with Google Closure Compiler..." 32 | `java -jar vendor/google-compiler/compiler.jar --compilation_level SIMPLE_OPTIMIZATIONS --js #{src} --summary_detail_level 3 --js_output_file #{target}` 33 | end 34 | 35 | def yui_compressor(src, target) 36 | puts "Minifying #{src} with YUI Compressor..." 37 | `java -jar vendor/yuicompressor/yuicompressor-2.4.2.jar #{src} -o #{target}` 38 | end 39 | 40 | def process_minified(src, target) 41 | cp target, File.join(FLEXIE_DIST_DIR,'temp.js') 42 | msize = File.size(File.join(FLEXIE_DIST_DIR,'temp.js')) 43 | `gzip -9 #{File.join(FLEXIE_DIST_DIR,'temp.js')}` 44 | 45 | osize = File.size(src) 46 | dsize = File.size(File.join(FLEXIE_DIST_DIR,'temp.js.gz')) 47 | rm_rf File.join(FLEXIE_DIST_DIR,'temp.js.gz') 48 | 49 | puts "Original version: %.3fk" % (osize/1024.0) 50 | puts "Minified: %.3fk" % (msize/1024.0) 51 | puts "Minified and gzipped: %.3fk, compression factor %.3f" % [dsize/1024.0, osize/dsize.to_f] 52 | end 53 | 54 | desc "Generates a minified version for distribution." 55 | task :dist do 56 | src, target = File.join(FLEXIE_DIST_DIR,'flexie.js'), File.join(FLEXIE_DIST_DIR,'flexie.min.js') 57 | google_compiler src, target 58 | process_minified src, target 59 | end 60 | 61 | desc "Generates a minified version for distribution using the YUI compressor." 62 | task :yuidist do 63 | src, target = File.join(FLEXIE_DIST_DIR,'flexie.js'), File.join(FLEXIE_DIST_DIR,'flexie.min.js') 64 | yui_compressor src, target 65 | process_minified src, target 66 | end 67 | 68 | Rake::PackageTask.new('flexie', FLEXIE_VERSION) do |package| 69 | package.need_tar_gz = true 70 | package.need_zip = true 71 | package.package_dir = FLEXIE_PKG_DIR 72 | package.package_files.include( 73 | 'README.md', 74 | 'dist/**/*', 75 | 'src/**/*', 76 | 'test/**/*', 77 | 'examples/**/*' 78 | ) 79 | end -------------------------------------------------------------------------------- /demo/css/box-flex.css: -------------------------------------------------------------------------------- 1 | #box-parent { 2 | width: 100%; /* Firefox needs this */ 3 | height: 100%; 4 | } 5 | 6 | #box-parent, #box-child-2, #nested-child-2 { 7 | display: -webkit-box; 8 | display: -moz-box; 9 | display: box; 10 | 11 | -webkit-box-orient: vertical; 12 | -moz-box-orient: vertical; 13 | box-orient: vertical; 14 | 15 | -webkit-box-direction: reverse; 16 | -moz-box-direction: reverse; 17 | box-direction: reverse; 18 | } 19 | 20 | #box-parent div { 21 | -webkit-box-flex: 1; 22 | -moz-box-flex: 1; 23 | box-flex: 1; 24 | } 25 | 26 | #box-child-2 { 27 | -webkit-box-ordinal-group: 2; 28 | -moz-box-ordinal-group: 2; 29 | box-ordinal-group: 2; 30 | } -------------------------------------------------------------------------------- /demo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Flexie Demo 6 | 7 | 8 | 63 | 64 | 65 | 66 |
67 |
Box Child 1
68 |
69 |
Nested Child 1
70 |
71 |
Deep Child 1
72 |
Deep Child 2
73 |
Deep Child 3
74 |
75 |
Nested Child 3
76 |
77 |
Box Child 3
78 |
79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /dist/flexie.min.js: -------------------------------------------------------------------------------- 1 | var Flexie=function(H,R){function O(a){if(a)a=a.replace(Ha,E).replace(Ia,E);return a}function ia(a,d){a="on"+a;var c=H[a];H[a]=typeof H[a]!=="function"?d:function(){c&&c();d()}}function ja(a){var d=a.nodeName.toLowerCase();if(a.id)d+="#"+a.id;else if(a.FLX_DOM_ID)d+="["+ka+"='"+a.FLX_DOM_ID+"']";return d}function ca(a){if(!a.FLX_DOM_ID){da+=1;a.FLX_DOM_ID=da;a.setAttribute(ka,a.FLX_DOM_ID)}}function Ja(a){var d,c,b,e,f=/\s?,\s?/,g,h,k,i={},n={},r,p,j,l,m,o,y,v;g=function(s,w,q,A){var z,C,I;s={selector:O(s), 2 | properties:[]};z=0;for(C=w.properties.length;z|\+|\~/g,"%").split(/%/g);d={_id:100,_class:10,_tag:1};b=c=0;for(e=a.length;b]*>([^<>]*)<\/style[\s]?>/img;for(var m=l.exec(j),o=[];m;){(m=m[1])&&o.push(m);m=l.exec(j)}l=o.join("\n\n")}return l}function b(j,l){if(j){if(Xa.test(j))return l.substring(0,l.indexOf("/",8))===j.substring(0,j.indexOf("/",8))?j:x;if(j.charAt(0)==="/")return l.substring(0,l.indexOf("/",8))+j;var m=l.split("?")[0];if(j.charAt(0)!=="?"&&m.charAt(m.length-1)!=="/")m=m.substring(0,m.lastIndexOf("/")+1);return m+j}}function e(j){if(j)return c(j).replace(f, 16 | E).replace(g,function(l,m,o,y,v,s){l=e(b(o||v,j));return s?"@media "+s+" {"+l+"}":l}).replace(h,function(l,m,o,y){o=o||E;return m?l:" url("+o+b(y,j,true)+o+") "});return E}var f=/(\/\*[^*]*\*+([^\/][^*]*\*+)*\/)\s*?/g,g=/@import\s*(?:(?:(?:url\(\s*(['"]?)(.*)\1)\s*\))|(?:(['"])(.*)\3))\s*([^;]*);/g,h=/(behavior\s*?:\s*)?\burl\(\s*(["']?)(?!data:)([^"')]+)\2\s*\)/g,k=/((?:^|(?:\s*\})+)(?:\s*@media[^\{]+\{)?)\s*([^\{]*?[\[:][^{]+)/g,i=/([(\[+~])\s+/g,n=/\s+([)\]+~])/g,r=/\s+/g,p=/^\s*((?:[\S\s]*\S)?)\s*$/; 17 | return function(){var j,l=[],m,o;m=R.getElementsByTagName("BASE");var y=m.length>0?m[0].href:R.location.href,v=R.styleSheets,s,w;m=0;for(o=v.length;m|\+|\~/g,""),e+"zoom:1;",0);else W.IE===7&&b.addRule(h,e+"display:inline-block;",0)}else{b.addRule(h, 22 | e,0);b.addRule(h+":before","content: '.';display: block;height: 0;overflow: hidden",0);b.addRule(h+":after","content: '.';display: block;height: 0;overflow: hidden;clear:both;",0)}else if(b.insertRule){b.insertRule(h+"{"+e+"}",0);b.insertRule(h+":after{content: '.';display: block;height: 0;overflow: hidden;clear:both;}",0)}}c.cleared=u}},boxDirection:function(a,d,c){var b,e,f;if(c.direction==="reverse"&&!c.reversed||c.direction==="normal"&&c.reversed){d=d.reverse();b=0;for(e=d.length;b=9?"cssFloat":"styleFloat"]="left";if(c.orient==="vertical"|| 24 | c.orient==="block-axis")g.style.clear="left";if(W.IE===6)g.style.display="inline"}}switch(c.orient){case "vertical":case "block-axis":this.props=b;this.anti=a;break;default:this.props=a;this.anti=b}},boxOrdinalGroup:function(a,d,c){var b,e;if(d.length){b=function(f){f=f.keys;f=c.reversed?f:f.reverse();var g,h,k,i,n,r;g=0;for(h=f.length;g1&&b(e)}},boxFlex:function(a, 25 | d,c){var b=this,e,f,g,h;if(d.length){e=function(k){var i=k.groups;k=k.keys;var n,r,p,j,l,m,o,y,v,s;r=0;for(p=k.length;rn)M(o.match,b.props.pos,x)}}};f=function(k){var i=0,n,r,p,j,l,m;n=0;for(r=d.length;n';fa(c,"display","box",x);fa(c,"box-align","stretch",u);fa(c,"box-pack","justify",u);R.body.appendChild(c);d=c.firstChild.offsetHeight; 35 | b={boxAlignStretch:function(){return d===100},boxPackJustify:function(){var g=0,h,k;h=0;for(k=c.childNodes.length;h|\+|\~/g, "%").split(/%/g); 859 | 860 | matrix = { 861 | _id : 100, 862 | _class : 10, 863 | _tag : 1 864 | }; 865 | 866 | // Start with rule index position 867 | total = 0; 868 | 869 | // Add each selector value to total. 870 | for (i = 0, j = selectorGrid.length; i < j; i++) { 871 | chunk = selectorGrid[i]; 872 | 873 | if ((/#/).test(chunk)) { 874 | total += matrix._id; 875 | } else if ((/\.|\[|\:/).test(chunk)) { 876 | total += matrix._class; 877 | } else if ((/[a-zA-Z]+/).test(chunk)) { 878 | total += matrix._tag; 879 | } 880 | } 881 | 882 | return total; 883 | } 884 | 885 | function filterDuplicates (matches, children, type) { 886 | var filteredMatches = [], exists, 887 | spec = (type ? "ordinal" : "flex") + "Specificity", 888 | i, j, x, k, l, f; 889 | 890 | for (i = 0, j = matches.length; i < j; i++) { 891 | x = matches[i]; 892 | 893 | if ((!type && x.flex) || (type && x["ordinal-group"])) { 894 | x[spec] = x[spec] || calculateSpecificity(x.selector); 895 | 896 | exists = FALSE; 897 | 898 | for (k = 0, l = filteredMatches.length; k < l; k++) { 899 | f = filteredMatches[k]; 900 | 901 | if (f.match === x.match) { 902 | if (f[spec] < x[spec]) { 903 | filteredMatches[j] = x; 904 | } 905 | 906 | exists = TRUE; 907 | return FALSE; 908 | } 909 | } 910 | 911 | if (!exists) { 912 | filteredMatches.push(x); 913 | } 914 | } 915 | } 916 | 917 | return filteredMatches; 918 | } 919 | 920 | function createMatchMatrix(matches, children, type) { 921 | var groups = {}, keys = [], totalRatio = 0, 922 | group, order = "ordinal-group", 923 | BoxOrdinalAttr = "data-" + order, 924 | i, j, kid, k, l, x, key; 925 | 926 | // Filter dupes 927 | matches = filterDuplicates(matches, children, type); 928 | 929 | for (i = 0, j = children.length; i < j; i++) { 930 | kid = children[i]; 931 | 932 | for (k = 0, l = matches.length; k < l; k++) { 933 | x = matches[k]; 934 | 935 | if (type) { 936 | // If no value declared, it's the default. 937 | group = x[order] || "1"; 938 | 939 | if (x.match === kid) { 940 | x.match.setAttribute(BoxOrdinalAttr, group); 941 | 942 | groups[group] = groups[group] || []; 943 | groups[group].push(x); 944 | } 945 | } else { 946 | // If no value declared, it's the default. 947 | group = x.flex || "0"; 948 | 949 | if (x.match === kid && (!x[group] || (x[group] && parseInt(x[group], 10) <= 1))) { 950 | totalRatio += parseInt(group, 10); 951 | 952 | groups[group] = groups[group] || []; 953 | groups[group].push(x); 954 | } 955 | } 956 | } 957 | 958 | if (type && !kid.getAttribute(BoxOrdinalAttr)) { 959 | group = "1"; 960 | kid.setAttribute(BoxOrdinalAttr, group); 961 | 962 | groups[group] = groups[group] || []; 963 | groups[group].push({ 964 | match : kid 965 | }); 966 | } 967 | } 968 | 969 | for (key in groups) { 970 | if (groups.hasOwnProperty(key)) { 971 | keys.push(key); 972 | } 973 | } 974 | 975 | keys.sort(function (a, b) { 976 | return b - a; 977 | }); 978 | 979 | return { 980 | keys : keys, 981 | groups : groups, 982 | total : totalRatio 983 | }; 984 | } 985 | 986 | function attachResizeListener(construct, params) { 987 | if (!RESIZE_LISTENER) { 988 | var storedWidth, storedHeight, 989 | currentWidth, currentHeight, 990 | docBody = doc.body, 991 | docEl = doc.documentElement, 992 | resizeTimer, 993 | innerWidth = "innerWidth", innerHeight = "innerHeight", 994 | clientWidth = "clientWidth", clientHeight = "clientHeight"; 995 | 996 | addEvent("resize", function () { 997 | if (resizeTimer) { 998 | window.clearTimeout(resizeTimer); 999 | } 1000 | 1001 | resizeTimer = window.setTimeout(function () { 1002 | currentWidth = win[innerWidth] || docEl[innerWidth] || docEl[clientWidth] || docBody[clientWidth]; 1003 | currentHeight = win[innerHeight] || docEl[innerHeight] || docEl[clientHeight] || docBody[clientHeight]; 1004 | 1005 | if (storedWidth !== currentWidth || storedHeight !== currentHeight) { 1006 | FLX.updateInstance(NULL, NULL); 1007 | 1008 | storedWidth = currentWidth; 1009 | storedHeight = currentHeight; 1010 | } 1011 | }, 250); 1012 | }); 1013 | 1014 | RESIZE_LISTENER = TRUE; 1015 | } 1016 | } 1017 | 1018 | function cleanPositioningProperties (children) { 1019 | var i, j, kid, w, h; 1020 | 1021 | for (i = 0, j = children.length; i < j; i++) { 1022 | kid = children[i]; 1023 | 1024 | w = kid.style.width; 1025 | h = kid.style.height; 1026 | 1027 | kid.style.cssText = EMPTY_STRING; 1028 | 1029 | kid.style.width = w; 1030 | kid.style.height = h; 1031 | } 1032 | } 1033 | 1034 | function sanitizeChildren (target, nodes) { 1035 | var children = [], node, i, j; 1036 | 1037 | for (i = 0, j = nodes.length; i < j; i++) { 1038 | node = nodes[i]; 1039 | 1040 | if (node) { 1041 | switch (node.nodeName.toLowerCase()) { 1042 | case "script" : 1043 | case "style" : 1044 | case "link" : 1045 | break; 1046 | 1047 | default : 1048 | if (node.nodeType === 1) { 1049 | children.push(node); 1050 | } else if ((node.nodeType === 3) && (node.isElementContentWhitespace || (ONLY_WHITESPACE).test(node.data))) { 1051 | target.removeChild(node); 1052 | i--; 1053 | } 1054 | break; 1055 | } 1056 | } 1057 | } 1058 | 1059 | return children; 1060 | } 1061 | 1062 | function parentFlex (target) { 1063 | var totalFlex = 0, 1064 | parent = target.parentNode, 1065 | obj, 1066 | matrix, 1067 | isNested; 1068 | 1069 | while (parent.FLX_DOM_ID) { 1070 | obj = FLEX_BOXES[parent.FLX_DOM_ID]; 1071 | matrix = createMatchMatrix(obj.children, sanitizeChildren(parent, parent.childNodes), NULL); 1072 | 1073 | totalFlex += matrix.total; 1074 | isNested = TRUE; 1075 | 1076 | parent = parent.parentNode; 1077 | } 1078 | 1079 | return { 1080 | nested : isNested, 1081 | flex : totalFlex 1082 | }; 1083 | } 1084 | 1085 | function dimensionValues (target, prop) { 1086 | var parent = target.parentNode, 1087 | obj, dimension, i, j, rule; 1088 | 1089 | if (parent.FLX_DOM_ID) { 1090 | obj = FLEX_BOXES[parent.FLX_DOM_ID]; 1091 | 1092 | for (i = 0, j = obj.properties.length; i < j; i++) { 1093 | rule = obj.properties[i]; 1094 | 1095 | if ((new RegExp(prop)).test(rule.property)) { 1096 | dimension = TRUE; 1097 | return FALSE; 1098 | } 1099 | } 1100 | } 1101 | 1102 | return dimension; 1103 | } 1104 | 1105 | function updateChildValues (params) { 1106 | var i, j, x; 1107 | 1108 | if (params.flexMatrix) { 1109 | for (i = 0, j = params.children.length; i < j; i++) { 1110 | x = params.children[i]; 1111 | x.flex = params.flexMatrix[i]; 1112 | } 1113 | } 1114 | 1115 | if (params.ordinalMatrix) { 1116 | for (i = 0, j = params.children.length; i < j; i++) { 1117 | x = params.children[i]; 1118 | x["ordinal-group"] = params.ordinalMatrix[i]; 1119 | } 1120 | } 1121 | 1122 | return params; 1123 | } 1124 | 1125 | function ensureStructuralIntegrity (params, instance) { 1126 | var target = params.target; 1127 | 1128 | if (!target.FLX_DOM_ID) { 1129 | target.FLX_DOM_ID = target.FLX_DOM_ID || (++FLX_DOM_ID); 1130 | } 1131 | 1132 | if (!params.nodes) { 1133 | params.nodes = sanitizeChildren(target, target.childNodes); 1134 | } 1135 | 1136 | if (!params.selector) { 1137 | params.selector = buildSelector(target); 1138 | target.setAttribute(FLX_PARENT_ATTR, TRUE); 1139 | } 1140 | 1141 | if (!params.properties) { 1142 | params.properties = []; 1143 | } 1144 | 1145 | if (!params.children) { 1146 | params.children = matchFlexChildren(target, LIBRARY, sanitizeChildren(target, target.childNodes)); 1147 | } 1148 | 1149 | if (!params.nested) { 1150 | params.nested = params.selector + " [" + FLX_PARENT_ATTR + "]"; 1151 | } 1152 | 1153 | params.target = target; 1154 | params._instance = instance; 1155 | 1156 | return params; 1157 | } 1158 | 1159 | selectivizrEngine = (function () { 1160 | var RE_COMMENT = /(\/\*[^*]*\*+([^\/][^*]*\*+)*\/)\s*?/g, 1161 | RE_IMPORT = /@import\s*(?:(?:(?:url\(\s*(['"]?)(.*)\1)\s*\))|(?:(['"])(.*)\3))\s*([^;]*);/g, 1162 | RE_ASSET_URL = /(behavior\s*?:\s*)?\burl\(\s*(["']?)(?!data:)([^"')]+)\2\s*\)/g, 1163 | RE_SELECTOR_GROUP = /((?:^|(?:\s*\})+)(?:\s*@media[^\{]+\{)?)\s*([^\{]*?[\[:][^{]+)/g, 1164 | 1165 | // Whitespace normalization regexp's 1166 | RE_TIDY_TRAILING_WHITESPACE = /([(\[+~])\s+/g, 1167 | RE_TIDY_LEADING_WHITESPACE = /\s+([)\]+~])/g, 1168 | RE_TIDY_CONSECUTIVE_WHITESPACE = /\s+/g, 1169 | RE_TIDY_TRIM_WHITESPACE = /^\s*((?:[\S\s]*\S)?)\s*$/; 1170 | 1171 | // --[ trim() ]--------------------------------------------------------- 1172 | // removes leading, trailing whitespace from a string 1173 | function trim(text) { 1174 | return text.replace(RE_TIDY_TRIM_WHITESPACE, PLACEHOLDER_STRING); 1175 | } 1176 | 1177 | // --[ normalizeWhitespace() ]------------------------------------------ 1178 | // removes leading, trailing and consecutive whitespace from a string 1179 | function normalizeWhitespace(text) { 1180 | return trim(text).replace(RE_TIDY_CONSECUTIVE_WHITESPACE, SPACE_STRING); 1181 | } 1182 | 1183 | // --[ normalizeSelectorWhitespace() ]---------------------------------- 1184 | // tidys whitespace around selector brackets and combinators 1185 | function normalizeSelectorWhitespace(selectorText) { 1186 | return normalizeWhitespace(selectorText.replace(RE_TIDY_TRAILING_WHITESPACE, PLACEHOLDER_STRING).replace(RE_TIDY_LEADING_WHITESPACE, PLACEHOLDER_STRING)); 1187 | } 1188 | 1189 | // --[ patchStyleSheet() ]---------------------------------------------- 1190 | // Scans the passed cssText for selectors that require emulation and 1191 | // creates one or more patches for each matched selector. 1192 | function patchStyleSheet(cssText) { 1193 | return cssText.replace(RE_SELECTOR_GROUP, function (m, prefix, selectorText) { 1194 | var selectorGroups, selector, 1195 | i, j, group; 1196 | 1197 | selectorGroups = selectorText.split(","); 1198 | 1199 | for (i = 0, j = selectorGroups.length; i < j; i++) { 1200 | group = selectorGroups[i]; 1201 | selector = normalizeSelectorWhitespace(group) + SPACE_STRING; 1202 | } 1203 | 1204 | return prefix + selectorGroups.join(","); 1205 | }); 1206 | } 1207 | 1208 | // --[ getXHRObject() ]------------------------------------------------- 1209 | function getXHRObject() { 1210 | if (win.XMLHttpRequest) { 1211 | return new win.XMLHttpRequest(); 1212 | } 1213 | 1214 | try { 1215 | return new win.ActiveXObject("Microsoft.XMLHTTP"); 1216 | } catch (e) { 1217 | return NULL; 1218 | } 1219 | } 1220 | 1221 | function parseInlineStyles ( text ) { 1222 | var reg = /]*>([^<>]*)<\/style[\s]?>/img, 1223 | match = reg.exec(text), 1224 | stylesheets = [], 1225 | rawCSSText; 1226 | 1227 | while (match) { 1228 | rawCSSText = match[1]; 1229 | 1230 | if (rawCSSText) { 1231 | stylesheets.push(rawCSSText); 1232 | } 1233 | 1234 | match = reg.exec(text); 1235 | } 1236 | 1237 | return stylesheets.join("\n\n"); 1238 | } 1239 | 1240 | // --[ loadStyleSheet() ]----------------------------------------------- 1241 | function loadStyleSheet(url) { 1242 | var xhr = getXHRObject(), 1243 | responseText; 1244 | 1245 | xhr.open("GET", url, FALSE); 1246 | xhr.send(); 1247 | 1248 | responseText = (xhr.status === 200) ? xhr.responseText : EMPTY_STRING; 1249 | 1250 | if (url === window.location.href) { 1251 | responseText = parseInlineStyles(responseText); 1252 | } 1253 | 1254 | return responseText; 1255 | } 1256 | 1257 | // --[ resolveUrl() ]--------------------------------------------------- 1258 | // Converts a URL fragment to a fully qualified URL using the specified 1259 | // context URL. Returns null if same-origin policy is broken 1260 | function resolveUrl(url, contextUrl) { 1261 | 1262 | // IE9 returns a false positive sometimes(?) 1263 | if (!url) { 1264 | return; 1265 | } 1266 | 1267 | function getProtocolAndHost(url) { 1268 | return url.substring(0, url.indexOf("/", 8)); 1269 | } 1270 | 1271 | // absolute path 1272 | if (PROTOCOL.test(url)) { 1273 | return getProtocolAndHost(contextUrl) === getProtocolAndHost(url) ? url : NULL; 1274 | } 1275 | 1276 | // root-relative path 1277 | if (url.charAt(0) === "/") { 1278 | return getProtocolAndHost(contextUrl) + url; 1279 | } 1280 | 1281 | // relative path 1282 | var contextUrlPath = contextUrl.split("?")[0]; // ignore query string in the contextUrl 1283 | if (url.charAt(0) !== "?" && contextUrlPath.charAt(contextUrlPath.length - 1) !== "/") { 1284 | contextUrlPath = contextUrlPath.substring(0, contextUrlPath.lastIndexOf("/") + 1); 1285 | } 1286 | 1287 | return contextUrlPath + url; 1288 | } 1289 | 1290 | // --[ parseStyleSheet() ]---------------------------------------------- 1291 | // Downloads the stylesheet specified by the URL, removes it's comments 1292 | // and recursivly replaces @import rules with their contents, ultimately 1293 | // returning the full cssText. 1294 | function parseStyleSheet( url ) { 1295 | if (url) { 1296 | return loadStyleSheet(url).replace(RE_COMMENT, EMPTY_STRING). 1297 | replace(RE_IMPORT, function( match, quoteChar, importUrl, quoteChar2, importUrl2, media ) { 1298 | var cssText = parseStyleSheet(resolveUrl(importUrl || importUrl2, url)); 1299 | return (media) ? "@media " + media + " {" + cssText + "}" : cssText; 1300 | }). 1301 | replace(RE_ASSET_URL, function( match, isBehavior, quoteChar, assetUrl ) { 1302 | quoteChar = quoteChar || EMPTY_STRING; 1303 | return isBehavior ? match : " url(" + quoteChar + resolveUrl(assetUrl, url, true) + quoteChar + ") "; 1304 | }); 1305 | } 1306 | return EMPTY_STRING; 1307 | } 1308 | 1309 | // --[ init() ]--------------------------------------------------------- 1310 | return function () { 1311 | // honour the tag 1312 | var url, stylesheets = [], stylesheet, i, j, 1313 | baseTags = doc.getElementsByTagName("BASE"), 1314 | baseUrl = (baseTags.length > 0) ? baseTags[0].href : doc.location.href, 1315 | externalStyles = doc.styleSheets, 1316 | cssText, tree, flexers; 1317 | 1318 | for (i = 0, j = externalStyles.length; i < j; i++) { 1319 | stylesheet = externalStyles[i]; 1320 | 1321 | if (stylesheet != NULL) { 1322 | stylesheets.push(stylesheet); 1323 | } 1324 | } 1325 | 1326 | // Add self to test for inline styles 1327 | stylesheets.push(window.location); 1328 | 1329 | for (i = 0, j = stylesheets.length; i < j; i++) { 1330 | stylesheet = stylesheets[i]; 1331 | 1332 | if (stylesheet) { 1333 | url = resolveUrl(stylesheet.href, baseUrl); 1334 | 1335 | if (url) { 1336 | cssText = patchStyleSheet(parseStyleSheet(url)); 1337 | } 1338 | 1339 | if (cssText) { 1340 | tree = buildSelectorTree(cssText); 1341 | flexers = findFlexboxElements(tree); 1342 | } 1343 | } 1344 | } 1345 | 1346 | buildFlexieCall(flexers); 1347 | }; 1348 | }()); 1349 | 1350 | // Flexie box constructor 1351 | FLX.box = function (params) { 1352 | return this.renderModel(params); 1353 | }; 1354 | 1355 | FLX.box.prototype = { 1356 | properties : { 1357 | boxModel : function (target, children, params) { 1358 | var selectors, stylesheet, paddingFix, generatedRules, 1359 | i, j, selector; 1360 | 1361 | target.style.display = "block"; 1362 | 1363 | if (BROWSER.IE === 8) { 1364 | target.style.overflow = "hidden"; 1365 | } 1366 | 1367 | // We'll be using floats, so the easiest way to retain layout 1368 | // is the dreaded clear fix: 1369 | if (!params.cleared) { 1370 | selectors = params.selector.split(/\s?,\s?/); 1371 | stylesheet = doc.styleSheets; 1372 | stylesheet = stylesheet[stylesheet.length - 1]; 1373 | paddingFix = "padding-top:" + (getComputedStyle(target, PADDING_TOP, NULL) || "0.1px;"); 1374 | 1375 | generatedRules = [ 1376 | "content: '.'", 1377 | "display: block", 1378 | "height: 0", 1379 | "overflow: hidden" 1380 | ].join(";"); 1381 | 1382 | for (i = 0, j = selectors.length; i < j; i++) { 1383 | selector = selectors[i]; 1384 | 1385 | if (stylesheet.addRule) { 1386 | if (BROWSER.IE < 8) { 1387 | target.style.zoom = "1"; 1388 | 1389 | if (BROWSER.IE === 6) { 1390 | stylesheet.addRule(selector.replace(/\>|\+|\~/g, ""), paddingFix + "zoom:1;", 0); 1391 | } else if (BROWSER.IE === 7) { 1392 | stylesheet.addRule(selector, paddingFix + "display:inline-block;", 0); 1393 | } 1394 | } else { 1395 | stylesheet.addRule(selector, paddingFix, 0); 1396 | stylesheet.addRule(selector + ":before", generatedRules, 0); 1397 | stylesheet.addRule(selector + ":after", generatedRules + ";clear:both;", 0); 1398 | } 1399 | } else if (stylesheet.insertRule) { 1400 | stylesheet.insertRule(selector + "{" + paddingFix + "}", 0); 1401 | stylesheet.insertRule(selector + ":after{" + generatedRules + ";clear:both;}", 0); 1402 | } 1403 | } 1404 | 1405 | params.cleared = TRUE; 1406 | } 1407 | }, 1408 | 1409 | boxDirection : function (target, children, params) { 1410 | var nestedSelector, nested, 1411 | i, j, kid, node; 1412 | 1413 | if ((params.direction === "reverse" && !params.reversed) || (params.direction === "normal" && params.reversed)) { 1414 | children = children.reverse(); 1415 | 1416 | for (i = 0, j = children.length; i < j; i++) { 1417 | kid = children[i]; 1418 | target.appendChild(kid); 1419 | } 1420 | 1421 | // box-direction is inheritable. 1422 | // We need to see if there are any nested flexbox elements 1423 | nestedSelector = LIBRARY(params.nested); 1424 | 1425 | for (i = 0, j = nestedSelector.length; i < j; i++) { 1426 | node = nestedSelector[i]; 1427 | 1428 | nested = FLEX_BOXES[node.FLX_DOM_ID]; 1429 | 1430 | if (nested && nested.direction === INHERIT) { 1431 | nested.direction = params.direction; 1432 | } 1433 | } 1434 | 1435 | params.reversed = !params.reversed; 1436 | } 1437 | }, 1438 | 1439 | boxOrient : function (target, children, params) { 1440 | var self = this, wide, high, 1441 | i, j, kid; 1442 | 1443 | wide = { 1444 | pos : "marginLeft", 1445 | opp : "marginRight", 1446 | dim : "width", 1447 | out : "offsetWidth", 1448 | func : clientWidth, 1449 | pad : [PADDING_LEFT, PADDING_RIGHT, BORDER_LEFT, BORDER_RIGHT] 1450 | }; 1451 | 1452 | high = { 1453 | pos : "marginTop", 1454 | opp : "marginBottom", 1455 | dim : "height", 1456 | out : "offsetHeight", 1457 | func : clientHeight, 1458 | pad : [PADDING_TOP, PADDING_BOTTOM, BORDER_TOP, BORDER_BOTTOM] 1459 | }; 1460 | 1461 | if (!SUPPORT) { 1462 | for (i = 0, j = children.length; i < j; i++) { 1463 | kid = children[i]; 1464 | 1465 | kid.style[(BROWSER.IE >= 9) ? "cssFloat" : "styleFloat"] = LEFT; 1466 | 1467 | if (params.orient === VERTICAL || params.orient === BLOCK_AXIS) { 1468 | kid.style.clear = LEFT; 1469 | } 1470 | 1471 | if (BROWSER.IE === 6) { 1472 | kid.style.display = "inline"; 1473 | } 1474 | } 1475 | } 1476 | 1477 | switch (params.orient) { 1478 | case VERTICAL : 1479 | case BLOCK_AXIS: 1480 | self.props = high; 1481 | self.anti = wide; 1482 | break; 1483 | 1484 | default : 1485 | self.props = wide; 1486 | self.anti = high; 1487 | break; 1488 | } 1489 | }, 1490 | 1491 | boxOrdinalGroup : function (target, children, params) { 1492 | var organizeChildren, 1493 | matrix; 1494 | 1495 | if (!children.length) { 1496 | return; 1497 | } 1498 | 1499 | organizeChildren = function (matrix) { 1500 | var keys = matrix.keys, 1501 | iterator = params.reversed ? keys : keys.reverse(), 1502 | i, j, key, k, l, kid; 1503 | 1504 | for (i = 0, j = iterator.length; i < j; i++) { 1505 | key = iterator[i]; 1506 | 1507 | for (k = 0, l = children.length; k < l; k++) { 1508 | kid = children[k]; 1509 | 1510 | if (key === kid.getAttribute("data-ordinal-group")) { 1511 | target.appendChild(kid); 1512 | } 1513 | } 1514 | } 1515 | }; 1516 | 1517 | matrix = createMatchMatrix(params.children, children, TRUE); 1518 | 1519 | if (matrix.keys.length > 1) { 1520 | organizeChildren(matrix); 1521 | } 1522 | }, 1523 | 1524 | boxFlex : function (target, children, params) { 1525 | var self = this, 1526 | testForRestrictiveProperties, 1527 | findTotalWhitespace, 1528 | distributeRatio, 1529 | matrix, 1530 | restrict, 1531 | whitespace, 1532 | distro; 1533 | 1534 | if (!children.length) { 1535 | return; 1536 | } 1537 | 1538 | testForRestrictiveProperties = function (matrix) { 1539 | var flexers = matrix.groups, 1540 | keys = matrix.keys, 1541 | max, i, j, key, 1542 | k, l, x, m, n, rule; 1543 | 1544 | for (i = 0, j = keys.length; i < j; i++) { 1545 | key = keys[i]; 1546 | 1547 | for (k = 0, l = flexers[key].length; k < l; k++) { 1548 | x = flexers[key][k]; 1549 | max = NULL; 1550 | 1551 | for (m = 0, n = x.properties.length; m < n; m++) { 1552 | rule = x.properties[m]; 1553 | 1554 | if ((RESTRICTIVE_PROPERTIES).test(rule.property)) { 1555 | max = parseFloat(rule.value); 1556 | } 1557 | } 1558 | 1559 | if (!max || x.match[self.props.out] > max) { 1560 | appendPixelValue(x.match, self.props.pos, NULL); 1561 | } 1562 | 1563 | } 1564 | } 1565 | }; 1566 | 1567 | findTotalWhitespace = function (matrix) { 1568 | var groupDimension = 0, 1569 | whitespace, 1570 | ration, 1571 | i, j, kid, 1572 | k, l, pad; 1573 | 1574 | for (i = 0, j = children.length; i < j; i++) { 1575 | kid = children[i]; 1576 | 1577 | groupDimension += getComputedStyle(kid, self.props.dim, TRUE); 1578 | 1579 | for (k = 0, l = self.props.pad.length; k < l; k++) { 1580 | pad = self.props.pad[k]; 1581 | 1582 | groupDimension += getComputedStyle(kid, pad, TRUE); 1583 | } 1584 | 1585 | groupDimension += getComputedStyle(kid, self.props.pos, TRUE); 1586 | groupDimension += getComputedStyle(kid, self.props.opp, TRUE); 1587 | } 1588 | 1589 | whitespace = target[self.props.out] - groupDimension; 1590 | 1591 | for (i = 0, j = self.props.pad.length; i < j; i++) { 1592 | pad = self.props.pad[i]; 1593 | whitespace -= getComputedStyle(target, pad, TRUE); 1594 | } 1595 | 1596 | ration = (whitespace / matrix.total); 1597 | 1598 | return { 1599 | whitespace : whitespace, 1600 | ration : ration 1601 | }; 1602 | }; 1603 | 1604 | distributeRatio = function (matrix, whitespace) { 1605 | var flexers = matrix.groups, 1606 | keys = matrix.keys, 1607 | flex, specificity, 1608 | ration = whitespace.ration, 1609 | widthRation, trueDim, newDimension, 1610 | i, j, key, k, l, x; 1611 | 1612 | for (i = 0, j = keys.length; i < j; i++) { 1613 | key = keys[i]; 1614 | widthRation = (ration * key); 1615 | 1616 | for (k = 0, l = flexers[key].length; k < l; k++) { 1617 | x = flexers[key][k]; 1618 | 1619 | if (x.match) { 1620 | flex = x.match.getAttribute("data-flex"); 1621 | specificity = x.match.getAttribute("data-specificity"); 1622 | 1623 | if (!flex || (specificity <= x.flexSpecificity)) { 1624 | x.match.setAttribute("data-flex", key); 1625 | x.match.setAttribute("data-specificity", x.flexSpecificity); 1626 | 1627 | trueDim = getComputedStyle(x.match, self.props.dim, TRUE); 1628 | newDimension = Math.max(0, (trueDim + widthRation)); 1629 | appendPixelValue(x.match, self.props.dim, newDimension); 1630 | } 1631 | } 1632 | } 1633 | } 1634 | }; 1635 | 1636 | matrix = createMatchMatrix(params.children, children, NULL); 1637 | 1638 | if (matrix.total) { 1639 | params.hasFlex = TRUE; 1640 | 1641 | restrict = testForRestrictiveProperties(matrix); 1642 | whitespace = findTotalWhitespace(matrix); 1643 | 1644 | // Distribute the calculated ratios among the children 1645 | distro = distributeRatio(matrix, whitespace); 1646 | } 1647 | }, 1648 | 1649 | boxAlign : function (target, children, params) { 1650 | var self = this, 1651 | targetDimension, 1652 | kidDimension, 1653 | flexCheck = parentFlex(target), 1654 | i, j, pad, k, l, kid; 1655 | 1656 | if (!SUPPORT && !flexCheck.flex && (params.orient === VERTICAL || params.orient === BLOCK_AXIS)) { 1657 | if (!dimensionValues(target, self.anti.dim)) { 1658 | appendPixelValue(target, self.anti.dim, NULL); 1659 | } 1660 | appendPixelValue(children, self.anti.dim, NULL); 1661 | } 1662 | 1663 | // Remove padding / border from target dimension 1664 | targetDimension = target[self.anti.out]; 1665 | 1666 | for (i = 0, j = self.anti.pad.length; i < j; i++) { 1667 | pad = self.anti.pad[i]; 1668 | targetDimension -= getComputedStyle(target, pad, TRUE); 1669 | } 1670 | 1671 | switch (params.align) { 1672 | case "start" : 1673 | break; 1674 | 1675 | case "end" : 1676 | for (i = 0, j = children.length; i < j; i++) { 1677 | kid = children[i]; 1678 | 1679 | kidDimension = targetDimension - kid[self.anti.out]; 1680 | kidDimension -= getComputedStyle(kid, self.anti.opp, TRUE); 1681 | appendPixelValue(kid, self.anti.pos, kidDimension); 1682 | } 1683 | break; 1684 | 1685 | case "center" : 1686 | for (i = 0, j = children.length; i < j; i++) { 1687 | kid = children[i]; 1688 | 1689 | kidDimension = (targetDimension - kid[self.anti.out]) / 2; 1690 | appendPixelValue(kid, self.anti.pos, kidDimension); 1691 | } 1692 | break; 1693 | 1694 | default : 1695 | for (i = 0, j = children.length; i < j; i++) { 1696 | kid = children[i]; 1697 | 1698 | switch (kid.nodeName.toLowerCase()) { 1699 | case "button" : 1700 | case "input" : 1701 | case "select" : 1702 | break; 1703 | 1704 | default : 1705 | var subtract = 0; 1706 | 1707 | for (k = 0, l = self.anti.pad.length; k < l; k++) { 1708 | pad = self.anti.pad[k]; 1709 | 1710 | subtract += getComputedStyle(kid, pad, TRUE); 1711 | subtract += getComputedStyle(target, pad, TRUE); 1712 | } 1713 | 1714 | kid.style[self.anti.dim] = "100%"; 1715 | kidDimension = kid[self.anti.out] - subtract; 1716 | appendPixelValue(kid, self.anti.dim, NULL); 1717 | 1718 | kidDimension = targetDimension; 1719 | kidDimension -= getComputedStyle(kid, self.anti.pos, TRUE); 1720 | 1721 | for (k = 0, l = self.anti.pad.length; k < l; k++) { 1722 | pad = self.anti.pad[k]; 1723 | 1724 | kidDimension -= getComputedStyle(kid, pad, TRUE); 1725 | } 1726 | 1727 | kidDimension -= getComputedStyle(kid, self.anti.opp, TRUE); 1728 | kidDimension = Math.max(0, kidDimension); 1729 | 1730 | appendPixelValue(kid, self.anti.dim, kidDimension); 1731 | break; 1732 | } 1733 | } 1734 | break; 1735 | } 1736 | }, 1737 | 1738 | boxPack : function (target, children, params) { 1739 | var self = this, 1740 | groupDimension = 0, 1741 | firstComputedMargin = 0, 1742 | targetPadding = 0, 1743 | totalDimension, 1744 | fractionedDimension, 1745 | currentDimension, 1746 | remainder, 1747 | length = children.length - 1, 1748 | kid, i, j, value, pad; 1749 | 1750 | for (i = 0, j = children.length; i < j; i++) { 1751 | kid = children[i]; 1752 | 1753 | groupDimension += kid[self.props.out]; 1754 | groupDimension += getComputedStyle(kid, self.props.pos, TRUE); 1755 | groupDimension += getComputedStyle(kid, self.props.opp, TRUE); 1756 | } 1757 | 1758 | firstComputedMargin = getComputedStyle(children[0], self.props.pos, TRUE); 1759 | totalDimension = target[self.props.out] - groupDimension; 1760 | 1761 | // Remove padding / border from target dimension 1762 | for (i = 0, j = self.props.pad.length; i < j; i++) { 1763 | pad = self.props.pad[i]; 1764 | totalDimension -= getComputedStyle(target, pad, TRUE); 1765 | } 1766 | 1767 | // If totalDimension is less than 0, we have a problem... 1768 | if (totalDimension < 0) { 1769 | totalDimension = Math.max(0, totalDimension); 1770 | } 1771 | 1772 | switch (params.pack) { 1773 | case "end" : 1774 | appendPixelValue(children[0], self.props.pos, targetPadding + firstComputedMargin + totalDimension); 1775 | break; 1776 | 1777 | case "center" : 1778 | if (targetPadding) { 1779 | targetPadding /= 2; 1780 | } 1781 | 1782 | appendPixelValue(children[0], self.props.pos, targetPadding + firstComputedMargin + Math.floor(totalDimension / 2)); 1783 | break; 1784 | 1785 | case "justify" : 1786 | fractionedDimension = Math.floor((targetPadding + totalDimension) / length); 1787 | remainder = (fractionedDimension * length) - totalDimension; 1788 | 1789 | i = children.length - 1; 1790 | 1791 | while (i) { 1792 | kid = children[i]; 1793 | currentDimension = fractionedDimension; 1794 | 1795 | if (remainder) { 1796 | currentDimension++; 1797 | remainder++; 1798 | } 1799 | 1800 | value = getComputedStyle(kid, self.props.pos, TRUE) + currentDimension; 1801 | appendPixelValue(kid, self.props.pos, value); 1802 | 1803 | i--; 1804 | } 1805 | 1806 | break; 1807 | } 1808 | 1809 | target.style.overflow = ""; 1810 | } 1811 | }, 1812 | 1813 | setup : function (target, children, params) { 1814 | var self = this, matrix, flexCheck, 1815 | key, func; 1816 | 1817 | if (!target || !children || !params) { 1818 | return; 1819 | } 1820 | 1821 | if (SUPPORT && SUPPORT.partialSupport) { 1822 | matrix = createMatchMatrix(params.children, children, NULL); 1823 | flexCheck = parentFlex(target); 1824 | children = sanitizeChildren(target, target.childNodes); 1825 | 1826 | self.properties.boxOrient.call(self, target, children, params); 1827 | 1828 | if (!matrix.total || !LIBRARY(params.nested).length) { 1829 | if ((params.align === "stretch") && !SUPPORT.boxAlignStretch && (!flexCheck.nested || !flexCheck.flex)) { 1830 | self.properties.boxAlign.call(self, target, children, params); 1831 | } 1832 | 1833 | if ((params.pack === "justify") && !SUPPORT.boxPackJustify && !matrix.total) { 1834 | self.properties.boxPack.call(self, target, children, params); 1835 | } 1836 | } 1837 | } else if (!SUPPORT) { 1838 | for (key in self.properties) { 1839 | if (self.properties.hasOwnProperty(key)) { 1840 | func = self.properties[key]; 1841 | func.call(self, target, sanitizeChildren(target, target.childNodes), params); 1842 | } 1843 | } 1844 | } 1845 | }, 1846 | 1847 | trackDOM : function (params) { 1848 | attachResizeListener(this, params); 1849 | }, 1850 | 1851 | updateModel : function (params) { 1852 | var self = this, 1853 | target = params.target, 1854 | children = params.nodes; 1855 | 1856 | // Null properties 1857 | cleanPositioningProperties(children); 1858 | 1859 | if (params.flexMatrix || params.ordinalMatrix) { 1860 | params = updateChildValues(params); 1861 | } 1862 | 1863 | self.setup(target, children, params); 1864 | self.bubbleUp(target, params); 1865 | }, 1866 | 1867 | renderModel : function (params) { 1868 | var self = this, 1869 | target = params.target, 1870 | nodes = target.childNodes; 1871 | 1872 | // Sanity check. 1873 | if (!target.length && !nodes) { 1874 | return false; 1875 | } 1876 | 1877 | params = ensureStructuralIntegrity(params, this); 1878 | 1879 | // Setup properties 1880 | self.updateModel(params); 1881 | 1882 | // Resize / DOM Polling Events 1883 | // Delay for an instant because IE6 is insane. 1884 | win.setTimeout(function () { 1885 | self.trackDOM(params); 1886 | }, 0); 1887 | 1888 | return self; 1889 | }, 1890 | 1891 | bubbleUp : function (target, params) { 1892 | var self = this, flex, 1893 | parent = params.target.parentNode; 1894 | 1895 | while (parent) { 1896 | flex = FLEX_BOXES[parent.FLX_DOM_ID]; 1897 | 1898 | if (flex) { 1899 | cleanPositioningProperties(flex.nodes); 1900 | self.setup(flex.target, flex.nodes, flex); 1901 | } 1902 | 1903 | parent = parent.parentNode; 1904 | } 1905 | } 1906 | }; 1907 | 1908 | FLX.updateInstance = function (target, params) { 1909 | var box, key; 1910 | 1911 | if (target) { 1912 | box = FLEX_BOXES[target.FLX_DOM_ID]; 1913 | 1914 | if (box && box._instance) { 1915 | box._instance.updateModel(box); 1916 | } else if (!box) { 1917 | box = new FLX.box(params); 1918 | } 1919 | } else { 1920 | for (key in FLEX_BOXES) { 1921 | if (FLEX_BOXES.hasOwnProperty(key)) { 1922 | box = FLEX_BOXES[key]; 1923 | 1924 | if (box && box._instance) { 1925 | box._instance.updateModel(box); 1926 | } 1927 | } 1928 | } 1929 | } 1930 | }; 1931 | 1932 | FLX.getInstance = function (target) { 1933 | return FLEX_BOXES[target.FLX_DOM_ID]; 1934 | }; 1935 | 1936 | FLX.destroyInstance = function (target) { 1937 | var box, destroy, i, j, x, key; 1938 | 1939 | destroy = function (box) { 1940 | box.target.FLX_DOM_ID = NULL; 1941 | box.target.style.cssText = EMPTY_STRING; 1942 | 1943 | for (i = 0, j = box.children.length; i < j; i++) { 1944 | x = box.children[i]; 1945 | x.match.style.cssText = EMPTY_STRING; 1946 | } 1947 | }; 1948 | 1949 | if (target) { 1950 | box = FLEX_BOXES[target.FLX_DOM_ID]; 1951 | 1952 | if (box) { 1953 | destroy(box); 1954 | } 1955 | } else { 1956 | for (key in FLEX_BOXES) { 1957 | if (FLEX_BOXES.hasOwnProperty(key)) { 1958 | destroy(FLEX_BOXES[key]); 1959 | } 1960 | } 1961 | 1962 | FLEX_BOXES = []; 1963 | } 1964 | }; 1965 | 1966 | FLX.flexboxSupport = function () { 1967 | var partialSupportGrid = {}, 1968 | height = 100, 1969 | childHeight, 1970 | dummy = doc.createElement("flxbox"), 1971 | child = '', 1972 | tests, result, key, value; 1973 | 1974 | dummy.style.width = dummy.style.height = height + "px"; 1975 | dummy.innerHTML = (child + child + child); 1976 | 1977 | appendProperty(dummy, "display", "box", NULL); 1978 | appendProperty(dummy, "box-align", "stretch", TRUE); 1979 | appendProperty(dummy, "box-pack", "justify", TRUE); 1980 | 1981 | doc.body.appendChild(dummy); 1982 | childHeight = dummy.firstChild.offsetHeight; 1983 | 1984 | tests = { 1985 | boxAlignStretch : function () { 1986 | return (childHeight === 100); 1987 | }, 1988 | 1989 | boxPackJustify : function () { 1990 | var totalOffset = 0, 1991 | i, j; 1992 | 1993 | for (i = 0, j = dummy.childNodes.length; i < j; i++) { 1994 | totalOffset += dummy.childNodes[i].offsetLeft; 1995 | } 1996 | 1997 | return (totalOffset === 135); 1998 | } 1999 | }; 2000 | 2001 | for (key in tests) { 2002 | if (tests.hasOwnProperty(key)) { 2003 | value = tests[key]; 2004 | 2005 | result = value(); 2006 | 2007 | if (!result) { 2008 | partialSupportGrid.partialSupport = TRUE; 2009 | } 2010 | 2011 | partialSupportGrid[key] = result; 2012 | } 2013 | } 2014 | 2015 | doc.body.removeChild(dummy); 2016 | return ~ (dummy.style.display).indexOf("box") ? partialSupportGrid : FALSE; 2017 | }; 2018 | 2019 | FLX.init = function () { 2020 | FLX.flexboxSupported = SUPPORT = FLX.flexboxSupport(); 2021 | 2022 | if ((!SUPPORT || SUPPORT.partialSupport) && LIBRARY) { 2023 | selectivizrEngine(); 2024 | } 2025 | }; 2026 | 2027 | // Flexie Version 2028 | FLX.version = "1.0.3"; 2029 | 2030 | // Load when the DOM is ready 2031 | attachLoadMethod(FLX.init); 2032 | 2033 | return FLX; 2034 | }(this, document)); 2035 | -------------------------------------------------------------------------------- /test/css/demo.css: -------------------------------------------------------------------------------- 1 | /* Demo Styling. Pay no attention to the CSS behind the box */ 2 | /* (See what I did there?) */ 3 | 4 | body, html { 5 | width: 100%; 6 | height: 100%; 7 | padding: 0; 8 | margin: 0; 9 | font: normal 12px Arial, sans-serif; 10 | } 11 | 12 | #box-wrap-vertical, #box-wrap-horizontal { 13 | margin: 20px auto; 14 | width: 700px; 15 | height: 300px; 16 | background: #666; 17 | position: relative; 18 | } 19 | 20 | #box-wrap-vertical div, #box-wrap-horizontal div { 21 | width: 50px; 22 | height: 100px; 23 | line-height: 100px; 24 | text-align: center; 25 | background: #999; 26 | white-space: nowrap; 27 | border: solid pink; 28 | } 29 | 30 | #box-wrap-vertical div { 31 | width: auto; 32 | height: 20px; 33 | line-height: 20px; 34 | } 35 | -------------------------------------------------------------------------------- /test/css/test.css: -------------------------------------------------------------------------------- 1 | /* 2 | Properties to test: 3 | (via ) 4 | 5 | Parent properties: 6 | -------------------------- 7 | 8 | + display: box 9 | - This new value for the display style opts this element and its immediate children into the flexible box model. 10 | The flexbox model works only with immediate children. 11 | 12 | + box-orient 13 | - How should the box's children be aligned? 14 | - Values: 15 | + horizonal (default) 16 | - vertical 17 | - inherit 18 | + inline-axis (maps to horizontal) 19 | - block-axis (maps to vertical) 20 | 21 | + box-align 22 | - Basically box-pack's brother property. 23 | Sets how the box's children are aligned in the box. 24 | If the orientation is horizontal it will decide the alignment vertically and vice-versa. 25 | - Values: 26 | + stretch (default) 27 | + start 28 | + end 29 | + center 30 | - baseline 31 | 32 | + box-direction 33 | - Children within a horizontally oriented box are, by default, displayed from left to right in the same 34 | order as they appear in the source document. Children within a vertically oriented box are displayed 35 | top to bottom in the same order. The box-direction and box-ordinal-group properties may be used to 36 | change this ordering. 37 | - Values: 38 | + normal (default) 39 | + reverse 40 | - inherit 41 | 42 | + box-pack 43 | - Sets the alignment of the box along the box-orient axis. 44 | So if box-orient is horizontal it will chose how the box's children are aligned horizontally, and vice-versa. 45 | - Values: 46 | + start (default) 47 | + end 48 | + center 49 | + justify 50 | 51 | Child properties: 52 | -------------------------- 53 | + box-flex 54 | - The flexibility ratio for this child. 55 | If a child had 1 and its sibling had 2, any additional space in the parent box would be consumed 56 | twice as much by the sibling. It defaults to 0 which is inflexible. 57 | - Values: 58 | - 0 (default) 59 | - Any integer 60 | 61 | box-ordinal-group 62 | - 63 | - Values: 64 | - 1 (default) 65 | - Any integer 66 | 67 | ??? properties: 68 | -------------------------- 69 | box-flex-group 70 | box-lines 71 | 72 | */ 73 | 74 | /* Demo Styling */ 75 | @import url("demo.css"); 76 | 77 | #box-wrap-horizontal { 78 | /* Display Box */ 79 | display: -moz-box; 80 | display: -webkit-box; 81 | display: -ms-box; 82 | display: box; 83 | 84 | /* -webkit-box-align: start; 85 | -moz-box-align: start; 86 | -ms-box-align: start; 87 | box-align: start; 88 | 89 | -webkit-box-align: stretch; 90 | -moz-box-align: stretch; 91 | -ms-box-align: stretch; 92 | box-align: stretch; 93 | 94 | -webkit-box-pack: justify; 95 | -moz-box-pack: justify; 96 | -ms-box-pack: justify; 97 | box-pack: justify;*/ 98 | } 99 | 100 | #box-wrap-horizontal div { 101 | margin: 15px 5px 20px 10px; 102 | padding: 10px 5px 25px 20px; 103 | border-width: 9px 4px 6px 13px; 104 | } 105 | 106 | #box-wrap-horizontal #box-1 { 107 | margin-left: 25px; 108 | } 109 | 110 | #box-wrap-horizontal #box-5 { 111 | margin-right: 25px; 112 | } 113 | 114 | #box-wrap-vertical { 115 | /* Display Box */ 116 | display: -moz-box; 117 | display: -webkit-box; 118 | display: -ms-box; 119 | display: box; 120 | 121 | -webkit-box-orient: vertical; 122 | -moz-box-orient: vertical; 123 | -ms-box-orient: vertical; 124 | box-orient: vertical; 125 | 126 | /* -webkit-box-align: stretch; 127 | -moz-box-align: stretch; 128 | -ms-box-align: stretch; 129 | box-align: stretch; 130 | 131 | -webkit-box-pack: justify; 132 | -moz-box-pack: justify; 133 | -ms-box-pack: justify; 134 | box-pack: justify;*/ 135 | } 136 | 137 | #box-wrap-vertical div { 138 | margin: 8px 2px 5px 4px; 139 | padding: 5px 4px 3px 2px; 140 | border-width: 8px 2px 7px 6px; 141 | } 142 | -------------------------------------------------------------------------------- /test/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Flexie | Unit Tests 6 | 7 | 8 | 9 | 10 |
11 |
Box 1
12 |
Box 2
13 |
Box 3
14 |
Box 4
15 |
Box 5
16 |
17 | 18 |
19 |
Box 6
20 |
Box 7
21 |
Box 8
22 |
Box 9
23 |
Box 10
24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /vendor/google-compiler/COPYING: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /vendor/google-compiler/README: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009 The Closure Compiler Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // 18 | // Contents 19 | // 20 | 21 | The Closure Compiler performs checking, instrumentation, and 22 | optimizations on JavaScript code. The purpose of this README is to 23 | explain how to build and run the Closure Compiler. 24 | 25 | The Closure Compiler requires Java 6 or higher. 26 | http://www.java.com/ 27 | 28 | 29 | // 30 | // Building The Closure Compiler 31 | // 32 | 33 | There are three ways to get a Closure Compiler executable. 34 | 35 | 1) Use one we built for you. 36 | 37 | Pre-built Closure binaries can be found at 38 | http://code.google.com/p/closure-compiler/downloads/list 39 | 40 | 41 | 2) Check out the source and build it with Apache Ant. 42 | 43 | First, check out the full source tree of the Closure Compiler. There 44 | are instructions on how to do this at the project site. 45 | http://code.google.com/p/closure-compiler/source/checkout 46 | 47 | Apache Ant is a cross-platform build tool. 48 | http://ant.apache.org/ 49 | 50 | At the root of the source tree, there is an Ant file named 51 | build.xml. To use it, navigate to the same directory and type the 52 | command 53 | 54 | ant jar 55 | 56 | This will produce a jar file called "build/compiler.jar". 57 | 58 | 59 | 3) Check out the source and build it with Eclipse. 60 | 61 | Eclipse is a cross-platform IDE. 62 | http://www.eclipse.org/ 63 | 64 | Under Eclipse's File menu, click "New > Project ..." and create a 65 | "Java Project." You will see an options screen. Give the project a 66 | name, select "Create project from existing source," and choose the 67 | root of the checked-out source tree as the existing directory. Verify 68 | that you are using JRE version 6 or higher. 69 | 70 | Eclipse can use the build.xml file to discover rules. When you 71 | navigate to the build.xml file, you will see all the build rules in 72 | the "Outline" pane. Run the "jar" rule to build the compiler in 73 | build/compiler.jar. 74 | 75 | 76 | // 77 | // Running The Closure Compiler 78 | // 79 | 80 | Once you have the jar binary, running the Closure Compiler is straightforward. 81 | 82 | On the command line, type 83 | 84 | java -jar compiler.jar 85 | 86 | This starts the compiler in interactive mode. Type 87 | 88 | var x = 17 + 25; 89 | 90 | then hit "Enter", then hit "Ctrl-Z" (on Windows) or "Ctrl-D" (on Mac or Linux) 91 | and "Enter" again. The Compiler will respond: 92 | 93 | var x=42; 94 | 95 | The Closure Compiler has many options for reading input from a file, 96 | writing output to a file, checking your code, and running 97 | optimizations. To learn more, type 98 | 99 | java -jar compiler.jar --help 100 | 101 | You can read more detailed documentation about the many flags at 102 | http://code.google.com/closure/compiler/docs/gettingstarted_app.html 103 | 104 | 105 | // 106 | // Compiling Multiple Scripts 107 | // 108 | 109 | If you have multiple scripts, you should compile them all together with 110 | one compile command. 111 | 112 | java -jar compiler.jar --js=in1.js --js=in2.js ... --js_output_file=out.js 113 | 114 | The Closure Compiler will concatenate the files in the order they're 115 | passed at the command line. 116 | 117 | If you need to compile many, many scripts together, you may start to 118 | run into problems with managing dependencies between scripts. You 119 | should check out the Closure Library. It contains functions for 120 | enforcing dependencies between scripts, and a tool called calcdeps.py 121 | that knows how to give scripts to the Closure Compiler in the right 122 | order. 123 | 124 | http://code.google.com/p/closure-library/ 125 | 126 | // 127 | // Licensing 128 | // 129 | 130 | Unless otherwise stated, all source files are licensed under 131 | the Apache License, Version 2.0. 132 | 133 | 134 | ----- 135 | Code under: 136 | src/com/google/javascript/rhino 137 | test/com/google/javascript/rhino 138 | 139 | URL: http://www.mozilla.org/rhino 140 | Version: 1.5R3, with heavy modifications 141 | License: Netscape Public License and MPL / GPL dual license 142 | 143 | Description: A partial copy of Mozilla Rhino. Mozilla Rhino is an 144 | implementation of JavaScript for the JVM. The JavaScript parser and 145 | the parse tree data structures were extracted and modified 146 | significantly for use by Google's JavaScript compiler. 147 | 148 | Local Modifications: The packages have been renamespaced. All code not 149 | relavant to parsing has been removed. A JSDoc parser and static typing 150 | system have been added. 151 | 152 | 153 | ----- 154 | Code in: 155 | lib/libtrunk_rhino_parser_jarjared.jar 156 | 157 | Rhino 158 | URL: http://www.mozilla.org/rhino 159 | Version: Trunk 160 | License: Netscape Public License and MPL / GPL dual license 161 | 162 | Description: Mozilla Rhino is an implementation of JavaScript for the JVM. 163 | 164 | Local Modifications: None. We've used JarJar to renamespace the code 165 | post-compilation. See: 166 | http://code.google.com/p/jarjar/ 167 | 168 | 169 | ----- 170 | Code in: 171 | lib/args4j.jar 172 | 173 | Args4j 174 | URL: https://args4j.dev.java.net/ 175 | Version: 2.0.12 176 | License: MIT 177 | 178 | Description: 179 | args4j is a small Java class library that makes it easy to parse command line 180 | options/arguments in your CUI application. 181 | 182 | Local Modifications: None. 183 | 184 | 185 | ----- 186 | Code in: 187 | lib/guava.jar 188 | 189 | Guava Libraries 190 | URL: http://code.google.com/p/guava-libraries/ 191 | Version: R7 192 | License: Apache License 2.0 193 | 194 | Description: Google's core Java libraries. 195 | 196 | Local Modifications: None. 197 | 198 | 199 | ----- 200 | Code in: 201 | lib/jsr305.jar 202 | 203 | Annotations for software defect detection 204 | URL: http://code.google.com/p/jsr-305/ 205 | Version: svn revision 47 206 | License: BSD License 207 | 208 | Description: Annotations for software defect detection. 209 | 210 | Local Modifications: None. 211 | 212 | 213 | ---- 214 | Code in: 215 | lib/junit.jar 216 | 217 | JUnit 218 | URL: http://sourceforge.net/projects/junit/ 219 | Version: 4.8.2 220 | License: Common Public License 1.0 221 | 222 | Description: A framework for writing and running automated tests in Java. 223 | 224 | Local Modifications: None. 225 | 226 | 227 | --- 228 | Code in: 229 | lib/protobuf-java.jar 230 | 231 | Protocol Buffers 232 | URL: http://code.google.com/p/protobuf/ 233 | Version: 2.3.0 234 | License: New BSD License 235 | 236 | Description: Supporting libraries for protocol buffers, 237 | an encoding of structured data. 238 | 239 | Local Modifications: None 240 | 241 | 242 | --- 243 | Code in: 244 | lib/ant.jar 245 | lib/ant-launcher.jar 246 | 247 | URL: http://ant.apache.org/bindownload.cgi 248 | Version: 1.8.1 249 | License: Apache License 2.0 250 | Description: 251 | Ant is a Java based build tool. In theory it is kind of like "make" 252 | without make's wrinkles and with the full portability of pure java code. 253 | 254 | Local Modifications: None 255 | 256 | 257 | --- 258 | Code in: 259 | lib/json.jar 260 | URL: http://json.org/java/index.html 261 | Version: JSON version 20090211 262 | License: MIT license 263 | Description: 264 | JSON is a set of java files for use in transmitting data in JSON format. 265 | 266 | Local Modifications: None 267 | 268 | --- 269 | Code in: 270 | tools/maven-ant-tasks-2.1.1.jar 271 | URL: http://maven.apache.org 272 | Version 2.1.1 273 | License: Apache License 2.0 274 | Description: 275 | Maven Ant tasks are used to manage dependencies and to install/deploy to 276 | maven repositories. 277 | 278 | Local Modifications: None 279 | -------------------------------------------------------------------------------- /vendor/google-compiler/compiler.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doctyper/flexie/ba0dd6a2f7a2ed4127090062cabb70dc2cd8b6b7/vendor/google-compiler/compiler.jar -------------------------------------------------------------------------------- /vendor/yuicompressor/README: -------------------------------------------------------------------------------- 1 | ============================================================================== 2 | YUI Compressor 3 | ============================================================================== 4 | 5 | NAME 6 | 7 | YUI Compressor - The Yahoo! JavaScript and CSS Compressor 8 | 9 | SYNOPSIS 10 | 11 | Usage: java -jar yuicompressor-x.y.z.jar [options] [input file] 12 | 13 | Global Options 14 | -h, --help Displays this information 15 | --type Specifies the type of the input file 16 | --charset Read the input file using 17 | --line-break Insert a line break after the specified column number 18 | -v, --verbose Display informational messages and warnings 19 | -o Place the output into . Defaults to stdout. 20 | 21 | JavaScript Options 22 | --nomunge Minify only, do not obfuscate 23 | --preserve-semi Preserve all semicolons 24 | --disable-optimizations Disable all micro optimizations 25 | 26 | DESCRIPTION 27 | 28 | The YUI Compressor is a JavaScript compressor which, in addition to removing 29 | comments and white-spaces, obfuscates local variables using the smallest 30 | possible variable name. This obfuscation is safe, even when using constructs 31 | such as 'eval' or 'with' (although the compression is not optimal is those 32 | cases) Compared to jsmin, the average savings is around 20%. 33 | 34 | The YUI Compressor is also able to safely compress CSS files. The decision 35 | on which compressor is being used is made on the file extension (js or css) 36 | 37 | GLOBAL OPTIONS 38 | 39 | -h, --help 40 | Prints help on how to use the YUI Compressor 41 | 42 | --line-break 43 | Some source control tools don't like files containing lines longer than, 44 | say 8000 characters. The linebreak option is used in that case to split 45 | long lines after a specific column. It can also be used to make the code 46 | more readable, easier to debug (especially with the MS Script Debugger) 47 | Specify 0 to get a line break after each semi-colon in JavaScript, and 48 | after each rule in CSS. 49 | 50 | --type js|css 51 | The type of compressor (JavaScript or CSS) is chosen based on the 52 | extension of the input file name (.js or .css) This option is required 53 | if no input file has been specified. Otherwise, this option is only 54 | required if the input file extension is neither 'js' nor 'css'. 55 | 56 | --charset character-set 57 | If a supported character set is specified, the YUI Compressor will use it 58 | to read the input file. Otherwise, it will assume that the platform's 59 | default character set is being used. The output file is encoded using 60 | the same character set. 61 | 62 | -o outfile 63 | Place output in file outfile. If not specified, the YUI Compressor will 64 | default to the standard output, which you can redirect to a file. 65 | 66 | -v, --verbose 67 | Display informational messages and warnings. 68 | 69 | JAVASCRIPT ONLY OPTIONS 70 | 71 | --nomunge 72 | Minify only. Do not obfuscate local symbols. 73 | 74 | --preserve-semi 75 | Preserve unnecessary semicolons (such as right before a '}') This option 76 | is useful when compressed code has to be run through JSLint (which is the 77 | case of YUI for example) 78 | 79 | --disable-optimizations 80 | Disable all the built-in micro optimizations. 81 | 82 | NOTES 83 | 84 | + If no input file is specified, it defaults to stdin. 85 | 86 | + The YUI Compressor requires Java version >= 1.4. 87 | 88 | + It is possible to prevent a local variable, nested function or function 89 | argument from being obfuscated by using "hints". A hint is a string that 90 | is located at the very beginning of a function body like so: 91 | 92 | function fn (arg1, arg2, arg3) { 93 | "arg2:nomunge, localVar:nomunge, nestedFn:nomunge"; 94 | 95 | ... 96 | var localVar; 97 | ... 98 | 99 | function nestedFn () { 100 | .... 101 | } 102 | 103 | ... 104 | } 105 | 106 | The hint itself disappears from the compressed file. 107 | 108 | + C-style comments starting with /*! are preserved. This is useful with 109 | comments containing copyright/license information. For example: 110 | 111 | /*! 112 | * TERMS OF USE - EASING EQUATIONS 113 | * Open source under the BSD License. 114 | * Copyright 2001 Robert Penner All rights reserved. 115 | */ 116 | 117 | becomes: 118 | 119 | /* 120 | * TERMS OF USE - EASING EQUATIONS 121 | * Open source under the BSD License. 122 | * Copyright 2001 Robert Penner All rights reserved. 123 | */ 124 | 125 | AUTHOR 126 | 127 | The YUI Compressor was written and is maintained by: 128 | Julien Lecomte 129 | The CSS portion is a port of Isaac Schlueter's cssmin utility. 130 | 131 | COPYRIGHT 132 | 133 | Copyright (c) 2007-2009, Yahoo! Inc. All rights reserved. 134 | 135 | LICENSE 136 | 137 | All code specific to YUI Compressor is issued under a BSD license. 138 | YUI Compressor extends and implements code from Mozilla's Rhino project. 139 | Rhino is issued under the Mozilla Public License (MPL), and MPL applies 140 | to the Rhino source and binaries that are distributed with YUI Compressor. -------------------------------------------------------------------------------- /vendor/yuicompressor/yuicompressor-2.4.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doctyper/flexie/ba0dd6a2f7a2ed4127090062cabb70dc2cd8b6b7/vendor/yuicompressor/yuicompressor-2.4.2.jar --------------------------------------------------------------------------------