Skip to content
Browse files

MooTools is now supported.

  • Loading branch information...
1 parent a667824 commit 8f6dc2a79a557cad5b429c95695186e0d8cf20c5 @balupton committed Jan 21, 2011
Showing with 124 additions and 3 deletions.
  1. +1 −1 README.md
  2. +2 −2 demo/index.php
  3. +121 −0 scripts/uncompressed/history.adapter.mootools.js
View
2 README.md
@@ -42,11 +42,11 @@ Licensed under the New BSD License, Copyright 2011 Benjamin Arthur Lupton
- jQuery
- Prototype
+- MooTools
### Unsupported
- Dojo
-- MooTools
## Browsers
View
4 demo/index.php
@@ -24,9 +24,9 @@
<body>
<script type="text/javascript" src="scripts/jquery.js"></script>
<script type="text/javascript">jQuery.noConflict()</script>
- <script type="text/javascript" src="scripts/prototype.js"></script>
+ <script type="text/javascript" src="scripts/mootools.js"></script>
<script type="text/javascript" src="../scripts/uncompressed/history.js"></script>
- <script type="text/javascript" src="../scripts/uncompressed/history.adapter.prototype.js"></script>
+ <script type="text/javascript" src="../scripts/uncompressed/history.adapter.mootools.js"></script>
<script type="text/javascript" src="scripts/demo.js"></script>
<div id="wrap">
View
121 scripts/uncompressed/history.adapter.mootools.js
@@ -0,0 +1,121 @@
+// History.js MooTools Adapter
+// New-BSD License, Copyright 2011 Benjamin Arthur Lupton <contact@balupton.com>
+
+(function(MooTools,window,undefined){
+
+ // --------------------------------------------------------------------------
+ // Initialise
+
+ // Localise Globals
+ var
+ History = window.History||{},
+ history = window.history;
+
+ // Check Existence of Adapter
+ if ( typeof History.Adapter !== 'undefined' ) {
+ throw new Error('History.js Adapter has already been emulated...');
+ }
+
+ // Add the Adapter
+ History.Adapter = {
+
+ /**
+ * History.Adapter.getBrowserFlag()
+ * @return [msie,webkit,mozilla,opera]
+ */
+ getBrowserFlag: function(){
+ var
+ flags_out = ['msie','mozilla','webkit','webkit','opera'],
+ flags_in = ['ie','firefox','safari','chrome','opera'],
+ result = null;
+
+ flags_in.each(function(i,flag){
+ if ( Browser[flag]||false ) {
+ result = flags_out[i];
+ return false;
+ }
+ });
+
+ return result;
+ },
+
+ /**
+ * History.Adapter.getBrowserMajorVersion()
+ * @return integer
+ */
+ getBrowserMajorVersion: function(){
+ var version = null;
+ switch ( true ) {
+ case Browser.ie6:
+ version = 6;
+ break;
+ case Browser.ie7:
+ version = 7;
+ break;
+ case Browser.ie8:
+ version = 8;
+ break;
+ case Browser.ie:
+ version = 9;
+ break;
+ case Browser.firefox2:
+ version = 2;
+ break;
+ case Browser.firefox3:
+ version = 3;
+ break;
+ case Browser.firefox:
+ version = 4;
+ break;
+ case Browser.safari3:
+ version = 3;
+ break;
+ case Browser.safari4:
+ version = 4;
+ break;
+ case Browser.safari:
+ version = 5;
+ break;
+ case Browser.chrome:
+ version = 8;
+ break;
+ case Browser.opera:
+ version = 10;
+ break
+ }
+
+ return version;
+ },
+
+ /**
+ * History.Adapter.bind(el,event,callback)
+ * @param element
+ * @param string event
+ * @param function callback
+ * @return element
+ */
+ bind: function(el,event,callback){
+ var El = typeof el === 'string' ? document.id(el) : el;
+ return El.addEvent(event,callback);
+ },
+
+ /**
+ * History.Adapter.trigger(el,event,data)
+ * @param element
+ * @param string event
+ * @param object data
+ * @return element
+ */
+ trigger: function(el,event,data){
+ var El = typeof el === 'string' ? document.id(el) : el;
+ return El.fireEvent(event,data||{});
+ }
+ };
+
+ // Check Load Status
+ if ( typeof History.init !== 'undefined' ) {
+ // History.js loaded faster than the Adapter, Fire init
+ History.init();
+ }
+
+})(MooTools,window);

0 comments on commit 8f6dc2a

Please sign in to comment.
Something went wrong with that request. Please try again.