Git Product home page Git Product logo

Comments (9)

cbotman avatar cbotman commented on May 27, 2024 10

We're talking now of maybe doing this sooner rather than later. Will report back later this week with thoughts.

from modaal.

faradaytrs avatar faradaytrs commented on May 27, 2024 1

Any progress on this?

from modaal.

danhumaan avatar danhumaan commented on May 27, 2024

Hi @medikoo
Thanks for opening the conversation, it's certainly something we've thought about. At this time however, this is the library we chose to build on top of. We agree that there is value in not having a dependency and we will consider it down the line for expansion of the plugin.

from modaal.

bklik avatar bklik commented on May 27, 2024

Moving these examples here from #29 since I closed it.

e.g.
var dom = document.body;
var element = document.querySelector('.class-name|#id');
if(element.classList.contains('class-name') {};
element.addEventListener('click|keydown', function);
etc.

from modaal.

cbotman avatar cbotman commented on May 27, 2024

Yeah at first glance I thought this would be straight forward too, but we are using jQuery for more than just fancy DOM selectors and things. Yesterday I got as far as compiling a list of all the jQuery methods we use, so can look at what it would take to replace them all.

As you can see there are quite a lot of calls. So the question is where do we draw the line between implementing a lot of basic methods (adding weight to Modaal even when jQuery is present), versus depending on a library?

I would like to take a look at other UI/widget libraries (things like Isotope or even other modals), and see how they've handled this.

For replacing animate(), I can imagine having a sort of progressive enhancement. So if you have included a library that provides the animate API, such as jQuery or Velocity.js, we use it, otherwise we skip the animation and jump to the end result. E.g. an element might show or hide instantly rather than fading. Just an idea.

I'm sure we're not the first to have this discussion, so please feel free to share anything you know of that's relevant. :)

The list:

Handy selectors and DOM traversal:
$()
element.children()
element.contains()
element.find()
element.is()

DOM manipulation:
element.addClass()
element.append()
element.attr() and element.getAttribute() (why both?)
element.clone()
element.css()
element.data()
element.empty()
element.hasClass()
element.hide()
element.html()
element.on() - bind event
element.off() - unbind event
element.removeAttr()
element.removeClass()

Animation:
element.animate() - only used to fade opacity and call oncomplete() callback
element.stop()

AJAX:
$.ajax() (.success(), .error() and .abort() callbacks)

Misc:
array.extend() (options array, etc)

from modaal.

silvenon avatar silvenon commented on May 27, 2024

You could use Zepto, which has the same API, but much smaller file size. If you'd like to go vanilla JS (I recommend, because jQuery is an unnecessary abstraction today), You Might Not Need jQuery is a good resource. Here is some stuff I found as a response to your list:

Selectors and DOM traversal

$()

The dollar does a lot of things. If you're using it for selecting, use these:

  • document.querySelector(selector)
  • document.querySelectorAll(selector)

$el.children()

Vanilla: el.children

However, note that document.querySelectorAll returns a NodeList, .children returns a HTMLCollection etc. None of these can be looped through directly because they are not arrays, they are array-like. You can transform them into arrays using Array.from().

$el.contains($child)

Vanilla: el !== child && el.contains(child)

$el.find(selector)

Vanilla: el.querySelector(selector)/el.querySelectorAll(selector)

$el.is($otherEl)

Vanilla: el === otherEl

DOM manipulation

$el.addClass()/$el.removeClass()

For all classy stuff use classie for IE8+ or these for IE10+:

  • el.classList.add()
  • el.classList.remove()

$el.append()

Vanilla: el.appendChild()

$el.attr()/$el.removeAttribute()

Vanilla:

  • el.getAttribute(attr)
  • el.setAttribute(attr, value)
  • el.removeAttribute()

$el.clone()

Vanilla: el.cloneNode(true)

$el.css('background', 'blue')

Vanilla: el.style.background = 'blue'

$el.data()

Vanilla: ?

$el.empty()

Vanilla: el.innerHTML = ''

$el.hide()

Vanilla: el.style.display = 'none'

$el.html()

Vanilla: el.innerHTML

$el.on()/$el.off()

For all eventy stuff use eventie for IE8+ or these for IE9+:

  • el.addEventListener()
  • el.removeEventListener()

AJAX

Maybe it's a good idea to use the Fetch API if IE10+ is acceptable. Otherwise you could find a tiny AJAX library on Microjs.

from modaal.

cbotman avatar cbotman commented on May 27, 2024

Hi @silvenon, thanks for putting that together. I'll have a good read and try to get some time on this late next week.

from modaal.

kareljan avatar kareljan commented on May 27, 2024

What's the status on this? Or is this project dead?

from modaal.

danhumaan avatar danhumaan commented on May 27, 2024

hi @kareljan - project is technically not dead, this github may seem very quite but it is a tool we still use nearly daily. The difficulty has been dedicating time to it and work through both updates, and bugs as other, billable, projects unfortunately take some priority.

This particular task is something that is definitely on our minds with the plugin, though I can't provide any more detail than that, ora timeframe on when it may be looked at.

Thanks for your patience.

from modaal.

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.