<commit_before>
type("InlineWidget", ["IWidget"],
     {
         _error: function(error) {
             IndicoUI.Dialogs.Util.error(error);
         }
     });


/*
 * This class implements a widget that interacts directly with the
 * remote server. States are handled, through a callback interface.
 */
type("InlineRemoteWidget", ["InlineWidget"],

     {

         _handleError: function(error) {
             this._error(error);
         },

         _handleLoading: function(error) {
             return Html.span({}, 'loading...');
         },

         _handleLoaded: function() {
             // do nothing, overload
         },

         _handleBackToEditMode: function() {
             // do nothing, overload
         },

         draw: function() {
             var self = this;
             var t;
             t = setTimeout("$E(\""+"message" + "\").set(\'\u00A0\')",2000);
             var canvas = Html.span({}, 'loading...');
             canvas.set(self.drawContent());
             var message = Html.span({style: {marginLeft:'10px'}},'\u00A0');
             message.dom.id = "message";
             if (t){ clearTimeout(t);}
             var table = Html.table();
             table.dom.style.display = 'inline';
             var tbody = Html.tbody();
             table.set(tbody);
             var row1 = Html.tr();
             var cell2 = Html.td();
                    cell2.append(canvas);
                    row1.append(cell2);
             cellMessage = Html.td();
             cellMessage.dom.style.verticalAlign = "middle";
             cellMessage.dom.rowSpan = 2;
             cellMessage.append(message);
             row1.append(cellMessage);

             var content = this._handleContent();

             // if the widget is set to load on startup,
             // the content will be a 'loading' message
             var wcanvas = Html.div({}, this.loadOnStartup?
                                   this._handleLoading():
                                   content);

             // observe state changes and call
             // the handlers accordingly
             this.source.state.observe(function(state) {
                 if (state == SourceState.Error) {
                     self._handleError(self.source.error.get());
                     wcanvas.set(content);
                     self.setMode('edit');
                     self._handleBackToEditMode();
                 } else if (state == SourceState.Loaded) {
                     self._handleLoaded(self.source.get());
                     wcanvas.set(content);
                     self.setMode('display');
                 } else {
                     wcanvas.set(self._handleLoading());
                 }
             });
            

             
             return wcanvas;
         }

     },
     /*
      * method - remote method
      * attributes - attributes that are passed
      * loadOnStartup - should the widget start loading from the
      * server automatically?
      */
     function(method, attributes, loadOnStartup, callback) {
         loadOnStartup = exists(loadOnStartup)?loadOnStartup:true;
         this.ready = new WatchValue();
         this.ready.set(false);
         this.loadOnStartup = loadOnStartup;
         this.source = indicoSource(method, attributes, null, !loadOnStartup, callback);
     });

type("InlineRemoteWidgetForOptionButton", ["InlineWidget"],
     {
         draw: function() {
             var self = this;
             var t;
             t = setTimeout("$E(\""+"message" + "\").set(\'\u00A0\')",2000);
             var canvas = Html.span({}, 'loading...');
             canvas.set(self.drawContent());
             var message = Html.span({style: {marginLeft:'10px'}},'\u00A0');
             message.dom.id = "message";
             if (t){ clearTimeout(t);}
             var table = Html.table();
             table.dom.style.display = 'inline';
             var tbody = Html.tbody();
             table.set(tbody);
             var row1 = Html.tr();
             var cell2 = Html.td();
                    cell2.append(canvas);
                    row1.append(cell2);
             cellMessage = Html.td();
             cellMessage.dom.style.verticalAlign = "middle";
             cellMessage.dom.rowSpan = 2;
             cellMessage.append(message);
             row1.append(cellMessage);

             tbody.append(row1);

             this.source.state.observe(function(state) {
                 if (state == SourceState.Error) {
                     self.ready.set(true);
                     self._error(self.source.error.get());
                 } else if (state == SourceState.Committing) {
                     self.ready.set(true);
                     message.set('Saving');
                     message.dom.style.color='orange';
                  } 
                    else  {message.set(' ');}
             });
            

             return table;
         }

     },
     function(method, attributes) {
         this.ready = new WatchValue();
         this.ready.set(false);
         this.source = indicoSource(method, attributes);
     });
     
type("SwitchOptionButton", ["InlineRemoteWidgetForOptionButton"],
     {
         error: function(error) {
             this.checkbox.set(true);
             alert(error.message);
         },

         drawContent: function() {
             return Html.div({},
                             this.checkbox,
                             this.caption);

         }
     },
     function(method, attributes, caption) {
         this.InlineRemoteWidgetForOptionButton(method, attributes);
         this.caption = caption;
         this.checkbox = Html.checkbox({});

         $B(this.checkbox, this.source);
     });


