onPage plugin in npm

onPage plugin in npm

bg7bg7 Posts: 132Questions: 19Answers: 0

We're migrating to use npm and all of the plugins that we're using are there except one.

https://datatables.net/blog/2017/always-visible-editing-panel

On that page is a link to the source in the "Complete plug-in code" section but unfortunately that link seems to be broken and instead redirects to the main plugins page.

Would it be possible to add this plugin to the plugins page list as well as add it to npm with the other plugins? I've included the plugin code that used to be available below.

Thanks.

Ben

/* https://editor.datatables.net/plug-ins/display-controller/editor.onPage */

function onPageDisplay ( elm ) {
  let name = 'onPage'+Math.random();
  let Editor = $.fn.dataTable.Editor;
  let emptyInfo;

  Editor.display[name] = $.extend( true, {}, Editor.models.display, {
    // Create the HTML mark-up needed the display controller
    init: function ( editor ) {
      emptyInfo = elm.html();
      return Editor.display[name];
    },

    // Show the form
    open: function ( editor, form, callback ) {
      elm.children().detach();
      elm.append( form );

      if ( callback ) {
        callback();
      }
    },

    // Hide the form
    close: function ( editor, callback ) {
      elm.children().detach();
      elm.html( emptyInfo );

      if ( callback ) {
        callback();
      }
    },

    node: function () {
      return elm;
    }
  } );

  return name;
}

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 65,891Questions: 1Answers: 10,962 Site admin
    Answer ✓

    The onPageDisplay display controller isn't needed any more with Editor 3 :).

    Use the new static display controller, which is basically the same thing, just integrated into Editor core.

    Allan

  • bg7bg7 Posts: 132Questions: 19Answers: 0
    edited August 10

    Allan,

    Very cool. We've not upgraded to 3.0 yet as we're in a holding pattern until StateRestore is ready. I'll make a note to check it out when we upgrade.

    Thanks.

    Ben

  • allanallan Posts: 65,891Questions: 1Answers: 10,962 Site admin

    Ah yes, sorry. I'd forgotten you were waiting on StateRestore. Hopefully news on that soon :)

    Allan

Sign In or Register to comment.