diff --git a/.gitignore b/.gitignore index a8507049..75eb2460 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,8 @@ dist build/github/jquerypp docs/* npm-debug.log +build/ci/can +build/ci/jquery +build/ci/funcunit +build/ci/steal +dist/ \ No newline at end of file diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 00000000..96725b65 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,54 @@ +{ + "globals": { + + "steal": true, + "can": true, + + + "Zepto": true, + + + "QUnit": true, + "test": true, + "asyncTest": true, + "expect": true, + "module": true, + "ok": true, + "equal": true, + "notEqual": true, + "deepEqual": true, + "notDeepEqual": true, + "strictEqual": true, + "notStrictEqual": true, + "raises": true, + "start": true, + "stop": true + }, + + + "curly": true, + "eqeqeq": true, + "freeze": true, + "indent": 2, + "latedef": true, + "noarg": true, + "undef": true, + "unused": "vars", + "trailing": true, + "maxdepth": 4, + "boss" : true, + + "eqnull": true, + "evil": true, + "loopfunc": true, + "smarttabs": true, + "maxerr" : 200, + + "jquery": true, + "dojo": true, + "mootools": true, + "yui": true, + "browser": true, + "phantom": true, + "rhino": true +} diff --git a/.npmignore b/.npmignore new file mode 100644 index 00000000..05a9d0cf --- /dev/null +++ b/.npmignore @@ -0,0 +1 @@ +!dist/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 62037d2e..7fbd8557 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: node_js -node_js: 0.8 -before_script: build/ci/init.sh -script: phantomjs build/ci/phantom.js http://localhost:8000/jquery/qunit.html \ No newline at end of file +before_install: + - "export DISPLAY=:99.0" + - "sh -e /etc/init.d/xvfb start" +node_js: 0.10 diff --git a/1x1.jpg b/1x1.jpg new file mode 100644 index 00000000..b0d69110 Binary files /dev/null and b/1x1.jpg differ diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 00000000..394c62a9 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,104 @@ +var path = require('path'); +var normalize = function(depName, depLoad, curName, curLoad) { + depName = depName.substring(depName.indexOf('#') + 1, depName.length); + + if(depName === 'dist/jquery') { + return 'jquery'; + } + + if(curLoad) { + depName = path.relative(path.dirname(curLoad.address), depLoad.address); + if(depName[0] !== '.') { + depName = './' + depName; + } + } + + return depName; +}; + +module.exports = function (grunt) { + var _ = grunt.util._; + var builderJSON = grunt.file.readJSON('builder.json'); + var pkg = grunt.file.readJSON('package.json'); + + grunt.initConfig({ + jshint: { + options: { + jshintrc: true + }, + lib: [ + 'dom/**/*.js', 'event/**/*.js', 'lang/**/*.js', 'test/**/*.js' + ] + }, + + 'steal-export': { + dist: { + system: { + config: "package.json!npm", + main: "jquerypp" + }, + outputs: { + "cjs": { + graphs: ['jquerypp'], + format: 'cjs', + useNormalizedDependencies: true, + ignore: ['jquery'], + normalize: normalize, + dest: function(moduleName){ + return path.join(__dirname, 'dist/cjs/' + normalize(moduleName) + '.js'); + } + }, + "amd": { + graphs: ['jquerypp'], + format: 'amd', + useNormalizedDependencies: true, + ignore: ['jquery'], + normalize: normalize, + dest: function(moduleName){ + return path.join(__dirname, 'dist/amd/' + normalize(moduleName) + '.js'); + } + }, + "+global-js": { + ignore: ['jquery'], + exports: { 'jquery/jquery': 'jQuery' } + }, + 'min +global-js': { + minify: true, + dest: path.join(__dirname, 'dist/global/jquerypp.min.js') + } + } + } + }, + + usebanner: { + taskName: { + options: { + position: 'top', + banner: _.template(builderJSON.banner, { + pkg: pkg, + ids: [ 'jQuery++ dist build' ] + }), + linebreak: true + }, + files: { + src: [ 'dist/**/*.js' ] + } + } + }, + + testee: { + options: { + browsers: [ 'firefox' ] + }, + all: ['test.html'] + } + }); + + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('testee'); + grunt.loadNpmTasks('steal-tools'); + grunt.loadNpmTasks('grunt-banner'); + + grunt.registerTask('test', ['testee']); + grunt.registerTask('build', ['steal-export', 'usebanner']); +}; diff --git a/bower.json b/bower.json new file mode 100644 index 00000000..914e3ce5 --- /dev/null +++ b/bower.json @@ -0,0 +1,17 @@ +{ + "name": "jquerypp", + "title": "jQuery++", + "version": "2.0.0", + "repo": "bitovi/canjs", + "description": "jQuery's missing utils and special events", + "main": "can.jquery.js", + "keywords": [ + "mvc", + "canjs", + "can", + "requirejs", + "component", + "amd" + ], + "license": "MIT" +} \ No newline at end of file diff --git a/build/amdify.js b/build/amdify.js deleted file mode 100644 index 017d50cf..00000000 --- a/build/amdify.js +++ /dev/null @@ -1,140 +0,0 @@ -steal('steal/build', 'steal/build/pluginify', function(steal) { - var contents = {}, - modules = {}, - inexcludes = function(excludes, src) { - for(var i = 0; i < excludes.length; i++) { - if(src.indexOf(excludes[i]) !== -1) { - return true; - } - } - return false; - }, - /** - * Creates a variable name from a filename or AMD module name. - * - * @param {String} name The name of the AMD module or file - * @return {String} The variable name - */ - variableName = function(name) { - var start = name.lastIndexOf('/') + 1, - end = name.lastIndexOf('.') !== -1 ? name.lastIndexOf('.') : name.length; - return '__' + name.substring(start, end).replace(/\./g, '_'); - }, - /** - * Returns a steal.File instance from a filename or AMD module name. - * - * @param name - * @param suffix - * @return {*} - */ - getFile = function(name, suffix) { - var suffix = suffix || '.js', file = name; - if(name.indexOf(suffix, name.length - suffix.length) === -1) { - file = file + suffix; - } - return steal.File(file); - }, - /** - * Returns a list of steal dependencies for a given file and caches - * the plain content. - * - * @param {String} file The JavaScript file to load - * @param {Array} excludes A list of dependencies to exclude - * @param {Object} options Options - * @param {Function} callback A callback getting passed an array - * of steals - */ - getDependencies = function(file, excludes, options, callback) { - steal.build.open("steal/rhino/empty.html", { - startFile : file, - skipCallbacks: true - }, function(opener){ - var ret = []; - opener.each(function(stl, text){ - if(!inexcludes(excludes || [], stl.rootSrc.toString())) { - // Add the parsed content to cache - if(!contents[stl.rootSrc.toString().toString()]) { - contents[stl.rootSrc.toString()] = steal.build.pluginify.content(stl, options, text); - } - ret.push(stl); - } - }); - callback(ret); - }, null); - }, - /** - * Creates the actual module recursively - * - * @param {String} name The name of the main module file - * @param {Array} excludes A list of files to exclude - * @param {Object} options The options to use - */ - createModule = function(name, excludes, options) { - getDependencies(name, excludes, options, function(steals) { - var content, - dependencies = [], - names = [], - nameMap = options.names || {}, - map = options.map || {}, - where = getFile(options.out + (map[name] || name)); - - print(' > ' + name + ' -> ' + (map[name] || name)); - - steals.forEach(function(stl) { - var current = (map[stl.rootSrc.toString()] || stl.rootSrc.toString()); - if(stl.rootSrc.toString() !== name) { // Don't include the current file - if(!modules[stl.rootSrc.toString()]) { - createModule(stl.rootSrc.toString(), excludes, options); - } - dependencies.push("'" + current + "'"); - names.push(nameMap[current] || variableName(current)); - } - }); - - content = "define([" + - dependencies.join(',') + - '], function(' + - names.join(', ') + - ') { \n' + - (contents[name] || (' return ' + (options.global || '{}'))) + - ';\n})'; - - modules[name] = content; - - steal.File(where.dir()).mkdirs(); - where.save(content); - }); - }; - - /** - * Creates a set of AMD modules recursively. The `map` options contain a mapping from Steal - * rootSrc filenames to AMD module names. For examples: - * - * { "jquery/dom/compare/compare.js" : "jquerypp/compare" } - * - * Will map "jquery/dom/compare/compare.js" to "jquerypp/compare.js" in the output folder - * and all dependencies as well (e.g. dependent files would `define(['jquery/compare'], ...)`. - * By default it will use the Steal rootSrc name. - * The `names` mapping can be used to map AMD module names to variable names passed to the - * pluginified function. By default this will be the filename without extension, `__` prefixed and - * `.` converted to `_` (looking like `define(['jquery/compare`], function(__compare) { ... })`). - * - * @param {String} source The root JavaScript source file name to generate the modules from. - * @param {Object} options The options for generating AMD modules. - * The following options will be used: - * - * - `out` - The output folder - * - `excludes` - An array of files to exclude (must be the full Steal rootSrc) - * - `map` - A mapping from full Steal rootSrc filenames to the AMD module name. - * Any missing folders will be created automatically. - * - `names` - A mapping from AMD module names (as set in `map` or the default) - * to parameter variable names. - * - `global` - The global option passed to pluginify - */ - steal.build.amdify = function(source, options) { - var out = options.out; - print('Creating AMD modules for ' + source + " in " + options.out); - steal.File(out).mkdirs(); - createModule(source, options.exclude || {}, options); - } -}); diff --git a/build/ci/init.sh b/build/ci/init.sh deleted file mode 100755 index 76f97097..00000000 --- a/build/ci/init.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -BASEDIR=$(dirname $0) -cd $BASEDIR -../../node_modules/.bin/http-server -p 8000 & -git clone https://github.com/jupiterjs/canjs.git can -git clone https://github.com/jupiterjs/steal.git -git clone https://github.com/jupiterjs/jquerypp.git jquery -git clone https://github.com/jupiterjs/funcunit.git -cd funcunit -git submodule update --init --recursive \ No newline at end of file diff --git a/build/ci/phantom.js b/build/ci/phantom.js deleted file mode 100644 index 9200da17..00000000 --- a/build/ci/phantom.js +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Qt+WebKit powered headless test runner using Phantomjs - * - * Phantomjs installation: http://code.google.com/p/phantomjs/wiki/BuildInstructions - * - * Run with: - * phantomjs runner.js [url-of-your-qunit-testsuite] - * - * E.g. - * phantomjs runner.js http://localhost/qunit/test - */ - -var url = phantom.args[0]; - -var page = require('webpage').create(); - -// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this") -page.onConsoleMessage = function(msg) { - console.log(msg); -}; - -page.open(url, function(status){ - if (status !== "success") { - console.log("Unable to access network: " + status); - phantom.exit(1); - } else { - // page.evaluate(addLogging); - var interval = setInterval(function() { - if (finished()) { - clearInterval(interval); - onfinishedTests(); - } - }, 500); - } -}); - -page.onResourceReceived = function(data) { - page.evaluate(function(addLogging) { - // Only add setZeroTimeout to the window object, and hide everything - // else in a closure. - (function() { - var timeouts = []; - var messageName = "zero-timeout-message"; - - // Like setTimeout, but only takes a function argument. There's - // no time argument (always zero) and no arguments (you have to - // use a closure). - function setZeroTimeout(fn) { - timeouts.push(fn); - window.postMessage(messageName, "*"); - } - - function handleMessage(event) { - if (event.source == window && event.data == messageName) { - event.stopPropagation(); - if (timeouts.length > 0) { - var fn = timeouts.shift(); - fn(); - } - } - } - - window.addEventListener("message", handleMessage, true); - - // Add the one thing we want added to the window object. - window.setZeroTimeout = setZeroTimeout; - })(); - - setZeroTimeout(function() { - if(window.QUnit && !window.QUnit.__logging) { - console.log('Adding logging'); - addLogging(); - window.QUnit.__logging = true; - } - }); - }, addLogging); -} - -function finished() { - return page.evaluate(function(){ - return !!window.qunitDone; - }); -} - -function onfinishedTests() { - var output = page.evaluate(function() { - return JSON.stringify(window.qunitDone); - }); - phantom.exit(JSON.parse(output).failed > 0 ? 1 : 0); -} - -function addLogging() { - var print = function(msg) { - console.log(msg); - }; - - QUnit.begin(function() { - print("Starting ..."); - }); - - QUnit.log(function(o){ - var result = o.result, - message = o.message || 'okay'; - - // Testdox layout - if(result) { - print(' [x] ' + message); - } else { - print(' [ ] ' + message); - if(o.expected) { - print(' Actual: ' + o.actual); - print(' Expected: ' + o.expected); - } - } - }); - - QUnit.testStart(function(o){ - print(' ' + o.name); - }); - - QUnit.moduleStart(function(o){ - print("\n" + o.name); - }); - - QUnit.done(function(o) { - if(o.failed > 0) { - print("\n" + 'FAILURES!'); - print('Tests: ' + o.total - + ', Passed: ' + o.passed, - + ', Failures: ' + o.failed); - } else { - print("\n" + 'SUCESS!'); - print('Tests: ' + o.total); - } - print('Took: ' + o.runtime + 'ms'); - window.qunitDone = true; - }); -} diff --git a/build/ci/stealconfig.js b/build/ci/stealconfig.js deleted file mode 100644 index 08bbeefe..00000000 --- a/build/ci/stealconfig.js +++ /dev/null @@ -1,18 +0,0 @@ -steal.config({ - map: { - "*": { - 'jquery/jquery.js' : "jquery", - "can/util/util.js": "can/util/jquery/jquery.js" - } - }, - paths: { - "jquery": "can/util/jquery/jquery.1.8.1.js" - }, - ext: { - js: "js", - css: "css", - less: "steal/less/less.js", - coffee: "steal/coffee/coffee.js", - ejs: "can/view/ejs/ejs.js" - } -}) diff --git a/build/docco/.gitignore b/build/docco/.gitignore deleted file mode 100644 index 0820d537..00000000 --- a/build/docco/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -temp -docs diff --git a/build/docco/generate.js b/build/docco/generate.js deleted file mode 100644 index 8f14d00f..00000000 --- a/build/docco/generate.js +++ /dev/null @@ -1,146 +0,0 @@ -var path = require('path'), - fs = require('fs'), - child_process = require('child_process'), - os = require('os'), - - // Resolve directories - rhinoDir = path.join( path.dirname( fs.realpathSync( __filename )), '../../..' ), - jqueryDir = path.join( rhinoDir, 'jquery' ), - docsDir = path.join( jqueryDir, "docs" ), - doccoDir = path.join( jqueryDir, "build/docco" ), - doccoOutDir = path.join( doccoDir, "docs" ), - sourceDir = path.join( doccoDir, 'standalone' ), - makePath = path.join( doccoDir, "makestandalone.js" ), - genCommand; - -function execCommandWithOutput( command, cwd, callback ) { - - var spawn, parts; - - parts = command.split(" "); - spawn = child_process.spawn( parts.shift(), parts, { - cwd : cwd, - env : process.env - }); - - ["stdout", "stderr"].forEach( function( stream ) { - spawn[stream].setEncoding("utf-8"); - spawn[stream].pipe( process[stream] ); - }); - - spawn.on("exit", callback ); - -} - -function runDocco() { - - fs.mkdir(docsDir, function() { - - fs.readdir( path.join( doccoDir, "temp" ), function( err, files ) { - - files = files.map(function( file ) { - return path.join( "temp", file ); - }); - - var command = os.platform() != "win32" ? - "node_modules/docco/bin/docco " : - "sh node_modules/docco/bin/docco "; - - console.log( "Generating docco annotated source..." ); - - - execCommandWithOutput( command + files.join(" "), doccoDir, function( exitCode ) { - if ( exitCode == 0 ) { - fs.readdir( doccoOutDir, function( err, files ) { - console.log("Moving files into place..."); - files.forEach(function( file ) { - console.log( "\t" + file ); - fs.renameSync( path.join( doccoDir, "docs", file ), path.join( jqueryDir, "docs", file )); - }); - console.log("Cleaning up..."); - ["temp", "standalone", "docs"].forEach(function( dir ) { - fs.readdir( path.join( doccoDir, dir ), function( e, files ) { - files.forEach(function( file ) { - fs.unlinkSync( path.join( doccoDir, dir, file )); - }); - fs.rmdir( path.join( doccoDir, dir )); - }); - }); - console.log("Done!"); - }); - } else { - console.log("Error generating annotated source."); - } - }); - - }); - - - }); - -} - -function format( exitCode ) { - - if ( exitCode != 0 ) { - console.log("Error generating unminified sources."); - return - } - - fs.readdir( sourceDir, function( err, files ) { - - var count = 0; - - if ( ! files.length ) { - console.log("Error - Source directory is empty"); - } - - // Only annotate full srcs - files = files.filter(function( file ) { - return file.indexOf(".min.") < 0; - }); - - // Create the temp directory for stripped code - fs.mkdir( path.join( doccoDir, "temp"), function() { - - // Generate source for all standalones - console.log( "Stripping multiline comments and steal removes..." ); - console.log( "Converting tabs to 4 spaces." ); - - files.forEach(function( file ) { - fs.readFile( path.join( sourceDir, file ), "utf-8", function( err, code ) { - console.log( "\t" + file ); - - // Remove multiline comments - code = code.replace( /\/\*(?:.*)(?:\n\s+\*.*)*\n/gim, ""); - - // Remove double semicolons from steal pluginify - code = code.replace( /;[\s]*;/gim, ";"); - code = code.replace( /(\/\/.*)\n[\s]*;/gi, "$1"); - - // Tabs -> four spaces - code = code.replace( /\t/gim, " "); - - // Only single new lines - code = code.replace( /(\n){3,}/gim, "\n\n"); - - fs.writeFile( path.join( doccoDir, "temp", file ), code, "utf-8", function() { - if ( ++count == files.length ) { - runDocco(); - } - }); - }); - }); - }); - }); -} - -console.log("Generating unminified sources..."); - -if ( os.platform() != "win32" ) { - genCommand = "./js " + makePath; -} else { - genCommand = "js.bat " + makePath; -} - -execCommandWithOutput( genCommand, rhinoDir, format ); diff --git a/build/docco/makestandalone.js b/build/docco/makestandalone.js deleted file mode 100644 index cf70d2ca..00000000 --- a/build/docco/makestandalone.js +++ /dev/null @@ -1,47 +0,0 @@ -load("steal/rhino/rhino.js"); -steal('jquery/build/extract.js', 'steal/clean', function() { - - var out = "jquery/build/docco/standalone/", - excludes = [ 'steal/dev', - "can/util/jquery/jquery.1.7.1.js", - "jquery/build/lib.js" ], - plugins = { - "jquery/dom/animate/animate.js" : "jquery.animate.js", - "jquery/dom/compare/compare.js" : "jquery.compare.js", - "jquery/dom/cookie/cookie.js" : "jquery.cookie.js", - "jquery/dom/dimensions/dimensions.js" : "jquery.dimensions.js", - "jquery/dom/form_params/form_params.js" : "jquery.form_params.js", - "jquery/dom/range/range.js" : "jquery.range.js", - "jquery/dom/selection/selection.js" : "jquery.selection.js", - "jquery/dom/styles/styles.js" : "jquery.styles.js", - "jquery/dom/within/within.js" : "jquery.within.js", - "jquery/event/default/default.js" : "jquery.event.default.js", - "jquery/event/destroyed/destroyed.js" : "jquery.event.destroyed.js", - "jquery/event/drag/drag.js" : "jquery.event.drag.js", - "jquery/event/drop/drop.js" : "jquery.event.drop.js", - "jquery/event/fastfix/fastfix.js" : "jquery.event.fastfix.js", - "jquery/event/hover/hover.js" : "jquery.event.hover.js", - "jquery/event/key/key.js" : "jquery.event.key.js", - "jquery/event/pause/pause.js" : "jquery.event.pause.js", - "jquery/event/resize/resize.js" : "jquery.event.resize.js", - "jquery/event/swipe/swipe.js" : "jquery.event.swipe.js", - "jquery/event/livehack/livehack.js" : "jquery.event.livehack.js", - "jquery/lang/json/json.js" : "jquery.lang.json.js", - "jquery/lang/vector/vector.js" : "jquery.lang.vector.js" - }; - - steal.File(out).mkdirs(); - - steal.build.extract(plugins, { - skipCallbacks: true, - exclude : excludes.concat([ - 'jquery/dom/dom.js', 'jquery/event/event.js', 'jquery/jquery.js' - ]), - out : out - }); - - for(var name in plugins) { - console.log("Cleaning " + out + plugins[name]); - steal.clean(out + plugins[name]); - } -}); diff --git a/build/docco/package.json b/build/docco/package.json deleted file mode 100644 index 8811690c..00000000 --- a/build/docco/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "docco-generator", - "version" : "0.0.1", - "dependencies": { - "docco": ">= 0.1.x" - }, - "engine": "node >= 0.6.x" -} diff --git a/build/extract.js b/build/extract.js deleted file mode 100644 index 9dbfc86c..00000000 --- a/build/extract.js +++ /dev/null @@ -1,52 +0,0 @@ -steal('steal/build/pluginify', function() { - var inexcludes = function(excludes, src) { - for(var i = 0; i < excludes.length; i++) { - if(src.indexOf(excludes[i]) !== -1) { - return true; - } - } - return false; - }, - getDependencies = function(file, options, callback) { - steal.build.open("steal/rhino/empty.html", { - startFile : file, - skipCallbacks: true - }, function(opener){ - var ret = []; - opener.each(function(stl, text) { - var src = stl.src.toString(); - if(!inexcludes(options.exclude || [], src)) { - ret.push(src); - } - }); - callback(ret); - }, null); - }; - - steal.build.extract = function(plugins, options) { - var ops = steal.extend({ global : 'jQuery' }, options); - steal.File(ops.out).mkdirs(); - print('Extracting plugin files'); - for(var file in plugins) { - var content = ""; - - getDependencies(file, ops, function(steals) { - console.log(steals); -// if(steals.length > 1) { -// content += "// Dependencies:\n//\n"; -// } -// steals.forEach(function(stl) { -// if(stl.rootSrc !== file) { -// content += "// - " + (plugins[stl.rootSrc] || stl.rootSrc) + "\n"; -// } -// }); -// if(steals.length > 1) { -// content += "\n"; -// } -// content += steal.build.pluginify.content({ rootSrc : file }, ops); -// new steal.File(options.out + plugins[file]).save(content); -// print(' > ' + file + ' -> ' + plugins[file]); - }); - } - } -}); diff --git a/build/github/package.json b/build/github/package.json deleted file mode 100644 index 0312e102..00000000 --- a/build/github/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "github-download-updater", - "version" : "0.0.1", - "dependencies": { - "commander": ">= 0.1.x", - "github": ">= 0.1.x", - "underscore" : ">= 0.1.x", - "underscore.deferred" : ">= 0.1.x", - "tafa-misc-util" : ">= 0.1.x", - "mime" : ">= 1.2.5" - }, - "engine": "node >= 0.6.x" -} diff --git a/build/github/s3-post.js b/build/github/s3-post.js deleted file mode 100644 index 0f078d52..00000000 --- a/build/github/s3-post.js +++ /dev/null @@ -1,106 +0,0 @@ -// Generated by CoffeeScript 1.3.1 -(function() { - var crypto, https, joinBuffers, postToS3, readText, signPolicy, url, _ref; - - url = require('url'); - - https = require('https'); - - crypto = require('crypto'); - - _ref = require('tafa-misc-util'), joinBuffers = _ref.joinBuffers, readText = _ref.readText; - - signPolicy = function(secretKey, policy) { - var data, hmac, json, key, policy64, signature64; - json = JSON.stringify(policy); - policy64 = new Buffer(json).toString('base64'); - data = new Buffer(policy64, 'utf-8'); - key = new Buffer(secretKey, 'utf-8'); - hmac = crypto.createHmac('sha1', key); - hmac.update(data); - signature64 = hmac.digest('base64'); - return { - signature64: signature64, - policy64: policy64 - }; - }; - - postToS3 = function(_arg, callback) { - var AWSAccessKeyId, Filename, acl, addParam, arr, boundary, bucket, buf, ca, contentType, customUrl, data, host, hostname, key, options, policy64, port, protocol, req, req_body, signature64, success_action_status, _ref1; - AWSAccessKeyId = _arg.AWSAccessKeyId, policy64 = _arg.policy64, signature64 = _arg.signature64, bucket = _arg.bucket, key = _arg.key, data = _arg.data, boundary = _arg.boundary, customUrl = _arg.customUrl, ca = _arg.ca, acl = _arg.acl, success_action_status = _arg.success_action_status, Filename = _arg.Filename, contentType = _arg.contentType; - if (callback == null) { - callback = (function() {}); - } - if (customUrl) { - _ref1 = url.parse(customUrl), protocol = _ref1.protocol, hostname = _ref1.hostname, port = _ref1.port; - if (protocol !== "https:") { - return callback(new Error("customUrl must be https://")); - } - host = hostname; - port || (port = 443); - } else { - host = "" + bucket + ".s3.amazonaws.com"; - port = 443; - } - boundary || (boundary = '----------R46EARkAg4SAXSjufGsb6m'); - buf = function(x) { - return new Buffer(x); - }; - arr = []; - addParam = function(k, v) { - arr.push(buf('--' + boundary + '\r\n')); - arr.push(buf('Content-Disposition: form-data; name="' + k + '"\r\n\r\n')); - return arr.push(buf(v), buf('\r\n')); - }; - addParam('key', key); - addParam('acl', acl); - addParam('success_action_status', success_action_status); - addParam('Filename', Filename); - addParam('AWSAccessKeyId', AWSAccessKeyId); - addParam('Policy', policy64); - addParam('Signature', signature64); - addParam('Content-Type', contentType); - console.log(arr.join("")); - arr.push(buf('--' + boundary + '\r\n')); - arr.push(buf('Content-Disposition: form-data; name="file"; filename="data"\r\n')); - arr.push(buf("Content-Length: " + data.length + "\r\n")); - arr.push(buf('Content-Transfer-Encoding: binary\r\n\r\n')); - arr.push(data, buf('\r\n')); - arr.push(buf('--' + boundary + '--')); - req_body = joinBuffers(arr); - options = { - host: host, - port: port, - path: '/', - method: 'POST', - headers: { - 'Host': "" + bucket + ".s3.amazonaws.com", - 'Content-Type': 'multipart/form-data; boundary=' + boundary, - 'Content-Length': req_body.length - } - }; - if (ca) { - options.ca = ca; - } - req = https.request(options, function(res) { - var _ref2; - if ((200 <= (_ref2 = res.statusCode) && _ref2 < 300)) { - return callback(null); - } else { - return readText(res, function(text) { - return callback({ - responseCode: res.statusCode, - responseText: text - }); - }); - } - }); - return req.end(req_body); - }; - - module.exports = { - postToS3: postToS3, - signPolicy: signPolicy - }; - -}).call(this); \ No newline at end of file diff --git a/build/github/update-download.js b/build/github/update-download.js deleted file mode 100644 index 197c2b44..00000000 --- a/build/github/update-download.js +++ /dev/null @@ -1,273 +0,0 @@ -var path = require("path"), - fs = require("fs"), - spawn = require("child_process").spawn, - -// Third party modules - program = require("commander"), - GitHubApi = require("github"), - _ = require("underscore"), - s3p = require("./s3-post.js"), - mime = require('mime'), - -// Get the current version - version = fs.readFileSync(path.join(__dirname, "../version")).toString("utf8").trim(), - -// Describe all the files we'll be uploading to Github - descriptions = { - "jquerypp.js" : "jQuery++ #{VERSION} - All plugins", - }, - -// Figure out some paths - rhinoPath = path.join(__dirname, "../../.."), - distPathShort = "jquery/dist/", - distPath = path.join(__dirname, "../../dist"), - -// Github client - github = new GitHubApi({ - version : "3.0.0" - }), - remote = "git@github.com:jupiterjs/jquerypp.git", - -// Timeouts - stealTimeout, - -// For Github credentials - username, - password, - -// For steal build process - pluginify; - -// Get deferreds -_.mixin(require("underscore.deferred")); - -function updateDist() { - console.log("Copying built files to gh-pages."); - - var clone = spawn("git", [ "clone", remote ], { - cwd : __dirname - }), dfd = new _.Deferred(); - - clone.on("exit", function () { - - var clonePath = path.join(__dirname, "jquerypp"), - checkout = spawn("git", [ "checkout", "gh-pages"], { - cwd : clonePath - }); - - checkout.on("exit", function () { - var cloneReleasePath = path.join(clonePath, "release"), - latestPath = path.join(cloneReleasePath, "latest"), - versionPath = path.join(cloneReleasePath, version); - // Make sure directories exist - [ cloneReleasePath, versionPath, latestPath ].forEach(function (dir) { - if (!path.existsSync(dir)) { - fs.mkdirSync(dir); - } - }); - - fs.readdir(distPath, function (err, files) { - var dfds = files.map(function (file) { - var dfd = new _.Deferred(), - inPath, outPath, latestOutPath, - inStream; - - if(file.match(/.*\.js/)) { - inPath = path.join(distPath, file), - outPath = path.join(versionPath, file), - latestOutPath = path.join(latestPath, file), - inStream = fs.createReadStream(inPath); - inStream.pipe(fs.createWriteStream(outPath)); - inStream.pipe(fs.createWriteStream(latestOutPath)); - - inStream.on("end", function () { - dfd.resolve(); - }); - } else { - dfd.resolve(); - } - - return dfd.promise(); - - }); - - _.when.apply(_, dfds).done(function () { - console.log("Finished copying files. Cleaning up...") - var add = spawn("git", ["add", "release/*"], { - cwd : clonePath - }); - - add.on("exit", function () { - var commit = spawn("git", ["commit", "-m", "Generated release files for " + version ], { - cwd : clonePath - }); - - commit.on("exit", function () { - var push = spawn("git", ["push", "origin", "gh-pages"], { - cwd : clonePath - }); - - push.on("exit", function () { - - var remove = spawn("rm", ["-rf", "jquerypp"], { - cwd : __dirname - }); - console.log("Done!") - - }); - }); - }); - }); - }); - }); - - }); - - return dfd.promise(); -} - -// Upload files to the Github downloads page -function uploadFiles() { - console.log('Uploading files'); - - var dfd = new _.Deferred(), - dfds = _.map(descriptions, function (desc, filename) { - - var dfd = new _.Deferred(); - - desc = desc.replace("#{VERSION}", version); - - fs.readFile(path.join(distPath, filename), function (err, buf) { - console.log('Uploading ' + filename + ' MIME type ' + mime.lookup(filename)); - - github.httpSend({ - "user" : "jupiterjs", - "repo" : "jquerypp", - "name" : filename, - "size" : buf.length, - "description" : desc, - "content_type" : mime.lookup(filename) - }, { - "url" : "/repos/:user/:repo/downloads", - "method" : "POST", - "params" : { - "$user" : null, - "$repo" : null, - "$name" : null, - "$size" : null, - "description" : null, - "$content_type" : null - } - }, function (err, socket) { - console.log(err); - var data = JSON.parse(socket.data); - - - s3p.postToS3({ - key : data.path, - acl : data.acl, - success_action_status : "201", - Filename : data.name, - AWSAccessKeyId : data.accesskeyid, - policy64 : data.policy, - signature64 : data.signature, - contentType : data.mime_type, - data : buf, - bucket : "github" - }, function (e) { - if (e) { - console.log(e); - } - dfd.resolve(); - }) - - }); - - }); - - return dfd.promise(); - }); - - _.when.apply(_, dfds).done(dfd.resolve.bind(dfd)); - - return dfd.promise(); -} - -function stealBuild() { - - var dfd = new _.Deferred(), - zipFile; - - // Run Steal build script - pluginify = spawn(rhinoPath + "/js", ["jquery/build/make.js"], { - cwd : rhinoPath - }); - - pluginify.on("exit", function (code) { - // Create a zip file - // tar -cvzf jquery/dist/jquerypp.tar.gz jquery/dist - zipFile = 'jquerypp-' + version + '.zip'; - descriptions[zipFile] = "jQuery++ #{VERSION} - Full download"; - spawn("zip", ["-r", zipFile, '.'], { - cwd : distPath - }).on("exit", function () { - console.log("Done creating ZIP file " + zipFile); - dfd.resolve(code); - }); - }); - - return dfd.promise(); -} - -// Clean up on process exit -process.on("exit", function () { - process.stdout.write("\n") -}) - -// Get Github credentials -function getCredentials() { - - var dfd = new _.Deferred(); - - program.prompt("Github Username: ", function (name) { - username = name; - - program.password("Github Password: ", "*", function (pass) { - var timeout; - password = pass; - process.stdin.pause(); - - github.authenticate({ - type : "basic", - username : username, - password : password - }); - - process.stdout.write("Building jQuery++...") - stealTimeout = setInterval(function () { - process.stdout.write(".") - }, 1000) - dfd.resolve(); - }) - - }); - - return dfd.promise(); -} - -_.when(stealBuild(), getCredentials()).done(function (code) { - console.log('Built and got credentials'); - - if (stealTimeout) { - clearTimeout(stealTimeout); - process.stdout.write(" Done!\n") - } - - console.log(code); - if (code != 0) { - console.log("Steal build process failed.") - } else { - _.when(uploadFiles(), updateDist()).done(function () { - }); - } -}); diff --git a/build/lib.js b/build/lib.js deleted file mode 100644 index a9736545..00000000 --- a/build/lib.js +++ /dev/null @@ -1,24 +0,0 @@ -steal( - "jquery/dom/animate", - "jquery/dom/compare", - "jquery/dom/cookie", - "jquery/dom/dimensions", - "jquery/dom/form_params", - "jquery/dom/range", - "jquery/dom/selection", - "jquery/dom/styles", - "jquery/dom/within", - "jquery/event/default", - "jquery/event/destroyed", - "jquery/event/drag", - 'jquery/event/drag/limit', - 'jquery/event/drag/scroll', - 'jquery/event/drag/step', - "jquery/event/drop", - "jquery/event/fastfix", - "jquery/event/hover", - "jquery/event/key", - "jquery/event/pause", - "jquery/event/resize", - "jquery/event/swipe" -) \ No newline at end of file diff --git a/build/make.js b/build/make.js deleted file mode 100644 index 46b83617..00000000 --- a/build/make.js +++ /dev/null @@ -1,102 +0,0 @@ - -load("steal/rhino/rhino.js"); -steal('steal/build/pluginify', 'jquery/build/extract.js', // 'jquery/build/stealify.js', 'jquery/build/amdify.js', -function() { - - var out = "jquery/dist/", - excludes = [ 'steal/dev/', - 'jquery', - 'jquery/build/lib.js' ]; - - steal.File(out).mkdirs(); - - // Create full library -// steal.build.pluginify('jquery/build/lib.js', { -// out: out + "jquerypp.js", -// skipCallbacks: true, -// shim : { 'jquery' : 'jQuery' }, -// exclude : excludes.concat([ -// 'jquery/dom/dom.js', 'jquery/event/event.js', 'jquery/jquery.js' -// ]) -// }); - - // Create separate files - steal.build.extract({ - "jquery/dom/animate/animate.js" : "jquery.animate.js", - "jquery/dom/compare/compare.js" : "jquery.compare.js", - "jquery/dom/cookie/cookie.js" : "jquery.cookie.js", - "jquery/dom/dimensions/dimensions.js" : "jquery.dimensions.js", - "jquery/dom/form_params/form_params.js" : "jquery.form_params.js", - "jquery/dom/range/range.js" : "jquery.range.js", - "jquery/dom/selection/selection.js" : "jquery.selection.js", - "jquery/dom/styles/styles.js" : "jquery.styles.js", - "jquery/dom/within/within.js" : "jquery.within.js", - "jquery/event/default/default.js" : "jquery.event.default.js", - "jquery/event/destroyed/destroyed.js" : "jquery.event.destroyed.js", - "jquery/event/drag/drag.js" : "jquery.event.drag.js", - "jquery/event/drop/drop.js" : "jquery.event.drop.js", - "jquery/event/fastfix/fastfix.js" : "jquery.event.fastfix.js", - "jquery/event/hover/hover.js" : "jquery.event.hover.js", - "jquery/event/key/key.js" : "jquery.event.key.js", - "jquery/event/pause/pause.js" : "jquery.event.pause.js", - "jquery/event/resize/resize.js" : "jquery.event.resize.js", - "jquery/event/swipe/swipe.js" : "jquery.event.swipe.js", - "jquery/event/livehack/livehack.js" : "jquery.event.livehack.js", - "jquery/lang/json/json.js" : "jquery.lang.json.js", - "jquery/lang/vector/vector.js" : "jquery.lang.vector.js" - }, { - skipCallbacks: true, - exclude : excludes.concat([ - 'jquery/dom/dom.js', 'jquery/event/event.js', 'jquery/jquery.js' - ]), - out : out + 'lib/' - }); - - // Make Steal distributable -// steal.build.stealify('jquery/build/lib.js', { -// out : out + 'steal/', -// exclude : excludes -// }); - - // Make AMD modules -// steal.build.amdify('jquery/build/lib.js', { -// out : out + 'amd/', -// exclude : excludes.concat([ -// 'jquery/dom/dom.js', 'jquery/event/event.js' -// ]), -// map : { // steal file to CommonJS module name mappings -// "jquery/jquery.js" : "jquery", -// "jquery/build/lib.js" : "jquerypp/index", -// "jquery/lang/json/json.js" : "jquerypp/util/json", -// "jquery/lang/vector/vector.js" : "jquerypp/util/vector", -// "jquery/dom/animate/animate.js" : "jquerypp/animate", -// "jquery/dom/compare/compare.js" : "jquerypp/compare", -// "jquery/dom/cookie/cookie.js" : "jquerypp/cookie", -// "jquery/dom/dimensions/dimensions.js" : "jquerypp/dimensions", -// "jquery/dom/form_params/form_params.js" : "jquerypp/form_params", -// "jquery/dom/range/range.js" : "jquerypp/range", -// "jquery/dom/selection/selection.js" : "jquerypp/selection", -// "jquery/dom/styles/styles.js" : "jquerypp/styles", -// "jquery/dom/within/within.js" : "jquerypp/within", -// "jquery/event/default/default.js" : "jquerypp/event/default", -// "jquery/event/destroyed/destroyed.js" : "jquerypp/event/destroyed", -// "jquery/event/drag/drag.js" : "jquerypp/event/drag", -// "jquery/event/drag/limit/limit.js" : "jquerypp/event/drag.limit", -// "jquery/event/drag/scroll/scroll.js" : "jquerypp/event/drag.scroll", -// "jquery/event/drag/step/step.js" : "jquerypp/event/drag.step", -// "jquery/event/drop/drop.js" : "jquerypp/event/drop", -// "jquery/event/fastfix/fastfix.js" : "jquerypp/event/fastfix", -// "jquery/event/hover/hover.js" : "jquerypp/event/hover", -// "jquery/event/key/key.js" : "jquerypp/event/key", -// "jquery/event/reverse/reverse.js" : "jquerypp/event/reverse", -// "jquery/event/livehack/livehack.js" : "jquerypp/event/livehack", -// "jquery/event/pause/pause.js" : "jquerypp/event/pause", -// "jquery/event/resize/resize.js" : "jquerypp/event/resize", -// "jquery/event/swipe/swipe.js" : "jquerypp/event/swipe" -// }, -// names : { // Module name to variable name mappings -// 'jquery' : 'jQuery' -// }, -// global : 'jQuery' -// }); -}); diff --git a/build/stealify.js b/build/stealify.js deleted file mode 100644 index 1a936f21..00000000 --- a/build/stealify.js +++ /dev/null @@ -1,43 +0,0 @@ -steal('steal/build', function(steal) { - var inexcludes = function(excludes, src) { - for(var i = 0; i < excludes.length; i++) { - if(src.indexOf(excludes[i]) !== -1) { - return true; - } - } - return false; - }; - - /** - * A build plugin that copies only actual dependencies for a given file into - * a destination folder. The destination folder content is the minimal fileset - * you can deliver to be used with Steal. - * - * @param {String} source The source file to copy the dependencies for - * @param {Object} options The following options are available: - * - `out` - The output folder (will be created if it doesn't exist) - * - `excludes` - An array of files to exclude from copying - */ - steal.build.stealify = function(source, options) { - var out = options.out || steal.File(source).dir(); - print('Copying Steal dependencies for ' + source + ' to ' + out); - steal.File(out).mkdirs(); - steal.build.open("steal/rhino/empty.html", { - startFile : source, - skipCallbacks: true - }, function(opener){ - opener.each(function(stl){ - if(!inexcludes(options.exclude || [], stl.rootSrc.toString())) { - var file = steal.File(stl.rootSrc.toString()), - outPath = steal.File(out + file.dir()), - copyTo = outPath.path + '/' + file.filename(); - outPath.mkdirs(); - print(' > ' + copyTo); - file.copyTo(copyTo); - } else { - print(' Ignoring ' + stl.rootSrc.toString()); - } - }) - }); - } -}) \ No newline at end of file diff --git a/build/version b/build/version deleted file mode 100644 index afaf360d..00000000 --- a/build/version +++ /dev/null @@ -1 +0,0 @@ -1.0.0 \ No newline at end of file diff --git a/builder.json b/builder.json new file mode 100644 index 00000000..ca989169 --- /dev/null +++ b/builder.json @@ -0,0 +1,121 @@ +{ + "filename": "jquerypp.custom.js", + "banner": "/*!\n * <%= pkg.title || pkg.name %> - <%= pkg.version %>\n * <%= pkg.homepage %>\n * Copyright (c) <%= new Date().getFullYear() %> <%= pkg.author.name %>\n * <%= new Date().toUTCString() %>\n * Licensed <%= pkg.licenses[0].type %>\n<% if(typeof url !== \"undefined\") { %>\n * Includes: <%= ids %>\n * Download from: <%= url %>\n<% } %> */\n", + "modules": { + "jquerypp/dom/animate/animate": { + "name": "jQuery.animate", + "description": "Animate using CSS animations", + "type": "dom", + "isDefault": true + }, + "jquerypp/dom/compare/compare": { + "name": "jQuery.compare", + "description": "Compare element document position", + "type": "dom", + "isDefault": true + }, + "jquerypp/dom/cookie/cookie": { + "name": "jQuery.cookie", + "description": "Read and write cookies", + "type": "dom", + "isDefault": true + }, + "jquerypp/dom/form_params/form_params": { + "name": "jQuery.formParams", + "description": "Serializes a form into an object", + "type": "dom", + "isDefault": true + }, + "jquerypp/dom/range/range": { + "name": "jQuery.range", + "description": "Create and manipulate text ranges", + "type": "dom", + "isDefault": true + }, + "jquerypp/dom/selection/selection": { + "name": "jQuery.selection", + "description": "Get and set the current text selection", + "type": "dom", + "isDefault": true + }, + "jquerypp/dom/within/within": { + "name": "jQuery.within", + "description": "Get elements within an area or at a point", + "type": "dom", + "isDefault": true + }, + "jquerypp/event/removed/removed": { + "name": "jQuery.event.removed", + "description": "An element is removed from the DOM", + "type": "event", + "isDefault": true + }, + "jquerypp/event/drag/drag": { + "name": "jQuery.event.drag", + "description": "Delegatable drag events", + "type": "event", + "isDefault": true + }, + "jquerypp/event/drop/drop": { + "name": "jQuery.event.drop", + "description": "Delegatable drop events", + "type": "event", + "isDefault": true + }, + "jquerypp/event/hover/hover": { + "name": "jQuery.event.hover", + "description": "Delegatable hover events", + "type": "event", + "isDefault": true + }, + "jquerypp/event/key/key": { + "name": "jQuery.event.key", + "description": "Returns a string representation of the key pressed", + "type": "event", + "isDefault": true + }, + "jquerypp/event/pause/pause": { + "name": "jQuery.event.pause", + "description": "Pause and resume event propagation", + "type": "event", + "isDefault": true + }, + "jquerypp/event/resize/resize": { + "name": "jQuery.event.resize", + "description": "Listen to a resize event on every object", + "type": "event", + "isDefault": true + }, + "jquerypp/event/swipe/swipe": { + "name": "jQuery.event.swipe", + "description": "Delegatable swipe events", + "type": "event", + "isDefault": true + } + }, + "types": { + "dom": "DOM helpers", + "event": "Special events" + }, + "pluginify": { + "shim": { + "jquery/jquery.js": "$" + }, + "wrapper": "(function($) {\n<%= content %>\n})(jQuery);\n" + }, + "configurations": { + "default": { + "description": "jQuery", + "isDefault": true + } + }, + "ignore": ["dojo","dojo/dojo","dojo/main", + "jquery","jquery/jquery", + "mootools/mootools","mootools", + "zepto","zepto/zepto", + "yui","yui/yui"], + "exports": { + "jquery": "jQuery", + "zepto": "Zepto" + } +} \ No newline at end of file diff --git a/changelog.md b/changelog.md index 152c90a4..2dd60838 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,16 @@ ### Change Log +__1.0.1__ + +- fix: [Force hover leave on new mouseenter](https://github.com/bitovi/jquerypp/pull/65) +- fix: [Removing the element being hovered prevents all future hoverenter](https://github.com/bitovi/jquerypp/issues/64) +- fix: [hover.leave != 0 prevents hover of next element with same selecto](https://github.com/bitovi/jquerypp/issues/63) +- fix: [Changing jQuery references to local $](https://github.com/bitovi/jquerypp/pull/71) +- fix: [Breaks in jQuery.noConflict(true) Scenario](https://github.com/bitovi/jquerypp/issues/67) +- fix: [Can't download drag.limit, drag.step, and drag.scroll from downloader on website](https://github.com/bitovi/jquerypp/pull/66) +- feature: [jQuery 1.9.x support](https://github.com/bitovi/jquerypp/commit/692ed50a7b43fb2c6bfb9d89c5e0505ddcbd6595) +- feature: Added to the new [jQuery plugin repository](http://plugins.jquery.com/jquerypp) + __1.0.0__ - feature: jQuery 1.8.0+ compatibility @@ -11,6 +22,8 @@ __1.0.0__ - fix: [.stop() does not stop callbacks from being executed](https://github.com/jupiterjs/jquerypp/issues/28) - fix: [jQuery.event.swipe.max isn't actually being used](https://github.com/jupiterjs/jquerypp/issues/33) - fix: [Range triggers error on IE8](https://github.com/jupiterjs/jquerypp/issues/39) +- fix: [[FormParams] convertValue function: Null value to undefined (Internet Explorer Fix)](https://github.com/jupiterjs/jquerypp/pull/51) +- fix: [HoverInit delay 0 does not trigger hoverenter if immediately moused out](https://github.com/bitovi/jquerypp/issues/57) __1.0 Beta 2__ @@ -27,6 +40,6 @@ __1.0 Beta 2__ - Links to annotated sources ([e.g. jQuery.animate](http://donejs.com/jquery/docs/jquery.animate.html)) - Changelog and list of heroes section -__1.0 Beta__ (June 1st 2012) +__1.0 Beta__ - Released! \ No newline at end of file diff --git a/class/class.js b/class/class.js deleted file mode 100644 index c6e68fa3..00000000 --- a/class/class.js +++ /dev/null @@ -1,8 +0,0 @@ -//jQuery.Class -// This is a modified version of John Resig's class -// http://ejohn.org/blog/simple-javascript-inheritance/ -// It provides class level inheritance and callbacks. -//!steal-clean -steal("jquery", "can/construct", "can/construct/proxy","can/construct/super", function($, Construct) { - $.Class = Construct; -})(); diff --git a/class/class_test.js b/class/class_test.js deleted file mode 100644 index 61caa64d..00000000 --- a/class/class_test.js +++ /dev/null @@ -1,205 +0,0 @@ -steal("jquery/class") //load your app - .then('funcunit/qunit').then(function(){ - -module("jquery/class"); - -test("Creating", function(){ - - jQuery.Class.extend("Animal", - { - count: 0, - test: function() { - return this.match ? true : false - } - }, - { - init: function() { - this.constructor.count++; - this.eyes = false; - } - } - ); - Animal.extend("Dog", - { - match : /abc/ - }, - { - init: function() { - this._super(); - }, - talk: function() { - return "Woof"; - } - }); - Dog.extend("Ajax", - { - count : 0 - }, - { - init: function( hairs ) { - this._super(); - this.hairs = hairs; - this.setEyes(); - - }, - setEyes: function() { - this.eyes = true; - } - }); - new Dog(); - new Animal(); - new Animal(); - var ajax = new Ajax(1000); - - equals(2, Animal.count, "right number of animals"); - equals(1, Dog.count, "right number of animals") - ok(Dog.match, "right number of animals") - ok(!Animal.match, "right number of animals") - ok(Dog.test(), "right number of animals") - ok(!Animal.test(), "right number of animals") - equals(1, Ajax.count, "right number of animals") - equals(2, Animal.count, "right number of animals"); - equals(true, ajax.eyes, "right number of animals"); - equals(1000, ajax.hairs, "right number of animals"); -}) - - -test("new instance",function(){ - var d = Ajax.newInstance(6); - equals(6, d.hairs); -}) - - -test("namespaces",function(){ - var fb = $.Class.extend("Foo.Bar") - ok(Foo.Bar === fb, "returns class") - equals(fb.shortName, "Bar", "short name is right"); - equals(fb.fullName, "Foo.Bar","fullName is right") - -}) - -test("setups", function(){ - var order = 0, - staticSetup, - staticSetupArgs, - staticInit, - staticInitArgs, - protoSetup, - protoInitArgs, - protoInit, - staticProps = { - setup: function() { - staticSetup = ++order; - staticSetupArgs = arguments; - return ["something"] - }, - init: function() { - staticInit = ++order; - staticInitArgs = arguments; - } - }, - protoProps = { - setup: function( name ) { - protoSetup = ++order; - return ["Ford: "+name]; - }, - init: function() { - protoInit = ++order; - protoInitArgs = arguments; - } - } - $.Class.extend("Car",staticProps,protoProps); - - var geo = new Car("geo"); - equals(staticSetup, 1); - equals(staticInit, 2); - equals(protoSetup, 3); - equals(protoInit, 4); - - same($.makeArray(staticInitArgs), ["something"] ) - same($.makeArray(protoInitArgs),["Ford: geo"] ) - - same($.makeArray(staticSetupArgs),[$.Class, "Car",staticProps, protoProps] ,"static construct"); - - - //now see if staticSetup gets called again ... - Car.extend("Truck"); - equals(staticSetup, 5, "Static setup is called if overwriting"); - -}); - -test("callback", function(){ - var curVal = 0; - $.Class.extend("Car",{ - show: function( value ) { - equals(curVal, value) - } - },{ - show: function( value ) { - - } - }) - var cb = Car.proxy('show'); - curVal = 1; - cb(1) - - curVal = 2; - var cb2 = Car.proxy('show',2) - cb2(); -}); - -test("callback error", 1,function(){ - $.Class.extend("Car",{ - show: function( value ) { - equals(curVal, value) - } - },{ - show: function( value ) { - - } - }) - try{ - Car.proxy('huh'); - ok(false, "I should have errored") - }catch(e){ - ok(true, "Error was thrown") - } -}) - -test("Creating without extend", function(){ - $.Class("Bar",{ - ok : function(){ - ok(true, "ok called") - } - }); - new Bar().ok(); - - Bar("Foo",{ - dude : function(){ - ok(true, "dude called") - } - }); - new Foo().dude(true); -}) - - -/* Not sure I want to fix this yet. -test("Super in derived when parent doesn't have init", function(){ - $.Class("Parent",{ - }); - - Parent("Derived",{ - init : function(){ - this._super(); - } - }); - - try { - new Derived(); - ok(true, "Can call super in init safely") - } catch (e) { - ok(false, "Failed to call super in init with error: " + e) - } -})*/ - -}); \ No newline at end of file diff --git a/class/qunit.html b/class/qunit.html deleted file mode 100644 index 503f699f..00000000 --- a/class/qunit.html +++ /dev/null @@ -1,15 +0,0 @@ - -
- - - - -{} with
-values in a
-controller's [jQuery.Controller.prototype.options options]. This means
-we can easily provide a default showEvent value and create
-a menu without providing a value like:
-
- $.Controller("Menu",
- {
- defaults : {
- showEvent : "click"
- }
- },
- {
- "li {showEvent}" : function(el){
- el.children('ul').show()
- }
- });
-
- $("#clickMe").menu(); //defaults to using click
-
-Sometimes, we might might want to configure our widget to
-use different elements. The following makes the menu widget's
-button elements configurable:
-
- $.Controller("Menu",{
- "{button} {showEvent}" : function(el){
- el.children('ul').show()
- }
- })
-
- $('#buttonMenu').menu({button: "button"});
-
-### Templating the root element.
-
-Finally, controller lets you bind to objects outside
-of the [jQuery.Controller.prototype.element controller's element].
-
-The following listens to clicks on the window:
-
- $.Controller("HideOnClick",{
- "{window} click" : function(){
- this.element.hide()
- }
- })
-
-The following listens to Todos being created:
-
- $.Controller("NewTodos",{
- "{App.Models.Todo} created" : function(Todo, ev, newTodo){
- this.element.append("newTodos.ejs", newTodo)
- }
- });
-
-But instead of making NewTodos only work with the Todo model,
-we can make it configurable:
-
- $.Controller("Newbie",{
- "{model} created" : function(Model, ev, newItem){
- this.element.append(this.options.view, newItem)
- }
- });
-
- $('#newItems').newbie({
- model: App.Models.Todo,
- view: "newTodos.ejs"
- })
-
-### How Templated events work
-
-When looking up a value to replace {},
-controller first looks up the item in the options, then it looks
-up the value in the window object. It does not use eval to look up the
-object. Instead it uses [jQuery.String.getObject].
-
-
-## Subscribing to OpenAjax messages and custom bindings
-
-The jquery/controller/subscribe plugin allows controllers to listen
-to OpenAjax.hub messages like:
-
- $.Controller("Listener",{
- "something.updated subscribe" : function(called, data){
-
- }
- })
-
-You can create your own binders by adding to [jQuery.Controller.static.processors].
-
-## Manually binding to events.
-
-The [jQuery.Controller.prototype.bind] and [jQuery.Controller.prototype.delegate]
-methods let you listen to events on other elements. These event handlers will
-be unbound when the controller instance is destroyed.
-
diff --git a/controller/pages/plugin.md b/controller/pages/plugin.md
deleted file mode 100644
index d3ee520f..00000000
--- a/controller/pages/plugin.md
+++ /dev/null
@@ -1,101 +0,0 @@
-@page jquery.controller.plugin The generated jQuery plugin
-@parent jQuery.Controller
-
-When you create a controller, it creates a jQuery plugin that can be
-used to:
-
- - Create controllers on an element or elements
- - Call controller methods
- - Update a controller
-
-For example, the following controller:
-
- $.Controller("My.Widget",{
- say : function(){
- alert(this.options.message);
- }
- })
-
-creates a jQuery.fn.my_widget method that you can use like:
-
- // create my_widget on each .thing
- $(".thing").my_widget({message : "Hello"})
-
- // alerts "Hello"
- $(".thing").my_widget("say");
-
- // updates the message option
- $(".thing").my_widget({message : "World"});
-
- // alerts "World"
- $(".thing").my_widget("say");
-
-Note that in every case, the my_widget plugin
-returns the original jQuery collection for chaining ($('.thing')). If you want to
-get a value from a controller, use the [jQuery.fn.controllers] or [jQuery.fn.controller].
-
-## Creating controllers
-
-When a controller's jQuery plugin helper is used on a jQuery collection, it goes to each
-element and tests if it has a controller instance on the element. If it does not, it creates one.
-
-It calls new YourController with the element and any additional arguments you passed
-to the jQuery plugin helper. So for example, say there are 2 elements in $('.thing').
-
-This:
-
- $(".thing").my_widget({message : "Hello"})
-
-Does the exact same thing as:
-
- var things = $('.thing'),
- options = {message : "Hello"};
- new My.Widget(things[0],options);
- new My.Widget(things[1],options);
-
-Note, when a new Class is created, it calls your
-class's prototype setup and init methods. Read [jQuery.Controller.prototype.setup controller's setup]
-for the details on what happens when a new controller is created.
-
-
-## Calling methods on controllers
-
-Once a Controller is already on an element, you can call methods on it with the same jQuery
-helper. The first param to the helper is the name of the method, the following params are
-passed to the jQuery function. For example:
-
- $.Controller("Adder",{
- sum : function(first, second, third){
- this.element.text(first+second+third);
- }
- })
-
- // add an adder to the page
- $("#myadder").adder()
-
- // show the sum of 1+2+3
- $("#myadder").adder("sum",1,2,3);
-
-## Naming
-
-By default, a controller's jQuery helper is the controller name:
-
- - [jQuery.String.underscore underscored]
- - "." replaced with "_"
- - with Controllers removed.
-
-Here are some examples:
-
- $.Controller("Foo") // -> .foo()
- $.Controller("Foo.Bar") // -> .foo_bar()
- $.Controller("Foo.Controllers.Bar") // -> .foo_bar()
-
-You can overwrite the Controller's default name by setting a static pluginName property:
-
- $.Controller("My.Tabs",
- {
- pluginName: "tabs"
- },
- { ... })
-
- $("#tabs").tabs()
diff --git a/controller/qunit.html b/controller/qunit.html
deleted file mode 100644
index ae8fad54..00000000
--- a/controller/qunit.html
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
- See this blog entry for more information.
-
- Here are some links in a normal paragraph: Google,
- Google Groups (Link).
- This link has class="blog":
- diveintomark
-
-
Everything inside the red border is inside a div with id="foo".
This is a normal link: Yahoo
-This link has class="blog": Simon Willison's Weblog
Try them out:
-