');
this.$box.attr('data-title', this.lang.get('choose'));
this.$box.addClass('redactor-modal-tab');
this.$box.hide();
this.$box.css({
overflow: 'auto',
height: '300px',
'line-height': 1
});
$body.append(this.$box);
$R.ajax.get({
url: this.opts.imageManagerJson,
success: this._parse.bind(this)
});
},
_parse: function (data) {
for (var key in data) {
var obj = data[key];
if (typeof obj !== 'object') continue;
var $img = $R.dom('
');
var url = (obj.thumb) ? obj.thumb : obj.url;
$img.attr('src', url);
$img.attr('data-params', encodeURI(JSON.stringify(obj)));
$img.css({
width: '96px',
height: '72px',
margin: '0 4px 2px 0',
cursor: 'pointer'
});
$img.on('click', this._insert.bind(this));
this.$box.append($img);
}
},
_insert: function (e) {
e.preventDefault();
var $el = $R.dom(e.target);
var data = JSON.parse(decodeURI($el.attr('data-params')));
this.app.api('module.image.insert', {
image: data
});
}
});
$R.add('plugin', 'fullscreen', {
translations: {
en: {
"fullscreen": "Fullscreen"
}
},
init: function (app) {
this.app = app;
this.opts = app.opts;
this.lang = app.lang;
this.$win = app.$win;
this.$doc = app.$doc;
this.$body = app.$body;
this.editor = app.editor;
this.toolbar = app.toolbar;
this.container = app.container;
this.selection = app.selection;
// local
this.isOpen = false;
this.docScroll = 0;
},
// public
start: function () {
var data = {
title: this.lang.get('fullscreen'),
api: 'plugin.fullscreen.toggle'
};
var button = this.toolbar.addButtonAuto('fullscreen', data);
button.setIcon('
');
this.$target = (this.toolbar.isTarget()) ? this.toolbar.getTargetElement() : this.$body;
if (this.opts.fullscreen) this.toggle();
},
toggle: function () {
return (this.isOpen) ? this.close() : this.open();
},
open: function () {
this.docScroll = this.$doc.scrollTop();
this._createPlacemarker();
this.selection.save();
var $container = this.container.getElement();
var $editor = this.editor.getElement();
var $html = (this.toolbar.isTarget()) ? $R.dom('body, html') : this.$target;
if (this.opts.toolbarExternal) this._buildInternalToolbar();
this.$target.prepend($container);
this.$target.addClass('redactor-body-fullscreen');
$container.addClass('redactor-box-fullscreen');
if (this.isTarget) $container.addClass('redactor-box-fullscreen-target');
$html.css('overflow', 'hidden');
if (this.opts.maxHeight) $editor.css('max-height', '');
if (this.opts.minHeight) $editor.css('min-height', '');
this._resize();
this.$win.on('resize.redactor-plugin-fullscreen', this._resize.bind(this));
this.$doc.scrollTop(0);
var button = this.toolbar.getButton('fullscreen');
button.setIcon('
');
this.selection.restore();
this.isOpen = true;
this.opts.zindex = 1051;
},
close: function () {
this.isOpen = false;
this.opts.zindex = false;
this.selection.save();
var $container = this.container.getElement();
var $editor = this.editor.getElement();
var $html = $R.dom('body, html');
if (this.opts.toolbarExternal) this._buildExternalToolbar();
this.$target.removeClass('redactor-body-fullscreen');
this.$win.off('resize.redactor-plugin-fullscreen');
$html.css('overflow', '');
$container.removeClass('redactor-box-fullscreen redactor-box-fullscreen-target');
$editor.css('height', 'auto');
if (this.opts.minHeight) $editor.css('minHeight', this.opts.minHeight);
if (this.opts.maxHeight) $editor.css('maxHeight', this.opts.maxHeight);
var button = this.toolbar.getButton('fullscreen');
button.setIcon('
');
this._removePlacemarker($container);
this.selection.restore();
this.$doc.scrollTop(this.docScroll);
},
// private
_resize: function () {
var $toolbar = this.toolbar.getElement();
var $editor = this.editor.getElement();
var height = this.$win.height() - $toolbar.height();
$editor.height(height);
},
_buildInternalToolbar: function () {
var $wrapper = this.toolbar.getWrapper();
var $toolbar = this.toolbar.getElement();
$wrapper.addClass('redactor-toolbar-wrapper');
$wrapper.append($toolbar);
$toolbar.removeClass('redactor-toolbar-external');
$container.prepend($wrapper);
},
_buildExternalToolbar: function () {
var $wrapper = this.toolbar.getWrapper();
var $toolbar = this.toolbar.getElement();
this.$external = $R.dom(this.opts.toolbarExternal);
$toolbar.addClass('redactor-toolbar-external');
this.$external.append($toolbar);
$wrapper.remove();
},
_createPlacemarker: function () {
var $container = this.container.getElement();
this.$placemarker = $R.dom('
');
$container.after(this.$placemarker);
},
_removePlacemarker: function ($container) {
this.$placemarker.before($container);
this.$placemarker.remove();
}
});
$R.add('plugin', 'video', {
translations: {
en: {
"video": "Video",
"video-html-code": "Video Embed Code or Youtube/Vimeo Link"
}
},
modals: {
'video':
'
'
},
init: function (app) {
this.app = app;
this.lang = app.lang;
this.opts = app.opts;
this.toolbar = app.toolbar;
this.component = app.component;
this.insertion = app.insertion;
this.inspector = app.inspector;
},
// messages
onmodal: {
video: {
opened: function ($modal, $form) {
$form.getField('video')
.focus();
},
insert: function ($modal, $form) {
var data = $form.getData();
this._insert(data);
}
}
},
oncontextbar: function (e, contextbar) {
var data = this.inspector.parse(e.target)
if (data.isComponentType('video')) {
var node = data.getComponent();
var buttons = {
"remove": {
title: this.lang.get('delete'),
api: 'plugin.video.remove',
args: node
}
};
contextbar.set(e, node, buttons, 'bottom');
}
},
// public
start: function () {
var obj = {
title: this.lang.get('video'),
api: 'plugin.video.open'
};
var $button = this.toolbar.addButtonAfter('image', 'video', obj);
$button.setIcon('
');
},
open: function () {
var options = {
title: this.lang.get('video'),
width: '600px',
name: 'video',
handle: 'insert',
commands: {
insert: {
title: this.lang.get('insert')
},
cancel: {
title: this.lang.get('cancel')
}
}
};
this.app.api('module.modal.build', options);
},
remove: function (node) {
this.component.remove(node);
},
// private
_insert: function (data) {
this.app.api('module.modal.close');
if (data.video.trim() === '') {
return;
}
// parsing
data.video = this._matchData(data.video);
// inserting
if (this._isVideoIframe(data.video)) {
var $video = this.component.create('video', data.video);
this.insertion.insertHtml($video);
}
},
_isVideoIframe: function (data) {
return (data.match(/