From 25fe6beb8e5da6b50d06cc2dfd91ae7a14f248d6 Mon Sep 17 00:00:00 2001 From: Gabriele Rabbiosi Date: Tue, 19 Mar 2013 23:00:16 +0100 Subject: [PATCH 01/24] - Added an ieshiv.js (for now handcrafted) to the demo-assets - Included in the demo-template.html a polyfill and ieshiv.js for IE < 9 --- misc/demo-assets/ieshiv.js | 62 ++++++++++++++++++++++++++++++++++++++ misc/demo-template.html | 5 +++ 2 files changed, 67 insertions(+) create mode 100644 misc/demo-assets/ieshiv.js diff --git a/misc/demo-assets/ieshiv.js b/misc/demo-assets/ieshiv.js new file mode 100644 index 0000000000..01c7975554 --- /dev/null +++ b/misc/demo-assets/ieshiv.js @@ -0,0 +1,62 @@ +// READ: http://docs-next.angularjs.org/guide/ie +// element tags are statically defined in order to accommodate lazy-loading whereby directives are also unknown + +// The ieshiv takes care of our ui.directives and AngularJS's ng-view, ng-include, ng-pluralize, ng-switch. +// However, IF you have custom directives that can be used as html tags (yours or someone else's) then +// add list of directives into window.myCustomTags + +// + +(function (exports) { + + var debug = window.ieShivDebug || false, + tags = [ "ngInclude", "ngPluralize", "ngView", "ngSwitch", "accordion", "accordionGroup", "accordionHeading", + "accordionTransclude", "alert", "btnRadio", "btnCheckbox", "carousel", "slide", "collapse", + "dropdownToggle", "modal", "pagination", "popoverPopup", "popover", "progress", "progressbar", "tabs", + "pane", "tooltipPopup", "tooltip", "typeahead", "typeaheadPopup" + ]; + + window.myCustomTags = window.myCustomTags || []; // externally defined by developer using angular-ui directives + tags.push.apply(tags, window.myCustomTags); + + var toCustomElements = function (str) { + var result = []; + var dashed = str.replace(/([A-Z])/g, function ($1) { + return " " + $1.toLowerCase(); + }); + var tokens = dashed.split(' '); + var dirname = tokens.join('-'); + + result.push(dirname); + result.push("x-" + dirname); + result.push("data-" + dirname); + return result; + +/* for now, ui-bootstrap doesn't have a prefix... + * + var ns = tokens[0]; + var dirname = tokens.slice(1).join('-'); + + // this is finite list and it seemed senseless to create a custom method + result.push(ns + ":" + dirname); + result.push(ns + "-" + dirname); + result.push("x-" + ns + "-" + dirname); + result.push("data-" + ns + "-" + dirname); + return result; +*/ + }; + + for (var i = 0, tlen = tags.length; i < tlen; i++) { + var customElements = toCustomElements(tags[i]); + for (var j = 0, clen = customElements.length; j < clen; j++) { + var customElement = customElements[j]; + document.createElement(customElement); + } + } + +})(window); \ No newline at end of file diff --git a/misc/demo-template.html b/misc/demo-template.html index a84e431bab..4a102dbc82 100644 --- a/misc/demo-template.html +++ b/misc/demo-template.html @@ -6,6 +6,11 @@ + + From c1b8e3b042a173cf0820217ef543e9c02293a933 Mon Sep 17 00:00:00 2001 From: Gabriele Rabbiosi Date: Thu, 21 Mar 2013 00:20:17 +0100 Subject: [PATCH 02/24] Implemented grunt task to automatically generate ieshiv based on the directives that are present in the last build --- Gruntfile.js | 27 +++++++++++++++++- misc/demo-template.html | 2 +- misc/ieshiv-template.js | 61 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 misc/ieshiv-template.js diff --git a/Gruntfile.js b/Gruntfile.js index beeff606ea..185dba79c1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -48,8 +48,16 @@ module.exports = function(grunt) { dist_tpls:{ src:['<%= dist %>/<%= filename %>-tpls-<%= pkg.version %>.js'], dest:'<%= dist %>/<%= filename %>-tpls-<%= pkg.version %>.min.js' + }, + dist_ieshiv: { + src: ['<%= dist %>/ieshiv-<%= pkg.version %>.js'], + dest: '<%= dist %>/ieshiv-<%= pkg.version %>.min.js' } }, + ieshiv: { + src: 'misc/ieshiv-template.js', + dest: '<%= dist %>/ieshiv-<%= pkg.version %>.js' + }, html2js: { src: ['template/**/*.html'] }, @@ -158,7 +166,24 @@ module.exports = function(grunt) { grunt.config('concat.dist.src', grunt.config('concat.dist.src').concat(srcFiles)); grunt.config('concat.dist_tpls.src', grunt.config('concat.dist_tpls.src').concat(srcFiles).concat(tplFiles)); - grunt.task.run(['concat', 'uglify']); + grunt.task.run(['concat', 'ieshiv', 'uglify']); + }); + + grunt.registerTask('ieshiv', 'Create the ieshiv file, based on the current build', function() { + var directives = []; + var matches = grunt.file.read(grunt.config('concat.dist.dest')).match(/\.directive\(('|")[^'"]*('|")/g); + + matches.forEach(function(match) { + directives.push(/('|")([^'"]+)('|")/.exec(match)[2]); + }); + + grunt.file.write( + grunt.config('ieshiv.dest'), + grunt.template.process(grunt.file.read(grunt.config('ieshiv.src')), {data: { + directives: '"' + directives.join('", "') + '"', + version : grunt.config('pkg.version') + }}) + ); }); grunt.registerTask('site', 'Create grunt demo site from every module\'s files', function() { diff --git a/misc/demo-template.html b/misc/demo-template.html index 4a102dbc82..cb36cc7900 100644 --- a/misc/demo-template.html +++ b/misc/demo-template.html @@ -8,7 +8,7 @@ diff --git a/misc/ieshiv-template.js b/misc/ieshiv-template.js new file mode 100644 index 0000000000..3d0802355f --- /dev/null +++ b/misc/ieshiv-template.js @@ -0,0 +1,61 @@ +// READ: http://docs-next.angularjs.org/guide/ie +// element tags are statically defined in order to accommodate lazy-loading whereby directives are also unknown + +// The ieshiv takes care of our ui.directives and AngularJS's ng-view, ng-include, ng-pluralize, ng-switch. +// However, IF you have custom directives that can be used as html tags (yours or someone else's) then +// add list of directives into window.myCustomTags + +// +// +// Version: <%= version %> +// + +(function (exports) { + + var debug = window.ieShivDebug || false, + tags = [<%= directives %>]; + + window.myCustomTags = window.myCustomTags || []; // externally defined by developer using angular-ui directives + tags.push.apply(tags, window.myCustomTags); + + var toCustomElements = function (str) { + var result = []; + var dashed = str.replace(/([A-Z])/g, function ($1) { + return " " + $1.toLowerCase(); + }); + var tokens = dashed.split(' '); + var dirname = tokens.join('-'); + + result.push(dirname); + result.push("x-" + dirname); + result.push("data-" + dirname); + return result; + +/* for now, ui-bootstrap doesn't have a prefix... + * + var ns = tokens[0]; + var dirname = tokens.slice(1).join('-'); + + // this is finite list and it seemed senseless to create a custom method + result.push(ns + ":" + dirname); + result.push(ns + "-" + dirname); + result.push("x-" + ns + "-" + dirname); + result.push("data-" + ns + "-" + dirname); + return result; +*/ + }; + + for (var i = 0, tlen = tags.length; i < tlen; i++) { + var customElements = toCustomElements(tags[i]); + for (var j = 0, clen = customElements.length; j < clen; j++) { + var customElement = customElements[j]; + document.createElement(customElement); + } + } + +})(window); \ No newline at end of file From 83cf9b2ed491c2d9a3a509410df1565cd00b81f4 Mon Sep 17 00:00:00 2001 From: Gabriele Rabbiosi Date: Thu, 21 Mar 2013 21:45:33 +0100 Subject: [PATCH 03/24] Added some angular-js directives to the ieshiv-template.js file --- misc/ieshiv-template.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/ieshiv-template.js b/misc/ieshiv-template.js index 3d0802355f..16653e8e4e 100644 --- a/misc/ieshiv-template.js +++ b/misc/ieshiv-template.js @@ -18,7 +18,7 @@ (function (exports) { var debug = window.ieShivDebug || false, - tags = [<%= directives %>]; + tags = ["ngInclude", "ngPluralize", "ngView", "ngSwitch", <%= directives %>]; window.myCustomTags = window.myCustomTags || []; // externally defined by developer using angular-ui directives tags.push.apply(tags, window.myCustomTags); From 6e9b8f5a189f9aa4416a0ef9e9f8605d3fa4e220 Mon Sep 17 00:00:00 2001 From: Gabriele Rabbiosi Date: Thu, 21 Mar 2013 22:17:26 +0100 Subject: [PATCH 04/24] Added polyfill for Array.indexOf() to ieshiv file --- misc/ieshiv-template.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/misc/ieshiv-template.js b/misc/ieshiv-template.js index 16653e8e4e..0e80917805 100644 --- a/misc/ieshiv-template.js +++ b/misc/ieshiv-template.js @@ -57,5 +57,42 @@ document.createElement(customElement); } } + + /** + * Polyfill for Array.indexOf() + * Taken from: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/indexOf + */ + if (!Array.prototype.indexOf) { + Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) { + "use strict"; + if (this == null) { + throw new TypeError(); + } + var t = Object(this); + var len = t.length >>> 0; + if (len === 0) { + return -1; + } + var n = 0; + if (arguments.length > 1) { + n = Number(arguments[1]); + if (n != n) { // shortcut for verifying if it's NaN + n = 0; + } else if (n != 0 && n != Infinity && n != -Infinity) { + n = (n > 0 || -1) * Math.floor(Math.abs(n)); + } + } + if (n >= len) { + return -1; + } + var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0); + for (; k < len; k++) { + if (k in t && t[k] === searchElement) { + return k; + } + } + return -1; + } + } })(window); \ No newline at end of file From d18689f627c297a021a707b821efeb4ac03593ea Mon Sep 17 00:00:00 2001 From: Gabriele Rabbiosi Date: Mon, 25 Mar 2013 17:54:17 +0100 Subject: [PATCH 05/24] Revert "Added polyfill for Array.indexOf() to ieshiv file" This reverts commit 6e9b8f5a189f9aa4416a0ef9e9f8605d3fa4e220. --- misc/ieshiv-template.js | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/misc/ieshiv-template.js b/misc/ieshiv-template.js index 0e80917805..16653e8e4e 100644 --- a/misc/ieshiv-template.js +++ b/misc/ieshiv-template.js @@ -57,42 +57,5 @@ document.createElement(customElement); } } - - /** - * Polyfill for Array.indexOf() - * Taken from: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/indexOf - */ - if (!Array.prototype.indexOf) { - Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) { - "use strict"; - if (this == null) { - throw new TypeError(); - } - var t = Object(this); - var len = t.length >>> 0; - if (len === 0) { - return -1; - } - var n = 0; - if (arguments.length > 1) { - n = Number(arguments[1]); - if (n != n) { // shortcut for verifying if it's NaN - n = 0; - } else if (n != 0 && n != Infinity && n != -Infinity) { - n = (n > 0 || -1) * Math.floor(Math.abs(n)); - } - } - if (n >= len) { - return -1; - } - var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0); - for (; k < len; k++) { - if (k in t && t[k] === searchElement) { - return k; - } - } - return -1; - } - } })(window); \ No newline at end of file From 0723b4d05b0a3891765bf15cca446fb9a0d7aff2 Mon Sep 17 00:00:00 2001 From: Gabriele Rabbiosi Date: Mon, 25 Mar 2013 18:49:11 +0100 Subject: [PATCH 06/24] Added external polyfill es5-shim to demo-template.html page --- misc/demo-template.html | 1 + 1 file changed, 1 insertion(+) diff --git a/misc/demo-template.html b/misc/demo-template.html index cb36cc7900..24f541cd82 100644 --- a/misc/demo-template.html +++ b/misc/demo-template.html @@ -8,6 +8,7 @@ From 1ab3d01db21b889233ed2897f14f21e9d3b91276 Mon Sep 17 00:00:00 2001 From: Gabriele Rabbiosi Date: Mon, 25 Mar 2013 21:48:48 +0100 Subject: [PATCH 07/24] - Added IE8-specific testacular configuration - Modified grunt server task to accept an :ie8 parameter that lets you run testacular using IE8-specific configuration --- Gruntfile.js | 12 ++++++++- testacular-ie8.conf.js | 60 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 testacular-ie8.conf.js diff --git a/Gruntfile.js b/Gruntfile.js index e462289e69..38e21d42d8 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -290,7 +290,17 @@ module.exports = function(grunt) { }); grunt.registerTask('server', 'start testacular server', function() { - var options = ['--no-single-run', '--no-auto-watch'].concat(this.args); + var options = ['--no-single-run', '--no-auto-watch']; + + this.args.forEach(function(arg) { + if (arg == "ie8") { + options.push("testacular-ie8.conf.js"); + } + else { + options.push(arg); + } + }); + runTestacular('start', options); }); diff --git a/testacular-ie8.conf.js b/testacular-ie8.conf.js new file mode 100644 index 0000000000..e591b66a4f --- /dev/null +++ b/testacular-ie8.conf.js @@ -0,0 +1,60 @@ + +// base path, that will be used to resolve files and exclude +basePath = '.'; + +// list of files / patterns to load in the browser +files = [ + JASMINE, + JASMINE_ADAPTER, + 'misc/test-lib/jquery-1.8.2.min.js', + 'misc/test-lib/angular.js', + 'misc/test-lib/angular-mocks.js', + 'misc/test-lib/helpers.js', + 'http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js', + 'http://cdnjs.cloudflare.com/ajax/libs/es5-shim/1.2.4/es5-shim.min.js', + 'dist/ieshiv-*.js', + 'src/**/*.js', + 'template/**/*.js' +]; + +// list of files to exclude +exclude = [ + //ieshiv was included, be sure to exclude minified version otherwise it will be included 2 times + 'dist/ieshiv-*.min.js' +]; + +// Start these browsers, currently available: +// - Chrome +// - ChromeCanary +// - Firefox +// - Opera +// - Safari +// - PhantomJS +browsers = [ + +]; + +// test results reporter to use +// possible values: dots || progress +reporter = 'progress'; + +// web server port +port = 9018; + +// cli runner port +runnerPort = 9100; + +// enable / disable colors in the output (reporters and logs) +colors = true; + +// level of logging +// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG +logLevel = LOG_INFO; + +// enable / disable watching file and executing tests whenever any file changes +autoWatch = true; + +// Continuous Integration mode +// if true, it capture browsers, run tests and exit +singleRun = false; + From 9bc342f34a5b6f07668c863ec333da29a108d345 Mon Sep 17 00:00:00 2001 From: Gabriele Rabbiosi Date: Mon, 25 Mar 2013 22:15:32 +0100 Subject: [PATCH 08/24] grunt ieshiv task: fixed regex to match directive declarations that have spaces between the open parenthesis and the name of the directive --- Gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 38e21d42d8..86d3bc2006 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -172,7 +172,7 @@ module.exports = function(grunt) { grunt.registerTask('ieshiv', 'Create the ieshiv file, based on the current build', function() { var directives = []; - var matches = grunt.file.read(grunt.config('concat.dist.dest')).match(/\.directive\(('|")[^'"]*('|")/g); + var matches = grunt.file.read(grunt.config('concat.dist.dest')).match(/\.directive\([^'"]*('|")[^'"]*('|")/g); matches.forEach(function(match) { directives.push(/('|")([^'"]+)('|")/.exec(match)[2]); From 99c899bc29ee76541bc28618994e4e993dbcad90 Mon Sep 17 00:00:00 2001 From: Gabriele Rabbiosi Date: Mon, 25 Mar 2013 22:17:07 +0100 Subject: [PATCH 09/24] Added grunt log to ieshiv task that inform the user about the successful creation of the file --- Gruntfile.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Gruntfile.js b/Gruntfile.js index 86d3bc2006..03c5b3e1ea 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -185,6 +185,8 @@ module.exports = function(grunt) { version : grunt.config('pkg.version') }}) ); + + grunt.log.writeln('File "' + grunt.config('ieshiv.dest') + '" created.'); }); grunt.registerTask('site', 'Create grunt demo site from every module\'s files', function() { From 9de4b9ae9e373bfe4d5bf57bfc41017841b3a8b0 Mon Sep 17 00:00:00 2001 From: Gabriele Rabbiosi Date: Mon, 25 Mar 2013 22:19:57 +0100 Subject: [PATCH 10/24] Removed AngularJS directives from ieshiv-template file; they will be included ONLY if explicitly used inside one of the project's directives --- misc/ieshiv-template.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/ieshiv-template.js b/misc/ieshiv-template.js index 16653e8e4e..3d0802355f 100644 --- a/misc/ieshiv-template.js +++ b/misc/ieshiv-template.js @@ -18,7 +18,7 @@ (function (exports) { var debug = window.ieShivDebug || false, - tags = ["ngInclude", "ngPluralize", "ngView", "ngSwitch", <%= directives %>]; + tags = [<%= directives %>]; window.myCustomTags = window.myCustomTags || []; // externally defined by developer using angular-ui directives tags.push.apply(tags, window.myCustomTags); From c5dc31dd33b5dd0e67b8bb0e9e4c6c87c6846094 Mon Sep 17 00:00:00 2001 From: Gabriele Rabbiosi Date: Tue, 9 Apr 2013 21:47:49 +0200 Subject: [PATCH 11/24] Revert "- Added IE8-specific testacular configuration" This reverts commit 1ab3d01db21b889233ed2897f14f21e9d3b91276. --- Gruntfile.js | 12 +-------- testacular-ie8.conf.js | 60 ------------------------------------------ 2 files changed, 1 insertion(+), 71 deletions(-) delete mode 100644 testacular-ie8.conf.js diff --git a/Gruntfile.js b/Gruntfile.js index 539de39f6d..4670b42db0 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -301,17 +301,7 @@ module.exports = function(grunt) { }); grunt.registerTask('server', 'start testacular server', function() { - var options = ['--no-single-run', '--no-auto-watch']; - - this.args.forEach(function(arg) { - if (arg == "ie8") { - options.push("testacular-ie8.conf.js"); - } - else { - options.push(arg); - } - }); - + var options = ['--no-single-run', '--no-auto-watch'].concat(this.args); runTestacular('start', options); }); diff --git a/testacular-ie8.conf.js b/testacular-ie8.conf.js deleted file mode 100644 index e591b66a4f..0000000000 --- a/testacular-ie8.conf.js +++ /dev/null @@ -1,60 +0,0 @@ - -// base path, that will be used to resolve files and exclude -basePath = '.'; - -// list of files / patterns to load in the browser -files = [ - JASMINE, - JASMINE_ADAPTER, - 'misc/test-lib/jquery-1.8.2.min.js', - 'misc/test-lib/angular.js', - 'misc/test-lib/angular-mocks.js', - 'misc/test-lib/helpers.js', - 'http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js', - 'http://cdnjs.cloudflare.com/ajax/libs/es5-shim/1.2.4/es5-shim.min.js', - 'dist/ieshiv-*.js', - 'src/**/*.js', - 'template/**/*.js' -]; - -// list of files to exclude -exclude = [ - //ieshiv was included, be sure to exclude minified version otherwise it will be included 2 times - 'dist/ieshiv-*.min.js' -]; - -// Start these browsers, currently available: -// - Chrome -// - ChromeCanary -// - Firefox -// - Opera -// - Safari -// - PhantomJS -browsers = [ - -]; - -// test results reporter to use -// possible values: dots || progress -reporter = 'progress'; - -// web server port -port = 9018; - -// cli runner port -runnerPort = 9100; - -// enable / disable colors in the output (reporters and logs) -colors = true; - -// level of logging -// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG -logLevel = LOG_INFO; - -// enable / disable watching file and executing tests whenever any file changes -autoWatch = true; - -// Continuous Integration mode -// if true, it capture browsers, run tests and exit -singleRun = false; - From 9ffcf581ed664e72158afd3bb7b65835578b0e26 Mon Sep 17 00:00:00 2001 From: Gabriele Rabbiosi Date: Tue, 16 Apr 2013 21:43:37 +0200 Subject: [PATCH 12/24] Update karma configuration to enable IE8 testing --- karma.conf.js | 4 ++++ misc/test-lib/es5-shim.min.js | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100755 misc/test-lib/es5-shim.min.js diff --git a/karma.conf.js b/karma.conf.js index 15d329e4ec..03c2f73bcd 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -10,12 +10,16 @@ files = [ 'misc/test-lib/angular.js', 'misc/test-lib/angular-mocks.js', 'misc/test-lib/helpers.js', + 'misc/test-lib/es5-shim.min.js', + 'dist/ieshiv-*.js', 'src/**/*.js', 'template/**/*.js' ]; // list of files to exclude exclude = [ + // exclude the ieshiv minified version to prevent loading it twice + 'dist/ieshiv-*.min.js' ]; // Start these browsers, currently available: diff --git a/misc/test-lib/es5-shim.min.js b/misc/test-lib/es5-shim.min.js new file mode 100755 index 0000000000..ea01ac4779 --- /dev/null +++ b/misc/test-lib/es5-shim.min.js @@ -0,0 +1,17 @@ +(function(o){"function"==typeof define?define(o):"function"==typeof YUI?YUI.add("es5",o):o()})(function(){function o(){}function v(a){a=+a;a!==a?a=0:0!==a&&(a!==1/0&&a!==-(1/0))&&(a=(0>>0;if(h(a)!="[object Function]")throw new TypeError;for(;++e>>0,f=Array(e);if(h(a)!="[object Function]")throw new TypeError(a+" is not a function");for(var g=0;g>>0,f=[],g;if(h(a)!="[object Function]")throw new TypeError(a+" is not a function");for(var i=0;i>>0;if(h(a)!="[object Function]")throw new TypeError(a+" is not a function");for(var f=0;f>>0;if(h(a)!="[object Function]")throw new TypeError(a+" is not a function");for(var f=0;f>>0;if(h(a)!="[object Function]")throw new TypeError(a+ +" is not a function");if(!c&&arguments.length==1)throw new TypeError("reduce of empty array with no initial value");var e=0,f;if(arguments.length>=2)f=arguments[1];else{do{if(e in d){f=d[e++];break}if(++e>=c)throw new TypeError("reduce of empty array with no initial value");}while(1)}for(;e>>0;if(h(a)!= +"[object Function]")throw new TypeError(a+" is not a function");if(!c&&arguments.length==1)throw new TypeError("reduceRight of empty array with no initial value");var e,c=c-1;if(arguments.length>=2)e=arguments[1];else{do{if(c in d){e=d[c--];break}if(--c<0)throw new TypeError("reduceRight of empty array with no initial value");}while(1)}do c in this&&(e=a.call(void 0,e,d[c],c,b));while(c--);return e});if(!Array.prototype.indexOf||-1!=[0,1].indexOf(1,2))Array.prototype.indexOf=function(a){var b=l&& +h(this)=="[object String]"?this.split(""):n(this),d=b.length>>>0;if(!d)return-1;var c=0;arguments.length>1&&(c=v(arguments[1]));for(c=c>=0?c:Math.max(0,d+c);c>>0;if(!d)return-1;var c=d-1;arguments.length>1&&(c=Math.min(c,v(arguments[1])));for(c=c>=0?c:d-Math.abs(c);c>=0;c--)if(c in b&& +a===b[c])return c;return-1};if(!Object.keys){var w=!0,x="toString toLocaleString valueOf hasOwnProperty isPrototypeOf propertyIsEnumerable constructor".split(" "),A=x.length,r;for(r in{toString:null})w=!1;Object.keys=function(a){if(typeof a!="object"&&typeof a!="function"||a===null)throw new TypeError("Object.keys called on a non-object");var b=[],d;for(d in a)t(a,d)&&b.push(d);if(w)for(d=0;d9999?"+":"")+("00000"+Math.abs(c)).slice(0<=c&&c<=9999?-4:-6);for(b=a.length;b--;){d=a[b];d<10&&(a[b]="0"+d)}return c+"-"+a.slice(0,2).join("-")+"T"+a.slice(2).join(":")+"."+("000"+this.getUTCMilliseconds()).slice(-3)+ +"Z"};r=!1;try{r=Date.prototype.toJSON&&null===(new Date(NaN)).toJSON()&&-1!==(new Date(-621987552E5)).toJSON().indexOf("-000001")&&Date.prototype.toJSON.call({toISOString:function(){return true}})}catch(H){}r||(Date.prototype.toJSON=function(){var a=Object(this),b;a:if(s(a))b=a;else{b=a.valueOf;if(typeof b==="function"){b=b.call(a);if(s(b))break a}b=a.toString;if(typeof b==="function"){b=b.call(a);if(s(b))break a}throw new TypeError;}if(typeof b==="number"&&!isFinite(b))return null;b=a.toISOString; +if(typeof b!="function")throw new TypeError("toISOString property is not callable");return b.call(a)});var g=Date,m=function(a,b,d,c,e,f,h){var i=arguments.length;if(this instanceof g){i=i==1&&String(a)===a?new g(m.parse(a)):i>=7?new g(a,b,d,c,e,f,h):i>=6?new g(a,b,d,c,e,f):i>=5?new g(a,b,d,c,e):i>=4?new g(a,b,d,c):i>=3?new g(a,b,d):i>=2?new g(a,b):i>=1?new g(a):new g;i.constructor=m;return i}return g.apply(this,arguments)},u=function(a,b){var d=b>1?1:0;return B[b]+Math.floor((a-1969+d)/4)-Math.floor((a- +1901+d)/100)+Math.floor((a-1601+d)/400)+365*(a-1970)},C=RegExp("^(\\d{4}|[+-]\\d{6})(?:-(\\d{2})(?:-(\\d{2})(?:T(\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d{3}))?)?(Z|(?:([-+])(\\d{2}):(\\d{2})))?)?)?)?$"),B=[0,31,59,90,120,151,181,212,243,273,304,334,365],j;for(j in g)m[j]=g[j];m.now=g.now;m.UTC=g.UTC;m.prototype=g.prototype;m.prototype.constructor=m;m.parse=function(a){var b=C.exec(a);if(b){var d=Number(b[1]),c=Number(b[2]||1)-1,e=Number(b[3]||1)-1,f=Number(b[4]||0),h=Number(b[5]||0),i=Number(b[6]|| +0),j=Number(b[7]||0),m=!b[4]||b[8]?0:Number(new g(1970,0)),k=b[9]==="-"?1:-1,l=Number(b[10]||0),b=Number(b[11]||0);if(f<(h>0||i>0||j>0?24:25)&&h<60&&i<60&&j<1E3&&c>-1&&c<12&&l<24&&b<60&&e>-1&&e Date: Tue, 16 Apr 2013 22:00:26 +0200 Subject: [PATCH 13/24] Refactor accordion tests to make them green in IE8 --- src/accordion/test/accordionSpec.js | 43 ++++++++++++++++------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/src/accordion/test/accordionSpec.js b/src/accordion/test/accordionSpec.js index acad565a2f..f007e967e1 100644 --- a/src/accordion/test/accordionSpec.js +++ b/src/accordion/test/accordionSpec.js @@ -116,9 +116,12 @@ describe('accordion', function () { beforeEach(inject(function(_$rootScope_, _$compile_) { scope = _$rootScope_; $compile = _$compile_; + + element = angular.element('
').appendTo(document.body); })); afterEach(function () { + element.remove(); element = groups = scope = $compile = undefined; }); @@ -128,16 +131,12 @@ describe('accordion', function () { "" + "Content 1" + "Content 2" + - ""; - element = angular.element(tpl); - angular.element(document.body).append(element); + ""; + element.html(tpl); $compile(element)(scope); scope.$digest(); groups = element.find('.accordion-group'); }); - afterEach(function() { - element.remove(); - }); it('should create accordion groups with content', function () { expect(groups.length).toEqual(2); @@ -175,7 +174,7 @@ describe('accordion', function () { "" + "{{group.content}}" + ""; - element = angular.element(tpl); + element.html(tpl); model = [ {name: 'title 1', content: 'Content 1'}, {name: 'title 2', content: 'Content 2'} @@ -220,8 +219,8 @@ describe('accordion', function () { "" + "Content 1" + "Content 2" + - ""; - element = angular.element(tpl); + ""; + element.html(tpl); scope.open1 = false; scope.open2 = true; $compile(element)(scope); @@ -241,21 +240,16 @@ describe('accordion', function () { "" + "
{{item}}
" + "Static content" + - "
"; - element = angular.element(tpl); + ""; + element.html(tpl); scope.items = ['Item 1', 'Item 2', 'Item 3']; scope.open1 = true; scope.open2 = false; - angular.element(document.body).append(element); $compile(element)(scope); scope.$digest(); groups = element.find('.accordion-group'); }); - afterEach(function() { - element.remove(); - }); - it('should have visible group body when the group with isOpen set to true', function () { expect(findGroupBody(0)[0].clientHeight).not.toBe(0); expect(findGroupBody(1)[0].clientHeight).toBe(0); @@ -271,7 +265,8 @@ describe('accordion', function () { 'Body' + '' + ''; - element = $compile(tpl)(scope); + element.html(tpl); + $compile(element)(scope); scope.$digest(); groups = element.find('.accordion-group'); }); @@ -285,10 +280,20 @@ describe('accordion', function () { }); describe('accordion-heading, with repeating accordion-groups', function() { - it('should clone the accordion-heading for each group', function() { - element = $compile('{{x}}')(scope); + beforeEach(function() { + var tpl = + '' + + '' + + '{{x}}' + + '' + + ''; + element.html(tpl); + $compile(element)(scope); scope.$digest(); groups = element.find('.accordion-group'); + }); + + it('should clone the accordion-heading for each group', function() { expect(groups.length).toBe(3); expect(findGroupLink(0).text()).toBe('1'); expect(findGroupLink(1).text()).toBe('2'); From eed775b4b28597a0593e5c4379dfba4e36cf664b Mon Sep 17 00:00:00 2001 From: Gabriele Rabbiosi Date: Tue, 16 Apr 2013 23:32:49 +0200 Subject: [PATCH 14/24] Remove old ieshiv file, not used anymore --- misc/demo-assets/ieshiv.js | 62 -------------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 misc/demo-assets/ieshiv.js diff --git a/misc/demo-assets/ieshiv.js b/misc/demo-assets/ieshiv.js deleted file mode 100644 index 01c7975554..0000000000 --- a/misc/demo-assets/ieshiv.js +++ /dev/null @@ -1,62 +0,0 @@ -// READ: http://docs-next.angularjs.org/guide/ie -// element tags are statically defined in order to accommodate lazy-loading whereby directives are also unknown - -// The ieshiv takes care of our ui.directives and AngularJS's ng-view, ng-include, ng-pluralize, ng-switch. -// However, IF you have custom directives that can be used as html tags (yours or someone else's) then -// add list of directives into window.myCustomTags - -// - -(function (exports) { - - var debug = window.ieShivDebug || false, - tags = [ "ngInclude", "ngPluralize", "ngView", "ngSwitch", "accordion", "accordionGroup", "accordionHeading", - "accordionTransclude", "alert", "btnRadio", "btnCheckbox", "carousel", "slide", "collapse", - "dropdownToggle", "modal", "pagination", "popoverPopup", "popover", "progress", "progressbar", "tabs", - "pane", "tooltipPopup", "tooltip", "typeahead", "typeaheadPopup" - ]; - - window.myCustomTags = window.myCustomTags || []; // externally defined by developer using angular-ui directives - tags.push.apply(tags, window.myCustomTags); - - var toCustomElements = function (str) { - var result = []; - var dashed = str.replace(/([A-Z])/g, function ($1) { - return " " + $1.toLowerCase(); - }); - var tokens = dashed.split(' '); - var dirname = tokens.join('-'); - - result.push(dirname); - result.push("x-" + dirname); - result.push("data-" + dirname); - return result; - -/* for now, ui-bootstrap doesn't have a prefix... - * - var ns = tokens[0]; - var dirname = tokens.slice(1).join('-'); - - // this is finite list and it seemed senseless to create a custom method - result.push(ns + ":" + dirname); - result.push(ns + "-" + dirname); - result.push("x-" + ns + "-" + dirname); - result.push("data-" + ns + "-" + dirname); - return result; -*/ - }; - - for (var i = 0, tlen = tags.length; i < tlen; i++) { - var customElements = toCustomElements(tags[i]); - for (var j = 0, clen = customElements.length; j < clen; j++) { - var customElement = customElements[j]; - document.createElement(customElement); - } - } - -})(window); \ No newline at end of file From 19ab7e5f4cee7814589da175d5581f5a1e1d222f Mon Sep 17 00:00:00 2001 From: Gabriele Rabbiosi Date: Sun, 28 Apr 2013 16:16:34 +0200 Subject: [PATCH 15/24] Fix carousel widget and tests to work on IE8 --- src/carousel/carousel.js | 2 +- src/carousel/test/carousel.spec.js | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/carousel/carousel.js b/src/carousel/carousel.js index 4fb09b7e87..54826ae37d 100644 --- a/src/carousel/carousel.js +++ b/src/carousel/carousel.js @@ -38,7 +38,7 @@ angular.module('ui.bootstrap.carousel', ['ui.bootstrap.transition']) if (self.currentSlide && angular.isString(direction) && !$scope.noTransition && nextSlide.$element) { //We shouldn't do class manip in here, but it's the same weird thing bootstrap does. need to fix sometime nextSlide.$element.addClass(direction); - nextSlide.$element[0].offsetWidth = nextSlide.$element[0].offsetWidth; //force reflow + nextSlide.$element[0].offsetWidth; //force reflow //Set all other slides to stop doing their stuff for the new transition angular.forEach(slides, function(slide) { diff --git a/src/carousel/test/carousel.spec.js b/src/carousel/test/carousel.spec.js index a962bc15dc..95cf99be31 100644 --- a/src/carousel/test/carousel.spec.js +++ b/src/carousel/test/carousel.spec.js @@ -11,7 +11,7 @@ describe('carousel', function() { })); describe('basics', function() { - var elm, scope, carouselScope; + var elm, scope; beforeEach(function() { scope = $rootScope.$new(); scope.slides = [ @@ -19,19 +19,21 @@ describe('carousel', function() { {active:false,content:'two'}, {active:false,content:'three'} ]; - elm = $compile( + var tpl = '' + '' + '{{slide.content}}' + '' + - '' - )(scope); - carouselScope = elm.scope(); + ''; + elm = angular.element('
').appendTo(document.body); + elm.html(tpl); + $compile(elm)(scope); scope.interval = 5000; scope.$apply(); }); afterEach(function() { scope.$destroy(); + elm.remove(); }); function testSlideActive(slideIndex) { @@ -171,10 +173,10 @@ describe('carousel', function() { testSlideActive(0); $timeout.flush(); testSlideActive(1); - elm.trigger('mouseenter'); + elm.find('div.carousel').trigger('mouseenter'); expect($timeout.flush).toThrow();//pause should cancel current timeout testSlideActive(1); - elm.trigger('mouseleave'); + elm.find('div.carousel').trigger('mouseleave'); $timeout.flush(); testSlideActive(2); }); From d99248ac88f0f2f06668650f51836845ddc8a2f8 Mon Sep 17 00:00:00 2001 From: Gabriele Rabbiosi Date: Sun, 28 Apr 2013 20:44:53 +0200 Subject: [PATCH 16/24] Fix jshint warning --- src/carousel/carousel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/carousel/carousel.js b/src/carousel/carousel.js index 54826ae37d..6a96deef1c 100644 --- a/src/carousel/carousel.js +++ b/src/carousel/carousel.js @@ -38,7 +38,7 @@ angular.module('ui.bootstrap.carousel', ['ui.bootstrap.transition']) if (self.currentSlide && angular.isString(direction) && !$scope.noTransition && nextSlide.$element) { //We shouldn't do class manip in here, but it's the same weird thing bootstrap does. need to fix sometime nextSlide.$element.addClass(direction); - nextSlide.$element[0].offsetWidth; //force reflow + var useless = nextSlide.$element[0].offsetWidth; //force reflow //Set all other slides to stop doing their stuff for the new transition angular.forEach(slides, function(slide) { From 0d7eae9bb89576bf55014f67c7b124487ad758c9 Mon Sep 17 00:00:00 2001 From: Gabriele Rabbiosi Date: Mon, 29 Apr 2013 23:52:11 +0200 Subject: [PATCH 17/24] Fix tooltip directive to make tests green There are still some issues with the $position service on IE8 --- src/tooltip/tooltip.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tooltip/tooltip.js b/src/tooltip/tooltip.js index c72484ce71..5e4ff7a431 100644 --- a/src/tooltip/tooltip.js +++ b/src/tooltip/tooltip.js @@ -54,14 +54,14 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] ) var directiveName = snake_case( type ); var template = - '<'+ directiveName +'-popup '+ + '
'+ - ''; + '
'; return { restrict: 'EA', @@ -225,7 +225,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] ) .directive( 'tooltipPopup', function () { return { - restrict: 'E', + restrict: 'EA', replace: true, scope: { content: '@', placement: '@', animation: '&', isOpen: '&' }, templateUrl: 'template/tooltip/tooltip-popup.html' @@ -238,7 +238,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] ) .directive( 'tooltipHtmlUnsafePopup', function () { return { - restrict: 'E', + restrict: 'EA', replace: true, scope: { content: '@', placement: '@', animation: '&', isOpen: '&' }, templateUrl: 'template/tooltip/tooltip-html-unsafe-popup.html' From bf3e23183022dabaa891d0a198b7e7632aabf934 Mon Sep 17 00:00:00 2001 From: Gabriele Rabbiosi Date: Mon, 29 Apr 2013 23:58:42 +0200 Subject: [PATCH 18/24] Remove IE9.js from demo page because it mess up some css In particular, it make tooltip arrow invisible in IE8... --- misc/demo/index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/misc/demo/index.html b/misc/demo/index.html index dfcb5bf3f4..0820d41c88 100644 --- a/misc/demo/index.html +++ b/misc/demo/index.html @@ -7,7 +7,6 @@ From 93189642dafeabd43b749b3c8f9230ad2447d785 Mon Sep 17 00:00:00 2001 From: Gabriele Rabbiosi Date: Fri, 3 May 2013 23:33:58 +0200 Subject: [PATCH 19/24] Fix progress directive to make tests green in IE8 --- src/progressbar/docs/demo.html | 2 +- src/progressbar/test/progressbar.spec.js | 71 ++++++++++++++---------- template/progressbar/progress.html | 2 +- 3 files changed, 43 insertions(+), 32 deletions(-) diff --git a/src/progressbar/docs/demo.html b/src/progressbar/docs/demo.html index 8fbfb082f8..0b987b4f85 100644 --- a/src/progressbar/docs/demo.html +++ b/src/progressbar/docs/demo.html @@ -3,7 +3,7 @@

Static

-
+

Dynamic

diff --git a/src/progressbar/test/progressbar.spec.js b/src/progressbar/test/progressbar.spec.js index 24889e26e7..634737fda5 100644 --- a/src/progressbar/test/progressbar.spec.js +++ b/src/progressbar/test/progressbar.spec.js @@ -1,3 +1,12 @@ +(function() { + +var getInlineWidth = function(element) { + var style = element.attr('style'); + var width = /(^| )width: +([^;]+)(;|$)/i.exec(style)[2]; + + return width; +}; + describe('progressbar directive with no binding', function () { var $rootScope, element; beforeEach(module('ui.bootstrap.progressbar')); @@ -19,7 +28,7 @@ describe('progressbar directive with no binding', function () { }); it('has a "bar" element with expected width', function() { - expect(element.children().eq(0).css('width')).toBe('22%'); + expect(getInlineWidth(element.children().eq(0))).toBe('22%'); }); }); @@ -45,23 +54,23 @@ describe('progressbar directive with data-binding', function () { }); it('has a "bar" element with expected width', function() { - expect(element.children().eq(0).css('width')).toBe('33%'); + expect(getInlineWidth(element.children().eq(0))).toBe('33%'); }); it('changes width when bind value changes', function() { $rootScope.percent = 55; $rootScope.$digest(); expect(element.children().length).toBe(1); - expect(element.children().eq(0).css('width')).toBe('55%'); + expect(getInlineWidth(element.children().eq(0))).toBe('55%'); expect(element.children().eq(0).hasClass('bar')).toBe(true); $rootScope.percent += 11; $rootScope.$digest(); - expect(element.children().eq(0).css('width')).toBe('66%'); + expect(getInlineWidth(element.children().eq(0))).toBe('66%'); $rootScope.percent = 0; $rootScope.$digest(); - expect(element.children().eq(0).css('width')).toBe('0%'); + expect(getInlineWidth(element.children().eq(0))).toBe('0%'); }); it('can handle correctly objects value && class', function() { @@ -75,7 +84,7 @@ describe('progressbar directive with data-binding', function () { expect(element.hasClass('progress')).toBe(true); var barElement = element.children().eq(0); - expect(barElement.css('width')).toBe('45%'); + expect(getInlineWidth(barElement)).toBe('45%'); expect(barElement.hasClass('bar')).toBe(true); expect(barElement.hasClass('bar-warning')).toBe(true); }); @@ -106,9 +115,9 @@ describe('stacked progressbar directive', function () { }); it('has a elements with expected width', function() { - expect(element.children().eq(0).css('width')).toBe('12%'); - expect(element.children().eq(1).css('width')).toBe('22%'); - expect(element.children().eq(2).css('width')).toBe('33%'); + expect(getInlineWidth(element.children().eq(0))).toBe('12%'); + expect(getInlineWidth(element.children().eq(1))).toBe('22%'); + expect(getInlineWidth(element.children().eq(2))).toBe('33%'); }); it('changes width when bind value changes', function() { @@ -116,9 +125,9 @@ describe('stacked progressbar directive', function () { $rootScope.$digest(); expect(element.children().length).toBe(3); - expect(element.children().eq(0).css('width')).toBe('12%'); - expect(element.children().eq(1).css('width')).toBe('35%'); - expect(element.children().eq(2).css('width')).toBe('33%'); + expect(getInlineWidth(element.children().eq(0))).toBe('12%'); + expect(getInlineWidth(element.children().eq(1))).toBe('35%'); + expect(getInlineWidth(element.children().eq(2))).toBe('33%'); }); it('can remove bars', function() { @@ -127,8 +136,8 @@ describe('stacked progressbar directive', function () { expect(element.children().length).toBe(2); - expect(element.children().eq(0).css('width')).toBe('12%'); - expect(element.children().eq(1).css('width')).toBe('22%'); + expect(getInlineWidth(element.children().eq(0))).toBe('12%'); + expect(getInlineWidth(element.children().eq(1))).toBe('22%'); }); it('can handle correctly object changes', function() { @@ -143,17 +152,17 @@ describe('stacked progressbar directive', function () { var barElement; barElement = element.children().eq(0); - expect(barElement.css('width')).toBe('12%'); + expect(getInlineWidth(barElement)).toBe('12%'); expect(barElement.hasClass('bar')).toBe(true); expect(barElement.hasClass('bar-danger')).toBe(false); barElement = element.children().eq(1); - expect(barElement.css('width')).toBe('29%'); + expect(getInlineWidth(barElement)).toBe('29%'); expect(barElement.hasClass('bar')).toBe(true); expect(barElement.hasClass('bar-danger')).toBe(true); barElement = element.children().eq(2); - expect(barElement.css('width')).toBe('33%'); + expect(getInlineWidth(barElement)).toBe('33%'); expect(barElement.hasClass('bar')).toBe(true); expect(barElement.hasClass('bar-danger')).toBe(false); }); @@ -173,23 +182,23 @@ describe('stacked progressbar directive', function () { var barElement; barElement = element.children().eq(0); - expect(barElement.css('width')).toBe('15%'); + expect(getInlineWidth(barElement)).toBe('15%'); expect(barElement.hasClass('bar-info')).toBe(true); barElement = element.children().eq(1); - expect(barElement.css('width')).toBe('11%'); + expect(getInlineWidth(barElement)).toBe('11%'); expect(barElement.hasClass('bar-info')).toBe(false); barElement = element.children().eq(2); - expect(barElement.css('width')).toBe('9%'); + expect(getInlineWidth(barElement)).toBe('9%'); expect(barElement.hasClass('bar-danger')).toBe(true); barElement = element.children().eq(3); - expect(barElement.css('width')).toBe('22%'); + expect(getInlineWidth(barElement)).toBe('22%'); expect(barElement.hasClass('bar-warning')).toBe(true); barElement = element.children().eq(4); - expect(barElement.css('width')).toBe('5%'); + expect(getInlineWidth(barElement)).toBe('5%'); expect(barElement.hasClass('bar-warning')).toBe(false); }); @@ -264,11 +273,11 @@ describe('stacked progressbar directive with auto-types', function () { }); it('has elements with expected width', function() { - expect(element.children().eq(0).css('width')).toBe('12%'); - expect(element.children().eq(1).css('width')).toBe('22%'); - expect(element.children().eq(2).css('width')).toBe('33%'); - expect(element.children().eq(3).css('width')).toBe('5%'); - expect(element.children().eq(4).css('width')).toBe('11%'); + expect(getInlineWidth(element.children().eq(0))).toBe('12%'); + expect(getInlineWidth(element.children().eq(1))).toBe('22%'); + expect(getInlineWidth(element.children().eq(2))).toBe('33%'); + expect(getInlineWidth(element.children().eq(3))).toBe('5%'); + expect(getInlineWidth(element.children().eq(4))).toBe('11%'); }); it('has elements with automatic types', function() { @@ -289,7 +298,7 @@ describe('stacked progressbar directive with auto-types', function () { var stackedTypes = config.stackedTypes; var bar = element.children().eq(1); - expect(bar.css('width')).toBe('18%'); + expect(getInlineWidth(bar)).toBe('18%'); expect(bar.hasClass('bar-' + stackedTypes[1])).toBe(false); expect(bar.hasClass('bar-something')).toBe(true); }); @@ -305,7 +314,7 @@ describe('stacked progressbar directive with auto-types', function () { var stackedTypes = config.stackedTypes; var bar = element.children().eq(1); - expect(bar.css('width')).toBe('18%'); + expect(getInlineWidth(bar)).toBe('18%'); expect(bar.hasClass('bar-' + stackedTypes[1])).toBe(false); expect(bar.hasClass('bar-something')).toBe(true); }); @@ -323,4 +332,6 @@ describe('stacked progressbar directive with auto-types', function () { expect(element.children().eq(2).hasClass('bar-success')).toBe(true); }); -}); \ No newline at end of file +}); + +})(); \ No newline at end of file diff --git a/template/progressbar/progress.html b/template/progressbar/progress.html index d390e79f7d..a2c0c99b42 100644 --- a/template/progressbar/progress.html +++ b/template/progressbar/progress.html @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file From 538412da0a7e0ddfdd8b06fab85bce294e743721 Mon Sep 17 00:00:00 2001 From: Gabriele Rabbiosi Date: Sun, 12 May 2013 14:52:10 +0200 Subject: [PATCH 20/24] Fix typeahead test to make it work in IE8 --- src/typeahead/test/typeahead.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/typeahead/test/typeahead.spec.js b/src/typeahead/test/typeahead.spec.js index 746a5a2854..6956570d7d 100644 --- a/src/typeahead/test/typeahead.spec.js +++ b/src/typeahead/test/typeahead.spec.js @@ -296,7 +296,7 @@ describe('typeahead tests', function () { var element = prepareInputEl("
"); changeInputValueTo(element, 'fo'); - var matchHighlight = findMatches(element).find('a').html(); + var matchHighlight = findMatches(element).find('a').html().toLowerCase(); expect(matchHighlight).toEqual('prefixfoo'); }); From 6cace57d8947fe66ef607affd94f17ee2d4643ad Mon Sep 17 00:00:00 2001 From: Gabriele Rabbiosi Date: Sun, 12 May 2013 15:27:31 +0200 Subject: [PATCH 21/24] Fix tabs tests to make them work in IE8 --- src/tabs/test/tabsSpec.js | 63 ++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 24 deletions(-) diff --git a/src/tabs/test/tabsSpec.js b/src/tabs/test/tabsSpec.js index 0c7ca733a9..8e8ead0863 100644 --- a/src/tabs/test/tabsSpec.js +++ b/src/tabs/test/tabsSpec.js @@ -8,23 +8,27 @@ describe('tabs', function() { beforeEach(module('template/tabs/tabs.html', 'template/tabs/pane.html')); beforeEach(inject(function($rootScope, $compile) { - // we might move this tpl into an html file as well... - elm = angular.element( - '
' + - '' + - '' + - 'first content is {{first}}' + - '' + - '' + - 'second content is {{second}}' + - '' + - '' + - '
'); - + elm = angular.element('
').appendTo(document.body); scope = $rootScope; + + var tpl = + '' + + '' + + 'first content is {{first}}' + + '' + + '' + + 'second content is {{second}}' + + '' + + ''; + elm.html(tpl); $compile(elm)(scope); scope.$digest(); })); + + afterEach(function() { + elm.remove(); + elm = scope = undefined; + }); it('should create clickable titles', inject(function($compile, $rootScope) { @@ -98,17 +102,17 @@ describe('remote selection', function() { beforeEach(module('template/tabs/tabs.html', 'template/tabs/pane.html')); beforeEach(inject(function($rootScope, $compile) { - // we might move this tpl into an html file as well... - elm = angular.element( - '
' + - '' + - '' + - '{{pane.content}}}' + - '' + - '' + - '
' - ); + elm = angular.element('
').appendTo(document.body); scope = $rootScope; + + var tpl = + '' + + '' + + '{{pane.content}}}' + + '' + + ''; + elm.html(tpl); + scope.panes = [ { title:"Dynamic Title 1", content:"Dynamic content 1", active:true}, { title:"Dynamic Title 2", content:"Dynamic content 2" } @@ -222,7 +226,18 @@ describe('remove tabs', function() { it('should remove title panes when elements are destroyed and change selection', inject(function($controller, $compile, $rootScope) { var scope = $rootScope; - var elm = $compile("Hellocontent {{i}}")(scope); + var elm = angular.element('
').appendTo(document.body); + var tpl = + "" + + "" + + "Hello" + + "" + + "" + + "content {{i}}" + + "" + + ""; + elm.html(tpl); + $compile(elm)(scope); scope.$apply(); function titles() { From 9e1bf7752fc978efa9d7b0495d47fb81f85719fb Mon Sep 17 00:00:00 2001 From: Gabriele Rabbiosi Date: Thu, 23 May 2013 22:07:03 +0200 Subject: [PATCH 22/24] Refactor ieshiv template and grunt task --- Gruntfile.js | 12 ++++---- misc/ieshiv-template.js | 61 ----------------------------------------- misc/ieshiv.tpl.js | 39 ++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 67 deletions(-) delete mode 100644 misc/ieshiv-template.js create mode 100644 misc/ieshiv.tpl.js diff --git a/Gruntfile.js b/Gruntfile.js index b85d082350..349cf42725 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -91,7 +91,7 @@ module.exports = function(grunt) { } }, ieshiv: { - src: 'misc/ieshiv-template.js', + src: 'misc/ieshiv.tpl.js', dest: '<%= dist %>/ieshiv-<%= pkg.version %>.js' }, html2js: { @@ -266,17 +266,17 @@ module.exports = function(grunt) { }); grunt.registerTask('ieshiv', 'Create the ieshiv file, based on the current build', function() { - var directives = []; - var matches = grunt.file.read(grunt.config('concat.dist.dest')).match(/\.directive\([^'"]*('|")[^'"]*('|")/g); + var directiveNames = []; + var directiveDeclarations = grunt.file.read(grunt.config('concat.dist.dest')).match(/\.directive\([^'"]*('|")[^'"]*('|")/g); - matches.forEach(function(match) { - directives.push(/('|")([^'"]+)('|")/.exec(match)[2]); + directiveDeclarations.forEach(function(match) { + directiveNames.push(/('|")([^'"]+)('|")/.exec(match)[2]); }); grunt.file.write( grunt.config('ieshiv.dest'), grunt.template.process(grunt.file.read(grunt.config('ieshiv.src')), {data: { - directives: '"' + directives.join('", "') + '"', + directives: '"' + directiveNames.join('", "') + '"', version : grunt.config('pkg.version') }}) ); diff --git a/misc/ieshiv-template.js b/misc/ieshiv-template.js deleted file mode 100644 index 3d0802355f..0000000000 --- a/misc/ieshiv-template.js +++ /dev/null @@ -1,61 +0,0 @@ -// READ: http://docs-next.angularjs.org/guide/ie -// element tags are statically defined in order to accommodate lazy-loading whereby directives are also unknown - -// The ieshiv takes care of our ui.directives and AngularJS's ng-view, ng-include, ng-pluralize, ng-switch. -// However, IF you have custom directives that can be used as html tags (yours or someone else's) then -// add list of directives into window.myCustomTags - -// -// -// Version: <%= version %> -// - -(function (exports) { - - var debug = window.ieShivDebug || false, - tags = [<%= directives %>]; - - window.myCustomTags = window.myCustomTags || []; // externally defined by developer using angular-ui directives - tags.push.apply(tags, window.myCustomTags); - - var toCustomElements = function (str) { - var result = []; - var dashed = str.replace(/([A-Z])/g, function ($1) { - return " " + $1.toLowerCase(); - }); - var tokens = dashed.split(' '); - var dirname = tokens.join('-'); - - result.push(dirname); - result.push("x-" + dirname); - result.push("data-" + dirname); - return result; - -/* for now, ui-bootstrap doesn't have a prefix... - * - var ns = tokens[0]; - var dirname = tokens.slice(1).join('-'); - - // this is finite list and it seemed senseless to create a custom method - result.push(ns + ":" + dirname); - result.push(ns + "-" + dirname); - result.push("x-" + ns + "-" + dirname); - result.push("data-" + ns + "-" + dirname); - return result; -*/ - }; - - for (var i = 0, tlen = tags.length; i < tlen; i++) { - var customElements = toCustomElements(tags[i]); - for (var j = 0, clen = customElements.length; j < clen; j++) { - var customElement = customElements[j]; - document.createElement(customElement); - } - } - -})(window); \ No newline at end of file diff --git a/misc/ieshiv.tpl.js b/misc/ieshiv.tpl.js new file mode 100644 index 0000000000..4d65eca3cc --- /dev/null +++ b/misc/ieshiv.tpl.js @@ -0,0 +1,39 @@ +// READ: http://docs.angularjs.org/guide/ie + +// The ieshiv takes care of ui.bootstrap.* directives; it's dynamically generated +// using the current version of the framework + +// +// +// Version: <%= version %> +// + +(function () { + + var tags = [<%= directives %>]; + + var toCustomElements = function (str) { + var result = []; + var dashed = str.replace(/([A-Z])/g, function ($1) { + return " " + $1.toLowerCase(); + }); + var tokens = dashed.split(' '); + var dirname = tokens.join('-'); + + result.push(dirname); + result.push("x-" + dirname); + result.push("data-" + dirname); + return result; + }; + + for (var i = 0, tlen = tags.length; i < tlen; i++) { + var customElements = toCustomElements(tags[i]); + for (var j = 0, clen = customElements.length; j < clen; j++) { + var customElement = customElements[j]; + document.createElement(customElement); + } + } + +})(); \ No newline at end of file From 538e64f641b5c3d0bfd209142abcf287efea489d Mon Sep 17 00:00:00 2001 From: Gabriele Rabbiosi Date: Thu, 23 May 2013 22:18:33 +0200 Subject: [PATCH 23/24] Fix demo site to make it look nice on IE8 --- misc/demo/index.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/misc/demo/index.html b/misc/demo/index.html index 996ea935ca..c3f9eaf3e9 100644 --- a/misc/demo/index.html +++ b/misc/demo/index.html @@ -9,6 +9,10 @@ From 3ecfebf9f029af22fcb018b49275a2bafd7623b8 Mon Sep 17 00:00:00 2001 From: Gabriele Rabbiosi Date: Thu, 23 May 2013 22:39:24 +0200 Subject: [PATCH 24/24] Add IE8 compatibility documentation on demo site --- misc/demo/index.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/misc/demo/index.html b/misc/demo/index.html index c3f9eaf3e9..53f7cf4f16 100644 --- a/misc/demo/index.html +++ b/misc/demo/index.html @@ -166,6 +166,20 @@

Installation

angular.module('myModule', ['ui.bootstrap']);

You can fork one of the plunkers from this page to see a working example of what is described here.

+

IE8 compatibility

+

To be able to use this library on Internet Explorer 8 you must also include: +

+
    +
  • a shim/shiv library of your choice + (on this site we are using es5-shim)
  • +
  • the ieshiv-*.js file distributed alongside this library
  • +
+

You can include them inside your site like this: +

+