mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-11 00:03:10 +00:00
fix(ngdocs): provide test code for syntax links in docs and fix the syntax directive for IE8
This commit is contained in:
parent
2f571a9c83
commit
5f92d4144e
2 changed files with 58 additions and 4 deletions
50
docs/component-spec/syntaxSpec.js
Normal file
50
docs/component-spec/syntaxSpec.js
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
describe('Docs Syntax', function() {
|
||||||
|
|
||||||
|
beforeEach(module('bootstrap'));
|
||||||
|
|
||||||
|
describe('syntax', function() {
|
||||||
|
|
||||||
|
var id, element, document;
|
||||||
|
|
||||||
|
beforeEach(inject(function($compile, $rootScope, $document) {
|
||||||
|
document = $document[0];
|
||||||
|
//create the HTML elements missing in IE8 for this directive
|
||||||
|
document.createElement('nav');
|
||||||
|
|
||||||
|
element = angular.element(
|
||||||
|
'<div>' +
|
||||||
|
'<pre syntax ' +
|
||||||
|
'syntax-github="gh-url" ' +
|
||||||
|
'syntax-plunkr="pl-url" ' +
|
||||||
|
'syntax-fiddle="jf-url">' +
|
||||||
|
'</pre>' +
|
||||||
|
'</div>'
|
||||||
|
);
|
||||||
|
$compile(element)($rootScope);
|
||||||
|
$rootScope.$digest();
|
||||||
|
|
||||||
|
element = element[0];
|
||||||
|
document.body.appendChild(element);
|
||||||
|
}));
|
||||||
|
|
||||||
|
it("should properly prepare a github link in the page", function() {
|
||||||
|
var github = element.querySelector('.syntax-github');
|
||||||
|
expect(github.innerHTML).toMatch(/View on Github/i);
|
||||||
|
expect(github.getAttribute('href')).toBe('gh-url');
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should properly prepare a plunkr link in the page", function() {
|
||||||
|
var plunkr = element.querySelector('.syntax-plunkr');
|
||||||
|
expect(plunkr.innerHTML).toMatch(/View on Plunkr/i);
|
||||||
|
expect(plunkr.getAttribute('href')).toBe('pl-url');
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should properly prepare a jsfiddle link in the page", function() {
|
||||||
|
var jsfiddle = element.querySelector('.syntax-jsfiddle');
|
||||||
|
expect(jsfiddle.innerHTML).toMatch(/View on JSFiddle/i);
|
||||||
|
expect(jsfiddle.getAttribute('href')).toBe('jf-url');
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
12
docs/components/bootstrap/bootstrap.js
vendored
12
docs/components/bootstrap/bootstrap.js
vendored
|
|
@ -57,7 +57,8 @@ directive.syntax = function() {
|
||||||
'<span class="' + icon + '"></span> ' + text +
|
'<span class="' + icon + '"></span> ' + text +
|
||||||
'</a>';
|
'</a>';
|
||||||
};
|
};
|
||||||
var html = '<nav class="syntax-links">';
|
|
||||||
|
var html = '';
|
||||||
var types = {
|
var types = {
|
||||||
'github' : {
|
'github' : {
|
||||||
text : 'View on Github',
|
text : 'View on Github',
|
||||||
|
|
@ -82,11 +83,14 @@ directive.syntax = function() {
|
||||||
html += makeLink(type, data.text, link, data.icon);
|
html += makeLink(type, data.text, link, data.icon);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
html += '</nav>';
|
|
||||||
var nav = angular.element(html);
|
var nav = document.createElement('nav');
|
||||||
|
nav.className = 'syntax-links';
|
||||||
|
nav.innerHTML = html;
|
||||||
|
|
||||||
var node = element[0];
|
var node = element[0];
|
||||||
var par = node.parentNode;
|
var par = node.parentNode;
|
||||||
par.insertBefore(nav[0], node);
|
par.insertBefore(nav, node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue