class Action extends SelectFromArray
{
-public function getOptions()
-{
- return [
- 'index'=>__("Basculer entre la publication et l'index"),
- 'chapters'=>__('Afficher le sommaire'),
- 'print'=>__('Imprimer'),
- 'share'=>__('Partager par e-mail'),
- 'bookmarks'=>__('Ajouter un marque-page'),
- 'pdf'=>__('Télécharger le PDF'),
- 'notes'=>__('Notes'),
- 'fullscreen'=>__('Basculer entre le mode plein écran et le mode normal'),
- 'sound'=>__('Activer / Couper le son'),
- //'2dmode'=>__('Basculer du mode 2D au mode 3D'),
- 'archives'=>__('Afficher les archives'),
- 'basket'=>__('Ouvrir le panier'),
- 'form'=>__('Ouvrir le formulaire'),
- 'facebook'=>__('Partager sur Facebook'),
- 'twitter'=>__('Partager sur Twitter'),
- //'googleplus'=>__('Partager sur Google+'),
- 'linkedin'=>__('Partager sur LinkedIn'),
- //'viadeo'=>__('Partager sur Viadeo'),
- 'whatsapp'=>__('Partager sur Whatsapp'),
- 'pinterest'=>__('Partager sur Pinterest'),
- ];
-}
+ protected $_ajax = false;
+
+ public function getOptions()
+ {
+
+ return [
+ 'index' => __("Basculer entre la publication et l'index"),
+ 'chapters' => __('Afficher le sommaire'),
+ 'print' => __('Imprimer'),
+ 'share' => __('Partager par e-mail'),
+ 'bookmarks' => __('Ajouter un marque-page'),
+ 'pdf' => __('Télécharger le PDF'),
+ 'notes' => __('Notes'),
+ 'fullscreen' => __('Basculer entre le mode plein écran et le mode normal'),
+ 'sound' => __('Activer / Couper le son'),
+ //'2dmode'=>__('Basculer du mode 2D au mode 3D'),
+ 'archives' => __('Afficher les archives'),
+ 'basket' => __('Ouvrir le panier'),
+ 'form' => __('Ouvrir le formulaire'),
+ 'facebook' => __('Partager sur Facebook'),
+ 'twitter' => __('Partager sur Twitter'),
+ //'googleplus'=>__('Partager sur Google+'),
+ 'linkedin' => __('Partager sur LinkedIn'),
+ //'viadeo'=>__('Partager sur Viadeo'),
+ 'whatsapp' => __('Partager sur Whatsapp'),
+ 'pinterest' => __('Partager sur Pinterest'),
+ ];
+ }
}
class Depth extends SelectFromArray
{
protected $_ajax = false;
+ protected $_allowNull=false;
+
+ protected $_default=-1;
+
public function getOptions()
{
class Layer extends SelectFromArray
{
-public function getOptions()
-{
- return [
- 'both'=>__('Texte et image'),
- 'text'=>__('Texte'),
- 'image'=>__('Image'),
- ];
-}
+ protected $_ajax = false;
+ protected $_allowNull = false;
+ protected $_default = 'both';
+
+ public function getOptions()
+ {
+ return [
+ 'both' => __('Texte et image'),
+ 'text' => __('Texte'),
+ 'image' => __('Image'),
+ ];
+ }
}
class MultimediaIntegration extends SelectFromArray
{
+ protected $_ajax=false;
+ protected $_allowNull=false;
+ protected $_default='inline';
+
public function getOptions()
{
return [
class NumberingType extends SelectFromArray
{
+ protected $_ajax = false;
+ protected $_allowNull = false;
+ protected $_default = 'virtual';
+
public function getOptions()
{
return [
class RolloverAnimation extends SelectFromArray
{
+ protected $_ajax = false;
+ protected $_allowNull = false;
+ protected $_default = 'none';
+
public function getOptions()
{
return [
class ShowLinkCloseMode extends SelectFromArray
{
-public function getOptions()
-{
- return [
- 'none' => __('Aucune'),
- 'topright' => __('En haut à droite'),
- 'topleft' => __('En haut à gauche'),
- 'whole' => __('Toute la zone'),
- ];
-}
+ protected $_ajax = false;
+ protected $_allowNull = false;
+ protected $_default = 'none';
+
+ public function getOptions()
+ {
+ return [
+ 'none' => __('Aucune'),
+ 'topright' => __('En haut à droite'),
+ 'topleft' => __('En haut à gauche'),
+ 'whole' => __('Toute la zone'),
+ ];
+ }
}
class ShowLinkMode extends SelectFromArray
{
+ protected $_ajax = false;
+ protected $_allowNull = false;
+ protected $_default = 'show';
+
public function getOptions()
{
return [
class Target extends SelectFromArray
{
- protected $_ajax=false;
- protected $_allowNull=false;
+ protected $_ajax = false;
+ protected $_allowNull = false;
+ protected $_default = '_blank';
public function getOptions()
{
class TriggerLinkEvent extends SelectFromArray
{
+ protected $_ajax = false;
+ protected $_allowNull = false;
+ protected $_default = 'page';
+
public function getOptions()
{
return [
class WebvideoService extends SelectFromArray
{
+ protected $_ajax = false;
+ protected $_default = 'youtube';
+ protected $_allowNull = false;
+
+
public function getOptions()
{
return [
'vimeo' => 'Vimeo',
'brightcove' => 'Vimeo',
];
-}
+ }
}
use App\Fields\FluidbookLinkEditor\Depth;
use App\Fields\FluidbookLinkEditor\LinkType;
use App\Fields\FluidbookLinkEditor\MultimediaIntegration;
+use App\Fields\FluidbookLinkEditor\RolloverAnimation;
use App\Models\FluidbookPublication;
use Cubist\Backpack\Magic\Fields\Checkbox;
use Cubist\Backpack\Magic\Fields\FieldGroupEnd;
}
$this->addField('header_tooltip', FormSection::class, __('Infobulles'));
$this->addField('tooltip', Text::class, __('Texte de l\'infobulle'), ['hint' => __('Laisser vide pour conserver le texte par défaut')]);
- $this->addField('display_area', Checkbox::class, __('Afficher la zone de couleur au survol'));
+ $this->addField('display_area', Checkbox::class, __('Afficher la zone de couleur au survol'), ['default' => true]);
}
public function addTypeField()
if ($this->_addedContents) {
$this->addField('header_contents', FormSection::class, __('Contenus superposés'));
$this->addField('image', FilesOrURL::class, __('Image'), array_merge($this->getFilesOrURLEntry(), ['accept' => ['.jpg', '.jpeg', '.png', '.svg', '.gif']]));
+ $this->addField('image_rollover', RolloverAnimation::class, __('Animation de l\'image au survol'));
$this->addField('animation', FilesOrURL::class, __('Animation'), array_merge($this->getFilesOrURLEntry(), ['accept' => ['.html']]));
}
if ($this->_integration) {
- $this->addField('inline', MultimediaIntegration::class, __('Intégration'), ['default' => 'inline']);
+ $this->addField('inline', MultimediaIntegration::class, __('Intégration'));
}
if ($this->_multimedia) {
$this->addMultimediaFields();
function LinkeditorForm(linkeditor) {
this.linkeditor = linkeditor;
+ this._maskChangeEvent = false;
+ this._maskChangeEventTimeout = null;
this.init();
}
LinkeditorForm.prototype = {
init: function () {
- $(document).on('focus', "input[type=text],input[type=email],input[type=url],input[type=number],textarea", function () {
- var $this = $(this);
- setTimeout(function () {
- $this.select();
- }, 1);
+ var $this = this;
+
+ $('#linkeditor-panel-form').on('change', '[name="type"]', function () {
+ if ($this._maskChangeEvent) {
+ return;
+ }
+ $this.saveFormDataInLink();
+ $this.updateLinkForm();
+ });
+
+ $('#linkeditor-panel-form').on('change', "input, select, textarea", function () {
+ if ($this._maskChangeEvent) {
+ return;
+ }
+ $this.saveFormDataInLink();
});
},
- initCodeMirror: function () {
- $('#linkeditor-panel-form textarea.code').each(function () {
- var textarea = $(this);
- var c = CodeMirror.fromTextArea($(textarea).get(0), {
- lineNumbers: true, mode: $(textarea).data('mode'), theme: 'dracula',
- });
- $(textarea).data('codemirror', c);
- c.on('change', function (o) {
- o.save();
- });
+ saveFormDataInLink: function () {
+
+ var form = $("#linkeditor-panel-form form");
+ if ($(form).length === 0) {
+ return;
+ }
+
+ this.maskChangeEvent();
+ var link = $(form).data('link');
+ var data = $(form).serializeArray()
+ var ignore = ['_method', '_referrer', '_token', 'http_referrer'];
+ var map = {y: 'top', x: 'left', w: 'width', h: 'height'};
+ var savedData = {};
+ $.each(data, function (k, v) {
+ if (ignore.indexOf(v.name) >= 0) {
+ return;
+ }
+ let key = v.name;
+ if (map[v.name] !== undefined && map[v.name] !== null) {
+ key = map[v.name];
+ }
+ savedData[key] = v.value;
+ $(link).attr('fb-' + key, v.value);
});
+ $(link).attr('fb-update', 1);
+ this.linkeditor.links.updateLinkData($(link).attr('fb-origuid'), savedData);
+ this.linkeditor.hasChanged();
+ this.unmaskChangeEvent();
},
+ emptyForm: function () {
+ $('#linkeditor-panel-form .select2_from_array').each(function () {
+ $(this).select2('close');
+ $(this).select2('destroy');
+ });
+ $('#linkeditor-panel-form').html('');
+ },
+
+ updateLinkForm: function () {
+ var links = $('.link.selected:not(.pendingCreate)');
+ if (links.length != 1) {
+ this.emptyForm();
+ return;
+ }
+
+ this.emptyForm();
+ var container = $('#linkeditor-panel-form');
+ var link = $(links).eq(0);
+ var type = $(link).attr('fb-type');
+ var form = $("#linkeditor-form-template-" + type).clone(false);
+
+ $(form).attr('id', null);
+ $(form).data('link', link);
+ this.updateFormData(form);
+ container.append(form);
+
+
+ this.initSelect2();
+ },
+
+ updateFormData: function (form) {
+ var $this = this;
+ try {
+ if (form === undefined) {
+ form = $('#linkeditor-panel-form form');
+ if (form.length === 0) {
+ return;
+ }
+ }
+ var link = $(form).data('link');
+ if (link === undefined || link === null) {
+ return;
+ }
+ } catch (e) {
+ return;
+ }
+
+
+ var types = {x: 'dimension', y: 'dimension', w: 'dimension', h: 'dimension', rot: 'dimension'}
+ var map = {top: 'y', left: 'x', width: 'w', height: 'h'};
+
+ this.maskChangeEvent();
+ $.each(this.linkeditor.links.getLinkData(link), function (k, v) {
+ if (map[k] !== undefined) {
+ k = map[k];
+ }
+ var type = 'string';
+ if (types[k] !== undefined) {
+ type = types[k];
+ }
+ if (type === 'dimension') {
+ v = parseFloat(v);
+ if (isNaN(v)) {
+ v = 0;
+ }
+ v = Math.round(v * 100000) / 100000;
+ }
+ $(form).find('[name=' + k + ']').val(v);
+ });
+ this.unmaskChangeEvent();
+ },
+
+ maskChangeEvent: function () {
+ this._maskChangeEvent = true;
+ },
+
+ unmaskChangeEvent: function () {
+ var $this = this;
+ clearTimeout(this._maskChangeEventTimeout);
+ if (this._maskChangeEvent === false) {
+ return;
+ }
+ this._maskChangeEventTimeout = setTimeout(function () {
+ $this._maskChangeEvent = false;
+ }, 100);
+ },
+
+
initSelect2: function () {
// trigger select2 for each untriggered select2 box
$('#linkeditor-panel-form .select2_from_array:not(.init)').each(function (i, obj) {
var options = {
theme: "bootstrap",
};
- if ($(this).is('[data-ajax]')) {
- options.ajax = {
- url: 'select2/' + $(this).data('ajax'), dataType: 'json', delay: 250,
- };
- }
if ($(this).is('[data-allow-html="1"]')) {
options.escapeMarkup = function (m) {
return m;
}
}
- $(obj).addClass('init').select2(options);
+ $(this).addClass('init')
+ $(this).select2(options);
});
},
deselectAll = false;
}
if (deselectAll) {
+ $this.form.saveFormDataInLink();
$this.links.deselectAllLinks();
}
});
});
$(e).css(css).attr('fb-update', '0');
});
- this.links.updateFormData();
+ this.form.updateFormData();
},
fluidbookTo: function (dim, name, rect) {
var link = this.duplicateLinkClick({width: 0, height: 0});
$(link).addClass('pendingCreate');
this.startResizeLink('se');
- this.updateLinkForm();
+ this.linkeditor.form.updateLinkForm();
},
startResizeLink: function (corner) {
$('.pendingCreate').each(function () {
$this.deleteLink($(this), true);
});
- this.updateLinkForm();
+ this.linkeditor.form.updateLinkForm();
this.resizeLinkPos = null;
},
$(this).removeClass('pendingCreate');
}
- $this.updateLinkData($(this).attr('fb-uid'), {
+ $this.updateLinkData($(this).attr('fb-origuid'), {
top: newTop, left: newLeft, width: newWidth, height: newHeight
});
});
.attr('fb-top', top)
.attr('fb-update', '1');
- $this.updateLinkData($(this).attr('fb-uid'), {
+ $this.updateLinkData($(this).attr('fb-origuid'), {
top: top, left: left,
});
});
}
$(l).addClass('selected');
this.currentSelection.push(l);
- this.updateLinkForm();
+ this.linkeditor.form.updateLinkForm();
this.lastSelectedLink = l;
},
- updateLinkForm: function () {
- var container = $('#linkeditor-panel-form');
- container.html('');
- var links = $('.link.selected:not(.pendingCreate)');
- if (links.length != 1) {
- return;
- }
- var link = $(links).eq(0);
- var type = $(link).attr('fb-type');
- var form = $("#linkeditor-form-template-" + type).clone(false);
-
- $(form).attr('id', null);
- $(form).data('link', link);
- this.updateFormData(form);
- container.append(form);
-
- // Reset select2 fields
- $(form).find('select.select2_from_array.init').each(function () {
- $(this).removeClass('init');
- });
-
- this.linkeditor.form.initSelect2();
- this.linkeditor.form.initCodeMirror();
- },
-
- updateFormData: function (form) {
- try {
- if (form === undefined) {
- form = $('#linkeditor-panel-form form');
- if (form.length === 0) {
- return;
- }
- }
- var link = $(form).data('link');
- if (link === undefined || link === null) {
- return;
- }
- } catch (e) {
- return;
- }
- var types = {x: 'dimension', y: 'dimension', w: 'dimension', h: 'dimension', rot: 'dimension'}
- var map = {top: 'y', left: 'x', width: 'w', height: 'h'};
- $.each(this.getLinkData(link), function (k, v) {
- if (map[k] !== undefined) {
- k = map[k];
- }
- var type = 'string';
- if (types[k] !== undefined) {
- type = types[k];
- }
- if (type === 'dimension') {
- v = Math.round(parseFloat(v) * 100000) / 100000;
- }
- $(form).find('[name=' + k + ']').val(v);
- });
- },
-
checkLastSelectedLink: function () {
if (this.lastSelectedLink === null || $(this.lastSelectedLink).length === 0) {
return;
deselectAllLinks: function () {
this.currentSelection = [];
$(".link.selected").removeClass('selected');
- this.updateLinkForm();
+ this.linkeditor.form.updateLinkForm();
},
offsetSelectedLinks: function (dim, value) {
let data = {};
data[dim] = newValue;
$(this).attr('fb-' + dim, newValue).attr('fb-update', '1');
- $this.updateLinkData($(this).attr('fb-uid'), data);
+ $this.updateLinkData($(this).attr('fb-origuid'), data);
});
this.linkeditor.updateFBElements();
- this.updateFormData();
+ this.linkeditor.form.updateFormData();
},
getLinksOfPage: function (p) {
change = true;
}
+ link.origuid = link.uid;
+
let attrs = {};
$.each(link, function (k, v) {
attrs['fb-' + k] = v;
let link = this.addLink(data);
this.deselectAllLinks();
this.selectLink($(link));
- this.updateFormData();
+ this.linkeditor.form.updateFormData();
return $(link);
},
if (triggerChange === undefined) {
triggerChange = true;
}
- delete LINKS[$(link).attr('fb-uid')];
+ delete LINKS[$(link).attr('fb-origuid')];
$(link).remove();
if (triggerChange === true) {
this.linkeditor.hasChanged();
+.select2-hidden-accessible
+ position: fixed !important
+
#linkeditor-form-templates
display: none