Created
February 21, 2015 20:16
-
-
Save anonymous/2552a4a4eb6264c5ccc6 to your computer and use it in GitHub Desktop.
JS Bin Custom Directive Chart // source http://jsbin.com/cafapi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html ng-app="chart"> | |
<head> | |
<meta name="description" content="Custom Directive Chart"> | |
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
label{ | |
width:55px; | |
display:inline-block; | |
} | |
</style> | |
</head> | |
<body ng-controller="dir"> | |
<chart first="first" second="second" third="third" fourth="fourth" total="total()" ></chart> | |
<input min=0 ng-model="first" type="number"> <br> | |
<input min=0 ng-model="second" type="number"> <br> | |
<input min=0 ng-model="third" type="number"> <br> | |
<input min=0 ng-model="fourth" type="number"> <br> | |
{{f|a3melelsa7:'arg1':'arg2':''}} | |
<input ng-model="f"> | |
{{gg}} | |
<br> | |
<input type="number" ng-model="ff">{{ff|currency:c}} | |
<input ng-model="qwerty" ng-change="c.set('ahmed',qwerty)" > | |
{{qwerty}} | |
<script id="jsbin-javascript"> | |
var scope; | |
var app=angular.module('chart',[]); | |
app.controller('dir',function($scope,$filter,cookie){ | |
scope=$scope; | |
$scope.c=cookie; | |
$scope.$watch('qwerty',function(newr,old,scope){ | |
scope.qwerty=cookie.get('ahmed'); | |
}); | |
$scope.qwerty=cookie.get('ahmed'); | |
$scope.first=12; | |
$scope.second=84; | |
$scope.third=72; | |
$scope.fourth=100; | |
$scope.total=function(){return $scope.first+$scope.second+$scope.third+$scope.fourth;} | |
$scope.gg=$filter('a3melelsa7')(''); | |
}); | |
app.directive('chart',function(){ | |
return { | |
restrict:'E', | |
scope:{first:'=',second:'=',third:'=',fourth:'=',total:'='}, | |
template:'<div class="ch-container" ><div class="first ch" style="height:{{(first/total)*100}}px"></div> <div class="second ch" style="height:{{(second/total)*100}}px"></div> <div class="third ch" style="height:{{(third/total)*100}}px"></div> <div class="fourth ch" style="height:{{(fourth/total)*100}}px"></div> </div><style>.first{ background-color:red; }.second{ background-color:yellow;}.third{ background-color:black; }.fourth{ background-color:green; }.ch{ height:90px; width:30px; display:inline-block; margin-left:10px; }.ch-container{ border:1px solid; border-right:0px; border-top:0px;}</style>' | |
} | |
}) | |
app.filter('a3melelsa7',function(){ | |
return function(elem){ | |
if(elem=='7azl2om'){ | |
return "nehen"; | |
} | |
else{ | |
return "nhon"+arguments.length; | |
} | |
} | |
}) | |
app.factory('cookie',function(){ | |
set=function(key,value,expires){ | |
var mydate=new Date(); | |
mydate.setYear(mydate.getFullYear()+1) | |
if(expires){ | |
document.cookie=key+"="+value+";"; | |
} | |
else{ | |
document.cookie=key+"="+value+";expires="+mydate; | |
} | |
} | |
get=function(key){ | |
return document.cookie.split(key+'=')[1].split(';')[0]; | |
} | |
del=function(key){ | |
document.cookie=key+"=;expires=Thu, 01 Jan 1970 00:00:00 UTC;" | |
} | |
return { | |
set:set, | |
del:del, | |
get:get | |
} | |
}) | |
</script> | |
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html> | |
<html ng-app="chart"> | |
<head> | |
<meta name="description" content="Custom Directive Chart"> | |
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"><\/script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body ng-controller="dir"> | |
<chart first="first" second="second" third="third" fourth="fourth" total="total()" ></chart> | |
<input min=0 ng-model="first" type="number"> <br> | |
<input min=0 ng-model="second" type="number"> <br> | |
<input min=0 ng-model="third" type="number"> <br> | |
<input min=0 ng-model="fourth" type="number"> <br> | |
{{f|a3melelsa7:'arg1':'arg2':''}} | |
<input ng-model="f"> | |
{{gg}} | |
<br> | |
<input type="number" ng-model="ff">{{ff|currency:c}} | |
<input ng-model="qwerty" ng-change="c.set('ahmed',qwerty)" > | |
{{qwerty}} | |
</body> | |
</html></script> | |
<script id="jsbin-source-css" type="text/css"> | |
label{ | |
width:55px; | |
display:inline-block; | |
}</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var scope; | |
var app=angular.module('chart',[]); | |
app.controller('dir',function($scope,$filter,cookie){ | |
scope=$scope; | |
$scope.c=cookie; | |
$scope.$watch('qwerty',function(newr,old,scope){ | |
scope.qwerty=cookie.get('ahmed'); | |
}); | |
$scope.qwerty=cookie.get('ahmed'); | |
$scope.first=12; | |
$scope.second=84; | |
$scope.third=72; | |
$scope.fourth=100; | |
$scope.total=function(){return $scope.first+$scope.second+$scope.third+$scope.fourth;} | |
$scope.gg=$filter('a3melelsa7')(''); | |
}); | |
app.directive('chart',function(){ | |
return { | |
restrict:'E', | |
scope:{first:'=',second:'=',third:'=',fourth:'=',total:'='}, | |
template:'<div class="ch-container" ><div class="first ch" style="height:{{(first/total)*100}}px"></div> <div class="second ch" style="height:{{(second/total)*100}}px"></div> <div class="third ch" style="height:{{(third/total)*100}}px"></div> <div class="fourth ch" style="height:{{(fourth/total)*100}}px"></div> </div><style>.first{ background-color:red; }.second{ background-color:yellow;}.third{ background-color:black; }.fourth{ background-color:green; }.ch{ height:90px; width:30px; display:inline-block; margin-left:10px; }.ch-container{ border:1px solid; border-right:0px; border-top:0px;}</style>' | |
} | |
}) | |
app.filter('a3melelsa7',function(){ | |
return function(elem){ | |
if(elem=='7azl2om'){ | |
return "nehen"; | |
} | |
else{ | |
return "nhon"+arguments.length; | |
} | |
} | |
}) | |
app.factory('cookie',function(){ | |
set=function(key,value,expires){ | |
var mydate=new Date(); | |
mydate.setYear(mydate.getFullYear()+1) | |
if(expires){ | |
document.cookie=key+"="+value+";"; | |
} | |
else{ | |
document.cookie=key+"="+value+";expires="+mydate; | |
} | |
} | |
get=function(key){ | |
return document.cookie.split(key+'=')[1].split(';')[0]; | |
} | |
del=function(key){ | |
document.cookie=key+"=;expires=Thu, 01 Jan 1970 00:00:00 UTC;" | |
} | |
return { | |
set:set, | |
del:del, | |
get:get | |
} | |
}) | |
</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
label{ | |
width:55px; | |
display:inline-block; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var scope; | |
var app=angular.module('chart',[]); | |
app.controller('dir',function($scope,$filter,cookie){ | |
scope=$scope; | |
$scope.c=cookie; | |
$scope.$watch('qwerty',function(newr,old,scope){ | |
scope.qwerty=cookie.get('ahmed'); | |
}); | |
$scope.qwerty=cookie.get('ahmed'); | |
$scope.first=12; | |
$scope.second=84; | |
$scope.third=72; | |
$scope.fourth=100; | |
$scope.total=function(){return $scope.first+$scope.second+$scope.third+$scope.fourth;} | |
$scope.gg=$filter('a3melelsa7')(''); | |
}); | |
app.directive('chart',function(){ | |
return { | |
restrict:'E', | |
scope:{first:'=',second:'=',third:'=',fourth:'=',total:'='}, | |
template:'<div class="ch-container" ><div class="first ch" style="height:{{(first/total)*100}}px"></div> <div class="second ch" style="height:{{(second/total)*100}}px"></div> <div class="third ch" style="height:{{(third/total)*100}}px"></div> <div class="fourth ch" style="height:{{(fourth/total)*100}}px"></div> </div><style>.first{ background-color:red; }.second{ background-color:yellow;}.third{ background-color:black; }.fourth{ background-color:green; }.ch{ height:90px; width:30px; display:inline-block; margin-left:10px; }.ch-container{ border:1px solid; border-right:0px; border-top:0px;}</style>' | |
} | |
}) | |
app.filter('a3melelsa7',function(){ | |
return function(elem){ | |
if(elem=='7azl2om'){ | |
return "nehen"; | |
} | |
else{ | |
return "nhon"+arguments.length; | |
} | |
} | |
}) | |
app.factory('cookie',function(){ | |
set=function(key,value,expires){ | |
var mydate=new Date(); | |
mydate.setYear(mydate.getFullYear()+1) | |
if(expires){ | |
document.cookie=key+"="+value+";"; | |
} | |
else{ | |
document.cookie=key+"="+value+";expires="+mydate; | |
} | |
} | |
get=function(key){ | |
return document.cookie.split(key+'=')[1].split(';')[0]; | |
} | |
del=function(key){ | |
document.cookie=key+"=;expires=Thu, 01 Jan 1970 00:00:00 UTC;" | |
} | |
return { | |
set:set, | |
del:del, | |
get:get | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment