DIsable JavaScript password strength meter - javascript

I would like to disable the JQuery password strength meter. I think it's running from the following script.
Can I just remove the script link(s), or would it likely cause validation issues? Should I be un-enquing scripts instead? I am pretty clueless with JS, an example would be greatly appreciated.
jQuery(function(s) {
var r = {
init: function() {
s(document.body).on("keyup change", "form.register #reg_password, form.checkout #account_password, form.edit-account #password_1, form.lost_reset_password #password_1", this.strengthMeter), s("form.checkout #createaccount").change()
},
strengthMeter: function() {
var e = s("form.register, form.checkout, form.edit-account, form.lost_reset_password"),
t = s('input[type="submit"]', e),
a = s("#reg_password, #account_password, #password_1", e),
o = 1,
d = a.val();
r.includeMeter(e, a), o = r.checkPasswordStrength(e, a), d.length > 0 && o < wc_password_strength_meter_params.min_password_strength && !e.is("form.checkout") ? t.attr("disabled", "disabled").addClass("disabled") : t.removeAttr("disabled", "disabled").removeClass("disabled")
},
includeMeter: function(r, e) {
var t = r.find(".woocommerce-password-strength");
"" === e.val() ? (t.remove(), s(document.body).trigger("wc-password-strength-removed")) : 0 === t.length && (e.after('<div class="woocommerce-password-strength" aria-live="polite"></div>'), s(document.body).trigger("wc-password-strength-added"))
},
checkPasswordStrength: function(s, r) {
var e = s.find(".woocommerce-password-strength"),
t = s.find(".woocommerce-password-hint"),
a = '<small class="woocommerce-password-hint">' + wc_password_strength_meter_params.i18n_password_hint + "</small>",
o = wp.passwordStrength.meter(r.val(), wp.passwordStrength.userInputBlacklist()),
d = "";
switch (e.removeClass("short bad good strong"), t.remove(), o < wc_password_strength_meter_params.min_password_strength && (d = " - " + wc_password_strength_meter_params.i18n_password_error), o) {
case 0:
e.addClass("short").html(pwsL10n["short"] + d), e.after(a);
break;
case 1:
case 2:
e.addClass("bad").html(pwsL10n.bad + d), e.after(a);
break;
case 3:
e.addClass("good").html(pwsL10n.good + d);
break;
case 4:
e.addClass("strong").html(pwsL10n.strong + d);
break;
case 5:
e.addClass("short").html(pwsL10n.mismatch)
}
return o
}
};
r.init()
});

for jquery try
$('#your-password-textbox').unbind()
It will remove all event handlers for selected element.

Related

Full calendar touch issue

I am using full calendar v.13.0 and trying to popup event modal on touch slots. currently Modal popup if I click using mouse but I am generating apk using cordova and in apk modal not popup on touch.
Here is my code
eventRender: function(e, t, a) {
t.draggable();
$(e).addTouch();
if (t.attr("href")) t.attr("data-toggle", "modal"), t.attr("href", "javascript:void(0)"), t.attr("onclick", 'calendar.openModalGcal("' + encodeURI(e.title) + '","' + e.url + '");');
else {
if (1 == c.icons_title) {
var o = t.find(".fc-title").text().replace(/\[(.*?)\]/gi, '<i class="$1"></i>');
t.find(".fc-title").html(o)
}
var n = e.color,
l = moment(e.start).format("YYYY-MM-DD"),
r = moment(e.start).format("HH:mm"),
d = moment(e.end).format("YYYY-MM-DD"),
i = moment(e.end).format("HH:mm");
if (0 == moment(e.end).isValid()) d = l, i = r;
null !== e.end && "month" == a.name && ("H:mm" != c.timeFormat && "h:mm" != c.timeFormat || (timeformat = e.start.format("H:mm") + " - " + e.end.format("H:mm"), t.find(".fc-time").html(timeformat))), "modal" == c.version && (t.attr("data-toggle", "modal"), t.attr("href", "javascript:void(0)"), t.attr("data-id", e.original_id), t.attr("data-rep_id", e.id), t.attr("data-title", encodeURIComponent(e.title)), t.attr("data-url", encodeURIComponent(e.url)), t.attr("data-eventstart", e.start), t.attr("data-eventend", e.end), t.attr("data-color", n), t.attr("data-d_startdate", l), t.attr("data-d_starttime", r), t.attr("data-d_enddate", d), t.attr("data-d_endtime", i), t.attr("onclick", "calendar.openModal(this)"))
}
Object.freeze(calendar)
}

Replace img with lazyload

I'm using lazyload plugin on my page and it has data-src parameter and at the same time I'm using another plugin to replace my image on responsive and it's using data-src parameter too.and I change name of data-src as data-swapMeto not conflict. but I wonder that lazyload notice my image or not ? which one is work lazy ? replace img ? or both ?
and another thing is there any way to remove data-src-base my path can be different
click to see my project on codepen
function makeImagesResponsive() {
var e = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth,
t = document.getElementsByTagName("body")[0].getElementsByTagName("img");
if (t.length === 0) return;
var n;
t[0].hasAttribute ? n = function(e, t) {
return e.hasAttribute(t)
} : n = function(e, t) {
return e.getAttribute(t) !== null
};
var r = window.devicePixelRatio ? window.devicePixelRatio >= 1.2 ? 1 : 0 : 0;
for (var i = 0; i < t.length; i++) {
var s = t[i],
o = r && n(s, "data-swapMe2x") ? "data-swapMe2x" : "data-swapMe",
u = r && n(s, "data-src-base2x") ? "data-src-base2x" : "data-src-base";
if (!n(s, o)) continue;
var a = n(s, u) ? s.getAttribute(u) : "",
f = s.getAttribute(o),
l = f.split(",");
for (var c = 0; c < l.length; c++) {
var h = l[c].split(":"),
p = h[0],
d = h[1],
v, m;
if (p.indexOf("<") !== -1) {
v = p.split("<");
if (l[c - 1]) {
var g = l[c - 1].split(/:(.+)/),
y = g[0].split("<");
m = e <= v[1] && e > y[1]
} else m = e <= v[1]
} else {
v = p.split(">");
if (l[c + 1]) {
var b = l[c + 1].split(/:(.+)/),
w = b[0].split(">");
m = e >= v[1] && e < w[1]
} else m = e >= v[1]
}
if (m) {
var E = a + d;
s.src !== E && s.setAttribute("src", E);
break
}
}
}
}
if (window.addEventListener) {
window.addEventListener("load", makeImagesResponsive, !1);
window.addEventListener("resize", makeImagesResponsive, !1)
} else {
window.attachEvent("onload", makeImagesResponsive);
window.attachEvent("onresize", makeImagesResponsive)
};
<html lang="en">
<head>
<meta charset="UTF-8" />
</head>
<body>
<aside>
<img alt='kitten!' data-src-base='http://yurtici.anitur.com.tr/musteri/ingoing/2017/htm/img/' data-src="http://yurtici.anitur.com.tr/musteri/ingoing/2017/htm/img/1.jpg" data-swapMe='<480:4.jpg,<768:3.jpg,<960:2.jpg,>960:1.jpg' class="lazyload" />
</aside>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lazysizes/2.0.7/lazysizes.min.js"></script>
</body>
</html>

