add docblock for password
[roojs1] / Roo / form / Signature.js
index 1426745..579d0ea 100644 (file)
@@ -25,7 +25,7 @@ Roo.form.Signature = function(config){
          /**
          * @event confirm
          * Fires when the 'confirm' icon is pressed (add a listener to enable add button)
-            * @param {Roo.form.ComboBox} combo This combo box
+            * @param {Roo.form.Signature} combo This combo box
             */
         'confirm' : true,
         /**
@@ -100,6 +100,7 @@ Roo.extend(Roo.form.Signature, Roo.form.Field,  {
         this.svgEl = this.signPanel.createChild({
               xmlns : 'http://www.w3.org/2000/svg',
               tag : 'svg',
+              id : this.svgID + "-svg",
               width: this.width,
               height: this.height,
               viewBox: '0 0 '+this.width+' '+this.height,
@@ -113,6 +114,7 @@ Roo.extend(Roo.form.Signature, Roo.form.Field,  {
                 },
                 {
                     tag: "line",
+                    id: this.svgID + "-svg-l",
                     x1: "0", // start
                     y1: (this.height*0.8), // start set the line in 80% of height
                     x2: this.width, // end
@@ -158,7 +160,7 @@ Roo.extend(Roo.form.Signature, Roo.form.Field,  {
         pt.x = e.clientX; 
         pt.y = e.clientY;
         if (this.isTouchEvent(e)) {
-            pt.x =  e.targetTouches[0].clientX 
+            pt.x =  e.targetTouches[0].clientX;
             pt.y = e.targetTouches[0].clientY;
         }
         var a = this.svgEl.dom.getScreenCTM();
@@ -169,7 +171,7 @@ Roo.extend(Roo.form.Signature, Roo.form.Field,  {
     //mouse event headler 
     down : function (e) {
         this.signatureTmp += 'M' + this.getCoords(e) + ' ';
-        this.signPanel.select('#'+ this.svgID + '-svg-p', true).first().dom.setAttributeNS('http://www.w3.org/2000/svg','d', this.signatureTmp);
+        this.signPanel.select('#'+ this.svgID + '-svg-p', true).first().attr('d', this.signatureTmp);
         
         this.isMouseDown = true;
         
@@ -178,7 +180,7 @@ Roo.extend(Roo.form.Signature, Roo.form.Field,  {
     move : function (e) {
         if (this.isMouseDown) {
             this.signatureTmp += 'L' + this.getCoords(e) + ' ';
-            this.signPanel.select('#'+ this.svgID + '-svg-p', true).first().dom.setAttributeNS('http://www.w3.org/2000/svg', 'd', this.signatureTmp);
+            this.signPanel.select('#'+ this.svgID + '-svg-p', true).first().attr( 'd', this.signatureTmp);
         }
         
         e.preventDefault();
@@ -242,7 +244,7 @@ Roo.extend(Roo.form.Signature, Roo.form.Field,  {
             {
                 cls : '  x-signature-btn x-signature-'+id,
                 scope: editor, // was editor...
-                handler: this.setConfirmed,
+                handler: this.confirmHandler,
                 clickEvent:'mousedown',
                 text: this.labels.confirm
             }
@@ -251,13 +253,14 @@ Roo.extend(Roo.form.Signature, Roo.form.Field,  {
     },
     //public
     /**
+     * when user is clicked confirm then show this image.....
      * 
      * @return {String} Image Data URI
      */
     getImageDataURI : function(){
-        var svg = this.svgEl.dom.outerHTML;
+        var svg = this.svgEl.dom.parentNode.innerHTML;
         var src = 'data:image/svg+xml;base64,'+window.btoa(svg);
-        return src;
+        return src; 
     },
     /**
      * 
@@ -266,6 +269,20 @@ Roo.extend(Roo.form.Signature, Roo.form.Field,  {
     getConfirmed : function(){
         return this.isConfirmed;
     },
+    /**
+     * 
+     * @return {Number} this.width
+     */
+    getWidth : function(){
+        return this.width;
+    },
+    /**
+     * 
+     * @return {Number} this.height
+     */
+    getHeight : function(){
+        return this.height;
+    },
     // private
     getSignature : function(){
         return this.signatureTmp;
@@ -274,22 +291,39 @@ Roo.extend(Roo.form.Signature, Roo.form.Field,  {
     reset : function(){
         this.signatureTmp = '';
         this.signPanel.select('#'+ this.svgID + '-svg-r', true).first().attr('fill', '#ffa');
-        this.signPanel.select('#'+ this.svgID + '-svg-p', true).first().dom.setAttributeNS('http://www.w3.org/2000/svg', 'd', '');
+        this.signPanel.select('#'+ this.svgID + '-svg-p', true).first().attr( 'd', '');
         this.isConfirmed = false;
         Roo.form.Signature.superclass.reset.call(this);
     },
+    setSignature : function(s){
+        this.signatureTmp = s;
+        this.signPanel.select('#'+ this.svgID + '-svg-r', true).first().attr('fill', '#ffa');
+        this.signPanel.select('#'+ this.svgID + '-svg-p', true).first().attr( 'd', s);
+        this.setValue(s);
+        this.isConfirmed = false;
+        Roo.form.Signature.superclass.reset.call(this);
+    }, 
     test : function(){
 //        Roo.log(this.signPanel.dom.contentWindow.up())
     },
     //private
     setConfirmed : function(){
+        
+        
+        
+//        Roo.log(Roo.get(this.signPanel.dom.contentWindow.r).attr('fill', '#cfc'));
+    },
+    // private
+    confirmHandler : function(){
         if(!this.getSignature()){
             return;
         }
+        
         this.signPanel.select('#'+ this.svgID + '-svg-r', true).first().attr('fill', '#cfc');
         this.setValue(this.getSignature());
         this.isConfirmed = true;
-//        Roo.log(Roo.get(this.signPanel.dom.contentWindow.r).attr('fill', '#cfc'));
+        
+        this.fireEvent('confirm', this);
     },
     // private
     // Subclasses should provide the validation implementation by overriding this