Browse code

Konflikt mit anderen JavaScripts beseitigt

Hagen Klemp authored on16/02/2019 15:04:53
Showing3 changed files
... ...
@@ -5,7 +5,7 @@
5 5
 1. Ergänzen Sie als _letzten_ Eintrag im Bereich "require" diese Zeile
6 6
 ```
7 7
     "require": {
8
-        "do-while/contao-signature-formfield-bundle": "dev-master"
8
+        "do-while/contao-signature-formfield-bundle": "^1.0"
9 9
     }
10 10
 ```
11 11
 1. Dann rufen Sie den Composer mit `composer update` auf oder Sie rufen den **Contao Manager** auf.
... ...
@@ -32,11 +32,11 @@ Dazu muss man allerdings den SimpleToken in der Quelltext-Ansicht in das HTML ei
32 32
 
33 33
 
34 34
 ## Version
35
-* 0.1.0<br>Testversion: 2019-02-05<br>Version für Contao ab Version 4.4 LTS
35
+* 1.0.0<br>Erstversion: 2019-02-16<br>Version für Contao ab Version 4.4 LTS
36 36
 
37 37
 
38 38
 **Problem melden | *Report Problem*:**<br>
39 39
 https://github.com/do-while/contao-signature-formfield-bundle/issues
40 40
 
41 41
 ___
42
-Softleister - 2019-02-05
42
+Softleister - 2019-02-16
... ...
@@ -1,7 +1,6 @@
1 1
 <?php
2 2
     $GLOBALS['TL_CSS'][] = 'bundles/softleistersignatureformfield/styles.css|static';
3 3
     $GLOBALS['TL_JAVASCRIPT'][] = 'bundles/softleistersignatureformfield/jSignature.min.noconflict.js|static';
4
-    $GLOBALS['TL_JAVASCRIPT'][] = 'bundles/softleistersignatureformfield/jSignature.UndoButton.js|static';
5 4
 ?>
6 5
 
7 6
 <?php $this->extend('form_row'); ?>
... ...
@@ -26,20 +25,24 @@
26 25
   <input id="hidden_<?= $this->id ?>" type="hidden" name="<?= $this->name ?>" value="">
27 26
   <div id="signature_<?= $this->id ?>" class="canvas" style="width:<?= $this->width ?>px;height:<?= $this->height ?>px;background-color:#<?= $this->bgcolor ?>;"></div>
28 27
   <script>
29
-      $(document).ready(function() {
30
-          var $sigdiv = $("#signature_<?= $this->id ?>")
31
-          $sigdiv.jSignature({
32
-              'color': "#<?= $this->color ?>",
33
-              'lineWidth': <?= $this->pen ?>,
34
-              'width': '<?= $this->width ?>',
35
-              'height': '<?= $this->height ?>',
36
-              'background-color': "transparent",
37
-              'UndoButton': true
38
-          })
39
-          $sigdiv.bind('change', function(e) {
40
-              document.getElementById("hidden_<?= $this->id ?>").value = $sigdiv.jSignature("getData","default")
28
+
29
+    jQuery.noConflict();
30
+    (function($) {
31
+        $(function() {
32
+            var $sigdiv = $("#signature_<?= $this->id ?>")
33
+            $sigdiv.jSignature({
34
+                'color': "#<?= $this->color ?>",
35
+                'lineWidth': <?= $this->pen ?>,
36
+                'width': '<?= $this->width ?>',
37
+                'height': '<?= $this->height ?>',
38
+                'background-color': "transparent",
39
+                'UndoButton': true
40
+            })
41
+            $sigdiv.bind('change', function(e) {
42
+                document.getElementById("hidden_<?= $this->id ?>").value = $sigdiv.jSignature("getData","default")
41 43
           })
42
-      })
44
+        });
45
+    })(jQuery);
43 46
   </script>
44 47
   
45 48
 <?php $this->endblock(); ?>
46 49
deleted file mode 100644
... ...
@@ -1,165 +0,0 @@
1
-/** @license
2
-jSignature v2 jSignature's Undo Button and undo functionality plugin
3
-
4
-*/
5
-/**
6
-Copyright (c) 2011 Willow Systems Corp http://willow-systems.com
7
-MIT License <http://www.opensource.org/licenses/mit-license.php>
8
-*/
9
-
10
-;(function(){
11
-
12
-	var apinamespace = 'jSignature'
13
-
14
-	function attachHandlers(buttonRenderer, apinamespace, extensionName) {
15
-		var $undoButton = buttonRenderer.call(this)
16
-
17
-		;(function(jSignatureInstance, $undoButton, apinamespace) {
18
-			jSignatureInstance.events.subscribe(
19
-				apinamespace + '.change'
20
-				, function(){
21
-					if (jSignatureInstance.dataEngine.data.length) {
22
-						$undoButton.show()
23
-					} else {
24
-						$undoButton.hide()
25
-					}
26
-				}
27
-			)
28
-		})( this, $undoButton, apinamespace )
29
-
30
-		;(function(jSignatureInstance, $undoButton, apinamespace) {
31
-
32
-			var eventName = apinamespace + '.undo'
33
-
34
-			$undoButton.bind('click', function(){
35
-				jSignatureInstance.events.publish(eventName)
36
-			})
37
-
38
-			// This one creates new "undo" event listener to jSignature instance
39
-			// It handles the actual undo-ing.
40
-			jSignatureInstance.events.subscribe(
41
-				eventName
42
-				, function(){
43
-					var data = jSignatureInstance.dataEngine.data
44
-					if (data.length) {
45
-						data.pop()
46
-						jSignatureInstance.resetCanvas(data)
47
-					}
48
-				}
49
-			)
50
-		})( 
51
-			this
52
-			, $undoButton
53
-			, this.events.topics.hasOwnProperty( apinamespace + '.undo' ) ? 
54
-				// oops, seems some other plugin or code has already claimed "jSignature.undo" event
55
-				// we will use this extension's name for event name prefix
56
-				extensionName :
57
-				// Great! we will use 'jSignature' for event name prefix.
58
-				apinamespace
59
-		)
60
-	}
61
-
62
-	function ExtensionInitializer(extensionName){
63
-		// we are called very early in instance's life.
64
-		// right after the settings are resolved and 
65
-		// jSignatureInstance.events is created 
66
-		// and right before first ("jSignature.initializing") event is called.
67
-		// You don't really need to manupilate 
68
-		// jSignatureInstance directly, just attach
69
-		// a bunch of events to jSignatureInstance.events
70
-		// (look at the source of jSignatureClass to see when these fire)
71
-		// and your special pieces of code will attach by themselves.
72
-
73
-		// this function runs every time a new instance is set up.
74
-		// this means every var you create will live only for one instance
75
-		// unless you attach it to something outside, like "window."
76
-		// and pick it up later from there.
77
-
78
-		// when globalEvents' events fire, 'this' is globalEvents object
79
-		// when jSignatureInstance's events fire, 'this' is jSignatureInstance
80
-
81
-		// Here,
82
-		// this = is new jSignatureClass's instance.
83
-
84
-		// The way you COULD approch setting this up is:
85
-		// if you have multistep set up, attach event to "jSignature.initializing"
86
-		// that attaches other events to be fired further lower the init stream.
87
-		// Or, if you know for sure you rely on only one jSignatureInstance's event,
88
-		// just attach to it directly
89
-
90
-		var apinamespace = 'jSignature'
91
-
92
-		this.events.subscribe(
93
-			// name of the event
94
-			apinamespace + '.attachingEventHandlers'
95
-			// event handlers, can pass args too, but in majority of cases,
96
-			// 'this' which is jSignatureClass object instance pointer is enough to get by.
97
-			, function(){
98
-
99
-				// hooking up "undo" button	to lower edge of Canvas.
100
-				// but only when options passed to jSignature('init', options)
101
-				// contain "undoButton":renderingFunction pair.
102
-				// or "undoButton":true (in which case default, internal rendering fn is used)
103
-				if (this.settings[extensionName]) {
104
-					var oursettings = this.settings[extensionName]
105
-					if (typeof oursettings !== 'function') {
106
-						// we make it a function.
107
-
108
-						// we allow people to override the button rendering code,
109
-						// but when developler is OK with default look (and just passes "truthy" value)
110
-						// this defines default look for the button:
111
-						// centered against canvas, hanging on its lower side.
112
-						oursettings = function(){
113
-							// this === jSignatureInstance 
114
-							var undoButtonSytle = 'position:absolute;display:none;margin:0 !important;top:auto'
115
-							, $undoButton = $('<input type="button" value="Undo last stroke" style="'+undoButtonSytle+'" />')
116
-								.appendTo(this.$controlbarLower)
117
-
118
-							// this centers the button against the canvas.
119
-							var buttonWidth = $undoButton.width()
120
-							$undoButton.css(
121
-								'left'
122
-								, Math.round(( this.canvas.width - buttonWidth ) / 2)
123
-							)
124
-							// IE 7 grows the button. Correcting for that.
125
-							if ( buttonWidth !== $undoButton.width() ) {
126
-								$undoButton.width(buttonWidth)
127
-							}
128
-
129
-							return $undoButton
130
-						}
131
-					}
132
-
133
-					attachHandlers.call( 
134
-						this
135
-						, oursettings
136
-						, apinamespace
137
-						, extensionName
138
-					)
139
-				}
140
-			}
141
-		)
142
-	}
143
-
144
-	var ExtensionAttacher = function(){
145
-		$.fn[apinamespace](
146
-			'addPlugin'
147
-			,'instance' // type of plugin
148
-			,'UndoButton' // extension name
149
-			,ExtensionInitializer
150
-		)
151
-	}
152
-	
153
-
154
-//  //Because plugins are minified together with jSignature, multiple defines per (minified) file blow up and dont make sense
155
-//	//Need to revisit this later.
156
-	
157
-//	if ( typeof define === "function" && define.amd != null) {
158
-//		// AMD-loader compatible resource declaration
159
-//		// you need to call this one with jQuery as argument.
160
-//		define(function(){return Initializer} )
161
-//	} else {
162
-		ExtensionAttacher()
163
-//	}
164
-
165
-})();
166 0
\ No newline at end of file