aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMisko Hevery2010-03-22 15:46:52 -0700
committerMisko Hevery2010-03-22 15:46:52 -0700
commitd4ba33d075fea5e86963a9ff4982e433fc8c7968 (patch)
treef09f67d52feb3544d5d86ad22a4c6613cf430f4e /src
parentb4561ff951ff452e55e820f6f8344dc2668cfd90 (diff)
parent5119c8a86fa2b8ce9d0f0c343b57dd96aa88ce8c (diff)
downloadangular.js-d4ba33d075fea5e86963a9ff4982e433fc8c7968.tar.bz2
Merge branch 'directives' of github.com:angular/angular.js into directives
Diffstat (limited to 'src')
-rw-r--r--src/directives.js2
-rw-r--r--src/widgets2.js85
2 files changed, 87 insertions, 0 deletions
diff --git a/src/directives.js b/src/directives.js
index 8047cdbd..861805fe 100644
--- a/src/directives.js
+++ b/src/directives.js
@@ -123,3 +123,5 @@ angularDirective("watch", function(expression, element){
//widget related
//ng-validate, ng-required, ng-formatter
//ng-error
+
+//ng-scope ng-controller????
diff --git a/src/widgets2.js b/src/widgets2.js
new file mode 100644
index 00000000..0d7bbd49
--- /dev/null
+++ b/src/widgets2.js
@@ -0,0 +1,85 @@
+// <input type="text" name="bla" ng-action=""> -> <ng:textinput name="" ng-action=""/>
+angular.widget("inputtext", function(element) {
+ var expression = element.attr('name');
+ var formatter = this.formatter(element.attr('formatter'));
+ var validator = this.validator(element.attr('validator'));
+
+ function validate(value) {
+ var error = validator(element);
+ if (error) {
+ element.addClass("ng-error");
+ scope.markInvalid(this); //move out of scope
+ } else {
+ scope.clearInvalid(this);
+ }
+ }
+
+
+ element.keyup(this.withScope(function(){
+ this.$evalSet(expression, formatter.parse(element.val()));
+ validate(element.val());
+ }));
+
+ return {watch: expression, apply: function(newValue){
+ element.val(formatter.format(newValue));
+ validate(element.val());
+ }};
+
+});
+
+angular.widget("inputfile", function(element) {
+
+});
+
+angular.widget("inputradio", function(element) {
+
+});
+
+
+// <ng:colorpicker name="chosenColor" >
+angular.widget("colorpicker", function(element) {
+ var name = element.attr('datasource');
+ var formatter = this.formatter(element.attr('ng-formatter'));
+
+ element.colorPicker(this.withScope(function(selectedColor){
+ this.$evalSet(name, formatter.parse(selectedColor));
+ }));
+
+ return function(){
+ this.$watch(expression, function(cmyk){
+ element.setColor(formatter.format(cmyk));
+ });
+ }
+});
+
+angular.widget("template", function(element) {
+ var srcExpression = element.attr('src');
+ var self = this;
+ return {watch:srcExpression, apply:function(src){
+ $.load(src, function(html){
+ self.destroy(element);
+ element.html(html);
+ self.compile(element);
+ });
+ }};
+});
+
+
+/**
+ *
+ * {
+ * withScope: //safely executes, with a try/catch. applies scope
+ * compile:
+ * widget:
+ * directive:
+ * validator:
+ * formatter:
+ *
+ *
+ * config:
+ * loadCSS:
+ * loadScript:
+ * loadTemplate:
+ * }
+ *
+ **/