0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2025-01-06 23:00:08 -05:00
Squire/ui/Squire-UI.js
2014-07-08 15:36:25 +10:00

43 lines
No EOL
1.1 KiB
JavaScript

if (typeof buildPath == "undefined") {
buildPath = 'build/';
}
function buildPathConCat(value) {
return buildPath + value;
}
$(document).ready(function () {
SquireUI = function(options) {
// Create instance of iFrame
var container, editor;
if (options.replace) {
container = $(options.replace).parent();
$(options.replace).remove();
} else if (options.div) {
container = $(options.div);
} else {
throw new Error(
"No element was defined for the editor to inject to."
);
}
var iframe = document.createElement('iframe');
var div = document.createElement('div');
$(div).load(buildPath + 'Squire-UI.html', function () {
$('.item').click(function () {
console.log($(this).parent().parent().parent());
});
});
$(container).append(div);
$(container).append(iframe);
editor = new Squire(iframe.contentWindow.document);
return editor;
};
});