[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_3_2-1653-g1cafc3a

Michal Čihař nijel at users.sourceforge.net
Tue Apr 20 10:10:35 CEST 2010


The branch, master has been updated
       via  1cafc3a509eca28246982ae29a0ba764bd73def6 (commit)
       via  378094ac307835b22aafd45c5af1ea1dc763dfd4 (commit)
      from  81ffe74473b3a50fe9ee7d13144917ca09bcf028 (commit)


- Log -----------------------------------------------------------------
commit 1cafc3a509eca28246982ae29a0ba764bd73def6
Author: Michal Čihař <michal at cihar.com>
Date:   Tue Apr 20 10:10:15 2010 +0200

    Remove old calendar code.

commit 378094ac307835b22aafd45c5af1ea1dc763dfd4
Author: Muhammad Adnan <hiddenpearls at gmail.com>
Date:   Tue Apr 20 10:08:41 2010 +0200

    [interface] Use jQuery calendar dialog.
    
    rfe #2983207, patch #2988715

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog               |    2 +
 calendar.php            |   32 ----
 js/jquery/timepicker.js |  416 +++++++++++++++++++++++++++++++++++++++++++++++
 js/tbl_change.js        |  279 -------------------------------
 tbl_change.php          |   29 ++--
 tbl_select.php          |   22 ++-
 6 files changed, 452 insertions(+), 328 deletions(-)
 delete mode 100644 calendar.php
 create mode 100644 js/jquery/timepicker.js

diff --git a/ChangeLog b/ChangeLog
index 69d3472..35d8773 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -77,6 +77,8 @@ $Id$
   synchronisation.
 + rfe #2988633 [relation] Improve ON DELETE/ON UPDATE drop-downs
 + rfe #2988629 [relation] Improve labels in relation view 
++ rfe #2983207, patch #2988715 [interface] Use jQuery calendar dialog, thanks
+  to Muhammad Adnan.
 
 3.3.3.0 (not yet released)
 - patch #2982480 [navi] Do not group if there would be one table in group,
diff --git a/calendar.php b/calendar.php
deleted file mode 100644
index 58cdf42..0000000
--- a/calendar.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-/* vim: set expandtab sw=4 ts=4 sts=4: */
-/**
- *
- * @version $Id$
- * @package phpMyAdmin
- */
-
-/**
- *
- */
-require_once './libraries/common.inc.php';
-require_once './libraries/header_http.inc.php';
-$page_title = $strCalendar;
-require './libraries/header_meta_style.inc.php';
-$GLOBALS['js_include'][] = 'common.js';
-$GLOBALS['js_include'][] = 'tbl_change.js';
-require './libraries/header_scripts.inc.php';
-?>
-<script type="text/javascript">
-//<![CDATA[
-var month_names = new Array("<?php echo implode('","', $month); ?>");
-var day_names = new Array("<?php echo implode('","', $day_of_week); ?>");
-var submit_text = "<?php echo $strGo . ' (' . $strTime . ')'; ?>";
-//]]>
-</script>
-</head>
-<body onload="initCalendar();">
-<div id="calendar_data"></div>
-<div id="clock_data"></div>
-</body>
-</html>
diff --git a/js/jquery/timepicker.js b/js/jquery/timepicker.js
new file mode 100644
index 0000000..84879c4
--- /dev/null
+++ b/js/jquery/timepicker.js
@@ -0,0 +1,416 @@
+/*!
+ * jQuery UI Timepicker 0.2.1
+ *
+ * Copyright (c) 2009 Martin Milesich (http://milesich.com/)
+ *
+ * Some parts are
+ *   Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
+ *
+ * $Id: timepicker.js 28 2009-08-11 20:31:23Z majlo $
+ *
+ * Depends:
+ *  ui.core.js
+ *  ui.datepicker.js
+ *  ui.slider.js
+ */
+(function($) {
+
+/**
+ * Extending default values
+ */
+$.extend($.datepicker._defaults, {
+		 'dateFormat': 'yy-mm-dd',
+		 'changeMonth': true,
+		'changeYear': true,
+    'stepMinutes': 1, // Number of minutes to step up/down
+    'stepHours': 1, // Number of hours to step up/down
+    'time24h': false, // True if 24h time
+    'showTime': false, // Show timepicker with datepicker
+    'altTimeField': '' // Selector for an alternate field to store time into
+});
+
+/**
+ * _hideDatepicker must be called with null
+ */
+$.datepicker._connectDatepickerOverride = $.datepicker._connectDatepicker;
+$.datepicker._connectDatepicker = function(target, inst) {
+    $.datepicker._connectDatepickerOverride(target, inst);
+
+    // showButtonPanel is required with timepicker
+    if (this._get(inst, 'showTime')) {
+        inst.settings['showButtonPanel'] = true;
+    }
+
+    var showOn = this._get(inst, 'showOn');
+
+    if (showOn == 'button' || showOn == 'both') {
+        // Unbind all click events
+        inst.trigger.unbind('click');
+
+        // Bind new click event
+        inst.trigger.click(function() {
+            if ($.datepicker._datepickerShowing && $.datepicker._lastInput == target)
+                $.datepicker._hideDatepicker(null); // This override is all about the "null"
+            else
+                $.datepicker._showDatepicker(target);
+            return false;
+        });
+    }
+};
+
+/**
+ * Datepicker does not have an onShow event so I need to create it.
+ * What I actually doing here is copying original _showDatepicker
+ * method to _showDatepickerOverload method.
+ */
+$.datepicker._showDatepickerOverride = $.datepicker._showDatepicker;
+$.datepicker._showDatepicker = function (input) {
+    // Call the original method which will show the datepicker
+    $.datepicker._showDatepickerOverride(input);
+
+    input = input.target || input;
+
+    // find from button/image trigger
+    if (input.nodeName.toLowerCase() != 'input') input = $('input', input.parentNode)[0];
+
+    // Do not show timepicker if datepicker is disabled
+    if ($.datepicker._isDisabledDatepicker(input)) return;
+
+    // Get instance to datepicker
+    var inst = $.datepicker._getInst(input);
+
+    var showTime = $.datepicker._get(inst, 'showTime');
+
+    // If showTime = True show the timepicker
+    if (showTime) $.timepicker.show(input);
+};
+
+/**
+ * Same as above. Here I need to extend the _checkExternalClick method
+ * because I don't want to close the datepicker when the sliders get focus.
+ */
+$.datepicker._checkExternalClickOverride = $.datepicker._checkExternalClick;
+$.datepicker._checkExternalClick = function (event) {
+    if (!$.datepicker._curInst) return;
+    var $target = $(event.target);
+
+    if (($target.parents('#' + $.timepicker._mainDivId).length == 0)) {
+        $.datepicker._checkExternalClickOverride(event);
+    }
+};
+
+/**
+ * Datepicker has onHide event but I just want to make it simple for you
+ * so I hide the timepicker when datepicker hides.
+ */
+$.datepicker._hideDatepickerOverride = $.datepicker._hideDatepicker;
+$.datepicker._hideDatepicker = function(input, duration) {
+    // Some lines from the original method
+    var inst = this._curInst;
+
+    if (!inst || (input && inst != $.data(input, PROP_NAME))) return;
+
+    // Get the value of showTime property
+    var showTime = this._get(inst, 'showTime');
+
+    if (input === undefined && showTime) {
+        if (inst.input) {
+            inst.input.val(this._formatDate(inst));
+            inst.input.trigger('change'); // fire the change event
+        }
+
+        this._updateAlternate(inst);
+
+        if (showTime) $.timepicker.update(this._formatDate(inst));
+    }
+
+    // Hide datepicker
+    $.datepicker._hideDatepickerOverride(input, duration);
+
+    // Hide the timepicker if enabled
+    if (showTime) {
+        $.timepicker.hide();
+    }
+};
+
+/**
+ * This is a complete replacement of the _selectDate method.
+ * If showed with timepicker do not close when date is selected.
+ */
+$.datepicker._selectDate = function(id, dateStr) {
+    var target = $(id);
+    var inst = this._getInst(target[0]);
+    var showTime = this._get(inst, 'showTime');
+    dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
+    if (!showTime) {
+        if (inst.input)
+            inst.input.val(dateStr);
+        this._updateAlternate(inst);
+    }
+    var onSelect = this._get(inst, 'onSelect');
+    if (onSelect)
+        onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);  // trigger custom callback
+    else if (inst.input && !showTime)
+        inst.input.trigger('change'); // fire the change event
+    if (inst.inline)
+        this._updateDatepicker(inst);
+    else if (!inst.stayOpen) {
+        if (showTime) {
+            this._updateDatepicker(inst);
+        } else {
+            this._hideDatepicker(null, this._get(inst, 'duration'));
+            this._lastInput = inst.input[0];
+            if (typeof(inst.input[0]) != 'object')
+                inst.input[0].focus(); // restore focus
+            this._lastInput = null;
+        }
+    }
+};
+
+/**
+ * We need to resize the timepicker when the datepicker has been changed.
+ */
+$.datepicker._updateDatepickerOverride = $.datepicker._updateDatepicker;
+$.datepicker._updateDatepicker = function(inst) {
+    $.datepicker._updateDatepickerOverride(inst);
+    $.timepicker.resize();
+};
+
+function Timepicker() {}
+
+Timepicker.prototype = {
+    init: function()
+    {
+        this._mainDivId = 'ui-timepicker-div';
+        this._inputId   = null;
+        this._orgValue  = null;
+        this._orgHour   = null;
+        this._orgMinute = null;
+        this._colonPos  = -1;
+        this._visible   = false;
+        this.tpDiv      = $('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ui-helper-hidden-accessible" style="width: 100px; display: none; position: absolute;"></div>');
+        this._generateHtml();
+    },
+
+    show: function (input)
+    {
+        // Get instance to datepicker
+        var inst = $.datepicker._getInst(input);
+
+        this._time24h = $.datepicker._get(inst, 'time24h');
+        this._altTimeField = $.datepicker._get(inst, 'altTimeField');
+
+        var stepMinutes = parseInt($.datepicker._get(inst, 'stepMinutes'), 10) || 1;
+        var stepHours   = parseInt($.datepicker._get(inst, 'stepHours'), 10)   || 1;
+
+        if (60 % stepMinutes != 0) { stepMinutes = 1; }
+        if (24 % stepHours != 0)   { stepHours   = 1; }
+
+        $('#hourSlider').slider('option', 'max', 24 - stepHours);
+        $('#hourSlider').slider('option', 'step', stepHours);
+
+        $('#minuteSlider').slider('option', 'max', 60 - stepMinutes);
+        $('#minuteSlider').slider('option', 'step', stepMinutes);
+
+        this._inputId = input.id;
+
+        if (!this._visible) {
+            this._parseTime();
+            this._orgValue = $('#' + this._inputId).val();
+        }
+
+        this.resize();
+
+        $('#' + this._mainDivId).show();
+
+        this._visible = true;
+
+        var dpDiv     = $('#' + $.datepicker._mainDivId);
+        var dpDivPos  = dpDiv.position();
+
+        var viewWidth = (window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth) + $(document).scrollLeft();
+        var tpRight   = this.tpDiv.offset().left + this.tpDiv.outerWidth();
+
+        if (tpRight > viewWidth) {
+            dpDiv.css('left', dpDivPos.left - (tpRight - viewWidth) - 5);
+            this.tpDiv.css('left', dpDiv.offset().left + dpDiv.outerWidth() + 'px');
+        }
+    },
+
+    update: function (fd)
+    {
+        var curTime = $('#' + this._mainDivId + ' span.fragHours').text()
+                    + ':'
+                    + $('#' + this._mainDivId + ' span.fragMinutes').text();
+
+        if (!this._time24h) {
+            curTime += ' ' + $('#' + this._mainDivId + ' span.fragAmpm').text();
+        }
+
+        var curDate = $('#' + this._inputId).val();
+
+        $('#' + this._inputId).val(fd + ' ' + curTime);
+
+        if (this._altTimeField) {
+            $(this._altTimeField).each(function() { $(this).val(curTime); });
+        }
+    },
+
+    hide: function ()
+    {
+        this._visible = false;
+        $('#' + this._mainDivId).hide();
+    },
+
+    resize: function ()
+    {
+        var dpDiv = $('#' + $.datepicker._mainDivId);
+        var dpDivPos = dpDiv.position();
+
+        var hdrHeight = $('#' + $.datepicker._mainDivId +  ' > div.ui-datepicker-header:first-child').height();
+
+        $('#' + this._mainDivId + ' > div.ui-datepicker-header:first-child').css('height', hdrHeight);
+
+        this.tpDiv.css({
+            'height': dpDiv.height(),
+            'top'   : dpDivPos.top,
+            'left'  : dpDivPos.left + dpDiv.outerWidth() + 'px'
+        });
+
+        $('#hourSlider').css('height',   this.tpDiv.height() - (3.5 * hdrHeight));
+        $('#minuteSlider').css('height', this.tpDiv.height() - (3.5 * hdrHeight));
+    },
+
+    _generateHtml: function ()
+    {
+        var html = '';
+
+        html += '<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix ui-corner-all">';
+        html += '<div class="ui-datepicker-title" style="margin:0">';
+        html += '<span class="fragHours">08</span><span class="delim">:</span><span class="fragMinutes">45</span> <span class="fragAmpm"></span></div></div><table>';
+        html += '<tr><th>Hour</th><th>Minute</th></tr>';
+        html += '<tr><td align="center"><div id="hourSlider" class="slider"></div></td><td align="center"><div id="minuteSlider" class="slider"></div></td></tr>';
+        html += '</table>';
+
+        this.tpDiv.empty().append(html);
+        $('body').append(this.tpDiv);
+
+        var self = this;
+
+        $('#hourSlider').slider({
+            orientation: "vertical",
+            range: 'min',
+            min: 0,
+            max: 23,
+            step: 1,
+            slide: function(event, ui) {
+                self._writeTime('hour', ui.value);
+            },
+            stop: function(event, ui) {
+                $('#' + self._inputId).focus();
+            }
+        });
+
+        $('#minuteSlider').slider({
+            orientation: "vertical",
+            range: 'min',
+            min: 0,
+            max: 59,
+            step: 1,
+            slide: function(event, ui) {
+                self._writeTime('minute', ui.value);
+            },
+            stop: function(event, ui) {
+                $('#' + self._inputId).focus();
+            }
+        });
+
+        $('#hourSlider > a').css('padding', 0);
+        $('#minuteSlider > a').css('padding', 0);
+    },
+
+    _writeTime: function (type, value)
+    {
+        if (type == 'hour') {
+            if (!this._time24h) {
+                if (value < 12) {
+                    $('#' + this._mainDivId + ' span.fragAmpm').text('am');
+                } else {
+                    $('#' + this._mainDivId + ' span.fragAmpm').text('pm');
+                    value -= 12;
+                }
+
+                if (value == 0) value = 12;
+            } else {
+                $('#' + this._mainDivId + ' span.fragAmpm').text('');
+            }
+
+            if (value < 10) value = '0' + value;
+            $('#' + this._mainDivId + ' span.fragHours').text(value);
+        }
+
+        if (type == 'minute') {
+            if (value < 10) value = '0' + value;
+            $('#' + this._mainDivId + ' span.fragMinutes').text(value);
+        }
+    },
+
+    _parseTime: function ()
+    {
+        var dt = $('#' + this._inputId).val();
+
+        this._colonPos = dt.search(':');
+
+        var m = 0, h = 0, a = '';
+
+        if (this._colonPos != -1) {
+            h = parseInt(dt.substr(this._colonPos - 2, 2), 10);
+            m = parseInt(dt.substr(this._colonPos + 1, 2), 10);
+            a = jQuery.trim(dt.substr(this._colonPos + 3, 3));
+        }
+
+        a = a.toLowerCase();
+
+        if (a != 'am' && a != 'pm') {
+            a = '';
+        }
+
+        if (h < 0) h = 0;
+        if (m < 0) m = 0;
+
+        if (h > 23) h = 23;
+        if (m > 59) m = 59;
+
+        if (a == 'pm' && h  < 12) h += 12;
+        if (a == 'am' && h == 12) h  = 0;
+
+        this._setTime('hour',   h);
+        this._setTime('minute', m);
+
+        this._orgHour   = h;
+        this._orgMinute = m;
+    },
+
+    _setTime: function (type, value)
+    {
+        if (isNaN(value)) value = 0;
+        if (value < 0)    value = 0;
+        if (value > 23 && type == 'hour')   value = 23;
+        if (value > 59 && type == 'minute') value = 59;
+
+        if (type == 'hour') {
+            $('#hourSlider').slider('value', value);
+        }
+
+        if (type == 'minute') {
+            $('#minuteSlider').slider('value', value);
+        }
+
+        this._writeTime(type, value);
+    }
+};
+
+$.timepicker = new Timepicker();
+$('document').ready(function () {$.timepicker.init();});
+
+})(jQuery);
diff --git a/js/tbl_change.js b/js/tbl_change.js
index 9539591..a5ee5c1 100644
--- a/js/tbl_change.js
+++ b/js/tbl_change.js
@@ -247,282 +247,3 @@ function unNullify(urlField, multi_edit)
 
     return true;
 } // end of the 'unNullify()' function
-
-var day;
-var month;
-var year;
-var hour;
-var minute;
-var second;
-var clock_set = 0;
-
-/**
- * Opens calendar window.
- *
- * @param   string      calendar.php parameters
- * @param   string      form name
- * @param   string      id of field name
- * @param   string      edit type - date/timestamp
- * @param   string      id of the corresponding checkbox for NULL 
- */
-function openCalendar(params, form, field, type, fieldNull) {
-    window.open("./calendar.php?" + params, "calendar", "width=400,height=200,status=yes");
-    dateField = eval("document." + form + "." + field);
-    dateType = type;
-    if (fieldNull != '') {
-        dateFieldNull = eval("document." + form + "." + fieldNull);
-    }
-}
-
-/**
- * Formats number to two digits.
- *
- * @param   int number to format.
- * @param   string type of number
- */
-function formatNum2(i, valtype) {
-    f = (i < 10 ? '0' : '') + i;
-    if (valtype && valtype != '') {
-        switch(valtype) {
-            case 'month':
-                f = (f > 12 ? 12 : f);
-                break;
-
-            case 'day':
-                f = (f > 31 ? 31 : f);
-                break;
-
-            case 'hour':
-                f = (f > 24 ? 24 : f);
-                break;
-
-            default:
-            case 'second':
-            case 'minute':
-                f = (f > 59 ? 59 : f);
-                break;
-        }
-    }
-
-    return f;
-}
-
-/**
- * Formats number to two digits.
- *
- * @param   int number to format.
- * @param   int default value
- * @param   string type of number
- */
-function formatNum2d(i, default_v, valtype) {
-    i = parseInt(i, 10);
-    if (isNaN(i)) return default_v;
-    return formatNum2(i, valtype)
-}
-
-/**
- * Formats number to four digits.
- *
- * @param   int number to format.
- */
-function formatNum4(i) {
-    i = parseInt(i, 10)
-    return (i < 1000 ? i < 100 ? i < 10 ? '000' : '00' : '0' : '') + i;
-}
-
-/**
- * Initializes calendar window.
- */
-function initCalendar() {
-    if (!year && !month && !day) {
-        /* Called for first time */
-        if (window.opener.dateField.value) {
-            value = window.opener.dateField.value;
-            if (window.opener.dateType == 'datetime' || window.opener.dateType == 'date') {
-                if (window.opener.dateType == 'datetime') {
-                    parts   = value.split(' ');
-                    value   = parts[0];
-
-                    if (parts[1]) {
-                        time    = parts[1].split(':');
-                        hour    = parseInt(time[0],10);
-                        minute  = parseInt(time[1],10);
-                        second  = parseInt(time[2],10);
-                    }
-                }
-                date        = value.split("-");
-                day         = parseInt(date[2],10);
-                month       = parseInt(date[1],10) - 1;
-                year        = parseInt(date[0],10);
-            } else {
-                year        = parseInt(value.substr(0,4),10);
-                month       = parseInt(value.substr(4,2),10) - 1;
-                day         = parseInt(value.substr(6,2),10);
-                hour        = parseInt(value.substr(8,2),10);
-                minute      = parseInt(value.substr(10,2),10);
-                second      = parseInt(value.substr(12,2),10);
-            }
-        }
-        if (isNaN(year) || isNaN(month) || isNaN(day) || day == 0) {
-            dt      = new Date();
-            year    = dt.getFullYear();
-            month   = dt.getMonth();
-            day     = dt.getDate();
-        }
-        if (isNaN(hour) || isNaN(minute) || isNaN(second)) {
-            dt      = new Date();
-            hour    = dt.getHours();
-            minute  = dt.getMinutes();
-            second  = dt.getSeconds();
-        }
-    } else {
-        /* Moving in calendar */
-        if (month > 11) {
-            month = 0;
-            year++;
-        }
-        if (month < 0) {
-            month = 11;
-            year--;
-        }
-    }
-
-    if (document.getElementById) {
-        cnt = document.getElementById("calendar_data");
-    } else if (document.all) {
-        cnt = document.all["calendar_data"];
-    }
-
-    cnt.innerHTML = "";
-
-    str = ""
-
-    //heading table
-    str += '<table class="calendar"><tr><th width="50%">';
-    str += '<form method="NONE" onsubmit="return 0">';
-    str += '<a href="javascript:month--; initCalendar();">«</a> ';
-    str += '<select id="select_month" name="monthsel" onchange="month = parseInt(document.getElementById(\'select_month\').value); initCalendar();">';
-    for (i =0; i < 12; i++) {
-        if (i == month) selected = ' selected="selected"';
-        else selected = '';
-        str += '<option value="' + i + '" ' + selected + '>' + month_names[i] + '</option>';
-    }
-    str += '</select>';
-    str += ' <a href="javascript:month++; initCalendar();">»</a>';
-    str += '</form>';
-    str += '</th><th width="50%">';
-    str += '<form method="NONE" onsubmit="return 0">';
-    str += '<a href="javascript:year--; initCalendar();">«</a> ';
-    str += '<select id="select_year" name="yearsel" onchange="year = parseInt(document.getElementById(\'select_year\').value); initCalendar();">';
-    for (i = year - 25; i < year + 25; i++) {
-        if (i == year) selected = ' selected="selected"';
-        else selected = '';
-        str += '<option value="' + i + '" ' + selected + '>' + i + '</option>';
-    }
-    str += '</select>';
-    str += ' <a href="javascript:year++; initCalendar();">»</a>';
-    str += '</form>';
-    str += '</th></tr></table>';
-
-    str += '<table class="calendar"><tr>';
-    for (i = 0; i < 7; i++) {
-        str += "<th>" + day_names[i] + "</th>";
-    }
-    str += "</tr>";
-
-    var firstDay = new Date(year, month, 1).getDay();
-    var lastDay = new Date(year, month + 1, 0).getDate();
-
-    str += "<tr>";
-
-    dayInWeek = 0;
-    for (i = 0; i < firstDay; i++) {
-        str += "<td> </td>";
-        dayInWeek++;
-    }
-    for (i = 1; i <= lastDay; i++) {
-        if (dayInWeek == 7) {
-            str += "</tr><tr>";
-            dayInWeek = 0;
-        }
-
-        dispmonth = 1 + month;
-
-        if (window.opener.dateType == 'datetime' || window.opener.dateType == 'date') {
-            actVal = "" + formatNum4(year) + "-" + formatNum2(dispmonth, 'month') + "-" + formatNum2(i, 'day');
-        } else {
-            actVal = "" + formatNum4(year) + formatNum2(dispmonth, 'month') + formatNum2(i, 'day');
-        }
-        if (i == day) {
-            style = ' class="selected"';
-            current_date = actVal;
-        } else {
-            style = '';
-        }
-        str += "<td" + style + "><a href=\"javascript:returnDate('" + actVal + "');\">" + i + "</a></td>"
-        dayInWeek++;
-    }
-    for (i = dayInWeek; i < 7; i++) {
-        str += "<td> </td>";
-    }
-
-    str += "</tr></table>";
-
-    cnt.innerHTML = str;
-
-    // Should we handle time also?
-    if (window.opener.dateType != 'date' && !clock_set) {
-
-        if (document.getElementById) {
-            cnt = document.getElementById("clock_data");
-        } else if (document.all) {
-            cnt = document.all["clock_data"];
-        }
-
-        str = '';
-        init_hour = hour;
-        init_minute = minute;
-        init_second = second;
-        str += '<fieldset>';
-        str += '<form method="NONE" class="clock" onsubmit="returnDate(\'' + current_date + '\')">';
-        str += '<input id="hour"    type="text" size="2" maxlength="2" onblur="this.value=formatNum2d(this.value, init_hour, \'hour\'); init_hour = this.value;" value="' + formatNum2(hour, 'hour') + '" />:';
-        str += '<input id="minute"  type="text" size="2" maxlength="2" onblur="this.value=formatNum2d(this.value, init_minute, \'minute\'); init_minute = this.value;" value="' + formatNum2(minute, 'minute') + '" />:';
-        str += '<input id="second"  type="text" size="2" maxlength="2" onblur="this.value=formatNum2d(this.value, init_second, \'second\'); init_second = this.value;" value="' + formatNum2(second, 'second') + '" />';
-        str += '  ';
-        str += '<input type="submit" value="' + submit_text + '"/>';
-        str += '</form>';
-        str += '</fieldset>';
-
-        cnt.innerHTML = str;
-        clock_set = 1;
-    }
-
-}
-
-/**
- * Returns date from calendar.
- *
- * @param   string     date text
- */
-function returnDate(d) {
-    txt = d;
-    if (window.opener.dateType != 'date') {
-        // need to get time
-        h = parseInt(document.getElementById('hour').value,10);
-        m = parseInt(document.getElementById('minute').value,10);
-        s = parseInt(document.getElementById('second').value,10);
-        if (window.opener.dateType == 'datetime') {
-            txt += ' ' + formatNum2(h, 'hour') + ':' + formatNum2(m, 'minute') + ':' + formatNum2(s, 'second');
-        } else {
-            // timestamp
-            txt += formatNum2(h, 'hour') + formatNum2(m, 'minute') + formatNum2(s, 'second');
-        }
-    }
-
-    window.opener.dateField.value = txt;
-     window.opener.dateField.className='';
-    if (typeof(window.opener.dateFieldNull) != 'undefined') {
-        window.opener.dateFieldNull.checked = false;
-    }
-    window.close();
-}
diff --git a/tbl_change.php b/tbl_change.php
index 84e5f69..31110c1 100644
--- a/tbl_change.php
+++ b/tbl_change.php
@@ -114,7 +114,8 @@ if ($GLOBALS['cfg']['ShowPropertyComments']) {
  * used in ./libraries/header.inc.php to load JavaScript library file
  */
 $GLOBALS['js_include'][] = 'tbl_change.js';
-
+$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
+$GLOBALS['js_include'][] = 'jquery/timepicker.js';
 /**
  * HTTP and HTML headers
  */
@@ -1056,7 +1057,7 @@ foreach ($rows as $row_id => $vrow) {
                 <input type="text" name="fields<?php echo $field_name_appendix; ?>"
                     value="<?php echo $special_chars; ?>" size="<?php echo $fieldsize; ?>"
                     class="textfield" <?php echo $unnullify_trigger; ?>
-                    tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
+                    tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"                   
                     id="field_<?php echo ($idindex); ?>_3" />
                 <?php
                 if ($field['Extra'] == 'auto_increment') {
@@ -1083,15 +1084,21 @@ foreach ($rows as $row_id => $vrow) {
                     // the _3 suffix points to the date field
                     // the _2 suffix points to the corresponding NULL checkbox
                     ?>
-                    <script type="text/javascript">
-                    //<![CDATA[
-                    document.write('<a title="<?php echo $strCalendar;?>"');
-                    document.write(' href="javascript:openCalendar(\'<?php echo PMA_generate_common_url();?>\', \'insertForm\', \'field_<?php echo ($idindex); ?>_3\', \'<?php echo (substr($field['pma_type'], 0, 9) == 'timestamp') ? 'datetime' : substr($field['pma_type'], 0, 9); ?>\', \'field_<?php echo ($idindex); ?>_2\')">');
-                    document.write('<img class="calendar"');
-                    document.write(' src="<?php echo $pmaThemeImage; ?>b_calendar.png"');
-                    document.write(' alt="<?php echo $strCalendar; ?>"/></a>');
-                    //]]>
-                    </script>
+<script type="text/javascript">
+//<![CDATA[
+$(function() {
+    $('#field_<?php echo ($idindex); ?>_3').datepicker({
+    	duration: '',
+		time24h: true,
+		 stepMinutes: 1,
+        stepHours: 1,
+        <?php echo ($field['pma_type'] == 'date' ? "showTime: false,":"showTime: true,"); ?>
+		altTimeField: '',
+        constrainInput: false
+     });
+});
+//]]>
+</script>
                     <?php
                 }
             }
diff --git a/tbl_select.php b/tbl_select.php
index 879c0e6..440bd3e 100644
--- a/tbl_select.php
+++ b/tbl_select.php
@@ -20,7 +20,7 @@ require_once './libraries/mysql_charsets.lib.php';
 
 $GLOBALS['js_include'][] = 'tbl_change.js';
 $GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
-
+$GLOBALS['js_include'][] = 'jquery/timepicker.js';
 if ($GLOBALS['cfg']['PropertiesIconic'] == true) {
     $titles['Browse'] =
         '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
@@ -231,11 +231,21 @@ while (list($operator) = each($GLOBALS['cfg']['UnaryOperators'])) {
         $type = $fields_type[$i];
         if ($type == 'date' || $type == 'datetime' || substr($type, 0, 9) == 'timestamp') {
         ?>
-                    <script type="text/javascript">
-                    //<![CDATA[
-                    document.write('<a title="<?php echo $strCalendar;?>" href="javascript:openCalendar(\'<?php echo PMA_generate_common_url();?>\', \'insertForm\', \'field_<?php echo ($i); ?>\', \'<?php echo (substr($type, 0, 9) == 'timestamp') ? 'datetime' : substr($type, 0, 9); ?>\', \'\')"><img class="calendar" src="<?php echo $pmaThemeImage; ?>b_calendar.png" alt="<?php echo $strCalendar; ?>"/></a>');
-                    //]]>
-                    </script>
+<script type="text/javascript">
+//<![CDATA[
+$(function() {
+    $('#field_<?php echo $i; ?>').datepicker({
+    	duration: '',
+		time24h: true,
+		 stepMinutes: 1,
+        stepHours: 1,
+        <?php echo ($type == 'date' ? "showTime: false,":"showTime: true,"); ?>
+		altTimeField: '',
+        constrainInput: false
+     });
+});
+//]]>
+</script>
         <?php
         }
         ?>


hooks/post-receive
-- 
phpMyAdmin




More information about the Git mailing list