From d14b90ded2f3e3845f001d15047f4a4d4fad3840 Mon Sep 17 00:00:00 2001 From: Ghislain Seguin Date: Mon, 30 Dec 2013 20:54:43 -0700 Subject: [PATCH] Build: Manage dependencies with bower Fixes gh-6369 --- Gruntfile.js | 82 +++++++++++++++++++++++++++++++++++++++++ bower.json | 29 +++++++++++++++ external/qunit.css | 16 ++++---- external/qunit.js | 1 + js/jquery.hashchange.js | 29 ++++++++++----- js/jquery.js | 2 - js/jquery.ui.core.js | 2 +- js/jquery.ui.widget.js | 2 +- package.json | 3 +- 9 files changed, 144 insertions(+), 22 deletions(-) create mode 100644 bower.json diff --git a/Gruntfile.js b/Gruntfile.js index 7288afc1446..77e3ad472e1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -736,6 +736,85 @@ module.exports = function( grunt ) { } }, + bowercopy: { + options: { + + // Bower components folder will be removed afterwards + clean: true + }, + tests: { + options: { + destPrefix: "external" + }, + files: { + "qunit.js": "qunit/qunit/qunit.js", + "qunit.css": "qunit/qunit/qunit.css", + "jshint/jshint.js": "jshint/dist/jshint.js" + } + }, + requirejs: { + options: { + destPrefix: "external" + }, + files: { + "requirejs/require.js": "requirejs/require.js", + "requirejs/plugins/text.js": "requirejs-text/text.js", + "requirejs/plugins/json.js": "requirejs-plugins/src/json.js" + } + }, + jquery: { + options: { + destPrefix: "js" + }, + files: { + "jquery.js": "jquery/jquery.js" + } + }, + "jquery-ui": { + options: { + destPrefix: "js", + copyOptions: { + process: function( content ) { + var version = grunt.file.readJSON( "bower.json" ).dependencies[ "jquery-ui" ]; + if ( /#/.test( version ) ) { + version = version.split( "#" )[ 1 ]; + } + return content.replace( /@VERSION/g, version ); + } + } + }, + files: { + "jquery.ui.core.js": "jquery-ui/ui/jquery.ui.core.js", + "jquery.ui.widget.js": "jquery-ui/ui/jquery.ui.widget.js" + } + }, + "jquery-ui-tabs": { + options: { + destPrefix: "js", + copyOptions: { + process: function( content ) { + var version = grunt.file.readJSON( "bower.json" ).dependencies[ "jquery-ui-tabs" ]; + if ( /#/.test( version ) ) { + version = version.split( "#" )[ 1 ]; + } + return content.replace( /@VERSION/g, version ); + } + } + }, + files: { + "widgets/jquery.ui.tabs.js": "jquery-ui-tabs/ui/jquery.ui.tabs.js" + } + }, + "jquery-plugins": { + options: { + destPrefix: "js" + }, + files: { + "jquery.hashchange.js": "jquery-hashchange/jquery.ba-hashchange.js" + } + } + }, + clean: { dist: [ dist ], git: [ path.join( dist, "git" ) ], @@ -746,6 +825,7 @@ module.exports = function( grunt ) { }); // grunt plugins + grunt.loadNpmTasks( "grunt-bowercopy" ); grunt.loadNpmTasks( "grunt-contrib-jshint" ); grunt.loadNpmTasks( "grunt-contrib-clean" ); grunt.loadNpmTasks( "grunt-contrib-copy" ); @@ -807,6 +887,8 @@ module.exports = function( grunt ) { grunt.registerTask( "dist:release", [ "release:init", "dist", "cdn" ] ); grunt.registerTask( "dist:git", [ "dist", "clean:git", "config:copy:git:-git", "copy:git" ] ); + grunt.registerTask( "updateDependencies", [ "bowercopy" ] ); + grunt.registerTask( "test", [ "jshint", "config:fetchHeadHash", "js:release", "connect", "qunit:http" ] ); grunt.registerTask( "test:ci", [ "qunit_junit", "connect", "qunit:http" ] ); diff --git a/bower.json b/bower.json new file mode 100644 index 00000000000..e1a2831e155 --- /dev/null +++ b/bower.json @@ -0,0 +1,29 @@ +{ + "name": "jquery-mobile", + "version": "1.4.1pre", + "main": [ + "js/jquery.mobile.js", + "css/themes/default/jquery.mobile.css" + ], + "ignore": [ + ".jshintrc", + "**/*.txt", + "build", + "demos", + "tests", + "tools" + ], + "dependencies": { + "jquery": "1.10.2", + "jquery-ui": "jquery/jquery-ui#c0ab71056b936627e8a7821f03c044aec6280a40", + "jquery-ui-tabs": "jquery/jquery-ui#fadf2b312a05040436451c64bbfaf4814bc62c56", + "jquery-hashchange": "gseguin/jquery-hashchange#77c4b3551fc6bdc2ac6b22b2641cfd7ac6b212d2" + }, + "devDependencies": { + "requirejs": "2.1.2", + "qunit": "1.9.0", + "jshint": "2.4.0", + "requirejs-text": "2.0.3", + "requirejs-plugins": "millermedeiros/requirejs-plugins#34330a5d735474ac0b518eb1eb270c9e5505a537" + } +} diff --git a/external/qunit.css b/external/qunit.css index 01263fbbdd7..257b224ff44 100644 --- a/external/qunit.css +++ b/external/qunit.css @@ -38,8 +38,10 @@ line-height: 1em; font-weight: normal; - -webkit-border-radius: 5px 5px 0 0; border-radius: 5px 5px 0 0; + -moz-border-radius: 5px 5px 0 0; + -webkit-border-top-right-radius: 5px; + -webkit-border-top-left-radius: 5px; } #qunit-header a { @@ -111,8 +113,9 @@ background-color: #fff; - -webkit-border-radius: 5px; border-radius: 5px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; } #qunit-tests table { @@ -187,8 +190,10 @@ } #qunit-tests > li:last-child { - -webkit-border-radius: 0 0 5px 5px; border-radius: 0 0 5px 5px; + -moz-border-radius: 0 0 5px 5px; + -webkit-border-bottom-right-radius: 5px; + -webkit-border-bottom-left-radius: 5px; } #qunit-tests .fail { color: #000000; background-color: #EE5757; } @@ -224,8 +229,3 @@ width: 1000px; height: 1000px; } - -[data-nstest-role='page'], [data-nstest-role='dialog'] { - position: absolute !important; - top: -10000px !important; -} \ No newline at end of file diff --git a/external/qunit.js b/external/qunit.js index 73b8d13e21d..9efedcb4424 100644 --- a/external/qunit.js +++ b/external/qunit.js @@ -1328,6 +1328,7 @@ function registerLoggingCallback( key ) { // Supports deprecated method of completely overwriting logging callbacks function runLoggingCallbacks( key, scope, args ) { + //debugger; var i, callbacks; if ( QUnit.hasOwnProperty( key ) ) { QUnit[ key ].call(scope, args ); diff --git a/js/jquery.hashchange.js b/js/jquery.hashchange.js index ea48c502647..ea2086bb346 100644 --- a/js/jquery.hashchange.js +++ b/js/jquery.hashchange.js @@ -1,5 +1,14 @@ +/*! + * jQuery hashchange event - v1.3 - 7/21/2010 + * http://benalman.com/projects/jquery-hashchange-plugin/ + * + * Copyright (c) 2010 "Cowboy" Ben Alman + * Dual licensed under the MIT and GPL licenses. + * http://benalman.com/about/license/ + */ + // Script: jQuery hashchange event -// +// // *Version: 1.3, Last updated: 7/21/2010* // // Project Home - http://benalman.com/projects/jquery-hashchange-plugin/ @@ -76,7 +85,9 @@ // extra awesomeness that BBQ provides. This plugin will be included as // part of jQuery BBQ, but also be available separately. -(function( $, window, undefined ) { +(function($,window,undefined){ + '$:nomunge'; // Used by YUI compressor. + // Reused string. var str_hashchange = 'hashchange', @@ -242,14 +253,14 @@ // event for browsers that don't natively support it, including creating a // polling loop to watch for hash changes and in IE 6/7 creating a hidden // Iframe to enable back and forward. - fake_onhashchange = (function() { + fake_onhashchange = (function(){ var self = {}, timeout_id, // Remember the initial hash so it doesn't get triggered immediately. last_hash = get_fragment(), - fn_retval = function( val ) { return val; }, + fn_retval = function(val){ return val; }, history_set = fn_retval, history_get = fn_retval; @@ -286,7 +297,7 @@ // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv // vvvvvvvvvvvvvvvvvvv REMOVE IF NOT SUPPORTING IE6/7/8 vvvvvvvvvvvvvvvvvvv // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv - window.attachEvent && !window.addEventListener && !supports_onhashchange && (function() { + window.attachEvent && !window.addEventListener && !supports_onhashchange && (function(){ // Not only do IE6/7 need the "magical" Iframe treatment, but so does IE8 // when running in "IE7 compatibility" mode. @@ -295,7 +306,7 @@ // When the event is bound and polling starts in IE 6/7, create a hidden // Iframe for history handling. - self.start = function() { + self.start = function(){ if ( !iframe ) { iframe_src = $.fn[ str_hashchange ].src; iframe_src = iframe_src && iframe_src + get_fragment(); @@ -306,7 +317,7 @@ // When Iframe has completely loaded, initialize the history and // start polling. - .one( 'load', function() { + .one( 'load', function(){ iframe_src || history_set( get_fragment() ); poll(); }) @@ -322,7 +333,7 @@ // prettify the back/next history menu entries. Since IE sometimes // errors with "Unspecified error" the very first time this is set // (yes, very useful) wrap this with a try/catch block. - doc.onpropertychange = function() { + doc.onpropertychange = function(){ try { if ( event.propertyName === 'title' ) { iframe.document.title = doc.title; @@ -359,7 +370,7 @@ iframe_doc.open(); // Set document.domain for the Iframe document as well, if necessary. - domain && iframe_doc.write( '' ); iframe_doc.close(); diff --git a/js/jquery.js b/js/jquery.js index a27e7f62d60..c5c648255c1 100644 --- a/js/jquery.js +++ b/js/jquery.js @@ -797,7 +797,6 @@ jQuery.extend({ } } - // Flatten any nested arrays return core_concat.apply( [], ret ); }, @@ -8200,7 +8199,6 @@ jQuery.extend({ } } - // if no content if ( status === 204 || s.type === "HEAD" ) { statusText = "nocontent"; diff --git a/js/jquery.ui.core.js b/js/jquery.ui.core.js index 202d6d06041..4e8e38a9fb4 100644 --- a/js/jquery.ui.core.js +++ b/js/jquery.ui.core.js @@ -290,4 +290,4 @@ $.ui.plugin = { } }; -})( jQuery ); \ No newline at end of file +})( jQuery ); diff --git a/js/jquery.ui.widget.js b/js/jquery.ui.widget.js index a876df8a2fc..88162b298e4 100644 --- a/js/jquery.ui.widget.js +++ b/js/jquery.ui.widget.js @@ -1,5 +1,5 @@ /*! - * jQuery UI Widget c0ab71056b936627e8a7821f03c044aec6280a40N + * jQuery UI Widget c0ab71056b936627e8a7821f03c044aec6280a40 * http://jqueryui.com * * Copyright 2013 jQuery Foundation and other contributors diff --git a/package.json b/package.json index 604ef4012c1..85561d71548 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,8 @@ "xmlhttprequest": "1.6.0", "semver": "2.2.1", "cheerio": "0.12.4", - "underscore": "1.5.2" + "underscore": "1.5.2", + "grunt-bowercopy": "0.5.0" }, "main": "Gruntfile.js", "engines": {