Added LSformElement :: postaladdress
authorBenjamin Renard <brenard@easter-eggs.com>
Mon, 11 Apr 2011 09:23:24 +0000 (11:23 +0200)
committerBenjamin Renard <brenard@easter-eggs.com>
Mon, 11 Apr 2011 09:23:24 +0000 (11:23 +0200)
public_html/images/black/map_go.png [new file with mode: 0644]
public_html/images/default/map_go.png [new file with mode: 0644]
public_html/includes/class/class.LSattr_html_postaladdress.php [new file with mode: 0644]
public_html/includes/class/class.LSformElement_postaladdress.php [new file with mode: 0644]
public_html/includes/js/LSformElement_postaladdress.js [new file with mode: 0644]

diff --git a/public_html/images/black/map_go.png b/public_html/images/black/map_go.png
new file mode 100644 (file)
index 0000000..acd1091
Binary files /dev/null and b/public_html/images/black/map_go.png differ
diff --git a/public_html/images/default/map_go.png b/public_html/images/default/map_go.png
new file mode 100644 (file)
index 0000000..11eab26
Binary files /dev/null and b/public_html/images/default/map_go.png differ
diff --git a/public_html/includes/class/class.LSattr_html_postaladdress.php b/public_html/includes/class/class.LSattr_html_postaladdress.php
new file mode 100644 (file)
index 0000000..208efe0
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+/*******************************************************************************
+ * Copyright (C) 2007 Easter-eggs
+ * http://ldapsaisie.labs.libre-entreprise.org
+ *
+ * Author: See AUTHORS file in top-level directory.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+******************************************************************************/
+
+LSsession :: loadLSclass('LSattr_html_textarea');
+
+/**
+ * Type d'attribut HTML postaladdress
+ *
+ * @author Benjamin Renard <brenard@easter-eggs.com>
+ */
+class LSattr_html_postaladdress extends LSattr_html_textarea {
+
+  var $LSformElement_type = 'postaladdress';
+  
+}
+
+?>
diff --git a/public_html/includes/class/class.LSformElement_postaladdress.php b/public_html/includes/class/class.LSformElement_postaladdress.php
new file mode 100644 (file)
index 0000000..7d1fd4f
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+/*******************************************************************************
+ * Copyright (C) 2007 Easter-eggs
+ * http://ldapsaisie.labs.libre-entreprise.org
+ *
+ * Author: See AUTHORS file in top-level directory.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+******************************************************************************/
+
+LSsession :: loadLSclass('LSformElement_textarea');
+
+/**
+ * Element postaladdress d'un formulaire pour LdapSaisie
+ *
+ * @author Benjamin Renard <brenard@easter-eggs.com>
+ */
+
+class LSformElement_postaladdress extends LSformElement_textarea {
+
+  var $fieldTemplateExtraClass = 'LSformElement_postaladdress';
+
+ /**
+  * Retourne les infos d'affichage de l'élément
+  * 
+  * Cette méthode retourne les informations d'affichage de l'élement
+  *
+  * @retval array
+  */
+  function getDisplay(){
+    $return = parent :: getDisplay();
+    if ($this -> isFreeze()) {
+      if (isset($this -> params['html_options']['map_url_format']) && !empty($this->values)) {
+        LSsession :: addJSconfigParam('LSformElement_postaladdress_'.$this -> name, array (
+            'map_url' => $this -> attr_html -> attribute -> ldapObject -> getFData($this -> params['html_options']['map_url_format']) 
+          )
+        );
+        LSsession :: addHelpInfos(
+          'LSformElement_postaladdress',
+            array(
+              'viewOnMap' => _('View on map')
+            )
+        );
+        LSsession :: addJSscript('LSformElement_postaladdress.js');
+      }
+    }
+    return $return;
+  }
+}
+
+?>
diff --git a/public_html/includes/js/LSformElement_postaladdress.js b/public_html/includes/js/LSformElement_postaladdress.js
new file mode 100644 (file)
index 0000000..a2c9f3b
--- /dev/null
@@ -0,0 +1,75 @@
+var LSformElement_postaladdress = new Class({
+    initialize: function(){
+      this.initialiseLSformElement_postaladdress();
+      if (typeof(varLSform) != "undefined") {
+        varLSform.addModule("LSformElement_postaladdress",this);
+      }
+    },
+    
+    initialiseLSformElement_postaladdress: function(el) {
+      if (typeof(el) == 'undefined') {
+        el = document;
+      }
+      el.getElements('p.LSformElement_postaladdress').each(function(p) {
+        this.addBtnAfter.bind(this)(p);
+      }, this);
+    },
+   
+    getFieldName: function(el) {
+      try {
+        var name = el.getParent().getParent().id;
+        return name;
+      }
+      catch (err) {
+        LSdebug(err);
+      }
+      return;
+    },
+
+    getFieldParams: function(el) {
+      var name = this.getFieldName(el);
+      if (typeof(varLSdefault.LSjsConfig['LSformElement_postaladdress_'+name]) != "undefined") {
+        var params = varLSdefault.LSjsConfig['LSformElement_postaladdress_'+name];
+        if (typeof(params)!="undefined") {
+          return params;
+        }
+      }
+      return;
+    },
+    addBtnAfter: function(el) {
+      var name = this.getFieldName(el);
+      if (typeof(varLSdefault.LSjsConfig['LSformElement_postaladdress_'+name]) == "undefined") {
+        return;
+      }
+      var btn = new Element('img');
+      btn.setProperties({
+        src:    varLSdefault.imagePath('map_go.png'),
+        alt:    'View on map'
+      });
+      btn.addClass('btn');
+      btn.setStyle('float','left');
+      btn.injectBefore(el);
+      btn.addEvent('click',this.onBtnClick.bind(this,el));
+      varLSdefault.addHelpInfo(btn,'LSformElement_postaladdress','viewOnMap');
+    },
+    
+    reinitialize: function(el) {
+      varLSform.initializeModule('LSformElement_textarea',el);
+      this.initialiseLSformElement_postaladdress(el);
+    },
+    
+    onBtnClick: function(el) {
+      var address = el.get('html');
+      if (typeof(address)!="undefined") {
+        var params = this.getFieldParams(el);
+        if (params && typeof(params.map_url)!="undefined") {
+          href = params.map_url;
+        }
+        window.open(href,'_blank');
+      }
+    }
+});
+window.addEvent(window.ie ? 'load' : 'domready', function() {
+  varLSformElement_postaladdress = new LSformElement_postaladdress();
+});