diff --git a/etemplate/inc/class.etemplate_new.inc.php b/etemplate/inc/class.etemplate_new.inc.php index 99ae0d6b08..31c17a525b 100644 --- a/etemplate/inc/class.etemplate_new.inc.php +++ b/etemplate/inc/class.etemplate_new.inc.php @@ -145,7 +145,7 @@ class etemplate_new extends etemplate_widget_template else // first call { // 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('jquery','jquery.tools.min'); egw_framework::includeCSS('/etemplate/js/test/test.css'); common::egw_header(); @@ -156,8 +156,10 @@ class etemplate_new extends etemplate_widget_template echo '
'; common::egw_footer(); diff --git a/etemplate/js/et2_core_legacyJSFunctions.js b/etemplate/js/et2_core_legacyJSFunctions.js index ce06e0ba9c..a28d25b968 100644 --- a/etemplate/js/et2_core_legacyJSFunctions.js +++ b/etemplate/js/et2_core_legacyJSFunctions.js @@ -1,5 +1,5 @@ /** - * eGroupWare eTemplate2 - A simple PHP expression parser written in JS + * eGroupWare eTemplate2 - Execution layer for legacy event code * * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @package etemplate @@ -114,8 +114,14 @@ context = _widget.getDOMNode(); } - // Generate the function itself - var func = new Function('egw', 'widget', 'window', _code); + // Generate the function itself, if it fails, log the error message and + // return a function which always returns false + try { + var func = new Function('egw', 'widget', 'window', 'document', _code); + } catch(e) { + _widget.egw().debug('error', 'Error while compiling JS code ', _code); + return (function() {return false}); + } // Execute the code and return its results, pass the egw instance and // the widget @@ -127,7 +133,8 @@ egw.debug('log', 'Executing legacy JS code: ', _code); // Return the result of the called function - return func.call(context, egw, _widget, egw.window); + return func.call(context, egw, _widget, egw.window, + egw.window.document); } } diff --git a/etemplate/js/et2_widget_date.js b/etemplate/js/et2_widget_date.js index f4fd84552c..cab491fdf1 100644 --- a/etemplate/js/et2_widget_date.js +++ b/etemplate/js/et2_widget_date.js @@ -65,7 +65,7 @@ var et2_date = et2_inputWidget.extend({ if(input_time.attr("type") == "time") { this.input_time = input_time; - this.input_time.appendTo(node).attr("size", 5); + this.input_time.appendTo(this.span).attr("size", 5); // Update internal value if control changes this.input_time.change(this,function(e){e.data.set_value($j(e.target).val());}); } @@ -78,88 +78,7 @@ var et2_date = et2_inputWidget.extend({ this.setDOMNode(this.span[0]); // jQuery-UI date picker - this.setupPopup(this.input_date, this._type == "date-time"); - }, - - /** - * Setup the date-picker popup - */ - setupPopup: function(node, include_time) { - - if(typeof include_time === "undefined") include_time = false; - - if(this.type == "date" || this.type == "date-time") { - // Date format in jQuery UI date format - var dateformat = egw().preference("dateformat").replace("Y","yy").replace("d","dd").replace("m","mm").replace("M", "M"); - - // First day of the week - var first_day = {"Monday": 1, "Sunday": 0, "Saturday": 6}; - var first_day_pref = this.egw().preference("weekdaystarts","calendar"); - - var self = this; - - // Initialize - node.datepicker({ - dateFormat: dateformat, - autoSize: true, - firstDay: first_day_pref ? first_day[first_day_pref] : 0, - showButtonPanel: true, // Today, Done buttons - nextText: this.egw().lang("Next"), - currentText: this.egw().lang("today"), - prevText: this.egw().lang("Prev"), - closeText: this.egw().lang("Done"), - - showOtherMonths: true, - selectOtherMonths: true, - - showWeek: true, // Week numbers - changeMonth: true, // Month selectbox - changeYear: true, // Year selectbox - - onClose: function(date_text, picker) { - // Only update if there's a change - "" if no date selected - if(date_text != "") self.set_value(new Date( - picker.selectedYear, - picker.selectedMonth, - picker.selectedDay, - self.input_hours ? self.input_hours.val() : 0, - self.input_minutes ? self.input_minutes.val() : 0, - 0,0 - )); - }, - // Trigger button - showOn: "both", - buttonImage: this.egw().image('datepopup','phpgwapi'), - buttonImageOnly: true - }); - - // Translate (after initialize has its way) - var translate_fields = { - "dayNames": false, - "dayNamesShort":3, - "dayNamesMin": 2, - "monthNames": false, - "monthNamesShort": 3 - } - var full = []; - for(var i in translate_fields) - { - var trans = this.input_date.datepicker("option",i); - // Keep the full one for missing short ones - for(var key in trans) { - if(translate_fields[i] === false) - { - trans[key] = this.egw().lang(trans[key]); - } - else - { - trans[key] = full[key].substr(0,translate_fields[i]); - } - } - if(translate_fields[i] === false) full = trans; - node.datepicker("option",i,trans); - } - } + this.egw().calendar(this.input_date, this._type == "date-time"); }, _make_time_selects: function (node) { diff --git a/phpgwapi/inc/class.egw_framework.inc.php b/phpgwapi/inc/class.egw_framework.inc.php index 6093ab0e16..dc5d003433 100644 --- a/phpgwapi/inc/class.egw_framework.inc.php +++ b/phpgwapi/inc/class.egw_framework.inc.php @@ -781,13 +781,39 @@ abstract class egw_framework self::validate_file('/phpgwapi/config.php'); self::validate_file('/phpgwapi/images.php',array('template' => $GLOBALS['egw_info']['user']['preferences']['common']['template_set'])); } - $java_script .= self::get_script_links(); // set webserver_url for json - $java_script .= ""; + + $java_script .= self::get_script_links(); + + $java_script .= '