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

@ -49,33 +49,31 @@ function getFiles() {
//common js files //common js files
var js = [ var js = [
'<banner:meta.banner>', forms+'editable-form.js',
forms+'editable-form.js', forms+'editable-form-utils.js',
forms+'editable-form-utils.js', containers+'editable-container.js',
containers+'editable-container.js', containers+'editable-inline.js',
containers+'editable-inline.js', lib+'element/editable-element.js',
lib+'element/editable-element.js', inputs+'abstract.js',
inputs+'abstract.js', inputs+'list.js',
inputs+'list.js', inputs+'text.js',
inputs+'text.js', inputs+'textarea.js',
inputs+'textarea.js', inputs+'select.js',
inputs+'select.js', inputs+'checklist.js',
inputs+'checklist.js', inputs+'html5types.js',
inputs+'html5types.js', inputs+'select2/select2.js',
inputs+'select2/select2.js', inputs+'combodate/lib/combodate.js',
inputs+'combodate/lib/combodate.js', inputs+'combodate/combodate.js'
inputs+'combodate/combodate.js'
]; ];
//common css files //common css files
var css = [ var css = [
'<banner:meta.banner>', forms+'editable-form.css',
forms+'editable-form.css', containers+'editable-container.css',
containers+'editable-container.css', lib+'element/editable-element.css'
lib+'element/editable-element.css'
]; ];
//create 'concat' config //create 'concat' and 'uglify' tasks
var task, folder, dest, concat_files = {}, min_files = {}; var task, folder, dest, concat_files = {}, min_files = {};
for(var k in config) { for(var k in config) {
folder = '<%= dist %>/'+k+'-editable/'; folder = '<%= dist %>/'+k+'-editable/';
@ -88,7 +86,7 @@ function getFiles() {
dest: dest+'.js' dest: dest+'.js'
}; };
min_files[task] = { min_files[task] = {
src: ['<banner:meta.banner>', '<config:concat.'+task+'.dest>'], src: ['<%= concat.'+task+'.dest %>'],
dest: dest + '.min.js' dest: dest + '.min.js'
}; };
@ -106,7 +104,14 @@ function getFiles() {
/*global module:false*/ /*global module:false*/
module.exports = function(grunt) { module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib'); grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-requirejs');
//version of jquery-ui datepicker to be copied into dist //version of jquery-ui datepicker to be copied into dist
var dp_ui_ver = '1.10.3'; var dp_ui_ver = '1.10.3';
@ -130,66 +135,75 @@ module.exports = function(grunt) {
//get js and css for different builds //get js and css for different builds
var files = getFiles(); var files = getFiles();
// Project configuration. var banner = '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> \n' +
grunt.initConfig({
pkg: '<json:package.json>',
dist: 'dist',
meta: {
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> \n' +
'* <%= pkg.description %>\n' + '* <%= pkg.description %>\n' +
'* <%= pkg.homepage %>\n' + '* <%= pkg.homepage %>\n' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' + '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */' ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n';
},
clean: ['<config:dist>'], files.concat_files.options = {banner: banner};
files.min_files.options = {banner: banner};
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
dist: 'dist',
clean: ['<%= dist %>'],
concat: files.concat_files, concat: files.concat_files,
min: files.min_files,
uglify: files.min_files,
qunit: { qunit: {
bootstrap: [ bootstrap2: {
options: {
urls: [
'http://localhost:8000/test/index.html?f=bootstrap&c=popup'+module, 'http://localhost:8000/test/index.html?f=bootstrap&c=popup'+module,
'http://localhost:8000/test/index.html?f=bootstrap&c=inline'+module 'http://localhost:8000/test/index.html?f=bootstrap&c=inline'+module
], ]
jqueryui: [ }
},
bootstrap3: {
options: {
urls: [
'http://localhost:8000/test/index.html?f=bs3&c=popup'+module,
'http://localhost:8000/test/index.html?f=bs3&c=inline'+module
]
}
},
jqueryui: {
options: {
urls:[
'http://localhost:8000/test/index.html?f=jqueryui&c=popup'+module, 'http://localhost:8000/test/index.html?f=jqueryui&c=popup'+module,
'http://localhost:8000/test/index.html?f=jqueryui&c=inline'+module 'http://localhost:8000/test/index.html?f=jqueryui&c=inline'+module
], ]
plain: [ }
},
plain: {
options: {
urls:[
'http://localhost:8000/test/index.html?f=plain&c=popup'+module, 'http://localhost:8000/test/index.html?f=plain&c=popup'+module,
'http://localhost:8000/test/index.html?f=plain&c=inline'+module 'http://localhost:8000/test/index.html?f=plain&c=inline'+module
], ]
}
},
//test all builds under several versions of jquery //test all builds under several versions of jquery
testover: qunit_testover testover: {
options: {
urls:qunit_testover
}
},
}, },
server: {
port: 8000, connect: {
base: '.' server: {
port: 8000,
base: '.'
}
}, },
lint: {
//TODO: lint tests files
//files: ['grunt.js', 'src/js/*.js', 'test/**/*.js']
files: ['grunt.js',
'src/editable-form/*.js',
'src/containers/*.js',
'src/element/*.js',
'src/inputs/*.js',
'src/inputs/date/*.js',
'src/inputs/dateui/*.js',
'src/inputs/datetime/*.js',
'src/inputs/combodate/*.js',
'src/inputs/select2/*.js',
'src/inputs-ext/address/*.js',
'src/inputs-ext/wysihtml5/*.js'
]
},
/*
watch: {
files: '<config:lint.files>',
tasks: 'lint qunit'
},
*/
jshint: { jshint: {
options: { options: {
curly: true, curly: true,
@ -203,11 +217,26 @@ module.exports = function(grunt) {
boss: true, boss: true,
eqnull: true, eqnull: true,
browser: true, browser: true,
evil: false evil: false,
globals: {
jQuery: true
},
}, },
globals: { js: [ 'Gruntfile.js',
jQuery: true 'src/editable-form/*.js',
} 'src/containers/*.js',
'src/element/*.js',
'src/inputs/*.js',
'src/inputs/date/*.js',
'src/inputs/dateui/*.js',
'src/inputs/datetime/*.js',
'src/inputs/combodate/*.js',
'src/inputs/select2/*.js',
'src/inputs-ext/address/*.js',
'src/inputs-ext/wysihtml5/*.js'
]
}, },
copy: { copy: {
dist: { dist: {
@ -238,22 +267,29 @@ module.exports = function(grunt) {
'<%= dist %>/jquery-editable/jquery-ui-datepicker/css/redmond/images/': 'src/inputs/dateui/jquery-ui-datepicker/css/redmond/images/**' '<%= dist %>/jquery-editable/jquery-ui-datepicker/css/redmond/images/': 'src/inputs/dateui/jquery-ui-datepicker/css/redmond/images/**'
} }
} }
}, }
uglify: {}
}); });
//test task //test task
grunt.registerTask('test', 'lint server qunit:bootstrap'); grunt.registerTask('test', ['jshint', 'connect', 'qunit:bootstrap2']);
grunt.registerTask('testall', 'lint server qunit:bootstrap qunit:jqueryui qunit:plain'); grunt.registerTask('testall', [
grunt.registerTask('testover', 'lint server qunit:testover'); 'jshint',
'connect',
'qunit:bootstrap2',
'qunit:bootstrap3',
'qunit:jqueryui',
'qunit:plain'
]);
grunt.registerTask('testover', ['jshint', 'connect', 'qunit:testover']);
// Default task. // Default task.
// grunt.registerTask('default', 'lint qunit'); grunt.registerTask('default', ['clean', 'jshint', 'concat', 'uglify', 'copy']);
grunt.registerTask('default', 'clean lint concat min copy');
grunt.registerTask('server', 'connect:server:keepalive');
// build // build
grunt.registerTask('build', 'clean lint concat min copy'); grunt.registerTask('build', ['clean', 'jshint', 'concat', 'uglify', 'copy']);
//to run particular task use ":", e.g. copy:libs //to run particular task use ":", e.g. copy:libs
}; };

