phcthemes_admin_panel_pack 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.autogrow.js +37 -0
- data/app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.charcounter.js +53 -0
- data/app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.checkbox.js +54 -0
- data/app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.datepicker.js +59 -0
- data/app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.js +823 -0
- data/app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.masked.js +46 -0
- data/app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.time.js +71 -0
- data/app/assets/javascripts/phcthemes_admin_panel_pack_metronic.js +5 -0
- data/lib/phcthemes_admin_panel_pack/version.rb +1 -1
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afd4b11895fab866151949bca3ecbcb178ec7d4bf181e93cefa3e7f71034aaf9
|
4
|
+
data.tar.gz: 51c1669b43126cd7486d151899bbb0a14315bfd2c7adabef585a3c9733460407
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31a5be6549d09ac7ee17f46da2b09f8fc1631bea0a8bde330f430b0d8f908e74932718e2636de4a4a8a790186e1a7777fe15295959a6b7d47766bbf284b02282
|
7
|
+
data.tar.gz: c41598e749c859949735ddf57afb932f6fe6c5462f3506f5d7855467b62856f2e3471b935746c60a7d9c632bcd468f3e21f891671af504e4e2cf232f38356060
|
@@ -0,0 +1,37 @@
|
|
1
|
+
/**
|
2
|
+
* @file autogrow plugin for jquery-jeditable
|
3
|
+
* @author Mika Tuupola, Nicolas CARPi
|
4
|
+
* @copyright © 2008 Mika Tuupola, Nicolas CARPi
|
5
|
+
* @home https://github.com/NicolasCARPi/jquery_jeditable
|
6
|
+
* @licence MIT (see LICENCE file)
|
7
|
+
* @name PluginAutogrow
|
8
|
+
* @example <caption>Autogrow example:</caption>
|
9
|
+
* $(".autogrow").editable("save.php", {
|
10
|
+
* type : "autogrow",
|
11
|
+
* submit : 'OK',
|
12
|
+
* cancel : 'cancel'
|
13
|
+
* });
|
14
|
+
*/
|
15
|
+
'use strict';
|
16
|
+
(function ($) {
|
17
|
+
$.editable.addInputType("autogrow", {
|
18
|
+
element : function(settings, original) {
|
19
|
+
var textarea = $("<textarea />");
|
20
|
+
if (settings.rows) {
|
21
|
+
textarea.attr("rows", settings.rows);
|
22
|
+
} else {
|
23
|
+
textarea.height(settings.height);
|
24
|
+
}
|
25
|
+
if (settings.cols) {
|
26
|
+
textarea.attr("cols", settings.cols);
|
27
|
+
} else {
|
28
|
+
textarea.width(settings.width);
|
29
|
+
}
|
30
|
+
$(this).append(textarea);
|
31
|
+
return(textarea);
|
32
|
+
},
|
33
|
+
plugin : function(settings, original) {
|
34
|
+
$("textarea", this).autoGrow();
|
35
|
+
}
|
36
|
+
});
|
37
|
+
})(jQuery);
|
@@ -0,0 +1,53 @@
|
|
1
|
+
/**
|
2
|
+
* Depends on Charcounter jQuery plugin by Tom Deater
|
3
|
+
* http://www.tomdeater.com/jquery/character_counter/
|
4
|
+
*
|
5
|
+
* @file charcounter textarea plugin for jquery-jeditable
|
6
|
+
* @author Mika Tuupola, Nicolas CARPi
|
7
|
+
* @home https://github.com/NicolasCARPi/jquery_jeditable
|
8
|
+
* @licence MIT (see LICENCE file)
|
9
|
+
* @copyright © 2006 Mika Tuupola, Nicolas CARPi
|
10
|
+
* @name PluginCharcounter
|
11
|
+
* @example <caption>Charcounter example:</caption>
|
12
|
+
* $(".charcounter").editable("save.php", {
|
13
|
+
* type : "charcounter",
|
14
|
+
* submit : 'OK',
|
15
|
+
* charcounter : {
|
16
|
+
* characters : 60
|
17
|
+
* }
|
18
|
+
* });
|
19
|
+
*/
|
20
|
+
'use strict';
|
21
|
+
(function ($) {
|
22
|
+
$.editable.addInputType("charcounter", {
|
23
|
+
element : function(settings, original) {
|
24
|
+
var textarea = $("<textarea />");
|
25
|
+
if (settings.rows) {
|
26
|
+
textarea.attr("rows", settings.rows);
|
27
|
+
} else {
|
28
|
+
textarea.height(settings.height);
|
29
|
+
}
|
30
|
+
if (settings.cols) {
|
31
|
+
textarea.attr("cols", settings.cols);
|
32
|
+
} else {
|
33
|
+
textarea.width(settings.width);
|
34
|
+
}
|
35
|
+
|
36
|
+
// stop bubbling and propagation to parent element
|
37
|
+
textarea.click(function(event) {
|
38
|
+
if (event.cancelBubble) {
|
39
|
+
event.cancelBubble();
|
40
|
+
}
|
41
|
+
if (event.stopPropagation) {
|
42
|
+
event.stopPropagation();
|
43
|
+
}
|
44
|
+
});
|
45
|
+
|
46
|
+
$(this).append(textarea);
|
47
|
+
return(textarea);
|
48
|
+
},
|
49
|
+
plugin : function(settings, original) {
|
50
|
+
$("textarea", this).charCounter(settings.charcounter.characters, settings.charcounter);
|
51
|
+
}
|
52
|
+
});
|
53
|
+
})(jQuery);
|
@@ -0,0 +1,54 @@
|
|
1
|
+
/**
|
2
|
+
* @file checkbox plugin for jquery-jeditable
|
3
|
+
* @author Mika Tuupola, Nicolas CARPi
|
4
|
+
* @home https://github.com/NicolasCARPi/jquery_jeditable
|
5
|
+
* @licence MIT (see LICENCE file)
|
6
|
+
* @name PluginCheckbox
|
7
|
+
*/
|
8
|
+
'use strict';
|
9
|
+
(function ($) {
|
10
|
+
$.editable.addInputType('checkbox', {
|
11
|
+
element : function(settings, original) {
|
12
|
+
var input = $('<input type="checkbox">');
|
13
|
+
$(this).append(input);
|
14
|
+
|
15
|
+
$(input).bind('click', function() {
|
16
|
+
if ($(input).val() === 'on') {
|
17
|
+
$(input).val('off');
|
18
|
+
$(input).removeAttr('checked');
|
19
|
+
} else {
|
20
|
+
$(input).val('on');
|
21
|
+
$(input).attr('checked', 'checked');
|
22
|
+
}
|
23
|
+
});
|
24
|
+
|
25
|
+
return(input);
|
26
|
+
},
|
27
|
+
|
28
|
+
content : function(string, settings, original) {
|
29
|
+
|
30
|
+
var checked = (string === 'yes') ? 'on' : 'off';
|
31
|
+
var input = $(':input:first', this);
|
32
|
+
|
33
|
+
if (checked === 'on') {
|
34
|
+
$(input).attr('checked', checked);
|
35
|
+
} else {
|
36
|
+
$(input).removeAttr('checked');
|
37
|
+
}
|
38
|
+
|
39
|
+
var value = $(input).is(':checked') ? 'on' : 'off';
|
40
|
+
$(input).val(value);
|
41
|
+
},
|
42
|
+
|
43
|
+
submit: function (settings, original) {
|
44
|
+
var value;
|
45
|
+
var input = $(':input:first', this);
|
46
|
+
if (input.is(':checked')) {
|
47
|
+
value = '1';
|
48
|
+
} else {
|
49
|
+
value = '0';
|
50
|
+
}
|
51
|
+
$('input', this).val(value);
|
52
|
+
}
|
53
|
+
});
|
54
|
+
})(jQuery);
|
@@ -0,0 +1,59 @@
|
|
1
|
+
/**
|
2
|
+
* Depends on datepicker widget from jQuery-ui
|
3
|
+
* https://jqueryui.com/datepicker/
|
4
|
+
*
|
5
|
+
* @file datepicker plugin for jquery-jeditable
|
6
|
+
* @author Nicolas CARPi
|
7
|
+
* @copyright © 2008 Mika Tuupola, Nicolas CARPi
|
8
|
+
* @home https://github.com/NicolasCARPi/jquery_jeditable
|
9
|
+
* @licence MIT (see LICENCE file)
|
10
|
+
* @name PluginDatepicker
|
11
|
+
* @example <caption>Datepicker example:</caption>
|
12
|
+
* $(".date").editable("save.php", {
|
13
|
+
* type : "datepicker",
|
14
|
+
* submit : 'OK',
|
15
|
+
* datepicker : {
|
16
|
+
* format: "dd-mm-yy"
|
17
|
+
* },
|
18
|
+
* cancel : 'cancel',
|
19
|
+
* });
|
20
|
+
*/
|
21
|
+
'use strict';
|
22
|
+
(function ($) {
|
23
|
+
$.editable.addInputType('datepicker', {
|
24
|
+
|
25
|
+
element : function(settings, original) {
|
26
|
+
var input = $('<input />');
|
27
|
+
if (settings.datepicker) {
|
28
|
+
input.datepicker(settings.datepicker);
|
29
|
+
} else {
|
30
|
+
input.datepicker();
|
31
|
+
}
|
32
|
+
|
33
|
+
// get the date in the correct format
|
34
|
+
if (settings.datepicker.format) {
|
35
|
+
input.datepicker('option', 'dateFormat', settings.datepicker.format);
|
36
|
+
}
|
37
|
+
|
38
|
+
$(this).append(input);
|
39
|
+
return(input);
|
40
|
+
},
|
41
|
+
|
42
|
+
submit: function (settings, original) {
|
43
|
+
var dateRaw = $('input', this).datepicker('getDate');
|
44
|
+
var dateFormatted;
|
45
|
+
|
46
|
+
if (settings.datepicker.format) {
|
47
|
+
dateFormatted = $.datepicker.formatDate(settings.datepicker.format, new Date(dateRaw));
|
48
|
+
} else {
|
49
|
+
dateFormatted = dateRaw;
|
50
|
+
}
|
51
|
+
$('input', this).val(dateFormatted);
|
52
|
+
},
|
53
|
+
|
54
|
+
plugin : function(settings, original) {
|
55
|
+
// prevent disappearing of calendar
|
56
|
+
settings.onblur = null;
|
57
|
+
}
|
58
|
+
});
|
59
|
+
})(jQuery);
|
@@ -0,0 +1,823 @@
|
|
1
|
+
/**
|
2
|
+
* @file Jeditable - jQuery in place edit plugin
|
3
|
+
* @home https://github.com/NicolasCARPi/jquery_jeditable
|
4
|
+
* @author Mika Tuupola, Dylan Verheul, Nicolas CARPi
|
5
|
+
* @copyright © 2006 Mika Tuupola, Dylan Verheul, Nicolas CARPi
|
6
|
+
* @licence MIT (see LICENCE file)
|
7
|
+
* @name Jquery-jeditable
|
8
|
+
* @type jQuery
|
9
|
+
*
|
10
|
+
* @param {String|Function} target - URL or Function to send edited content to. Can also be 'disable', 'enable', or 'destroy'
|
11
|
+
* @param {Object} [options] - Additional options
|
12
|
+
* @param {Object} [options.ajaxoptions] - jQuery Ajax options. See https://api.jquery.com/jQuery.ajax/
|
13
|
+
* @param {Function} [options.before] - Function to be executed before going into edit mode
|
14
|
+
* @param {Function} [options.callback] - function(result, settings, submitdata) Function to run after submitting edited content
|
15
|
+
* @param {String} [options.cancel] - Cancel button value, empty means no button
|
16
|
+
* @param {String} [options.cancelcssclass] - CSS class to apply to cancel button
|
17
|
+
* @param {Number} [options.cols] - Number of columns if using textarea
|
18
|
+
* @param {String} [options.cssclass] - CSS class to apply to input form; use 'inherit' to copy from parent
|
19
|
+
* @param {String} [options.inputcssclass] - CSS class to apply to input. 'inherit' to copy from parent
|
20
|
+
* @param {String|Function} [options.data] - Content loaded in the form
|
21
|
+
* @param {String} [options.event='click'] - jQuery event such as 'click' of 'dblclick'. See https://api.jquery.com/category/events/
|
22
|
+
* @param {String} [options.formid] - Give an id to the form that is produced
|
23
|
+
* @param {String|Number} [options.height='auto'] - Height of the element in pixels or 'auto' or 'none'
|
24
|
+
* @param {String} [options.id='id'] - POST parameter name of edited div id
|
25
|
+
* @param {String} [options.indicator] - Indicator html to show when saving
|
26
|
+
* @param {String} [options.label] - Label for the form
|
27
|
+
* @param {String} [options.list] - HTML5 attribute for text input. Will suggest from a datalist with id of the list option
|
28
|
+
* @param {String|Function} [options.loaddata] - Extra parameters to pass when fetching content before editing
|
29
|
+
* @param {String} [options.loadtext='Loading…'] - Text to display while loading external content
|
30
|
+
* @param {String} [options.loadtype='GET'] - Request type for loadurl (GET or POST)
|
31
|
+
* @param {String} [options.loadurl] - URL to fetch input content before editing
|
32
|
+
* @param {Number} [options.max] - Maximum value for number type
|
33
|
+
* @param {String} [options.maxlength] - The maximum number of character in the text field
|
34
|
+
* @param {String} [options.method] - Method to use to send edited content (POST or PUT)
|
35
|
+
* @param {Number} [options.min] - Mininum value for number type
|
36
|
+
* @param {Boolean} [options.multiple] - Allow multiple selections in a select input
|
37
|
+
* @param {String} [options.name='value'] - POST parameter name of edited content
|
38
|
+
* @param {String|Function} [options.onblur='cancel'] - Use 'cancel', 'submit', 'ignore' or function. If function returns false, the form is cancelled.
|
39
|
+
* @param {Function} [options.onedit] - function triggered upon edition; will cancel edition if it returns false
|
40
|
+
* @param {Function} [options.onerror] - function(settings, original, xhr) { ... } called on error
|
41
|
+
* @param {Function} [options.onreset] - function(settings, original) { ... } called before reset
|
42
|
+
* @param {Function} [options.onsubmit] - function(settings, original) { ... } called before submit
|
43
|
+
* @param {String} [options.pattern] - HTML5 attribute for text or URL input
|
44
|
+
* @param {String} [options.placeholder='Click to edit'] - Placeholder text or html to insert when element is empty
|
45
|
+
* @param {Number} [options.rows] - number of rows if using textarea
|
46
|
+
* @param {Boolean} [options.select] - When true text is selected
|
47
|
+
* @param {Function} [options.showfn]- Function that can animate the element when switching to edit mode
|
48
|
+
* @param {String} [options.size] - The size of the text field
|
49
|
+
* @param {String} [options.sortselectoptions] - Sort the options of a select form
|
50
|
+
* @param {Number} [options.step] - Step size for number type
|
51
|
+
* @param {String} [options.style] - Style to apply to input form; 'inherit' to copy from parent
|
52
|
+
* @param {String} [options.submit] - submit button value, empty means no button
|
53
|
+
* @param {String} [options.submitcssclass] - CSS class to apply to submit button
|
54
|
+
* @param {Object|Function} [options.submitdata] - Extra parameters to send when submitting edited content. function(revert, settings, submitdata)
|
55
|
+
* @param {String} [options.tooltip] - Tooltip text that appears on hover (via title attribute)
|
56
|
+
* @param {String} [options.type='text'] - text, textarea, select, email, number, url (or any 3rd party input type)
|
57
|
+
* @param {String|Number} [options.width='auto'] - The width of the element in pixels or 'auto' or 'none'
|
58
|
+
*
|
59
|
+
* @example <caption>Simple usage example:</caption>
|
60
|
+
* $(".editable").editable("save.php", {
|
61
|
+
* cancel : 'Cancel',
|
62
|
+
* submit : 'Save',
|
63
|
+
* tooltip : "Click to edit...",
|
64
|
+
* });
|
65
|
+
*/
|
66
|
+
(function($) {
|
67
|
+
|
68
|
+
'use strict';
|
69
|
+
|
70
|
+
// Keyboard accessibility/WAI-ARIA - allow users to navigate to an editable element using TAB/Shift+TAB
|
71
|
+
$.fn.editableAriaShim = function () {
|
72
|
+
this.attr({
|
73
|
+
role: 'button',
|
74
|
+
tabindex: 0
|
75
|
+
});
|
76
|
+
return this; // <-- object chaining.
|
77
|
+
};
|
78
|
+
|
79
|
+
// EDITABLE function
|
80
|
+
$.fn.editable = function(target, options) {
|
81
|
+
|
82
|
+
if ('disable' === target) {
|
83
|
+
$(this).data('disabled.editable', true);
|
84
|
+
return;
|
85
|
+
}
|
86
|
+
if ('enable' === target) {
|
87
|
+
$(this).data('disabled.editable', false);
|
88
|
+
return;
|
89
|
+
}
|
90
|
+
if ('destroy' === target) {
|
91
|
+
$(this)
|
92
|
+
.unbind($(this).data('event.editable'))
|
93
|
+
.removeData('disabled.editable')
|
94
|
+
.removeData('event.editable');
|
95
|
+
return;
|
96
|
+
}
|
97
|
+
var settings = $.extend({}, $.fn.editable.defaults, {target:target}, options);
|
98
|
+
|
99
|
+
/* setup some functions */
|
100
|
+
var plugin = $.editable.types[settings.type].plugin || function() { };
|
101
|
+
var submit = $.editable.types[settings.type].submit || function() { };
|
102
|
+
var buttons = $.editable.types[settings.type].buttons || $.editable.types.defaults.buttons;
|
103
|
+
var content = $.editable.types[settings.type].content || $.editable.types.defaults.content;
|
104
|
+
var element = $.editable.types[settings.type].element || $.editable.types.defaults.element;
|
105
|
+
var reset = $.editable.types[settings.type].reset || $.editable.types.defaults.reset;
|
106
|
+
var destroy = $.editable.types[settings.type].destroy || $.editable.types.defaults.destroy;
|
107
|
+
var callback = settings.callback || function() { };
|
108
|
+
var intercept = settings.intercept || function(s) { return s; };
|
109
|
+
var onedit = settings.onedit || function() { };
|
110
|
+
var onsubmit = settings.onsubmit || function() { };
|
111
|
+
var onreset = settings.onreset || function() { };
|
112
|
+
var onerror = settings.onerror || reset;
|
113
|
+
var before = settings.before || false;
|
114
|
+
|
115
|
+
// TOOLTIP
|
116
|
+
if (settings.tooltip) {
|
117
|
+
$(this).attr('title', settings.tooltip);
|
118
|
+
}
|
119
|
+
|
120
|
+
return this.each(function() {
|
121
|
+
|
122
|
+
/* Save this to self because this changes when scope changes. */
|
123
|
+
var self = this;
|
124
|
+
|
125
|
+
/* Save so it can be later used by $.editable('destroy') */
|
126
|
+
$(this).data('event.editable', settings.event);
|
127
|
+
|
128
|
+
/* If element is empty add something clickable (if requested) */
|
129
|
+
if (!$.trim($(this).html())) {
|
130
|
+
$(this).html(settings.placeholder);
|
131
|
+
}
|
132
|
+
|
133
|
+
if ('destroy' === target) {
|
134
|
+
destroy.apply($(this).find('form'), [settings, self]);
|
135
|
+
return;
|
136
|
+
}
|
137
|
+
|
138
|
+
// EVENT IS FIRED
|
139
|
+
$(this).bind(settings.event, function(e) {
|
140
|
+
|
141
|
+
/* Abort if element is disabled. */
|
142
|
+
if (true === $(this).data('disabled.editable')) {
|
143
|
+
return;
|
144
|
+
}
|
145
|
+
|
146
|
+
// do nothing if user press Tab again, just go to next element, not into edit mode
|
147
|
+
if (e.which === 9) {
|
148
|
+
return;
|
149
|
+
}
|
150
|
+
|
151
|
+
/* Prevent throwing an exeption if edit field is clicked again. */
|
152
|
+
if (self.editing) {
|
153
|
+
return;
|
154
|
+
}
|
155
|
+
|
156
|
+
/* Abort if onedit hook returns false. */
|
157
|
+
if (false === onedit.apply(this, [settings, self, e])) {
|
158
|
+
return;
|
159
|
+
}
|
160
|
+
|
161
|
+
/* execute the before function if any was specified */
|
162
|
+
if (settings.before && jQuery.isFunction(settings.before)) {
|
163
|
+
settings.before(e);
|
164
|
+
} else if (settings.before && !jQuery.isFunction(settings.before)) {
|
165
|
+
throw "The 'before' option needs to be provided as a function!";
|
166
|
+
}
|
167
|
+
|
168
|
+
/* Prevent default action and bubbling. */
|
169
|
+
e.preventDefault();
|
170
|
+
e.stopPropagation();
|
171
|
+
|
172
|
+
/* Remove tooltip. */
|
173
|
+
if (settings.tooltip) {
|
174
|
+
$(self).removeAttr('title');
|
175
|
+
}
|
176
|
+
|
177
|
+
/* Remove placeholder text, replace is here because of IE. */
|
178
|
+
if ($(this).html().toLowerCase().replace(/(;|"|\/)/g, '') ===
|
179
|
+
settings.placeholder.toLowerCase().replace(/(;|"|\/)/g, '')) {
|
180
|
+
$(this).html('');
|
181
|
+
}
|
182
|
+
|
183
|
+
self.editing = true;
|
184
|
+
self.revert = $(self).text();
|
185
|
+
$(self).html('');
|
186
|
+
|
187
|
+
/* Create the form object. */
|
188
|
+
var form = $('<form />');
|
189
|
+
|
190
|
+
/* Apply css or style or both. */
|
191
|
+
if (settings.cssclass) {
|
192
|
+
if ('inherit' === settings.cssclass) {
|
193
|
+
form.attr('class', $(self).attr('class'));
|
194
|
+
} else {
|
195
|
+
form.attr('class', settings.cssclass);
|
196
|
+
}
|
197
|
+
}
|
198
|
+
|
199
|
+
if (settings.style) {
|
200
|
+
if ('inherit' === settings.style) {
|
201
|
+
form.attr('style', $(self).attr('style'));
|
202
|
+
/* IE needs the second line or display wont be inherited. */
|
203
|
+
form.css('display', $(self).css('display'));
|
204
|
+
} else {
|
205
|
+
form.attr('style', settings.style);
|
206
|
+
}
|
207
|
+
}
|
208
|
+
|
209
|
+
// add a label if it exists
|
210
|
+
if (settings.label) {
|
211
|
+
form.append('<label>' + settings.label + '</label>');
|
212
|
+
}
|
213
|
+
|
214
|
+
// add an ID to the form
|
215
|
+
if (settings.formid) {
|
216
|
+
form.attr('id', settings.formid);
|
217
|
+
}
|
218
|
+
|
219
|
+
/* Add main input element to form and store it in input. */
|
220
|
+
var input = element.apply(form, [settings, self]);
|
221
|
+
|
222
|
+
if (settings.inputcssclass) {
|
223
|
+
if ('inherit' === settings.inputcssclass) {
|
224
|
+
input.attr('class', $(self).attr('class'));
|
225
|
+
} else {
|
226
|
+
input.attr('class', settings.inputcssclass);
|
227
|
+
}
|
228
|
+
}
|
229
|
+
|
230
|
+
/* Set input content via POST, GET, given data or existing value. */
|
231
|
+
var input_content;
|
232
|
+
|
233
|
+
// timeout function
|
234
|
+
var t;
|
235
|
+
var isSubmitting = false;
|
236
|
+
|
237
|
+
if (settings.loadurl) {
|
238
|
+
t = self.setTimeout(function() {
|
239
|
+
input.disabled = true;
|
240
|
+
}, 100);
|
241
|
+
$(self).html(settings.loadtext);
|
242
|
+
|
243
|
+
var loaddata = {};
|
244
|
+
loaddata[settings.id] = self.id;
|
245
|
+
if ($.isFunction(settings.loaddata)) {
|
246
|
+
$.extend(loaddata, settings.loaddata.apply(self, [self.revert, settings]));
|
247
|
+
} else {
|
248
|
+
$.extend(loaddata, settings.loaddata);
|
249
|
+
}
|
250
|
+
$.ajax({
|
251
|
+
type : settings.loadtype,
|
252
|
+
url : settings.loadurl,
|
253
|
+
data : loaddata,
|
254
|
+
async: false,
|
255
|
+
cache : false,
|
256
|
+
success: function(result) {
|
257
|
+
self.clearTimeout(t);
|
258
|
+
input_content = result;
|
259
|
+
input.disabled = false;
|
260
|
+
}
|
261
|
+
});
|
262
|
+
} else if (settings.data) {
|
263
|
+
input_content = settings.data;
|
264
|
+
if ($.isFunction(settings.data)) {
|
265
|
+
input_content = settings.data.apply(self, [self.revert, settings]);
|
266
|
+
}
|
267
|
+
} else {
|
268
|
+
input_content = self.revert;
|
269
|
+
}
|
270
|
+
content.apply(form, [input_content, settings, self]);
|
271
|
+
|
272
|
+
input.attr('name', settings.name);
|
273
|
+
|
274
|
+
/* adjust the width of the element to account for the margin/padding/border */
|
275
|
+
if (settings.width !== 'none') {
|
276
|
+
var adj_width = settings.width - (input.outerWidth(true) - settings.width);
|
277
|
+
input.width(adj_width);
|
278
|
+
}
|
279
|
+
|
280
|
+
/* Add buttons to the form. */
|
281
|
+
buttons.apply(form, [settings, self]);
|
282
|
+
|
283
|
+
/* Add created form to self. */
|
284
|
+
if (settings.showfn && $.isFunction(settings.showfn)) {
|
285
|
+
form.hide();
|
286
|
+
}
|
287
|
+
|
288
|
+
// clear the loadtext that we put here before
|
289
|
+
$(self).html('');
|
290
|
+
|
291
|
+
$(self).append(form);
|
292
|
+
|
293
|
+
// execute the showfn
|
294
|
+
if (settings.showfn && $.isFunction(settings.showfn)) {
|
295
|
+
settings.showfn(form);
|
296
|
+
}
|
297
|
+
|
298
|
+
/* Attach 3rd party plugin if requested. */
|
299
|
+
plugin.apply(form, [settings, self]);
|
300
|
+
|
301
|
+
/* Focus to first visible form element. */
|
302
|
+
form.find(':input:visible:enabled:first').focus();
|
303
|
+
|
304
|
+
/* Highlight input contents when requested. */
|
305
|
+
if (settings.select) {
|
306
|
+
input.select();
|
307
|
+
}
|
308
|
+
|
309
|
+
/* discard changes if pressing esc */
|
310
|
+
$(this).keydown(function(e) {
|
311
|
+
if (e.which === 27) {
|
312
|
+
e.preventDefault();
|
313
|
+
reset.apply(form, [settings, self]);
|
314
|
+
}
|
315
|
+
});
|
316
|
+
|
317
|
+
/* Discard, submit or nothing with changes when clicking outside. */
|
318
|
+
/* Do nothing is usable when navigating with tab. */
|
319
|
+
if ('cancel' === settings.onblur) {
|
320
|
+
input.blur(function(e) {
|
321
|
+
/* Prevent canceling if submit was clicked. */
|
322
|
+
t = self.setTimeout(function() {
|
323
|
+
reset.apply(form, [settings, self]);
|
324
|
+
}, 500);
|
325
|
+
});
|
326
|
+
} else if ('submit' === settings.onblur) {
|
327
|
+
input.blur(function(e) {
|
328
|
+
/* Prevent double submit if submit was clicked. */
|
329
|
+
t = self.setTimeout(function() {
|
330
|
+
form.submit();
|
331
|
+
}, 200);
|
332
|
+
});
|
333
|
+
} else if ($.isFunction(settings.onblur)) {
|
334
|
+
input.blur(function(e) {
|
335
|
+
// reset the form if the onblur function returns false
|
336
|
+
if (false === settings.onblur.apply(self, [input.val(), settings, form])) {
|
337
|
+
reset.apply(form, [settings, self]);
|
338
|
+
}
|
339
|
+
});
|
340
|
+
}
|
341
|
+
|
342
|
+
form.submit(function(e) {
|
343
|
+
|
344
|
+
/* Do no submit. */
|
345
|
+
e.preventDefault();
|
346
|
+
e.stopPropagation();
|
347
|
+
|
348
|
+
if (isSubmitting) {
|
349
|
+
// we are already submitting! Stop right here.
|
350
|
+
return false;
|
351
|
+
} else {
|
352
|
+
isSubmitting = true;
|
353
|
+
}
|
354
|
+
|
355
|
+
if (t) {
|
356
|
+
self.clearTimeout(t);
|
357
|
+
}
|
358
|
+
|
359
|
+
/* Call before submit hook. */
|
360
|
+
/* If it returns false abort submitting. */
|
361
|
+
isSubmitting = false !== onsubmit.apply(form, [settings, self]);
|
362
|
+
if (isSubmitting) {
|
363
|
+
/* Custom inputs call before submit hook. */
|
364
|
+
/* If it returns false abort submitting. */
|
365
|
+
isSubmitting = false !== submit.apply(form, [settings, self]);
|
366
|
+
if (isSubmitting) {
|
367
|
+
|
368
|
+
/* Check if given target is function */
|
369
|
+
if ($.isFunction(settings.target)) {
|
370
|
+
/* Callback function to handle the target reponse */
|
371
|
+
var responseHandler = function(value, complete) {
|
372
|
+
isSubmitting = false;
|
373
|
+
if (false !== complete) {
|
374
|
+
$(self).html(value);
|
375
|
+
self.editing = false;
|
376
|
+
callback.apply(self, [self.innerHTML, settings]);
|
377
|
+
if (!$.trim($(self).html())) {
|
378
|
+
$(self).html(settings.placeholder);
|
379
|
+
}
|
380
|
+
}
|
381
|
+
};
|
382
|
+
/* Call the user target function */
|
383
|
+
var userTarget = settings.target.apply(self, [input.val(), settings, responseHandler]);
|
384
|
+
/* Handle the target function return for compatibility */
|
385
|
+
if (false !== userTarget && undefined !== userTarget) {
|
386
|
+
responseHandler(userTarget, userTarget);
|
387
|
+
}
|
388
|
+
|
389
|
+
} else {
|
390
|
+
/* Add edited content and id of edited element to POST. */
|
391
|
+
var submitdata = {};
|
392
|
+
submitdata[settings.name] = input.val();
|
393
|
+
submitdata[settings.id] = self.id;
|
394
|
+
/* Add extra data to be POST:ed. */
|
395
|
+
if ($.isFunction(settings.submitdata)) {
|
396
|
+
$.extend(submitdata, settings.submitdata.apply(self, [self.revert, settings, submitdata]));
|
397
|
+
} else {
|
398
|
+
$.extend(submitdata, settings.submitdata);
|
399
|
+
}
|
400
|
+
|
401
|
+
/* Quick and dirty PUT support. */
|
402
|
+
if ('PUT' === settings.method) {
|
403
|
+
submitdata._method = 'put';
|
404
|
+
}
|
405
|
+
|
406
|
+
// SHOW INDICATOR
|
407
|
+
$(self).html(settings.indicator);
|
408
|
+
|
409
|
+
/* Defaults for ajaxoptions. */
|
410
|
+
var ajaxoptions = {
|
411
|
+
type : 'POST',
|
412
|
+
complete: function (xhr, status) {
|
413
|
+
isSubmitting = false;
|
414
|
+
},
|
415
|
+
data : submitdata,
|
416
|
+
dataType: 'html',
|
417
|
+
url : settings.target,
|
418
|
+
success : function(result, status) {
|
419
|
+
|
420
|
+
// INTERCEPT
|
421
|
+
result = intercept.apply(self, [result, status]);
|
422
|
+
|
423
|
+
if (ajaxoptions.dataType === 'html') {
|
424
|
+
$(self).html(result);
|
425
|
+
}
|
426
|
+
self.editing = false;
|
427
|
+
callback.apply(self, [result, settings, submitdata]);
|
428
|
+
if (!$.trim($(self).html())) {
|
429
|
+
$(self).html(settings.placeholder);
|
430
|
+
}
|
431
|
+
},
|
432
|
+
error : function(xhr, status, error) {
|
433
|
+
onerror.apply(form, [settings, self, xhr]);
|
434
|
+
}
|
435
|
+
};
|
436
|
+
|
437
|
+
/* Override with what is given in settings.ajaxoptions. */
|
438
|
+
$.extend(ajaxoptions, settings.ajaxoptions);
|
439
|
+
$.ajax(ajaxoptions);
|
440
|
+
}
|
441
|
+
}
|
442
|
+
}
|
443
|
+
|
444
|
+
/* Show tooltip again. */
|
445
|
+
$(self).attr('title', settings.tooltip);
|
446
|
+
return false;
|
447
|
+
});
|
448
|
+
});
|
449
|
+
|
450
|
+
// PRIVILEGED METHODS
|
451
|
+
|
452
|
+
// RESET
|
453
|
+
self.reset = function(form) {
|
454
|
+
/* Prevent calling reset twice when blurring. */
|
455
|
+
if (self.editing) {
|
456
|
+
/* Before reset hook, if it returns false abort reseting. */
|
457
|
+
if (false !== onreset.apply(form, [settings, self])) {
|
458
|
+
$(self).text(self.revert);
|
459
|
+
self.editing = false;
|
460
|
+
if (!$.trim($(self).html())) {
|
461
|
+
$(self).html(settings.placeholder);
|
462
|
+
}
|
463
|
+
/* Show tooltip again. */
|
464
|
+
if (settings.tooltip) {
|
465
|
+
$(self).attr('title', settings.tooltip);
|
466
|
+
}
|
467
|
+
}
|
468
|
+
}
|
469
|
+
};
|
470
|
+
|
471
|
+
// DESTROY
|
472
|
+
self.destroy = function(form) {
|
473
|
+
$(self)
|
474
|
+
.unbind($(self).data('event.editable'))
|
475
|
+
.removeData('disabled.editable')
|
476
|
+
.removeData('event.editable');
|
477
|
+
|
478
|
+
self.clearTimeouts();
|
479
|
+
|
480
|
+
if (self.editing) {
|
481
|
+
reset.apply(form, [settings, self]);
|
482
|
+
}
|
483
|
+
};
|
484
|
+
|
485
|
+
// CLEARTIMEOUT
|
486
|
+
self.clearTimeout = function(t) {
|
487
|
+
var timeouts = $(self).data('timeouts');
|
488
|
+
clearTimeout(t);
|
489
|
+
if(timeouts) {
|
490
|
+
var i = timeouts.indexOf(t);
|
491
|
+
if(i > -1) {
|
492
|
+
timeouts.splice(i, 1);
|
493
|
+
if(timeouts.length <= 0) {
|
494
|
+
$(self).removeData('timeouts');
|
495
|
+
}
|
496
|
+
} else {
|
497
|
+
console.warn('jeditable clearTimeout could not find timeout '+t);
|
498
|
+
}
|
499
|
+
}
|
500
|
+
};
|
501
|
+
|
502
|
+
// CLEAR ALL TIMEOUTS
|
503
|
+
self.clearTimeouts = function () {
|
504
|
+
var timeouts = $(self).data('timeouts');
|
505
|
+
if(timeouts) {
|
506
|
+
for(var i = 0, n = timeouts.length; i < n; ++i) {
|
507
|
+
clearTimeout(timeouts[i]);
|
508
|
+
}
|
509
|
+
timeouts.length = 0;
|
510
|
+
$(self).removeData('timeouts');
|
511
|
+
}
|
512
|
+
};
|
513
|
+
|
514
|
+
// SETTIMEOUT
|
515
|
+
self.setTimeout = function(callback, time) {
|
516
|
+
var timeouts = $(self).data('timeouts');
|
517
|
+
var t = setTimeout(function() {
|
518
|
+
callback();
|
519
|
+
self.clearTimeout(t);
|
520
|
+
}, time);
|
521
|
+
if(!timeouts) {
|
522
|
+
timeouts = [];
|
523
|
+
$(self).data('timeouts', timeouts);
|
524
|
+
}
|
525
|
+
timeouts.push(t);
|
526
|
+
return t;
|
527
|
+
};
|
528
|
+
});
|
529
|
+
};
|
530
|
+
|
531
|
+
var _supportInType = function (type) {
|
532
|
+
var i = document.createElement('input');
|
533
|
+
i.setAttribute('type', type);
|
534
|
+
return i.type !== 'text' ? type : 'text';
|
535
|
+
};
|
536
|
+
|
537
|
+
|
538
|
+
$.editable = {
|
539
|
+
types: {
|
540
|
+
defaults: {
|
541
|
+
element : function(settings, original) {
|
542
|
+
var input = $('<input type="hidden"></input>');
|
543
|
+
$(this).append(input);
|
544
|
+
return(input);
|
545
|
+
},
|
546
|
+
content : function(string, settings, original) {
|
547
|
+
$(this).find(':input:first').val(string);
|
548
|
+
},
|
549
|
+
reset : function(settings, original) {
|
550
|
+
original.reset(this);
|
551
|
+
},
|
552
|
+
destroy: function(settings, original) {
|
553
|
+
original.destroy(this);
|
554
|
+
},
|
555
|
+
buttons : function(settings, original) {
|
556
|
+
var form = this;
|
557
|
+
var submit;
|
558
|
+
if (settings.submit) {
|
559
|
+
/* If given html string use that. */
|
560
|
+
if (settings.submit.match(/>$/)) {
|
561
|
+
submit = $(settings.submit).click(function() {
|
562
|
+
if (submit.attr('type') !== 'submit') {
|
563
|
+
form.submit();
|
564
|
+
}
|
565
|
+
});
|
566
|
+
/* Otherwise use button with given string as text. */
|
567
|
+
} else {
|
568
|
+
submit = $('<button type="submit" />');
|
569
|
+
submit.html(settings.submit);
|
570
|
+
if (settings.submitcssclass) {
|
571
|
+
submit.addClass(settings.submitcssclass);
|
572
|
+
}
|
573
|
+
}
|
574
|
+
$(this).append(submit);
|
575
|
+
}
|
576
|
+
if (settings.cancel) {
|
577
|
+
var cancel;
|
578
|
+
/* If given html string use that. */
|
579
|
+
if (settings.cancel.match(/>$/)) {
|
580
|
+
cancel = $(settings.cancel);
|
581
|
+
/* otherwise use button with given string as text */
|
582
|
+
} else {
|
583
|
+
cancel = $('<button type="cancel" />');
|
584
|
+
cancel.html(settings.cancel);
|
585
|
+
if (settings.cancelcssclass) {
|
586
|
+
cancel.addClass(settings.cancelcssclass);
|
587
|
+
}
|
588
|
+
}
|
589
|
+
$(this).append(cancel);
|
590
|
+
|
591
|
+
$(cancel).click(function(event) {
|
592
|
+
var reset;
|
593
|
+
if ($.isFunction($.editable.types[settings.type].reset)) {
|
594
|
+
reset = $.editable.types[settings.type].reset;
|
595
|
+
} else {
|
596
|
+
reset = $.editable.types.defaults.reset;
|
597
|
+
}
|
598
|
+
reset.apply(form, [settings, original]);
|
599
|
+
return false;
|
600
|
+
});
|
601
|
+
}
|
602
|
+
}
|
603
|
+
},
|
604
|
+
text: {
|
605
|
+
element : function(settings, original) {
|
606
|
+
var input = $('<input />').attr({
|
607
|
+
autocomplete: 'off',
|
608
|
+
list: settings.list,
|
609
|
+
maxlength: settings.maxlength,
|
610
|
+
pattern: settings.pattern,
|
611
|
+
placeholder: settings.placeholder,
|
612
|
+
tooltip: settings.tooltip,
|
613
|
+
type: 'text'
|
614
|
+
});
|
615
|
+
|
616
|
+
if (settings.width !== 'none') {
|
617
|
+
input.css('width', settings.width);
|
618
|
+
}
|
619
|
+
|
620
|
+
if (settings.height !== 'none') {
|
621
|
+
input.css('height', settings.height);
|
622
|
+
}
|
623
|
+
|
624
|
+
if (settings.size) {
|
625
|
+
input.attr('size', settings.size);
|
626
|
+
}
|
627
|
+
|
628
|
+
if (settings.maxlength) {
|
629
|
+
input.attr('maxlength', settings.maxlength);
|
630
|
+
}
|
631
|
+
|
632
|
+
$(this).append(input);
|
633
|
+
return(input);
|
634
|
+
}
|
635
|
+
},
|
636
|
+
|
637
|
+
// TEXTAREA
|
638
|
+
textarea: {
|
639
|
+
element : function(settings, original) {
|
640
|
+
var textarea = $('<textarea></textarea>');
|
641
|
+
if (settings.rows) {
|
642
|
+
textarea.attr('rows', settings.rows);
|
643
|
+
} else if (settings.height !== 'none') {
|
644
|
+
textarea.height(settings.height);
|
645
|
+
}
|
646
|
+
if (settings.cols) {
|
647
|
+
textarea.attr('cols', settings.cols);
|
648
|
+
} else if (settings.width !== 'none') {
|
649
|
+
textarea.width(settings.width);
|
650
|
+
}
|
651
|
+
|
652
|
+
if (settings.maxlength) {
|
653
|
+
textarea.attr('maxlength', settings.maxlength);
|
654
|
+
}
|
655
|
+
|
656
|
+
$(this).append(textarea);
|
657
|
+
return(textarea);
|
658
|
+
}
|
659
|
+
},
|
660
|
+
|
661
|
+
// SELECT
|
662
|
+
select: {
|
663
|
+
element : function(settings, original) {
|
664
|
+
var select = $('<select />');
|
665
|
+
|
666
|
+
if (settings.multiple) {
|
667
|
+
select.attr('multiple', 'multiple');
|
668
|
+
}
|
669
|
+
|
670
|
+
$(this).append(select);
|
671
|
+
return(select);
|
672
|
+
},
|
673
|
+
content : function(data, settings, original) {
|
674
|
+
var json;
|
675
|
+
// If it is string assume it is json
|
676
|
+
if (String === data.constructor) {
|
677
|
+
json = JSON.parse(data);
|
678
|
+
} else {
|
679
|
+
// Otherwise assume it is a hash already
|
680
|
+
json = data;
|
681
|
+
}
|
682
|
+
|
683
|
+
// Create tuples for sorting
|
684
|
+
var tuples = [];
|
685
|
+
var key;
|
686
|
+
|
687
|
+
if (Array.isArray(json) && json.every(Array.isArray)) {
|
688
|
+
// Process list of tuples
|
689
|
+
tuples = json // JSON already contains list of [key, value]
|
690
|
+
json = {};
|
691
|
+
tuples.forEach(function(e) {
|
692
|
+
json[e[0]] = e[1]; // Recreate json object to comply with following code
|
693
|
+
});
|
694
|
+
} else {
|
695
|
+
// Process object
|
696
|
+
for (key in json) {
|
697
|
+
tuples.push([key, json[key]]); // Store: [key, value]
|
698
|
+
}
|
699
|
+
}
|
700
|
+
|
701
|
+
if (settings.sortselectoptions) {
|
702
|
+
// sort it
|
703
|
+
tuples.sort(function (a, b) {
|
704
|
+
a = a[1];
|
705
|
+
b = b[1];
|
706
|
+
return a < b ? -1 : (a > b ? 1 : 0);
|
707
|
+
});
|
708
|
+
}
|
709
|
+
// now add the options to our select
|
710
|
+
var option;
|
711
|
+
for (var i = 0; i < tuples.length; i++) {
|
712
|
+
key = tuples[i][0];
|
713
|
+
var value = tuples[i][1];
|
714
|
+
|
715
|
+
if (!json.hasOwnProperty(key)) {
|
716
|
+
continue;
|
717
|
+
}
|
718
|
+
|
719
|
+
if (key !== 'selected') {
|
720
|
+
option = $('<option />').val(key).append(value);
|
721
|
+
|
722
|
+
// add the selected prop if it's the same as original or if the key is 'selected'
|
723
|
+
if (json.selected === key || key === $.trim(original.revert)) {
|
724
|
+
$(option).prop('selected', 'selected');
|
725
|
+
}
|
726
|
+
|
727
|
+
$(this).find('select').append(option);
|
728
|
+
}
|
729
|
+
}
|
730
|
+
|
731
|
+
// submit on change if no submit button defined
|
732
|
+
if (!settings.submit) {
|
733
|
+
var form = this;
|
734
|
+
$(this).find('select').change(function() {
|
735
|
+
form.submit();
|
736
|
+
});
|
737
|
+
}
|
738
|
+
}
|
739
|
+
},
|
740
|
+
|
741
|
+
// NUMBER
|
742
|
+
number: {
|
743
|
+
element: function (settings, original) {
|
744
|
+
var input = $('<input />').attr({
|
745
|
+
maxlength: settings.maxlength,
|
746
|
+
placeholder: settings.placeholder,
|
747
|
+
min : settings.min,
|
748
|
+
max : settings.max,
|
749
|
+
step: settings.step,
|
750
|
+
tooltip: settings.tooltip,
|
751
|
+
type: _supportInType('number')
|
752
|
+
});
|
753
|
+
if (settings.width !== 'none') {
|
754
|
+
input.css('width', settings.width);
|
755
|
+
}
|
756
|
+
$(this).append(input);
|
757
|
+
return input;
|
758
|
+
}
|
759
|
+
},
|
760
|
+
|
761
|
+
// EMAIL
|
762
|
+
email: {
|
763
|
+
element: function (settings, original) {
|
764
|
+
var input = $('<input />').attr({
|
765
|
+
maxlength: settings.maxlength,
|
766
|
+
placeholder: settings.placeholder,
|
767
|
+
tooltip: settings.tooltip,
|
768
|
+
type: _supportInType('email')
|
769
|
+
});
|
770
|
+
if (settings.width !== 'none') {
|
771
|
+
input.css('width', settings.width);
|
772
|
+
}
|
773
|
+
$(this).append(input);
|
774
|
+
return input;
|
775
|
+
}
|
776
|
+
},
|
777
|
+
|
778
|
+
// URL
|
779
|
+
url: {
|
780
|
+
element: function (settings, original) {
|
781
|
+
var input = $('<input />').attr({
|
782
|
+
maxlength: settings.maxlength,
|
783
|
+
pattern: settings.pattern,
|
784
|
+
placeholder: settings.placeholder,
|
785
|
+
tooltip: settings.tooltip,
|
786
|
+
type: _supportInType('url')
|
787
|
+
});
|
788
|
+
if (settings.width !== 'none') {
|
789
|
+
input.css('width', settings.width);
|
790
|
+
}
|
791
|
+
$(this).append(input);
|
792
|
+
return input;
|
793
|
+
}
|
794
|
+
}
|
795
|
+
},
|
796
|
+
|
797
|
+
// add new input type
|
798
|
+
addInputType: function(name, input) {
|
799
|
+
$.editable.types[name] = input;
|
800
|
+
}
|
801
|
+
};
|
802
|
+
|
803
|
+
/* Publicly accessible defaults. */
|
804
|
+
$.fn.editable.defaults = {
|
805
|
+
name : 'value',
|
806
|
+
id : 'id',
|
807
|
+
type : 'text',
|
808
|
+
width : 'auto',
|
809
|
+
height : 'auto',
|
810
|
+
// Keyboard accessibility - use mouse click OR press any key to enable editing
|
811
|
+
event : 'click.editable keydown.editable',
|
812
|
+
onblur : 'cancel',
|
813
|
+
tooltip : 'Click to edit',
|
814
|
+
loadtype : 'GET',
|
815
|
+
loadtext : 'Loading...',
|
816
|
+
placeholder: 'Click to edit',
|
817
|
+
sortselectoptions: false,
|
818
|
+
loaddata : {},
|
819
|
+
submitdata : {},
|
820
|
+
ajaxoptions: {}
|
821
|
+
};
|
822
|
+
|
823
|
+
})(jQuery);
|
@@ -0,0 +1,46 @@
|
|
1
|
+
/**
|
2
|
+
* Depends on Masked Input jQuery plugin by Josh Bush:
|
3
|
+
* http://digitalbush.com/projects/masked-input-plugin
|
4
|
+
*
|
5
|
+
* @file masked input plugin for jquery-jeditable
|
6
|
+
* @author Mika Tuupola, Nicolas CARPi
|
7
|
+
* @home https://github.com/NicolasCARPi/jquery_jeditable
|
8
|
+
* @licence MIT (see LICENCE file)
|
9
|
+
* @copyright © 2007 Mika Tuupola, Nicolas CARPi
|
10
|
+
* @name PluginMaskedInput
|
11
|
+
*/
|
12
|
+
'use strict';
|
13
|
+
(function ($) {
|
14
|
+
$.editable.addInputType('masked', {
|
15
|
+
element : function(settings, original) {
|
16
|
+
var input = $('<input />').attr({
|
17
|
+
autocomplete: 'off',
|
18
|
+
list: settings.list,
|
19
|
+
maxlength: settings.maxlength,
|
20
|
+
pattern: settings.pattern,
|
21
|
+
placeholder: settings.placeholder,
|
22
|
+
tooltip: settings.tooltip,
|
23
|
+
type: 'text'
|
24
|
+
}).mask(settings.mask);
|
25
|
+
|
26
|
+
if (settings.width !== 'none') {
|
27
|
+
input.css('width', settings.width);
|
28
|
+
}
|
29
|
+
|
30
|
+
if (settings.height !== 'none') {
|
31
|
+
input.css('height', settings.height);
|
32
|
+
}
|
33
|
+
|
34
|
+
if (settings.size) {
|
35
|
+
input.attr('size', settings.size);
|
36
|
+
}
|
37
|
+
|
38
|
+
if (settings.maxlength) {
|
39
|
+
input.attr('maxlength', settings.maxlength);
|
40
|
+
}
|
41
|
+
|
42
|
+
$(this).append(input);
|
43
|
+
return(input);
|
44
|
+
}
|
45
|
+
});
|
46
|
+
})(jQuery);
|
@@ -0,0 +1,71 @@
|
|
1
|
+
/**
|
2
|
+
* @file timepicker plugin for jquery-jeditable
|
3
|
+
* @author Mika Tuupola, Nicolas CARPi
|
4
|
+
* @home https://github.com/NicolasCARPi/jquery_jeditable
|
5
|
+
* @licence MIT (see LICENCE file)
|
6
|
+
* @copyright © 2007 Mika Tuupola, Nicolas CARPi
|
7
|
+
* @name PluginTimepicker
|
8
|
+
*/
|
9
|
+
'use strict';
|
10
|
+
(function ($) {
|
11
|
+
$.editable.addInputType('time', {
|
12
|
+
/* Create input element. */
|
13
|
+
element : function(settings, original) {
|
14
|
+
/* Create and pulldowns for hours and minutes. Append them to */
|
15
|
+
/* form which is accessible as variable this. */
|
16
|
+
var hourselect = $('<select id="hour_" />');
|
17
|
+
var minselect = $('<select id="min_" />');
|
18
|
+
|
19
|
+
var option;
|
20
|
+
|
21
|
+
for (var hour=0; hour <= 23; hour++) {
|
22
|
+
if (hour < 10) {
|
23
|
+
hour = '0' + hour;
|
24
|
+
}
|
25
|
+
option = $('<option />').val(hour).append(hour);
|
26
|
+
hourselect.append(option);
|
27
|
+
}
|
28
|
+
$(this).append(hourselect);
|
29
|
+
|
30
|
+
for (var min=0; min <= 45; min = parseInt(min, 10) + 15) {
|
31
|
+
if (min < 10) {
|
32
|
+
min = '0' + min;
|
33
|
+
}
|
34
|
+
option = $('<option />').val(min).append(min);
|
35
|
+
minselect.append(option);
|
36
|
+
}
|
37
|
+
$(this).append(minselect);
|
38
|
+
|
39
|
+
/* Last create an hidden input. This is returned to plugin. It will */
|
40
|
+
/* later hold the actual value which will be submitted to server. */
|
41
|
+
var hidden = $('<input type="hidden" />');
|
42
|
+
$(this).append(hidden);
|
43
|
+
return(hidden);
|
44
|
+
},
|
45
|
+
/* Set content / value of previously created input element. */
|
46
|
+
content : function(string, settings, original) {
|
47
|
+
/* Select correct hour and minute in pulldowns. */
|
48
|
+
var hour = parseInt(string.substr(0,2), 10);
|
49
|
+
var min = parseInt(string.substr(3,2), 10);
|
50
|
+
|
51
|
+
$('#hour_', this).children().each(function() {
|
52
|
+
if (hour === $(this).val()) {
|
53
|
+
$(this).attr('selected', 'selected');
|
54
|
+
}
|
55
|
+
});
|
56
|
+
$('#min_', this).children().each(function() {
|
57
|
+
if (min === $(this).val()) {
|
58
|
+
$(this).attr('selected', 'selected');
|
59
|
+
}
|
60
|
+
});
|
61
|
+
|
62
|
+
},
|
63
|
+
/* Call before submit hook. */
|
64
|
+
submit: function (settings, original) {
|
65
|
+
/* Take values from hour and minute pulldowns. Create string such as */
|
66
|
+
/* 13:45 from them. Set value of the hidden input field to this string. */
|
67
|
+
var value = $('#hour_').val() + ':' + $('#min_').val();
|
68
|
+
$('input', this).val(value);
|
69
|
+
}
|
70
|
+
});
|
71
|
+
})(jQuery);
|
@@ -3,4 +3,9 @@
|
|
3
3
|
//= require themes/metronic/theme/vendors.bundle.js
|
4
4
|
//= require jquery-ui
|
5
5
|
//= require common/datatables/datatables.js
|
6
|
+
//= require common/jquery-jeditable/jquery.jeditable.js
|
7
|
+
//= require common/jquery-jeditable/jquery.datepicker.js
|
8
|
+
//= require common/jquery-jeditable/jquery.checkbox.js
|
9
|
+
//= require common/jquery-jeditable/jquery.masked.js
|
10
|
+
//= require common/jquery-jeditable/jquery.time.js
|
6
11
|
//= require rails_sortable
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phcthemes_admin_panel_pack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PHCDevworks
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -351,6 +351,13 @@ files:
|
|
351
351
|
- app/assets/javascripts/common/isotope/isotope.pkgd.js
|
352
352
|
- app/assets/javascripts/common/jquery-countdown/jquery.countdown.js
|
353
353
|
- app/assets/javascripts/common/jquery-filterizer/jquery.filterizr.min.js
|
354
|
+
- app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.autogrow.js
|
355
|
+
- app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.charcounter.js
|
356
|
+
- app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.checkbox.js
|
357
|
+
- app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.datepicker.js
|
358
|
+
- app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.js
|
359
|
+
- app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.masked.js
|
360
|
+
- app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.time.js
|
354
361
|
- app/assets/javascripts/common/jquery-jvectormap/jquery-jvectormap.js
|
355
362
|
- app/assets/javascripts/common/jquery-placeholder/jquery.placeholder.js
|
356
363
|
- app/assets/javascripts/common/jquery-slimscroll/jquery.slimscroll.js
|