Retour à la documentation
define([
'dojo/_base/declare', 'dojo/dom-style', 'dijit/_WidgetBase', 'dijit/_TemplatedMixin', 'dojo/window', 'dojo/dom-class',
'dojo/dom-construct', 'dojo/on', 'dojo/touch', 'dojo/_base/lang', 'dijit/popup'
], function(declare, domStyle, _Base, _Template, win, domClass, domConstruct, on, touch, lang, popup) {
/**
* Permet de créer un objet de menu propre à l'API
*/
return declare([_Base, _Template], {
templateString: '<div class="SpwPopupItem"><div class="dialogPopupTitle" style="width: 100%; height: 40px;" data-dojo-attach-point="titleNode"></div><div data-dojo-attach-point="widgetNode" class="spwPopupItemWidgetNode"></div></div>',
widget: null,
dimensions: null,
closable: false,
/**
* Appelé après la création du SpwPopupItem
*/
postCreate: function() {
this.inherited(arguments);
if (this.widget.widgetTitle) {
this.titleNode.innerHTML = '<span>' + this.widget.widgetTitle + '</span>';
}
else {
domStyle.set(this.titleNode, 'display', 'none');
}
if (this.lightTitle) {
domClass.add(this.domNode, 'lightTitle');
}
domStyle.set(this.widgetNode, 'height', this.getWidgetHeight());
this.widget.placeAt(this.widgetNode);
if (this.closable) {
var closeIcon = domConstruct.create('div', {
'class': 'spwCloseIcon',
'style': 'top: 10px; right: 8px;'
}, this.domNode, 'last');
on(closeIcon, touch.press, lang.hitch(this, function() {
this.widget.unblockClosing();
popup.close();
}));
}
},
/**
* Redimensionne le SpwPopupItem
*/
resize: function() {
this.inherited(arguments);
domStyle.set(this.widgetNode, 'height', this.getWidgetHeight());
if (this.widget && this.widget.resize) {
this.widget.resize();
}
},
/**
* Rafraîchit le SpwPopupItem
*/
refresh: function() {
this.widget.placeAt(this.widgetNode);
},
/**
* Permet d'obtenir la taille du widget
* @return la taille du widget en pixel
*/
getWidgetHeight: function() {
if (this.dimensions.h === 'auto') {
return 'auto';
}
var h = this.dimensions.h;
if (h.indexOf('vh') > -1) {
var vs = win.getBox();
var h = (vs.h * (+(h.slice(0, -2)) / 100) - 40) + 'px';
}
else {
if (h.indexOf('px') > -1) {
h = h.slice(0, -2);
}
h = (+h - 40) + 'px';
}
return h;
},
/**
* Appelé à l'ouverture du SpwPopupItem
*/
onOpen: function () {
if (this.lightTitle) {
if(this.parentMenu == null){
domClass.remove(this._popupWrapper, "Popup");
domClass.add(this._popupWrapper, this.widgetInfo && this.widgetInfo.popupClass ? this.widgetInfo.popupClass : "iWantToMenuPopup");
} else {
domClass.add(this._popupWrapper, "iWantToMenuChildPopup");
domClass.remove(this._popupWrapper, "Popup");
}
if(!domClass.contains(document.body, "claro")){
domClass.add(this._popupWrapper, "claro");
domStyle.set(this._popupWrapper, { "width":"auto", "height": "auto", "overflow": "initial" });
}
}
this.refresh();
if (this.widget.resize) {
this.widget.resize();
}
this.widget.onActivate();
if (this.closable) {
this.widget.blockClosing();
}
},
/**
* Appelé à la fermeture du SpwPopupItem
*/
onClose: function () {
this.widget.onDeactivate();
},
/**
* Ferme le SpwPopupitem
*/
close: function () {
if (this.parentMenu && this.parentMenu.parentMenu
&& this.parentMenu.parentMenu.currentPopupItem
&& this.parentMenu.parentMenu.currentPopupItem.popup
&& this.parentMenu.parentMenu.currentPopupItem.popup.onExecute) {
this.parentMenu.parentMenu.currentPopupItem.popup.onExecute();
}
},
onExecute: function () {
}
});
});