Browse code

Konflikt mit anderen JavaScripts beseitigt

Hagen Klemp authored on16/02/2019 15:04:53
Showing1 changed files
1 1
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
Browse code

Initial

Hagen Klemp authored on03/02/2019 23:08:50
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,165 @@
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
+})();
0 166
\ No newline at end of file