Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update project to be browserify/webpack-compatible #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -12,11 +12,13 @@ Download the [production version][min] or the [development version][max].

Run `npm install` to install the plugin dependencies

* John Resig's Class.create.js 1.1.4+
* John Resig's [Class.extend](https://github.com/mattinsler/resig-class)



Or download the [Class Library][classes_lib] manually.

[classes_lib]: https://raw.github.com/chrisisbeef/jquery-encoder/master/list/class.min.js
[classes_lib]: https://raw.githubusercontent.com/mattinsler/resig-class/master/index.js

## Usage

12 changes: 0 additions & 12 deletions libs/class.min.js

This file was deleted.

12 changes: 0 additions & 12 deletions libs/jquery-loader.js

This file was deleted.

9,555 changes: 0 additions & 9,555 deletions libs/jquery/jquery.js

This file was deleted.

244 changes: 0 additions & 244 deletions libs/qunit/qunit.css

This file was deleted.

2,152 changes: 0 additions & 2,152 deletions libs/qunit/qunit.js

This file was deleted.

29 changes: 25 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
{
"name": "jquery-plugin",
"version": "0.0.0-ignored",
"name": "jquery-encoder",
"version": "1.0.0",
"engines": {
"node": ">= 0.8.0"
},
"main": "src/jquery.jquery-encoder.js",
"scripts": {
"test": "grunt qunit"
},
"dependencies": {
"jquery": "*",
"resig-class": "^1.0.0"
},
"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-clean": "~0.4.0",
@@ -15,6 +20,22 @@
"grunt-contrib-qunit": "~0.2.0",
"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-watch": "~0.4.0",
"node.class": "^1.1.4"
}
"qunitjs": "^1.23.1"
},
"license": "MIT",
"description": "A Contextual Encoding Plugin for jQuery",
"repository": {
"type": "git",
"url": "https://github.com/chrisisbeef/jquery-encoder.git"
},
"keywords": [
"jquery",
"plugin",
"encode"
],
"author": "Chris Schmidt",
"bugs": {
"url": "https://github.com/chrisisbeef/jquery-encoder/issues"
},
"homepage": "https://github.com/chrisisbeef/jquery-encoder#readme"
}
31 changes: 29 additions & 2 deletions src/jquery.jquery-encoder.js
Original file line number Diff line number Diff line change
@@ -4,7 +4,34 @@
* The jquery-encoder is published by OWASP under the MIT license. You should read and accept the
* LICENSE before you use, modify, and/or redistribute this software.
*/
(function($) {
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery', 'resig-class'], factory);
} else if (typeof module === 'object' && module.exports) {
// Node/CommonJS
module.exports = function( root, jQuery ) {
var Class = require('resig-class');
if ( jQuery === undefined ) {
// require('jQuery') returns a factory that requires window to
// build a jQuery instance, we normalize how we use modules
// that require this pattern but the window provided is a noop
// if it's defined (how jquery works)
if ( typeof window !== 'undefined' ) {
jQuery = require('jquery');
}
else {
jQuery = require('jquery')(root);
}
}
factory(jQuery, Class);
return jQuery;
};
} else {
// Browser globals
factory(jQuery, Class);
}
}(function ($, Class) {
var default_immune = {
'js' : [',','.','_',' ']
};
@@ -1446,4 +1473,4 @@
$.encoder = Object.preventExtensions($.encoder);
$.fn.encode = Object.preventExtensions($.fn.encode);
}
})(jQuery);
}));
10 changes: 3 additions & 7 deletions test/jquery-encoder.html
Original file line number Diff line number Diff line change
@@ -12,14 +12,10 @@
<head>
<meta charset="utf-8">
<title>jQuery Encoder Plugin Test Suite</title>
<!-- Load local jQuery. This can be overridden with a ?jquery=___ param. -->
<!--<script type="text/javascript" src="https://code.jquery.com/jquery-1.9.0.min.js"></script>-->
<script src="../libs/jquery-loader.js"></script>
<script src="script-loader.js"></script>
<!-- Load local QUnit. -->
<link rel="stylesheet" href="../libs/qunit/qunit.css" media="screen">
<script src="../libs/qunit/qunit.js"></script>
<!-- Load local lib and tests. -->
<script type="text/javascript" src="../node_modules/node.class/class.min.js"></script>
<link rel="stylesheet" href="../node_modules/qunitjs/qunit/qunit.css" media="screen">
<script src="../node_modules/qunitjs/qunit/qunit.js"></script>
<script src="../src/jquery.jquery-encoder.js"></script>
<!--<script src="jquery-encoder_test.js"></script>-->
<!-- Removing access to jQuery and $. But it'll still be available as _$, if
22 changes: 22 additions & 0 deletions test/script-loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(function() {
function loadScript(path) {
// This is the only time I'll ever use document.write, I promise!
document.write('<script src="' + path + '"></script>');
}
function loadClassLib() {
loadScript('../node_modules/resig-class/index.js');
}
function loadJQueryLib() {
// Get any jquery=___ param from the query string.
var jqversion = location.search.match(/[?&]jquery=(.*?)(?=&|$)/);
// If a version was specified, use that version from code.jquery.com.
if (jqversion) {
loadScript('http://code.jquery.com/jquery-' + jqversion[1] + '.js');
} else {
// Default to local jquery
loadScript('../node_modules/jquery/dist/jquery.js');
}
}
loadClassLib();
loadJQueryLib();
}());