From 53e12f2cb295f843e2bdf3e8a792c8b96f9a7dcf Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 11 Apr 2011 11:23:24 +0200 Subject: [PATCH] Added LSformElement :: postaladdress --- public_html/images/black/map_go.png | Bin 0 -> 447 bytes public_html/images/default/map_go.png | Bin 0 -> 842 bytes .../class/class.LSattr_html_postaladdress.php | 36 +++++++++ .../class.LSformElement_postaladdress.php | 63 +++++++++++++++ .../js/LSformElement_postaladdress.js | 75 ++++++++++++++++++ 5 files changed, 174 insertions(+) create mode 100644 public_html/images/black/map_go.png create mode 100644 public_html/images/default/map_go.png create mode 100644 public_html/includes/class/class.LSattr_html_postaladdress.php create mode 100644 public_html/includes/class/class.LSformElement_postaladdress.php create mode 100644 public_html/includes/js/LSformElement_postaladdress.js diff --git a/public_html/images/black/map_go.png b/public_html/images/black/map_go.png new file mode 100644 index 0000000000000000000000000000000000000000..acd1091bac0f09e5baae25a5f67dd37a966fdc4d GIT binary patch literal 447 zcmV;w0YLtVP)Px#0%A)?L;(MXkIcUS000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ipV-2?8jd z{+4CL7|i#==5u1hMl5M1po2@D3z4-i3GI z4On;sc3A|qun+~Yu+bozlrAQ)I=i#8^YdAl1>-rz>E5?E$-S5To0+poPPZ|7WiQsT ziPf3rF^_rt702;m44G)^olkakd{!ChI+mHZBS>NFqTk-ihvGq-GO zv^E4wCK48eT*s={8o5%gH2asZq1AKO&~>Y#t`*CsNTdm7CdPsbh8l%8KFG~kDAug& z>DuvAYEy0Cy)EfNF_z=dN9XOU^<7eU?g2uAp1BhfjT>66=-6d5PyQ03Z@%l8skDA* zv}!X~l)ebel~$}NRT`UGtrP3MI0;GBGqrEGw;Tan07PX6DVCH*elYzhBsU=<(Atb2GcE)hYl8004pj2*~on z?Z0oIsm;vI?0)<8cZ5oi6(axyL8%l#Jcc44urK8oFbZfPvTC3~!6G!%z>b0s0K&P{+vu#W_io~a`h@zXK zC=!O33<^$5v$zuQxtBw2-c%}R$1S$lOBt!iu*6DWiCUXC7B{^|j znI|ggXHNdO-trP-k0nqF8MbQv_-{1JlsVf(hkEGJ?evxLG4bxj~o4;Q#>3iv`_q_Jh zegQQh2$-Cj*Ug50h+}`Gby<;mbo&u`S;&iAp|sptvSZT&qIBTd5BAs*o>qghES+Ea z-K85pYc^YwB#~sPyeurP{%TZYvSMVEk93DUJ2yWl8pX~I-c<{Tv%ZylWPGe?qS2NN zQ%RP{^2{BR3$h}YmxY_1KTS91U0nLc<>f2x?H*7g2%(~7(jdgf^M*B{Db5nd&%Gio zQc0G&dv?2BcRl99;@8eEp7ZL#6Fxrnsalrh@;tY3dZ&#u1Q6`n@+1f$fWyb`6Dkdt zmoIzc@P{@|Ey(gugnfse_ + */ +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 index 00000000..7d1fd4f5 --- /dev/null +++ b/public_html/includes/class/class.LSformElement_postaladdress.php @@ -0,0 +1,63 @@ + + */ + +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 index 00000000..a2c9f3bb --- /dev/null +++ b/public_html/includes/js/LSformElement_postaladdress.js @@ -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(); +});