Coder Social home page Coder Social logo

Comments (9)

RussCoder avatar RussCoder commented on August 28, 2024

It can be done. Although, there are different ways how it can be implemented. I will think about it.

from djvujs.

r-pankevicius avatar r-pankevicius commented on August 28, 2024

I haven't seen it in action, but as I remember (from translation strings) there is a message "what you would like to do with this multipart document: save this part or pack all parts and save a whole document.

Maybe like this?

from djvujs.

RussCoder avatar RussCoder commented on August 28, 2024

Yes. But I meant a different thing. I could just accept a callback, returning true/false, in which you could just use a standard confirm() function. Or to accept a text, which is shown in a dialog inside the viewer. Probably, the latter variant.

from djvujs.

r-pankevicius avatar r-pankevicius commented on August 28, 2024

I was thinking more about a data-driven stuff like this:
undefined = default (as it is now);
string = the message to display with OK button;
2 strings array: the message to display + text in the button ("Yes, I agree").

Your idea about callback function returning true/false is maybe OK, but I don't fully understand how it will fit here.

Maybe you can give an example of callback function that will work fine for my initial feature request?

from djvujs.

RussCoder avatar RussCoder commented on August 28, 2024

The example of such a function:

function confirmation() {
   return confirm("Doing this you agree with that");
}

Of course, in a more general case it should return a Promise resolving to true or false in order to allow you to use something else besides the confirm() blocking function.
The idea to use a callback came to me with a desire not to create additional visual component and do as little as possible.
However, I know that without confirm() creation of custom window will be a hassle for you, much greater than to add such a feature using existing viewer components for me.

from djvujs.

r-pankevicius avatar r-pankevicius commented on August 28, 2024

Maybe:

function confirmation(confirm) {
   return confirm("Doing this you agree with that");
}

from djvujs.

r-pankevicius avatar r-pankevicius commented on August 28, 2024

Or more sophisticated:

function confirmation(confirm) {
   return confirm(
        /*message*/"Doing this you agree with that", 
        {
            "ok" : "Yes, I agree",
             "cancel": "No, I disagree",
             "default" : "ok"
         });
}

from djvujs.

RussCoder avatar RussCoder commented on August 28, 2024

Do you know that confirm() is a browser built-in function? You can run confirm('Hello!') in the console right now.

In the latest release (viewer 0.5.6), I added a new UI option for you:

uiOptions: {
    onSaveNotification: {
      text: "Here is your notification/agreement for the user",
      yesButton: "Text on the yes button", // optional
      noButton: "Text on the no button", // optional
    },
}

It's also described in the documentation on the website.

from djvujs.

r-pankevicius avatar r-pankevicius commented on August 28, 2024

If you see browser's confirm you'll feel like today is year 1999.

from djvujs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.