From 0953fb9c63bc7d54a0070549323e096cd2d1c479 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Mon, 9 Apr 2012 23:27:57 +0000 Subject: [PATCH 01/11] What's with all the spaces, man? --- jquery.swapstyle.js | 68 ++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/jquery.swapstyle.js b/jquery.swapstyle.js index f9ad43d..af908cc 100644 --- a/jquery.swapstyle.js +++ b/jquery.swapstyle.js @@ -4,37 +4,35 @@ * Date: 09/14/11 */ -( function ( $ ) { +(function ($) { "use strict"; - $.swapstyle = function ( original, replacement ) { - var s, // Sheet index - r, // Rule index - thisSheet, // Cache each sheet as we loop through - thisNode, // Node for link tags - href, // Cache the href - cssRules, // So we can store where the browser stores import rules - rule; // Cache the rule + $.swapstyle = function (original, replacement) { + var s, // Sheet index + r, // Rule index + thisSheet, // Cache each sheet as we loop through + thisNode, // Node for link tags + href, // Cache the href + cssRules, // So we can store where the browser stores import rules + rule; // Cache the rule // Loop through all the stylesheets - for ( s = 0; s < document.styleSheets.length; s++ ) { + for (s = 0; s < document.styleSheets.length; s++) { // The current stylesheet - thisSheet = document.styleSheets[ s ]; + thisSheet = document.styleSheets[s]; // If the href property isn't null, we should check the rule. - if ( thisSheet.href !== null && - typeof thisSheet.href !== "undefined" ) { - if ( thisSheet.href.indexOf( original ) !== -1 ) { + if (thisSheet.href !== null && typeof thisSheet.href !== "undefined") { + if (thisSheet.href.indexOf(original) !== -1) { // Modify the link in question thisNode = thisSheet.ownerNode; if (thisSheet.owningElement) { - //IE - thisNode = thisSheet.owningElement; + thisNode = thisSheet.owningElement; //IE } - href = thisNode.href; - thisNode.href = href.replace( original, replacement ); + href = thisNode.href; + thisNode.href = href.replace(original, replacement); // We've already replaced the stylesheet, so we // shouldn't haveto check any of it's rules. @@ -45,45 +43,39 @@ // Figure out where the browser keeps it's css rules cssRules = thisSheet.cssRules; - // IE if (thisSheet.imports) { - cssRules = thisSheet.imports; + cssRules = thisSheet.imports; // IE } // Go through the stylesheet's rules if there are any - if ( cssRules !== null ) { - for ( r = 0; r < cssRules.length; r++ ) { + if (cssRules !== null) { + for (r = 0; r < cssRules.length; r++) { // The current rule - rule = cssRules[ r ]; + rule = cssRules[r]; /* * If the rule has an href, it's an @import! We * should check the href. I tried using 'instanceof,' * but Opera had no idea how to handle that * - if ( rule instanceof CSSImportRule && - rule.href.indexOf(original) != -1 ) { */ + if (rule instanceof CSSImportRule && rule.href.indexOf(original) != -1) { */ - if ( rule.href !== null && - typeof rule.href !== "undefined" ) { - if ( rule.href.indexOf( original ) !== -1 ) { + if (rule.href !== null && typeof rule.href !== "undefined") { + if (rule.href.indexOf(original) !== -1) { // Insert the new rule at the end - if ( thisSheet.insertRule ) { - thisSheet.insertRule( - "@import url(" + replacement + ");", - cssRules.length - ); + if (thisSheet.insertRule) { + thisSheet.insertRule("@import url(" + replacement + ");", cssRules.length); } else { // IE - thisSheet.addImport( replacement, cssRules.length ); + thisSheet.addImport(replacement, cssRules.length); } // Delete the old one to get rid of clutter - if ( thisSheet.deleteRule ) { - thisSheet.deleteRule( r ); + if (thisSheet.deleteRule) { + thisSheet.deleteRule(r); } else { // IE - thisSheet.removeImport( r ); + thisSheet.removeImport(r); } } // IF :rule.href.indexOf( original ) !== -1 } // IF: rule.href !== null && typeof rule.href !== "undefined" @@ -91,4 +83,4 @@ } // IF: typeof cssRules !== "undefined" } // FOR: s = 0; s < document.styleSheets.length; s++ }; -} )( jQuery ); \ No newline at end of file +})(jQuery); \ No newline at end of file From b6cc0aa12a0be5be70f16fe949bf886aa17f5bbb Mon Sep 17 00:00:00 2001 From: Benjamin Date: Mon, 9 Apr 2012 23:34:16 +0000 Subject: [PATCH 02/11] What's with all the spaces, man? Seriously. --- jquery.swapstyle.js | 47 +++------------------------------------------ 1 file changed, 3 insertions(+), 44 deletions(-) diff --git a/jquery.swapstyle.js b/jquery.swapstyle.js index a41a665..6e167d0 100644 --- a/jquery.swapstyle.js +++ b/jquery.swapstyle.js @@ -7,41 +7,23 @@ (function ($) { "use strict"; -<<<<<<< HEAD - $.swapstyle = function (original, replacement) { + $.swapstyle = function ( original, replacement ) { var s, // Sheet index r, // Rule index thisSheet, // Cache each sheet as we loop through thisNode, // Node for link tags href, // Cache the href - cssRules, // So we can store where the browser stores import rules + cssRules, // So we can have where the browser keeps import rules rule; // Cache the rule - -======= - $.swapstyle = function ( original, replacement ) { - var s, // Sheet index - r, // Rule index - thisSheet, // Cache each sheet as we loop through - thisNode, // Node for link tags - href, // Cache the href - cssRules, // So we can have where the browser keeps import rules - rule; // Cache the rule ->>>>>>> 961ffce48706401208793f5fa288d2d6af2e7cae // Loop through all the stylesheets for (s = 0; s < document.styleSheets.length; s++) { // The current stylesheet thisSheet = document.styleSheets[s]; // If the href property isn't null, we should check the rule. -<<<<<<< HEAD if (thisSheet.href !== null && typeof thisSheet.href !== "undefined") { if (thisSheet.href.indexOf(original) !== -1) { -======= - if ( thisSheet.href !== null && - typeof thisSheet.href !== "undefined" ) { - if ( thisSheet.href.indexOf( original ) !== -1 ) { ->>>>>>> 961ffce48706401208793f5fa288d2d6af2e7cae // Modify the link in question thisNode = thisSheet.ownerNode; @@ -49,15 +31,9 @@ thisNode = thisSheet.owningElement; //IE } -<<<<<<< HEAD href = thisNode.href; thisNode.href = href.replace(original, replacement); - -======= - href = thisNode.href; - thisNode.href = href.replace( original, replacement ); ->>>>>>> 961ffce48706401208793f5fa288d2d6af2e7cae // We've already replaced the stylesheet, so we // shouldn't haveto check any of it's rules. continue; @@ -84,27 +60,14 @@ * if (rule instanceof CSSImportRule && rule.href.indexOf(original) != -1) { */ -<<<<<<< HEAD if (rule.href !== null && typeof rule.href !== "undefined") { if (rule.href.indexOf(original) !== -1) { -======= - if ( rule.href !== null && - typeof rule.href !== "undefined" ) { - if ( rule.href.indexOf( original ) !== -1 ) { ->>>>>>> 961ffce48706401208793f5fa288d2d6af2e7cae // Insert the new rule at the end if (thisSheet.insertRule) { thisSheet.insertRule("@import url(" + replacement + ");", cssRules.length); } else { // IE -<<<<<<< HEAD thisSheet.addImport(replacement, cssRules.length); -======= - thisSheet.addImport( - replacement, - cssRules.length - ); ->>>>>>> 961ffce48706401208793f5fa288d2d6af2e7cae } // Delete the old one to get rid of clutter @@ -120,8 +83,4 @@ } // IF: typeof cssRules !== "undefined" } // FOR: s = 0; s < document.styleSheets.length; s++ }; -<<<<<<< HEAD -})(jQuery); -======= -} )( jQuery ); ->>>>>>> 961ffce48706401208793f5fa288d2d6af2e7cae +})(jQuery); \ No newline at end of file From a182f9ace321b547aa0084ed83c85304bcf42c83 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Wed, 30 May 2012 11:15:33 -0300 Subject: [PATCH 03/11] Added a link to gh-pages. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8a833dc..dd21d5d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# jQuery.SwapStyle +# [jQuery.SwapStyle](http://btleffler.github.com/jQuery-SwapStyle/) Simple jQuery plugin that swaps out stylesheets. From 06b6b4dc7e86d2cb89b640cd569016944ed64fa5 Mon Sep 17 00:00:00 2001 From: btleffler Date: Mon, 17 Mar 2014 15:10:56 -0400 Subject: [PATCH 04/11] Ignore .project --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..310a24c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.project + From 2e2a1eeaae8524f4927c327e9e85c4b9285b04df Mon Sep 17 00:00:00 2001 From: btleffler Date: Mon, 17 Mar 2014 15:30:52 -0400 Subject: [PATCH 05/11] Add license --- LICENSE | 19 +++++++++++++++++++ README.md | 26 ++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..67dacd9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2013 Benjamin Leffler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md index dd21d5d..6a2993c 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Simple jQuery plugin that swaps out stylesheets. * jQuery (obviously) * Two or more stylesheets that you would like to swap out - + ## Usage Using the plugin is very simple. @@ -23,4 +23,26 @@ Using the plugin is very simple. A simple example would be: - $.swapstyle( "styles/one.css", "styles/two.css" ); \ No newline at end of file + $.swapstyle( "styles/one.css", "styles/two.css" ); + + +# LICENSE - MIT +Copyright (c) 2013 Benjamin Leffler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. From 90e67ea44bd06e804334734978d7779fcd796bb0 Mon Sep 17 00:00:00 2001 From: btleffler Date: Mon, 17 Mar 2014 15:32:39 -0400 Subject: [PATCH 06/11] Update code snippets --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6a2993c..75d7b5b 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,16 @@ Simple jQuery plugin that swaps out stylesheets. Using the plugin is very simple. - $.swapstyle( urlOfOriginal, urlOfReplacment ); +```js +$.swapstyle( urlOfOriginal, urlOfReplacment ); +``` + A simple example would be: - $.swapstyle( "styles/one.css", "styles/two.css" ); +```js +$.swapstyle( "styles/one.css", "styles/two.css" ); +``` # LICENSE - MIT From bec20b900930ae56cdb949a427e28a5dc9034478 Mon Sep 17 00:00:00 2001 From: btleffler Date: Mon, 17 Mar 2014 15:44:58 -0400 Subject: [PATCH 07/11] Add jQuery package json --- swapStyle.jquery.json | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 swapStyle.jquery.json diff --git a/swapStyle.jquery.json b/swapStyle.jquery.json new file mode 100644 index 0000000..c0f0aab --- /dev/null +++ b/swapStyle.jquery.json @@ -0,0 +1,31 @@ +{ + "name": "swapStyle", + "version": "0.1.0", + "title": "jQuery Swap Style", + "author": { + "name": "Benjamin Leffler", + "email": "btleffler@gmail.com", + "url": "http://btleffler.com" + }, + "licenses": [ + { + "type": "MIT", + "URL": "http://opensource.org/licenses/MIT" + } + ], + "dependencies": { + "jQuery": ">=1.6x <3" + }, + "description": "Simple way to swap out CSS stylesheets using jQuery and the javascript CSS api.", + "keywords": [ + "CSS", + "stylesheet", + "swap", + "theme", + "style" + ], + "homepage": "http://btleffler.github.io/jQuery-SwapStyle/", + "docs": "https://github.com/btleffler/jQuery-SwapStyle/blob/master/README.md", + "demo": "http://btleffler.github.io/jQuery-SwapStyle/", + "bugs": "https://github.com/btleffler/jQuery-SwapStyle/issues" +} From 1334300c8cf79709c64ddd36537f8c9b0245e252 Mon Sep 17 00:00:00 2001 From: btleffler Date: Mon, 17 Mar 2014 15:51:16 -0400 Subject: [PATCH 08/11] Tweak based on manifest validator --- swapStyle.jquery.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/swapStyle.jquery.json b/swapStyle.jquery.json index c0f0aab..0c0bf2c 100644 --- a/swapStyle.jquery.json +++ b/swapStyle.jquery.json @@ -10,11 +10,11 @@ "licenses": [ { "type": "MIT", - "URL": "http://opensource.org/licenses/MIT" + "url": "http://opensource.org/licenses/MIT" } ], "dependencies": { - "jQuery": ">=1.6x <3" + "jquery": ">=1.6x <3" }, "description": "Simple way to swap out CSS stylesheets using jQuery and the javascript CSS api.", "keywords": [ From 2cfcfd1d24d6e0c862733163c54e1559c462da36 Mon Sep 17 00:00:00 2001 From: btleffler Date: Mon, 17 Mar 2014 16:07:16 -0400 Subject: [PATCH 09/11] Formatting and comment update --- jquery.swapstyle.js | 10 +++++----- jquery.swapstyle.min.js | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/jquery.swapstyle.js b/jquery.swapstyle.js index 6e167d0..7ecd8c9 100644 --- a/jquery.swapstyle.js +++ b/jquery.swapstyle.js @@ -1,13 +1,13 @@ /** * jQuery.SwapStyle: Swap Stylesheets * Author: Benjamin Leffler - * Date: 09/14/11 + * Date: 03/17/14 */ (function ($) { "use strict"; - $.swapstyle = function ( original, replacement ) { + $.swapstyle = function (original, replacement) { var s, // Sheet index r, // Rule index thisSheet, // Cache each sheet as we loop through @@ -23,7 +23,7 @@ // If the href property isn't null, we should check the rule. if (thisSheet.href !== null && typeof thisSheet.href !== "undefined") { - if (thisSheet.href.indexOf(original) !== -1) { + if (thisSheet.href.indexOf(original) !== -1) { // Modify the link in question thisNode = thisSheet.ownerNode; @@ -31,7 +31,7 @@ thisNode = thisSheet.owningElement; //IE } - href = thisNode.href; + href = thisNode.href; thisNode.href = href.replace(original, replacement); // We've already replaced the stylesheet, so we @@ -83,4 +83,4 @@ } // IF: typeof cssRules !== "undefined" } // FOR: s = 0; s < document.styleSheets.length; s++ }; -})(jQuery); \ No newline at end of file +})(jQuery); diff --git a/jquery.swapstyle.min.js b/jquery.swapstyle.min.js index 539e129..9a3d80f 100644 --- a/jquery.swapstyle.min.js +++ b/jquery.swapstyle.min.js @@ -1,6 +1,7 @@ /** * jQuery.SwapStyle: Swap Stylesheets * Author: Benjamin Leffler - * Date: 09/14/11 + * Date: 03/17/14 */ -(function(a){"use strict";a.swapstyle=function(a,b){var c,d,e,f,g,h,i;for(c=0;c Date: Mon, 17 Mar 2014 16:09:08 -0400 Subject: [PATCH 10/11] version bump --- swapStyle.jquery.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swapStyle.jquery.json b/swapStyle.jquery.json index 0c0bf2c..a2ca9e3 100644 --- a/swapStyle.jquery.json +++ b/swapStyle.jquery.json @@ -1,6 +1,6 @@ { "name": "swapStyle", - "version": "0.1.0", + "version": "0.1.1", "title": "jQuery Swap Style", "author": { "name": "Benjamin Leffler", From c558e1f079dd1f1687f637ff05c55a20d29caa7d Mon Sep 17 00:00:00 2001 From: btleffler Date: Wed, 19 Mar 2014 12:08:35 -0400 Subject: [PATCH 11/11] Updated dates --- LICENSE | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index 67dacd9..a717efe 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2013 Benjamin Leffler +Copyright (c) 2014444 Benjamin Leffler Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 75d7b5b..022d414 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ $.swapstyle( "styles/one.css", "styles/two.css" ); # LICENSE - MIT -Copyright (c) 2013 Benjamin Leffler +Copyright (c) 2014 Benjamin Leffler Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal