migrate to grunt 0.4

This commit is contained in:
vitalets
2013-08-31 13:15:19 +04:00
parent 0c1ea90005
commit 0abd9831ae
50 changed files with 250 additions and 144 deletions

@ -2,7 +2,6 @@
* In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery
* http://github.com/vitalets/x-editable
* Copyright (c) 2013 Vitaliy Potapov; Licensed MIT */
/**
Form with single input element, two buttons and two states: normal/loading.
Applied as jQuery method to DIV tag (not to form tag!). This is because form can be in loading state when spinner shown.
@ -33,6 +32,9 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
//set initial value
//todo: may be add check: typeof str === 'string' ?
this.value = this.input.str2value(this.options.value);
//prerender: get input.$input
this.input.prerender();
},
initTemplate: function() {
this.$form = $($.fn.editableform.template);
@ -80,9 +82,8 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
this.initInput();
//append input to form
this.input.prerender();
this.$form.find('div.editable-input').append(this.input.$tpl);
//append form to container
this.$div.append(this.$form);
@ -620,6 +621,9 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
//error class attached to editable-error-block
$.fn.editableform.errorBlockClass = 'editable-error';
//engine
$.fn.editableform.engine = 'jqeury';
}(window.jQuery));
/**
@ -898,6 +902,8 @@ Applied as jQuery method.
containerDataName: null, //object name in element's .data()
innerCss: null, //tbd in child class
containerClass: 'editable-container editable-popup', //css class applied to container element
defaults: {}, //container itself defaults
init: function(element, options) {
this.$element = $(element);
//since 1.4.1 container do not use data-* directly as they already merged into options.
@ -975,10 +981,9 @@ Applied as jQuery method.
throw new Error(this.containerName + ' not found. Have you included corresponding js file?');
}
var cDef = $.fn[this.containerName].defaults;
//keys defined in container defaults go to container, others go to form
for(var k in this.options) {
if(k in cDef) {
if(k in this.defaults) {
this.containerOptions[k] = this.options[k];
} else {
this.formOptions[k] = this.options[k];
@ -2249,7 +2254,7 @@ Makes editable any HTML element on the page. Applied as jQuery method.
@since 1.4.5
@default #FFFF80
**/
highlight: '#FFFF80'
highlight: '#FFFF80'
};
}(window.jQuery));
@ -2415,7 +2420,7 @@ To create your own input you can inherit from this class.
},
// -------- helper functions --------
setClass: function() {
setClass: function() {
if(this.options.inputclass) {
this.$input.addClass(this.options.inputclass);
}
@ -2447,9 +2452,9 @@ To create your own input you can inherit from this class.
@property inputclass
@type string
@default input-medium
@default null
**/
inputclass: 'input-medium',
inputclass: null,
//scope for external methods (e.g. source defined as function)
//for internal use only
scope: null,
@ -3817,7 +3822,7 @@ $(function(){
@type string
@default ', '
**/
viewseparator: ', '
viewseparator: ', '
});
$.fn.editabletypes.select2 = Constructor;
@ -4343,7 +4348,14 @@ $(function(){
$.extend(Constructor.prototype, {
render: function () {
this.$input.combodate(this.options.combodate);
if($.fn.editableform.engine === 'bs3') {
this.$input.siblings().find('select').addClass('form-control');
}
if(this.options.inputclass) {
this.$input.siblings().find('select').addClass(this.options.inputclass);
}
//"clear" link
/*
if(this.options.clear) {
@ -4468,15 +4480,33 @@ $(function(){
}(window.jQuery));
/*
Editableform based on Twitter Bootstrap
Editableform based on Twitter Bootstrap 2
*/
(function ($) {
"use strict";
//store parent methods
var pInitInput = $.fn.editableform.Constructor.prototype.initInput;
$.extend($.fn.editableform.Constructor.prototype, {
initTemplate: function() {
this.$form = $($.fn.editableform.template);
this.$form.find('.editable-error-block').addClass('help-block');
},
initInput: function() {
pInitInput.apply(this);
//for bs2 set default class `input-medium` to standard inputs
var emptyInputClass = this.input.options.inputclass === null || this.input.options.inputclass === false;
var defaultClass = 'input-medium';
//add bs2 default class to standard inputs
//if(this.input.$input.is('input,select,textarea')) {
var stdtypes = 'text,select,textarea,password,email,url,tel,number,range,time'.split(',');
if(~$.inArray(this.input.type, stdtypes) && emptyInputClass) {
this.input.options.inputclass = defaultClass;
this.input.$input.addClass(defaultClass);
}
}
});
@ -4486,7 +4516,9 @@ Editableform based on Twitter Bootstrap
//error classes
$.fn.editableform.errorGroupClass = 'error';
$.fn.editableform.errorBlockClass = null;
$.fn.editableform.errorBlockClass = null;
//engine
$.fn.editableform.engine = 'bs2';
}(window.jQuery));
/**
@ -4502,13 +4534,14 @@ Editableform based on Twitter Bootstrap
containerName: 'popover',
//for compatibility with bootstrap <= 2.2.1 (content inserted into <p> instead of directly .popover-content)
innerCss: $.fn.popover && $($.fn.popover.defaults.template).find('p').length ? '.popover-content p' : '.popover-content',
defaults: $.fn.popover.defaults,
initContainer: function(){
$.extend(this.containerOptions, {
trigger: 'manual',
selector: false,
content: ' ',
template: $.fn.popover.defaults.template
template: this.defaults.template
});
//as template property is used in inputs, hide it from popover

File diff suppressed because one or more lines are too long