move dateui to folder, add jquery-ui-datepicker

This commit is contained in:
vitalets
2012-11-14 22:44:18 +04:00
parent 8a64d3fb28
commit 00a451278a
44 changed files with 3691 additions and 9517 deletions

View File

@@ -1,16 +1,19 @@
/**
* editable abstract type definition
* Every new type must implement this interface
* It does not store value or text. It just store settings and input
*/
Abstract editable input class.
To create your own input you should inherit from this class.
@class abstract
**/
(function ($) {
var Abstract = function () { };
Abstract.prototype = {
/**
* initialize settings
*/
Iinitializes input
@method init()
**/
init: function(type, options, defaults) {
this.type = type;
this.options = $.extend({}, defaults, options);
@@ -19,9 +22,10 @@
},
/**
* creates DOM element which is ready to be shown
* Can return jQuery deferred object
*/
Renders input. Can return jQuery deferred object.
@method render()
**/
render: function() {
this.$input = $(this.options.tpl);
if(this.options.inputclass) {
@@ -34,51 +38,74 @@
},
/**
* set element's html by value
*/
Sets element's html by value.
@method value2html(value, element)
@param {mixed} value
@param {DOMElement} element
**/
value2html: function(value, element) {
var html = $('<div>').text(value).html();
$(element).html(html);
},
/**
* returns value from element's html
*/
Converts element's html to value
@method html2value(html)
@param {string} html
@returns {mixed}
**/
html2value: function(html) {
return $('<div>').html(html).text();
},
/**
* convert value to string for submiting on server
*/
Converts value to string (for submiting to server)
@method value2str(value)
@param {mixed} value
@returns {string}
**/
value2str: function(value) {
return value;
},
/**
* convert string received from server (data-value or options.value) into value object
*/
Converts string received from server into value.
@method str2value(str)
@param {string} str
@returns {mixed}
**/
str2value: function(str) {
return str;
},
/**
* set value to input
*/
Sets value of input.
@method value2input(value)
@param {mixed} value
**/
value2input: function(value) {
this.$input.val(value);
},
/**
* returns value (object) by input
*/
Returns value of input. Value can be object (e.g. datepicker)
@method input2value()
**/
input2value: function() {
return this.$input.val();
},
/**
* method called to focus input again
*/
Activates input. For text it sets focus.
@method activate()
**/
activate: function() {
if(this.$input.is(':visible')) {
this.$input.focus();
@@ -86,11 +113,31 @@
}
};
Abstract.defaults = {
Abstract.defaults = {
/**
HTML template of input
@property tpl
@type string
@default ''
**/
tpl: '',
/**
CSS class automatically applied to input
@property inputclass
@type string
@default 'span2'
**/
inputclass: 'span2',
name: null,
placeholder: false
/**
Name attribute of input
@property name
@type string
@default null
**/
name: null
};
$.extend($.fn.editableform.types, {abstract: Abstract});

View File

@@ -1,7 +1,10 @@
/**
* jQuery UI Datepicker
* Note: you can not use both date and dateui on the one page!
*/
jQuery UI Datepicker
Note: you can not use both date and dateui on the same page.
@class dateui
@extends abstract
**/
(function ($) {
var DateUI = function (options) {
@@ -86,14 +89,48 @@
});
DateUI.defaults = $.extend({}, $.fn.editableform.types.abstract.defaults, {
/**
@property tpl
@default <div style="float: left"></div>
**/
tpl:'<div style="float: left"></div>',
/**
@property inputclass
@default ''
**/
inputclass: '',
format:'yyyy-mm-dd', //format used for sending to server and converting from value
viewformat: null, //used for display date in element
/**
Format used for sending value to server. Also applied when converting date from <code>data-value</code> attribute.<br>
Full <a href="http://docs.jquery.com/UI/Datepicker/formatDate">list of tokens</a>.
//special options
firstDay: 0,
datepicker:{
@property format
@type string
@default yyyy-mm-dd
**/
format:'yyyy-mm-dd',
/**
Format used for displaying date. If not specified equals to <code>format</code>
@property viewformat
@type string
@default null
**/
viewformat: null,
/**
Configuration of datepicker.
Full list of <a href="http://api.jqueryui.com/datepicker">possible options</a>.
@property datepicker
@type object
@default {
firstDay: 0,
changeYear: true,
changeMonth: true
}
**/
datepicker: {
firstDay: 0,
changeYear: true,
changeMonth: true
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,9 @@
/**
* select
*/
Select input
@class select
@extends abstract
**/
(function ($) {
var Select = function (options) {
@@ -213,9 +216,38 @@
});
Select.defaults = $.extend({}, $.fn.editableform.types.abstract.defaults, {
/**
@property tpl
@default <select></select>
**/
tpl:'<select></select>',
source:null, //can be string (url), object or array [{value: 1, text: 'abc'}, {...}]
/**
Source data for dropdown list. If string - considered ajax url to load items. Otherwise should be an array.
Array format is: <code>[{value: 1, text: "text"}, {...}]</code><br>
For compability it also supports format <code>{value1: text1, value2: text2 ...}</code> but it does not guarantee elements order.
@property source
@type string|array|object
@default null
@example
source: 'groups.php'
**/
source:null,
/**
Data automatically prepended to the begining of dropdown list.
@property prepend
@type string|array|object
@default false
**/
prepend:false,
/**
Error message shown when list cannot be loaded (e.g. ajax error)
@property sourceError
@type string
@default Error when loading options
**/
sourceError: 'Error when loading options'
});

View File

@@ -1,6 +1,9 @@
/**
* text
*/
Text input
@class text
@extends abstract
**/
(function ($) {
var Text = function (options) {
this.init('text', options, Text.defaults);
@@ -18,9 +21,21 @@
});
Text.defaults = $.extend({}, $.fn.editableform.types.abstract.defaults, {
tpl: '<input type="text">'
/**
@property tpl
@default <input type="text">
**/
tpl: '<input type="text">',
/**
Placeholder attribute of input. Shown when input is empty.
@property placeholder
@type string
@default null
**/
placeholder: null
});
$.fn.editableform.types.text = Text;
}(window.jQuery));
}(window.jQuery));

View File

@@ -1,6 +1,10 @@
/**
* textarea
*/
Textarea input
@class textarea
@extends abstract
@module inputs
**/
(function ($) {
var Textarea = function (options) {
@@ -53,8 +57,24 @@
});
Textarea.defaults = $.extend({}, $.fn.editableform.types.abstract.defaults, {
/**
@property tpl
@default <textarea rows="8"></textarea>
**/
tpl:'<textarea rows="8"></textarea>',
inputclass:'span3'
/**
@property inputclass
@default 'span3'
**/
inputclass:'span3',
/**
Placeholder attribute of input. Shown when input is empty.
@property placeholder
@type string
@default null
**/
placeholder: null
});
$.fn.editableform.types.textarea = Textarea;