Skip to content

Instantly share code, notes, and snippets.

@chlab
Last active December 23, 2015 10:39
Show Gist options
  • Save chlab/6622844 to your computer and use it in GitHub Desktop.
Save chlab/6622844 to your computer and use it in GitHub Desktop.
This diff describes the changes necessary to get Kalendae to work in IE7.
@@ -12,7 +12,6 @@
var today;
var Kalendae = function (targetElement, options) {
- if (typeof document.addEventListener !== 'function' && !util.isIE8()) return;
//if the first argument isn't an element and isn't a string, assume that it is the options object
var is_element = false;
@@ -574,10 +573,19 @@
},
$$: function (selector) {
+ if (typeof jQuery !== 'undefined') {
+ return jQuery(selector).get();
+ }
return document.querySelectorAll(selector);
},
make: function (tagName, attributes, attach) {
+ if (typeof jQuery !== 'undefined') {
+ var $e = $('<' + tagName + '/>').attr(attributes);
+ if (attach)
+ $e.appendTo(attach);
+ return $e.get(0);
+ }
var k, e = document.createElement(tagName);
if (!!attributes) for (k in attributes) if (attributes.hasOwnProperty(k)) e.setAttribute(k, attributes[k]);
if (!!attach) attach.appendChild(e);
@@ -743,7 +751,7 @@
//auto-initializaiton code
-if (typeof document.addEventListener === 'function') Kalendae.util.domReady(function () {
+Kalendae.util.domReady(function () {
var els = util.$$('.auto-kal'),
i = els.length,
e,
@@ -765,8 +773,8 @@
}
});
+
Kalendae.Input = function (targetElement, options) {
- if (typeof document.addEventListener !== 'function' && !util.isIE8()) return;
var $input = this.input = util.$(targetElement),
overwriteInput;
@@ -1725,7 +1733,7 @@
today = moment().stripTime();
-if (typeof jQuery !== 'undefined' && typeof document.addEventListener === 'function') {
+if (typeof jQuery !== 'undefined') {
jQuery.fn.kalendae = function (options) {
this.each(function (i, e) {
if (e.tagName === 'INPUT') {
@@ -1737,7 +1745,7 @@
}
});
return this;
- }
+ };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment