0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-01-18 10:52:19 +01:00

Merge branch 'v4-dev' into v4-media-breakpoint-between

This commit is contained in:
David Baughman 2015-08-27 13:41:24 -07:00
commit e481c8fff2
44 changed files with 1261 additions and 631 deletions

View File

@ -7,7 +7,6 @@ node_js:
before_install:
- travis_retry pip install -r test-infra/requirements.txt --user
- rvm install 2.0.0 && rvm use 2.0.0
- export GEMDIR=$(rvm gemdir)
- "export TRAVIS_COMMIT_MSG=\"$(git log --format=%B --no-merges -n 1)\""
- echo "$TRAVIS_COMMIT_MSG" | grep '\[skip validator\]'; export TWBS_DO_VALIDATOR=$?; true
- echo "$TRAVIS_COMMIT_MSG" | grep '\[skip sauce\]'; export TWBS_DO_SAUCE=$?; true
@ -23,8 +22,6 @@ cache:
- vendor/bundle
env:
global:
- JEKYLL_VERSION="2.5.3"
- ROUGE_VERSION="1.8.0"
- SAUCE_USERNAME="bootstrap"
- secure: "pJkBwnuae9dKU5tEcCqccfS1QQw7/meEcfz63fM7ba7QJNjoA6BaXj08L5Z3Vb5vBmVPwBawxo5Hp0jC0r/Z/O0hGnAmz/Cz09L+cy7dSAZ9x4hvZePSja/UAusaB5ogMoO8l2b773MzgQeSmrLbExr9BWLeqEfjC2hFgdgHLaQ="
- secure: "gqjqISbxBJK6byFbsmr1AyP1qoWH+rap06A2gI7v72+Tn2PU2nYkIMUkCvhZw6K889jv+LhQ/ybcBxDOXHpNCExCnSgB4dcnmYp+9oeNZb37jSP0rQ+Ib4OTLjzc3/FawE/fUq5kukZTC7porzc/k0qJNLAZRx3YLALmK1GIdUY="

View File

@ -35,7 +35,7 @@ Our bug tracker utilizes several labels to help organize and identify issues. He
- `browser bug` - Issues that are reported to us, but actually are the result of a browser-specific bug. These are diagnosed with reduced test cases and result in an issue opened on that browser's own bug tracker.
- `confirmed` - Issues that have been confirmed with a reduced test case and identify a bug in Bootstrap.
- `css` - Issues stemming from our compiled CSS or source Less files.
- `css` - Issues stemming from our compiled CSS or source Sass files.
- `docs` - Issues for improving or updating our documentation.
- `examples` - Issues involving the example templates included in our docs.
- `feature` - Issues asking for a new feature to be added, or an existing one to be extended or modified. New features require a minor version bump (e.g., `v3.0.0` to `v3.1.0`).
@ -136,7 +136,7 @@ project (indentation, accurate comments, etc.) and any other requirements
**Do not edit `bootstrap.css`, `bootstrap-theme.css`, or `bootstrap.js`
directly!** Those files are automatically generated. You should edit the
source files in [`/bootstrap/less/`](https://github.com/twbs/bootstrap/tree/master/less)
source files in [`/bootstrap/scss/`](https://github.com/twbs/bootstrap/tree/master/scss)
and/or [`/bootstrap/js/`](https://github.com/twbs/bootstrap/tree/master/js) instead.
Similarly, when contributing to Bootstrap's documentation, you should edit the

View File

@ -4,9 +4,9 @@
source 'https://rubygems.org'
group :development, :test do
gem 'jekyll', '~> 2.5.2'
gem 'jekyll', '~> 2.5.3'
gem 'jekyll-redirect-from', '~> 0.8.0'
gem 'rouge', '~> 1.7.4'
gem 'sass', '~> 3.4.9'
gem 'scss-lint', '~> 0.31'
gem 'rouge', '~> 1.9.1'
gem 'sass', '~> 3.4.18'
gem 'scss_lint', '~> 0.41'
end

View File

@ -4,18 +4,18 @@ GEM
blankslate (2.1.2.4)
celluloid (0.16.0)
timers (~> 4.0.0)
classifier-reborn (2.0.2)
classifier-reborn (2.0.3)
fast-stemmer (~> 1.0)
coffee-script (2.3.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.8.0)
coffee-script-source (1.9.1.1)
colorator (0.1)
execjs (2.2.2)
execjs (2.6.0)
fast-stemmer (1.0.2)
ffi (1.9.6)
ffi (1.9.10)
hitimes (1.2.2)
jekyll (2.5.2)
jekyll (2.5.3)
classifier-reborn (~> 2.0)
colorator (~> 0.1)
jekyll-coffeescript (~> 1.0)
@ -32,53 +32,53 @@ GEM
toml (~> 0.1.0)
jekyll-coffeescript (1.0.1)
coffee-script (~> 2.2)
jekyll-gist (1.1.0)
jekyll-gist (1.3.3)
jekyll-paginate (1.1.0)
jekyll-redirect-from (0.8.0)
jekyll (>= 2.0)
jekyll-sass-converter (1.3.0)
sass (~> 3.2)
jekyll-watch (1.2.0)
jekyll-watch (1.2.1)
listen (~> 2.7)
kramdown (1.5.0)
liquid (2.6.1)
listen (2.8.4)
celluloid (>= 0.15.2)
kramdown (1.8.0)
liquid (2.6.3)
listen (2.10.1)
celluloid (~> 0.16.0)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
mercenary (0.3.5)
parslet (1.5.0)
blankslate (~> 2.0)
posix-spawn (0.3.9)
pygments.rb (0.6.0)
posix-spawn (0.3.11)
pygments.rb (0.6.3)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.1.0)
yajl-ruby (~> 1.2.0)
rainbow (2.0.0)
rb-fsevent (0.9.4)
rb-fsevent (0.9.5)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
redcarpet (3.2.2)
rouge (1.7.4)
redcarpet (3.3.2)
rouge (1.9.1)
safe_yaml (1.0.4)
sass (3.4.9)
scss-lint (0.31.0)
sass (3.4.18)
scss_lint (0.41.0)
rainbow (~> 2.0)
sass (~> 3.4.1)
sass (~> 3.4.15)
timers (4.0.1)
hitimes
toml (0.1.2)
parslet (~> 1.5.0)
yajl-ruby (1.1.0)
yajl-ruby (1.2.1)
PLATFORMS
ruby
DEPENDENCIES
jekyll (~> 2.5.2)
jekyll (~> 2.5.3)
jekyll-redirect-from (~> 0.8.0)
rouge (~> 1.7.4)
sass (~> 3.4.9)
scss-lint (~> 0.31)
rouge (~> 1.9.1)
sass (~> 3.4.18)
scss_lint (~> 0.41)
BUNDLED WITH
1.10.5
1.10.6

View File

@ -190,10 +190,6 @@ module.exports = function (grunt) {
src: '<%= concat.bootstrap.dest %>',
dest: 'dist/js/<%= pkg.name %>.min.js'
},
customize: {
src: configBridge.paths.customizerJs,
dest: 'docs/assets/js/customize.min.js'
},
docsJs: {
src: configBridge.paths.docsJs,
dest: 'docs/assets/js/docs.min.js'
@ -403,14 +399,6 @@ module.exports = function (grunt) {
exec: {
npmUpdate: {
command: 'npm update'
},
bundleUpdate: {
command: function () {
// Update dev gems and all the test gemsets
return 'bundle update && ' + glob.sync('test-infra/gemfiles/*.gemfile').map(function (gemfile) {
return 'BUNDLE_GEMFILE=' + gemfile + ' bundle update';
}).join(' && ');
}
}
},
@ -467,6 +455,7 @@ module.exports = function (grunt) {
runSubset('sauce-js-unit') &&
// Skip Sauce on Travis when [skip sauce] is in the commit message
isUndefOrNonZero(process.env.TWBS_DO_SAUCE)) {
testSubtasks.push('babel:dev');
testSubtasks.push('connect');
testSubtasks.push('saucelabs-qunit');
}
@ -474,7 +463,7 @@ module.exports = function (grunt) {
grunt.registerTask('test-js', ['eslint', 'jscs:core', 'jscs:test', 'jscs:grunt', 'qunit']);
// JS distribution task.
grunt.registerTask('dist-js', ['concat', 'lineremover', 'babel:dist', 'stamp', 'uglify:core', 'commonjs']);
grunt.registerTask('dist-js', ['babel:dev', 'concat', 'lineremover', 'babel:dist', 'stamp', 'uglify:core', 'commonjs']);
grunt.registerTask('test-scss', ['scsslint']);
@ -535,7 +524,4 @@ module.exports = function (grunt) {
done();
});
});
// Task for updating the cached RubyGem packages used by the Travis build (which are controlled by test-infra/Gemfile.lock).
// This task should be run and the updated file should be committed whenever Bootstrap's RubyGem dependencies change.
grunt.registerTask('update-gemfile-lock', ['exec:bundleUpdate']);
};

File diff suppressed because one or more lines are too long

View File

@ -3054,9 +3054,9 @@ var Tooltip = (function ($) {
value: function setContent() {
var tip = this.getTipElement();
var title = this.getTitle();
var method = this.config.html ? 'innerHTML' : 'innerText';
var method = this.config.html ? 'html' : 'text';
$(tip).find(Selector.TOOLTIP_INNER)[0][method] = title;
$(tip).find(Selector.TOOLTIP_INNER)[method](title);
$(tip).removeClass(ClassName.FADE).removeClass(ClassName.IN);
@ -3418,10 +3418,10 @@ var Popover = (function ($) {
var tip = this.getTipElement();
var title = this.getTitle();
var content = this._getContent();
var titleElement = $(tip).find(Selector.TITLE)[0];
var $titleElement = $(tip).find(Selector.TITLE);
if (titleElement) {
titleElement[this.config.html ? 'innerHTML' : 'innerText'] = title;
if ($titleElement) {
$titleElement[this.config.html ? 'html' : 'text'](title);
}
// we use append for html objects to maintain js events

File diff suppressed because one or more lines are too long

View File

@ -121,10 +121,10 @@
var tip = this.getTipElement();
var title = this.getTitle();
var content = this._getContent();
var titleElement = $(tip).find(Selector.TITLE)[0];
var $titleElement = $(tip).find(Selector.TITLE);
if (titleElement) {
titleElement[this.config.html ? 'innerHTML' : 'innerText'] = title;
if ($titleElement) {
$titleElement[this.config.html ? 'html' : 'text'](title);
}
// we use append for html objects to maintain js events

View File

@ -348,9 +348,9 @@
value: function setContent() {
var tip = this.getTipElement();
var title = this.getTitle();
var method = this.config.html ? 'innerHTML' : 'innerText';
var method = this.config.html ? 'html' : 'text';
$(tip).find(Selector.TOOLTIP_INNER)[0][method] = title;
$(tip).find(Selector.TOOLTIP_INNER)[method](title);
$(tip).removeClass(ClassName.FADE).removeClass(ClassName.IN);

View File

@ -2,58 +2,3 @@
code: zh
description: Bootstrap 中文文档
url: http://v4.bootcss.com/
- name: Danish
code: da
description: Bootstrap på Dansk
url: http://getbootstrap.dk/
- name: French
code: fr
description: Bootstrap en Français
url: http://www.oneskyapp.com/fr/docs/bootstrap/getting-started/
- name: German
code: de
description: Bootstrap auf Deutsch
url: http://holdirbootstrap.de/
- name: Italian
code: it
description: Bootstrap in Italiano
url: http://www.hackerstribe.com/guide/IT-bootstrap-3.1.1/
- name: Korean
code: ko
description: Bootstrap 한국어
url: http://bootstrapk.com/
- name: Brazilian Portuguese
code: pt-BR
description: Bootstrap em Português do Brasil
url: http://bootstrapbrasil.github.io/
- name: Russian
code: ru
description: Bootstrap по-русски
url: http://www.oneskyapp.com/ru/docs/bootstrap/
- name: Spanish
code: es
description: Bootstrap en Español
url: http://www.oneskyapp.com/es/docs/bootstrap/
- name: Turkish
code: tr
description: Türkçe Bootstrap
url: http://www.trbootstrap.com
- name: Ukrainian
code: uk
description: Bootstrap українською
url: http://twbs.docs.org.ua
- name: Vietnamese
code: vi
description: Bootstrap bằng tiếng Việt
url: http://getbootstrap.com.vn

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -25,7 +25,7 @@
// Detects the actual version of IE in use, even if it's in an older-IE emulation mode.
// IE JavaScript conditional compilation docs: https://msdn.microsoft.com/library/121hztk3%28v=vs.94%29.aspx
// @cc_on docs: https://msdn.microsoft.com/library/8ka90k2e%28v=vs.94%29.aspx
var jscriptVersion = new Function('/*@cc_on return @_jscript_version; @*/')() // jshint ignore:line
var jscriptVersion = new Function('/*@cc_on return @_jscript_version; @*/')()
if (jscriptVersion === undefined) {
return 11 // IE11+ not in emulation mode
}

View File

@ -1,196 +0,0 @@
/*!
* AnchorJS - v1.0.1 - 2015-05-15
* https://github.com/bryanbraun/anchorjs
* Copyright (c) 2015 Bryan Braun; Licensed MIT
*/
function AnchorJS(options) {
'use strict';
this.options = options || {};
this._applyRemainingDefaultOptions = function(opts) {
this.options.icon = this.options.hasOwnProperty('icon') ? opts.icon : '&#xe9cb'; // Accepts characters (and also URLs?), like '#', '¶', '❡', or '§'.
this.options.visible = this.options.hasOwnProperty('visible') ? opts.visible : 'hover'; // Also accepts 'always'
this.options.placement = this.options.hasOwnProperty('placement') ? opts.placement : 'right'; // Also accepts 'left'
this.options.class = this.options.hasOwnProperty('class') ? opts.class : ''; // Accepts any class name.
};
this._applyRemainingDefaultOptions(options);
this.add = function(selector) {
var elements,
elsWithIds,
idList,
elementID,
i,
roughText,
tidyText,
index,
count,
newTidyText,
readableID,
anchor,
div,
anchorNodes;
this._applyRemainingDefaultOptions(this.options);
// Provide a sensible default selector, if none is given.
if (!selector) {
selector = 'h1, h2, h3, h4, h5, h6';
} else if (typeof selector !== 'string') {
throw new Error('The selector provided to AnchorJS was invalid.');
}
elements = document.querySelectorAll(selector);
if (elements.length === 0) {
return false;
}
this._addBaselineStyles();
// We produce a list of existing IDs so we don't generate a duplicate.
elsWithIds = document.querySelectorAll('[id]');
idList = [].map.call(elsWithIds, function assign(el) {
return el.id;
});
for (i = 0; i < elements.length; i++) {
if (elements[i].hasAttribute('id')) {
elementID = elements[i].getAttribute('id');
} else {
roughText = elements[i].textContent;
// Refine it so it makes a good ID. Strip out non-safe characters, replace
// spaces with hyphens, truncate to 32 characters, and make toLowerCase.
//
// Example string: // '⚡⚡⚡ Unicode icons are cool--but don't belong in a URL.'
tidyText = roughText.replace(/[^\w\s-]/gi, '') // ' Unicode icons are cool--but dont belong in a URL'
.replace(/\s+/g, '-') // '-Unicode-icons-are-cool--but-dont-belong-in-a-URL'
.replace(/-{2,}/g, '-') // '-Unicode-icons-are-cool-but-dont-belong-in-a-URL'
.substring(0, 32) // '-Unicode-icons-are-cool-but-dont'
.replace(/^-+|-+$/gm, '') // 'Unicode-icons-are-cool-but-dont'
.toLowerCase(); // 'unicode-icons-are-cool-but-dont'
// Compare our generated ID to existing IDs (and increment it if needed)
// before we add it to the page.
newTidyText = tidyText;
count = 0;
do {
if (index !== undefined) {
newTidyText = tidyText + '-' + count;
}
// .indexOf is supported in IE9+.
index = idList.indexOf(newTidyText);
count += 1;
} while (index !== -1);
index = undefined;
idList.push(newTidyText);
// Assign it to our element.
// Currently the setAttribute element is only supported in IE9 and above.
elements[i].setAttribute('id', newTidyText);
elementID = newTidyText;
}
readableID = elementID.replace(/-/g, ' ');
anchor = '<a class="anchorjs-link ' + this.options.class + '" href="#' + elementID + '" aria-label="Anchor link for: ' + readableID + '" data-anchorjs-icon="' + this.options.icon + '"></a>';
div = document.createElement('div');
div.innerHTML = anchor;
anchorNodes = div.childNodes;
if (this.options.visible === 'always') {
anchorNodes[0].style.opacity = '1';
}
if (this.options.icon === '&#xe9cb') {
anchorNodes[0].style.fontFamily = 'anchorjs-icons';
anchorNodes[0].style.fontStyle = 'normal';
anchorNodes[0].style.fontVariant = 'normal';
anchorNodes[0].style.fontWeight = 'normal';
}
if (this.options.placement === 'left') {
anchorNodes[0].style.position = 'absolute';
anchorNodes[0].style.marginLeft = '-1em';
anchorNodes[0].style.paddingRight = '0.5em';
elements[i].insertBefore(anchorNodes[0], elements[i].firstChild);
} else { // if the option provided is `right` (or anything else).
anchorNodes[0].style.paddingLeft = '0.375em';
elements[i].appendChild(anchorNodes[0]);
}
}
return this;
};
this.remove = function(selector) {
var domAnchor,
elements = document.querySelectorAll(selector);
for (var i = 0; i < elements.length; i++) {
domAnchor = elements[i].querySelector('.anchorjs-link');
if (domAnchor) {
elements[i].removeChild(domAnchor);
}
}
return this;
};
this._addBaselineStyles = function() {
// We don't want to add global baseline styles if they've been added before.
if (document.head.querySelector('style.anchorjs') !== null) {
return;
}
var style = document.createElement('style'),
linkRule =
' .anchorjs-link {' +
' opacity: 0;' +
' text-decoration: none;' +
' -webkit-font-smoothing: antialiased;' +
' -moz-osx-font-smoothing: grayscale;' +
' }',
hoverRule =
' *:hover > .anchorjs-link,' +
' .anchorjs-link:focus {' +
' opacity: 1;' +
' }',
anchorjsLinkFontFace =
' @font-face {' +
' font-family: "anchorjs-icons";' +
' font-style: normal;' +
' font-weight: normal;' + // Icon from icomoon; 10px wide & 10px tall; 2 empty below & 4 above
' src: url(data:application/x-font-ttf;charset=utf-8;base64,AAEAAAALAIAAAwAwT1MvMg8SBTUAAAC8AAAAYGNtYXAWi9QdAAABHAAAAFRnYXNwAAAAEAAAAXAAAAAIZ2x5Zgq29TcAAAF4AAABNGhlYWQEZM3pAAACrAAAADZoaGVhBhUDxgAAAuQAAAAkaG10eASAADEAAAMIAAAAFGxvY2EAKACuAAADHAAAAAxtYXhwAAgAVwAAAygAAAAgbmFtZQ5yJ3cAAANIAAAB2nBvc3QAAwAAAAAFJAAAACAAAwJAAZAABQAAApkCzAAAAI8CmQLMAAAB6wAzAQkAAAAAAAAAAAAAAAAAAAABEAAAAAAAAAAAAAAAAAAAAABAAADpywPA/8AAQAPAAEAAAAABAAAAAAAAAAAAAAAgAAAAAAADAAAAAwAAABwAAQADAAAAHAADAAEAAAAcAAQAOAAAAAoACAACAAIAAQAg6cv//f//AAAAAAAg6cv//f//AAH/4xY5AAMAAQAAAAAAAAAAAAAAAQAB//8ADwABAAAAAAAAAAAAAgAANzkBAAAAAAEAAAAAAAAAAAACAAA3OQEAAAAAAQAAAAAAAAAAAAIAADc5AQAAAAACADEARAJTAsAAKwBUAAABIiYnJjQ/AT4BMzIWFxYUDwEGIicmND8BNjQnLgEjIgYPAQYUFxYUBw4BIwciJicmND8BNjIXFhQPAQYUFx4BMzI2PwE2NCcmNDc2MhcWFA8BDgEjARQGDAUtLXoWOR8fORYtLTgKGwoKCjgaGg0gEhIgDXoaGgkJBQwHdR85Fi0tOAobCgoKOBoaDSASEiANehoaCQkKGwotLXoWOR8BMwUFLYEuehYXFxYugC44CQkKGwo4GkoaDQ0NDXoaShoKGwoFBe8XFi6ALjgJCQobCjgaShoNDQ0NehpKGgobCgoKLYEuehYXAAEAAAABAACiToc1Xw889QALBAAAAAAA0XnFFgAAAADRecUWAAAAAAJTAsAAAAAIAAIAAAAAAAAAAQAAA8D/wAAABAAAAAAAAlMAAQAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAACAAAAAoAAMQAAAAAACgAUAB4AmgABAAAABQBVAAIAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAADgCuAAEAAAAAAAEADgAAAAEAAAAAAAIABwCfAAEAAAAAAAMADgBLAAEAAAAAAAQADgC0AAEAAAAAAAUACwAqAAEAAAAAAAYADgB1AAEAAAAAAAoAGgDeAAMAAQQJAAEAHAAOAAMAAQQJAAIADgCmAAMAAQQJAAMAHABZAAMAAQQJAAQAHADCAAMAAQQJAAUAFgA1AAMAAQQJAAYAHACDAAMAAQQJAAoANAD4YW5jaG9yanMtaWNvbnMAYQBuAGMAaABvAHIAagBzAC0AaQBjAG8AbgBzVmVyc2lvbiAxLjAAVgBlAHIAcwBpAG8AbgAgADEALgAwYW5jaG9yanMtaWNvbnMAYQBuAGMAaABvAHIAagBzAC0AaQBjAG8AbgBzYW5jaG9yanMtaWNvbnMAYQBuAGMAaABvAHIAagBzAC0AaQBjAG8AbgBzUmVndWxhcgBSAGUAZwB1AGwAYQByYW5jaG9yanMtaWNvbnMAYQBuAGMAaABvAHIAagBzAC0AaQBjAG8AbgBzRm9udCBnZW5lcmF0ZWQgYnkgSWNvTW9vbi4ARgBvAG4AdAAgAGcAZQBuAGUAcgBhAHQAZQBkACAAYgB5ACAASQBjAG8ATQBvAG8AbgAuAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==) format("truetype");' +
' }',
pseudoElContent =
' [data-anchorjs-icon]::after {' +
' content: attr(data-anchorjs-icon);' +
' }',
firstStyleEl;
style.className = 'anchorjs';
style.appendChild(document.createTextNode('')); // Necessary for Webkit.
// We place it in the head with the other style tags, if possible, so as to
// not look out of place. We insert before the others so these styles can be
// overridden if necessary.
firstStyleEl = document.head.querySelector('[rel="stylesheet"], style');
if (firstStyleEl === undefined) {
document.head.appendChild(style);
} else {
document.head.insertBefore(style, firstStyleEl);
}
style.sheet.insertRule(linkRule, style.sheet.cssRules.length);
style.sheet.insertRule(hoverRule, style.sheet.cssRules.length);
style.sheet.insertRule(pseudoElContent, style.sheet.cssRules.length);
style.sheet.insertRule(anchorjsLinkFontFace, style.sheet.cssRules.length);
};
}
var anchors = new AnchorJS();

6
docs/assets/js/vendor/anchor.min.js vendored Normal file
View File

@ -0,0 +1,6 @@
/*!
* AnchorJS - v1.2.1 - 2015-07-02
* https://github.com/bryanbraun/anchorjs
* Copyright (c) 2015 Bryan Braun; Licensed MIT
*/
function AnchorJS(A){"use strict";this.options=A||{},this._applyRemainingDefaultOptions=function(A){this.options.icon=this.options.hasOwnProperty("icon")?A.icon:"",this.options.visible=this.options.hasOwnProperty("visible")?A.visible:"hover",this.options.placement=this.options.hasOwnProperty("placement")?A.placement:"right",this.options.class=this.options.hasOwnProperty("class")?A.class:""},this._applyRemainingDefaultOptions(A),this.add=function(A){var e,t,o,n,i,s,a,l,r,h,c,g;if(this._applyRemainingDefaultOptions(this.options),A){if("string"!=typeof A)throw new Error("The selector provided to AnchorJS was invalid.")}else A="h1, h2, h3, h4, h5, h6";if(e=document.querySelectorAll(A),0===e.length)return!1;for(this._addBaselineStyles(),t=document.querySelectorAll("[id]"),o=[].map.call(t,function(A){return A.id}),i=0;i<e.length;i++){if(e[i].hasAttribute("id"))n=e[i].getAttribute("id");else{s=e[i].textContent,a=s.replace(/[^\w\s-]/gi,"").replace(/\s+/g,"-").replace(/-{2,}/g,"-").substring(0,64).replace(/^-+|-+$/gm,"").toLowerCase(),h=a,r=0;do void 0!==l&&(h=a+"-"+r),l=o.indexOf(h),r+=1;while(-1!==l);l=void 0,o.push(h),e[i].setAttribute("id",h),n=h}c=n.replace(/-/g," "),g=document.createElement("a"),g.className="anchorjs-link "+this.options.class,g.href="#"+n,g.setAttribute("aria-label","Anchor link for: "+c),g.setAttribute("data-anchorjs-icon",this.options.icon),"always"===this.options.visible&&(g.style.opacity="1"),""===this.options.icon&&(g.style.fontFamily="anchorjs-icons",g.style.fontStyle="normal",g.style.fontVariant="normal",g.style.fontWeight="normal",g.style.lineHeight=1),"left"===this.options.placement?(g.style.position="absolute",g.style.marginLeft="-1em",g.style.paddingRight="0.5em",e[i].insertBefore(g,e[i].firstChild)):(g.style.paddingLeft="0.375em",e[i].appendChild(g))}return this},this.remove=function(A){for(var e,t=document.querySelectorAll(A),o=0;o<t.length;o++)e=t[o].querySelector(".anchorjs-link"),e&&t[o].removeChild(e);return this},this._addBaselineStyles=function(){if(null===document.head.querySelector("style.anchorjs")){var A,e=document.createElement("style"),t=" .anchorjs-link { opacity: 0; text-decoration: none; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }",o=" *:hover > .anchorjs-link, .anchorjs-link:focus { opacity: 1; }",n=' @font-face { font-family: "anchorjs-icons"; font-style: normal; font-weight: normal; src: url(data:application/x-font-ttf;charset=utf-8;base64,AAEAAAALAIAAAwAwT1MvMg8SBTUAAAC8AAAAYGNtYXAWi9QdAAABHAAAAFRnYXNwAAAAEAAAAXAAAAAIZ2x5Zgq29TcAAAF4AAABNGhlYWQEZM3pAAACrAAAADZoaGVhBhUDxgAAAuQAAAAkaG10eASAADEAAAMIAAAAFGxvY2EAKACuAAADHAAAAAxtYXhwAAgAVwAAAygAAAAgbmFtZQ5yJ3cAAANIAAAB2nBvc3QAAwAAAAAFJAAAACAAAwJAAZAABQAAApkCzAAAAI8CmQLMAAAB6wAzAQkAAAAAAAAAAAAAAAAAAAABEAAAAAAAAAAAAAAAAAAAAABAAADpywPA/8AAQAPAAEAAAAABAAAAAAAAAAAAAAAgAAAAAAADAAAAAwAAABwAAQADAAAAHAADAAEAAAAcAAQAOAAAAAoACAACAAIAAQAg6cv//f//AAAAAAAg6cv//f//AAH/4xY5AAMAAQAAAAAAAAAAAAAAAQAB//8ADwABAAAAAAAAAAAAAgAANzkBAAAAAAEAAAAAAAAAAAACAAA3OQEAAAAAAQAAAAAAAAAAAAIAADc5AQAAAAACADEARAJTAsAAKwBUAAABIiYnJjQ/AT4BMzIWFxYUDwEGIicmND8BNjQnLgEjIgYPAQYUFxYUBw4BIwciJicmND8BNjIXFhQPAQYUFx4BMzI2PwE2NCcmNDc2MhcWFA8BDgEjARQGDAUtLXoWOR8fORYtLTgKGwoKCjgaGg0gEhIgDXoaGgkJBQwHdR85Fi0tOAobCgoKOBoaDSASEiANehoaCQkKGwotLXoWOR8BMwUFLYEuehYXFxYugC44CQkKGwo4GkoaDQ0NDXoaShoKGwoFBe8XFi6ALjgJCQobCjgaShoNDQ0NehpKGgobCgoKLYEuehYXAAEAAAABAACiToc1Xw889QALBAAAAAAA0XnFFgAAAADRecUWAAAAAAJTAsAAAAAIAAIAAAAAAAAAAQAAA8D/wAAABAAAAAAAAlMAAQAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAACAAAAAoAAMQAAAAAACgAUAB4AmgABAAAABQBVAAIAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAADgCuAAEAAAAAAAEADgAAAAEAAAAAAAIABwCfAAEAAAAAAAMADgBLAAEAAAAAAAQADgC0AAEAAAAAAAUACwAqAAEAAAAAAAYADgB1AAEAAAAAAAoAGgDeAAMAAQQJAAEAHAAOAAMAAQQJAAIADgCmAAMAAQQJAAMAHABZAAMAAQQJAAQAHADCAAMAAQQJAAUAFgA1AAMAAQQJAAYAHACDAAMAAQQJAAoANAD4YW5jaG9yanMtaWNvbnMAYQBuAGMAaABvAHIAagBzAC0AaQBjAG8AbgBzVmVyc2lvbiAxLjAAVgBlAHIAcwBpAG8AbgAgADEALgAwYW5jaG9yanMtaWNvbnMAYQBuAGMAaABvAHIAagBzAC0AaQBjAG8AbgBzYW5jaG9yanMtaWNvbnMAYQBuAGMAaABvAHIAagBzAC0AaQBjAG8AbgBzUmVndWxhcgBSAGUAZwB1AGwAYQByYW5jaG9yanMtaWNvbnMAYQBuAGMAaABvAHIAagBzAC0AaQBjAG8AbgBzRm9udCBnZW5lcmF0ZWQgYnkgSWNvTW9vbi4ARgBvAG4AdAAgAGcAZQBuAGUAcgBhAHQAZQBkACAAYgB5ACAASQBjAG8ATQBvAG8AbgAuAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==) format("truetype"); }',i=" [data-anchorjs-icon]::after { content: attr(data-anchorjs-icon); }";e.className="anchorjs",e.appendChild(document.createTextNode("")),A=document.head.querySelector('[rel="stylesheet"], style'),void 0===A?document.head.appendChild(e):document.head.insertBefore(e,A),e.sheet.insertRule(t,e.sheet.cssRules.length),e.sheet.insertRule(o,e.sheet.cssRules.length),e.sheet.insertRule(i,e.sheet.cssRules.length),e.sheet.insertRule(n,e.sheet.cssRules.length)}}}var anchors=new AnchorJS;

View File

@ -96,7 +96,7 @@ The collapse plugin utilizes a few classes to handle the heavy lifting:
- `.collapse.in` shows the content
- `.collapsing` is added when the transition starts, and removed when it finishes
These classes can be found in `component-animations.less`.
These classes can be found in `_animation.scss`.
### Via data attributes

View File

@ -31,15 +31,17 @@
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Project name</a>
<nav class="nav navbar-nav pull-left">
<a class="nav-item nav-link" href="#">Dashboard</a>
<a class="nav-item nav-link" href="#">Settings</a>
<a class="nav-item nav-link" href="#">Profile</a>
<a class="nav-item nav-link" href="#">Help</a>
</nav>
<form class="navbar-form pull-right">
<input type="text" class="form-control" placeholder="Search...">
</form>
<div id="navbar">
<nav class="nav navbar-nav pull-left">
<a class="nav-item nav-link" href="#">Dashboard</a>
<a class="nav-item nav-link" href="#">Settings</a>
<a class="nav-item nav-link" href="#">Profile</a>
<a class="nav-item nav-link" href="#">Help</a>
</nav>
<form class="navbar-form pull-right">
<input type="text" class="form-control" placeholder="Search...">
</form>
</div>
</nav>
<div class="container-fluid">

View File

@ -70,7 +70,7 @@
<hr>
<footer>
<p>&copy; Company 2014</p>
<p>&copy; Company 2015</p>
</footer>
</div> <!-- /container -->

View File

@ -28,7 +28,7 @@ Our Gruntfile includes the following commands and tasks:
| --- | --- |
| `grunt` | Run `grunt` to run tests locally and compile the CSS and JavaScript into `/dist`. **Uses [Sass](http://sass-lang.com/) and [UglifyJS](http://lisperator.net/uglifyjs/).** |
| `grunt dist` | `grunt dist` creates the `/dist` directory with compiled files. **Uses [Sass](http://sass-lang.com/) and [UglifyJS](http://lisperator.net/uglifyjs/).** |
| `grunt test` | Runs [JSHint](http://jshint.com) and [QUnit](http://qunitjs.com/) tests headlessly in [PhantomJS](http://phantomjs.org/) (used for CI). |
| `grunt test` | Runs [scss-lint](https://github.com/brigade/scss-lint), [ESLint](http://eslint.org/) and [QUnit](http://qunitjs.com/) tests headlessly in [PhantomJS](http://phantomjs.org/) (used for CI). |
| `grunt docs` | Builds and tests CSS, JavaScript, and other assets which are used when running the documentation locally via `jekyll serve`. |
| `grunt watch` | This is a convenience method for watching just Sass files and automatically building them whenever you save. |

View File

@ -52,7 +52,7 @@ Install Bootstrap in your Node powered apps with [the npm package](https://www.n
Bootstrap's `package.json` contains some additional metadata under the following keys:
- `less` - path to Bootstrap's main [Less](http://lesscss.org) source file
- `sass` - path to Bootstrap's main [Sass](http://sass-lang.com/) source file
- `style` - path to Bootstrap's non-minified CSS that's been precompiled using the default settings (no customization)
### Meteor

View File

@ -57,7 +57,7 @@ title: Bootstrap &middot; The world's most popular mobile-first and responsive f
<div class="col-sm-4 m-b-lg">
<img src="assets/img/sass.png" alt="Sass support" class="img-responsive">
<h4>Preprocessor</h4>
<p>Bootstrap ships with vanilla CSS, but its source code utilizes <a href="../css/#sass">Sass</a>, a popular CSS preprocessor. Quickly get started with precompiled CSS or build on the source.</p>
<p>Bootstrap ships with vanilla CSS, but its source code utilizes <a href="http://sass-lang.com/">Sass</a>, a popular CSS preprocessor. Quickly get started with precompiled CSS or build on the source.</p>
</div>
<div class="col-sm-4 m-b-lg">
<img src="assets/img/devices.png" alt="Responsive across devices" class="img-responsive">

View File

@ -151,7 +151,7 @@ The following components have been removed in v4.0.0.
| Wells | | Cards |
| Justified navs | | |
TODO: audit classes in v4 that aren't present in v4
TODO: audit classes in v3 that aren't present in v4
### Responsive utilities

View File

@ -1,7 +0,0 @@
{
"extends" : "../js/.jshintrc",
"asi" : false,
"browser" : false,
"es3" : false,
"node" : true
}

View File

@ -4,7 +4,7 @@
"../assets/js/vendor/holder.min.js",
"assets/js/vendor/jekyll-search.js",
"../assets/js/vendor/ZeroClipboard.min.js",
"../assets/js/vendor/anchor.js",
"../assets/js/vendor/anchor.min.js",
"../assets/js/vendor/tether.min.js",
"../assets/js/src/application.js"
]

6
js/dist/popover.js vendored
View File

@ -104,10 +104,10 @@ var Popover = (function ($) {
var tip = this.getTipElement();
var title = this.getTitle();
var content = this._getContent();
var titleElement = $(tip).find(Selector.TITLE)[0];
var $titleElement = $(tip).find(Selector.TITLE);
if (titleElement) {
titleElement[this.config.html ? 'innerHTML' : 'innerText'] = title;
if ($titleElement) {
$titleElement[this.config.html ? 'html' : 'text'](title);
}
// we use append for html objects to maintain js events

File diff suppressed because one or more lines are too long

4
js/dist/tooltip.js vendored
View File

@ -331,9 +331,9 @@ var Tooltip = (function ($) {
value: function setContent() {
var tip = this.getTipElement();
var title = this.getTitle();
var method = this.config.html ? 'innerHTML' : 'innerText';
var method = this.config.html ? 'html' : 'text';
$(tip).find(Selector.TOOLTIP_INNER)[0][method] = title;
$(tip).find(Selector.TOOLTIP_INNER)[method](title);
$(tip).removeClass(ClassName.FADE).removeClass(ClassName.IN);

File diff suppressed because one or more lines are too long

View File

@ -116,12 +116,12 @@ const Popover = (($) => {
let tip = this.getTipElement()
let title = this.getTitle()
let content = this._getContent()
let titleElement = $(tip).find(Selector.TITLE)[0]
let $titleElement = $(tip).find(Selector.TITLE)
if (titleElement) {
titleElement[
this.config.html ? 'innerHTML' : 'innerText'
] = title
if ($titleElement) {
$titleElement[
this.config.html ? 'html' : 'text'
](title)
}
// we use append for html objects to maintain js events

View File

@ -358,9 +358,9 @@ const Tooltip = (($) => {
setContent() {
let tip = this.getTipElement()
let title = this.getTitle()
let method = this.config.html ? 'innerHTML' : 'innerText'
let method = this.config.html ? 'html' : 'text'
$(tip).find(Selector.TOOLTIP_INNER)[0][method] = title
$(tip).find(Selector.TOOLTIP_INNER)[method](title)
$(tip)
.removeClass(ClassName.FADE)

View File

@ -1,6 +0,0 @@
{
"extends" : "../../.jshintrc",
"devel" : true,
"es3" : false,
"qunit" : true
}

View File

@ -1,12 +1,12 @@
/*!
* QUnit 1.17.1
* QUnit 1.18.0
* http://qunitjs.com/
*
* Copyright jQuery Foundation and other contributors
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2015-01-20T19:39Z
* Date: 2015-04-03T10:23Z
*/
/** Font Family and Sizes */
@ -116,7 +116,13 @@
#qunit-tests.hidepass li.running,
#qunit-tests.hidepass li.pass {
display: none;
visibility: hidden;
position: absolute;
width: 0px;
height: 0px;
padding: 0;
border: 0;
margin: 0;
}
#qunit-tests li strong {
@ -132,6 +138,11 @@
color: #C2CCD1;
text-decoration: none;
}
#qunit-tests li p a {
padding: 0.25em;
color: #6B6464;
}
#qunit-tests li a:hover,
#qunit-tests li a:focus {
color: #000;

1355
js/tests/vendor/qunit.js vendored
View File

@ -1,12 +1,12 @@
/*!
* QUnit 1.17.1
* QUnit 1.18.0
* http://qunitjs.com/
*
* Copyright jQuery Foundation and other contributors
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2015-01-20T19:39Z
* Date: 2015-04-03T10:23Z
*/
(function( window ) {
@ -116,6 +116,9 @@ config = {
// when enabled, all tests must call expect()
requireExpects: false,
// depth up-to which object will be dumped
maxDepth: 5,
// add checkboxes that are persisted in the query-string
// when enabled, the id is set to `true` as a `QUnit.config` property
urlConfig: [
@ -185,11 +188,17 @@ config.modules.push( config.currentModule );
// String search anywhere in moduleName+testName
config.filter = urlParams.filter;
if ( urlParams.maxDepth ) {
config.maxDepth = parseInt( urlParams.maxDepth, 10 ) === -1 ?
Number.POSITIVE_INFINITY :
urlParams.maxDepth;
}
config.testId = [];
if ( urlParams.testId ) {
// Ensure that urlParams.testId is an array
urlParams.testId = [].concat( urlParams.testId );
urlParams.testId = decodeURIComponent( urlParams.testId ).split( "," );
for ( i = 0; i < urlParams.testId.length; i++ ) {
config.testId.push( urlParams.testId[ i ] );
}
@ -197,6 +206,9 @@ config.modules.push( config.currentModule );
// Figure out if we're running the tests from a server or not
QUnit.isLocal = location.protocol === "file:";
// Expose the current QUnit version
QUnit.version = "1.18.0";
}());
// Root QUnit object.
@ -484,20 +496,14 @@ function done() {
});
}
// Doesn't support IE6 to IE9
// Doesn't support IE6 to IE9, it will return undefined on these browsers
// See also https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error/Stack
function extractStacktrace( e, offset ) {
offset = offset === undefined ? 4 : offset;
var stack, include, i;
if ( e.stacktrace ) {
// Opera 12.x
return e.stacktrace.split( "\n" )[ offset + 3 ];
} else if ( e.stack ) {
// Firefox, Chrome, Safari 6+, IE10+, PhantomJS and Node
if ( e.stack ) {
stack = e.stack.split( "\n" );
if ( /^error$/i.test( stack[ 0 ] ) ) {
stack.shift();
@ -515,9 +521,10 @@ function extractStacktrace( e, offset ) {
}
}
return stack[ offset ];
// Support: Safari <=6 only
} else if ( e.sourceURL ) {
// Safari < 6
// exclude useless self-reference for generated Error objects
if ( /qunit.js$/.test( e.sourceURL ) ) {
return;
@ -529,16 +536,19 @@ function extractStacktrace( e, offset ) {
}
function sourceFromStacktrace( offset ) {
var e = new Error();
if ( !e.stack ) {
var error = new Error();
// Support: Safari <=7 only, IE <=10 - 11 only
// Not all browsers generate the `stack` property for `new Error()`, see also #636
if ( !error.stack ) {
try {
throw e;
throw error;
} catch ( err ) {
// This should already be true in most browsers
e = err;
error = err;
}
}
return extractStacktrace( e, offset );
return extractStacktrace( error, offset );
}
function synchronize( callback, last ) {
@ -1123,7 +1133,7 @@ Test.prototype = {
valid: function() {
var include,
filter = config.filter,
filter = config.filter && config.filter.toLowerCase(),
module = QUnit.urlParams.module && QUnit.urlParams.module.toLowerCase(),
fullName = ( this.module.name + ": " + this.testName ).toLowerCase();
@ -1146,7 +1156,7 @@ Test.prototype = {
include = filter.charAt( 0 ) !== "!";
if ( !include ) {
filter = filter.toLowerCase().slice( 1 );
filter = filter.slice( 1 );
}
// If the filter matches, we need to honour include
@ -1284,87 +1294,52 @@ QUnit.assert = Assert.prototype = {
return assert.test.push.apply( assert.test, arguments );
},
/**
* Asserts rough true-ish result.
* @name ok
* @function
* @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" );
*/
ok: function( result, message ) {
message = message || ( result ? "okay" : "failed, expected argument to be truthy, was: " +
QUnit.dump.parse( result ) );
this.push( !!result, result, true, message );
},
/**
* Assert that the first two arguments are equal, with an optional message.
* Prints out both actual and expected values.
* @name equal
* @function
* @example equal( format( "{0} bytes.", 2), "2 bytes.", "replaces {0} with next argument" );
*/
notOk: function( result, message ) {
message = message || ( !result ? "okay" : "failed, expected argument to be falsy, was: " +
QUnit.dump.parse( result ) );
this.push( !result, result, false, message );
},
equal: function( actual, expected, message ) {
/*jshint eqeqeq:false */
this.push( expected == actual, actual, expected, message );
},
/**
* @name notEqual
* @function
*/
notEqual: function( actual, expected, message ) {
/*jshint eqeqeq:false */
this.push( expected != actual, actual, expected, message );
},
/**
* @name propEqual
* @function
*/
propEqual: function( actual, expected, message ) {
actual = objectValues( actual );
expected = objectValues( expected );
this.push( QUnit.equiv( actual, expected ), actual, expected, message );
},
/**
* @name notPropEqual
* @function
*/
notPropEqual: function( actual, expected, message ) {
actual = objectValues( actual );
expected = objectValues( expected );
this.push( !QUnit.equiv( actual, expected ), actual, expected, message );
},
/**
* @name deepEqual
* @function
*/
deepEqual: function( actual, expected, message ) {
this.push( QUnit.equiv( actual, expected ), actual, expected, message );
},
/**
* @name notDeepEqual
* @function
*/
notDeepEqual: function( actual, expected, message ) {
this.push( !QUnit.equiv( actual, expected ), actual, expected, message );
},
/**
* @name strictEqual
* @function
*/
strictEqual: function( actual, expected, message ) {
this.push( expected === actual, actual, expected, message );
},
/**
* @name notStrictEqual
* @function
*/
notStrictEqual: function( actual, expected, message ) {
this.push( expected !== actual, actual, expected, message );
},
@ -1372,7 +1347,8 @@ QUnit.assert = Assert.prototype = {
"throws": function( block, expected, message ) {
var actual, expectedType,
expectedOutput = expected,
ok = false;
ok = false,
currentTest = ( this instanceof Assert && this.test ) || QUnit.config.current;
// 'expected' is optional unless doing string comparison
if ( message == null && typeof expected === "string" ) {
@ -1380,13 +1356,13 @@ QUnit.assert = Assert.prototype = {
expected = null;
}
this.test.ignoreGlobalErrors = true;
currentTest.ignoreGlobalErrors = true;
try {
block.call( this.test.testEnvironment );
block.call( currentTest.testEnvironment );
} catch (e) {
actual = e;
}
this.test.ignoreGlobalErrors = false;
currentTest.ignoreGlobalErrors = false;
if ( actual ) {
expectedType = QUnit.objectType( expected );
@ -1419,11 +1395,9 @@ QUnit.assert = Assert.prototype = {
expectedOutput = null;
ok = true;
}
this.push( ok, actual, expectedOutput, message );
} else {
this.test.pushFailure( message, null, "No exception was thrown." );
}
currentTest.assert.push( ok, actual, expectedOutput, message );
}
};
@ -1783,7 +1757,7 @@ QUnit.dump = (function() {
join: join,
//
depth: 1,
maxDepth: 5,
maxDepth: QUnit.config.maxDepth,
// This is the list of parsers, to modify them, use dump.setParser
parsers: {
@ -1830,7 +1804,7 @@ QUnit.dump = (function() {
nonEnumerableProperties = [ "message", "name" ];
for ( i in nonEnumerableProperties ) {
key = nonEnumerableProperties[ i ];
if ( key in map && !( key in keys ) ) {
if ( key in map && inArray( key, keys ) < 0 ) {
keys.push( key );
}
}
@ -1949,6 +1923,7 @@ if ( typeof window !== "undefined" ) {
"start",
"stop",
"ok",
"notOk",
"equal",
"notEqual",
"propEqual",
@ -1981,6 +1956,13 @@ if ( typeof exports !== "undefined" && exports ) {
exports.QUnit = QUnit;
}
if ( typeof define === "function" && define.amd ) {
define( function() {
return QUnit;
} );
QUnit.config.autostart = false;
}
// Get a reference to the global object, like window in browsers
}( (function() {
return this;
@ -1989,150 +1971,1088 @@ if ( typeof exports !== "undefined" && exports ) {
/*istanbul ignore next */
// jscs:disable maximumLineLength
/*
* Javascript Diff Algorithm
* By John Resig (http://ejohn.org/)
* Modified by Chu Alan "sprite"
* This file is a modified version of google-diff-match-patch's JavaScript implementation
* (https://code.google.com/p/google-diff-match-patch/source/browse/trunk/javascript/diff_match_patch_uncompressed.js),
* modifications are licensed as more fully set forth in LICENSE.txt.
*
* Released under the MIT license.
* The original source of google-diff-match-patch is attributable and licensed as follows:
*
* Copyright 2006 Google Inc.
* http://code.google.com/p/google-diff-match-patch/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* More Info:
* http://ejohn.org/projects/javascript-diff-algorithm/
* https://code.google.com/p/google-diff-match-patch/
*
* Usage: QUnit.diff(expected, actual)
*
* QUnit.diff( "the quick brown fox jumped over", "the quick fox jumps over" ) == "the quick <del>brown </del> fox <del>jumped </del><ins>jumps </ins> over"
* QUnit.diff( "the quick brown fox jumped over", "the quick fox jumps over" ) === "the quick <del>brown </del> fox jump<ins>s</ins><del>ed</del over"
*/
QUnit.diff = (function() {
var hasOwn = Object.prototype.hasOwnProperty;
/*jshint eqeqeq:false, eqnull:true */
function diff( o, n ) {
var i,
ns = {},
os = {};
function DiffMatchPatch() {
for ( i = 0; i < n.length; i++ ) {
if ( !hasOwn.call( ns, n[ i ] ) ) {
ns[ n[ i ] ] = {
rows: [],
o: null
};
}
ns[ n[ i ] ].rows.push( i );
}
// Defaults.
// Redefine these in your program to override the defaults.
for ( i = 0; i < o.length; i++ ) {
if ( !hasOwn.call( os, o[ i ] ) ) {
os[ o[ i ] ] = {
rows: [],
n: null
};
}
os[ o[ i ] ].rows.push( i );
}
// Number of seconds to map a diff before giving up (0 for infinity).
this.DiffTimeout = 1.0;
// Cost of an empty edit operation in terms of edit characters.
this.DiffEditCost = 4;
}
for ( i in ns ) {
if ( hasOwn.call( ns, i ) ) {
if ( ns[ i ].rows.length === 1 && hasOwn.call( os, i ) && os[ i ].rows.length === 1 ) {
n[ ns[ i ].rows[ 0 ] ] = {
text: n[ ns[ i ].rows[ 0 ] ],
row: os[ i ].rows[ 0 ]
};
o[ os[ i ].rows[ 0 ] ] = {
text: o[ os[ i ].rows[ 0 ] ],
row: ns[ i ].rows[ 0 ]
};
}
}
}
// DIFF FUNCTIONS
for ( i = 0; i < n.length - 1; i++ ) {
if ( n[ i ].text != null && n[ i + 1 ].text == null && n[ i ].row + 1 < o.length && o[ n[ i ].row + 1 ].text == null &&
n[ i + 1 ] == o[ n[ i ].row + 1 ] ) {
/**
* The data structure representing a diff is an array of tuples:
* [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']]
* which means: delete 'Hello', add 'Goodbye' and keep ' world.'
*/
var DIFF_DELETE = -1,
DIFF_INSERT = 1,
DIFF_EQUAL = 0;
n[ i + 1 ] = {
text: n[ i + 1 ],
row: n[ i ].row + 1
};
o[ n[ i ].row + 1 ] = {
text: o[ n[ i ].row + 1 ],
row: i + 1
};
}
}
/**
* Find the differences between two texts. Simplifies the problem by stripping
* any common prefix or suffix off the texts before diffing.
* @param {string} text1 Old string to be diffed.
* @param {string} text2 New string to be diffed.
* @param {boolean=} optChecklines Optional speedup flag. If present and false,
* then don't run a line-level diff first to identify the changed areas.
* Defaults to true, which does a faster, slightly less optimal diff.
* @param {number} optDeadline Optional time when the diff should be complete
* by. Used internally for recursive calls. Users should set DiffTimeout
* instead.
* @return {!Array.<!DiffMatchPatch.Diff>} Array of diff tuples.
*/
DiffMatchPatch.prototype.DiffMain = function( text1, text2, optChecklines, optDeadline ) {
var deadline, checklines, commonlength,
commonprefix, commonsuffix, diffs;
// Set a deadline by which time the diff must be complete.
if ( typeof optDeadline === "undefined" ) {
if ( this.DiffTimeout <= 0 ) {
optDeadline = Number.MAX_VALUE;
} else {
optDeadline = ( new Date() ).getTime() + this.DiffTimeout * 1000;
}
}
deadline = optDeadline;
for ( i = n.length - 1; i > 0; i-- ) {
if ( n[ i ].text != null && n[ i - 1 ].text == null && n[ i ].row > 0 && o[ n[ i ].row - 1 ].text == null &&
n[ i - 1 ] == o[ n[ i ].row - 1 ] ) {
// Check for null inputs.
if ( text1 === null || text2 === null ) {
throw new Error( "Null input. (DiffMain)" );
}
n[ i - 1 ] = {
text: n[ i - 1 ],
row: n[ i ].row - 1
};
o[ n[ i ].row - 1 ] = {
text: o[ n[ i ].row - 1 ],
row: i - 1
};
}
}
// Check for equality (speedup).
if ( text1 === text2 ) {
if ( text1 ) {
return [
[ DIFF_EQUAL, text1 ]
];
}
return [];
}
return {
o: o,
n: n
};
}
if ( typeof optChecklines === "undefined" ) {
optChecklines = true;
}
return function( o, n ) {
o = o.replace( /\s+$/, "" );
n = n.replace( /\s+$/, "" );
checklines = optChecklines;
var i, pre,
str = "",
out = diff( o === "" ? [] : o.split( /\s+/ ), n === "" ? [] : n.split( /\s+/ ) ),
oSpace = o.match( /\s+/g ),
nSpace = n.match( /\s+/g );
// Trim off common prefix (speedup).
commonlength = this.diffCommonPrefix( text1, text2 );
commonprefix = text1.substring( 0, commonlength );
text1 = text1.substring( commonlength );
text2 = text2.substring( commonlength );
if ( oSpace == null ) {
oSpace = [ " " ];
} else {
oSpace.push( " " );
}
// Trim off common suffix (speedup).
/////////
commonlength = this.diffCommonSuffix( text1, text2 );
commonsuffix = text1.substring( text1.length - commonlength );
text1 = text1.substring( 0, text1.length - commonlength );
text2 = text2.substring( 0, text2.length - commonlength );
if ( nSpace == null ) {
nSpace = [ " " ];
} else {
nSpace.push( " " );
}
// Compute the diff on the middle block.
diffs = this.diffCompute( text1, text2, checklines, deadline );
if ( out.n.length === 0 ) {
for ( i = 0; i < out.o.length; i++ ) {
str += "<del>" + out.o[ i ] + oSpace[ i ] + "</del>";
}
} else {
if ( out.n[ 0 ].text == null ) {
for ( n = 0; n < out.o.length && out.o[ n ].text == null; n++ ) {
str += "<del>" + out.o[ n ] + oSpace[ n ] + "</del>";
}
}
// Restore the prefix and suffix.
if ( commonprefix ) {
diffs.unshift( [ DIFF_EQUAL, commonprefix ] );
}
if ( commonsuffix ) {
diffs.push( [ DIFF_EQUAL, commonsuffix ] );
}
this.diffCleanupMerge( diffs );
return diffs;
};
for ( i = 0; i < out.n.length; i++ ) {
if ( out.n[ i ].text == null ) {
str += "<ins>" + out.n[ i ] + nSpace[ i ] + "</ins>";
} else {
/**
* Reduce the number of edits by eliminating operationally trivial equalities.
* @param {!Array.<!DiffMatchPatch.Diff>} diffs Array of diff tuples.
*/
DiffMatchPatch.prototype.diffCleanupEfficiency = function( diffs ) {
var changes, equalities, equalitiesLength, lastequality,
pointer, preIns, preDel, postIns, postDel;
changes = false;
equalities = []; // Stack of indices where equalities are found.
equalitiesLength = 0; // Keeping our own length var is faster in JS.
/** @type {?string} */
lastequality = null;
// Always equal to diffs[equalities[equalitiesLength - 1]][1]
pointer = 0; // Index of current position.
// Is there an insertion operation before the last equality.
preIns = false;
// Is there a deletion operation before the last equality.
preDel = false;
// Is there an insertion operation after the last equality.
postIns = false;
// Is there a deletion operation after the last equality.
postDel = false;
while ( pointer < diffs.length ) {
if ( diffs[ pointer ][ 0 ] === DIFF_EQUAL ) { // Equality found.
if ( diffs[ pointer ][ 1 ].length < this.DiffEditCost && ( postIns || postDel ) ) {
// Candidate found.
equalities[ equalitiesLength++ ] = pointer;
preIns = postIns;
preDel = postDel;
lastequality = diffs[ pointer ][ 1 ];
} else {
// Not a candidate, and can never become one.
equalitiesLength = 0;
lastequality = null;
}
postIns = postDel = false;
} else { // An insertion or deletion.
if ( diffs[ pointer ][ 0 ] === DIFF_DELETE ) {
postDel = true;
} else {
postIns = true;
}
/*
* Five types to be split:
* <ins>A</ins><del>B</del>XY<ins>C</ins><del>D</del>
* <ins>A</ins>X<ins>C</ins><del>D</del>
* <ins>A</ins><del>B</del>X<ins>C</ins>
* <ins>A</del>X<ins>C</ins><del>D</del>
* <ins>A</ins><del>B</del>X<del>C</del>
*/
if ( lastequality && ( ( preIns && preDel && postIns && postDel ) ||
( ( lastequality.length < this.DiffEditCost / 2 ) &&
( preIns + preDel + postIns + postDel ) === 3 ) ) ) {
// Duplicate record.
diffs.splice( equalities[equalitiesLength - 1], 0, [ DIFF_DELETE, lastequality ] );
// Change second copy to insert.
diffs[ equalities[ equalitiesLength - 1 ] + 1 ][ 0 ] = DIFF_INSERT;
equalitiesLength--; // Throw away the equality we just deleted;
lastequality = null;
if (preIns && preDel) {
// No changes made which could affect previous entry, keep going.
postIns = postDel = true;
equalitiesLength = 0;
} else {
equalitiesLength--; // Throw away the previous equality.
pointer = equalitiesLength > 0 ? equalities[ equalitiesLength - 1 ] : -1;
postIns = postDel = false;
}
changes = true;
}
}
pointer++;
}
// `pre` initialized at top of scope
pre = "";
if ( changes ) {
this.diffCleanupMerge( diffs );
}
};
for ( n = out.n[ i ].row + 1; n < out.o.length && out.o[ n ].text == null; n++ ) {
pre += "<del>" + out.o[ n ] + oSpace[ n ] + "</del>";
}
str += " " + out.n[ i ].text + nSpace[ i ] + pre;
}
}
}
/**
* Convert a diff array into a pretty HTML report.
* @param {!Array.<!DiffMatchPatch.Diff>} diffs Array of diff tuples.
* @param {integer} string to be beautified.
* @return {string} HTML representation.
*/
DiffMatchPatch.prototype.diffPrettyHtml = function( diffs ) {
var op, data, x, html = [];
for ( x = 0; x < diffs.length; x++ ) {
op = diffs[x][0]; // Operation (insert, delete, equal)
data = diffs[x][1]; // Text of change.
switch ( op ) {
case DIFF_INSERT:
html[x] = "<ins>" + data + "</ins>";
break;
case DIFF_DELETE:
html[x] = "<del>" + data + "</del>";
break;
case DIFF_EQUAL:
html[x] = "<span>" + data + "</span>";
break;
}
}
return html.join("");
};
return str;
};
/**
* Determine the common prefix of two strings.
* @param {string} text1 First string.
* @param {string} text2 Second string.
* @return {number} The number of characters common to the start of each
* string.
*/
DiffMatchPatch.prototype.diffCommonPrefix = function( text1, text2 ) {
var pointermid, pointermax, pointermin, pointerstart;
// Quick check for common null cases.
if ( !text1 || !text2 || text1.charAt(0) !== text2.charAt(0) ) {
return 0;
}
// Binary search.
// Performance analysis: http://neil.fraser.name/news/2007/10/09/
pointermin = 0;
pointermax = Math.min( text1.length, text2.length );
pointermid = pointermax;
pointerstart = 0;
while ( pointermin < pointermid ) {
if ( text1.substring( pointerstart, pointermid ) === text2.substring( pointerstart, pointermid ) ) {
pointermin = pointermid;
pointerstart = pointermin;
} else {
pointermax = pointermid;
}
pointermid = Math.floor( ( pointermax - pointermin ) / 2 + pointermin );
}
return pointermid;
};
/**
* Determine the common suffix of two strings.
* @param {string} text1 First string.
* @param {string} text2 Second string.
* @return {number} The number of characters common to the end of each string.
*/
DiffMatchPatch.prototype.diffCommonSuffix = function( text1, text2 ) {
var pointermid, pointermax, pointermin, pointerend;
// Quick check for common null cases.
if (!text1 || !text2 || text1.charAt(text1.length - 1) !== text2.charAt(text2.length - 1)) {
return 0;
}
// Binary search.
// Performance analysis: http://neil.fraser.name/news/2007/10/09/
pointermin = 0;
pointermax = Math.min(text1.length, text2.length);
pointermid = pointermax;
pointerend = 0;
while ( pointermin < pointermid ) {
if (text1.substring( text1.length - pointermid, text1.length - pointerend ) ===
text2.substring( text2.length - pointermid, text2.length - pointerend ) ) {
pointermin = pointermid;
pointerend = pointermin;
} else {
pointermax = pointermid;
}
pointermid = Math.floor( ( pointermax - pointermin ) / 2 + pointermin );
}
return pointermid;
};
/**
* Find the differences between two texts. Assumes that the texts do not
* have any common prefix or suffix.
* @param {string} text1 Old string to be diffed.
* @param {string} text2 New string to be diffed.
* @param {boolean} checklines Speedup flag. If false, then don't run a
* line-level diff first to identify the changed areas.
* If true, then run a faster, slightly less optimal diff.
* @param {number} deadline Time when the diff should be complete by.
* @return {!Array.<!DiffMatchPatch.Diff>} Array of diff tuples.
* @private
*/
DiffMatchPatch.prototype.diffCompute = function( text1, text2, checklines, deadline ) {
var diffs, longtext, shorttext, i, hm,
text1A, text2A, text1B, text2B,
midCommon, diffsA, diffsB;
if ( !text1 ) {
// Just add some text (speedup).
return [
[ DIFF_INSERT, text2 ]
];
}
if (!text2) {
// Just delete some text (speedup).
return [
[ DIFF_DELETE, text1 ]
];
}
longtext = text1.length > text2.length ? text1 : text2;
shorttext = text1.length > text2.length ? text2 : text1;
i = longtext.indexOf( shorttext );
if ( i !== -1 ) {
// Shorter text is inside the longer text (speedup).
diffs = [
[ DIFF_INSERT, longtext.substring( 0, i ) ],
[ DIFF_EQUAL, shorttext ],
[ DIFF_INSERT, longtext.substring( i + shorttext.length ) ]
];
// Swap insertions for deletions if diff is reversed.
if ( text1.length > text2.length ) {
diffs[0][0] = diffs[2][0] = DIFF_DELETE;
}
return diffs;
}
if ( shorttext.length === 1 ) {
// Single character string.
// After the previous speedup, the character can't be an equality.
return [
[ DIFF_DELETE, text1 ],
[ DIFF_INSERT, text2 ]
];
}
// Check to see if the problem can be split in two.
hm = this.diffHalfMatch(text1, text2);
if (hm) {
// A half-match was found, sort out the return data.
text1A = hm[0];
text1B = hm[1];
text2A = hm[2];
text2B = hm[3];
midCommon = hm[4];
// Send both pairs off for separate processing.
diffsA = this.DiffMain(text1A, text2A, checklines, deadline);
diffsB = this.DiffMain(text1B, text2B, checklines, deadline);
// Merge the results.
return diffsA.concat([
[ DIFF_EQUAL, midCommon ]
], diffsB);
}
if (checklines && text1.length > 100 && text2.length > 100) {
return this.diffLineMode(text1, text2, deadline);
}
return this.diffBisect(text1, text2, deadline);
};
/**
* Do the two texts share a substring which is at least half the length of the
* longer text?
* This speedup can produce non-minimal diffs.
* @param {string} text1 First string.
* @param {string} text2 Second string.
* @return {Array.<string>} Five element Array, containing the prefix of
* text1, the suffix of text1, the prefix of text2, the suffix of
* text2 and the common middle. Or null if there was no match.
* @private
*/
DiffMatchPatch.prototype.diffHalfMatch = function(text1, text2) {
var longtext, shorttext, dmp,
text1A, text2B, text2A, text1B, midCommon,
hm1, hm2, hm;
if (this.DiffTimeout <= 0) {
// Don't risk returning a non-optimal diff if we have unlimited time.
return null;
}
longtext = text1.length > text2.length ? text1 : text2;
shorttext = text1.length > text2.length ? text2 : text1;
if (longtext.length < 4 || shorttext.length * 2 < longtext.length) {
return null; // Pointless.
}
dmp = this; // 'this' becomes 'window' in a closure.
/**
* Does a substring of shorttext exist within longtext such that the substring
* is at least half the length of longtext?
* Closure, but does not reference any external variables.
* @param {string} longtext Longer string.
* @param {string} shorttext Shorter string.
* @param {number} i Start index of quarter length substring within longtext.
* @return {Array.<string>} Five element Array, containing the prefix of
* longtext, the suffix of longtext, the prefix of shorttext, the suffix
* of shorttext and the common middle. Or null if there was no match.
* @private
*/
function diffHalfMatchI(longtext, shorttext, i) {
var seed, j, bestCommon, prefixLength, suffixLength,
bestLongtextA, bestLongtextB, bestShorttextA, bestShorttextB;
// Start with a 1/4 length substring at position i as a seed.
seed = longtext.substring(i, i + Math.floor(longtext.length / 4));
j = -1;
bestCommon = "";
while ((j = shorttext.indexOf(seed, j + 1)) !== -1) {
prefixLength = dmp.diffCommonPrefix(longtext.substring(i),
shorttext.substring(j));
suffixLength = dmp.diffCommonSuffix(longtext.substring(0, i),
shorttext.substring(0, j));
if (bestCommon.length < suffixLength + prefixLength) {
bestCommon = shorttext.substring(j - suffixLength, j) +
shorttext.substring(j, j + prefixLength);
bestLongtextA = longtext.substring(0, i - suffixLength);
bestLongtextB = longtext.substring(i + prefixLength);
bestShorttextA = shorttext.substring(0, j - suffixLength);
bestShorttextB = shorttext.substring(j + prefixLength);
}
}
if (bestCommon.length * 2 >= longtext.length) {
return [ bestLongtextA, bestLongtextB,
bestShorttextA, bestShorttextB, bestCommon
];
} else {
return null;
}
}
// First check if the second quarter is the seed for a half-match.
hm1 = diffHalfMatchI(longtext, shorttext,
Math.ceil(longtext.length / 4));
// Check again based on the third quarter.
hm2 = diffHalfMatchI(longtext, shorttext,
Math.ceil(longtext.length / 2));
if (!hm1 && !hm2) {
return null;
} else if (!hm2) {
hm = hm1;
} else if (!hm1) {
hm = hm2;
} else {
// Both matched. Select the longest.
hm = hm1[4].length > hm2[4].length ? hm1 : hm2;
}
// A half-match was found, sort out the return data.
text1A, text1B, text2A, text2B;
if (text1.length > text2.length) {
text1A = hm[0];
text1B = hm[1];
text2A = hm[2];
text2B = hm[3];
} else {
text2A = hm[0];
text2B = hm[1];
text1A = hm[2];
text1B = hm[3];
}
midCommon = hm[4];
return [ text1A, text1B, text2A, text2B, midCommon ];
};
/**
* Do a quick line-level diff on both strings, then rediff the parts for
* greater accuracy.
* This speedup can produce non-minimal diffs.
* @param {string} text1 Old string to be diffed.
* @param {string} text2 New string to be diffed.
* @param {number} deadline Time when the diff should be complete by.
* @return {!Array.<!DiffMatchPatch.Diff>} Array of diff tuples.
* @private
*/
DiffMatchPatch.prototype.diffLineMode = function(text1, text2, deadline) {
var a, diffs, linearray, pointer, countInsert,
countDelete, textInsert, textDelete, j;
// Scan the text on a line-by-line basis first.
a = this.diffLinesToChars(text1, text2);
text1 = a.chars1;
text2 = a.chars2;
linearray = a.lineArray;
diffs = this.DiffMain(text1, text2, false, deadline);
// Convert the diff back to original text.
this.diffCharsToLines(diffs, linearray);
// Eliminate freak matches (e.g. blank lines)
this.diffCleanupSemantic(diffs);
// Rediff any replacement blocks, this time character-by-character.
// Add a dummy entry at the end.
diffs.push( [ DIFF_EQUAL, "" ] );
pointer = 0;
countDelete = 0;
countInsert = 0;
textDelete = "";
textInsert = "";
while (pointer < diffs.length) {
switch ( diffs[pointer][0] ) {
case DIFF_INSERT:
countInsert++;
textInsert += diffs[pointer][1];
break;
case DIFF_DELETE:
countDelete++;
textDelete += diffs[pointer][1];
break;
case DIFF_EQUAL:
// Upon reaching an equality, check for prior redundancies.
if (countDelete >= 1 && countInsert >= 1) {
// Delete the offending records and add the merged ones.
diffs.splice(pointer - countDelete - countInsert,
countDelete + countInsert);
pointer = pointer - countDelete - countInsert;
a = this.DiffMain(textDelete, textInsert, false, deadline);
for (j = a.length - 1; j >= 0; j--) {
diffs.splice( pointer, 0, a[j] );
}
pointer = pointer + a.length;
}
countInsert = 0;
countDelete = 0;
textDelete = "";
textInsert = "";
break;
}
pointer++;
}
diffs.pop(); // Remove the dummy entry at the end.
return diffs;
};
/**
* Find the 'middle snake' of a diff, split the problem in two
* and return the recursively constructed diff.
* See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations.
* @param {string} text1 Old string to be diffed.
* @param {string} text2 New string to be diffed.
* @param {number} deadline Time at which to bail if not yet complete.
* @return {!Array.<!DiffMatchPatch.Diff>} Array of diff tuples.
* @private
*/
DiffMatchPatch.prototype.diffBisect = function(text1, text2, deadline) {
var text1Length, text2Length, maxD, vOffset, vLength,
v1, v2, x, delta, front, k1start, k1end, k2start,
k2end, k2Offset, k1Offset, x1, x2, y1, y2, d, k1, k2;
// Cache the text lengths to prevent multiple calls.
text1Length = text1.length;
text2Length = text2.length;
maxD = Math.ceil((text1Length + text2Length) / 2);
vOffset = maxD;
vLength = 2 * maxD;
v1 = new Array(vLength);
v2 = new Array(vLength);
// Setting all elements to -1 is faster in Chrome & Firefox than mixing
// integers and undefined.
for (x = 0; x < vLength; x++) {
v1[x] = -1;
v2[x] = -1;
}
v1[vOffset + 1] = 0;
v2[vOffset + 1] = 0;
delta = text1Length - text2Length;
// If the total number of characters is odd, then the front path will collide
// with the reverse path.
front = (delta % 2 !== 0);
// Offsets for start and end of k loop.
// Prevents mapping of space beyond the grid.
k1start = 0;
k1end = 0;
k2start = 0;
k2end = 0;
for (d = 0; d < maxD; d++) {
// Bail out if deadline is reached.
if ((new Date()).getTime() > deadline) {
break;
}
// Walk the front path one step.
for (k1 = -d + k1start; k1 <= d - k1end; k1 += 2) {
k1Offset = vOffset + k1;
if ( k1 === -d || ( k1 !== d && v1[ k1Offset - 1 ] < v1[ k1Offset + 1 ] ) ) {
x1 = v1[k1Offset + 1];
} else {
x1 = v1[k1Offset - 1] + 1;
}
y1 = x1 - k1;
while (x1 < text1Length && y1 < text2Length &&
text1.charAt(x1) === text2.charAt(y1)) {
x1++;
y1++;
}
v1[k1Offset] = x1;
if (x1 > text1Length) {
// Ran off the right of the graph.
k1end += 2;
} else if (y1 > text2Length) {
// Ran off the bottom of the graph.
k1start += 2;
} else if (front) {
k2Offset = vOffset + delta - k1;
if (k2Offset >= 0 && k2Offset < vLength && v2[k2Offset] !== -1) {
// Mirror x2 onto top-left coordinate system.
x2 = text1Length - v2[k2Offset];
if (x1 >= x2) {
// Overlap detected.
return this.diffBisectSplit(text1, text2, x1, y1, deadline);
}
}
}
}
// Walk the reverse path one step.
for (k2 = -d + k2start; k2 <= d - k2end; k2 += 2) {
k2Offset = vOffset + k2;
if ( k2 === -d || (k2 !== d && v2[ k2Offset - 1 ] < v2[ k2Offset + 1 ] ) ) {
x2 = v2[k2Offset + 1];
} else {
x2 = v2[k2Offset - 1] + 1;
}
y2 = x2 - k2;
while (x2 < text1Length && y2 < text2Length &&
text1.charAt(text1Length - x2 - 1) ===
text2.charAt(text2Length - y2 - 1)) {
x2++;
y2++;
}
v2[k2Offset] = x2;
if (x2 > text1Length) {
// Ran off the left of the graph.
k2end += 2;
} else if (y2 > text2Length) {
// Ran off the top of the graph.
k2start += 2;
} else if (!front) {
k1Offset = vOffset + delta - k2;
if (k1Offset >= 0 && k1Offset < vLength && v1[k1Offset] !== -1) {
x1 = v1[k1Offset];
y1 = vOffset + x1 - k1Offset;
// Mirror x2 onto top-left coordinate system.
x2 = text1Length - x2;
if (x1 >= x2) {
// Overlap detected.
return this.diffBisectSplit(text1, text2, x1, y1, deadline);
}
}
}
}
}
// Diff took too long and hit the deadline or
// number of diffs equals number of characters, no commonality at all.
return [
[ DIFF_DELETE, text1 ],
[ DIFF_INSERT, text2 ]
];
};
/**
* Given the location of the 'middle snake', split the diff in two parts
* and recurse.
* @param {string} text1 Old string to be diffed.
* @param {string} text2 New string to be diffed.
* @param {number} x Index of split point in text1.
* @param {number} y Index of split point in text2.
* @param {number} deadline Time at which to bail if not yet complete.
* @return {!Array.<!DiffMatchPatch.Diff>} Array of diff tuples.
* @private
*/
DiffMatchPatch.prototype.diffBisectSplit = function( text1, text2, x, y, deadline ) {
var text1a, text1b, text2a, text2b, diffs, diffsb;
text1a = text1.substring(0, x);
text2a = text2.substring(0, y);
text1b = text1.substring(x);
text2b = text2.substring(y);
// Compute both diffs serially.
diffs = this.DiffMain(text1a, text2a, false, deadline);
diffsb = this.DiffMain(text1b, text2b, false, deadline);
return diffs.concat(diffsb);
};
/**
* Reduce the number of edits by eliminating semantically trivial equalities.
* @param {!Array.<!DiffMatchPatch.Diff>} diffs Array of diff tuples.
*/
DiffMatchPatch.prototype.diffCleanupSemantic = function(diffs) {
var changes, equalities, equalitiesLength, lastequality,
pointer, lengthInsertions2, lengthDeletions2, lengthInsertions1,
lengthDeletions1, deletion, insertion, overlapLength1, overlapLength2;
changes = false;
equalities = []; // Stack of indices where equalities are found.
equalitiesLength = 0; // Keeping our own length var is faster in JS.
/** @type {?string} */
lastequality = null;
// Always equal to diffs[equalities[equalitiesLength - 1]][1]
pointer = 0; // Index of current position.
// Number of characters that changed prior to the equality.
lengthInsertions1 = 0;
lengthDeletions1 = 0;
// Number of characters that changed after the equality.
lengthInsertions2 = 0;
lengthDeletions2 = 0;
while (pointer < diffs.length) {
if (diffs[pointer][0] === DIFF_EQUAL) { // Equality found.
equalities[equalitiesLength++] = pointer;
lengthInsertions1 = lengthInsertions2;
lengthDeletions1 = lengthDeletions2;
lengthInsertions2 = 0;
lengthDeletions2 = 0;
lastequality = diffs[pointer][1];
} else { // An insertion or deletion.
if (diffs[pointer][0] === DIFF_INSERT) {
lengthInsertions2 += diffs[pointer][1].length;
} else {
lengthDeletions2 += diffs[pointer][1].length;
}
// Eliminate an equality that is smaller or equal to the edits on both
// sides of it.
if (lastequality && (lastequality.length <=
Math.max(lengthInsertions1, lengthDeletions1)) &&
(lastequality.length <= Math.max(lengthInsertions2,
lengthDeletions2))) {
// Duplicate record.
diffs.splice( equalities[ equalitiesLength - 1 ], 0, [ DIFF_DELETE, lastequality ] );
// Change second copy to insert.
diffs[equalities[equalitiesLength - 1] + 1][0] = DIFF_INSERT;
// Throw away the equality we just deleted.
equalitiesLength--;
// Throw away the previous equality (it needs to be reevaluated).
equalitiesLength--;
pointer = equalitiesLength > 0 ? equalities[equalitiesLength - 1] : -1;
lengthInsertions1 = 0; // Reset the counters.
lengthDeletions1 = 0;
lengthInsertions2 = 0;
lengthDeletions2 = 0;
lastequality = null;
changes = true;
}
}
pointer++;
}
// Normalize the diff.
if (changes) {
this.diffCleanupMerge(diffs);
}
// Find any overlaps between deletions and insertions.
// e.g: <del>abcxxx</del><ins>xxxdef</ins>
// -> <del>abc</del>xxx<ins>def</ins>
// e.g: <del>xxxabc</del><ins>defxxx</ins>
// -> <ins>def</ins>xxx<del>abc</del>
// Only extract an overlap if it is as big as the edit ahead or behind it.
pointer = 1;
while (pointer < diffs.length) {
if (diffs[pointer - 1][0] === DIFF_DELETE &&
diffs[pointer][0] === DIFF_INSERT) {
deletion = diffs[pointer - 1][1];
insertion = diffs[pointer][1];
overlapLength1 = this.diffCommonOverlap(deletion, insertion);
overlapLength2 = this.diffCommonOverlap(insertion, deletion);
if (overlapLength1 >= overlapLength2) {
if (overlapLength1 >= deletion.length / 2 ||
overlapLength1 >= insertion.length / 2) {
// Overlap found. Insert an equality and trim the surrounding edits.
diffs.splice( pointer, 0, [ DIFF_EQUAL, insertion.substring( 0, overlapLength1 ) ] );
diffs[pointer - 1][1] =
deletion.substring(0, deletion.length - overlapLength1);
diffs[pointer + 1][1] = insertion.substring(overlapLength1);
pointer++;
}
} else {
if (overlapLength2 >= deletion.length / 2 ||
overlapLength2 >= insertion.length / 2) {
// Reverse overlap found.
// Insert an equality and swap and trim the surrounding edits.
diffs.splice( pointer, 0, [ DIFF_EQUAL, deletion.substring( 0, overlapLength2 ) ] );
diffs[pointer - 1][0] = DIFF_INSERT;
diffs[pointer - 1][1] =
insertion.substring(0, insertion.length - overlapLength2);
diffs[pointer + 1][0] = DIFF_DELETE;
diffs[pointer + 1][1] =
deletion.substring(overlapLength2);
pointer++;
}
}
pointer++;
}
pointer++;
}
};
/**
* Determine if the suffix of one string is the prefix of another.
* @param {string} text1 First string.
* @param {string} text2 Second string.
* @return {number} The number of characters common to the end of the first
* string and the start of the second string.
* @private
*/
DiffMatchPatch.prototype.diffCommonOverlap = function(text1, text2) {
var text1Length, text2Length, textLength,
best, length, pattern, found;
// Cache the text lengths to prevent multiple calls.
text1Length = text1.length;
text2Length = text2.length;
// Eliminate the null case.
if (text1Length === 0 || text2Length === 0) {
return 0;
}
// Truncate the longer string.
if (text1Length > text2Length) {
text1 = text1.substring(text1Length - text2Length);
} else if (text1Length < text2Length) {
text2 = text2.substring(0, text1Length);
}
textLength = Math.min(text1Length, text2Length);
// Quick check for the worst case.
if (text1 === text2) {
return textLength;
}
// Start by looking for a single character match
// and increase length until no match is found.
// Performance analysis: http://neil.fraser.name/news/2010/11/04/
best = 0;
length = 1;
while (true) {
pattern = text1.substring(textLength - length);
found = text2.indexOf(pattern);
if (found === -1) {
return best;
}
length += found;
if (found === 0 || text1.substring(textLength - length) ===
text2.substring(0, length)) {
best = length;
length++;
}
}
};
/**
* Split two texts into an array of strings. Reduce the texts to a string of
* hashes where each Unicode character represents one line.
* @param {string} text1 First string.
* @param {string} text2 Second string.
* @return {{chars1: string, chars2: string, lineArray: !Array.<string>}}
* An object containing the encoded text1, the encoded text2 and
* the array of unique strings.
* The zeroth element of the array of unique strings is intentionally blank.
* @private
*/
DiffMatchPatch.prototype.diffLinesToChars = function(text1, text2) {
var lineArray, lineHash, chars1, chars2;
lineArray = []; // e.g. lineArray[4] === 'Hello\n'
lineHash = {}; // e.g. lineHash['Hello\n'] === 4
// '\x00' is a valid character, but various debuggers don't like it.
// So we'll insert a junk entry to avoid generating a null character.
lineArray[0] = "";
/**
* Split a text into an array of strings. Reduce the texts to a string of
* hashes where each Unicode character represents one line.
* Modifies linearray and linehash through being a closure.
* @param {string} text String to encode.
* @return {string} Encoded string.
* @private
*/
function diffLinesToCharsMunge(text) {
var chars, lineStart, lineEnd, lineArrayLength, line;
chars = "";
// Walk the text, pulling out a substring for each line.
// text.split('\n') would would temporarily double our memory footprint.
// Modifying text would create many large strings to garbage collect.
lineStart = 0;
lineEnd = -1;
// Keeping our own length variable is faster than looking it up.
lineArrayLength = lineArray.length;
while (lineEnd < text.length - 1) {
lineEnd = text.indexOf("\n", lineStart);
if (lineEnd === -1) {
lineEnd = text.length - 1;
}
line = text.substring(lineStart, lineEnd + 1);
lineStart = lineEnd + 1;
if (lineHash.hasOwnProperty ? lineHash.hasOwnProperty(line) :
(lineHash[line] !== undefined)) {
chars += String.fromCharCode( lineHash[ line ] );
} else {
chars += String.fromCharCode(lineArrayLength);
lineHash[line] = lineArrayLength;
lineArray[lineArrayLength++] = line;
}
}
return chars;
}
chars1 = diffLinesToCharsMunge(text1);
chars2 = diffLinesToCharsMunge(text2);
return {
chars1: chars1,
chars2: chars2,
lineArray: lineArray
};
};
/**
* Rehydrate the text in a diff from a string of line hashes to real lines of
* text.
* @param {!Array.<!DiffMatchPatch.Diff>} diffs Array of diff tuples.
* @param {!Array.<string>} lineArray Array of unique strings.
* @private
*/
DiffMatchPatch.prototype.diffCharsToLines = function( diffs, lineArray ) {
var x, chars, text, y;
for ( x = 0; x < diffs.length; x++ ) {
chars = diffs[x][1];
text = [];
for ( y = 0; y < chars.length; y++ ) {
text[y] = lineArray[chars.charCodeAt(y)];
}
diffs[x][1] = text.join("");
}
};
/**
* Reorder and merge like edit sections. Merge equalities.
* Any edit section can move as long as it doesn't cross an equality.
* @param {!Array.<!DiffMatchPatch.Diff>} diffs Array of diff tuples.
*/
DiffMatchPatch.prototype.diffCleanupMerge = function(diffs) {
var pointer, countDelete, countInsert, textInsert, textDelete,
commonlength, changes;
diffs.push( [ DIFF_EQUAL, "" ] ); // Add a dummy entry at the end.
pointer = 0;
countDelete = 0;
countInsert = 0;
textDelete = "";
textInsert = "";
commonlength;
while (pointer < diffs.length) {
switch ( diffs[ pointer ][ 0 ] ) {
case DIFF_INSERT:
countInsert++;
textInsert += diffs[pointer][1];
pointer++;
break;
case DIFF_DELETE:
countDelete++;
textDelete += diffs[pointer][1];
pointer++;
break;
case DIFF_EQUAL:
// Upon reaching an equality, check for prior redundancies.
if (countDelete + countInsert > 1) {
if (countDelete !== 0 && countInsert !== 0) {
// Factor out any common prefixies.
commonlength = this.diffCommonPrefix(textInsert, textDelete);
if (commonlength !== 0) {
if ((pointer - countDelete - countInsert) > 0 &&
diffs[pointer - countDelete - countInsert - 1][0] ===
DIFF_EQUAL) {
diffs[pointer - countDelete - countInsert - 1][1] +=
textInsert.substring(0, commonlength);
} else {
diffs.splice( 0, 0, [ DIFF_EQUAL,
textInsert.substring( 0, commonlength )
] );
pointer++;
}
textInsert = textInsert.substring(commonlength);
textDelete = textDelete.substring(commonlength);
}
// Factor out any common suffixies.
commonlength = this.diffCommonSuffix(textInsert, textDelete);
if (commonlength !== 0) {
diffs[pointer][1] = textInsert.substring(textInsert.length -
commonlength) + diffs[pointer][1];
textInsert = textInsert.substring(0, textInsert.length -
commonlength);
textDelete = textDelete.substring(0, textDelete.length -
commonlength);
}
}
// Delete the offending records and add the merged ones.
if (countDelete === 0) {
diffs.splice( pointer - countInsert,
countDelete + countInsert, [ DIFF_INSERT, textInsert ] );
} else if (countInsert === 0) {
diffs.splice( pointer - countDelete,
countDelete + countInsert, [ DIFF_DELETE, textDelete ] );
} else {
diffs.splice( pointer - countDelete - countInsert,
countDelete + countInsert, [ DIFF_DELETE, textDelete ], [ DIFF_INSERT, textInsert ] );
}
pointer = pointer - countDelete - countInsert +
(countDelete ? 1 : 0) + (countInsert ? 1 : 0) + 1;
} else if (pointer !== 0 && diffs[pointer - 1][0] === DIFF_EQUAL) {
// Merge this equality with the previous one.
diffs[pointer - 1][1] += diffs[pointer][1];
diffs.splice(pointer, 1);
} else {
pointer++;
}
countInsert = 0;
countDelete = 0;
textDelete = "";
textInsert = "";
break;
}
}
if (diffs[diffs.length - 1][1] === "") {
diffs.pop(); // Remove the dummy entry at the end.
}
// Second pass: look for single edits surrounded on both sides by equalities
// which can be shifted sideways to eliminate an equality.
// e.g: A<ins>BA</ins>C -> <ins>AB</ins>AC
changes = false;
pointer = 1;
// Intentionally ignore the first and last element (don't need checking).
while (pointer < diffs.length - 1) {
if (diffs[pointer - 1][0] === DIFF_EQUAL &&
diffs[pointer + 1][0] === DIFF_EQUAL) {
// This is a single edit surrounded by equalities.
if ( diffs[ pointer ][ 1 ].substring( diffs[ pointer ][ 1 ].length -
diffs[ pointer - 1 ][ 1 ].length ) === diffs[ pointer - 1 ][ 1 ] ) {
// Shift the edit over the previous equality.
diffs[pointer][1] = diffs[pointer - 1][1] +
diffs[pointer][1].substring(0, diffs[pointer][1].length -
diffs[pointer - 1][1].length);
diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1];
diffs.splice(pointer - 1, 1);
changes = true;
} else if ( diffs[ pointer ][ 1 ].substring( 0, diffs[ pointer + 1 ][ 1 ].length ) ===
diffs[ pointer + 1 ][ 1 ] ) {
// Shift the edit over the next equality.
diffs[pointer - 1][1] += diffs[pointer + 1][1];
diffs[pointer][1] =
diffs[pointer][1].substring(diffs[pointer + 1][1].length) +
diffs[pointer + 1][1];
diffs.splice(pointer + 1, 1);
changes = true;
}
}
pointer++;
}
// If shifts were made, the diff needs reordering and another shift sweep.
if (changes) {
this.diffCleanupMerge(diffs);
}
};
return function(o, n) {
var diff, output, text;
diff = new DiffMatchPatch();
output = diff.DiffMain(o, n);
//console.log(output);
diff.diffCleanupEfficiency(output);
text = diff.diffPrettyHtml(output);
return text;
};
}());
// jscs:enable
@ -2256,7 +3176,14 @@ function addEvent( elem, type, fn ) {
} else if ( elem.attachEvent ) {
// support: IE <9
elem.attachEvent( "on" + type, fn );
elem.attachEvent( "on" + type, function() {
var event = window.event;
if ( !event.target ) {
event.target = event.srcElement || document;
}
fn.call( elem, event );
});
}
}
@ -2427,12 +3354,16 @@ function setUrl( params ) {
}
function applyUrlParams() {
var selectBox = id( "qunit-modulefilter" ),
selection = decodeURIComponent( selectBox.options[ selectBox.selectedIndex ].value ),
var selectedModule,
modulesList = id( "qunit-modulefilter" ),
filter = id( "qunit-filter-input" ).value;
selectedModule = modulesList ?
decodeURIComponent( modulesList.options[ modulesList.selectedIndex ].value ) :
undefined;
window.location = setUrl({
module: ( selection === "" ) ? undefined : selection,
module: ( selectedModule === "" ) ? undefined : selectedModule,
filter: ( filter === "" ) ? undefined : filter,
// Remove testId filter
@ -2588,9 +3519,14 @@ function storeFixture() {
function appendUserAgent() {
var userAgent = id( "qunit-userAgent" );
if ( userAgent ) {
userAgent.innerHTML = "";
userAgent.appendChild( document.createTextNode( navigator.userAgent ) );
userAgent.appendChild(
document.createTextNode(
"QUnit " + QUnit.version + "; " + navigator.userAgent
)
);
}
}
@ -2733,7 +3669,7 @@ function getNameHtml( name, module ) {
}
QUnit.testStart(function( details ) {
var running, testBlock;
var running, testBlock, bad;
testBlock = id( "qunit-test-output-" + details.testId );
if ( testBlock ) {
@ -2746,7 +3682,13 @@ QUnit.testStart(function( details ) {
running = id( "qunit-testresult" );
if ( running ) {
running.innerHTML = "Running: <br />" + getNameHtml( details.name, details.module );
bad = QUnit.config.reorder && defined.sessionStorage &&
+sessionStorage.getItem( "qunit-test-" + details.module + "-" + details.name );
running.innerHTML = ( bad ?
"Rerunning previously failed test: <br />" :
"Running: <br />" ) +
getNameHtml( details.name, details.module );
}
});
@ -2779,6 +3721,15 @@ QUnit.log(function( details ) {
actual + "</pre></td></tr>" +
"<tr class='test-diff'><th>Diff: </th><td><pre>" +
QUnit.diff( expected, actual ) + "</pre></td></tr>";
} else {
if ( expected.indexOf( "[object Array]" ) !== -1 ||
expected.indexOf( "[object Object]" ) !== -1 ) {
message += "<tr class='test-message'><th>Message: </th><td>" +
"Diff suppressed as the depth of object is more than current max depth (" +
QUnit.config.maxDepth + ").<p>Hint: Use <code>QUnit.dump.maxDepth</code> to " +
" run with a higher max depth or <a href='" + setUrl({ maxDepth: -1 }) + "'>" +
"Rerun</a> without max depth.</p></td></tr>";
}
}
if ( details.source ) {
@ -2863,13 +3814,15 @@ QUnit.testDone(function( details ) {
}
});
if ( !defined.document || document.readyState === "complete" ) {
if ( defined.document ) {
if ( document.readyState === "complete" ) {
QUnit.load();
} else {
addEvent( window, "load", QUnit.load );
}
} else {
config.pageLoaded = true;
config.autorun = true;
}
if ( defined.document ) {
addEvent( window, "load", QUnit.load );
}
})();

View File

@ -1,25 +1,17 @@
// package metadata file for Meteor.js
/* jshint strict:false */
/* global Package:true */
Package.describe({
name: 'twbs:bootstrap', // http://atmospherejs.com/twbs/bootstrap
summary: 'The most popular front-end framework for developing responsive, mobile first projects on the web.',
version: '3.3.5',
version: '4.0.0-alpha',
git: 'https://github.com/twbs/bootstrap.git'
});
Package.onUse(function (api) {
api.versionsFrom('METEOR@1.0');
api.use('jquery', 'client');
api.addFiles([
'dist/fonts/glyphicons-halflings-regular.eot',
'dist/fonts/glyphicons-halflings-regular.svg',
'dist/fonts/glyphicons-halflings-regular.ttf',
'dist/fonts/glyphicons-halflings-regular.woff',
'dist/fonts/glyphicons-halflings-regular.woff2'
], 'client', { isAsset: true });
api.addFiles([
'dist/css/bootstrap.css',
'dist/js/bootstrap.js'

View File

@ -44,7 +44,6 @@
"grunt-contrib-csslint": "~0.4.0",
"grunt-contrib-cssmin": "~0.12.2",
"grunt-contrib-jade": "~0.14.1",
"grunt-contrib-jshint": "~0.11.0",
"grunt-contrib-qunit": "~0.5.2",
"grunt-contrib-sass": "^0.8.1",
"grunt-contrib-uglify": "~0.8.0",

View File

@ -384,7 +384,7 @@ input[type="checkbox"] {
// Requires wrapping inputs and labels with `.form-group` for proper display of
// default HTML form controls and our custom form controls (e.g., input groups).
//
// Heads up! This is mixin-ed into `.navbar-form` in navbars.less.
// Heads up! This is mixin-ed into `.navbar-form` in _navbar.scss.
.form-inline {

View File

@ -28,7 +28,6 @@
@import "mixins/label";
@import "mixins/reset-filter";
@import "mixins/resize";
@import "mixins/responsive-visibility";
@import "mixins/screen-reader";
@import "mixins/size";
@import "mixins/tab-focus";

View File

@ -44,6 +44,6 @@
.hidden-print {
@media print {
@include responsive-invisibility(".hidden-print");
display: none !important;
}
}

View File

@ -1,21 +0,0 @@
// Responsive utilities
//
// More easily include all the states for responsive-utilities.less.
// [converter] $parent hack
@mixin responsive-visibility($parent) {
#{$parent} {
display: block !important;
}
table#{$parent} { display: table !important; }
tr#{$parent} { display: table-row !important; }
th#{$parent},
td#{$parent} { display: table-cell !important; }
}
// [converter] $parent hack
@mixin responsive-invisibility($parent) {
#{$parent} {
display: none !important;
}
}

View File

@ -13,16 +13,13 @@ Similar to git, `s3_cache.py` makes the assumption that [SHA-256 will effectivel
### For Bootstrap specifically
`s3_cache.py` is used to cache the npm packages that our Grunt tasks depend on and the RubyGems that Jekyll depends on. (Jekyll is needed to compile our docs to HTML so that we can run them thru an HTML5 validator.)
`s3_cache.py` is used to cache the npm packages that our Grunt tasks depend on.
For npm, the `node_modules` directory is cached based on our `npm-shrinkwrap.json` file.
For RubyGems, the `gemdir` of the current RVM-selected Ruby is cached based on the `pseudo_Gemfile.lock` file generated by our Travis build script.
`pseudo_Gemfile.lock` contains the versions of Ruby and Jekyll that we're using (read our `.travis.yml` for details).
## Why is `s3_cache.py` necessary?
`s3_cache.py` is used to speed up Bootstrap's Travis builds. Installing npm packages and RubyGems used to take up a significant fraction of our total build times. Also, at the time that `s3_cache.py` was written, npm was occasionally unreliable.
`s3_cache.py` is used to speed up Bootstrap's Travis builds. Installing npm packages used to take up a significant fraction of our total build times. Also, at the time that `s3_cache.py` was written, npm was occasionally unreliable.
Travis does offer built-in caching on their paid plans, but this do-it-ourselves S3 solution is significantly cheaper since we only need caching and not Travis' other paid features.

View File

@ -3,10 +3,5 @@
"key": "./npm-shrinkwrap.json",
"cache": "../node_modules",
"generate": "./uncached-npm-install.sh"
},
"rubygems": {
"key": "$BUNDLE_GEMFILE",
"cache": "../vendor/cache",
"generate": "cd .. ; bundle install --path=\"`pwd`/vendor/cache\""
}
}

View File

@ -1,7 +0,0 @@
# Ruby Gems for the 'core' set of tests
# Run `grunt update-gemfile-lock` to update to the latest compatible versions
source 'https://rubygems.org'
gem 'sass', '~> 3.4.9'
gem 'scss-lint', '~> 0.31'

View File

@ -1,15 +0,0 @@
GEM
remote: https://rubygems.org/
specs:
rainbow (2.0.0)
sass (3.4.9)
scss-lint (0.31.0)
rainbow (~> 2.0)
sass (~> 3.4.1)
PLATFORMS
ruby
DEPENDENCIES
sass (~> 3.4.9)
scss-lint (~> 0.31)