CeramicProject/newyt/Framework_File/ui-layout-0.0.0/ui-layout.min.js

7 lines
2.6 KiB
JavaScript

/**
* angular-ui-layout - This directive allows you to split !
* @version v0.0.0 - 2014-01-01
* @link https://github.com/angular-ui/ui-layout
* @license MIT
*/
"use strict";angular.module("ui.layout",[]).controller("uiLayoutCtrl",["$scope","$attrs","$element",function(a,b,c){return{opts:angular.extend({},a.$eval(b.uiLayout),a.$eval(b.options)),element:c}}]).directive("uiLayout",["$parse",function(a){var b='<div class="stretch ui-splitbar"></div>';return{restrict:"AE",compile:function(c,d){var e,f=c.children(),g=f.length,h=angular.extend({},a(d.uiLayout)(),a(d.options)()),i="column"===h.flow;for(c.addClass("stretch").addClass("ui-layout-"+(h.flow||"row")),e=0;g>e;++e)angular.element(f[e]).addClass("stretch");if(g>1){var j=i?"left":"top",k=i?"right":"bottom",l=100/g;for(e=0;g>e;++e){var m=angular.element(f[e]).css(j,l*e+"%").css(k,100-l*(e+1)+"%");if(g-1>e){var n=angular.element(b).css(j,l*(e+1)+"%");m.after(n)}}}},controller:"uiLayoutCtrl"}}]).directive("uiSplitbar",function(){var a=angular.element(document.body.parentElement);return{require:"^uiLayout",restrict:"EAC",link:function(b,c,d,e){function f(){var a=e.element[0].getBoundingClientRect(),b=q.getBoundingClientRect();k.time=+new Date,k.barSize=b[p],k.layoutSize=a[p],k.layoutOrigine=a[n]}function g(){var a=(j-k.layoutOrigine)/k.layoutSize*100;a=Math.min(a,100-k.barSize/k.layoutSize*100),a=Math.max(a,parseInt(q.previousElementSibling.style[n],10)),q.nextElementSibling.nextElementSibling&&(a=Math.min(a,parseInt(q.nextElementSibling.nextElementSibling.style[n],10))),q.style[n]=q.nextElementSibling.style[n]=a+"%",q.previousElementSibling.style[o]=100-a+"%",i=null}function h(a){j=a[m]||a.originalEvent[m],i&&window.cancelAnimationFrame(i),(!k.time||+new Date>k.time+1e3)&&f(),i=window.requestAnimationFrame(g)}var i,j,k={},l="column"===e.opts.flow,m=l?"clientX":"clientY",n=l?"left":"top",o=l?"right":"bottom",p=l?"width":"height",q=c[0];c.on("mousedown touchstart",function(b){return b.preventDefault(),b.stopPropagation(),a.on("mousemove touchmove",h),!1}),a.on("mouseup touchend",function(){a.off("mousemove touchmove")})}}});for(var lastTime=0,vendors=["ms","moz","webkit","o"],x=0;x<vendors.length&&!window.requestAnimationFrame;++x)window.requestAnimationFrame=window[vendors[x]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[vendors[x]+"CancelAnimationFrame"]||window[vendors[x]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(a){var b=(new Date).getTime(),c=Math.max(0,16-(b-lastTime)),d=window.setTimeout(function(){a(b+c)},c);return lastTime=b+c,d}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(a){clearTimeout(a)});