--- /dev/null
+/*
+Copyright (c) Igor Barma, Alexandre Desoubeaux, Christian Martel, Eric Brun, Mathieu Amblard, Gwenael Gevet, Pierre Guillot, 2012
+ * Copyright Alexandre Desoubeaux, Christian Martel, Cedric Lecarpentier, Alexandre Lefevre, Marc Salvat 2014-2016
+ * Copyright Alexandre Desoubeaux, Christian Martel, Cedric Lecarpentier, Marc Salvat, Marc Suarez, Harifetra Ramamonjy 2017
+For licensing, see README.txt or http://www.pentilanero.com (Cecill-C or AGPL or LGPL)
+*/
+Ext.ns("EntSavoie.ShortCuts");
+EntSavoie.ShortCuts.ShortCutsPanel = function (config) {
+ Ext.apply(this, config);
+
+ // Ajoute le texte des erreurs
+ Ext.QuickTips.init();
+ // turn on validation errors beside the field globally
+ Ext.form.Field.prototype.msgTarget = 'side';
+
+ this.firstLoad = this.firstLoad || true;
+
+ this.shortCutTree = this.shortCutTree || new EntSavoie.ShortCuts.ShortCutsTreeFolder({
+ actionURLAjax: this.actionURLAjax,
+ renderURLAjax: this.renderURLAjax,
+ mainContainer: this
+ });
+
+ this.closeBtn = this.closeBtn || new Ext.Button({
+ iconCls: "closeBtnIconCls",
+ handler: this.onCloseFn,
+ cls: 'closeBtnCls',
+ scope: this
+ });
+
+ //Constructeur de la page
+ EntSavoie.ShortCuts.ShortCutsPanel.superclass.constructor.call(this, {
+ style: "left:-1000px;top:-1000px;",
+ border: true,
+ height: 300,
+ width: 240,
+ layout: 'form',
+ listeners: {
+ render: function(p) {
+ //p.getEl().on('mouseleave', this.onMouseLeaveFn, this);
+ }
+ },
+ floating: {
+ shadow: true,
+ shim: true,
+ useDisplay: true,
+ constrain: false
+ },
+ items: [
+ {
+ layout: 'fit',
+ border: false,
+ height: 285,
+ items: [this.shortCutTree]
+ },
+ {
+ layout: 'fit',
+ border: false,
+ height: 15,
+ items: [this.closeBtn]
+ }
+ ]
+ });
+
+};
+
+Ext.extend(EntSavoie.ShortCuts.ShortCutsPanel, Ext.Panel, {
+ initComponent: function () {
+ EntSavoie.ShortCuts.ShortCutsPanel.superclass.initComponent.call(this);
+ },
+
+ onAddFolder: function(btn){
+ Ext.Msg.prompt(this.i18n.ShortCuts.ShortCutsPanel.onAddFolder.Msg.title, this.i18n.ShortCuts.ShortCutsPanel.onAddFolder.Msg.msg, function(btn, text){
+ if (btn == 'ok'){
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ params: {
+ cmd: "addShortCutFolder",
+ targetFolderId: this.shortCutTree.getSelectionModel().getSelectedNode().id,
+ folderTitle: text
+ },
+ scope: this,
+ success: this.onSuccessAddFolder,
+ failure: this.onFailureAddFolder
+ });
+ } else {
+ userMakeAction = false;
+ }
+ }, this);
+ },
+
+ onSuccessAddFolder: function(response, options) {
+ // Traitement des messages
+ var backObj = Ext.decode(response.responseText);
+ if (!backObj.success) {
+ Ext.MessageBox.alert(this.i18n.ShortCuts.ShortCutsPanel.onAddFolder.alert.title, this.i18n.ShortCuts.ShortCutsPanel.onAddFolder.alert.msg, function(btn){});
+ } else {
+ // Actualisation du tree
+ if(backObj.targetFolderId == 0){
+ backObj.targetFolderId = "rootNode/Favoris";
+ }
+
+ var newNode = new Ext.tree.TreeNode({id: backObj.id, text: backObj.title, leaf: false, iconCls: "shortCutFolder"});
+ this.shortCutTree.getNodeById(backObj.targetFolderId).appendChild(newNode);
+ this.shortCutTree.getNodeById(backObj.targetFolderId).expand();
+ userMakeAction = false;
+ Ext.slideMsg.msg(this.i18n.ShortCuts.ShortCutsPanel.onAddFolder.slideMsg.title, this.i18n.ShortCuts.ShortCutsPanel.onAddFolder.slideMsg.msg[0] + backObj.title + this.i18n.ShortCuts.ShortCutsPanel.onAddFolder.slideMsg.msg[1]);
+ }
+ },
+
+
+ onFailureAddFolder: function (response, options) {
+ Ext.MessageBox.alert(this.i18n.ShortCuts.ShortCutsPanel.onAddFolder.alert.title, this.i18n.ShortCuts.ShortCutsPanel.onAddFolder.alert.msg, function(btn){});
+ },
+
+ showAt: function (xy, reload) {
+ if(reload){
+ if(!this.firstLoad){ //Sinon double affichage des folders et shortCuts
+ this.shortCutTree.loader.load(this.shortCutTree.getRootNode(), function(){}, this);
+ }
+ this.shortCutTree.getRootNode().expand();
+ this.firstLoad = false;
+ }
+ this.setPagePosition(xy[0], xy[1]);
+ },
+
+ onCloseFn: function(btn){
+ this.showAt([ -1000, -1000 ], false);
+ },
+
+ onMouseLeaveFn: function(e, t, o) {
+ if(userMakeAction == false){
+ e.stopEvent();
+ var xy = e.getXY();
+ var xyPanel = this.getPosition();
+ if((xy[0]<xyPanel[0] || xy[0]>(xyPanel[0] + this.getWidth())) || (xy[1]<xyPanel[1] || (xy[1]>xyPanel[1] + this.getHeight()))){
+ this.onCloseFn();
+ }
+ }
+ }
+
+});