validation for divide by zero in javascript

I am trying to perform calculator operation, depending on the input values and the operator the result should be displayed. I am struck with validation of dividing by 0 and I am not able to display the result in another function. Please someone could help me!
function calCaulation(e) {
var x = document.getElementById("first").value;
var y = document.getElementById("second").value;
var z = document.getElementById("oper").value;
var a = "";
if ((isNaN(x) || x == "") || (isNaN(y) || y == "")) {
a = "Sum:Please enter the valid Number";
}
if (z == "/" && y == 0) {
a = "Divide By Zero Error";
}
return a;
}
else {
var x = parseFloat(document.getElementById("first").value);
var y = parseFloat(document.getElementById("second").value);
switch (z) {
case ("+"):
a = "Sum:" + ((x + y).toFixed(2));
break;
case ("-"):
a = "Sub:" + ((x - y).toFixed(2));
break;
case ("*"):
a = "Mul:" + ((x * y).toFixed(2));
break;
case ("/"):
a = "Div:" + ((x / y).toFixed(2));
break;
default:
a = "Invalid Operator";
}
return a;
}
}
You have a bracket and else clause too much.
See here for a working jsfiddle.
https://jsfiddle.net/r2aq88tu/4/
edit: also, your return statement after the error checks would leave the function before the real code would execute, I moved the return a inside each if to make it work.
Your new code:
function calCaulation(e) {
var x = document.getElementById("first").value;
var y = document.getElementById("second").value;
var z = document.getElementById("oper").value;
var a = "";
if ((isNaN(x) || x == "") || (isNaN(y) || y == "")) {
a = "Sum:Please enter the valid Number";
return a;
}
if (z == "/" && y == 0) {
a = "Divide By Zero Error";
return a;
}
var x = parseFloat(x);
var y = parseFloat(y);
switch (z) {
case ("+"):
a = "Sum:" + ((x + y).toFixed(2));
break;
case ("-"):
a = "Sub:" + ((x - y).toFixed(2));
break;
case ("*"):
a = "Mul:" + ((x * y).toFixed(2));
break;
case ("/"):
a = "Div:" + ((x / y).toFixed(2));
break;
default:
a = "Invalid Operator";
}
return a;
}

How does Twitter implement its Tweet Box?

