Fossil

Diff
Login

Differences From Artifact [80f6cb56ce]:

To Artifact [4f9b4b3128]:


156
157
158
159
160
161
162

163



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
        this.timerID = undefined;
        this.state = this.states.initial;
        const isInput = f.isInput(target);
        const updateText = function(msg){
          if(isInput) target.value = msg;
          else target.innerHTML = msg;
        }

        if(opt.pinSize && opt.confirmText){



          const digits = (''+(opt.timeout/1000 || opt.ticks)).length;
          const lblLong = "("+("00000000".substr(0,digits))+") "+opt.confirmText;
          const w1 = parseFloat(window.getComputedStyle(target).width);
          updateText(lblLong);
          const w2 = parseFloat(window.getComputedStyle(target).width);
          target.style.minWidth = target.style.maxWidth = (w1>w2 ? w1 : w2)+"px";
        }
        updateText(this.opt.initialText);
        if(this.opt.ticks && !this.opt.ontick){
          this.opt.ontick = function(tick){
            updateText("("+tick+") "+self.opt.confirmText);
          };
        }
        this.setClasses(false);
        this.doTimeout = function() {
          if(this.timerID){
            clearTimeout( this.timerID );
            delete this.timerID;







>

>
>
>

|








|







156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
        this.timerID = undefined;
        this.state = this.states.initial;
        const isInput = f.isInput(target);
        const updateText = function(msg){
          if(isInput) target.value = msg;
          else target.innerHTML = msg;
        }
        const formatCountdown = (txt, number) => txt + " ["+number+"]";
        if(opt.pinSize && opt.confirmText){
          /* Try to pin the element's width the the greater of its
             current width or its waiting-on-confirmation width
             to avoid layout reflow when it's activated. */
          const digits = (''+(opt.timeout/1000 || opt.ticks)).length;
          const lblLong = formatCountdown(opt.confirmText, "00000000".substr(0,digits));
          const w1 = parseFloat(window.getComputedStyle(target).width);
          updateText(lblLong);
          const w2 = parseFloat(window.getComputedStyle(target).width);
          target.style.minWidth = target.style.maxWidth = (w1>w2 ? w1 : w2)+"px";
        }
        updateText(this.opt.initialText);
        if(this.opt.ticks && !this.opt.ontick){
          this.opt.ontick = function(tick){
            updateText(formatCountdown(self.opt.confirmText,tick));
          };
        }
        this.setClasses(false);
        this.doTimeout = function() {
          if(this.timerID){
            clearTimeout( this.timerID );
            delete this.timerID;
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
     The default options for initConfirmer(). Tweak them to set the
     defaults. A couple of them (initialText and confirmText) are
     dynamically-generated, and can't reasonably be set in the
     defaults. Some, like ticks, cannot be set here because that would
     end up indirectly replacing non-tick timeouts with ticks.
  */
  F.confirmer.defaultOpts = {
    timeout:3000,
    ticks: undefined,
    ticktime: 998/*not *quite* 1000*/,
    onconfirm: undefined,
    ontimeout: undefined,
    onactivate: undefined,
    classInitial: '',
    classWaiting: '',
    debug: false
  };

})(window.fossil);







|
|










302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
     The default options for initConfirmer(). Tweak them to set the
     defaults. A couple of them (initialText and confirmText) are
     dynamically-generated, and can't reasonably be set in the
     defaults. Some, like ticks, cannot be set here because that would
     end up indirectly replacing non-tick timeouts with ticks.
  */
  F.confirmer.defaultOpts = {
    timeout:undefined,
    ticks: 3,
    ticktime: 998/*not *quite* 1000*/,
    onconfirm: undefined,
    ontimeout: undefined,
    onactivate: undefined,
    classInitial: '',
    classWaiting: '',
    debug: false
  };

})(window.fossil);