/*
 * This switch button is a 2-state switch that allows different requests to be
 * performed depending on whether the button should be enabled or disabled
 */
type("RemoteSwitchButton", ["InlineWidget"],
     {
         draw: function() {
<commit_msg>[FIX] Bringing back the inline edit<commit_after>
type("InlineWidget", ["IWidget"],
     {
         _error: function(error) {
             IndicoUI.Dialogs.Util.error(error);
         }
     });


/*
 * This class implements a widget that interacts directly with the
 * remote server. States are handled, through a callback interface.
 */
type("InlineRemoteWidget", ["InlineWidget"],

     {

         _handleError: function(error) {
             this._error(error);
         },

         _handleLoading: function(error) {
             return Html.span({}, 'loading...');
         },

         _handleLoaded: function() {
             // do nothing, overload
         },

         _handleBackToEditMode: function() {
             // do nothing, overload
         },

         draw: function() {
             var self = this;

             var content = this._handleContent();

             // if the widget is set to load on startup,
             // the content will be a 'loading' message
             var wcanvas = Html.div({}, this.loadOnStartup?
                                   this._handleLoading():
                                   content);

             // observe state changes and call
             // the handlers accordingly
             this.source.state.observe(function(state) {
                 if (state == SourceState.Error) {
                     self._handleError(self.source.error.get());
                     wcanvas.set(content);
                     self.setMode('edit');
                     self._handleBackToEditMode();
                 } else if (state == SourceState.Loaded) {
                     self._handleLoaded(self.source.get());
                     wcanvas.set(content);
                     self.setMode('display');
                 } else {
                     wcanvas.set(self._handleLoading());
                 }
             });

             return wcanvas;
         }

     },
     /*
      * method - remote method
      * attributes - attributes that are passed
      * loadOnStartup - should the widget start loading from the
      * server automatically?
      */
     function(method, attributes, loadOnStartup, callback) {
         loadOnStartup = exists(loadOnStartup)?loadOnStartup:true;
         this.ready = new WatchValue();
         this.ready.set(false);
         this.loadOnStartup = loadOnStartup;
         this.source = indicoSource(method, attributes, null, !loadOnStartup, callback);
     });

type("InlineRemoteWidgetForOptionButton", ["InlineWidget"],
     {
         draw: function() {
             var self = this;
             var t;
             t = setTimeout("$E(\""+"message" + "\").set(\'\u00A0\')",2000);
             var canvas = Html.span({}, 'loading...');
             canvas.set(self.drawContent());
             var message = Html.span({style: {marginLeft:'10px'}},'\u00A0');
             message.dom.id = "message";
             if (t){ clearTimeout(t);}
             var table = Html.table();
             table.dom.style.display = 'inline';
             var tbody = Html.tbody();
             table.set(tbody);
             var row1 = Html.tr();
             var cell2 = Html.td();
                    cell2.append(canvas);
                    row1.append(cell2);
             cellMessage = Html.td();
             cellMessage.dom.style.verticalAlign = "middle";
             cellMessage.dom.rowSpan = 2;
             cellMessage.append(message);
             row1.append(cellMessage);

             tbody.append(row1);

             this.source.state.observe(function(state) {
                 if (state == SourceState.Error) {
                     self.ready.set(true);
                     self._error(self.source.error.get());
                 } else if (state == SourceState.Committing) {
                     self.ready.set(true);
                     message.set('Saving');
                     message.dom.style.color='orange';
                  }
                    else  {message.set(' ');}
             });


             return table;
         }

     },
     function(method, attributes) {
         this.ready = new WatchValue();
         this.ready.set(false);
         this.source = indicoSource(method, attributes);
     });

type("SwitchOptionButton", ["InlineRemoteWidgetForOptionButton"],
     {
         error: function(error) {
             this.checkbox.set(true);
             alert(error.message);
         },

         drawContent: function() {
             return Html.div({},
                             this.checkbox,
                             this.caption);

         }
     },
     function(method, attributes, caption) {
         this.InlineRemoteWidgetForOptionButton(method, attributes);
         this.caption = caption;
         this.checkbox = Html.checkbox({});

         $B(this.checkbox, this.source);
     });


/*
 * This switch button is a 2-state switch that allows different requests to be
 * performed depending on whether the button should be enabled or disabled
 */
type("RemoteSwitchButton", ["InlineWidget"],
     {
         draw: function() {

{'fraction_non_alphanumeric': 0.1217971851317214, 'fraction_numerical': 0.005503428365211115, 'mean_word_length': 1.4743303571428572, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5316882', 'n_tokens_mistral': 2864, 'n_tokens_neox': 2763, 'n_words': 583}