From df06f6657ce78d291e242d0c333b1be60f7223d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20St=C3=B6ckel?= Date: Thu, 8 Mar 2012 14:05:00 +0000 Subject: [PATCH] Now always including egw and etemplate2 javascript code if we are in the top window --- etemplate/inc/class.etemplate_new.inc.php | 14 ++++---------- etemplate/js/et2_core_inputWidget.js | 2 +- etemplate/js/et2_widget_date.js | 18 ++++-------------- phpgwapi/inc/class.egw_framework.inc.php | 2 +- .../idots/class.idots_framework.inc.php | 18 ++++++++++++++++++ 5 files changed, 28 insertions(+), 26 deletions(-) diff --git a/etemplate/inc/class.etemplate_new.inc.php b/etemplate/inc/class.etemplate_new.inc.php index cff252b827..99ae0d6b08 100644 --- a/etemplate/inc/class.etemplate_new.inc.php +++ b/etemplate/inc/class.etemplate_new.inc.php @@ -101,17 +101,12 @@ class etemplate_new extends etemplate_widget_template */ function exec($method,$content,$sel_options='',$readonlys='',$preserv='',$output_mode=0,$ignore_validation='',$changes='') { + + // Overwrite "nonavbar" is the output_mode is two + $GLOBALS['egw_info']['flags']['nonavbar'] = ($output_mode == 2); + if (!$this->rel_path) throw new egw_exception_assertion_failed('No (valid) template read!'); - // load translations - translation::add_app('etemplate'); - foreach(translation::$loaded_apps as $app => $lang) - { - egw_framework::validate_file('/phpgwapi/lang.php', array( - 'app' => $app, - 'lang' => $lang, - )); - } // generate new etemplate request object self::$request = etemplate_request::read(); self::$request->output_mode = $output_mode; // let extensions "know" they are run eg. in a popup @@ -151,7 +146,6 @@ class etemplate_new extends etemplate_widget_template { // missing dependency, thought egw:uses jquery.jquery.tools does NOT work, maybe we should rename it to jquery-tools egw_framework::validate_file('jquery','jquery.tools.min'); - egw_framework::validate_file('.','etemplate2','etemplate'); egw_framework::includeCSS('/etemplate/js/test/test.css'); common::egw_header(); diff --git a/etemplate/js/et2_core_inputWidget.js b/etemplate/js/et2_core_inputWidget.js index 4de0f0f92f..0d30e603eb 100644 --- a/etemplate/js/et2_core_inputWidget.js +++ b/etemplate/js/et2_core_inputWidget.js @@ -113,7 +113,7 @@ var et2_inputWidget = et2_valueWidget.extend(et2_IInput, { change: function(_node) { if (this.onchange) { - return this.onchange(_node); + return et2_compileLegacyJS(this.onchange, this, _node)(); } }, diff --git a/etemplate/js/et2_widget_date.js b/etemplate/js/et2_widget_date.js index 5f65f593a9..857c0ae120 100644 --- a/etemplate/js/et2_widget_date.js +++ b/etemplate/js/et2_widget_date.js @@ -14,9 +14,6 @@ /*egw:uses jquery.jquery; - jscalendar.calendar-setup; - jscalendar.calendar; - /phpgwapi/js/jscalendar/lang/calendar-en.js; lib/date; et2_core_inputWidget; et2_core_valueWidget; @@ -81,17 +78,10 @@ var et2_date = et2_inputWidget.extend({ if (!dateformat) dateformat = "Y-m-d"; dateformat = dateformat.replace("Y","%Y").replace("d","%d").replace("m","%m").replace("M", "%b"); - var setup = { - inputField: this.options.id, - button: this.button.attr("id"), - showsTime: false, - onUpdate: function(_value) {_this.set_value(_value)}, - daFormat: dateformat, - firstDay: this.egw().preference("weekdaystarts","calendar") - }; - /*window.setTimeout(function() { - Calendar.setup(setup); - }, 500);*/ + this.egw().calendar(this.input_date, this.button, + function(_value) { + this.set_value(_value); + }, this); } // If date also has a time, or browser doesn't support HTML5 time type diff --git a/phpgwapi/inc/class.egw_framework.inc.php b/phpgwapi/inc/class.egw_framework.inc.php index 040a19f2cb..6093ab0e16 100644 --- a/phpgwapi/inc/class.egw_framework.inc.php +++ b/phpgwapi/inc/class.egw_framework.inc.php @@ -94,7 +94,7 @@ abstract class egw_framework '/phpgwapi/js/./egw_json.js', // always include javascript helper functions '/phpgwapi/js/jsapi/jsapi.js', - '/phpgwapi/js/jsapi/egw.js', +// '/phpgwapi/js/jsapi/egw.js', )); } diff --git a/phpgwapi/templates/idots/class.idots_framework.inc.php b/phpgwapi/templates/idots/class.idots_framework.inc.php index 032ea415f4..23e8941adf 100644 --- a/phpgwapi/templates/idots/class.idots_framework.inc.php +++ b/phpgwapi/templates/idots/class.idots_framework.inc.php @@ -64,6 +64,8 @@ class idots_framework extends egw_framework { parent::__construct($template); // call the constructor of the extended class + $GLOBALS['egw_info']['flags']['js_link_registry'] = true; + $this->tplsav2 = new tplsavant2(); $this->tplsav2->set_tpl_path(EGW_SERVER_ROOT.SEP.'phpgwapi'.SEP.'templates'.SEP.'idots'); } @@ -87,6 +89,22 @@ class idots_framework extends egw_framework if (self::$header_done) return ''; self::$header_done = true; + // load translations + translation::add_app('etemplate'); + foreach(translation::$loaded_apps as $app => $lang) + { + egw_framework::validate_file('/phpgwapi/lang.php', array( + 'app' => $app, + 'lang' => $lang, + )); + } + + if ($this->isTop(false)) + { + self::validate_file('jsapi', 'egw', 'phpgwapi'); + self::validate_file('.', 'etemplate2', 'etemplate'); + } + // add a content-type header to overwrite an existing default charset in apache (AddDefaultCharset directiv) header('Content-type: text/html; charset='.translation::charset());