├── .gitignore ├── demo ├── pages │ ├── bananas.html │ ├── apricots.html │ ├── coconuts.html │ ├── eggplants.php │ └── durians.html ├── styles │ ├── style.css │ ├── yui-reset-3.1.1-min.css │ └── generic.css ├── scripts │ └── modernizr-1.5.min.js └── index.html ├── CHECKLIST.txt ├── LICENSE.txt ├── README.md ├── Makefile ├── scripts ├── resources │ ├── core.console.js │ ├── jquery.scrollto.js │ ├── jquery.utilities.js │ ├── core.string.js │ ├── jquery.events.js │ ├── jquery.history.js │ └── jquery.extra.js └── jquery.ajaxy.min.js └── History.md /.gitignore: -------------------------------------------------------------------------------- 1 | .build 2 | .DS_Store -------------------------------------------------------------------------------- /demo/pages/bananas.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | jQuery Ajaxy - Bananas 6 | 7 | 8 |
9 | Bananas are long and yellow. 10 |
11 | 12 | -------------------------------------------------------------------------------- /demo/pages/apricots.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | jQuery Ajaxy - Apricots 6 | 7 | 8 |
9 | Apricots are small and orange. 10 |
11 | 12 | -------------------------------------------------------------------------------- /demo/pages/coconuts.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | jQuery Ajaxy - Coconuts 6 | 7 | 8 |
9 | Coconuts are round and hairy. 10 |
11 | 12 | -------------------------------------------------------------------------------- /demo/styles/style.css: -------------------------------------------------------------------------------- 1 | /* Imports*/ 2 | @import url("./yui-reset-3.1.1-min.css"); 3 | @import url("./generic.css"); 4 | 5 | #demo, #demo div { 6 | margin:0; 7 | } 8 | #demo { 9 | margin: 1em 0; 10 | padding: 0; 11 | border: 5px solid #DDD; 12 | font-size: 14px; 13 | } 14 | #menu { 15 | margin:0; 16 | padding:0; 17 | background:#DDD; 18 | border-bottom: 5px solid #DDD; 19 | } 20 | #menu li { 21 | margin:0; 22 | padding:0; 23 | background:white; 24 | padding:0 1em; 25 | } 26 | #menu .active { 27 | background:yellow; 28 | font-weight:bold; 29 | } 30 | #content { 31 | padding:1em; 32 | } 33 | #current { 34 | margin:0; 35 | padding:0; 36 | padding-left:1em; 37 | border-top: 5px solid #DDD; 38 | } 39 | 40 | :target,.target { 41 | background:yellow; 42 | } 43 | -------------------------------------------------------------------------------- /CHECKLIST.txt: -------------------------------------------------------------------------------- 1 | Benjamin "balupton" Lupton's Project Checklist v0.1.1 (July 09, 2010) 2 | 3 | All Projects: 4 | - Have you run all the unit tests for the project? 5 | - Have you remembered to remake the project? [make all] 6 | - Have you tested in all major browsers? 7 | - Have you ensured all documentation dates are correct? 8 | - Have you ensured all documentation project links are current? 9 | - Have you ensured version changelog entries have been added to appropriate file? 10 | - If yes; then you are good to tag this release if you like [git tag -s "v..."] 11 | - To push; use [git push --all] then [git push --tags] 12 | 13 | Project Specific: 14 | - Have you remembered to set it back to the minified version in the demo? 15 | - Do root urls work? 16 | - Do postponed anchors work? 17 | - Do postponed anchors work with back and forward buttons? (scrolling) 18 | - Do ajaxy anchors work? -------------------------------------------------------------------------------- /demo/styles/yui-reset-3.1.1-min.css: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010, Yahoo! Inc. All rights reserved. 3 | Code licensed under the BSD License: 4 | http://developer.yahoo.com/yui/license.html 5 | version: 3.1.1 6 | build: 47 7 | */ 8 | html{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym{border:0;font-variant:normal;}sup{vertical-align:text-top;}sub{vertical-align:text-bottom;}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit;}input,textarea,select{*font-size:100%;}legend{color:#000;} -------------------------------------------------------------------------------- /demo/pages/eggplants.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | jQuery Ajaxy - Eggplants 6 | 7 | 8 | 9 |
10 | 11 | 12 | :-O you know eggplant is a vegetable right? 13 | 14 | You sure know your stuff ;-) 15 | 16 | 17 |
18 | Would you say that eggplants came from eggs?
19 |
20 |
21 | 22 |
23 | 24 | If this form does not submit properly, it is because the server this is hosted on does not support AJAX POST requests. 25 |
26 | 27 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | (The MIT License) 2 | 3 | Copyright (c) 2008-2010 Benjamin Lupton 4 | 5 | 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: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | 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. 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## jQuery Ajaxy 2 | 3 | jQuery Ajaxy aims at solving complicated AJAX Paradigms by providing you with a easy managed solution to bind into page state (URL Hash) changes, AJAX form submits, and support AJAX links. 4 | 5 | 6 | ## Usage 7 | 8 | Refer to the [demo](http://balupton.github.com/jquery-ajaxy/demo/) and the [source code](https://github.com/balupton/jquery-ajaxy/tree/master/scripts/resources) 9 | 10 | To discover available configuration options, refer to [lines 36 to 156 in the `scripts/resources/jquery.ajaxy.js` file](https://github.com/balupton/jquery-ajaxy/blob/master/scripts/resources/jquery.ajaxy.js#L36-156) 11 | 12 | 13 | ## History 14 | 15 | You can discover the history inside the [History.md](https://github.com/balupton/jquery-ajaxy/blob/master/History.md#files) file 16 | 17 | 18 | ## License 19 | 20 | Licensed under the [MIT License](http://creativecommons.org/licenses/MIT/) 21 |
Copyright © 2008-2010 [Benjamin Arthur Lupton](http://balupton.com) 22 | 23 | 24 | ## Thanks 25 | 26 | - [jQuery](http://jquery.com/) 27 | - [jQuery UI History - Klaus Hartl](http://www.stilbuero.de/jquery/ui_history/) 28 | - [Really Simple History - Brian Dillard and Brad Neuberg](http://code.google.com/p/reallysimplehistory/) 29 | - [jQuery History Plugin - Taku Sano (Mikage Sawatari)](http://www.mikage.to/jquery/jquery_history.html) 30 | - [jQuery History Remote Plugin - Klaus Hartl](http://stilbuero.de/jquery/history/) 31 | - [Content With Style: Fixing the back button and enabling bookmarking for ajax apps - Mike Stenhouse](http://www.contentwithstyle.co.uk/Articles/38/fixing-the-back-button-and-enabling-bookmarking-for-ajax-apps) 32 | - [Bookmarks and Back Buttons](http://ajax.howtosetup.info/options-and-efficiencies/bookmarks-and-back-buttons/) 33 | - [Ajax: How to handle bookmarks and back buttons - Brad Neuberg](http://dev.aol.com/ajax-handling-bookmarks-and-back-button) 34 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Javascript/CSS Compressor Makefile - By Benjamin "balupton" Lupton (MIT Licenced) 2 | 3 | MAKEFLAGS = --no-print-directory --always-make 4 | MAKE = make $(MAKEFLAGS) 5 | 6 | BUILDDIR = ./.build 7 | 8 | CLOSUREURL = http://closure-compiler.googlecode.com/files/compiler-latest.zip 9 | CLOSUREDIR = $(BUILDDIR)/closure 10 | CLOSUREFILE = $(CLOSUREDIR)/compiler.jar 11 | YUIURL = http://yui.zenfs.com/releases/yuicompressor/yuicompressor-2.4.7.zip 12 | YUIDIR = $(BUILDDIR)/yui 13 | YUIFILE = $(YUIDIR)/yuicompressor-2.4.7/build/yuicompressor-2.4.7.jar 14 | 15 | 16 | all: 17 | $(MAKE) build; 18 | $(MAKE) add; 19 | 20 | 21 | demo: 22 | open ./demo/index.html 23 | 24 | add: 25 | git add .gitignore CHECKLIST.* COPYING.* demo Makefile README.* scripts 26 | 27 | push: 28 | git push --all ; git push --tags ; 29 | 30 | edithooks: 31 | mate .git/hooks/pre-commit 32 | 33 | 34 | refresh: 35 | wget -q http://balupton.github.com/jquery-sparkle/scripts/resources/core.console.js -O scripts/resources/core.console.js ; 36 | wget -q http://balupton.github.com/jquery-sparkle/scripts/resources/core.string.js -O scripts/resources/core.string.js ; 37 | wget -q http://balupton.github.com/jquery-sparkle/scripts/resources/jquery.events.js -O scripts/resources/jquery.events.js ; 38 | wget -q http://balupton.github.com/jquery-sparkle/scripts/resources/jquery.extra.js -O scripts/resources/jquery.extra.js ; 39 | wget -q http://balupton.github.com/jquery-sparkle/scripts/resources/jquery.utilities.js -O scripts/resources/jquery.utilities.js ; 40 | wget -q http://balupton.github.com/jquery-scrollto/scripts/resources/jquery.scrollto.js -O scripts/resources/jquery.scrollto.js ; 41 | wget -q http://balupton.github.com/jquery-history/scripts/resources/jquery.history.js -O scripts/resources/jquery.history.js ; 42 | wget -q http://balupton.github.com/jquery-history/demo/styles/generic.css -O demo/styles/generic.css ; 43 | 44 | 45 | pack: 46 | cat \ 47 | ./scripts/resources/core.console.js \ 48 | ./scripts/resources/core.string.js \ 49 | ./scripts/resources/jquery.events.js \ 50 | ./scripts/resources/jquery.extra.js \ 51 | ./scripts/resources/jquery.utilities.js \ 52 | ./scripts/resources/jquery.scrollto.js \ 53 | ./scripts/resources/jquery.history.js \ 54 | ./scripts/resources/jquery.ajaxy.js \ 55 | > ./scripts/jquery.ajaxy.js; 56 | 57 | compress: 58 | java -jar $(CLOSUREFILE) --create_source_map ./scripts/closure.map --js_output_file=./scripts/jquery.ajaxy.min.js --js=./scripts/jquery.ajaxy.js; 59 | 60 | build: 61 | $(MAKE) pack; 62 | $(MAKE) compress; 63 | 64 | build-update: 65 | $(MAKE) clean; 66 | mkdir $(BUILDDIR) $(CLOSUREDIR) $(YUIDIR); 67 | cd $(CLOSUREDIR); wget $(CLOSUREURL) -O file.zip; tar -xf file.zip; 68 | cd $(YUIDIR); wget $(YUIURL) -O file.zip; tar -xf file.zip; 69 | 70 | clean: 71 | rm -Rf $(BUILDDIR); 72 | -------------------------------------------------------------------------------- /demo/pages/durians.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | jQuery Ajaxy - Durians 6 | 7 | 8 |
9 |

The durian (pronounced /ˈdʊəriən/)[2] is the fruit of several tree species belonging to the genus Durio and the Malvaceae family[1][3] (although some taxonomists place Durio in a distinct family, Durionaceae[1]). Widely known and revered in southeast Asia as the "king of fruits", the durian is distinctive for its large size, unique odour, and formidable thorn-covered husk. The fruit can grow as large as 30 centimetres (12 in) long and 15 centimetres (6 in) in diameter, and it typically weighs one to three kilograms (2 to 7 lb). Its shape ranges from oblong to round, the colour of its husk green to brown, and its flesh pale yellow to red, depending on the species.

10 |

The edible flesh emits a distinctive odour, strong and penetrating even when the husk is intact. Some people regard the durian as fragrant; others find the aroma overpowering and offensive. The smell evokes reactions from deep appreciation to intense disgust. The odour has led to the fruit's banishment from certain hotels and public transportation in southeast Asia.

11 |

The durian, native to Brunei, Indonesia and Malaysia, has been known to the Western world for about 600 years. The 19th-century British naturalist Alfred Russel Wallace famously described its flesh as "a rich custard highly flavoured with almonds". The flesh can be consumed at various stages of ripeness, and it is used to flavour a wide variety of savoury and sweet edibles in Southeast Asian cuisines. The seeds can also be eaten when cooked.

12 |

There are 30 recognised Durio species, at least nine of which produce edible fruit. Durio zibethinus is the only species available in the international market: other species are sold in their local regions. There are hundreds of durian cultivars; many consumers express preferences for specific cultivars, which fetch higher prices in the market.

13 |
14 |

They are soo yummy.

15 |

As you just saw when you clicked the durians link; the browser would have automatically just scrolled to the sentence "They are soo yummy" and highlighted it yellow. This is because on the durians link we clicked, there is an anchor which points to that sentence. This is done with:
16 | <a href="./pages/durians.html#yummy" class="ajaxy ajaxy-page">Learn about Durians</a>
17 | Ajaxy will automatically convert the #yummy anchor into part of our querystring and use that. This is pretty awesome as it allows us to still have full support for anchor functionality despite us hijacking the hash to use for ajax states!
18 | The yellow background color is specified using the CSS3 :target,.target selector.

19 |
20 | 21 | -------------------------------------------------------------------------------- /demo/styles/generic.css: -------------------------------------------------------------------------------- 1 | /* CSS */ 2 | 3 | h1 { 4 | font-size: 2.5em; 5 | font-weight: bold; 6 | margin: 0.67em 0px 0.5em; 7 | } 8 | h2 { 9 | font-size: 2em; 10 | font-weight: bold; 11 | margin: 0.83em 0px 0.4em; 12 | } 13 | h3 { 14 | font-size: 1.5em; 15 | font-weight: bold; 16 | margin: 0.83em 0px 0.3em; 17 | } 18 | 19 | code.code, pre.code { 20 | border: 5px solid #DDD; 21 | padding: 7px 0 5px; 22 | font-size: 14px; 23 | overflow: auto; 24 | max-height: 500px; 25 | width: 100%; 26 | white-space: pre; 27 | display: block; 28 | } 29 | body code.prettyprint, body pre.prettyprint { 30 | border: 5px solid #DDD; 31 | padding: 7px 0 5px; 32 | } 33 | 34 | strong { 35 | font-weight:bold; 36 | } 37 | em { 38 | font-style:italic; 39 | } 40 | 41 | body { 42 | padding-left: 0px; 43 | padding-right: 0px; 44 | font-family: Arial, Helvetica, sans-serif; 45 | color: #000000; 46 | } 47 | 48 | 49 | p, 50 | .section div { 51 | padding: 0px; 52 | margin:1em 0; 53 | } 54 | .section.install p, 55 | .section.install div { 56 | margin:0.2em 0 1em; 57 | } 58 | 59 | 60 | textarea { 61 | width: 100%; 62 | } 63 | 64 | label { 65 | font-weight:bold; 66 | } 67 | 68 | .cols.two { 69 | position:relative; 70 | overflow:auto; 71 | } 72 | .cols .one { 73 | width:49%; 74 | float:left; 75 | } 76 | .cols .two { 77 | width:49%; 78 | float:right; 79 | } 80 | 81 | .section { 82 | border-top: 1px solid #BBB; 83 | margin-top: 15px; 84 | margin-left: 5%; 85 | margin-right: 5%; 86 | padding: 5px; 87 | padding-bottom: 0px; 88 | background-color: white; 89 | } 90 | 91 | .section ul { 92 | list-style: none; 93 | margin-top: 5px; 94 | } 95 | 96 | .section ul li { 97 | display: inline; 98 | } 99 | 100 | a.help { 101 | text-decoration:none; 102 | border-bottom:1px dotted #00E; 103 | } 104 | a.help:visited { 105 | border-bottom:1px dotted #551A8B; 106 | } 107 | 108 | .section ul.features { 109 | display: block; 110 | list-style: disc; 111 | margin-left:2em; 112 | } 113 | .section ul.features li { 114 | list-style: disc; 115 | display: list-item; 116 | } 117 | 118 | .section ul.install, 119 | .section ul.install li { 120 | list-style:disc outside none; 121 | } 122 | .section ul.install { 123 | margin-left:2em; 124 | } 125 | .section ul.install li { 126 | display: list-item; 127 | } 128 | 129 | .section span.code { 130 | font-family: "Courier New", Courier, monospace; 131 | margin-left: 10px; 132 | padding-left: 10px; 133 | font-size: 11px; 134 | border-left: 1px solid #000; 135 | } 136 | 137 | .section .link { 138 | font-size: 12px; 139 | font-style: italic; 140 | padding-left: 10px; 141 | margin-left: 10px; 142 | } 143 | 144 | .section .important { 145 | text-decoration: underline; 146 | } 147 | 148 | .section .title { 149 | font-weight: bold; 150 | font-size: 16px; 151 | } 152 | 153 | .clear { 154 | clear: left; 155 | } 156 | 157 | .section.header { 158 | text-align: center; 159 | font-size: 12px; 160 | padding-top: 10px; 161 | border-top: none; 162 | } 163 | 164 | .section.footer { 165 | text-align: center; 166 | font-size: 12px; 167 | padding-top: 10px; 168 | } 169 | 170 | body.loading { 171 | cursor:wait; 172 | } -------------------------------------------------------------------------------- /scripts/resources/core.console.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @depends nothing 3 | * @name core.console 4 | * @package jquery-sparkle {@link http://balupton.com/projects/jquery-sparkle} 5 | */ 6 | 7 | /** 8 | * Console Emulator 9 | * We have to convert arguments into arrays, and do this explicitly as webkit (chrome) hates function references, and arguments cannot be passed as is 10 | * @version 1.0.3 11 | * @date August 31, 2010 12 | * @since 0.1.0-dev, December 01, 2009 13 | * @package jquery-sparkle {@link http://balupton.com/projects/jquery-sparkle} 14 | * @author Benjamin "balupton" Lupton {@link http://balupton.com} 15 | * @copyright (c) 2009-2010 Benjamin Arthur Lupton {@link http://balupton.com} 16 | * @license MIT License {@link http://creativecommons.org/licenses/MIT/} 17 | */ 18 | 19 | // Check to see if console exists, if not define it 20 | if ( typeof window.console === 'undefined' ) { 21 | window.console = {}; 22 | } 23 | 24 | // Check to see if we have emulated the console yet 25 | if ( typeof window.console.emulated === 'undefined' ) { 26 | // Emulate Log 27 | if ( typeof window.console.log === 'function' ) { 28 | window.console.hasLog = true; 29 | } 30 | else { 31 | if ( typeof window.console.log === 'undefined' ) { 32 | window.console.log = function(){}; 33 | } 34 | window.console.hasLog = false; 35 | } 36 | 37 | // Emulate Debug 38 | if ( typeof window.console.debug === 'function' ) { 39 | window.console.hasDebug = true; 40 | } 41 | else { 42 | if ( typeof window.console.debug === 'undefined' ) { 43 | window.console.debug = !window.console.hasLog ? function(){} : function(){ 44 | var arr = ['console.debug:']; for(var i = 0; i < arguments.length; i++) { arr.push(arguments[i]); }; 45 | window.console.log.apply(window.console, arr); 46 | }; 47 | } 48 | window.console.hasDebug = false; 49 | } 50 | 51 | // Emulate Warn 52 | if ( typeof window.console.warn === 'function' ) { 53 | window.console.hasWarn = true; 54 | } 55 | else { 56 | if ( typeof window.console.warn === 'undefined' ) { 57 | window.console.warn = !window.console.hasLog ? function(){} : function(){ 58 | var arr = ['console.warn:']; for(var i = 0; i < arguments.length; i++) { arr.push(arguments[i]); }; 59 | window.console.log.apply(window.console, arr); 60 | }; 61 | } 62 | window.console.hasWarn = false; 63 | } 64 | 65 | // Emulate Error 66 | if ( typeof window.console.error === 'function' ) { 67 | window.console.hasError = true; 68 | } 69 | else { 70 | if ( typeof window.console.error === 'undefined' ) { 71 | window.console.error = function(){ 72 | var msg = "An error has occured."; 73 | 74 | // Log 75 | if ( window.console.hasLog ) { 76 | var arr = ['console.error:']; for(var i = 0; i < arguments.length; i++) { arr.push(arguments[i]); }; 77 | window.console.log.apply(window.console, arr); 78 | // Adjust Message 79 | msg = 'An error has occured. More information is available in your browser\'s javascript console.' 80 | } 81 | 82 | // Prepare Arguments 83 | for ( var i = 0; i < arguments.length; ++i ) { 84 | if ( typeof arguments[i] !== 'string' ) { 85 | break; 86 | } 87 | msg += "\n"+arguments[i]; 88 | } 89 | 90 | // Throw Error 91 | if ( typeof Error !== 'undefined' ) { 92 | throw new Error(msg); 93 | } 94 | else { 95 | throw(msg); 96 | } 97 | }; 98 | } 99 | window.console.hasError = false; 100 | } 101 | 102 | // Emulate Trace 103 | if ( typeof window.console.trace === 'function' ) { 104 | window.console.hasTrace = true; 105 | } 106 | else { 107 | if ( typeof window.console.trace === 'undefined' ) { 108 | window.console.trace = function(){ 109 | window.console.error('console.trace does not exist'); 110 | }; 111 | } 112 | window.console.hasTrace = false; 113 | } 114 | 115 | // Done 116 | window.console.emulated = true; 117 | } 118 | -------------------------------------------------------------------------------- /scripts/resources/jquery.scrollto.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @depends jquery 3 | * @name jquery.scrollto 4 | * @package jquery-scrollto {@link http://balupton.com/projects/jquery-scrollto} 5 | */ 6 | 7 | /** 8 | * jQuery Aliaser 9 | */ 10 | (function($){ 11 | 12 | /** 13 | * jQuery ScrollTo (balupton edition) 14 | * @version 1.0.1 15 | * @date August 31, 2010 16 | * @since 0.1.0, August 27, 2010 17 | * @package jquery-scrollto {@link http://balupton.com/projects/jquery-scrollto} 18 | * @author Benjamin "balupton" Lupton {@link http://balupton.com} 19 | * @copyright (c) 2010 Benjamin Arthur Lupton {@link http://balupton.com} 20 | * @license MIT License {@link http://creativecommons.org/licenses/MIT/} 21 | */ 22 | if ( !($.ScrollTo||false) ) { 23 | $.ScrollTo = { 24 | /** 25 | * The Default Configuration 26 | */ 27 | config: { 28 | duration: 400, 29 | easing: 'swing', 30 | callback: undefined, 31 | durationMode: 'each' 32 | }, 33 | 34 | /** 35 | * Configure ScrollTo 36 | */ 37 | configure: function(options){ 38 | var ScrollTo = $.ScrollTo; 39 | 40 | // Apply Options to Config 41 | $.extend(ScrollTo.config, options||{}); 42 | 43 | // Chain 44 | return this; 45 | }, 46 | 47 | /** 48 | * Perform the Scroll Animation for the Collections 49 | * We use $inline here, so we can determine the actual offset start for each overflow:scroll item 50 | * Each collection is for each overflow:scroll item 51 | */ 52 | scroll: function(collections, config){ 53 | var ScrollTo = $.ScrollTo; 54 | 55 | // Determine the Scroll 56 | var collection = collections.pop(), 57 | $container = collection.$container, 58 | $target = collection.$target; 59 | 60 | // Prepare the Inline Element of the Container 61 | var $inline = $('').css({ 62 | 'position': 'absolute', 63 | 'top': '0px', 64 | 'left': '0px' 65 | }); 66 | var position = $container.css('position'); 67 | 68 | // Insert the Inline Element of the Container 69 | $container.css('position','relative'); 70 | $inline.appendTo($container); 71 | 72 | // Determine the Offsets 73 | var startOffset = $inline.offset().top, 74 | targetOffset = $target.offset().top, 75 | offsetDifference = targetOffset - startOffset; 76 | 77 | // Reset the Inline Element of the Container 78 | $inline.remove(); 79 | $container.css('position',position); 80 | 81 | // Prepare the callback 82 | var callback = function(event){ 83 | // Check 84 | if ( collections.length === 0 ) { 85 | // Callback 86 | if ( typeof config.callback === 'function' ) { 87 | config.callback.apply(this,[event]); 88 | } 89 | } 90 | else { 91 | // Recurse 92 | ScrollTo.scroll(collections,config); 93 | } 94 | // Return true 95 | return true; 96 | }; 97 | 98 | // Perform the Scroll 99 | $container.animate({ 100 | 'scrollTop': offsetDifference+'px' 101 | }, config.duration, config.easing, callback); 102 | 103 | // Return true 104 | return true; 105 | }, 106 | 107 | /** 108 | * ScrollTo the Element using the Options 109 | */ 110 | fn: function(options){ 111 | var ScrollTo = $.ScrollTo; 112 | 113 | // Prepare 114 | var $target = $(this); 115 | if ( $target.length === 0 ) { 116 | // Chain 117 | return this; 118 | } 119 | 120 | // Fetch 121 | var $container = $target.parent(), 122 | collections = []; 123 | 124 | // Handle Options 125 | config = $.extend({},ScrollTo.config,options); 126 | 127 | // Cycle through the containers 128 | while ( $container.length === 1 && !$container.is('body') && !($container.get(0) === document) ) { 129 | // Check Container 130 | var container = $container.get(0); 131 | if ( $container.css('overflow-y') !== 'visible' && container.scrollHeight !== container.clientHeight ) { 132 | // Push the Collection 133 | collections.push({ 134 | '$container': $container, 135 | '$target': $target 136 | }); 137 | // Update the Target 138 | $target = $container; 139 | } 140 | // Update the Container 141 | $container = $container.parent(); 142 | } 143 | 144 | // Add the final collection 145 | collections.push({ 146 | '$container': $($.browser.msie ? 'html' : 'body'), 147 | '$target': $target 148 | }); 149 | 150 | // Adjust the Config 151 | if ( config.durationMode === 'all' ) { 152 | config.duration /= collections.length; 153 | } 154 | 155 | // Handle 156 | ScrollTo.scroll(collections,config); 157 | 158 | // Chain 159 | return this; 160 | }, 161 | 162 | /** 163 | * Construct 164 | */ 165 | construct: function(options){ 166 | var ScrollTo = $.ScrollTo; 167 | 168 | // Apply our jQuery Function 169 | $.fn.ScrollTo = ScrollTo.fn; 170 | 171 | // Apply our Options to the Default Config 172 | ScrollTo.config = $.extend(ScrollTo.config,options); 173 | 174 | // Chain 175 | return this; 176 | } 177 | }; 178 | 179 | // Construct It 180 | $.ScrollTo.construct(); 181 | } 182 | else { 183 | window.console.warn("$.ScrollTo has already been defined..."); 184 | } 185 | 186 | })(jQuery); 187 | -------------------------------------------------------------------------------- /scripts/resources/jquery.utilities.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @depends jquery 3 | * @name jquery.utilities 4 | * @package jquery-sparkle {@link http://balupton.com/projects/jquery-sparkle} 5 | */ 6 | 7 | /** 8 | * jQuery Aliaser 9 | */ 10 | (function($){ 11 | 12 | /** 13 | * Creates a new object, which uses baseObject's structure, and userObject's values when applicable 14 | * @params {Object} baseObject 15 | * @params {Object} userObject 16 | * @params {Object} ... 17 | * @return {Object} newObject 18 | * @version 1.0.0 19 | * @date August 01, 2010 20 | * @since 1.0.0 21 | * @package jquery-sparkle {@link http://balupton.com/projects/jquery-sparkle} 22 | * @author Benjamin "balupton" Lupton {@link http://balupton.com} 23 | * @copyright (c) 2009-2010 Benjamin Arthur Lupton {@link http://balupton.com} 24 | * @license MIT License {@link http://creativecommons.org/licenses/MIT/} 25 | */ 26 | $.prepareObject = $.prepareObject || function(baseObject,userObject) { 27 | var newObject = {}; 28 | var skipValue = '$.prepareObject.skipValue'; 29 | 30 | // Extend newObject 31 | $.extend(newObject,baseObject||{}); 32 | 33 | // Intercept with the userObject 34 | $.intercept(true,newObject,userObject); 35 | 36 | // Handle additional params 37 | var objects = arguments; 38 | objects[0] = objects[1] = skipValue; 39 | 40 | // Cycle through additional objects 41 | $.each(objects,function(i,object){ 42 | // Check if we want to skip 43 | if ( object === skipValue ) return true; // continue 44 | // Intercept with the object 45 | $.intercept(true,newObject,object); 46 | }); 47 | 48 | // Return the newObject 49 | return newObject; 50 | }; 51 | 52 | /** 53 | * Intercept two objects 54 | * @params [deep], &object1, object2, ... 55 | * @version 1.0.0 56 | * @date August 01, 2010 57 | * @since 1.0.0 58 | * @package jquery-sparkle {@link http://balupton.com/projects/jquery-sparkle} 59 | * @author Benjamin "balupton" Lupton {@link http://balupton.com} 60 | * @copyright (c) 2009-2010 Benjamin Arthur Lupton {@link http://balupton.com} 61 | * @license MIT License {@link http://creativecommons.org/licenses/MIT/} 62 | */ 63 | $.intercept = $.intercept || function() { 64 | // Prepare 65 | var objects = arguments, 66 | object, 67 | deep = false, 68 | copy = false; 69 | var skipValue = '$.intercept.skipValue'; 70 | 71 | // Check Deep 72 | if ( typeof objects[0] === 'boolean' ) { 73 | deep = objects[0]; 74 | objects[0] = skipValue; 75 | // Check Copy 76 | if ( typeof objects[1] === 'boolean' ) { 77 | copy = objects[1]; 78 | objects[1] = skipValue; 79 | // Handle Copy 80 | if ( copy ) { 81 | object = {}; 82 | } 83 | else { 84 | object = objects[2]; 85 | objects[2] = skipValue; 86 | } 87 | } 88 | else { 89 | object = objects[1]; 90 | objects[1] = skipValue; 91 | } 92 | } 93 | else { 94 | object = objects[0]; 95 | objects[0] = skipValue; 96 | } 97 | 98 | // Grab Keys 99 | var keys = {}; 100 | $.each(object,function(key){ 101 | keys[key] = true; 102 | }); 103 | 104 | // Intercept Objects 105 | if ( deep ) { 106 | // Cycle through objects 107 | $.each(objects, function(i,v){ 108 | // Check if we want to skip 109 | if ( v === skipValue ) return true; // continue 110 | // Cycle through arguments 111 | $.each(v, function(key,value){ 112 | // Check if the key exists so we can intercept 113 | if ( typeof keys[key] === 'undefined' ) return true; // continue 114 | // It exists, check value type 115 | if ( typeof value === 'object' && !(value.test||false && value.exec||false) ) { 116 | // Extend this object 117 | $.extend(object[key],value||{}); 118 | } 119 | else { 120 | // Copy value over 121 | object[key] = value; 122 | } 123 | }); 124 | }) 125 | } 126 | else { 127 | // Cycle through objects 128 | $.each(objects, function(i,v){ 129 | // Cycle through arguments 130 | $.each(v, function(key,value){ 131 | // Check if the key exists so we can intercept 132 | if ( typeof keys[key] === 'undefined' ) return true; // continue 133 | // It exists, check value type 134 | if ( typeof value === 'object' && !(value.test||false && value.exec||false) ) { 135 | // Intercept this object 136 | $.intercept(true,object[key],value); 137 | } 138 | else { 139 | // Copy value over 140 | object[key] = value; 141 | } 142 | }); 143 | }) 144 | } 145 | 146 | // Return object 147 | return object; 148 | }; 149 | 150 | /** 151 | * Handle a Promise 152 | * @param {Object} options.object 153 | * @param {String} options.handlers 154 | * @param {String} options.flag 155 | * @param {Funtion} options.handler 156 | * @return {Boolean} Whether or not the promise is ready 157 | * @version 1.0.0 158 | * @date August 31, 2010 159 | * @since 1.0.0 160 | * @package jquery-sparkle {@link http://balupton.com/projects/jquery-sparkle} 161 | * @author Benjamin "balupton" Lupton {@link http://balupton.com} 162 | * @copyright (c) 2009-2010 Benjamin Arthur Lupton {@link http://balupton.com} 163 | * @license MIT License {@link http://creativecommons.org/licenses/MIT/} 164 | */ 165 | $.promise = $.promise || function(options){ 166 | // Extract 167 | var object = options.object||this; 168 | 169 | // Check 170 | if ( typeof object[options.handlers] === 'undefined' ) { 171 | object[options.handlers] = []; 172 | } 173 | if ( typeof object[options.flag] === 'undefined' ) { 174 | object[options.flag] = false; 175 | } 176 | 177 | // Extract 178 | var handlers = object[options.handlers], 179 | flag = object[options.flag], 180 | handler = options.arguments[0]; 181 | 182 | // Handle 183 | switch ( typeof handler ) { 184 | case 'boolean': 185 | // We want to set the flag as true or false, then continue on 186 | flag = object[options.flag] = handler; 187 | // no break, as we want to continue on 188 | 189 | case 'undefined': 190 | // We want to fire the handlers, so check if the flag is true 191 | if ( flag && handlers.length ) { 192 | // Fire the handlers 193 | $.each(handlers, function(i,handler){ 194 | handler.call(object); 195 | }); 196 | // Clear the handlers 197 | object[options.handlers] = []; 198 | } 199 | break; 200 | 201 | case 'function': 202 | // We want to add or fire a handler, so check the flag 203 | if ( flag ) { 204 | // Fire the event handler 205 | handler.call(object); 206 | } 207 | else { 208 | // Add to the handlers 209 | object[options.handlers].push(handler); 210 | } 211 | break; 212 | 213 | default: 214 | window.console.error('Unknown arguments for $.promise', [this, arguments]); 215 | break; 216 | } 217 | 218 | // Return flag 219 | return flag; 220 | } 221 | 222 | })(jQuery); 223 | -------------------------------------------------------------------------------- /History.md: -------------------------------------------------------------------------------- 1 | ## History 2 | 3 | v1.6.1, December 28, 2012 4 | - Fixed `
` elements being stripped 5 | - Thanks to [exocom](https://github.com/exocom) for [pull request #7](https://github.com/balupton/jquery-ajaxy/pull/7) 6 | 7 | v1.6.0-beta, August 31, 2010 8 | - Added Ajaxy form demo. 9 | - Added Ajaxy.onReady, Ajaxy.onDocumentReady and Ajaxy.onConfigured promises 10 | - Controllers should now use classname instead of selector. B/C Break. 11 | - $.fn.addAjaxy now supports passing a controller so we can add the Controller.classname to the element(s) 12 | - Added $.fn.addAjaxy and $.fn.removeAjaxy 13 | - State.actionCompleted callback now supports options. 14 | - Added Refresh Action, this is triggered when we click the same Ajaxy link twice. If the refresh action does not exist a log will be outputted, and the Response action will be used instead. B/C Partial Break. 15 | - Improvements to the anchor handling, page tracking and scrolling. 16 | - While in postponed mode, and a anchor is clicked, we will treat the anchor as normal and not perform a redirect. 17 | - Added postpone and disable redirect option values. Postpone will postpone ajaxy functionality until the page is changed. Disable will disable ajaxy functionality all together. 18 | - Made Ajaxy.bind alias Ajaxy.addControllers, and add Ajaxy.addController 19 | - Fixed issue with jQuery UI AutoComplete. Fix due to update of sparkle dependencies. 20 | - We now use jQuery ScrollTo [v1.0.1-beta, August 31, 2010] as our ScrollTo Plugin: http://www.balupton.com/projects/jquery-scrollto 21 | - Updated jQuery History dependencies to [v1.5.0-final, August 31, 2010] 22 | - Updated jQuery Sparkle dependencies to [v1.5.2-beta, August 31, 2010] 23 | 24 | v1.5.8-beta, August 23, 2010 25 | - Added root_url to internal link checks 26 | - Improved internal links adding 27 | 28 | v1.5.7-beta, August 22, 2010 29 | - Added demo for Ajaxy Forms 30 | - Fixed Ajaxy Forms when used with Controller Selectors 31 | 32 | v1.5.6-beta, August 21, 2010 33 | - Updated jQuery Sparkle dependencies to [v1.4.17-final, August 21, 2010] 34 | - Updated jQuery History dependencies to [v1.4.4-final, August 21, 2010] 35 | 36 | v1.5.5-beta, August 19, 2010 37 | - Fixed issue with external links. http://getsatisfaction.com/balupton/topics/external_links_dont_work 38 | - Improved installation instructions to make more clear. 39 | - Updated Syntax Highlighter include and initialisation. We use http://www.balupton.com/projects/jquery-syntaxhighlighter 40 | - Code blocks within the demo are now using PRE instead of CODE elements due to an IE bug 41 | - Updated jQuery Sparkle dependencies to [v1.4.13-final, August 19, 2010]. 42 | - Updated jQuery History dependencies to [v1.4.3-final, August 19, 2010]. 43 | 44 | v1.5.4-beta, August 12, 2010 45 | - Updated jQuery History dependencies to [v1.4.2-final, August 12, 2010]. 46 | - This is a recommended update for all users. 47 | 48 | v1.5.3-beta, August 07, 2010 49 | - The Response.data returned on normal html ajaxy links is now as follows: 50 | { 51 | "controller": controller, 52 | "responseText": responseText, /* raw result */ 53 | "html": html, /* raw result put through Ajaxy.htmlCompat */ 54 | "title": title, /* the text of the title/#ajaxy-title element */ 55 | "head": head, /* the outerHTML of the head/#ajaxy-head element */ 56 | "body": body, /* the outerHTML of the body/#ajaxy-body element */ 57 | "content": content /* the innerHTML of the body/#ajaxy-body element or the html value */ 58 | } 59 | - Updated jQuery Sparkle dependencies to [v1.4.10-beta, August 07, 2010] 60 | 61 | v1.5.2-beta, August 07, 2010 62 | - Added the Ajaxy.htmlCompat function which will convert a html document into a jQuery compatible document. 63 | This is based on old functionality and includes fixes. 64 | The Response.data returned on normal html ajaxy links is now as follows: 65 | { 66 | "controller": controller, 67 | "responseText": responseText, /* raw result */ 68 | "html": html, /* raw result put through Ajaxy.htmlCompat */ 69 | "title": title, /* the value of the title element, or #ajaxy-title */ 70 | "head": head, /* the value of the head element, or #ajaxy-head */ 71 | "body": body, /* the value of the body element, or #ajaxy-body */ 72 | "content": content /* the value of the body element, or #ajaxy-body, or the html */ 73 | } 74 | - It is a backwards compatible release 75 | - Changed the demo to always use the unminified version, and included the minified version in a HTML comment 76 | - Added the HTML5 doctype and the utf8 meta element to the demo pages 77 | 78 | v1.5.1-beta, August 05, 2010 79 | - Fixed a redirection issue 80 | - Support for anchors is now complete. We can now detect all types of anchors and adjust the page and state accordingly. 81 | - Able to detect the severity of the page change, and if it is not considerable (such as only an anchor change) then do not both performing the request. 82 | - $.fn.SrollTo can now take the options argument. We also have a $.Ajaxy.options.scrollto_options for this. 83 | - Added the options [track_all_anchors] and [track_all_internal_links] to keep your Ajaxy website in sync; these are set to false by default. 84 | - A few more options added, should refer to the documentation about these. 85 | - Introduces a minor known issue that the ScrollTo plugin does no always scroll with animation. 86 | - Updated jQuery History dependencies to [v1.4.1-beta, August 05, 2010] 87 | 88 | v1.5.0-beta, August 03, 2010 89 | - Renamed format to extractHash. This change may break backwards compatibility in advanced cases. 90 | - Added support for anchors. This now requires a call to [var Action = this; this.documentReady()] once the content has updated to inform Ajaxy that it can take care of anchors now. See the updated JavaScript in the demo for more information. To do this we have included Ariel Flesler's $.fn.scrollTo with Balupton's $.fn.ScrollTo extension. 91 | - Added auto_ajaxify_documentReady option 92 | - Added auto_sparkle_documentReady option 93 | - Removed dependency on JSON2, instead we use jQuery's parseJSON 94 | - Fixed track providing 3 slashes issue 95 | - Fixed redirect issue 96 | - History requirement is now bundled into built jQuery Ajaxy script, so no need to include both anymore. This saves space as History and Ajax share some dependencies. 97 | - Updated jQuery History dependencies to [v1.4.0-beta, August 03, 2010] 98 | - This release may be a final release if no bugs are found. 99 | 100 | v1.4.0-beta, August 01, 2010 101 | - Updated licensing information. Still using the same license, as it is the best there is, but just provided some more information on it to make life simpler. 102 | - A very large redo and IS NOT backwards compatible 103 | - Added Controller.matches feature 104 | - Changed naming convention to Google's Javascript Standards for everything but options 105 | - Added #current to demo, to be similar to the jQuery History demo 106 | - Fixed SEO in the demo by using [./] on the pages instead of [/] 107 | - Added support for relative Ajaxy links 108 | - The Controller, State and Action are now separate entities. Instead of doing [this.response_data] or [this.data.response] you now do [this.State.Response.data] 109 | - All references to Hash have been renamed to State appropriately 110 | - We now support loading in complete HTML documents. Will find content and title automatically. 111 | - Updated jQuery Sparkle dependencies to [v1.4.8-beta, August 01, 2010] 112 | - Updated jQuery History dependencies to [v1.3.0-beta, August 01, 2010] 113 | - Quite close to a final release 114 | 115 | v1.3.2-dev, July 28, 2010 116 | - Track now includes base_url - this is a fix for certain circumstances. 117 | 118 | v1.3.1-dev, July 22, 2010 119 | - Updated demo to go into great detail 120 | 121 | v1.3.0-dev, July 22, 2010 122 | - Added demo 123 | - Added [redirect, relative_as_base, no_history_class, no_history_class, support_text] options 124 | - Added support for text responses 125 | - Added support for default controllers 126 | - Fixed an issue where request would fire twice for ajaxified controllers 127 | - Cleaned and now uses sparkle dependencies with makefile 128 | 129 | v1.2.0-beta, August 3, 2009 130 | - Moved base/root/relative url functionality inside 131 | - Fixed issue with A elements continuing link 132 | - Improvements to form submission 133 | - Debug improvements 134 | 135 | v1.1.0-beta, July 25, 2009 136 | - Added support for hash callbacks 137 | 138 | v1.0.1-final, July 11, 2009 139 | - Restructured a little bit 140 | - Documented 141 | - Added get and set functions for misc 142 | - Added support for Ajaxy error headers 143 | - Cleaned go/request 144 | 145 | v1.0.0-final, June 19, 2009 146 | - Been stable for over a year now, pushing live. 147 | 148 | v0.1.0-dev, July 24, 2008 149 | - Initial Release 150 | -------------------------------------------------------------------------------- /scripts/resources/core.string.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @depends nothing 3 | * @name core.string 4 | * @package jquery-sparkle {@link http://balupton.com/projects/jquery-sparkle} 5 | */ 6 | 7 | /** 8 | * Return a new string with any spaces trimmed the left and right of the string 9 | * @version 1.0.0 10 | * @date June 30, 2010 11 | * @package jquery-sparkle {@link http://balupton.com/projects/jquery-sparkle} 12 | * @author Benjamin "balupton" Lupton {@link http://balupton.com} 13 | * @copyright (c) 2009-2010 Benjamin Arthur Lupton {@link http://balupton.com} 14 | * @license MIT License {@link http://creativecommons.org/licenses/MIT/} 15 | */ 16 | String.prototype.trim = String.prototype.trim || function() { 17 | // Trim off any whitespace from the front and back 18 | return this.replace(/^\s+|\s+$/g, ''); 19 | }; 20 | 21 | /** 22 | * Return a new string with the value stripped from the left and right of the string 23 | * @version 1.1.1 24 | * @date July 22, 2010 25 | * @since 1.0.0, June 30, 2010 26 | * @package jquery-sparkle {@link http://balupton.com/projects/jquery-sparkle} 27 | * @author Benjamin "balupton" Lupton {@link http://balupton.com} 28 | * @copyright (c) 2009-2010 Benjamin Arthur Lupton {@link http://balupton.com} 29 | * @license MIT License {@link http://creativecommons.org/licenses/MIT/} 30 | */ 31 | String.prototype.strip = String.prototype.strip || function(value,regex){ 32 | // Strip a value from left and right, with optional regex support (defaults to false) 33 | value = String(value); 34 | var str = this; 35 | if ( value.length ) { 36 | if ( !(regex||false) ) { 37 | // We must escape value as we do not want regex support 38 | value = value.replace(/([\[\]\(\)\^\$\.\?\|\/\\])/g, '\\$1'); 39 | } 40 | str = str.replace(eval('/^'+value+'+|'+value+'+$/g'), ''); 41 | } 42 | return String(str); 43 | } 44 | 45 | /** 46 | * Return a new string with the value stripped from the left of the string 47 | * @version 1.1.1 48 | * @date July 22, 2010 49 | * @package jquery-sparkle {@link http://balupton.com/projects/jquery-sparkle} 50 | * @author Benjamin "balupton" Lupton {@link http://balupton.com} 51 | * @copyright (c) 2009-2010 Benjamin Arthur Lupton {@link http://balupton.com} 52 | * @license MIT License {@link http://creativecommons.org/licenses/MIT/} 53 | */ 54 | String.prototype.stripLeft = String.prototype.stripLeft || function(value,regex){ 55 | // Strip a value from the left, with optional regex support (defaults to false) 56 | value = String(value); 57 | var str = this; 58 | if ( value.length ) { 59 | if ( !(regex||false) ) { 60 | // We must escape value as we do not want regex support 61 | value = value.replace(/([\[\]\(\)\^\$\.\?\|\/\\])/g, '\\$1'); 62 | } 63 | str = str.replace(eval('/^'+value+'+/g'), ''); 64 | } 65 | return String(str); 66 | } 67 | 68 | /** 69 | * Return a new string with the value stripped from the right of the string 70 | * @version 1.1.1 71 | * @date July 22, 2010 72 | * @package jquery-sparkle {@link http://balupton.com/projects/jquery-sparkle} 73 | * @author Benjamin "balupton" Lupton {@link http://balupton.com} 74 | * @copyright (c) 2009-2010 Benjamin Arthur Lupton {@link http://balupton.com} 75 | * @license MIT License {@link http://creativecommons.org/licenses/MIT/} 76 | */ 77 | String.prototype.stripRight = String.prototype.stripRight || function(value,regex){ 78 | // Strip a value from the right, with optional regex support (defaults to false) 79 | value = String(value); 80 | var str = this; 81 | if ( value.length ) { 82 | if ( !(regex||false) ) { 83 | // We must escape value as we do not want regex support 84 | value = value.replace(/([\[\]\(\)\^\$\.\?\|\/\\])/g, '\\$1'); 85 | } 86 | str = str.replace(eval('/'+value+'+$/g'), ''); 87 | } 88 | return String(str); 89 | } 90 | 91 | /** 92 | * Return a int of the string 93 | * @version 1.0.0 94 | * @date June 30, 2010 95 | * @package jquery-sparkle {@link http://balupton.com/projects/jquery-sparkle} 96 | * @author Benjamin "balupton" Lupton {@link http://balupton.com} 97 | * @copyright (c) 2009-2010 Benjamin Arthur Lupton {@link http://balupton.com} 98 | * @license MIT License {@link http://creativecommons.org/licenses/MIT/} 99 | */ 100 | String.prototype.toInt = String.prototype.toInt || function(){ 101 | // Convert to a Integer 102 | return parseInt(this,10); 103 | }; 104 | 105 | /** 106 | * Return a new string of the old string wrapped with the start and end values 107 | * @version 1.0.0 108 | * @date June 30, 2010 109 | * @package jquery-sparkle {@link http://balupton.com/projects/jquery-sparkle} 110 | * @author Benjamin "balupton" Lupton {@link http://balupton.com} 111 | * @copyright (c) 2009-2010 Benjamin Arthur Lupton {@link http://balupton.com} 112 | * @license MIT License {@link http://creativecommons.org/licenses/MIT/} 113 | */ 114 | String.prototype.wrap = String.prototype.wrap || function(start,end){ 115 | // Wrap the string 116 | return start+this+end; 117 | }; 118 | 119 | /** 120 | * Return a new string of a selection of the old string wrapped with the start and end values 121 | * @version 1.0.0 122 | * @date June 30, 2010 123 | * @package jquery-sparkle {@link http://balupton.com/projects/jquery-sparkle} 124 | * @author Benjamin "balupton" Lupton {@link http://balupton.com} 125 | * @copyright (c) 2009-2010 Benjamin Arthur Lupton {@link http://balupton.com} 126 | * @license MIT License {@link http://creativecommons.org/licenses/MIT/} 127 | */ 128 | String.prototype.wrapSelection = String.prototype.wrapSelection || function(start,end,a,z){ 129 | // Wrap the selection 130 | if ( typeof a === 'undefined' || a === null ) a = this.length; 131 | if ( typeof z === 'undefined' || z === null ) z = this.length; 132 | return this.substring(0,a)+start+this.substring(a,z)+end+this.substring(z); 133 | }; 134 | 135 | /** 136 | * Return a new string of the slug of the old string 137 | * @version 1.1.0 138 | * @date July 16, 2010 139 | * @since 1.0.0, June 30, 2010 140 | * @package jquery-sparkle {@link http://balupton.com/projects/jquery-sparkle} 141 | * @author Benjamin "balupton" Lupton {@link http://balupton.com} 142 | * @copyright (c) 2009-2010 Benjamin Arthur Lupton {@link http://balupton.com} 143 | * @license MIT License {@link http://creativecommons.org/licenses/MIT/} 144 | */ 145 | String.prototype.toSlug = String.prototype.toSlug || function(){ 146 | // Convert a string to a slug 147 | return this.toLowerCase().replace(/[\s_]/g, '-').replace(/[^-a-z0-9]/g, '').replace(/--+/g, '-').replace(/^-+|-+$/g,''); 148 | } 149 | 150 | /** 151 | * Return a new JSON object of the old string. 152 | * Turns: 153 | * file.js?a=1&b.c=3.0&b.d=four&a_false_value=false&a_null_value=null 154 | * Into: 155 | * {"a":1,"b":{"c":3,"d":"four"},"a_false_value":false,"a_null_value":null} 156 | * @version 1.1.0 157 | * @date July 16, 2010 158 | * @since 1.0.0, June 30, 2010 159 | * @package jquery-sparkle {@link http://balupton.com/projects/jquery-sparkle} 160 | * @author Benjamin "balupton" Lupton {@link http://balupton.com} 161 | * @copyright (c) 2009-2010 Benjamin Arthur Lupton {@link http://balupton.com} 162 | * @license MIT License {@link http://creativecommons.org/licenses/MIT/} 163 | */ 164 | String.prototype.queryStringToJSON = String.prototype.queryStringToJSON || function ( ) 165 | { // Turns a params string or url into an array of params 166 | // Prepare 167 | var params = String(this); 168 | // Remove url if need be 169 | params = params.substring(params.indexOf('?')+1); 170 | // params = params.substring(params.indexOf('#')+1); 171 | // Change + to %20, the %20 is fixed up later with the decode 172 | params = params.replace(/\+/g, '%20'); 173 | // Do we have JSON string 174 | if ( params.substring(0,1) === '{' && params.substring(params.length-1) === '}' ) 175 | { // We have a JSON string 176 | return eval(decodeURIComponent(params)); 177 | } 178 | // We have a params string 179 | params = params.split(/\&(amp\;)?/); 180 | var json = {}; 181 | // We have params 182 | for ( var i = 0, n = params.length; i < n; ++i ) 183 | { 184 | // Adjust 185 | var param = params[i] || null; 186 | if ( param === null ) { continue; } 187 | param = param.split('='); 188 | if ( param === null ) { continue; } 189 | // ^ We now have "var=blah" into ["var","blah"] 190 | 191 | // Get 192 | var key = param[0] || null; 193 | if ( key === null ) { continue; } 194 | if ( typeof param[1] === 'undefined' ) { continue; } 195 | var value = param[1]; 196 | // ^ We now have the parts 197 | 198 | // Fix 199 | key = decodeURIComponent(key); 200 | value = decodeURIComponent(value); 201 | try { 202 | // value can be converted 203 | value = eval(value); 204 | } catch ( e ) { 205 | // value is a normal string 206 | } 207 | 208 | // Set 209 | // window.console.log({'key':key,'value':value}, split); 210 | var keys = key.split('.'); 211 | if ( keys.length === 1 ) 212 | { // Simple 213 | json[key] = value; 214 | } 215 | else 216 | { // Advanced (Recreating an object) 217 | var path = '', 218 | cmd = ''; 219 | // Ensure Path Exists 220 | $.each(keys,function(ii,key){ 221 | path += '["'+key.replace(/"/g,'\\"')+'"]'; 222 | jsonCLOSUREGLOBAL = json; // we have made this a global as closure compiler struggles with evals 223 | cmd = 'if ( typeof jsonCLOSUREGLOBAL'+path+' === "undefined" ) jsonCLOSUREGLOBAL'+path+' = {}'; 224 | eval(cmd); 225 | json = jsonCLOSUREGLOBAL; 226 | delete jsonCLOSUREGLOBAL; 227 | }); 228 | // Apply Value 229 | jsonCLOSUREGLOBAL = json; // we have made this a global as closure compiler struggles with evals 230 | valueCLOSUREGLOBAL = value; // we have made this a global as closure compiler struggles with evals 231 | cmd = 'jsonCLOSUREGLOBAL'+path+' = valueCLOSUREGLOBAL'; 232 | eval(cmd); 233 | json = jsonCLOSUREGLOBAL; 234 | delete jsonCLOSUREGLOBAL; 235 | delete valueCLOSUREGLOBAL; 236 | } 237 | // ^ We now have the parts added to your JSON object 238 | } 239 | return json; 240 | }; 241 | -------------------------------------------------------------------------------- /demo/scripts/modernizr-1.5.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Modernizr JavaScript library 1.5 3 | * http://www.modernizr.com/ 4 | * 5 | * Copyright (c) 2009-2010 Faruk Ates - http://farukat.es/ 6 | * Dual-licensed under the BSD and MIT licenses. 7 | * http://www.modernizr.com/license/ 8 | * 9 | * Featuring major contributions by 10 | * Paul Irish - http://paulirish.com 11 | */ 12 | window.Modernizr=function(i,e,I){function C(a,b){for(var c in a)if(m[a[c]]!==I&&(!b||b(a[c],D)))return true}function r(a,b){var c=a.charAt(0).toUpperCase()+a.substr(1);return!!C([a,"Webkit"+c,"Moz"+c,"O"+c,"ms"+c,"Khtml"+c],b)}function P(){j[E]=function(a){for(var b=0,c=a.length;b7)};d.historymanagement=function(){return!!(i.history&&history.pushState)};d.draganddrop=function(){return u("drag")&&u("dragstart")&&u("dragenter")&&u("dragover")&&u("dragleave")&&u("dragend")&&u("drop")};d.websockets=function(){return"WebSocket"in i};d.rgba=function(){m.cssText="background-color:rgba(150,255,150,.5)";return(""+m.backgroundColor).indexOf("rgba")!==-1};d.hsla=function(){m.cssText="background-color:hsla(120,40%,100%,.5)";return(""+ 17 | m.backgroundColor).indexOf("rgba")!==-1};d.multiplebgs=function(){m.cssText="background:url(//:),url(//:),red url(//:)";return/(url\s*\(.*?){3}/.test(m.background)};d.backgroundsize=function(){return r("backgroundSize")};d.borderimage=function(){return r("borderImage")};d.borderradius=function(){return r("borderRadius","",function(a){return(""+a).indexOf("orderRadius")!==-1})};d.boxshadow=function(){return r("boxShadow")};d.opacity=function(){var a=y.join("opacity:.5;")+"";m.cssText=a;return(""+m.opacity).indexOf("0.5")!== 18 | -1};d.cssanimations=function(){return r("animationName")};d.csscolumns=function(){return r("columnCount")};d.cssgradients=function(){var a=("background-image:"+y.join("gradient(linear,left top,right bottom,from(#9f9),to(white));background-image:")+y.join("linear-gradient(left top,#9f9, white);background-image:")).slice(0,-17);m.cssText=a;return(""+m.backgroundImage).indexOf("gradient")!==-1};d.cssreflections=function(){return r("boxReflect")};d.csstransforms=function(){return!!C(["transformProperty", 19 | "WebkitTransform","MozTransform","OTransform","msTransform"])};d.csstransforms3d=function(){var a=!!C(["perspectiveProperty","WebkitPerspective","MozPerspective","OPerspective","msPerspective"]);if(a){var b=document.createElement("style"),c=e.createElement("div");b.textContent="@media ("+y.join("transform-3d),(")+"modernizr){#modernizr{height:3px}}";e.getElementsByTagName("head")[0].appendChild(b);c.id="modernizr";s.appendChild(c);a=c.offsetHeight===3;b.parentNode.removeChild(b);c.parentNode.removeChild(c)}return a}; 20 | d.csstransitions=function(){return r("transitionProperty")};d.fontface=function(){var a;if(/*@cc_on@if(@_jscript_version>=5)!@end@*/0)a=true;else{var b=e.createElement("style"),c=e.createElement("span"),h,t=false,g=e.body,o,w;b.textContent="@font-face{font-family:testfont;src:url('data:font/ttf;base64,AAEAAAAMAIAAAwBAT1MvMliohmwAAADMAAAAVmNtYXCp5qrBAAABJAAAANhjdnQgACICiAAAAfwAAAAEZ2FzcP//AAMAAAIAAAAACGdseWYv5OZoAAACCAAAANxoZWFk69bnvwAAAuQAAAA2aGhlYQUJAt8AAAMcAAAAJGhtdHgGDgC4AAADQAAAABRsb2NhAIQAwgAAA1QAAAAMbWF4cABVANgAAANgAAAAIG5hbWUgXduAAAADgAAABPVwb3N03NkzmgAACHgAAAA4AAECBAEsAAUAAAKZAswAAACPApkCzAAAAesAMwEJAAACAAMDAAAAAAAAgAACbwAAAAoAAAAAAAAAAFBmRWQAAAAgqS8DM/8zAFwDMwDNAAAABQAAAAAAAAAAAAMAAAADAAAAHAABAAAAAABGAAMAAQAAAK4ABAAqAAAABgAEAAEAAgAuqQD//wAAAC6pAP///9ZXAwAAAAAAAAACAAAABgBoAAAAAAAvAAEAAAAAAAAAAAAAAAAAAAABAAIAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEACoAAAAGAAQAAQACAC6pAP//AAAALqkA////1lcDAAAAAAAAAAIAAAAiAogAAAAB//8AAgACACIAAAEyAqoAAwAHAC6xAQAvPLIHBADtMrEGBdw8sgMCAO0yALEDAC88sgUEAO0ysgcGAfw8sgECAO0yMxEhESczESMiARDuzMwCqv1WIgJmAAACAFUAAAIRAc0ADwAfAAATFRQWOwEyNj0BNCYrASIGARQGKwEiJj0BNDY7ATIWFX8aIvAiGhoi8CIaAZIoN/43KCg3/jcoAWD0JB4eJPQkHh7++EY2NkbVRjY2RgAAAAABAEH/+QCdAEEACQAANjQ2MzIWFAYjIkEeEA8fHw8QDxwWFhwWAAAAAQAAAAIAAIuYbWpfDzz1AAsEAAAAAADFn9IuAAAAAMWf0i797/8zA4gDMwAAAAgAAgAAAAAAAAABAAADM/8zAFwDx/3v/98DiAABAAAAAAAAAAAAAAAAAAAABQF2ACIAAAAAAVUAAAJmAFUA3QBBAAAAKgAqACoAWgBuAAEAAAAFAFAABwBUAAQAAgAAAAEAAQAAAEAALgADAAMAAAAQAMYAAQAAAAAAAACLAAAAAQAAAAAAAQAhAIsAAQAAAAAAAgAFAKwAAQAAAAAAAwBDALEAAQAAAAAABAAnAPQAAQAAAAAABQAKARsAAQAAAAAABgAmASUAAQAAAAAADgAaAUsAAwABBAkAAAEWAWUAAwABBAkAAQBCAnsAAwABBAkAAgAKAr0AAwABBAkAAwCGAscAAwABBAkABABOA00AAwABBAkABQAUA5sAAwABBAkABgBMA68AAwABBAkADgA0A/tDb3B5cmlnaHQgMjAwOSBieSBEYW5pZWwgSm9obnNvbi4gIFJlbGVhc2VkIHVuZGVyIHRoZSB0ZXJtcyBvZiB0aGUgT3BlbiBGb250IExpY2Vuc2UuIEtheWFoIExpIGdseXBocyBhcmUgcmVsZWFzZWQgdW5kZXIgdGhlIEdQTCB2ZXJzaW9uIDMuYmFlYzJhOTJiZmZlNTAzMiAtIHN1YnNldCBvZiBKdXJhTGlnaHRiYWVjMmE5MmJmZmU1MDMyIC0gc3Vic2V0IG9mIEZvbnRGb3JnZSAyLjAgOiBKdXJhIExpZ2h0IDogMjMtMS0yMDA5YmFlYzJhOTJiZmZlNTAzMiAtIHN1YnNldCBvZiBKdXJhIExpZ2h0VmVyc2lvbiAyIGJhZWMyYTkyYmZmZTUwMzIgLSBzdWJzZXQgb2YgSnVyYUxpZ2h0aHR0cDovL3NjcmlwdHMuc2lsLm9yZy9PRkwAQwBvAHAAeQByAGkAZwBoAHQAIAAyADAAMAA5ACAAYgB5ACAARABhAG4AaQBlAGwAIABKAG8AaABuAHMAbwBuAC4AIAAgAFIAZQBsAGUAYQBzAGUAZAAgAHUAbgBkAGUAcgAgAHQAaABlACAAdABlAHIAbQBzACAAbwBmACAAdABoAGUAIABPAHAAZQBuACAARgBvAG4AdAAgAEwAaQBjAGUAbgBzAGUALgAgAEsAYQB5AGEAaAAgAEwAaQAgAGcAbAB5AHAAaABzACAAYQByAGUAIAByAGUAbABlAGEAcwBlAGQAIAB1AG4AZABlAHIAIAB0AGgAZQAgAEcAUABMACAAdgBlAHIAcwBpAG8AbgAgADMALgBiAGEAZQBjADIAYQA5ADIAYgBmAGYAZQA1ADAAMwAyACAALQAgAHMAdQBiAHMAZQB0ACAAbwBmACAASgB1AHIAYQBMAGkAZwBoAHQAYgBhAGUAYwAyAGEAOQAyAGIAZgBmAGUANQAwADMAMgAgAC0AIABzAHUAYgBzAGUAdAAgAG8AZgAgAEYAbwBuAHQARgBvAHIAZwBlACAAMgAuADAAIAA6ACAASgB1AHIAYQAgAEwAaQBnAGgAdAAgADoAIAAyADMALQAxAC0AMgAwADAAOQBiAGEAZQBjADIAYQA5ADIAYgBmAGYAZQA1ADAAMwAyACAALQAgAHMAdQBiAHMAZQB0ACAAbwBmACAASgB1AHIAYQAgAEwAaQBnAGgAdABWAGUAcgBzAGkAbwBuACAAMgAgAGIAYQBlAGMAMgBhADkAMgBiAGYAZgBlADUAMAAzADIAIAAtACAAcwB1AGIAcwBlAHQAIABvAGYAIABKAHUAcgBhAEwAaQBnAGgAdABoAHQAdABwADoALwAvAHMAYwByAGkAcAB0AHMALgBzAGkAbAAuAG8AcgBnAC8ATwBGAEwAAAAAAgAAAAAAAP+BADMAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAQACAQIAEQt6ZXJva2F5YWhsaQ==')}"; 21 | e.getElementsByTagName("head")[0].appendChild(b);c.setAttribute("style","font:99px _,arial,helvetica;position:absolute;visibility:hidden");if(!g){g=s.appendChild(e.createElement("fontface"));t=true}c.innerHTML="........";c.id="fonttest";g.appendChild(c);h=c.offsetWidth*c.offsetHeight;c.style.font="99px testfont,_,arial,helvetica";a=h!==c.offsetWidth*c.offsetHeight;var v=function(){if(g.parentNode){a=j.fontface=h!==c.offsetWidth*c.offsetHeight;s.className=s.className.replace(/(no-)?fontface\b/,"")+ 22 | (a?" ":" no-")+"fontface"}};setTimeout(v,75);setTimeout(v,150);addEventListener("load",function(){v();(w=true)&&o&&o(a);setTimeout(function(){t||(g=c);g.parentNode.removeChild(g);b.parentNode.removeChild(b)},50)},false)}j._fontfaceready=function(p){w||a?p(a):(o=p)};return a||h!==c.offsetWidth};d.video=function(){var a=e.createElement("video"),b=!!a.canPlayType;if(b){b=new Boolean(b);b.ogg=a.canPlayType('video/ogg; codecs="theora"');b.h264=a.canPlayType('video/mp4; codecs="avc1.42E01E"');b.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"')}return b}; 23 | d.audio=function(){var a=e.createElement("audio"),b=!!a.canPlayType;if(b){b=new Boolean(b);b.ogg=a.canPlayType('audio/ogg; codecs="vorbis"');b.mp3=a.canPlayType("audio/mpeg;");b.wav=a.canPlayType('audio/wav; codecs="1"');b.m4a=a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")}return b};d.localStorage=function(){return"localStorage"in i&&i.localStorage!==null};d.sessionStorage=function(){try{return"sessionStorage"in i&&i.sessionStorage!==null}catch(a){return false}};d.webworkers=function(){return!!i.Worker}; 24 | d.applicationCache=function(){var a=i.applicationCache;return!!(a&&typeof a.status!="undefined"&&typeof a.update=="function"&&typeof a.swapCache=="function")};d.svg=function(){return!!e.createElementNS&&!!e.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect};d.smil=function(){return!!e.createElementNS&&/SVG/.test(M.call(e.createElementNS("http://www.w3.org/2000/svg","animate")))};d.svgclippaths=function(){return!!e.createElementNS&&/SVG/.test(M.call(e.createElementNS("http://www.w3.org/2000/svg", 25 | "clipPath")))};for(var z in d)if(O(d,z))N.push(((j[z.toLowerCase()]=d[z]())?"":"no-")+z.toLowerCase());j[E]||P();j.addTest=function(a,b){a=a.toLowerCase();if(!j[a]){b=!!b();s.className+=" "+(b?"":"no-")+a;j[a]=b;return j}};m.cssText="";D=n=null;(function(){var a=e.createElement("div");a.innerHTML="";return a.childNodes.length!==1})()&&function(a,b){function c(f,k){if(o[f])o[f].styleSheet.cssText+=k;else{var l=t[G],q=b[A]("style");q.media=f;l.insertBefore(q,l[G]);o[f]=q;c(f,k)}}function h(f, 26 | k){for(var l=new RegExp("\\b("+w+")\\b(?!.*[;}])","gi"),q=function(B){return".iepp_"+B},x=-1;++x\\s*$","i");g.innerHTML=f.outerHTML.replace(/\r|\n/g," ").replace(l,f.currentStyle.display=="block"?"":"");l=g.childNodes[0];l.className+=" iepp_"+q;l=p[p.length]=[f,l];f.parentNode.replaceChild(l[1],l[0])}h(b.styleSheets,"all")});a.attachEvent("onafterprint", 28 | function(){for(var f=-1,k;++f= MSIE 8 318 | if ( (browser.msie||false) && browserVersionInt >= 8 ) { 319 | nativeSupport = true; 320 | } 321 | // >= Webkit 528 322 | else if ( (browser.webkit||false) && browserVersionInt >= 528 ) { 323 | nativeSupport = true; 324 | } 325 | // >= Gecko 1.9.2.x 326 | else if ( (browser.mozilla||false) ) { 327 | // > Gecko 1 328 | if ( browserVersionPartsOne > 1 ) { 329 | nativeSupport = true; 330 | } 331 | // = Gecko 1 332 | else if ( browserVersionPartsOne === 1 ) { 333 | // > Gecko 1.9 334 | if ( browserVersionPartsTwo > 9 ) { 335 | nativeSupport = true; 336 | } 337 | // = Gecko 1.9 338 | else if ( browserVersionPartsTwo === 9 ) { 339 | // >= Gecko 1.9.2 340 | if ( browserVersionPartsThree >= 2 ) { 341 | nativeSupport = true; 342 | } 343 | } 344 | } 345 | } 346 | // >= Opera 10.60 347 | else if ( (browser.opera||false) ) { 348 | // > Opera 10 349 | if ( browserVersionPartsOne > 10 ) { 350 | nativeSupport = true; 351 | } 352 | // = Opera 10 353 | else if ( browserVersionPartsOne === 10 ) { 354 | // >= Opera 10.60 355 | if ( browserVersionPartsTwo >= 60 ) { 356 | nativeSupport = true; 357 | } 358 | } 359 | } 360 | 361 | // Return nativeSupport 362 | return nativeSupport; 363 | }, 364 | 365 | /** 366 | * Enable hashchange for all browsers 367 | * For browsers which do not have native support, the support must be emulated. 368 | */ 369 | hashchangeLoader: function () { 370 | var History = $.History; 371 | 372 | // Fetch nativeSupport 373 | var nativeSupport = History.nativeSupport(); 374 | 375 | // Check whether or not we need to implement a unfortunate but required workaround for browsers without nativeSupport 376 | if ( !nativeSupport ) { 377 | // We are not IE8, or another browser which supports onhashchange natively 378 | 379 | // State our checker function, it is used to constantly check the location to detect a change 380 | var checker; 381 | 382 | // Handle depending on the browser 383 | if ( $.browser.msie ) { 384 | // We are still IE 385 | // IE6, IE7, etc 386 | 387 | // Append and $iframe to the document, as $iframes are required for back and forward 388 | // Create a hidden $iframe for hash change tracking 389 | History.$iframe = $('