Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[close #1] First spec, linkify simple value
- Loading branch information
Showing
9 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
# | ||
#https://github.com/dsimard/ready.js | ||
|
||
readyjs ready.conf.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
(function($){ | ||
|
||
var noProtocolUrl = /(^|["'(\s]|<)(www\..+?\..+?)((?:[:?]|\.+)?(?=(?:\s|$)|>|[)"',]))/g, | ||
httpOrMailtoUrl = /(^|["'(\s]|<)((?:(?:https?|ftp):\/\/|mailto:).+?)((?:[:?]|\.+)?(?=(?:\s|$)|>|[)"',]))/g; | ||
|
||
$.fn.linkify = function() { | ||
$(this).html( | ||
$(this).html() | ||
.replace( noProtocolUrl, '$1<a href="<``>://$2">$2</a>$3' ) | ||
.replace( httpOrMailtoUrl, '$1<a href="$2">$2</a>$3' ) | ||
.replace( /"<``>/g, '"http' ) | ||
); | ||
return $(this); | ||
}; | ||
|
||
})(jQuery); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ "name" : "linkify" | ||
, "version" : "0.0.1" | ||
, "description" : "Linkify plugin for jQuery" | ||
, "main" : "runspecs.js" | ||
, "scripts" : | ||
{ | ||
"test": "node runspecs.js" | ||
} | ||
, "dependencies" : | ||
{ | ||
"dox" : "0.0.5", | ||
"ready.js" : "1.3.3", | ||
"jsdom" : "0.2.0", | ||
"jquery" : "1.5.1", | ||
"jasmine-node" : "1.0.6" | ||
} | ||
, "engines" : { "node" : ">=v0.4.12" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"src" : "./lib" | ||
, "dest" : "./minified" | ||
, "runGCompiler" : true | ||
, runJslint : true | ||
, aggregateTo : "linkify.min.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
global.window = require("jsdom") | ||
.jsdom() | ||
.createWindow(); | ||
global.jQuery = require("jquery").create(window); | ||
|
||
var jasmine = require('jasmine-node'); | ||
|
||
require(__dirname + "/lib/linkify.js") | ||
|
||
var isVerbose = true; | ||
var showColors = true; | ||
jasmine.executeSpecsInFolder(__dirname + '/specs', function(runner, log){ | ||
process.exit(runner.results().failedCount?1:0); | ||
}, isVerbose, showColors); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
var linkify = function(url) { | ||
return jQuery("<div>").html(url).linkify(); | ||
}, | ||
linkifiedWithHttps = "<a href=\"https://www.mifont.org\">https://www.mifont.org</a>", | ||
linkifiedWithHttp = "<a href=\"http://www.mifont.org\">http://www.mifont.org</a>", | ||
linkified = "<a href=\"http://www.mifont.org\">www.mifont.org</a>"; | ||
|
||
|
||
describe("Linkify simple value", function() { | ||
|
||
describe("When there is protocol in URL", function() { | ||
|
||
beforeEach( function () { | ||
jQuery("body").html(""); | ||
}); | ||
|
||
it('should url with http', function(){ | ||
expect( linkifiedWithHttp ).toEqual( linkify("http://www.mifont.org").html() ); | ||
}); | ||
|
||
it('should url with https', function(){ | ||
expect( linkifiedWithHttps ).toEqual( linkify("https://www.mifont.org").html() ); | ||
}); | ||
|
||
}); | ||
|
||
describe("When there isn't protocol in URL", function() { | ||
|
||
it('should url with http', function(){ | ||
expect( linkified ).toEqual( linkify("www.mifont.org").html() ); | ||
}); | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
# | ||
#instrument files | ||
#https://github.com/visionmedia/node-jscoverage | ||
#node-jscoverage lib lib-cov | ||
#TODO | ||
|
||
#dox --title JSONForm lib/jsonform.js > docs/index.html | ||
|
||
#https://github.com/dsimard/ready.js | ||
readyjs ready.conf.js | ||
|
||
#execute tests | ||
node runspecs.js |
Large diffs are not rendered by default.
Oops, something went wrong.