4
dist/CHANGELOG.txt vendored

@ -1,6 +1,10 @@
X-editable changelog X-editable changelog
============================= =============================
Version 1.4.7 wip
----------------------------
Version 1.4.6 Aug 8, 2013 Version 1.4.6 Aug 8, 2013
---------------------------- ----------------------------
[bug #312] can't apply selector more than once (vitalets) [bug #312] can't apply selector more than once (vitalets)

@ -2,7 +2,6 @@
* In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery * In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery
* http://github.com/vitalets/x-editable * http://github.com/vitalets/x-editable
* Copyright (c) 2013 Vitaliy Potapov; Licensed MIT */ * Copyright (c) 2013 Vitaliy Potapov; Licensed MIT */
.editableform { .editableform {
margin-bottom: 0; /* overwrites bootstrap margin */ margin-bottom: 0; /* overwrites bootstrap margin */
} }

Before

(image error) Size: 509 B

After

(image error) Size: 509 B

Before

(image error) Size: 1.8 KiB

After

(image error) Size: 1.8 KiB

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

File diff suppressed because one or more lines are too long

@ -2,7 +2,6 @@
* In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery * In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery
* http://github.com/vitalets/x-editable * http://github.com/vitalets/x-editable
* Copyright (c) 2013 Vitaliy Potapov; Licensed MIT */ * Copyright (c) 2013 Vitaliy Potapov; Licensed MIT */
.editableform { .editableform {
margin-bottom: 0; /* overwrites bootstrap margin */ margin-bottom: 0; /* overwrites bootstrap margin */
} }

Before

(image error) Size: 509 B

After

(image error) Size: 509 B

Before

(image error) Size: 1.8 KiB

After

(image error) Size: 1.8 KiB

@ -2,7 +2,6 @@
* In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery * In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery
* http://github.com/vitalets/x-editable * http://github.com/vitalets/x-editable
* Copyright (c) 2013 Vitaliy Potapov; Licensed MIT */ * Copyright (c) 2013 Vitaliy Potapov; Licensed MIT */
/** /**
Form with single input element, two buttons and two states: normal/loading. 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. 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 //set initial value
//todo: may be add check: typeof str === 'string' ? //todo: may be add check: typeof str === 'string' ?
this.value = this.input.str2value(this.options.value); this.value = this.input.str2value(this.options.value);
//prerender: get input.$input
this.input.prerender();
}, },
initTemplate: function() { initTemplate: function() {
this.$form = $($.fn.editableform.template); this.$form = $($.fn.editableform.template);
@ -80,9 +82,8 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
this.initInput(); this.initInput();
//append input to form //append input to form
this.input.prerender();
this.$form.find('div.editable-input').append(this.input.$tpl); this.$form.find('div.editable-input').append(this.input.$tpl);
//append form to container //append form to container
this.$div.append(this.$form); 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 //error class attached to editable-error-block
$.fn.editableform.errorBlockClass = 'editable-error'; $.fn.editableform.errorBlockClass = 'editable-error';
//engine
$.fn.editableform.engine = 'jqeury';
}(window.jQuery)); }(window.jQuery));
/** /**
@ -898,6 +902,8 @@ Applied as jQuery method.
containerDataName: null, //object name in element's .data() containerDataName: null, //object name in element's .data()
innerCss: null, //tbd in child class innerCss: null, //tbd in child class
containerClass: 'editable-container editable-popup', //css class applied to container element containerClass: 'editable-container editable-popup', //css class applied to container element
defaults: {}, //container itself defaults
init: function(element, options) { init: function(element, options) {
this.$element = $(element); this.$element = $(element);
//since 1.4.1 container do not use data-* directly as they already merged into options. //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?'); 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 //keys defined in container defaults go to container, others go to form
for(var k in this.options) { for(var k in this.options) {
if(k in cDef) { if(k in this.defaults) {
this.containerOptions[k] = this.options[k]; this.containerOptions[k] = this.options[k];
} else { } else {
this.formOptions[k] = this.options[k]; 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 @since 1.4.5
@default #FFFF80 @default #FFFF80
**/ **/
highlight: '#FFFF80' highlight: '#FFFF80'
}; };
}(window.jQuery)); }(window.jQuery));
@ -2415,7 +2420,7 @@ To create your own input you can inherit from this class.
}, },
// -------- helper functions -------- // -------- helper functions --------
setClass: function() { setClass: function() {
if(this.options.inputclass) { if(this.options.inputclass) {
this.$input.addClass(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 @property inputclass
@type string @type string
@default input-medium @default null
**/ **/
inputclass: 'input-medium', inputclass: null,
//scope for external methods (e.g. source defined as function) //scope for external methods (e.g. source defined as function)
//for internal use only //for internal use only
scope: null, scope: null,
@ -3817,7 +3822,7 @@ $(function(){
@type string @type string
@default ', ' @default ', '
**/ **/
viewseparator: ', ' viewseparator: ', '
}); });
$.fn.editabletypes.select2 = Constructor; $.fn.editabletypes.select2 = Constructor;
@ -4343,7 +4348,14 @@ $(function(){
$.extend(Constructor.prototype, { $.extend(Constructor.prototype, {
render: function () { render: function () {
this.$input.combodate(this.options.combodate); 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 //"clear" link
/* /*
if(this.options.clear) { if(this.options.clear) {
@ -4479,6 +4491,7 @@ $(function(){
$.extend($.fn.editableContainer.Popup.prototype, { $.extend($.fn.editableContainer.Popup.prototype, {
containerName: 'poshytip', containerName: 'poshytip',
innerCss: 'div.tip-inner', innerCss: 'div.tip-inner',
defaults: $.fn.poshytip.defaults,
initContainer: function(){ initContainer: function(){
this.handlePlacement(); this.handlePlacement();

File diff suppressed because one or more lines are too long

@ -2,7 +2,6 @@
* In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery * In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery
* http://github.com/vitalets/x-editable * http://github.com/vitalets/x-editable
* Copyright (c) 2013 Vitaliy Potapov; Licensed MIT */ * Copyright (c) 2013 Vitaliy Potapov; Licensed MIT */
.editableform { .editableform {
margin-bottom: 0; /* overwrites bootstrap margin */ margin-bottom: 0; /* overwrites bootstrap margin */
} }

Before

(image error) Size: 509 B

After

(image error) Size: 509 B

Before

(image error) Size: 1.8 KiB

After

(image error) Size: 1.8 KiB

@ -2,7 +2,6 @@
* In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery * In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery
* http://github.com/vitalets/x-editable * http://github.com/vitalets/x-editable
* Copyright (c) 2013 Vitaliy Potapov; Licensed MIT */ * Copyright (c) 2013 Vitaliy Potapov; Licensed MIT */
/** /**
Form with single input element, two buttons and two states: normal/loading. 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. 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 //set initial value
//todo: may be add check: typeof str === 'string' ? //todo: may be add check: typeof str === 'string' ?
this.value = this.input.str2value(this.options.value); this.value = this.input.str2value(this.options.value);
//prerender: get input.$input
this.input.prerender();
}, },
initTemplate: function() { initTemplate: function() {
this.$form = $($.fn.editableform.template); this.$form = $($.fn.editableform.template);
@ -80,9 +82,8 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
this.initInput(); this.initInput();
//append input to form //append input to form
this.input.prerender();
this.$form.find('div.editable-input').append(this.input.$tpl); this.$form.find('div.editable-input').append(this.input.$tpl);
//append form to container //append form to container
this.$div.append(this.$form); 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 //error class attached to editable-error-block
$.fn.editableform.errorBlockClass = 'editable-error'; $.fn.editableform.errorBlockClass = 'editable-error';
//engine
$.fn.editableform.engine = 'jqeury';
}(window.jQuery)); }(window.jQuery));
/** /**
@ -898,6 +902,8 @@ Applied as jQuery method.
containerDataName: null, //object name in element's .data() containerDataName: null, //object name in element's .data()
innerCss: null, //tbd in child class innerCss: null, //tbd in child class
containerClass: 'editable-container editable-popup', //css class applied to container element containerClass: 'editable-container editable-popup', //css class applied to container element
defaults: {}, //container itself defaults
init: function(element, options) { init: function(element, options) {
this.$element = $(element); this.$element = $(element);
//since 1.4.1 container do not use data-* directly as they already merged into options. //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?'); 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 //keys defined in container defaults go to container, others go to form
for(var k in this.options) { for(var k in this.options) {
if(k in cDef) { if(k in this.defaults) {
this.containerOptions[k] = this.options[k]; this.containerOptions[k] = this.options[k];
} else { } else {
this.formOptions[k] = this.options[k]; 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 @since 1.4.5
@default #FFFF80 @default #FFFF80
**/ **/
highlight: '#FFFF80' highlight: '#FFFF80'
}; };
}(window.jQuery)); }(window.jQuery));
@ -2415,7 +2420,7 @@ To create your own input you can inherit from this class.
}, },
// -------- helper functions -------- // -------- helper functions --------
setClass: function() { setClass: function() {
if(this.options.inputclass) { if(this.options.inputclass) {
this.$input.addClass(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 @property inputclass
@type string @type string
@default input-medium @default null
**/ **/
inputclass: 'input-medium', inputclass: null,
//scope for external methods (e.g. source defined as function) //scope for external methods (e.g. source defined as function)
//for internal use only //for internal use only
scope: null, scope: null,
@ -3817,7 +3822,7 @@ $(function(){
@type string @type string
@default ', ' @default ', '
**/ **/
viewseparator: ', ' viewseparator: ', '
}); });
$.fn.editabletypes.select2 = Constructor; $.fn.editabletypes.select2 = Constructor;
@ -4343,7 +4348,14 @@ $(function(){
$.extend(Constructor.prototype, { $.extend(Constructor.prototype, {
render: function () { render: function () {
this.$input.combodate(this.options.combodate); 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 //"clear" link
/* /*
if(this.options.clear) { if(this.options.clear) {
@ -4495,6 +4507,8 @@ Editableform based on jQuery UI
//error classes //error classes
$.fn.editableform.errorGroupClass = null; $.fn.editableform.errorGroupClass = null;
$.fn.editableform.errorBlockClass = 'ui-state-error'; $.fn.editableform.errorBlockClass = 'ui-state-error';
//engine
$.fn.editableform.engine = 'jqeury-ui';
}(window.jQuery)); }(window.jQuery));
/** /**
@ -4511,6 +4525,7 @@ Editableform based on jQuery UI
//object name in element's .data() //object name in element's .data()
containerDataName: 'ui-tooltip', containerDataName: 'ui-tooltip',
innerCss: '.ui-tooltip-content', innerCss: '.ui-tooltip-content',
defaults: $.ui.tooltip.prototype.options,
//split options on containerOptions and formOptions //split options on containerOptions and formOptions
splitOptions: function() { splitOptions: function() {
@ -4522,10 +4537,10 @@ Editableform based on jQuery UI
$.error('Please use jQueryUI with "tooltip" widget! http://jqueryui.com/download'); $.error('Please use jQueryUI with "tooltip" widget! http://jqueryui.com/download');
return; return;
} }
//defaults for tooltip //defaults for tooltip
var cDef = $.ui[this.containerName].prototype.options;
for(var k in this.options) { for(var k in this.options) {
if(k in cDef) { if(k in this.defaults) {
this.containerOptions[k] = this.options[k]; this.containerOptions[k] = this.options[k];
} else { } else {
this.formOptions[k] = this.options[k]; this.formOptions[k] = this.options[k];

File diff suppressed because one or more lines are too long

@ -21,12 +21,17 @@
"url": "https://github.com/vitalets/x-editable/blob/master/LICENSE-MIT" "url": "https://github.com/vitalets/x-editable/blob/master/LICENSE-MIT"
} }
], ],
"dependencies": { "dependencies": {},
},
"devDependencies": { "devDependencies": {
"grunt": "~0.3.11", "grunt": "~0.4.1",
"grunt-contrib": "0.1.1" "grunt-contrib-clean": "~0.5.0",
}, "grunt-contrib-concat": "~0.3.0",
"grunt-contrib-uglify": "~0.2.2",
"grunt-contrib-qunit": "~0.2.2",
"grunt-contrib-connect": "~0.3.0",
"grunt-contrib-jshint": "~0.6.4",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-requirejs": "~0.4.1"
},
"keywords": [] "keywords": []
} }

@ -58,7 +58,7 @@
/** /**
* move popover to new position. This function mainly copied from bootstrap-popover. * move popover to new position. This function mainly copied from bootstrap-popover.
*/ */
/*jshint laxcomma: true*/ /*jshint laxcomma: true, eqeqeq: false*/
setPosition: function () { setPosition: function () {
(function() { (function() {
@ -192,7 +192,7 @@
}).call(this.container()); }).call(this.container());
/*jshint laxcomma: false*/ /*jshint laxcomma: false, eqeqeq: true*/
} }
}); });

@ -1,28 +1,27 @@
<!DOCTYPE HTML> <!DOCTYPE HTML>
<html lang="en"> <!DOCTYPE html>
<html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Test X-editable</title> <title>Test X-editable</title>
<script> <script>
window.onload = function() { window.onload = function() {
//console.log('onlonad');
QUnit.config.autostart = false; QUnit.config.autostart = false;
}; };
</script> </script>
<!-- <script data-main="main.js" src="require-jquery.js"></script>--> <!-- <script data-main="main.js" src="require-jquery.js"></script>-->
<script data-main="main.js" src="require.js"></script> <script data-main="main.js" src="require.js"></script>
<!-- qunit (should be included here, otherwise phantomjs hangs-up on several tests )--> <!-- qunit (should be included here, otherwise phantomjs hangs-up on several tests )-->
<link rel="stylesheet" href="libs/qunit/qunit-1.12.0.css" type="text/css" media="screen" /> <link rel="stylesheet" href="libs/qunit/qunit-1.12.0.css"/>
<script src="libs/qunit/qunit-1.12.0.js"></script>
</head> </head>
<body> <body>
<div> <div id="qunit"></div>
<div id="qunit"></div> <div id="qunit-fixture"></div>
<div id="qunit-fixture"></div> <div id="qunit-fixture1"></div>
<div id="qunit-fixture1"></div> <div id="async-fixture" style="padding-left:300px"></div>
<div id="async-fixture" style="padding-left:300px"></div> <script src="libs/qunit/qunit-1.12.0.js"></script>
</div>
</body> </body>
</html> </html>

@ -8,7 +8,7 @@ var jqver = decodeURIComponent((new RegExp('[?|&]' + 'jquery' + '=' + '([^&;]+?)
jqurl = jqver ? "http://code.jquery.com/jquery-"+jqver+".min.js" : "libs/jquery/jquery-1.9.1.min.js"; jqurl = jqver ? "http://code.jquery.com/jquery-"+jqver+".min.js" : "libs/jquery/jquery-1.9.1.min.js";
require(["loader", jqurl], function(loader) { require(["loader", jqurl], function(loader) {
var config = loader.getConfig("../src"), var config = loader.getConfig("../src"),
params = loader.getParams(); params = loader.getParams();