Git Product home page Git Product logo

Comments (10)

fabien-d avatar fabien-d commented on May 28, 2024

From code, no. You can click to close, plus it automatically closes after set time. Can you provide a use case for this?

from alertify.js.

simonexmachina avatar simonexmachina commented on May 28, 2024

This is related to my other issue. My use case is this:

  1. User clicks a button that triggers a process that can take a number of seconds.
  2. The system shows a notification that the operation is in progress
  3. When the operation is completed the first notification is closed and another notification is displayed to indicate the outcome

There's two things I'd like to do here that I can't using the current API:

  1. Use Spin.js to display a progress indicator, but this requires a DOM element to attach itself to and I can't get this from the Alertify API
  2. Close the first notification when the operation completes

from alertify.js.

fabien-d avatar fabien-d commented on May 28, 2024

I see your point. I'm thinking I may return the log message instead of the alertify object... This would take away chaining on log messages, but would return the newly created log message.

I'll have to consider a few options, see what makes the most sense.

from alertify.js.

simonexmachina avatar simonexmachina commented on May 28, 2024

My suggestion would be to support chaining through the Alertify global, which internally uses an OO Alertify prototype. Then for this scenario API users could use Aleritfy.create() or new Alertify() then have access to instance-specific operations. This Alertify prototyp coule expose the DOM element through a method or a property (ie. .element(), .el, .getElement() etc.) and have a .close() method.

function() {
  Alertify = function() {...}
  Alertify.prototype = {
    el: null,
    alert: function() {
      ...
      return global;
    }, 
    close: function() {...}
  }
  return global = {
    alert: function() {
      return new Alertify().alert();
    },
    ...
    create: function() {
      return new Alertify();
    }
  }
}

Alertify.alert('Hello world')
var obj = Alertify.create();
obj.alert('Hello world')
new Spinner().spin(obj.el)
obj.close();  

from alertify.js.

235 avatar 235 commented on May 28, 2024

I'm facing the same issue. I have to show a permanent alert, something like alertify.log( "Make some action to progress!", "custom",0 ), until a user will take some actions. Then my code has to close it.

from alertify.js.

fabien-d avatar fabien-d commented on May 28, 2024

@SimonWade this is a good approach. I was thinking of separating the log message and the dialog message into separate modules. I would keep the dialog module as a singleton and restructure the log module as a factory.

The idea would be to offer a custom build option for alertify to only include the parts needed.

from alertify.js.

simonexmachina avatar simonexmachina commented on May 28, 2024

I'm not against code separation, but the build process should be optional IMO. One of the things I like about Alertify was that I could bring it in using bower and it worked straight away. So I think that adding the .create() method (or whatever it's called) and, if you do decide to modularise, then include a full build including both dialogs and log messages in the repo.

from alertify.js.

fabien-d avatar fabien-d commented on May 28, 2024

The custom build would be optional - similar to Modernizr.

Bower would still pull in the full core library (no extension). The custom build option would simply be available for extensions that shouldn't be in the core library, but could be useful to some.

from alertify.js.

simonexmachina avatar simonexmachina commented on May 28, 2024

Okay, sounds great!

Cheers,

Simon

On 17 January 2013 02:30, Fabien Doiron [email protected] wrote:

The custom build would be optional - similar to Modernizrhttp://modernizr.com/download/
.

Bower would still pull in the full core library (no extension). The custom
build option would simply be available for extensions that shouldn't be in
the core library, but could be useful to some.


Reply to this email directly or view it on GitHubhttps://github.com//issues/89#issuecomment-12323364.

from alertify.js.

fabien-d avatar fabien-d commented on May 28, 2024

This issue is resolved in 0.4.0rc1. You can now do:

var log = Alertify.log.info("Notification Message", 0);

// close
log.close();

// after closing, you can recreate and reshow
log.create();
log.show();

// you can also get the log element
// returns DOM element
log.el

You can try it out on the demo site

from alertify.js.

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.