clean up helper file
parent
649a28b6c6
commit
54a77458d6
|
@ -1,14 +1,13 @@
|
||||||
var testHelper = {};
|
var testHelper = {};
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
var $iframeContainer = $("#iframe-container"), $iframe;
|
var $iframeContainer = $("#iframe-container"),
|
||||||
|
$iframe;
|
||||||
|
|
||||||
testHelper.randomString = function randomString(len)
|
testHelper.randomString = function randomString(len) {
|
||||||
{
|
|
||||||
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||||
var randomstring = '';
|
var randomstring = '';
|
||||||
for (var i = 0; i < len; i++)
|
for (var i = 0; i < len; i++) {
|
||||||
{
|
|
||||||
var rnum = Math.floor(Math.random() * chars.length);
|
var rnum = Math.floor(Math.random() * chars.length);
|
||||||
randomstring += chars.substring(rnum, rnum + 1);
|
randomstring += chars.substring(rnum, rnum + 1);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +18,8 @@ var testHelper = {};
|
||||||
var padName = "FRONTEND_TEST_" + testHelper.randomString(20);
|
var padName = "FRONTEND_TEST_" + testHelper.randomString(20);
|
||||||
$iframe = $("<iframe src='/p/" + padName + "'></iframe>")
|
$iframe = $("<iframe src='/p/" + padName + "'></iframe>")
|
||||||
|
|
||||||
$iframeContainer.empty().append($iframe);
|
$iframeContainer.empty()
|
||||||
|
.append($iframe);
|
||||||
|
|
||||||
var checkInterval;
|
var checkInterval;
|
||||||
$iframe.load(function () {
|
$iframe.load(function () {
|
||||||
|
@ -28,14 +28,19 @@ var testHelper = {};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//check if loading div is hidden
|
//check if loading div is hidden
|
||||||
loaded = !testHelper.$getPadChrome().find("#editorloadingbox").is(":visible");
|
loaded = !testHelper.$getPadChrome()
|
||||||
} catch(e){}
|
.find("#editorloadingbox")
|
||||||
|
.is(":visible");
|
||||||
|
}
|
||||||
|
catch (e) {}
|
||||||
|
|
||||||
if (loaded) {
|
if (loaded) {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
clearInterval(checkInterval);
|
clearInterval(checkInterval);
|
||||||
|
|
||||||
cb(null, {name: padName});
|
cb(null, {
|
||||||
|
name: padName
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, 100);
|
}, 100);
|
||||||
});
|
});
|
||||||
|
@ -53,22 +58,28 @@ var testHelper = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
testHelper.$getPadOuter = function () {
|
testHelper.$getPadOuter = function () {
|
||||||
return testHelper.$getPadChrome().find('iframe.[name="ace_outer"]').contents();
|
return testHelper.$getPadChrome()
|
||||||
|
.find('iframe.[name="ace_outer"]')
|
||||||
|
.contents();
|
||||||
}
|
}
|
||||||
|
|
||||||
testHelper.$getPadInner = function () {
|
testHelper.$getPadInner = function () {
|
||||||
return testHelper.$getPadOuter().find('iframe.[name="ace_inner"]').contents();
|
return testHelper.$getPadOuter()
|
||||||
|
.find('iframe.[name="ace_inner"]')
|
||||||
|
.contents();
|
||||||
}
|
}
|
||||||
|
|
||||||
// copied from http: //stackoverflow.com/questions/985272/jquery-selecting-text-in-an-element-akin-to-highlighting-with-your-mouse
|
// copied from http: //stackoverflow.com/questions/985272/jquery-selecting-text-in-an-element-akin-to-highlighting-with-your-mouse
|
||||||
testHelper.selectText = function (element) {
|
testHelper.selectText = function (element) {
|
||||||
var doc = document, range, selection;
|
var doc = document,
|
||||||
|
range, selection;
|
||||||
|
|
||||||
if (doc.body.createTextRange) { //ms
|
if (doc.body.createTextRange) { //ms
|
||||||
range = doc.body.createTextRange();
|
range = doc.body.createTextRange();
|
||||||
range.moveToElementText(element);
|
range.moveToElementText(element);
|
||||||
range.select();
|
range.select();
|
||||||
} else if (window.getSelection) { //all others
|
}
|
||||||
|
else if (window.getSelection) { //all others
|
||||||
selection = window.getSelection();
|
selection = window.getSelection();
|
||||||
range = doc.createRange();
|
range = doc.createRange();
|
||||||
range.selectNodeContents(element);
|
range.selectNodeContents(element);
|
||||||
|
@ -77,4 +88,3 @@ var testHelper = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue