Skip to content

Commit 46c8baa

Browse files
authored
Merge pull request #20 from Maksonis/master
Resolves #18
2 parents 3d42752 + 06a53fc commit 46c8baa

1 file changed

Lines changed: 61 additions & 44 deletions

File tree

  • src/QuickTranslateBundle/Resources/public/js/quick-translate-btn

src/QuickTranslateBundle/Resources/public/js/quick-translate-btn/areablock.js

Lines changed: 61 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pimcore.document.editables.areablock = Class.create(pimcore.document.editables.a
2626
plusButton.remove();
2727
}
2828

29-
if (!limitReached) {
29+
if(!limitReached) {
3030
// plus buttons
3131
plusUpDiv = Ext.get(element).query('.pimcore_block_plus_up[data-name="' + this.name + '"]')[0];
3232
plusUpButton = new Ext.Button({
@@ -103,7 +103,7 @@ pimcore.document.editables.areablock = Class.create(pimcore.document.editables.a
103103
typeButton.on("afterrender", function (element, v) {
104104
v.dragZone = new Ext.dd.DragZone(v.getEl(), {
105105
hasOuterHandles: true,
106-
getDragData: function (e) {
106+
getDragData: function(e) {
107107
var sourceEl = element;
108108

109109
// only use the button as proxy element
@@ -127,7 +127,7 @@ pimcore.document.editables.areablock = Class.create(pimcore.document.editables.a
127127
beforeDragOut: function (target) {
128128
return target ? true : false;
129129
},
130-
getRepairXY: function () {
130+
getRepairXY: function() {
131131
return this.dragData.repairXY;
132132
}
133133
});
@@ -150,46 +150,9 @@ pimcore.document.editables.areablock = Class.create(pimcore.document.editables.a
150150
optionsButton.render(optionsDiv);
151151
}
152152

153-
154-
//visibility buttons
155-
visibilityButtons = this.visibilityButtons[element.key];
156-
if (typeof visibilityButtons === 'undefined') {
157-
visibilityDiv = Ext.get(element).query('.pimcore_block_visibility[data-name="' + this.name + '"]')[0];
158-
this.visibilityButtons[element.key] = new Ext.Button({
159-
cls: "pimcore_block_button_visibility",
160-
iconCls: "pimcore_icon_white_hide",
161-
enableToggle: true,
162-
pressed: (element.dataset.hidden == "true"),
163-
toggleHandler: function (element, el) {
164-
Ext.get(element).toggleCls('pimcore_area_hidden');
165-
}.bind(this, element)
166-
});
167-
this.visibilityButtons[element.key].render(visibilityDiv);
168-
if (element.dataset.hidden == "true") {
169-
Ext.get(element).addCls('pimcore_area_hidden');
170-
}
171-
}
172-
173-
174-
//dialogBox button
175-
dialogBoxDiv = Ext.get(element).query('.pimcore_block_dialog[data-name="' + this.name + '"]')[0];
176-
if (dialogBoxDiv) {
177-
dialogBoxButton = Ext.get(element).query('.pimcore_block_dialog[data-name="' + this.name + '"] .pimcore_block_button_dialog')[0];
178-
if (typeof dialogBoxButton === 'undefined') {
179-
dialogBoxDiv = Ext.get(element).query('.pimcore_block_dialog[data-name="' + this.name + '"]')[0];
180-
dialogBoxButton = new Ext.Button({
181-
cls: "pimcore_block_button_dialog",
182-
iconCls: "pimcore_icon_white_edit",
183-
listeners: {
184-
"click": this.openEditableDialogBox.bind(this, element, dialogBoxDiv)
185-
}
186-
});
187-
dialogBoxButton.render(dialogBoxDiv);
188-
}
189-
}
190-
191153
/* add quicktranslate btn */
192154
var quickTranslateButton = new Ext.Button({
155+
cls: "pimcore_block_button_translate",
193156
iconCls: 'quick-translate-icon',
194157
scale: 'small',
195158
handler: function (i) {
@@ -538,11 +501,65 @@ pimcore.document.editables.areablock = Class.create(pimcore.document.editables.a
538501

539502
}.bind(this, element)
540503
});
541-
quickTranslateButton.render(visibilityDiv);
504+
505+
//visibility buttons
506+
visibilityButtons = this.visibilityButtons[element.key];
507+
if (typeof visibilityButtons === 'undefined') {
508+
var elementIcon = "pimcore_material_icon_preview";
509+
if (element.dataset.hidden == "true") {
510+
elementIcon = "pimcore_icon_white_hide";
511+
}
512+
visibilityDiv = Ext.get(element).query('.pimcore_block_visibility[data-name="' + this.name + '"]')[0];
513+
this.visibilityButtons[element.key] = new Ext.Button({
514+
cls: "pimcore_block_button_visibility",
515+
iconCls: elementIcon,
516+
enableToggle: true,
517+
pressed: (element.dataset.hidden == "true"),
518+
toggleHandler: function (element, el) {
519+
Ext.get(element).toggleCls('pimcore_area_hidden');
520+
if (el.btnIconEl.dom.classList.contains('pimcore_icon_white_hide')) {
521+
Ext.get(el.btnIconEl.dom).removeCls('pimcore_icon_white_hide');
522+
Ext.get(el.btnIconEl.dom).addCls('pimcore_material_icon_preview');
523+
} else {
524+
Ext.get(el.btnIconEl.dom).removeCls('pimcore_material_icon_preview');
525+
Ext.get(el.btnIconEl.dom).addCls('pimcore_icon_white_hide');
526+
}
527+
}.bind(this, element)
528+
});
529+
this.visibilityButtons[element.key].render(visibilityDiv);
530+
quickTranslateButton.render(visibilityDiv);
531+
new Ext.tip.ToolTip({
532+
target: this.visibilityButtons[element.key],
533+
html: t("show_hide_areablock")
534+
});
535+
if(element.dataset.hidden == "true") {
536+
Ext.get(element).addCls('pimcore_area_hidden');
537+
}
538+
}
539+
540+
541+
//dialogBox button
542+
dialogBoxDiv = Ext.get(element).query('.pimcore_block_dialog[data-name="' + this.name + '"]')[0];
543+
if (dialogBoxDiv) {
544+
dialogBoxButton = Ext.get(element).query('.pimcore_block_dialog[data-name="' + this.name + '"] .pimcore_block_button_dialog')[0];
545+
if (typeof dialogBoxButton === 'undefined') {
546+
dialogBoxDiv = Ext.get(element).query('.pimcore_block_dialog[data-name="' + this.name + '"]')[0];
547+
dialogBoxButton = new Ext.Button({
548+
cls: "pimcore_block_button_dialog",
549+
iconCls: "pimcore_icon_white_edit",
550+
listeners: {
551+
"click": this.openEditableDialogBox.bind(this, element, dialogBoxDiv)
552+
}
553+
});
554+
dialogBoxButton.render(dialogBoxDiv);
555+
}
556+
}
557+
558+
542559

543560
labelDiv = Ext.get(Ext.get(element).query('.pimcore_block_label[data-name="' + this.name + '"]')[0]);
544-
labelText = "<b>" + element.type + "</b>";
545-
if (this.typeNameMappings[element.type]
561+
labelText = "<b>" + element.type + "</b>";
562+
if(this.typeNameMappings[element.type]
546563
&& typeof this.typeNameMappings[element.type].name != "undefined") {
547564
labelText = "<b>" + this.typeNameMappings[element.type].name + "</b> "
548565
+ this.typeNameMappings[element.type].description;

0 commit comments

Comments
 (0)