balsamine.2015-2016
clone your own copy | download snapshot

Snapshots | iceberg

Inside this repository

cssregions.min.js
application/javascript

Download raw (16.3 KB)

/*! Copyright 2012 Adobe Systems Inc.;
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

* http://www.apache.org/licenses/LICENSE-2.0

* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
!function(){typeof String.prototype.trim!="function"&&(String.prototype.trim=function(e){return e.replace(/^\s+/,"").replace(/\s+$/,"")}),typeof Array.prototype.forEach!="function"&&(Array.prototype.forEach=function(e,t){if(typeof e!="function")throw new TypeError("Invalid parameter. Expected 'function', got "+typeof e);var n=Object(this),r=n.length,i=0;for(i;i<r;i++)e.call(t,this[i],i,n)}),typeof Array.prototype.indexOf!="function"&&(Array.prototype.indexOf=function(e){var t=Object(this),n=-1;return t.forEach(function(t,r){if(t===e){n=r;return}}),n})}(),!function(e){function t(){var e=document,t=[];if(typeof e.querySelectorAll=="function")t=e.querySelectorAll('link[rel="stylesheet"], style'),t=Array.prototype.slice.call(t,0);else{var n=e.getElementsByTagName("link");if(n.length)for(var r=0,i=n.length;r<i;r++)n[r].getAttribute("rel")==="stylesheet"&&t.push(n[r]);n=e.getElementsByTagName("style");for(var r=0,i=n.length;r<i;r++)t.push(n[r])}return t}function n(e){this.source=e,this.url=e.href||null,this.cssText=""}function r(e){if(!(this instanceof r))return new r(e);this.stylesheets=[],this.queueCount=0,this.callback=e||function(){},this.init()}n.prototype.load=function(e,t,n){var r=this;if(this.url){var i=new XMLHttpRequest;i.onreadystatechange=function(){i.readyState===4&&(i.status===200?(r.cssText=i.responseText,e.call(n,r)):t.call(n,r))},i.open("GET",this.url,!1),i.send(null)}else this.cssText=this.source.textContent,e.call(n,r)},r.prototype.init=function(){var e=t(),r=e.length,i,s;this.queueCount=r;for(s=0;s<r;s++)i=new n(e[s]),this.stylesheets.push(i),i.load(this.onStyleSheetLoad,this.onStyleSheetError,this)},r.prototype.onStyleSheetLoad=function(e){this.queueCount--,this.onComplete.call(this)},r.prototype.onStyleSheetError=function(e){var t=this.stylesheets.length,n;for(n=0;n<t;n++)if(e.source===this.stylesheets[n].source){this.stylesheets.splice(n,1),this.queueCount--,this.onComplete.call(this);return}},r.prototype.onComplete=function(){this.queueCount===0&&this.callback.call(this,this.stylesheets)},e.StyleLoader=r}(window),!function(e){function t(){this.selectorText=null,this.style={},this.type="rule"}function n(){function e(e){var t=e.trim().split(";");return t.length?t.pop().trim():null}function n(e){var t={},n=e.trim().split(";");return!n||!n.length?t:(n.forEach(function(e){if(e.indexOf(":")==-1)return;var n,r,i=e.split(":");i[0]!==undefined&&i[1]!==undefined&&(n=i[0].trim(),r=i[1].trim().replace(/[\"\']/g,""),t[n]=r)}),t)}function r(i,s,o){function m(e,t){var n=0;while(t){switch(e.charAt(n)){case"{":t++;break;case"}":t--}n++}return n-1}var u=i.indexOf("{"),a,f=new t,l=i.substring(0,u),c=e(l),h=i.substr(u+1,i.length),p=h.indexOf("}"),d=h.indexOf("{");if(u>0){f.setSelector(c),o&&(f.setParentRule(o),a=n(l),o.setStyle(a));if(d>-1&&d<p){p=m(h,1);var v=h.substring(0,p);a=n(l),f.setStyle(a),f.cssRules=f.cssRules||[],r(v,f.cssRules,f),h=h.substring(p+1,h.length)}else a=n(h.substring(0,p)),f.setStyle(a),h=h.substring(p+1,i.length);r(h,s),s.unshift(f)}}function i(e){if(!e)throw new Error("CSSParser.cascadeRules(). No css rules available for cascade");if(!e.length)return e;var t=[],n={},r=[];return e.forEach(function(e){e.cssRules&&(e.cssRules=i(e.cssRules)),n[e.selectorText]?n[e.selectorText]=s({},n[e.selectorText],e):(r.push(e.selectorText),n[e.selectorText]=e)}),r.forEach(function(e){t.push(n[e])},this),n=null,r=null,t}function s(e){var t=Array.prototype.slice.call(arguments,1);return t.forEach(function(t){for(var n in t){if(n==="parentRule")return;typeof e[n]=="object"&&e[n]?typeof e[n].slice=="function"?e[n]=i(e[n].concat(t[n])):e[n]=s({},e[n],t[n]):e[n]=t[n]}}),e}return{cssRules:[],parse:function(e){e=e.replace(/[\n\t]+/g,"").replace(/\/\*[\s\S]*?\*\//g,"").trim(),r.call(this,e,this.cssRules)},parseCSSDeclaration:function(e){var t=[];return r.call(this,e,t),t.length&&t.length===1?t.pop():null},clear:function(){this.cssRules=[]},cascade:function(e){if(!e||!e.length){this.cssRules=i.call(this,this.cssRules);return}return i.call(this,e)},doExtend:s}}t.prototype={setSelector:function(e){this.selectorText=e;var t=e.match(/^@([^\s]+)\s*([^{]+)?/);if(t&&t[1]){switch(t[1]){case"template":this.type="template",this.cssRules=[];break;case"slot":this.type="slot";break;default:this.type="unknown"}this.identifier=t[2]||"auto"}},setStyle:function(e){if(!e)throw new TypeError("CSSRule.setStyles(). Invalid input. Expected 'object', got "+e);return this.style=e||{},this.style},setParentRule:function(e){if(!e)throw new TypeError("CSSRule.setParentRule(). Invalid input. Expected 'object', got "+properties);return this.parentRule=e,this.parentRule}},e=e||window,e.CSSParser=n}(window),window.CSSRegions=function(e){function t(){this.setup()}function w(){}function E(e,t){var n,r;if(typeof e.pop!="function")throw"Invalid input. Expected an array, got: "+typeof e;this.map={},this.length=0;for(n=0,r=e.length;n<r;n++)this[n]=e[n],this.length++,t&&e[n][t]&&(this.map[e[n][t]]=this[n])}function S(e,t,n){this.name=e||"none",this.overset=!0,this.contentNodes=[],this.regions=[],this.regionsByContent={},this._listeners={},this.firstEmptyRegionIndex=-1,this.lastRegionWithContentIndex=-1,t&&t.length&&(this.contentNodes=i(t)),n&&n.length&&(this.regions=i(n))}function T(){var e,t=document.createElement("span"),n=!1,r=x.getSupportedProperty("flow-into"),i=x.getSupportedProperty("getNamedFlows",document,!0);t.id="test-regions-support",t.style[r]="testflow",document.body.appendChild(t);try{e=document[i].call(document).testflow,n=typeof e.overset!="undefined"}catch(s){}finally{return t.style[r]="none",t.parentNode.removeChild(t),e=null,!!n}}t.prototype={hasNativeSupport:!1,prefixes:{css:"-adobe-",om:"adobe"},getPrefixedProperty:function(e){return this.prefixes.css.concat(e)},getPrefixedOMProperty:function(e){return this.prefixes.om.concat(e.charAt(0).toUpperCase()+e.slice(1))},getPrefixedEvent:function(e){return this.prefixes.om.concat(e)},init:function(){var e=this;if(!window.StyleLoader){console.error("Missing StyleLoader.js");return}new StyleLoader(function(){return function(t){e.onStylesLoaded(t)}}())},setup:function(){this.namedFlows=[],this.namedFlowCollection=null},onStylesLoaded:function(e){if(!window.CSSParser){console.error("Missing CSSParser.js");return}var t,n,r,i,s=new CSSParser;this.setup(),e.forEach(function(e){s.parse(e.cssText)});if(s.cssRules.length===0){console.log("There is no inline CSS for CSS Regions!");return}t=this.getNamedFlowRules(s.cssRules);for(n in t)r=t[n].contentNodesSelectors,i=t[n].regionsSelectors,this.namedFlows.push(new S(n,r,i));this.namedFlowCollection=new E(this.namedFlows,"name"),this.exposeGlobalOM(),this.doLayout()},getNamedFlowRules:function(e){var t,n,r,i=e.length,s={},o=this.getPrefixedProperty("flow"),u=this.getPrefixedProperty("flow-into"),a=this.getPrefixedProperty("flow-from");for(var f=0;f<i;f++){t=e[f];for(n in t.style)if(n.indexOf(o)!==-1){r=t.style[n],s[r]=s[r]||{contentNodesSelectors:[],regionsSelectors:[]},n.indexOf(u)!==-1&&s[r].contentNodesSelectors.push(t.selectorText),n.indexOf(a)!==-1&&s[r].regionsSelectors.push(t.selectorText);break}}return s},doLayout:function(){if(!this.namedFlows||!this.namedFlows.length){console.warn("No named flow / regions CSS rules");return}n++;if(n>1)return;while(n>0)u(),n--},exposeGlobalOM:function(){var e="getNamedFlows",t=this.getPrefixedOMProperty(e);document[e]=document[t]=this.getNamedFlows.bind(this)},getNamedFlows:function(){return this.namedFlowCollection},addSourceToNamedFlow:function(e,t){var n=this.getNamedFlows().namedItem(e);n||(n=new S(e),this.namedFlows.push(n),this.namedFlowCollection=new E(this.namedFlows,"name")),n.contentNodes.push(t),r[n.name]=!1},addRegionToNamedFlow:function(e,t){var n=this.getNamedFlows().namedItem(e);n||(n=new S(e),this.namedFlows.push(n),this.namedFlowCollection=new E(this.namedFlows,"name")),n.regions.push(t),r[n.name]=!1},NamedFlow:S,Collection:E};var n=0,r={},i=function(e){var t,n,r,i,s=[],o=e.length;for(t=0;t<o;t++){i=document.querySelectorAll(e[t]);for(n=0,r=i.length;n<r;++n)s.push(i[n])}return m(document.body,NodeFilter.SHOW_ELEMENT,{acceptNode:function(e){return s.indexOf(e)>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}})},s=function(e){var t,n,r,i=[];for(t=0,n=e.length;t<n;t++)r=e[t].cloneNode(!0),i.push(r),r.style.display==="none"&&(r.style.display=r["data-display"]||""),getComputedStyle(e[t]).display!=="none"&&(e[t]["data-display"]=e[t].style.display,e[t].style.display="none");return i},o=function(e,t){var n,r,i,s=[];for(n=0,r=e.length;n<r;n++)i=e[n],getComputedStyle(i).display!=="none"?(s.push(i),i["data-display"]=!0,t.lastRegionWithContentIndex<n&&(i["data-w"]!==getComputedStyle(i).width||i["data-h"]!==getComputedStyle(i).height)&&b([t.name])):i["data-display"]&&(b([t.name]),delete i["data-display"]);return s},u=function(){var e,t,n,i,u,f,l,c,h,d,v=[],m=document.getNamedFlows(),g=C.getPrefixedOMProperty("regionOverset");for(n=0,i=m.length;n<i;n++){t=m[n],t.regionsByContent={content:[],regions:[]},t.firstEmptyRegionIndex=-1,l=o(t.getRegions(),t),t.overset=!1;if(r[t.name]){h=l[t.lastRegionWithContentIndex].childNodes;for(u=0,f=h.length;u<f;++u)v.push(h[u]);u=t.lastRegionWithContentIndex}else v=s(t.contentNodes),u=0;for(f=l.length;u<f;u++){e=l[u],e.innerHTML="";if(v.length===0){t.firstEmptyRegionIndex===-1&&(t.firstEmptyRegionIndex=u),e[g]="empty";continue}c=v.shift();if(u+1===f){d=e.nextSibling||null,h=e.parentNode,h.removeChild(e);while(c)e.appendChild(c.cloneNode(!0)),p(c,-1,e,t),c=v.shift();d?(h.insertBefore(e,d),d=null):h.appendChild(e),h=null,t.lastRegionWithContentIndex=u,y(e)&&(e[g]="overset",t.overset=!0)}else{while(c){c=a(c,e,t),e["data-w"]=getComputedStyle(e).width,e["data-h"]=getComputedStyle(e).height;if(c){v.unshift(c);break}c=v.shift()}e[g]="fit"}r[t.name]=!0}if(t.regions.length>0){var b=C.getPrefixedEvent("regionlayoutupdate");t.fire({type:b,target:t})}}},a=function(e,t,n){var r,i,s,o,u=-1,a=null,h=[],b=[],w=e;return t.appendChild(w),y(t)?(t.removeChild(w),h=m(w,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,{acceptNode:function(e){return e.nodeName.toLowerCase()==="img"||e.nodeName.toLowerCase()==="fig"||e.nodeName.toLowerCase()==="#text"&&e.data.replace(/^\s+|\s+$/g,"")!==""?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}}),h.length!==1||h[0].nodeName.toLowerCase()!=="img"&&h[0].nodeName.toLowerCase()!=="fig"?(f(h),u=l(t,w,h,b),u<0?a=e:(r=h[u],r.nodeName==="#text"&&(o=b[u].replace(/^\s+|\s+$/g,""),s=o.split(" "),i=d(t,w,r,s),b[u]=g(s,i,s.length-1)),t.appendChild(c(w.cloneNode(!0))),p(t.lastChild,t,n),v(u,h,b,w),a=w)):a=e):p(w,t,n),a},f=function(e){var t,n,r,i,s;for(t=0,n=e.length;t<n;t++){s=e[t];if(s.nodeName==="#text")continue;r=0,i=s;while((i=i.previousSibling)!==null)r++;s["data-index"]=r}},l=function(e,t,n,r){var i,s,o,u,a=n.length,f=n.length,l=0,c=n.length-1;while(c>=l){o=l+Math.round((c-l)/2);for(a=o;a<f;a++){i=n[a];if(i.nodeName==="#text"){if(i.data==="")break;r[a]=i.data,i.data=""}else{if(!i.parentNode)break;r[a]=i.parentNode,i.parentNode.removeChild(i)}}e.appendChild(t);if(y(e))c=o-1,c<l&&(l=c);else{l=o+1;if(c>=l){u=l+Math.round((c-l)/2)+1;for(s=o;s<u;s++)i=n[s],i.nodeName==="#text"?i.data=r[s]:r[s].insertBefore(i,r[s].childNodes.item(i["data-index"])),delete r[s]}}e.removeChild(t)}return o},c=function(e){var t,n,r;n=m(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,{acceptNode:function(e){return e.nodeName.toLowerCase()==="img"||e.nodeName.toLowerCase()==="fig"||e.nodeName.toLowerCase()==="#text"&&e.data.replace(/^\s+|\s+$/g,"")!==""?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}}),r=n[n.length-1],t=r.nextSibling;while(t)h(t),t=t.nextSibling;t=r.parentNode.nextSibling;while(t)h(t),t=t.nextSibling;t=r.parentNode;while(t){if(t.parentNode===e){while(t.nextSibling)t.parentNode.removeChild(t.nextSibling);break}t=t.parentNode}return e},h=function(e){var t,n,r;if(e.nodeName==="#text"){e.parentNode.removeChild(e);return}t=e.childNodes;for(n=t.length-1;n>=0;n--)r=t.item(n),r.nodeName!=="#text"?r.childNodes.length===0?r.parentNode.removeChild(r):h(r):r.parentNode.removeChild(r);e.childNodes.length===0&&e.parentNode.removeChild(e)},p=function(e,t,n){var r,i,s,o,u,a;a=m(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,{acceptNode:function(e){return e.nodeName.toLowerCase()==="img"||e.nodeName.toLowerCase()==="fig"||e.nodeName.toLowerCase()==="#text"&&e.data.replace(/^\s+|\s+$/g,"")!==""?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}}),n.regionsByContent||(n.regionsByContent={content:[],regions:[]});for(r=0,i=a.length;r<i;r++)o=a[r],o.nodeName.toLowerCase()==="#text"&&(o=o.parentNode),u=n.regionsByContent.content.indexOf(o),u===-1&&(n.regionsByContent.content.push(o),u=n.regionsByContent.content.length-1),s=n.regionsByContent.regions[u]||[],s.push(t),n.regionsByContent.regions[u]=s},d=function(e,t,n,r){var i=0,s=0,o=r.length-1;while(o>=s)i=s+Math.round((o-s)/2),n.data=g(r,0,i-1),e.appendChild(t),y(e)?(o=i-1,o<s&&(s=o)):s=i+1,e.removeChild(t);return i},v=function(e,t,n,r){var i,s,o,u,a=[];for(s=e,o=t.length;s<o;s++)i=t[s],i.nodeName==="#text"?i.data=n[s]:n[s].insertBefore(i,n[s].childNodes.item(i["data-index"]));for(s=0;s<e;s++){i=t[s];if(i.nodeName==="#text"){u=i.parentNode,u.removeChild(i);while(u&&u.childNodes.length===0)u=u.parentNode,u.removeChild(u.childNodes.item(0));u&&a.push(u)}else a.push(i.parentNode),i.parentNode.removeChild(i)}for(s=0,o=a.length;s<o;s++){u=a[s];while(u&&u.childNodes.length===0)u=u.parentNode,u&&u.removeChild(u.childNodes.item(0))}u=t[e].parentNode;while(u){if(u.parentNode===r){while(u.previousSibling)u.parentNode.removeChild(u.previousSibling);break}u=u.parentNode}},m=function(e,t,n){var r,i,s=[];r=document.createNodeIterator(e,t,n,!1);while(i=r.nextNode())s.push(i);return s},g=function(e,t,n){return e.slice(t,n+1).join(" ")+" "},y=function(e){var t,n=e.style.overflow;if(!n||n==="visible")e.style.overflow="hidden";return t=e.clientHeight<e.scrollHeight-1,e.style.overflow=n,t},b=function(e){var t,n,i;if(e&&e.length)e.forEach(function(e){r[e]=!1});else{i=document.getNamedFlows();for(t=0,n=i.length;t<n;t++)r[i[t].name]=!1}};w.prototype={constructor:w,addEventListener:function(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t),C.doLayout()},fire:function(e){var t,n,r;if(this._listeners[e.type]instanceof Array){t=this._listeners[e.type];for(n=0,r=t.length;n<r;n++)t[n].call(this,e)}},removeEventListener:function(e,t){var n,r,i;if(this._listeners[e]instanceof Array){n=this._listeners[e];for(r=0,i=n.length;r<i;r++)if(n[r]===t){n.splice(r,1);break}}}},E.prototype={item:function(e){return this[e]||null},namedItem:function(e){return this.map[e]||null}},S.prototype=new w,S.prototype.constructor=S,S.prototype.getRegions=function(){return this.regions},S.prototype.getRegionsByContent=function(e){var t,n=[];return t=this.regionsByContent.content.indexOf(e),t!==-1&&(n=this.regionsByContent.regions[t]),n};var x=function(){function t(e,t){var n=t.join(e+" ").split(" ");return n.slice(0,n.length-1)}var e=" -webkit- -moz- -o- -ms- ";return{cssProperty:function(n,r){var r=r||document.body,i=e.split(" "),s=t(n,i);for(var o=0,u=s.length;o<u;o++)if(r.style[s[o]]!==undefined)return this.supportedProperty=s[o],!0;return!1},omProperty:function(n,r){var r=r||document,i=e.replace(/-/g,"").split(" ");i=i.slice(1,i.length);var s=n.charAt(0).toUpperCase()+n.slice(1),o=t(s,i);o=o.slice(0,o.length-1),o.unshift(n);for(var u=0,a=o.length;u<a;u++)if(o[u]in r)return this.supportedProperty=o[u],!0;return!1},getSupportedProperty:function(e,t,n){var n=!!n,r=function(){},i=new r;return i.supportedProperty=e,n?x.omProperty.call(i,e,t):x.cssProperty.call(i,e,t),i.supportedProperty}}}();typeof e.addEventListener=="undefined"&&(e.addEventListener=function(t,n){e.attachEvent("on"+t,n)});var N,C=new t,k=document.documentElement;return e.addEventListener("load",function(){if(x.cssProperty("flow-into")&&x.omProperty("getNamedFlows")&&T()){C.hasNativeSupport=!0,k.className+=" regions";return}C.init(),k.className+=" no-regions",e.addEventListener("resize",function(){window.clearTimeout(N),N=window.setTimeout(function(){b(),C.doLayout()},300)})}),C}(window);