fabien-d / alertify.js

JavaScript Alert/Notification System
http://fabien-d.github.com/alertify.js/
4.26k stars 726 forks source link

[Suggestion] Why the HTML as a dependency #224

Open abishekrsrikaanth opened 10 years ago

abishekrsrikaanth commented 10 years ago

I have a suggestion, am not sure what the other things. From the docs of 0.5, I understand that the below HTML needs to be added to the HTML

<!-- preferably just before the closing body tag -->
<div id="alertifyCover" class="alertify-cover alertify-hidden" aria-hidden="true"></div>
<section id="alertifyDialog" class="alertify alertify-close" aria-labelledby="alertifyTitle" aria-hidden="true">
    <div class="alertify-body">
        <p id="alertifyTitle" class="alertify-title"></p>
        <input type="text" id="alertifyInput" class="alertify-input" aria-hidden="true">
        <nav id="alertifyButtons" class="alertify-buttons">
            <button id="alertifyButtonCancel" class="alertify-button alertify-button-cancel" aria-hidden="true"></button>
            <button id="alertifyButtonOk" class="alertify-button alertify-button-ok" aria-hidden="true"></button>
        </nav>
        <a id="alertifyFocusReset" class="alertify-focus-reset" href="#" aria-hidden="true"></a>
    </div>
</section>

Any reason why this cannot be directly appended by the JS plugin? This way the plugin looses the dependency of a developer needing to do anything else other than referencing to the css and js file.

fabien-d commented 10 years ago

I was debating this myself - in 0.3 the HTML was inserted via JS, but with 0.5 I was leaning towards having it in the DOM by default. Saves the DOM injection which (in a way) makes it slightly faster.

I'm not married to the idea - I'm open to re-inserting in the JS if it makes sense. But I do like the idea of HTML being HTML. It's a transition towards it being a component.

abishekrsrikaanth commented 10 years ago

To be frank, I prefer components that are a no brainer when it comes to setting it up. Personally I prefer to do this when I create my components as well for the following reasons.

  1. Helps have complete control within the css and js that is part of the component.
  2. Everybody wants to customize a component to have look and feel based on their app. Having the HTML to be setup separately gives the end developer to make changes to the HTML, which can sometimes make the component to not work because of the changes. And developers will just create issues on github that it is not working because of the customization that they did. It is very difficult for the owner to just figure out why some developer is facing an issue when it is not an issue at all.

This is my opinion. But I am open to other developers views as well.

andyhot commented 10 years ago

Perhaps js can look for #alertifyDialog and if node isn't found, inject it via js