I'm trying to implement something like Twitter's tweet box, specifically:
Automatically highlights text in a red background when the overall length exceeds 140 characters.
Automatically highlights links, mentions, and hashtags in blue.
These should happen automatically aka when a user types.
By the semantic markup I'm seeing on Twitter, it looks like they're using a contentEditable div. And the DOM inside is modified whenever a mention/hashtag/link is detected, or when the length is exceeded over 140 characters:
<div aria-labelledby="tweet-box-mini-home-profile-label" id="tweet-box-mini-home-profile" class="tweet-box rich-editor notie" contenteditable="true" spellcheck="true" role="textbox" aria-multiline="true" dir="ltr" aria-autocomplete="list" aria-expanded="false" aria-owns="typeahead-dropdown-6">
<div>hello world <a class="twitter-atreply pretty-link" href="/testMention" role="presentation"><s>#</s>testMention</a> text <s>#</s>helloWorld text http://www.google.com text text text text text text text text text text text text text text <em>overflow red text here</em>
</div>
</div>
What I have done so far
Currently, I'm using a contentEditable field. It triggers a function onChange/onInput that parses the text. Check if it has a username/link/hashtag via regexr and replace them with the respective tags (I'm just using a simple <i> tag to enclose username and hashtag for now).
The problem I'm having is that because I'm changing/modifying the DOM of the contentEditable, the caret cursor position becomes lost.
I looked at this thread Persisting the changes of range objects after selection in HTML and it works fine only if the DOM isn't changed (which it is in my case, surrounding tags/hashtags with <i> tags, links with <a> tags, and overflow with <b> tags.
Fiddle: http://jsfiddle.net/4Lsqjkjb/
Does anyone have any alternative solutions/approaches on how to tackle this problem? Maybe I shouldn't use contentEditable? Or some way that doesn't directly modify the DOM of the contentEditable field so the caret position is maintained? Any help would be appreciated! I tried playing around with window.getSelection() and saving it before DOM change, but it always seem to reset after DOM changes are applied.
What I did is kind of a hack but works quite well as a workaround solution.
I've got a simple textarea (not contenteditable because of what's next, I'll explain below) and a div which is absolute positioned behind the textarea. Using javascript, I copy the content from the textarea to the div while splitting it at 140 chars and putting all extra characters inside an <em /> tag.
Well, it's a little bit more complicated because twitter algorithm to compute a tweet length is different (links doesn't count as their real value, because of t.co url shortening). The exact method can be found as part of the official twitter/twitter-txt repository.
Step-by-step code.
Wrap a simple textarea into a div to simplify the css:
<div class="tweet-composer">
<textarea class="editor-textarea js-keeper-editor">This is some text that will be highlight when longer than 20 characters. Like twitter. Type something...</textarea>
<div class="js-keeper-placeholder-back"></div>
</div>
CSS is just making the textarea and the div right above each other and highlight the text.
.tweet-composer {
position: relative;
z-index: 1;
}
.js-keeper-editor,
.js-keeper-placeholder-back {
background: transparent;
border: 1px solid #eee;
font-family: Helvetica, Arial, sans-serif;
font-size: 14px; /* Same font for both. */
margin: auto;
min-height: 200px;
outline: none;
padding: 10px;
width: 100%;
}
.js-keeper-placeholder-back {
bottom: 0;
color: transparent;
left: 0;
position: absolute;
top: 0;
white-space: pre-wrap;
width: 100%;
word-wrap: break-word;
z-index: -1;
}
.js-keeper-placeholder-back em {
background: #fcc !important;
}
Now the fun part, this is implemented using jQuery but that's not the important thing.
if (0 > remainingLength) {
// Split value if greater than
var allowedValuePart = currentValue.slice(0, realLength),
refusedValuePart = currentValue.slice(realLength)
;
// Fill the hidden div.
$placeholderBacker.html(allowedValuePart + '<em>' + refusedValuePart + '</em>');
} else {
$placeholderBacker.html('');
}
Add some event handler on change, and te common document ready and you're done. See the codepen link below.
Note that the div placed behind can be created using js too, when loading the page:
// Create a pseudo-element that will be hidden behind the placeholder.
var $placeholderBacker = $('<div class="js-keeper-placeholder-back"></div>');
$placeholderBacker.insertAfter($textarea);
Full example
See working example over here:
http://codepen.io/hussard/pen/EZvaBZ
This is not a direct answer with source code building the part of your application to your spec.
This is really not an easy thing to do.
You're right - the way to solving this problem is to use a contenteditable="true" container. But I'm afraid that from there it gets much much more complicated.
Enter DraftJS - A javascript solution to rich-text editing which does most of the heavy lifting for you.
Both of my solutions below require the use of both React and DraftJS
The Plug-&-Play Solution:
The React + DraftJS + Someone Else's "Plugin" solution is already here. You can check out draft-js-plugins.com. And here's the Github source code.
Personally, I wouldn't go this way. I would rather study their GitHub source code and implement my own DraftJS entities. Because I think that React-JS-Plugins feels a little bit clunky and overweight for just Links and Mentions. Plus, where are you "mentioning" from? Your own Application? Twitter? Doing it this way lets you have control over where you're grabbing the so-called "mentions".
The DIY Solution:
The best way I have found is to build your own set of working entities on top of a DraftJS based rich-text editor.
This of course also requires that you're using React.
Forgive me for not actually building a complete set of working code. I was interested in doing something similar for an App I'm building in Meteor with React on the front-end. So this really made sense to me because I'd only be adding one more library (DraftJS) and the rest would be my custom entities coded out.
Turns out this is really not an easy thing to do. I've been struggling with it for the past few days, and I'm not very close to a solution.
Your best drop-in solution currently is the At.js library, which is still being maintained, but definitely isn't perfect. One of the examples shows how you can kind of do a text highlight.
The most annoying part of this problem is that Twitter has a beautiful solution that seemingly works perfectly staring us right in the face. I took some time investigating the way they implement their "tweet box," and it's definitely not trivial. It looks like they're doing almost everything manually, including emulating undo/redo functionality, intercepting copy/pastes, providing custom code for IE/W3C, custom-coding Mac/PC, and more. They use a contenteditable div, which is in-and-of-itself problematic due to differences in browser implementations. It's pretty impressive, actually.
Here's the most relevant (obfuscated, unfortunately) code, taken from Twitter's boot JavaScript file (found by inspecting the header of the logged-in Twitter homepage). I didn't want to directly copy and paste the link, in case it's personalized to my Twitter account.
define("app/utils/html_text", ["module", "require", "exports"], function(module, require, exports) {
function isTextNode(a) {
return a.nodeType == 3 || a.nodeType == 4
}
function isElementNode(a) {
return a.nodeType == 1
}
function isBrNode(a) {
return isElementNode(a) && a.nodeName.toLowerCase() == "br"
}
function isOutsideContainer(a, b) {
while (a !== b) {
if (!a) return !0;
a = a.parentNode
}
}
var useW3CRange = window.getSelection,
useMsftTextRange = !useW3CRange && document.selection,
useIeHtmlFix = navigator.appName == "Microsoft Internet Explorer",
NBSP_REGEX = /[\xa0\n\t]/g,
CRLF_REGEX = /\r\n/g,
LINES_REGEX = /(.*?)\n/g,
SP_LEADING_OR_FOLLOWING_CLOSE_TAG_OR_PRECEDING_A_SP_REGEX = /^ |(<\/[^>]+>) | (?= )/g,
SP_LEADING_OR_TRAILING_OR_FOLLOWING_A_SP_REGEX = /^ | $|( ) /g,
MAX_OFFSET = Number.MAX_VALUE,
htmlText = function(a, b) {
function c(a, c) {
function h(a) {
var i = d.length;
if (isTextNode(a)) {
var j = a.nodeValue.replace(NBSP_REGEX, " "),
k = j.length;
k && (d += j, e = !0), c(a, !0, 0, i, i + k)
} else if (isElementNode(a)) {
c(a, !1, 0, i, i);
if (isBrNode(a)) a == f ? g = !0 : (d += "\n", e = !1);
else {
var l = a.currentStyle || window.getComputedStyle(a, ""),
m = l.display == "block";
m && b.msie && (e = !0);
for (var n = a.firstChild, o = 1; n; n = n.nextSibling, o++) {
h(n);
if (g) return;
i = d.length, c(a, !1, o, i, i)
}
g || a == f ? g = !0 : m && e && (d += "\n", e = !1)
}
}
}
var d = "",
e, f, g;
for (var i = a; i && isElementNode(i); i = i.lastChild) f = i;
return h(a), d
}
function d(a, b) {
var d = null,
e = b.length - 1;
if (useW3CRange) {
var f = b.map(function() {
return {}
}),
g;
c(a, function(a, c, d, h, i) {
g || f.forEach(function(f, j) {
var k = b[j];
h <= k && !isBrNode(a) && (f.node = a, f.offset = c ? Math.min(k, i) - h : d, g = c && j == e && i >= k)
})
}), f[0].node && f[e].node && (d = document.createRange(), d.setStart(f[0].node, f[0].offset), d.setEnd(f[e].node, f[e].offset))
} else if (useMsftTextRange) {
var h = document.body.createTextRange();
h.moveToElementText(a), d = h.duplicate();
if (b[0] == MAX_OFFSET) d.setEndPoint("StartToEnd", h);
else {
d.move("character", b[0]);
var i = e && b[1] - b[0];
i > 0 && d.moveEnd("character", i), h.inRange(d) || d.setEndPoint("EndToEnd", h)
}
}
return d
}
function e() {
return document.body.contains(a)
}
function f(b) {
a.innerHTML = b;
if (useIeHtmlFix)
for (var c = a.firstChild; c; c = c.nextSibling) isElementNode(c) && c.nodeName.toLowerCase() == "p" && c.innerHTML == "" && (c.innerText = "")
}
function g(a, b) {
return a.map(function(a) {
return Math.min(a, b.length)
})
}
function h() {
var b = getSelection();
if (b.rangeCount !== 1) return null;
var d = b.getRangeAt(0);
if (isOutsideContainer(d.commonAncestorContainer, a)) return null;
var e = [{
node: d.startContainer,
offset: d.startOffset
}];
d.collapsed || e.push({
node: d.endContainer,
offset: d.endOffset
});
var f = e.map(function() {
return MAX_OFFSET
}),
h = c(a, function(a, b, c, d) {
e.forEach(function(e, g) {
f[g] == MAX_OFFSET && a == e.node && (b || c == e.offset) && (f[g] = d + (b ? e.offset : 0))
})
});
return g(f, h)
}
function i() {
var b = document.selection.createRange();
if (isOutsideContainer(b.parentElement(), a)) return null;
var d = ["Start"];
b.compareEndPoints("StartToEnd", b) && d.push("End");
var e = d.map(function() {
return MAX_OFFSET
}),
f = document.body.createTextRange(),
h = c(a, function(c, g, h, i) {
function j(a, c) {
if (e[c] < MAX_OFFSET) return;
var d = f.compareEndPoints("StartTo" + a, b);
if (d > 0) return;
var g = f.compareEndPoints("EndTo" + a, b);
if (g < 0) return;
var h = f.duplicate();
h.setEndPoint("EndTo" + a, b), e[c] = i + h.text.length, c && !g && e[c]++
}!g && !h && c != a && (f.moveToElementText(c), d.forEach(j))
});
return g(e, h)
}
return {
getHtml: function() {
if (useIeHtmlFix) {
var b = "",
c = document.createElement("div");
for (var d = a.firstChild; d; d = d.nextSibling) isTextNode(d) ? (c.innerText = d.nodeValue, b += c.innerHTML) : b += d.outerHTML.replace(CRLF_REGEX, "");
return b
}
return a.innerHTML
},
setHtml: function(a) {
f(a)
},
getText: function() {
return c(a, function() {})
},
setTextWithMarkup: function(a) {
f((a + "\n").replace(LINES_REGEX, function(a, c) {
return b.mozilla || b.msie ? (c = c.replace(SP_LEADING_OR_FOLLOWING_CLOSE_TAG_OR_PRECEDING_A_SP_REGEX, "$1 "), b.mozilla ? c + "<BR>" : "<P>" + c + "</P>") : (c = (c || "<br>").replace(SP_LEADING_OR_TRAILING_OR_FOLLOWING_A_SP_REGEX, "$1 "), b.opera ? "<p>" + c + "</p>" : "<div>" + c + "</div>")
}))
},
getSelectionOffsets: function() {
var a = null;
return e() && (useW3CRange ? a = h() : useMsftTextRange && (a = i())), a
},
setSelectionOffsets: function(b) {
if (b && e()) {
var c = d(a, b);
if (c)
if (useW3CRange) {
var f = window.getSelection();
f.removeAllRanges(), f.addRange(c)
} else useMsftTextRange && c.select()
}
},
emphasizeText: function(b) {
var f = [];
b && b.length > 1 && e() && (c(a, function(a, c, d, e, g) {
if (c) {
var h = Math.max(e, b[0]),
i = Math.min(g, b[1]);
i > h && f.push([h, i])
}
}), f.forEach(function(b) {
var c = d(a, b);
c && (useW3CRange ? c.surroundContents(document.createElement("em")) : useMsftTextRange && c.execCommand("italic", !1, null))
}))
}
}
};
module.exports = htmlText
});
define("app/utils/tweet_helper", ["module", "require", "exports", "lib/twitter-text", "core/utils", "app/data/user_info"], function(module, require, exports) {
var twitterText = require("lib/twitter-text"),
utils = require("core/utils"),
userInfo = require("app/data/user_info"),
VALID_PROTOCOL_PREFIX_REGEX = /^https?:\/\//i,
tweetHelper = {
extractMentionsForReply: function(a, b) {
var c = a.attr("data-screen-name"),
d = a.attr("data-retweeter"),
e = a.attr("data-mentions") ? a.attr("data-mentions").split(" ") : [],
f = a.attr("data-tagged") ? a.attr("data-tagged").split(" ") : [];
e = e.concat(f);
var g = [c, b, d];
return e = e.filter(function(a) {
return g.indexOf(a) < 0
}), d && d != c && d != b && e.unshift(d), (!e.length || c != b) && e.unshift(c), e
},
linkify: function(a, b) {
return b = utils.merge({
hashtagClass: "twitter-hashtag pretty-link",
hashtagUrlBase: "/search?q=%23",
symbolTag: "s",
textWithSymbolTag: "b",
cashtagClass: "twitter-cashtag pretty-link",
cashtagUrlBase: "/search?q=%24",
usernameClass: "twitter-atreply pretty-link",
usernameUrlBase: "/",
usernameIncludeSymbol: !0,
listClass: "twitter-listname pretty-link",
urlClass: "twitter-timeline-link",
urlTarget: "_blank",
suppressNoFollow: !0,
htmlEscapeNonEntities: !0
}, b || {}), twitterText.autoLinkEntities(a, twitterText.extractEntitiesWithIndices(a), b)
}
};
module.exports = tweetHelper
});
define("app/ui/compose/with_rich_editor", ["module", "require", "exports", "app/utils/file", "app/utils/html_text", "app/utils/tweet_helper", "lib/twitter-text"], function(module, require, exports) {
function withRichEditor() {
this.defaultAttrs({
richSelector: "div.rich-editor",
linksSelector: "a",
normalizerSelector: "div.rich-normalizer",
$browser: $.browser
}), this.linkify = function(a) {
var b = {
urlTarget: null,
textWithSymbolTag: RENDER_URLS_AS_PRETTY_LINKS ? "b" : "",
linkAttributeBlock: function(a, b) {
var c = a.screenName || a.url;
c && (this.urlAndMentionsCharCount += c.length + 2), delete b.title, delete b["data-screen-name"], b.dir = a.hashtag && this.shouldBeRTL(a.hashtag, 0) ? "rtl" : "ltr", b.role = "presentation"
}.bind(this)
};
return this.urlAndMentionsCharCount = 0, tweetHelper.linkify(a, b)
}, this.around("setSelection", function(a, b) {
b && this.setSelectionIfFocused(b)
}), this.around("setCursorPosition", function(a, b) {
b === undefined && (b = this.attr.cursorPosition), b === undefined && (b = MAX_OFFSET), this.setSelectionIfFocused([b])
}), this.around("detectUpdatedText", function(a, b, c) {
var d = this.htmlRich.getHtml(),
e = this.htmlRich.getSelectionOffsets() || [MAX_OFFSET],
f = c !== undefined;
if (d === this.prevHtml && e[0] === this.prevSelectionOffset && !b && !f) return;
var g = f ? c : this.htmlRich.getText(),
h = g.replace(INVALID_CHARS_REGEX, "");
(f || !(!d && !this.hasFocus() || this.$text.attr("data-in-composition"))) && this.reformatHtml(h, d, e, f);
if (b || this.cleanedText != h || this.prevSelectionOffset != e[0]) this.prevSelectionOffset = e[0], this.updateCleanedTextAndOffset(h, e[0])
}), this.reformatHtml = function(a, b, c, d) {
this.htmlNormalizer.setTextWithMarkup(this.linkify(a)), this.interceptDataImageInContent();
var e = this.shouldBeRTL(a, this.urlAndMentionsCharCount);
this.$text.attr("dir", e ? "rtl" : "ltr"), this.$normalizer.find(e ? "[dir=rtl]" : "[dir=ltr]").removeAttr("dir"), RENDER_URLS_AS_PRETTY_LINKS && this.$normalizer.find(".twitter-timeline-link").wrapInner("<b>").addClass("pretty-link");
var f = this.getMaxLengthOffset(a);
f >= 0 && (this.htmlNormalizer.emphasizeText([f, MAX_OFFSET]), this.$normalizer.find("em").each(function() {
this.innerHTML = this.innerHTML.replace(TRAILING_SINGLE_SPACE_REGEX, "Â ")
}));
var g = this.htmlNormalizer.getHtml();
if (g !== b) {
var h = d && !this.isFocusing && this.hasFocus();
h && this.$text.addClass("fake-focus").blur(), this.htmlRich.setHtml(g), h && this.$text.focus().removeClass("fake-focus"), this.setSelectionIfFocused(c)
}
this.prevHtml = g
}, this.interceptDataImageInContent = function() {
if (!this.triggerGotImageData) return;
this.$text.find("img").filter(function(a, b) {
return b.src.match(/^data:/)
}).first().each(function(a, b) {
var c = file.getBlobFromDataUri(b.src);
file.getFileData("pasted.png", c).then(this.triggerGotImageData.bind(this))
}.bind(this))
}, this.getMaxLengthOffset = function(a) {
var b = this.getLength(a),
c = this.attr.maxLength;
if (b <= c) return -1;
c += twitterText.getUnicodeTextLength(a) - b;
var d = [{
indices: [c, c]
}];
return twitterText.modifyIndicesFromUnicodeToUTF16(a, d), d[0].indices[0]
}, this.setSelectionIfFocused = function(a) {
this.hasFocus() ? (this.previousSelection = null, this.htmlRich.setSelectionOffsets(a)) : this.previousSelection = a
}, this.selectPrevCharOnBackspace = function(a) {
if (a.which == 8 && !a.ctrlKey) {
var b = this.htmlRich.getSelectionOffsets();
b && b[0] != MAX_OFFSET && b.length == 1 && (b[0] ? this.setSelectionIfFocused([b[0] - 1, b[0]]) : this.stopEvent(a))
}
}, this.emulateCommandArrow = function(a) {
if (a.metaKey && !a.shiftKey && (a.which == 37 || a.which == 39)) {
var b = a.which == 37;
this.htmlRich.setSelectionOffsets([b ? 0 : MAX_OFFSET]), this.$text.scrollTop(b ? 0 : this.$text[0].scrollHeight), this.stopEvent(a)
}
}, this.stopEvent = function(a) {
a.preventDefault(), a.stopPropagation()
}, this.saveUndoStateDeferred = function(a) {
if (a.type == "mousemove" && a.which != 1) return;
setTimeout(function() {
this.detectUpdatedText(), this.saveUndoState()
}.bind(this), 0)
}, this.clearUndoState = function() {
this.undoHistory = [], this.undoIndex = -1
}, this.saveUndoState = function() {
var a = this.htmlRich.getText(),
b = this.htmlRich.getSelectionOffsets() || [a.length],
c = this.undoHistory,
d = c[this.undoIndex];
!d || d[0] !== a ? c.splice(++this.undoIndex, c.length, [a, b]) : d && (d[1] = b)
}, this.isUndoKey = function(a) {
return this.isMac ? a.which == 90 && a.metaKey && !a.shiftKey && !a.ctrlKey && !a.altKey : a.which == 90 && a.ctrlKey && !a.shiftKey && !a.altKey
}, this.emulateUndo = function(a) {
this.isUndoKey(a) && (this.stopEvent(a), this.saveUndoState(), this.undoIndex > 0 && this.setUndoState(this.undoHistory[--this.undoIndex]))
}, this.isRedoKey = function(a) {
return this.isMac ? a.which == 90 && a.metaKey && a.shiftKey && !a.ctrlKey && !a.altKey : this.isWin ? a.which == 89 && a.ctrlKey && !a.shiftKey && !a.altKey : a.which == 90 && a.shiftKey && a.ctrlKey && !a.altKey
}, this.emulateRedo = function(a) {
var b = this.undoHistory,
c = this.undoIndex;
c < b.length - 1 && this.htmlRich.getText() !== b[c][0] && b.splice(c + 1, b.length), this.isRedoKey(a) && (this.stopEvent(a), c < b.length - 1 && this.setUndoState(b[++this.undoIndex]))
}, this.setUndoState = function(a) {
this.detectUpdatedText(!1, a[0]), this.htmlRich.setSelectionOffsets(a[1]), this.trigger("uiHideAutocomplete")
}, this.undoStateAfterCursorMovement = function(a) {
a.which >= 33 && a.which <= 40 && this.saveUndoStateDeferred(a)
}, this.handleKeyDown = function(a) {
this.isIE && this.selectPrevCharOnBackspace(a), this.attr.$browser.mozilla && this.emulateCommandArrow(a), this.undoStateAfterCursorMovement(a), this.emulateUndo(a), this.emulateRedo(a)
}, this.interceptPaste = function(a) {
if (a.originalEvent && a.originalEvent.clipboardData) {
var b = a.originalEvent.clipboardData;
(this.interceptImagePaste(b) || this.interceptTextPaste(b)) && a.preventDefault()
}
}, this.interceptImagePaste = function(a) {
return this.triggerGotImageData && a.items && a.items.length === 1 && a.items[0].kind === "file" && a.items[0].type.indexOf("image/") === 0 ? (file.getFileData("pasted.png", a.items[0].getAsFile()).then(this.triggerGotImageData.bind(this)), !0) : !1
}, this.interceptTextPaste = function(a) {
var b = a.getData("text");
return b && document.execCommand("insertHTML", !1, $("<div>").text(b).html().replace(LINE_FEEDS_REGEX, "<br>")) ? !0 : !1
}, this.clearSelectionOnBlur = function() {
window.getSelection && (this.previousSelection = this.htmlRich.getSelectionOffsets(), this.previousSelection && getSelection().removeAllRanges())
}, this.restoreSelectionOnFocus = function() {
this.previousSelection ? setTimeout(function() {
this.htmlRich.setSelectionOffsets(this.previousSelection), this.previousSelection = null
}.bind(this), 0) : this.previousSelection = null
}, this.setFocusingState = function() {
this.isFocusing = !0, setTimeout(function() {
this.isFocusing = !1
}.bind(this), 0)
}, this.around("initTextNode", function(a) {
this.isIE = this.attr.$browser.msie || navigator.userAgent.indexOf("Trident") > -1, this.$text = this.select("richSelector"), this.undoHistory = [
["", [0]]
], this.undoIndex = 0, this.htmlRich = htmlText(this.$text[0], this.attr.$browser), this.$text.toggleClass("notie", !this.isIE), this.$normalizer = this.select("normalizerSelector"), this.htmlNormalizer = htmlText(this.$normalizer[0], this.attr.$browser);
var b = navigator.platform;
this.isMac = b.indexOf("Mac") != -1, this.isWin = b.indexOf("Win") != -1, this.on(this.$text, "click", {
linksSelector: this.stopEvent
}), this.on(this.$text, "focusin", this.setFocusingState), this.on(this.$text, "keydown", this.handleKeyDown), this.on(this.$text, "focusout", this.ignoreDuringFakeFocus(this.clearSelectionOnBlur)), this.on(this.$text, "focusin", this.ignoreDuringFakeFocus(this.restoreSelectionOnFocus)), this.on(this.$text, "focusin", this.ignoreDuringFakeFocus(this.saveUndoStateDeferred)), this.on(this.$text, "cut paste drop", this.saveUndoState), this.on(this.$text, "cut paste drop mousedown mousemove", this.saveUndoStateDeferred), this.on("uiSaveUndoState", this.saveUndoState), this.on("uiClearUndoState", this.clearUndoState), this.on(this.$text, "paste", this.interceptPaste), this.detectUpdatedText()
})
}
var file = require("app/utils/file"),
htmlText = require("app/utils/html_text"),
tweetHelper = require("app/utils/tweet_helper"),
twitterText = require("lib/twitter-text");
module.exports = withRichEditor;
var INVALID_CHARS_REGEX = /[\uFFFE\uFEFF\uFFFF\u200E\u200F\u202A-\u202E\x00-\x09\x0B\x0C\x0E-\x1F]/g,
RENDER_URLS_AS_PRETTY_LINKS = $.browser.mozilla && parseInt($.browser.version, 10) < 2,
TRAILING_SINGLE_SPACE_REGEX = / $/,
LINE_FEEDS_REGEX = /\r\n|\n\r|\n/g,
MAX_OFFSET = Number.MAX_VALUE
});
define("app/ui/compose/tweet_box_manager", ["module", "require", "exports", "app/ui/compose/tweet_box", "app/ui/compose/dm_composer", "app/ui/geo_picker", "core/component", "app/ui/compose/with_rich_editor"], function(module, require, exports) {
function tweetBoxManager() {
this.createTweetBoxAtTarget = function(a, b) {
this.createTweetBox(a.target, b)
}, this.createTweetBox = function(a, b) {
var c = $(a);
if (!((b.eventData || {}).scribeContext || {}).component) throw new Error("Please specify scribing component for tweet box.");
c.find(".geo-picker").length > 0 && GeoPicker.attachTo(c.find(".geo-picker"), b, {
parent: c
});
var d = c.find("div.rich-editor").length > 0 ? [withRichEditor] : [],
e = (b.dmOnly ? DmComposer : TweetBox).mixin.apply(this, d),
f = {
typeaheadData: this.attr.typeaheadData
};
e.attachTo(c, f, b)
}, this.after("initialize", function() {
this.on("uiInitTweetbox", this.createTweetBoxAtTarget)
})
}
var TweetBox = require("app/ui/compose/tweet_box"),
DmComposer = require("app/ui/compose/dm_composer"),
GeoPicker = require("app/ui/geo_picker"),
defineComponent = require("core/component"),
withRichEditor = require("app/ui/compose/with_rich_editor"),
TweetBoxManager = defineComponent(tweetBoxManager);
module.exports = TweetBoxManager
});
Obviously, this "answer" doesn't solve anything, but hopefully could provide enough to (re-)spark a conversation about this topic.

