Helper_jqxDateTimeInput.js.html 6.38 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Source: Helper/jqxDateTimeInput.js</title>

    <script src="scripts/prettify/prettify.js"></script>
    <script src="scripts/prettify/lang-css.js"></script>
    <!--[if lt IE 9]>
    <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Source: Helper/jqxDateTimeInput.js</h1>


    <section>
        <article>
            <pre class="prettyprint source linenums"><code>/**
                * @author Rafael Ostertag &lt;rafael.ostertag@math.uzh.ch>
                */


                /* global $ */

                /**
                * Qfq Namespace
                *
                * @namespace QfqNS
                */
                var QfqNS = QfqNS || {};
                /**
                * Qfq Helper Namespace
                *
                * @namespace QfqNS.Helper
                */
                QfqNS.Helper = QfqNS.Helper || {};

                (function (n) {
                'use strict';

                /**
                * Initializes jqxDateTimeInput widgets.
                *
                * It configures all `&lt;div>`s having a class `jqw-datetimepicker` as jqxDateTimeInput.
                *
                * Given the HTML snippet
                *
                * ...
                * &lt;div class="jqw-datetimepicker" data-control-name="datetimepicker" >&lt;/div>
                * ...
                *
                * it will create a hidden input sibling element of the `&lt;div>` where the selected date is stored for
                plain old
                * form submission, thus rendering the above snippet effectively to
                *
                * ...
                * &lt;div class="jqw-datetimepicker" data-control-name="datetimepicker" >&lt;/div>
                * &lt;input type="hidden" name="datetimepicker">
                * ...
                *
                * The jqxDateTimeInput can be configured using following `data` attributes
                *
                * * `data-control-name`: Mandatory attribute. Hold the name of the input element.
                * * `data-format-string': Optional Format string as required by jqxDateTimeInput. See also
                * {@link
                http://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxdatetimeinput/jquery-datetimeinput-api.htm}.
                * Default: "F".
                * * `data-show-time-button`: Boolean value `true` or `false`, indicating whether or not a time picker
                will be
                * displayed.
                *
                * @function
                * @name QfqNS.Helper.jqxDateTimeInput
                */
                var jqxDateTimeInput = function () {
                var index;
                var $containers = $("div.jqw-datetimepicker");

                $containers.each(function (index, object) {
                (function ($container) {
                var controlName = $container.data('control-name');
                if (!controlName) {
                QfqNS.Log.error("jqwDateTimePicker does not have a 'data-control-name' attribute.");
                return;
                }

                var formatString = $container.data('format-string');
                if (!formatString) {
                formatString = "F";
                }

                var showTimeButton = $container.data('show-time-button');
                if (showTimeButton === undefined) {
                showTimeButton = false;
                }

                var jqxDateTimeInputConfig = {
                formatString: formatString,
                showTimeButton: showTimeButton,
                theme: "bootstrap"
                };

                $container.jqxDateTimeInput(jqxDateTimeInputConfig);

                // Our code creates a hidden input element for each jqxwidget as sibling of the widget. We do this,
                // because jqxwidget don't create named input elements, and thus the value would not be sent to the
                // server using a Plain Old Form submission (even if performed by an ajax request).
                var $hiddenInput = $("&lt;input>")
                .attr('type', 'hidden')
                .attr('name', controlName);

                $container.after($hiddenInput);

                $hiddenInput.val($container.jqxDateTimeInput('value').toISOString());

                $container.on('valueChanged', function (event) {
                $hiddenInput.val(event.args.date.toISOString());
                });
                })($(object));
                });

                };

                n.jqxDateTimeInput = jqxDateTimeInput;


                })(QfqNS.Helper);</code></pre>
        </article>
    </section>


</div>

<nav>
    <h2><a href="index.html">Home</a></h2>

    <h3>Classes</h3>
    <ul>
        <li><a href="n.Alert.html">Alert</a></li>
        <li><a href="QfqNS.BSTabs.html">BSTabs</a></li>
        <li><a href="QfqNS.Element.Checkbox.html">Checkbox</a></li>
        <li><a href="QfqNS.Element.FormGroup.html">FormGroup</a></li>
        <li><a href="QfqNS.Element.Radio.html">Radio</a></li>
        <li><a href="QfqNS.Element.Select.html">Select</a></li>
        <li><a href="QfqNS.Element.Textual.html">Textual</a></li>
        <li><a href="QfqNS.FileDelete.html">FileDelete</a></li>
        <li><a href="QfqNS.FileUpload.html">FileUpload</a></li>
        <li><a href="QfqNS.Form.html">Form</a></li>
        <li><a href="QfqNS.PageState.html">PageState</a></li>
        <li><a href="QfqNS.QfqForm.html">QfqForm</a></li>
        <li><a href="QfqNS.QfqPage.html">QfqPage</a></li>
        <li><a href="QfqNS.QfqRecordList.html">QfqRecordList</a></li>
    </ul>
    <h3>Namespaces</h3>
    <ul>
        <li><a href="global.html#QfqNS">QfqNS</a></li>
        <li><a href="QfqNS.Element.html">Element</a></li>
        <li><a href="QfqNS.Helper.html">Helper</a></li>
    </ul>
    <h3><a href="global.html">Global</a></h3>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Mon May 23 2016 12:28:24
    GMT+0200 (CEST)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"></script>
</body>
</html>