Fossil SCM

Removed devious hard tabs which slipped in while porting.

stephan 2020-05-06 03:19 fileedit-ajaxify
Commit 626c45609ea479782257bec6aa1e30a7561996d6a25ad0404e47cb3b6ddb6aaf
1 file changed +94 -95
--- src/fossil.confirmer.js
+++ src/fossil.confirmer.js
@@ -20,50 +20,49 @@
2020
}
2121
});
2222
2323
Options:
2424
25
- .initialText = initial text of the element. Defaults
26
- to the result of the element's .value (for INPUT tags) or
27
- innerHTML (for everything else).
28
-
29
- .confirmText = text to show when in "confirm mode".
30
- Default=("Confirm: "+initialText), or something similar.
31
-
32
- .timeout = Number of milliseconds to wait for confirmation.
33
- Default=3000.
34
-
35
- .onconfirm = function to call when clicked in confirm mode. Default
36
- = undefined. The function's "this" is the the DOM element to which the
37
- countdown applies.
38
-
39
- .ontimeout = function to call when confirm is not issued. Default =
40
- undefined. The function's "this" is the DOM element to which the
41
- countdown applies.
42
-
43
- .onactivate = function to call when item is clicked, but only if the
44
- item is not currently in countdown mode. This is called (and must
45
- return) before the countdown starts. The function's "this" is the
46
- DOM element to which the countdown applies. This can be used, e.g.,
25
+ .initialText = initial text of the element. Defaults to the result
26
+ of the element's .value (for INPUT tags) or innerHTML (for
27
+ everything else).
28
+
29
+ .confirmText = text to show when in "confirm mode".
30
+ Default=("Confirm: "+initialText), or something similar.
31
+
32
+ .timeout = Number of milliseconds to wait for confirmation.
33
+ Default=3000.
34
+
35
+ .onconfirm = function to call when clicked in confirm mode. Default
36
+ = undefined. The function's "this" is the the DOM element to which
37
+ the countdown applies.
38
+
39
+ .ontimeout = function to call when confirm is not issued. Default =
40
+ undefined. The function's "this" is the DOM element to which the
41
+ countdown applies.
42
+
43
+ .onactivate = function to call when item is clicked, but only if the
44
+ item is not currently in countdown mode. This is called (and must
45
+ return) before the countdown starts. The function's "this" is the
46
+ DOM element to which the countdown applies. This can be used, e.g.,
4747
to change the element's text or CSS classes.
4848
49
- .classInitial = optional CSS class string (default='') which
50
- is added to the element during its "initial" state (the state
51
- it is in when it is not waiting on a timeout). When the target
52
- is activated (waiting on a timeout) this class is removed.
53
- In the case of a timeout, this class is added *before* the
54
- .ontimeout handler is called.
55
-
56
- .classActivated = optional CSS class string (default='') which
57
- is added to the target when it is waiting on a timeout. When
58
- the target leaves timeout-wait mode, this class is removed.
59
- When timeout-wait mode is entered, this class is added *before*
60
- the .onactivate handler is called.
61
-
62
- .debug = boolean. If truthy, it sends some debug output
63
- to the dev console to track what it's doing.
64
-
49
+ .classInitial = optional CSS class string (default='') which is
50
+ added to the element during its "initial" state (the state it is in
51
+ when it is not waiting on a timeout). When the target is activated
52
+ (waiting on a timeout) this class is removed. In the case of a
53
+ timeout, this class is added *before* the .ontimeout handler is
54
+ called.
55
+
56
+ .classActivated = optional CSS class string (default='') which is
57
+ added to the target when it is waiting on a timeout. When the target
58
+ leaves timeout-wait mode, this class is removed. When timeout-wait
59
+ mode is entered, this class is added *before* the .onactivate
60
+ handler is called.
61
+
62
+ .debug = boolean. If truthy, it sends some debug output to the dev
63
+ console to track what it's doing.
6564
6665
Due to the nature of multi-threaded code, it is potentially possible
6766
that confirmation and timeout actions BOTH happen if the user triggers
6867
the associated action at "just the right millisecond" before the
6968
timeout is triggered.
@@ -104,70 +103,70 @@
104103
if(isInput) target.value = msg;
105104
else target.innerHTML = msg;
106105
}
107106
updateText(self.opt.initialText);
108107
this.setClasses(false);
109
- this.doTimeout = function() {
110
- this.timerID = undefined;
111
- if( this.state != this.states.waiting ) {
112
- // it was already confirmed
113
- return;
114
- }
115
- this.setClasses( false );
116
- this.state = this.states.initial;
117
- dbg("Timeout triggered.");
118
- updateText(this.opt.initialText);
119
- if( this.opt.ontimeout ) {
120
- this.opt.ontimeout.call(this.target);
121
- }
122
- };
108
+ this.doTimeout = function() {
109
+ this.timerID = undefined;
110
+ if( this.state != this.states.waiting ) {
111
+ // it was already confirmed
112
+ return;
113
+ }
114
+ this.setClasses( false );
115
+ this.state = this.states.initial;
116
+ dbg("Timeout triggered.");
117
+ updateText(this.opt.initialText);
118
+ if( this.opt.ontimeout ) {
119
+ this.opt.ontimeout.call(this.target);
120
+ }
121
+ };
123122
target.addEventListener(
124123
'click', function(){
125
- switch( self.state ) {
126
- case( self.states.waiting ):
127
- if( undefined !== self.timerID ) clearTimeout( self.timerID );
128
- self.state = self.states.initial;
129
- self.setClasses( false );
130
- dbg("Confirmed");
131
- updateText(self.opt.initialText);
132
- if( self.opt.onconfirm ) self.opt.onconfirm.call(self.target);
133
- break;
134
- case( self.states.initial ):
135
- self.setClasses( true );
136
- if( self.opt.onactivate ) self.opt.onactivate.call( self.target );
137
- self.state = self.states.waiting;
138
- dbg("Waiting "+self.opt.timeout+"ms on confirmation...");
139
- updateText( self.opt.confirmText );
140
- self.timerID = setTimeout(function(){self.doTimeout();},self.opt.timeout );
141
- break;
142
- default: // can't happen.
143
- break;
144
- }
124
+ switch( self.state ) {
125
+ case( self.states.waiting ):
126
+ if( undefined !== self.timerID ) clearTimeout( self.timerID );
127
+ self.state = self.states.initial;
128
+ self.setClasses( false );
129
+ dbg("Confirmed");
130
+ updateText(self.opt.initialText);
131
+ if( self.opt.onconfirm ) self.opt.onconfirm.call(self.target);
132
+ break;
133
+ case( self.states.initial ):
134
+ self.setClasses( true );
135
+ if( self.opt.onactivate ) self.opt.onactivate.call( self.target );
136
+ self.state = self.states.waiting;
137
+ dbg("Waiting "+self.opt.timeout+"ms on confirmation...");
138
+ updateText( self.opt.confirmText );
139
+ self.timerID = setTimeout(function(){self.doTimeout();},self.opt.timeout );
140
+ break;
141
+ default: // can't happen.
142
+ break;
143
+ }
145144
}, false
146145
);
147146
};
148147
f.Holder.prototype = {
149148
states:{
150149
initial: 0, waiting: 1
151150
},
152151
setClasses: function(activated) {
153
- if( activated ) {
154
- if( this.opt.classActivated ) {
155
- this.target.addClass( this.opt.classActivated );
156
- }
157
- if( this.opt.classInitial ) {
158
- this.target.removeClass( this.opt.classInitial );
159
- }
160
- } else {
161
- if( this.opt.classInitial ) {
162
- this.target.addClass( this.opt.classInitial );
163
- }
164
- if( this.opt.classActivated ) {
165
- this.target.removeClass( this.opt.classActivated );
166
- }
167
- }
168
- }
152
+ if( activated ) {
153
+ if( this.opt.classActivated ) {
154
+ this.target.addClass( this.opt.classActivated );
155
+ }
156
+ if( this.opt.classInitial ) {
157
+ this.target.removeClass( this.opt.classInitial );
158
+ }
159
+ } else {
160
+ if( this.opt.classInitial ) {
161
+ this.target.addClass( this.opt.classInitial );
162
+ }
163
+ if( this.opt.classActivated ) {
164
+ this.target.removeClass( this.opt.classActivated );
165
+ }
166
+ }
167
+ }
169168
170169
};
171170
}/*static init*/
172171
opt = F.mergeLastWins(f.defaultOpts,{
173172
initialText: (
@@ -185,15 +184,15 @@
185184
defaults. A couple of them (initialText and confirmText) are
186185
dynamically-generated, and can't reasonably be set in the
187186
defaults.
188187
*/
189188
F.confirmer.defaultOpts = {
190
- timeout:3000,
191
- onconfirm:undefined,
192
- ontimeout:undefined,
193
- onactivate:undefined,
194
- classInitial:'',
195
- classActivated:'',
196
- debug:true
189
+ timeout:3000,
190
+ onconfirm:undefined,
191
+ ontimeout:undefined,
192
+ onactivate:undefined,
193
+ classInitial:'',
194
+ classActivated:'',
195
+ debug:true
197196
};
198197
199198
})(window.fossil);
200199
--- src/fossil.confirmer.js
+++ src/fossil.confirmer.js
@@ -20,50 +20,49 @@
20 }
21 });
22
23 Options:
24
25 .initialText = initial text of the element. Defaults
26 to the result of the element's .value (for INPUT tags) or
27 innerHTML (for everything else).
28
29 .confirmText = text to show when in "confirm mode".
30 Default=("Confirm: "+initialText), or something similar.
31
32 .timeout = Number of milliseconds to wait for confirmation.
33 Default=3000.
34
35 .onconfirm = function to call when clicked in confirm mode. Default
36 = undefined. The function's "this" is the the DOM element to which the
37 countdown applies.
38
39 .ontimeout = function to call when confirm is not issued. Default =
40 undefined. The function's "this" is the DOM element to which the
41 countdown applies.
42
43 .onactivate = function to call when item is clicked, but only if the
44 item is not currently in countdown mode. This is called (and must
45 return) before the countdown starts. The function's "this" is the
46 DOM element to which the countdown applies. This can be used, e.g.,
47 to change the element's text or CSS classes.
48
49 .classInitial = optional CSS class string (default='') which
50 is added to the element during its "initial" state (the state
51 it is in when it is not waiting on a timeout). When the target
52 is activated (waiting on a timeout) this class is removed.
53 In the case of a timeout, this class is added *before* the
54 .ontimeout handler is called.
55
56 .classActivated = optional CSS class string (default='') which
57 is added to the target when it is waiting on a timeout. When
58 the target leaves timeout-wait mode, this class is removed.
59 When timeout-wait mode is entered, this class is added *before*
60 the .onactivate handler is called.
61
62 .debug = boolean. If truthy, it sends some debug output
63 to the dev console to track what it's doing.
64
65
66 Due to the nature of multi-threaded code, it is potentially possible
67 that confirmation and timeout actions BOTH happen if the user triggers
68 the associated action at "just the right millisecond" before the
69 timeout is triggered.
@@ -104,70 +103,70 @@
104 if(isInput) target.value = msg;
105 else target.innerHTML = msg;
106 }
107 updateText(self.opt.initialText);
108 this.setClasses(false);
109 this.doTimeout = function() {
110 this.timerID = undefined;
111 if( this.state != this.states.waiting ) {
112 // it was already confirmed
113 return;
114 }
115 this.setClasses( false );
116 this.state = this.states.initial;
117 dbg("Timeout triggered.");
118 updateText(this.opt.initialText);
119 if( this.opt.ontimeout ) {
120 this.opt.ontimeout.call(this.target);
121 }
122 };
123 target.addEventListener(
124 'click', function(){
125 switch( self.state ) {
126 case( self.states.waiting ):
127 if( undefined !== self.timerID ) clearTimeout( self.timerID );
128 self.state = self.states.initial;
129 self.setClasses( false );
130 dbg("Confirmed");
131 updateText(self.opt.initialText);
132 if( self.opt.onconfirm ) self.opt.onconfirm.call(self.target);
133 break;
134 case( self.states.initial ):
135 self.setClasses( true );
136 if( self.opt.onactivate ) self.opt.onactivate.call( self.target );
137 self.state = self.states.waiting;
138 dbg("Waiting "+self.opt.timeout+"ms on confirmation...");
139 updateText( self.opt.confirmText );
140 self.timerID = setTimeout(function(){self.doTimeout();},self.opt.timeout );
141 break;
142 default: // can't happen.
143 break;
144 }
145 }, false
146 );
147 };
148 f.Holder.prototype = {
149 states:{
150 initial: 0, waiting: 1
151 },
152 setClasses: function(activated) {
153 if( activated ) {
154 if( this.opt.classActivated ) {
155 this.target.addClass( this.opt.classActivated );
156 }
157 if( this.opt.classInitial ) {
158 this.target.removeClass( this.opt.classInitial );
159 }
160 } else {
161 if( this.opt.classInitial ) {
162 this.target.addClass( this.opt.classInitial );
163 }
164 if( this.opt.classActivated ) {
165 this.target.removeClass( this.opt.classActivated );
166 }
167 }
168 }
169
170 };
171 }/*static init*/
172 opt = F.mergeLastWins(f.defaultOpts,{
173 initialText: (
@@ -185,15 +184,15 @@
185 defaults. A couple of them (initialText and confirmText) are
186 dynamically-generated, and can't reasonably be set in the
187 defaults.
188 */
189 F.confirmer.defaultOpts = {
190 timeout:3000,
191 onconfirm:undefined,
192 ontimeout:undefined,
193 onactivate:undefined,
194 classInitial:'',
195 classActivated:'',
196 debug:true
197 };
198
199 })(window.fossil);
200
--- src/fossil.confirmer.js
+++ src/fossil.confirmer.js
@@ -20,50 +20,49 @@
20 }
21 });
22
23 Options:
24
25 .initialText = initial text of the element. Defaults to the result
26 of the element's .value (for INPUT tags) or innerHTML (for
27 everything else).
28
29 .confirmText = text to show when in "confirm mode".
30 Default=("Confirm: "+initialText), or something similar.
31
32 .timeout = Number of milliseconds to wait for confirmation.
33 Default=3000.
34
35 .onconfirm = function to call when clicked in confirm mode. Default
36 = undefined. The function's "this" is the the DOM element to which
37 the countdown applies.
38
39 .ontimeout = function to call when confirm is not issued. Default =
40 undefined. The function's "this" is the DOM element to which the
41 countdown applies.
42
43 .onactivate = function to call when item is clicked, but only if the
44 item is not currently in countdown mode. This is called (and must
45 return) before the countdown starts. The function's "this" is the
46 DOM element to which the countdown applies. This can be used, e.g.,
47 to change the element's text or CSS classes.
48
49 .classInitial = optional CSS class string (default='') which is
50 added to the element during its "initial" state (the state it is in
51 when it is not waiting on a timeout). When the target is activated
52 (waiting on a timeout) this class is removed. In the case of a
53 timeout, this class is added *before* the .ontimeout handler is
54 called.
55
56 .classActivated = optional CSS class string (default='') which is
57 added to the target when it is waiting on a timeout. When the target
58 leaves timeout-wait mode, this class is removed. When timeout-wait
59 mode is entered, this class is added *before* the .onactivate
60 handler is called.
61
62 .debug = boolean. If truthy, it sends some debug output to the dev
63 console to track what it's doing.
 
64
65 Due to the nature of multi-threaded code, it is potentially possible
66 that confirmation and timeout actions BOTH happen if the user triggers
67 the associated action at "just the right millisecond" before the
68 timeout is triggered.
@@ -104,70 +103,70 @@
103 if(isInput) target.value = msg;
104 else target.innerHTML = msg;
105 }
106 updateText(self.opt.initialText);
107 this.setClasses(false);
108 this.doTimeout = function() {
109 this.timerID = undefined;
110 if( this.state != this.states.waiting ) {
111 // it was already confirmed
112 return;
113 }
114 this.setClasses( false );
115 this.state = this.states.initial;
116 dbg("Timeout triggered.");
117 updateText(this.opt.initialText);
118 if( this.opt.ontimeout ) {
119 this.opt.ontimeout.call(this.target);
120 }
121 };
122 target.addEventListener(
123 'click', function(){
124 switch( self.state ) {
125 case( self.states.waiting ):
126 if( undefined !== self.timerID ) clearTimeout( self.timerID );
127 self.state = self.states.initial;
128 self.setClasses( false );
129 dbg("Confirmed");
130 updateText(self.opt.initialText);
131 if( self.opt.onconfirm ) self.opt.onconfirm.call(self.target);
132 break;
133 case( self.states.initial ):
134 self.setClasses( true );
135 if( self.opt.onactivate ) self.opt.onactivate.call( self.target );
136 self.state = self.states.waiting;
137 dbg("Waiting "+self.opt.timeout+"ms on confirmation...");
138 updateText( self.opt.confirmText );
139 self.timerID = setTimeout(function(){self.doTimeout();},self.opt.timeout );
140 break;
141 default: // can't happen.
142 break;
143 }
144 }, false
145 );
146 };
147 f.Holder.prototype = {
148 states:{
149 initial: 0, waiting: 1
150 },
151 setClasses: function(activated) {
152 if( activated ) {
153 if( this.opt.classActivated ) {
154 this.target.addClass( this.opt.classActivated );
155 }
156 if( this.opt.classInitial ) {
157 this.target.removeClass( this.opt.classInitial );
158 }
159 } else {
160 if( this.opt.classInitial ) {
161 this.target.addClass( this.opt.classInitial );
162 }
163 if( this.opt.classActivated ) {
164 this.target.removeClass( this.opt.classActivated );
165 }
166 }
167 }
168
169 };
170 }/*static init*/
171 opt = F.mergeLastWins(f.defaultOpts,{
172 initialText: (
@@ -185,15 +184,15 @@
184 defaults. A couple of them (initialText and confirmText) are
185 dynamically-generated, and can't reasonably be set in the
186 defaults.
187 */
188 F.confirmer.defaultOpts = {
189 timeout:3000,
190 onconfirm:undefined,
191 ontimeout:undefined,
192 onactivate:undefined,
193 classInitial:'',
194 classActivated:'',
195 debug:true
196 };
197
198 })(window.fossil);
199

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button