How do I get rid of this JS error: TypeError: $(...).validate is not a function

I am using the following JS code from the fiddle provided in the answer here:
How to display messages from jQuery Validate plugin inside of Tooltipster tooltips?
Here's the fiddle: http://jsfiddle.net/kyK4G/
The error shows up on line 36, which is: submitHandler: function (form) { // for demo
And this is the error:
TypeError: $(...).validate is not a function
submitHandler: function (form) { // for demo
Code:
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
$(document).ready(function () {
// initialize tooltipster on text input elements
$('#myform input[type="text"]').tooltipster({
trigger: 'custom',
onlyOne: false,
position: 'right'
});
// initialize validate plugin on the form
$('#myform').validate({
errorPlacement: function (error, element) {
$(element).tooltipster('update', $(error).text());
$(element).tooltipster('show');
},
success: function (label, element) {
$(element).tooltipster('hide');
},
rules: {
field1: {
required: true,
email: true
},
field2: {
required: true,
minlength: 5
}
},
submitHandler: function (form) { // for demo
alert('valid form');
return false;
}
});
});
// no CDN - including plugin below
(function (d, f, g, b) {
var e = "tooltipster",
c = {
animation: "fade",
arrow: true,
arrowColor: "",
content: "",
delay: 200,
fixedWidth: 0,
maxWidth: 0,
functionBefore: function (l, m) {
m()
},
functionReady: function (l, m) {},
functionAfter: function (l) {},
icon: "(?)",
iconDesktop: false,
iconTouch: false,
iconTheme: ".tooltipster-icon",
interactive: false,
interactiveTolerance: 350,
offsetX: 0,
offsetY: 0,
onlyOne: true,
position: "top",
speed: 350,
timer: 0,
theme: ".tooltipster-default",
touchDevices: true,
trigger: "hover"
};
function h(m, l) {
this.element = m;
this.options = d.extend({}, c, l);
this._defaults = c;
this._name = e;
this.init()
}
function j() {
return !!("ontouchstart" in f)
}
function a() {
var l = g.body || g.documentElement;
var n = l.style;
var o = "transition";
if (typeof n[o] == "string") {
return true
}
v = ["Moz", "Webkit", "Khtml", "O", "ms"], o = o.charAt(0).toUpperCase() + o.substr(1);
for (var m = 0; m < v.length; m++) {
if (typeof n[v[m] + o] == "string") {
return true
}
}
return false
}
var k = true;
if (!a()) {
k = false
}
h.prototype = {
init: function () {
var r = d(this.element);
var n = this;
var q = true;
if ((n.options.touchDevices == false) && (j())) {
q = false
}
if (g.all && !g.querySelector) {
q = false
}
if (q == true) {
if ((this.options.iconDesktop == true) && (!j()) || ((this.options.iconTouch == true) && (j()))) {
var m = r.attr("title");
r.removeAttr("title");
var p = n.options.iconTheme;
var o = d('<span class="' + p.replace(".", "") + '" title="' + m + '">' + this.options.icon + "</span>");
o.insertAfter(r);
r.data("tooltipsterIcon", o);
r = o
}
var l = d.trim(n.options.content).length > 0 ? n.options.content : r.attr("title");
r.data("tooltipsterContent", l);
r.removeAttr("title");
if ((this.options.touchDevices == true) && (j())) {
r.bind("touchstart", function (t, s) {
n.showTooltip()
})
} else {
if (this.options.trigger == "hover") {
r.on("mouseenter.tooltipster", function () {
n.showTooltip()
});
if (this.options.interactive == true) {
r.on("mouseleave.tooltipster", function () {
var t = r.data("tooltipster");
var u = false;
if ((t !== b) && (t !== "")) {
t.mouseenter(function () {
u = true
});
t.mouseleave(function () {
u = false
});
var s = setTimeout(function () {
if (u == true) {
t.mouseleave(function () {
n.hideTooltip()
})
} else {
n.hideTooltip()
}
}, n.options.interactiveTolerance)
} else {
n.hideTooltip()
}
})
} else {
r.on("mouseleave.tooltipster", function () {
n.hideTooltip()
})
}
}
if (this.options.trigger == "click") {
r.on("click.tooltipster", function () {
if ((r.data("tooltipster") == "") || (r.data("tooltipster") == b)) {
n.showTooltip()
} else {
n.hideTooltip()
}
})
}
}
}
},
showTooltip: function (m) {
var n = d(this.element);
var l = this;
if (n.data("tooltipsterIcon") !== b) {
n = n.data("tooltipsterIcon")
}
if ((d(".tooltipster-base").not(".tooltipster-dying").length > 0) && (l.options.onlyOne == true)) {
d(".tooltipster-base").not(".tooltipster-dying").not(n.data("tooltipster")).each(function () {
d(this).addClass("tooltipster-kill");
var o = d(this).data("origin");
o.data("plugin_tooltipster").hideTooltip()
})
}
n.clearQueue().delay(l.options.delay).queue(function () {
l.options.functionBefore(n, function () {
if ((n.data("tooltipster") !== b) && (n.data("tooltipster") !== "")) {
var w = n.data("tooltipster");
if (!w.hasClass("tooltipster-kill")) {
var s = "tooltipster-" + l.options.animation;
w.removeClass("tooltipster-dying");
if (k == true) {
w.clearQueue().addClass(s + "-show")
}
if (l.options.timer > 0) {
var q = w.data("tooltipsterTimer");
clearTimeout(q);
q = setTimeout(function () {
w.data("tooltipsterTimer", b);
l.hideTooltip()
}, l.options.timer);
w.data("tooltipsterTimer", q)
}
if ((l.options.touchDevices == true) && (j())) {
d("body").bind("touchstart", function (B) {
if (l.options.interactive == true) {
var D = d(B.target);
var C = true;
D.parents().each(function () {
if (d(this).hasClass("tooltipster-base")) {
C = false
}
});
if (C == true) {
l.hideTooltip();
d("body").unbind("touchstart")
}
} else {
l.hideTooltip();
d("body").unbind("touchstart")
}
})
}
}
} else {
d("body").css("overflow-x", "hidden");
var x = n.data("tooltipsterContent");
var u = l.options.theme;
var y = u.replace(".", "");
var s = "tooltipster-" + l.options.animation;
var r = "-webkit-transition-duration: " + l.options.speed + "ms; -webkit-animation-duration: " + l.options.speed + "ms; -moz-transition-duration: " + l.options.speed + "ms; -moz-animation-duration: " + l.options.speed + "ms; -o-transition-duration: " + l.options.speed + "ms; -o-animation-duration: " + l.options.speed + "ms; -ms-transition-duration: " + l.options.speed + "ms; -ms-animation-duration: " + l.options.speed + "ms; transition-duration: " + l.options.speed + "ms; animation-duration: " + l.options.speed + "ms;";
var o = l.options.fixedWidth > 0 ? "width:" + l.options.fixedWidth + "px;" : "";
var z = l.options.maxWidth > 0 ? "max-width:" + l.options.maxWidth + "px;" : "";
var t = l.options.interactive == true ? "pointer-events: auto;" : "";
var w = d('<div class="tooltipster-base ' + y + " " + s + '" style="' + o + " " + z + " " + t + " " + r + '"><div class="tooltipster-content">' + x + "</div></div>");
w.appendTo("body");
n.data("tooltipster", w);
w.data("origin", n);
l.positionTooltip();
l.options.functionReady(n, w);
if (k == true) {
w.addClass(s + "-show")
} else {
w.css("display", "none").removeClass(s).fadeIn(l.options.speed)
}
var A = x;
var p = setInterval(function () {
var B = n.data("tooltipsterContent");
if (d("body").find(n).length == 0) {
w.addClass("tooltipster-dying");
l.hideTooltip()
} else {
if ((A !== B) && (B !== "")) {
A = B;
w.find(".tooltipster-content").html(B);
w.css({
width: "",
"-webkit-transition-duration": l.options.speed + "ms",
"-moz-transition-duration": l.options.speed + "ms",
"-o-transition-duration": l.options.speed + "ms",
"-ms-transition-duration": l.options.speed + "ms",
"transition-duration": l.options.speed + "ms",
"-webkit-transition-property": "-webkit-transform",
"-moz-transition-property": "-moz-transform",
"-o-transition-property": "-o-transform",
"-ms-transition-property": "-ms-transform",
"transition-property": "transform"
}).addClass("tooltipster-content-changing");
setTimeout(function () {
w.removeClass("tooltipster-content-changing");
setTimeout(function () {
w.css({
"-webkit-transition-property": "",
"-moz-transition-property": "",
"-o-transition-property": "",
"-ms-transition-property": "",
"transition-property": ""
})
}, l.options.speed)
}, l.options.speed);
tooltipWidth = w.outerWidth(false);
tooltipInnerWidth = w.innerWidth();
tooltipHeight = w.outerHeight(false);
l.positionTooltip()
}
}
if ((d("body").find(w).length == 0) || (d("body").find(n).length == 0)) {
clearInterval(p)
}
}, 200);
if (l.options.timer > 0) {
var q = setTimeout(function () {
w.data("tooltipsterTimer", b);
l.hideTooltip()
}, l.options.timer + l.options.speed);
w.data("tooltipsterTimer", q)
}
if ((l.options.touchDevices == true) && (j())) {
d("body").bind("touchstart", function (B) {
if (l.options.interactive == true) {
var D = d(B.target);
var C = true;
D.parents().each(function () {
if (d(this).hasClass("tooltipster-base")) {
C = false
}
});
if (C == true) {
l.hideTooltip();
d("body").unbind("touchstart")
}
} else {
l.hideTooltip();
d("body").unbind("touchstart")
}
})
}
w.mouseleave(function () {
l.hideTooltip()
})
}
});
n.dequeue()
})
},
hideTooltip: function (m) {
var p = d(this.element);
var l = this;
if (p.data("tooltipsterIcon") !== b) {
p = p.data("tooltipsterIcon")
}
var o = p.data("tooltipster");
if (o == b) {
o = d(".tooltipster-dying")
}
p.clearQueue();
if ((o !== b) && (o !== "")) {
var q = o.data("tooltipsterTimer");
if (q !== b) {
clearTimeout(q)
}
var n = "tooltipster-" + l.options.animation;
if (k == true) {
o.clearQueue().removeClass(n + "-show").addClass("tooltipster-dying").delay(l.options.speed).queue(function () {
o.remove();
p.data("tooltipster", "");
d("body").css("verflow-x", "");
l.options.functionAfter(p)
})
} else {
o.clearQueue().addClass("tooltipster-dying").fadeOut(l.options.speed, function () {
o.remove();
p.data("tooltipster", "");
d("body").css("verflow-x", "");
l.options.functionAfter(p)
})
}
}
},
positionTooltip: function (O) {
var A = d(this.element);
var ab = this;
if (A.data("tooltipsterIcon") !== b) {
A = A.data("tooltipsterIcon")
}
if ((A.data("tooltipster") !== b) && (A.data("tooltipster") !== "")) {
var ah = A.data("tooltipster");
ah.css("width", "");
var ai = d(f).width();
var B = A.outerWidth(false);
var ag = A.outerHeight(false);
var al = ah.outerWidth(false);
var m = ah.innerWidth() + 1;
var M = ah.outerHeight(false);
var aa = A.offset();
var Z = aa.top;
var u = aa.left;
var y = b;
if (A.is("area")) {
var T = A.attr("shape");
var af = A.parent().attr("name");
var P = d('img[usemap="#' + af + '"]');
var n = P.offset().left;
var L = P.offset().top;
var W = A.attr("coords") !== b ? A.attr("coords").split(",") : b;
if (T == "circle") {
var N = parseInt(W[0]);
var r = parseInt(W[1]);
var D = parseInt(W[2]);
ag = D * 2;
B = D * 2;
Z = L + r - D;
u = n + N - D
} else {
if (T == "rect") {
var N = parseInt(W[0]);
var r = parseInt(W[1]);
var q = parseInt(W[2]);
var J = parseInt(W[3]);
ag = J - r;
B = q - N;
Z = L + r;
u = n + N
} else {
if (T == "poly") {
var x = [];
var ae = [];
var H = 0,
G = 0,
ad = 0,
ac = 0;
var aj = "even";
for (i = 0; i < W.length; i++) {
var F = parseInt(W[i]);
if (aj == "even") {
if (F > ad) {
ad = F;
if (i == 0) {
H = ad
}
}
if (F < H) {
H = F
}
aj = "odd"
} else {
if (F > ac) {
ac = F;
if (i == 1) {
G = ac
}
}
if (F < G) {
G = F
}
aj = "even"
}
}
ag = ac - G;
B = ad - H;
Z = L + G;
u = n + H
} else {
ag = P.outerHeight(false);
B = P.outerWidth(false);
Z = L;
u = n
}
}
}
}
if (ab.options.fixedWidth == 0) {
ah.css({
width: m + "px",
"padding-left": "0px",
"padding-right": "0px"
})
}
var s = 0,
V = 0;
var X = parseInt(ab.options.offsetY);
var Y = parseInt(ab.options.offsetX);
var p = "";
function w() {
var an = d(f).scrollLeft();
if ((s - an) < 0) {
var am = s - an;
s = an;
ah.data("arrow-reposition", am)
}
if (((s + al) - an) > ai) {
var am = s - ((ai + an) - al);
s = (ai + an) - al;
ah.data("arrow-reposition", am)
}
}
function t(an, am) {
if (((Z - d(f).scrollTop() - M - X - 12) < 0) && (am.indexOf("top") > -1)) {
ab.options.position = an;
y = am
}
if (((Z + ag + M + 12 + X) > (d(f).scrollTop() + d(f).height())) && (am.indexOf("bottom") > -1)) {
ab.options.position = an;
y = am;
V = (Z - M) - X - 12
}
}
if (ab.options.position == "top") {
var Q = (u + al) - (u + B);
s = (u + Y) - (Q / 2);
V = (Z - M) - X - 12;
w();
t("bottom", "top")
}
if (ab.options.position == "top-left") {
s = u + Y;
V = (Z - M) - X - 12;
w();
t("bottom-left", "top-left")
}
if (ab.options.position == "top-right") {
s = (u + B + Y) - al;
V = (Z - M) - X - 12;
w();
t("bottom-right", "top-right")
}
if (ab.options.position == "bottom") {
var Q = (u + al) - (u + B);
s = u - (Q / 2) + Y;
V = (Z + ag) + X + 12;
w();
t("top", "bottom")
}
if (ab.options.position == "bottom-left") {
s = u + Y;
V = (Z + ag) + X + 12;
w();
t("top-left", "bottom-left")
}
if (ab.options.position == "bottom-right") {
s = (u + B + Y) - al;
V = (Z + ag) + X + 12;
w();
t("top-right", "bottom-right")
}
if (ab.options.position == "left") {
s = u - Y - al - 12;
myLeftMirror = u + Y + B + 12;
var K = (Z + M) - (Z + A.outerHeight(false));
V = Z - (K / 2) - X;
if ((s < 0) && ((myLeftMirror + al) > ai)) {
var o = parseFloat(ah.css("border-width")) * 2;
var l = (al + s) - o;
ah.css("width", l + "px");
M = ah.outerHeight(false);
s = u - Y - l - 12 - o;
K = (Z + M) - (Z + A.outerHeight(false));
V = Z - (K / 2) - X
} else {
if (s < 0) {
s = u + Y + B + 12;
ah.data("arrow-reposition", "left")
}
}
}
if (ab.options.position == "right") {
s = u + Y + B + 12;
myLeftMirror = u - Y - al - 12;
var K = (Z + M) - (Z + A.outerHeight(false));
V = Z - (K / 2) - X;
if (((s + al) > ai) && (myLeftMirror < 0)) {
var o = parseFloat(ah.css("border-width")) * 2;
var l = (ai - s) - o;
ah.css("width", l + "px");
M = ah.outerHeight(false);
K = (Z + M) - (Z + A.outerHeight(false));
V = Z - (K / 2) - X
} else {
if ((s + al) > ai) {
s = u - Y - al - 12;
ah.data("arrow-reposition", "right")
}
}
}
if (ab.options.arrow == true) {
var I = "tooltipster-arrow-" + ab.options.position;
if (ab.options.arrowColor.length < 1) {
var R = ah.css("background-color")
} else {
var R = ab.options.arrowColor
}
It sounds like you don't have the validate plugin script on the page:
http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js
It looks like you are not including the jQuery plugin that provides the .validate() method. You should include it after jQuery:
<script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"><script>
Generally, if you have an object, you can try and access different attributes using dot notation as follows:
var myAwesomeObject = {
coolProperty: "whooooa!"
, coolMethod: function() {return this;}
};
myAwesomeObject.coolProperty; // "whooooa!"
myAwesomeObject.coolMethod; // function(){return this;}
If the property happens to be a method, you can call it like:
myAwesomeObject.coolMethod(); // Object {coolProperty: ...
If the property you are trying to access doesn't exist on the object, you will get back undefined
myAwesomeObject.missingProperty; // undefined
Since undefined is not a function, trying to call a missing property as a method will result in the error you saw:
myAwesomeObject.missingMethod(); // TypeError: you messed up.
I also got this problem. I have fixed this problem other way. That I got in the documentation
To fix the problem you have to declared a specific class.
Using the
mfp-TYPE CSS class (where TYPE is the desired content type). For example: <a class="mfp-image image-link">Open image</a>, $('.image-link').magnificPopup().
Another Example: <a class="mfp-iframe video-link">Open Video</a>, $('.video-link').magnificPopup().

Categories