1
0
Fork 0
mirror of https://github.com/twbs/bootstrap.git synced 2022-11-09 12:25:43 -05:00

grunt test-js, grunt dist-js now working

This commit is contained in:
fat 2015-05-12 16:52:54 -07:00
parent a58febf71a
commit ab1578465a
23 changed files with 3048 additions and 2122 deletions

View file

@ -56,12 +56,25 @@ module.exports = function (grunt) {
docs: 'docs/dist'
},
// JS build configuration
lineremover: {
es6Import: {
files: {
'<%= concat.bootstrap.dest %>': '<%= concat.bootstrap.dest %>'
},
options: {
exclusionPattern: /^(import|export)/g
}
}
},
babel: {
src: {
options: {
sourceMap: true,
modules: 'ignore'
},
dist: {
files: {
'js/dist/util.js' : 'js/src/util.js',
'js/dist/alert.js' : 'js/src/alert.js',
@ -75,6 +88,14 @@ module.exports = function (grunt) {
'js/dist/tooltip.js' : 'js/src/tooltip.js',
'js/dist/popover.js' : 'js/src/popover.js'
}
},
dist: {
options: {
modules: 'ignore'
},
files: {
'<%= concat.bootstrap.dest %>' : '<%= concat.bootstrap.dest %>'
}
}
},
@ -86,9 +107,6 @@ module.exports = function (grunt) {
src: ['Gruntfile.js', 'grunt/*.js']
},
core: {
src: 'js/*.js'
},
es6: {
src: 'js/src/*.js'
},
test: {
@ -102,24 +120,35 @@ module.exports = function (grunt) {
}
},
stamp: {
options: {
banner: '<%= banner %>\n<%= jqueryCheck %>\n<%= jqueryVersionCheck %>\n+function ($) {\n',
footer: '\n}(jQuery);'
},
bootstrap: {
files: {
src: '<%= concat.bootstrap.dest %>'
}
}
},
concat: {
options: {
banner: '<%= banner %>\n<%= jqueryCheck %>\n<%= jqueryVersionCheck %>',
stripBanners: false
},
bootstrap: {
src: [
'js/transition.js',
'js/alert.js',
'js/button.js',
'js/carousel.js',
'js/collapse.js',
'js/dropdown.js',
'js/modal.js',
'js/tooltip.js',
'js/popover.js',
'js/scrollspy.js',
'js/tab.js'
'js/src/util.js',
'js/src/alert.js',
'js/src/button.js',
'js/src/carousel.js',
'js/src/collapse.js',
'js/src/dropdown.js',
'js/src/modal.js',
'js/src/scrollspy.js',
'js/src/tab.js',
'js/src/tooltip.js',
'js/src/popover.js'
],
dest: 'dist/js/<%= pkg.name %>.js'
}
@ -154,6 +183,9 @@ module.exports = function (grunt) {
files: 'js/tests/index.html'
},
// CSS build configuration
scsslint: {
scss: ['scss/*.scss', '!scss/_normalize.scss'],
options: {
@ -401,7 +433,7 @@ module.exports = function (grunt) {
grunt.registerTask('test-js', ['jscs:core', 'jscs:test', 'jscs:grunt', 'qunit']);
// JS distribution task.
grunt.registerTask('dist-js', ['concat', 'uglify:core', 'commonjs']);
grunt.registerTask('dist-js', ['concat', 'lineremover', 'babel:dist', 'stamp', 'uglify:core', 'commonjs']);
grunt.registerTask('test-scss', ['scsslint:scss']);

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

22
dist/js/npm.js vendored
View file

@ -1,12 +1,12 @@
// This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.
require('../../js/transition.js')
require('../../js/alert.js')
require('../../js/button.js')
require('../../js/carousel.js')
require('../../js/collapse.js')
require('../../js/dropdown.js')
require('../../js/modal.js')
require('../../js/tooltip.js')
require('../../js/popover.js')
require('../../js/scrollspy.js')
require('../../js/tab.js')
require('../../js/src/util.js')
require('../../js/src/alert.js')
require('../../js/src/button.js')
require('../../js/src/carousel.js')
require('../../js/src/collapse.js')
require('../../js/src/dropdown.js')
require('../../js/src/modal.js')
require('../../js/src/scrollspy.js')
require('../../js/src/tab.js')
require('../../js/src/tooltip.js')
require('../../js/src/popover.js')

6
js/dist/carousel.js vendored
View file

@ -133,7 +133,7 @@ var Carousel = (function ($) {
}
if (this._config.interval && !this._isPaused) {
this._interval = setInterval(this.next.bind(this), this._config.interval);
this._interval = setInterval($.proxy(this.next, this), this._config.interval);
}
}
}, {
@ -173,11 +173,11 @@ var Carousel = (function ($) {
value: function _addEventListeners() {
if (this._config.keyboard) {
$(this._element).on('keydown.bs.carousel', this._keydown.bind(this));
$(this._element).on('keydown.bs.carousel', $.proxy(this._keydown, this));
}
if (this._config.pause == 'hover' && !('ontouchstart' in document.documentElement)) {
$(this._element).on('mouseenter.bs.carousel', this.pause.bind(this)).on('mouseleave.bs.carousel', this.cycle.bind(this));
$(this._element).on('mouseenter.bs.carousel', $.proxy(this.pause, this)).on('mouseleave.bs.carousel', $.proxy(this.cycle, this));
}
}
}, {

File diff suppressed because one or more lines are too long

8
js/dist/modal.js vendored
View file

@ -114,7 +114,7 @@ var Modal = (function ($) {
this._setEscapeEvent();
this._setResizeEvent();
$(this._element).on(Event.DISMISS, Selector.DATA_DISMISS, this.hide.bind(this));
$(this._element).on(Event.DISMISS, Selector.DATA_DISMISS, $.proxy(this.hide, this));
$(this._dialog).on(Event.MOUSEDOWN, function () {
$(_this._element).one(Event.MOUSEUP, function (event) {
@ -124,7 +124,7 @@ var Modal = (function ($) {
});
});
this._showBackdrop(this._showElement.bind(this, relatedTarget));
this._showBackdrop($.proxy(this._showElement, this, relatedTarget));
}
}, {
key: 'hide',
@ -155,7 +155,7 @@ var Modal = (function ($) {
if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)) {
$(this._element).one(Util.TRANSITION_END, this._hideModal.bind(this)).emulateTransitionEnd(TRANSITION_DURATION);
$(this._element).one(Util.TRANSITION_END, $.proxy(this._hideModal, this)).emulateTransitionEnd(TRANSITION_DURATION);
} else {
this._hideModal();
}
@ -232,7 +232,7 @@ var Modal = (function ($) {
key: '_setResizeEvent',
value: function _setResizeEvent() {
if (this._isShown) {
$(window).on(Event.RESIZE, this._handleUpdate.bind(this));
$(window).on(Event.RESIZE, $.proxy(this._handleUpdate, this));
} else {
$(window).off(Event.RESIZE);
}

File diff suppressed because one or more lines are too long

2
js/dist/popover.js vendored
View file

@ -85,7 +85,7 @@ var Popover = (function ($) {
}, {
key: 'getTipElement',
value: function getTipElement() {
return this.tip = this.tip || $(this.config['template'])[0];
return this.tip = this.tip || $(this.config.template)[0];
}
}, {
key: 'setContent',

File diff suppressed because one or more lines are too long

View file

@ -64,7 +64,7 @@ var ScrollSpy = (function ($) {
this._activeTarget = null;
this._scrollHeight = 0;
$(this._scrollElement).on(Event.SCROLL, this._process.bind(this));
$(this._scrollElement).on(Event.SCROLL, $.proxy(this._process, this));
this.refresh();
this._process();

File diff suppressed because one or more lines are too long

2
js/dist/tab.js vendored
View file

@ -143,7 +143,7 @@ var Tab = (function ($) {
var active = $(container).find(Selector.ACTIVE_CHILD)[0];
var isTransitioning = callback && Util.supportsTransitionEnd() && (active && $(active).hasClass(ClassName.FADE) || !!$(container).find(Selector.FADE_CHILD)[0]);
var complete = this._transitionComplete.bind(this, element, active, isTransitioning, callback);
var complete = $.proxy(this._transitionComplete, this, element, active, isTransitioning, callback);
if (active && isTransitioning) {
$(active).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION);

2
js/dist/tab.js.map vendored

File diff suppressed because one or more lines are too long

7
js/dist/tooltip.js vendored
View file

@ -71,7 +71,8 @@ var Tooltip = (function ($) {
var Selector = {
TOOLTIP: '.tooltip',
TOOLTIP_INNER: '.tooltip-inner' };
TOOLTIP_INNER: '.tooltip-inner'
};
var TetherClass = {
element: false,
@ -339,12 +340,12 @@ var Tooltip = (function ($) {
triggers.forEach(function (trigger) {
if (trigger === 'click') {
$(_this4.element).on(_this4.constructor.Event.CLICK, _this4.config.selector, _this4.toggle.bind(_this4));
$(_this4.element).on(_this4.constructor.Event.CLICK, _this4.config.selector, $.proxy(_this4.toggle, _this4));
} else if (trigger !== Trigger.MANUAL) {
var eventIn = trigger == Trigger.HOVER ? _this4.constructor.Event.MOUSEENTER : _this4.constructor.Event.FOCUSIN;
var eventOut = trigger == Trigger.HOVER ? _this4.constructor.Event.MOUSELEAVE : _this4.constructor.Event.FOCUSOUT;
$(_this4.element).on(eventIn, _this4.config.selector, _this4._enter.bind(_this4)).on(eventOut, _this4.config.selector, _this4._leave.bind(_this4));
$(_this4.element).on(eventIn, _this4.config.selector, $.proxy(_this4._enter, _this4)).on(eventOut, _this4.config.selector, $.proxy(_this4._leave, _this4));
}
});

File diff suppressed because one or more lines are too long

View file

@ -139,7 +139,7 @@ const Carousel = (($) => {
if (this._config.interval && !this._isPaused) {
this._interval = setInterval(
this.next.bind(this), this._config.interval
$.proxy(this.next, this), this._config.interval
)
}
}
@ -177,14 +177,14 @@ const Carousel = (($) => {
_addEventListeners() {
if (this._config.keyboard) {
$(this._element)
.on('keydown.bs.carousel', this._keydown.bind(this))
.on('keydown.bs.carousel', $.proxy(this._keydown, this))
}
if (this._config.pause == 'hover' &&
!('ontouchstart' in document.documentElement)) {
$(this._element)
.on('mouseenter.bs.carousel', this.pause.bind(this))
.on('mouseleave.bs.carousel', this.cycle.bind(this))
.on('mouseenter.bs.carousel', $.proxy(this.pause, this))
.on('mouseleave.bs.carousel', $.proxy(this.cycle, this))
}
}

View file

@ -121,7 +121,7 @@ const Modal = (($) => {
$(this._element).on(
Event.DISMISS,
Selector.DATA_DISMISS,
this.hide.bind(this)
$.proxy(this.hide, this)
)
$(this._dialog).on(Event.MOUSEDOWN, () => {
@ -133,7 +133,7 @@ const Modal = (($) => {
})
this._showBackdrop(
this._showElement.bind(this, relatedTarget)
$.proxy(this._showElement, this, relatedTarget)
)
}
@ -166,7 +166,7 @@ const Modal = (($) => {
($(this._element).hasClass(ClassName.FADE))) {
$(this._element)
.one(Util.TRANSITION_END, this._hideModal.bind(this))
.one(Util.TRANSITION_END, $.proxy(this._hideModal, this))
.emulateTransitionEnd(TRANSITION_DURATION)
} else {
this._hideModal()
@ -241,7 +241,7 @@ const Modal = (($) => {
_setResizeEvent() {
if (this._isShown) {
$(window).on(Event.RESIZE, this._handleUpdate.bind(this))
$(window).on(Event.RESIZE, $.proxy(this._handleUpdate, this))
} else {
$(window).off(Event.RESIZE)
}

View file

@ -62,7 +62,7 @@ const ScrollSpy = (($) => {
this._activeTarget = null
this._scrollHeight = 0
$(this._scrollElement).on(Event.SCROLL, this._process.bind(this))
$(this._scrollElement).on(Event.SCROLL, $.proxy(this._process, this))
this.refresh()
this._process()

View file

@ -156,8 +156,14 @@ const Tab = (($) => {
&& ((active && $(active).hasClass(ClassName.FADE))
|| !!$(container).find(Selector.FADE_CHILD)[0])
let complete = this._transitionComplete.bind(
this, element, active, isTransitioning, callback)
let complete = $.proxy(
this._transitionComplete,
this,
element,
active,
isTransitioning,
callback
)
if (active && isTransitioning) {
$(active)

View file

@ -373,7 +373,7 @@ const Tooltip = (($) => {
$(this.element).on(
this.constructor.Event.CLICK,
this.config.selector,
this.toggle.bind(this)
$.proxy(this.toggle, this)
)
} else if (trigger !== Trigger.MANUAL) {
@ -388,12 +388,12 @@ const Tooltip = (($) => {
.on(
eventIn,
this.config.selector,
this._enter.bind(this)
$.proxy(this._enter, this)
)
.on(
eventOut,
this.config.selector,
this._leave.bind(this)
$.proxy(this._leave, this)
)
}
})

View file

@ -321,7 +321,7 @@ $(function () {
var $target = $('<a href="#" rel="tooltip" title="very very very very very very very very long tooltip in one line"/>')
.appendTo($container)
.bootstrapTooltip({
placement: 'right',
placement: 'right'
})
.bootstrapTooltip('show')

View file

@ -55,11 +55,13 @@
"grunt-html": "~4.0.1",
"grunt-jekyll": "~0.4.2",
"grunt-jscs": "~1.8.0",
"grunt-line-remover": "0.0.2",
"grunt-postcss": "^0.3.0",
"grunt-sass": "^1.0.0",
"grunt-saucelabs": "~8.6.0",
"grunt-scss-lint": "^0.3.4",
"grunt-sed": "~0.1.1",
"grunt-stamp": "^0.1.0",
"load-grunt-tasks": "~3.1.0",
"markdown-it": "^4.0.1",
"mq4-hover-shim": "^0.1.0",