2014-07-08 00:36:25 -05:00
|
|
|
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);
|
2014-07-07 07:35:28 -05:00
|
|
|
} else {
|
2014-07-08 00:36:25 -05:00
|
|
|
throw new Error(
|
|
|
|
"No element was defined for the editor to inject to."
|
|
|
|
);
|
2014-07-07 07:35:28 -05:00
|
|
|
}
|
2014-07-08 00:36:25 -05:00
|
|
|
var iframe = document.createElement('iframe');
|
|
|
|
var div = document.createElement('div');
|
2014-07-08 01:00:44 -05:00
|
|
|
div.className = 'Squire-UI';
|
|
|
|
|
2014-07-08 00:36:25 -05:00
|
|
|
$(div).load(buildPath + 'Squire-UI.html', function () {
|
|
|
|
$('.item').click(function () {
|
2014-07-08 01:00:44 -05:00
|
|
|
var me = $(this);
|
|
|
|
var iFrame = me.parents('.Squire-UI').next('iframe').first()[0];
|
|
|
|
var editor = iFrame.contentWindow.document;
|
|
|
|
var action = me.data('action');
|
|
|
|
console.log(editor, action);
|
2014-07-08 00:36:25 -05:00
|
|
|
});
|
|
|
|
});
|
2014-07-07 19:45:18 -05:00
|
|
|
|
2014-07-08 00:36:25 -05:00
|
|
|
$(container).append(div);
|
|
|
|
$(container).append(iframe);
|
2014-07-08 01:00:44 -05:00
|
|
|
|
2014-07-08 00:36:25 -05:00
|
|
|
editor = new Squire(iframe.contentWindow.document);
|
|
|
|
return editor;
|
|
|
|
};
|
2014-07-07 02:46:17 -05:00
|
|
|
|
2014-07-08 00:36:25 -05:00
|
|
|
|
2014-07-07 02:46:17 -05:00
|
|
|
|
2014-07-08 00:36:25 -05:00
|
|
|
});
|