/*! 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;i0){f.setSelector(c),o&&(f.setParentRule(o),a=n(l),o.setStyle(a));if(d>-1&&d1)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=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}})},s=function(e){var t,n,r,i=[];for(t=0,n=e.length;t0){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=l){o=l+Math.round((c-l)/2);for(a=o;a=l){u=l+Math.round((c-l)/2)+1;for(s=o;s=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=s)i=s+Math.round((o-s)/2),n.data=g(r,0,i-1),e.appendChild(t),y(e)?(o=i-1,o