의 미러
				http://git.whoc.org.uk/git/password-manager.git
				synced 2025-10-31 11:27:34 +01:00 
			
		
		
		
	Added JQTouch and Zepto libraries
JQTouch and Zepto are tentatively used for the mobile version of Clipperz. No final commitment has been made, though.
This commit is contained in:
		
							
								
								
									
										159
									
								
								frontend/gamma/js/JQTouch/extensions/jqt.actionsheet.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										159
									
								
								frontend/gamma/js/JQTouch/extensions/jqt.actionsheet.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,159 @@ | ||||
| /* | ||||
|  | ||||
|             _/    _/_/    _/_/_/_/_/                              _/ | ||||
|                _/    _/      _/      _/_/    _/    _/    _/_/_/  _/_/_/ | ||||
|           _/  _/  _/_/      _/    _/    _/  _/    _/  _/        _/    _/ | ||||
|          _/  _/    _/      _/    _/    _/  _/    _/  _/        _/    _/ | ||||
|         _/    _/_/  _/    _/      _/_/      _/_/_/    _/_/_/  _/    _/ | ||||
|        _/ | ||||
|     _/ | ||||
|  | ||||
|     Documentation and issue tracking on Google Code <http://code.google.com/p/jqtouch/> | ||||
|  | ||||
|     (c) 2012 by jQTouch project members. | ||||
|     See LICENSE.txt for license. | ||||
|  | ||||
|     Author: Thomas Yip | ||||
| */ | ||||
|  | ||||
| /* | ||||
|  | ||||
|             _/    _/_/    _/_/_/_/_/                              _/ | ||||
|                _/    _/      _/      _/_/    _/    _/    _/_/_/  _/_/_/ | ||||
|           _/  _/  _/_/      _/    _/    _/  _/    _/  _/        _/    _/ | ||||
|          _/  _/    _/      _/    _/    _/  _/    _/  _/        _/    _/ | ||||
|         _/    _/_/  _/    _/      _/_/      _/_/_/    _/_/_/  _/    _/ | ||||
|        _/ | ||||
|     _/ | ||||
|  | ||||
|     Documentation and issue tracking on Google Code <http://code.google.com/p/jqtouch/> | ||||
|  | ||||
|     (c) 2012 by jQTouch project members. | ||||
|     See LICENSE.txt for license. | ||||
|  | ||||
|     Author: Thomas Yip | ||||
| */ | ||||
|  | ||||
| (function($) { | ||||
|     var src = $("head script").last().attr("src") || ''; | ||||
|     var scriptpath = src.split('?')[0].split('/').slice(0, -1).join('/')+'/'; | ||||
|     var csspath = scriptpath + 'jqt.actionsheet.css'; | ||||
|     var link = $('<link href="' + csspath + '" rel="stylesheet">'); | ||||
|     $('head').append($(link)); | ||||
|  | ||||
|     function hide(callback) { | ||||
|         var $target = $(this); | ||||
|         var data = $(this).data('actionsheet'); | ||||
|         var $source = data.source; | ||||
|  | ||||
|         var timeout; | ||||
|  | ||||
|         function cleanup() { | ||||
|           clearTimeout(timeout); | ||||
|  | ||||
|           $source.removeClass('transition'); | ||||
|           $target.removeClass('inmotion transition'); | ||||
|           !callback || callback.apply(this, arguments); | ||||
|         }; | ||||
|         timeout = setTimeout(cleanup, 500); | ||||
|  | ||||
|         if (data.shown) { | ||||
|             $(this).data('actionsheet', {}); | ||||
|             $target.one('webkitTransitionEnd', cleanup); | ||||
|      | ||||
|             $source.addClass('transition'); | ||||
|             $target.removeClass('current').addClass('inmotion transition'); | ||||
|             $('#jqt').removeClass('actionopened'); | ||||
|         } | ||||
|         return $target; | ||||
|     } | ||||
|        | ||||
|     function show(callback) { | ||||
|         var $target = $(this); | ||||
|         var data = $(this).data('actionsheet') || {}; | ||||
|         if (!data.shown) { | ||||
|             var $source = $('#jqt .current:not(.actionsheet)'); | ||||
|      | ||||
|             $target.one('webkitTransitionEnd', function() { | ||||
|                 $source.removeClass('transition'); | ||||
|                 $target.removeClass('inmotion transition'); | ||||
|                 !callback || callback.apply(this, arguments); | ||||
|             }); | ||||
|      | ||||
|             data.shown = true; | ||||
|             data.source = $source; | ||||
|             $(this).data('actionsheet', data); | ||||
|  | ||||
|             $source.addClass('transition'); | ||||
|             $target.addClass('inmotion transition'); | ||||
|             $('#jqt').addClass('actionopened'); | ||||
|             setTimeout(function() { | ||||
|                 $target.addClass('current'); | ||||
|             }, 50); | ||||
|         } | ||||
|         return $target; | ||||
|     } | ||||
|      | ||||
|     var methods = { | ||||
|         init: function(options) { | ||||
|             $(this).addClass('actionsheet'); | ||||
|             $(this).data({shown: false}); | ||||
|         }, | ||||
|         show: show, | ||||
|         hide: hide | ||||
|     }; | ||||
|      | ||||
|     $.fn.actionsheet = function(method) { | ||||
|       if (methods[method]) { | ||||
|           if ($(this).is('.actionsheet')) { | ||||
|               return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); | ||||
|           } else { | ||||
|               var msg = 'Target is not a `actionsheet`. Action `' + method + '` is ignored.'; | ||||
|               console.warn(msg); | ||||
|           } | ||||
|       } else if ( typeof method === 'object' || ! method ) { | ||||
|           return methods.init.apply(this, arguments); | ||||
|       } else { | ||||
|           $.error( 'Method ' +  method + ' does not exist on jQuery.tooltip' ); | ||||
|       }         | ||||
|     }; | ||||
|  | ||||
|     if ($.jQTouch) { | ||||
|         $.jQTouch.addTapHandler({ | ||||
|             name: 'open-actionsheet', | ||||
|             isSupported: function(e, params) { | ||||
|                 return params.$el.is('.action'); | ||||
|             }, | ||||
|             fn: function(e, params) { | ||||
|                 params.$el.removeClass('active'); | ||||
|  | ||||
|                 var $target = $(params.hash); | ||||
|                 $target.actionsheet('show'); | ||||
|  | ||||
|                 return false; | ||||
|             } | ||||
|         }); | ||||
|         $.jQTouch.addTapHandler({ | ||||
|             name: 'follow-actionlink', | ||||
|             isSupported: function(e, params) { | ||||
|                 if ($('#jqt').hasClass('actionopened')) { | ||||
|                     return params.$el.is('.actionsheet a'); | ||||
|                 } | ||||
|                 return false; | ||||
|             }, | ||||
|             fn: function(e, params) { | ||||
|                 params.$el.removeClass('active'); | ||||
|  | ||||
|                 var $target = params.$el.closest('.actionsheet'); | ||||
|                 $target.actionsheet('hide', function() { | ||||
|                     if (!params.$el.is('.dismiss')) { | ||||
|                       params.$el.trigger('tap'); | ||||
|                     } | ||||
|                 }); | ||||
|                 return false; | ||||
|             } | ||||
|         }); | ||||
|     } else { | ||||
|         console.error('Extension `jqt.actionsheet` failed to load. jQT not found'); | ||||
|     } | ||||
| })($); | ||||
							
								
								
									
										52
									
								
								frontend/gamma/js/JQTouch/extensions/jqt.autotitles.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								frontend/gamma/js/JQTouch/extensions/jqt.autotitles.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,52 @@ | ||||
| /* | ||||
|  | ||||
|             _/    _/_/    _/_/_/_/_/                              _/ | ||||
|                _/    _/      _/      _/_/    _/    _/    _/_/_/  _/_/_/ | ||||
|           _/  _/  _/_/      _/    _/    _/  _/    _/  _/        _/    _/ | ||||
|          _/  _/    _/      _/    _/    _/  _/    _/  _/        _/    _/ | ||||
|         _/    _/_/  _/    _/      _/_/      _/_/_/    _/_/_/  _/    _/ | ||||
|        _/ | ||||
|     _/ | ||||
|  | ||||
|     Created by David Kaneda <http://www.davidkaneda.com> | ||||
|     Maintained by Thomas Yip <http://beedesk.com/> | ||||
|     Sponsored by Sencha Labs <http://www.sencha.com/> | ||||
|     Special thanks to Jonathan Stark <http://www.jonathanstark.com/> | ||||
|  | ||||
|     Documentation and issue tracking on GitHub <http://github.com/senchalabs/jQTouch/> | ||||
|  | ||||
|     (c) 2009-2011 Sencha Labs | ||||
|     jQTouch may be freely distributed under the MIT license. | ||||
|  | ||||
| */ | ||||
|  | ||||
| (function($) { | ||||
|     if ($.jQTouch) | ||||
|     { | ||||
|         $.jQTouch.addExtension(function AutoTitles(jQT){ | ||||
|              | ||||
|             var titleSelector='.toolbar h1'; | ||||
|  | ||||
|             $(function(){ | ||||
|                 $('#jqt').bind('pageAnimationStart', function(e, data){ | ||||
|                     if (data.direction === 'in'){ | ||||
|                         var $title = $(titleSelector, $(e.target)); | ||||
|                         var $ref = $(e.target).data('referrer'); | ||||
|                         if ($title.length && $ref && $title.text() === ''){ | ||||
|                             $title.html($ref.text()); | ||||
|                         } | ||||
|                     } | ||||
|                 }); | ||||
|             }); | ||||
|              | ||||
|             function setTitleSelector(ts){ | ||||
|                 titleSelector=ts; | ||||
|             } | ||||
|              | ||||
|             return { | ||||
|                 setTitleSelector: setTitleSelector | ||||
|             }; | ||||
|  | ||||
|         }); | ||||
|     } | ||||
| })($); | ||||
							
								
								
									
										96
									
								
								frontend/gamma/js/JQTouch/extensions/jqt.floaty.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										96
									
								
								frontend/gamma/js/JQTouch/extensions/jqt.floaty.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,96 @@ | ||||
| /* | ||||
|  | ||||
|             _/    _/_/    _/_/_/_/_/                              _/        | ||||
|                _/    _/      _/      _/_/    _/    _/    _/_/_/  _/_/_/     | ||||
|           _/  _/  _/_/      _/    _/    _/  _/    _/  _/        _/    _/    | ||||
|          _/  _/    _/      _/    _/    _/  _/    _/  _/        _/    _/     | ||||
|         _/    _/_/  _/    _/      _/_/      _/_/_/    _/_/_/  _/    _/      | ||||
|        _/                                                                   | ||||
|     _/ | ||||
|  | ||||
|     Created by David Kaneda <http://www.davidkaneda.com> | ||||
|     Documentation and issue tracking on Google Code <http://code.google.com/p/jqtouch/> | ||||
|      | ||||
|     Special thanks to Jonathan Stark <http://jonathanstark.com/> | ||||
|     and pinch/zoom <http://www.pinchzoom.com/> | ||||
|      | ||||
|     (c) 2009 by jQTouch project members. | ||||
|     See LICENSE.txt for license. | ||||
|  | ||||
| */ | ||||
|  | ||||
| (function($) { | ||||
|     if ($.jQTouch) | ||||
|     { | ||||
|         $.jQTouch.addExtension(function Floaty(jQT){ | ||||
|              | ||||
|             $.fn.makeFloaty = function(options){ | ||||
|                 var defaults = { | ||||
|                     align: 'top', | ||||
|                     spacing: 20, | ||||
|                     time: '.3s' | ||||
|                 }; | ||||
|  | ||||
|                 var settings = $.extend({}, defaults, options); | ||||
|  | ||||
|                 settings.align = (settings.align == 'top') ? 'top' : 'bottom'; | ||||
|                  | ||||
|                 return this.each(function(){ | ||||
|                     var $el = $(this); | ||||
|                      | ||||
|                     $el.css({ | ||||
|                         '-webkit-transition': 'top ' + settings.time + ' ease-in-out', | ||||
|                         'display': 'block', | ||||
|                         'min-height': '0 !important' | ||||
|                     }).data('settings', settings); | ||||
|  | ||||
|                     $(document).scroll(function(){ | ||||
|                         if ($el.data('floatyVisible') === 'true') | ||||
|                         { | ||||
|                             $el.scrollFloaty(); | ||||
|                         } | ||||
|                     }); | ||||
|                     $el.scrollFloaty(); | ||||
|                 }); | ||||
|             }; | ||||
|  | ||||
|             $.fn.scrollFloaty = function(){ | ||||
|  | ||||
|  | ||||
|                 return this.each(function(){ | ||||
|                     var $el = $(this); | ||||
|                     var settings = $el.data('settings'); // Settings not being set as object w/Zepto | ||||
|                     var wHeight = $('html').attr('clientHeight'); // WRONG | ||||
|  | ||||
|                     var newY = window.pageYOffset + | ||||
|                         ((settings.align == 'top') ?  | ||||
|                             settings.spacing : wHeight - settings.spacing - $el.get(0).offsetHeight); | ||||
|  | ||||
|                     $el.css('top', newY).data('floatyVisible', true); | ||||
|                 }); | ||||
|             }; | ||||
|  | ||||
|             $.fn.hideFloaty = function(){ | ||||
|                 return this.each(function(){ | ||||
|                     var $el = $(this); | ||||
|                     var oh = $el.get(0).offsetHeight; | ||||
|                      | ||||
|                     $el.css('top', -oh-10).data('floatyVisible', false); | ||||
|                 }); | ||||
|             }; | ||||
|              | ||||
|             $.fn.toggleFloaty = function(){ | ||||
|                 return this.each(function(){ | ||||
|                     var $el = $(this); | ||||
|                     if ($el.data('floatyVisible') === 'true'){ | ||||
|                         $el.hideFloaty(); | ||||
|                     } | ||||
|                     else | ||||
|                     { | ||||
|                         $el.scrollFloaty(); | ||||
|                     } | ||||
|                 }); | ||||
|             }; | ||||
|         }); | ||||
|     } | ||||
| })($); | ||||
							
								
								
									
										51
									
								
								frontend/gamma/js/JQTouch/extensions/jqt.location.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								frontend/gamma/js/JQTouch/extensions/jqt.location.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,51 @@ | ||||
| (function($) { | ||||
|     if ($.jQTouch) | ||||
|     { | ||||
|         $.jQTouch.addExtension(function Location(){ | ||||
|              | ||||
|             var latitude, longitude, callback, callback2; | ||||
|              | ||||
|             function updateLocation(fn, fn2) { | ||||
|                 if (navigator.geolocation) | ||||
|                 { | ||||
|                     callback = fn; | ||||
|                     callback2 = fn2; | ||||
|                     navigator.geolocation.getCurrentPosition(savePosition, failResponse); | ||||
|                     return true; | ||||
|                 } else { | ||||
|                     console.log('Device not capable of geo-location.'); | ||||
|                     fn(false); | ||||
|                     return false; | ||||
|                 } | ||||
|             } | ||||
|             function failResponse(error){ | ||||
|                 if (callback2) { | ||||
|                     callback2(error); | ||||
|                 } | ||||
|             } | ||||
|             function savePosition(position) { | ||||
|                 latitude = position.coords.latitude; | ||||
|                 longitude = position.coords.longitude; | ||||
|                 if (callback) { | ||||
|                     callback(getLocation()); | ||||
|                 } | ||||
|             } | ||||
|             function getLocation() { | ||||
|                 if (latitude && longitude) { | ||||
|                     return { | ||||
|                         latitude: latitude, | ||||
|                         longitude: longitude | ||||
|                     }; | ||||
|                      | ||||
|                 } else { | ||||
|                     console.log('No location available. Try calling updateLocation() first.'); | ||||
|                     return false; | ||||
|                 } | ||||
|             } | ||||
|             return { | ||||
|                 updateLocation: updateLocation, | ||||
|                 getLocation: getLocation | ||||
|             }; | ||||
|         }); | ||||
|     } | ||||
| })($); | ||||
							
								
								
									
										137
									
								
								frontend/gamma/js/JQTouch/extensions/jqt.menusheet.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										137
									
								
								frontend/gamma/js/JQTouch/extensions/jqt.menusheet.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,137 @@ | ||||
| /* | ||||
|  | ||||
|             _/    _/_/    _/_/_/_/_/                              _/ | ||||
|                _/    _/      _/      _/_/    _/    _/    _/_/_/  _/_/_/ | ||||
|           _/  _/  _/_/      _/    _/    _/  _/    _/  _/        _/    _/ | ||||
|          _/  _/    _/      _/    _/    _/  _/    _/  _/        _/    _/ | ||||
|         _/    _/_/  _/    _/      _/_/      _/_/_/    _/_/_/  _/    _/ | ||||
|        _/ | ||||
|     _/ | ||||
|  | ||||
|     Documentation and issue tracking on Google Code <http://code.google.com/p/jqtouch/> | ||||
|  | ||||
|     (c) 2012 by jQTouch project members. | ||||
|     See LICENSE.txt for license. | ||||
|  | ||||
|     Author: Thomas Yip | ||||
| */ | ||||
|  | ||||
| (function($) { | ||||
|     var src = $("head script").last().attr("src") || ''; | ||||
|     var scriptpath = src.split('?')[0].split('/').slice(0, -1).join('/')+'/'; | ||||
|     var csspath = scriptpath + 'jqt.menusheet.css'; | ||||
|     var link = $('<link href="' + csspath + '" rel="stylesheet">'); | ||||
|     $('head').append($(link)); | ||||
|  | ||||
|     function hide(callback) { | ||||
|         var $target = $(this); | ||||
|         var data = $(this).data('menusheet'); | ||||
|         if (data.shown) { | ||||
|             $(this).data('menusheet', {}); | ||||
|             var $source = data.source; | ||||
|             $source.unbind('touchstart mousedown', data.closehandler); | ||||
|             $source.one('webkitTransitionEnd', function() { | ||||
|                 $source.removeClass('inmotion transition in'); | ||||
|                 $target.removeClass('inmotion out'); | ||||
|                 !callback || callback.apply(this, arguments); | ||||
|             }); | ||||
|      | ||||
|             $source.addClass('inmotion transition in'); | ||||
|             $target.addClass('inmotion out').removeClass('current'); | ||||
|             $('#jqt').removeClass('menuopened'); | ||||
|         } | ||||
|         return $target; | ||||
|     } | ||||
|        | ||||
|     function show(callback) { | ||||
|         var $target = $(this); | ||||
|         var data = $(this).data('menusheet') || {}; | ||||
|         if (!data.shown) { | ||||
|             var $source = $('#jqt .current:not(.menusheet)'); | ||||
|             var closehandler = function() { | ||||
|                 $target.menusheet('hide'); | ||||
|                 return false; | ||||
|             }; | ||||
|      | ||||
|             $source.one('webkitTransitionEnd', function() { | ||||
|                 $source.one('touchstart mousedown', closehandler); | ||||
|                 $source.removeClass('inmotion transition out'); | ||||
|                 $target.removeClass('inmotion in'); | ||||
|                 !callback || callback.apply(this, arguments); | ||||
|             }); | ||||
|      | ||||
|             data.shown = true; | ||||
|             data.closehandler = closehandler; | ||||
|             data.source = $source; | ||||
|             $(this).data('menusheet', data); | ||||
|      | ||||
|             $source.addClass('inmotion transition out'); | ||||
|             $target.addClass('current in'); | ||||
|             $('#jqt').addClass('menuopened'); | ||||
|         } | ||||
|         return $target; | ||||
|     } | ||||
|      | ||||
|     var methods = { | ||||
|         init: function(options) { | ||||
|             $(this).addClass('menusheet'); | ||||
|             $(this).data({shown: false}); | ||||
|         }, | ||||
|         show: show, | ||||
|         hide: hide | ||||
|     }; | ||||
|      | ||||
|     $.fn.menusheet = function(method) { | ||||
|       if (methods[method]) { | ||||
|           if ($(this).is('.menusheet')) { | ||||
|               return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); | ||||
|           } else { | ||||
|               var msg = 'Target is not a `menusheet`. Action `' + method + '` is ignored.'; | ||||
|               console.warn(msg); | ||||
|           } | ||||
|       } else if ( typeof method === 'object' || ! method ) { | ||||
|           return methods.init.apply(this, arguments); | ||||
|       } else { | ||||
|           $.error( 'Method ' +  method + ' does not exist on jQuery.tooltip' ); | ||||
|       }         | ||||
|     }; | ||||
|  | ||||
|     if ($.jQTouch) { | ||||
|         $.jQTouch.addTapHandler({ | ||||
|             name: 'open-menusheet', | ||||
|             isSupported: function(e, params) { | ||||
|                 return params.$el.is('.menu'); | ||||
|             }, | ||||
|             fn: function(e, params) { | ||||
|                 params.$el.removeClass('active'); | ||||
|  | ||||
|                 var $target = $(params.hash); | ||||
|                 $target.menusheet('show'); | ||||
|  | ||||
|                 return false; | ||||
|             } | ||||
|         }); | ||||
|         $.jQTouch.addTapHandler({ | ||||
|             name: 'follow-menulink', | ||||
|             isSupported: function(e, params) { | ||||
|                 if ($('#jqt').hasClass('menuopened')) { | ||||
|                     return params.$el.is('.menusheet a'); | ||||
|                 } | ||||
|                 return false; | ||||
|             }, | ||||
|             fn: function(e, params) { | ||||
|                 params.$el.removeClass('active'); | ||||
|  | ||||
|                 var $target = params.$el.closest('.menusheet'); | ||||
|                 $target.menusheet('hide', function() { | ||||
|                     if (!params.$el.is('.dismiss')) { | ||||
|                       params.$el.trigger('tap'); | ||||
|                     } | ||||
|                 }); | ||||
|                 return false; | ||||
|             } | ||||
|         }); | ||||
|     } else { | ||||
|         console.error('Extension `jqt.menusheet` failed to load. jQT not found'); | ||||
|     } | ||||
| })($); | ||||
							
								
								
									
										97
									
								
								frontend/gamma/js/JQTouch/extensions/jqt.offline.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										97
									
								
								frontend/gamma/js/JQTouch/extensions/jqt.offline.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,97 @@ | ||||
| /* | ||||
|  | ||||
|             _/    _/_/    _/_/_/_/_/                              _/        | ||||
|                _/    _/      _/      _/_/    _/    _/    _/_/_/  _/_/_/     | ||||
|           _/  _/  _/_/      _/    _/    _/  _/    _/  _/        _/    _/    | ||||
|          _/  _/    _/      _/    _/    _/  _/    _/  _/        _/    _/     | ||||
|         _/    _/_/  _/    _/      _/_/      _/_/_/    _/_/_/  _/    _/      | ||||
|        _/                                                                   | ||||
|     _/ | ||||
|  | ||||
|     Created by David Kaneda <http://www.davidkaneda.com> | ||||
|     Documentation and issue tracking on Google Code <http://code.google.com/p/jqtouch/> | ||||
|      | ||||
|     Special thanks to Jonathan Stark <http://jonathanstark.com/> | ||||
|  | ||||
|     Lots of this code is specifically derived from Jonathan's book, | ||||
|     "Building iPhone Apps with HTML, CSS, and JavaScript" | ||||
|      | ||||
|     (c) 2009 by jQTouch project members. | ||||
|     See LICENSE.txt for license. | ||||
|  | ||||
| */ | ||||
|  | ||||
| (function($) { | ||||
|     if ($.jQTouch) | ||||
|     { | ||||
|         $.jQTouch.addExtension(function Offline(){ | ||||
|              | ||||
|             // Convenience array of status values | ||||
|             var cacheStatusValues = []; | ||||
|             cacheStatusValues[0] = 'uncached'; | ||||
|             cacheStatusValues[1] = 'idle'; | ||||
|             cacheStatusValues[2] = 'checking'; | ||||
|             cacheStatusValues[3] = 'downloading'; | ||||
|             cacheStatusValues[4] = 'updateready'; | ||||
|             cacheStatusValues[5] = 'obsolete'; | ||||
|  | ||||
|             // Listeners for all possible events | ||||
|             var cache = window.applicationCache; | ||||
|             cache.addEventListener('cached', logEvent, false); | ||||
|             cache.addEventListener('checking', logEvent, false); | ||||
|             cache.addEventListener('downloading', logEvent, false); | ||||
|             cache.addEventListener('error', logEvent, false); | ||||
|             cache.addEventListener('noupdate', logEvent, false); | ||||
|             cache.addEventListener('obsolete', logEvent, false); | ||||
|             cache.addEventListener('progress', logEvent, false); | ||||
|             cache.addEventListener('updateready', logEvent, false); | ||||
|  | ||||
|             // Log every event to the console | ||||
|             function logEvent(e) { | ||||
|                 var online, status, type, message; | ||||
|                 online = (isOnline()) ? 'yes' : 'no'; | ||||
|                 status = cacheStatusValues[cache.status]; | ||||
|                 type = e.type; | ||||
|                 message = 'online: ' + online; | ||||
|                 message+= ', event: ' + type; | ||||
|                 message+= ', status: ' + status; | ||||
|                 if (type == 'error' && navigator.onLine) { | ||||
|                     message+= ' There was an unknown error, check your Cache Manifest.'; | ||||
|                 } | ||||
|                 console.log(message); | ||||
|             } | ||||
|              | ||||
|             function isOnline() { | ||||
|                 return navigator.onLine; | ||||
|             } | ||||
|              | ||||
|             if (!$('html').attr('manifest')) { | ||||
|                 console.log('No Cache Manifest listed on the <html> tag.') | ||||
|             } | ||||
|  | ||||
|             // Swap in newly download files when update is ready | ||||
|             cache.addEventListener('updateready', function(e){ | ||||
|                     // Don't perform "swap" if this is the first cache | ||||
|                     if (cacheStatusValues[cache.status] != 'idle') { | ||||
|                         cache.swapCache(); | ||||
|                         console.log('Swapped/updated the Cache Manifest.'); | ||||
|                     } | ||||
|                 } | ||||
|             , false); | ||||
|  | ||||
|             // These two functions check for updates to the manifest file | ||||
|             function checkForUpdates(){ | ||||
|                 cache.update(); | ||||
|             } | ||||
|             function autoCheckForUpdates(){ | ||||
|                 setInterval(function(){cache.update()}, 10000); | ||||
|             } | ||||
|  | ||||
|             return { | ||||
|                 isOnline: isOnline, | ||||
|                 checkForUpdates: checkForUpdates, | ||||
|                 autoCheckForUpdates: autoCheckForUpdates | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
| })(jQuery); | ||||
							
								
								
									
										123
									
								
								frontend/gamma/js/JQTouch/extensions/jqt.themeswitcher.js
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										123
									
								
								frontend/gamma/js/JQTouch/extensions/jqt.themeswitcher.js
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,123 @@ | ||||
| /* | ||||
|  | ||||
|             _/    _/_/    _/_/_/_/_/                              _/ | ||||
|                _/    _/      _/      _/_/    _/    _/    _/_/_/  _/_/_/ | ||||
|           _/  _/  _/_/      _/    _/    _/  _/    _/  _/        _/    _/ | ||||
|          _/  _/    _/      _/    _/    _/  _/    _/  _/        _/    _/ | ||||
|         _/    _/_/  _/    _/      _/_/      _/_/_/    _/_/_/  _/    _/ | ||||
|        _/ | ||||
|     _/ | ||||
|  | ||||
|     Documentation and issue tracking on Google Code <http://code.google.com/p/jqtouch/> | ||||
|  | ||||
|     (c) 2011 by jQTouch project members. | ||||
|     See LICENSE.txt for license. | ||||
|  | ||||
| */ | ||||
|  | ||||
| (function($) { | ||||
|     if ($.jQTouch) { | ||||
|  | ||||
|         var scriptpath = $("script").last().attr("src").split('?')[0].split('/').slice(0, -1).join('/')+'/'; | ||||
|  | ||||
|         $.jQTouch.addExtension(function ThemeSwitcher(jQT) { | ||||
|  | ||||
|             var current, | ||||
|                 link, | ||||
|                 titles = {}, | ||||
|                 defaults = { | ||||
|                     themeStyleSelector: 'link[rel="stylesheet"][title]', | ||||
|                     themeIncluded: [ | ||||
|                         {title: 'jQTouch', href: scriptpath + '../themes/css/jqtouch.css'}, | ||||
|                         {title: 'Apple', href: scriptpath + '../themes/css/apple.css'}, | ||||
|                         {title: 'Vanilla', href: scriptpath + '../themes/css/vanilla.css'} | ||||
|  | ||||
|                     ] | ||||
|                 }, | ||||
|                 options = $.extend({}, defaults, jQT.settings); | ||||
|  | ||||
|             function setStyleState(item, title) { | ||||
|                 var $item = $(item); | ||||
|  | ||||
|                 if ($item.attr('title') === title) { | ||||
|                     item.disabled = false; // workaround for Firefox on Zepto | ||||
|                     $item.removeAttr('disabled'); | ||||
|                 } else { | ||||
|                   item.disabled = true; // workaround for Firefox on Zepto | ||||
|                   $item.attr('disabled', true); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             function initializeStyleState(item, title) { | ||||
|               // and, workaround for WebKit by initializing the 'disabled' attribute | ||||
|               if (!current) { | ||||
|                   current = title; | ||||
|               } | ||||
|               setStyleState(item, current); | ||||
|             } | ||||
|  | ||||
|             // public | ||||
|             function switchStyle(title) { | ||||
|                 current = title; | ||||
|                 $(options.themeStyleSelector).each(function(i, item) { | ||||
|                     setStyleState(item, title); | ||||
|                 }); | ||||
|             } | ||||
|  | ||||
|             // collect title names, from <head> | ||||
|             $(options.themeStyleSelector).each(function(i, item) { | ||||
|                 var $item = $(item); | ||||
|                 var title = $item.attr('title'); | ||||
|  | ||||
|                 titles[title] = true; | ||||
|  | ||||
|                 initializeStyleState(item, title); | ||||
|             }); | ||||
|  | ||||
|             // add included theme | ||||
|             for (var i=0; i < options.themeIncluded.length; i++) { | ||||
|                 var hash = options.themeIncluded[i]; | ||||
|                 if (!(hash.title in titles)) { | ||||
|                     link = $('<link title="' + hash.title + '" href="' + hash.href + '" rel="stylesheet">'); | ||||
|                     $('head').append($(link)); | ||||
|  | ||||
|                     titles[hash.title] = true; | ||||
|  | ||||
|                     initializeStyleState(link, hash.title); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             if (options.themeSelectionSelector) { | ||||
|                 // create UI items | ||||
|                 for (var title in titles) { | ||||
|                     var $item = $('<li><a href="#" data-title="' + title + '">' + title + '</a></li>'); | ||||
|                     $(options.themeSelectionSelector).append($item); | ||||
|                 } | ||||
|  | ||||
|                 // bind to UI items | ||||
|                 $(options.themeSelectionSelector).delegate('* > a', 'tap', function(e) { | ||||
|                     e.preventDefault(); | ||||
|                     e.stopPropagation(); | ||||
|  | ||||
|                     var $a = $(this).closest('a'); | ||||
|                     $a.removeClass('active'); | ||||
|                     switchStyle($a.attr('data-title')); | ||||
|  | ||||
|                     // poor-man simulation of radio button behaviour | ||||
|                     $(options.themeSelectionSelector).find('a').removeClass('selected'); | ||||
|                     $a.addClass('selected'); | ||||
|                 }); | ||||
|  | ||||
|                 // poor-man simulation of radio button behaviour | ||||
|                 $(options.themeSelectionSelector).closest('#jqt > *').bind('pageAnimationEnd', function(e, data){ | ||||
|                     if (data.direction === 'in') { | ||||
|                         $(options.themeSelectionSelector).find('a[data-title="' + current + '"]').addClass('selected'); | ||||
|                     } | ||||
|                 }); | ||||
|             } | ||||
|  | ||||
|             return {switchStyle: switchStyle}; | ||||
|  | ||||
|         }); | ||||
|     } | ||||
| })($); | ||||
							
								
								
									
										889
									
								
								frontend/gamma/js/JQTouch/jqtouch.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										889
									
								
								frontend/gamma/js/JQTouch/jqtouch.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,889 @@ | ||||
| /* | ||||
|  | ||||
|             _/    _/_/    _/_/_/_/_/                              _/ | ||||
|                _/    _/      _/      _/_/    _/    _/    _/_/_/  _/_/_/ | ||||
|           _/  _/  _/_/      _/    _/    _/  _/    _/  _/        _/    _/ | ||||
|          _/  _/    _/      _/    _/    _/  _/    _/  _/        _/    _/ | ||||
|         _/    _/_/  _/    _/      _/_/      _/_/_/    _/_/_/  _/    _/ | ||||
|        _/ | ||||
|     _/ | ||||
|  | ||||
|     Created by David Kaneda <http://www.davidkaneda.com> | ||||
|     Maintained by Thomas Yip <http://beedesk.com/> | ||||
|     Sponsored by Sencha Labs <http://www.sencha.com/> | ||||
|     Special thanks to Jonathan Stark <http://www.jonathanstark.com/> | ||||
|  | ||||
|     Documentation and issue tracking on GitHub <http://github.com/senchalabs/jQTouch/> | ||||
|  | ||||
|     (c) 2009-2011 Sencha Labs | ||||
|     jQTouch may be freely distributed under the MIT license. | ||||
|  | ||||
| */ | ||||
| (function() { | ||||
|  | ||||
|     var fx; | ||||
|     if ('Zepto' in window) { | ||||
|         fx = window.Zepto; | ||||
|         fx.fn.prop = fx.fn.attr; | ||||
|          | ||||
|         Event.prototype.isDefaultPrevented = function() { | ||||
|           return this.defaultPrevented; | ||||
|         }; | ||||
|     } else if ('jQuery' in window) { | ||||
|         fx = window.jQuery; | ||||
|  | ||||
|         // trick to get Zepto/touch.js to work for jQuery | ||||
|         window.Zepto = $; | ||||
|     } else { | ||||
|         throw('Either Zepto or jQuery is required but neither can be found.'); | ||||
|     } | ||||
|    | ||||
|     $.jQTouch = function(options) { | ||||
|         // Initialize internal jQT variables | ||||
|         var $ = fx, | ||||
|             $body, | ||||
|             $head=$('head'), | ||||
|             history=[], | ||||
|             newPageCount=0, | ||||
|             jQTSettings={}, | ||||
|             $currentPage='', | ||||
|             orientation='portrait', | ||||
|             touchSelectors=[], | ||||
|             publicObj={}, | ||||
|             tapBuffer=100, // High click delay = ~350, quickest animation (slide) = 250 | ||||
|             extensions=$.jQTouch.prototype.extensions, | ||||
|             extTapHandlers=$.jQTouch.prototype.tapHandlers, | ||||
|             tapHandlers=[], | ||||
|             animations=[], | ||||
|             hairExtensions='', | ||||
|             defaults = { | ||||
|                 addGlossToIcon: true, | ||||
|                 backSelector: '.back, .cancel, .goback', | ||||
|                 cacheGetRequests: true, | ||||
|                 debug: true, | ||||
|                 defaultAnimation: 'slideleft', | ||||
|                 fixedViewport: true, | ||||
|                 formSelector: 'form', | ||||
|                 fullScreen: true, | ||||
|                 fullScreenClass: 'fullscreen', | ||||
|                 icon: null, | ||||
|                 icon4: null, // available in iOS 4.2 and later. | ||||
|                 preloadImages: false, | ||||
|                 startupScreen: null, | ||||
|                 statusBar: 'default', // other options: black-translucent, black | ||||
|                 submitSelector: '.submit', | ||||
|                 touchSelector: 'a, .touch', | ||||
|                 trackScrollPositions: true, | ||||
|                 useAnimations: true, | ||||
|                 useFastTouch: true, | ||||
|                 useTouchScroll: true, | ||||
|                 animations: [ // highest to lowest priority | ||||
|                     {name:'cubeleft', selector:'.cubeleft, .cube', is3d: true}, | ||||
|                     {name:'cuberight', selector:'.cuberight', is3d: true}, | ||||
|                     {name:'dissolve', selector:'.dissolve'}, | ||||
|                     {name:'fade', selector:'.fade'}, | ||||
|                     {name:'flipleft', selector:'.flipleft, .flip', is3d: true}, | ||||
|                     {name:'flipright', selector:'.flipright', is3d: true}, | ||||
|                     {name:'pop', selector:'.pop', is3d: true}, | ||||
|                     {name:'swapleft', selector:'.swap', is3d: true}, | ||||
|                     {name:'slidedown', selector:'.slidedown'}, | ||||
|                     {name:'slideright', selector:'.slideright'}, | ||||
|                     {name:'slideup', selector:'.slideup'}, | ||||
|                     {name:'slideleft', selector:'.slideleft, .slide, #jqt > * > ul li a'} | ||||
|                 ] | ||||
|             }; // end defaults | ||||
|  | ||||
|         function warn(message) { | ||||
|             if (window.console !== undefined && jQTSettings.debug === true) { | ||||
|                 console.warn(message); | ||||
|             } | ||||
|         } | ||||
|         function addAnimation(animation) { | ||||
|             if (typeof(animation.selector) === 'string' && typeof(animation.name) === 'string') { | ||||
|                 animations.push(animation); | ||||
|             } | ||||
|         } | ||||
|         function addTapHandler(tapHandler) { | ||||
|           if (typeof(tapHandler.name) === 'string'  | ||||
|               && typeof(tapHandler.isSupported) === 'function' | ||||
|               && typeof(tapHandler.fn) === 'function') { | ||||
|              | ||||
|               tapHandlers.push(tapHandler); | ||||
|           } | ||||
|         } | ||||
|         function addPageToHistory(page, animation) { | ||||
|             history.unshift({ | ||||
|                 page: page, | ||||
|                 animation: animation, | ||||
|                 hash: '#' + page.attr('id'), | ||||
|                 id: page.attr('id') | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         // Unfortunately, we can not assume the "tap" event | ||||
|         // is being used for links, forms, etc. | ||||
|         function clickHandler(e) { | ||||
|             // Figure out whether to prevent default | ||||
|             var $el = $(e.target); | ||||
|  | ||||
|             // Find the nearest tappable ancestor | ||||
|             if (!$el.is(touchSelectors.join(', '))) { | ||||
|                 $el = $(e.target).closest(touchSelectors.join(', ')); | ||||
|             } | ||||
|  | ||||
|             // Prevent default if we found an internal link (relative or absolute) | ||||
|             if ($el && $el.attr('href') && !$el.isExternalLink()) { | ||||
|                 warn('Need to prevent default click behavior'); | ||||
|                 e.preventDefault(); | ||||
|             } else { | ||||
|                 warn('No need to prevent default click behavior'); | ||||
|             } | ||||
|  | ||||
|             // Trigger a tap event if touchstart is not on the job | ||||
|             if ($.support.touch) { | ||||
|                 warn('Not converting click to a tap event because touch handler is on the job'); | ||||
|             } else { | ||||
|                 warn('Converting click event to a tap event because touch handlers are not present or off'); | ||||
|                 $(e.target).trigger('tap', e); | ||||
|             } | ||||
|  | ||||
|         } | ||||
|         function doNavigation(fromPage, toPage, animation, goingBack) { | ||||
|  | ||||
|             goingBack = goingBack ? goingBack : false; | ||||
|  | ||||
|             // Error check for target page | ||||
|             if (toPage === undefined || toPage.length === 0) { | ||||
|                 $.fn.unselect(); | ||||
|                 warn('Target element is missing.'); | ||||
|                 return false; | ||||
|             } | ||||
|  | ||||
|             // Error check for fromPage===toPage | ||||
|             if (toPage.hasClass('current')) { | ||||
|                 $.fn.unselect(); | ||||
|                 warn('You are already on the page you are trying to navigate to.'); | ||||
|                 return false; | ||||
|             } | ||||
|  | ||||
|             // Collapse the keyboard | ||||
|             $(':focus').trigger('blur'); | ||||
|  | ||||
|             fromPage.trigger('pageAnimationStart', { direction: 'out', back: goingBack }); | ||||
|             toPage.trigger('pageAnimationStart', { direction: 'in', back: goingBack }); | ||||
|  | ||||
|             if ($.support.animationEvents && animation && jQTSettings.useAnimations) { | ||||
|                 // Fail over to 2d animation if need be | ||||
|                 if (!$.support.transform3d && animation.is3d) { | ||||
|                     warn('Did not detect support for 3d animations, falling back to ' + jQTSettings.defaultAnimation); | ||||
|                     animation.name = jQTSettings.defaultAnimation; | ||||
|                 } | ||||
|  | ||||
|                 // Reverse animation if need be | ||||
|                 var finalAnimationName = animation.name, | ||||
|                     is3d = animation.is3d ? 'animating3d' : ''; | ||||
|  | ||||
|                 if (goingBack) { | ||||
|                     finalAnimationName = finalAnimationName.replace(/left|right|up|down|in|out/, reverseAnimation ); | ||||
|                 } | ||||
|  | ||||
|                 warn('finalAnimationName is ' + finalAnimationName); | ||||
|  | ||||
|                 // Bind internal "cleanup" callback | ||||
|                 fromPage.bind('webkitAnimationEnd', navigationEndHandler); | ||||
|  | ||||
|                 // Trigger animations | ||||
|                 $body.addClass('animating ' + is3d); | ||||
|  | ||||
|                 var lastScroll = window.pageYOffset; | ||||
|  | ||||
|                 // Position the incoming page so toolbar is at top of viewport regardless of scroll position on from page | ||||
|                 if (jQTSettings.trackScrollPositions === true) { | ||||
|                     toPage.css('top', window.pageYOffset - (toPage.data('lastScroll') || 0)); | ||||
|                 } | ||||
|                  | ||||
|                 toPage.addClass(finalAnimationName + ' in current'); | ||||
|                 fromPage.removeClass('current').addClass(finalAnimationName + ' out inmotion'); | ||||
|                  | ||||
|                 if (jQTSettings.trackScrollPositions === true) { | ||||
|                     fromPage.data('lastScroll', lastScroll); | ||||
|                     $('.scroll', fromPage).each(function(){ | ||||
|                         $(this).data('lastScroll', this.scrollTop); | ||||
|                     }); | ||||
|                 } | ||||
|             } else { | ||||
|                 toPage.addClass('current in'); | ||||
|                 fromPage.removeClass('current'); | ||||
|                 navigationEndHandler(); | ||||
|             } | ||||
|              | ||||
|             // Housekeeping | ||||
|             $currentPage = toPage; | ||||
|             if (goingBack) { | ||||
|                 history.shift(); | ||||
|             } else { | ||||
|                 addPageToHistory($currentPage, animation); | ||||
|             } | ||||
|             setHash($currentPage.attr('id')); | ||||
|  | ||||
|             // Private navigationEnd callback | ||||
|             function navigationEndHandler(event) { | ||||
|                 var bufferTime = tapBuffer; | ||||
|  | ||||
|                 if ($.support.animationEvents && animation && jQTSettings.useAnimations) { | ||||
|                     fromPage.unbind('webkitAnimationEnd', navigationEndHandler); | ||||
|                     fromPage.removeClass(finalAnimationName + ' out inmotion'); | ||||
|                     if (finalAnimationName) { | ||||
|                       toPage.removeClass(finalAnimationName); | ||||
|                     } | ||||
|                     $body.removeClass('animating animating3d'); | ||||
|                     if (jQTSettings.trackScrollPositions === true) { | ||||
|                         toPage.css('top', -toPage.data('lastScroll')); | ||||
|  | ||||
|                         // Have to make sure the scroll/style resets | ||||
|                         // are outside the flow of this function. | ||||
|                         setTimeout(function(){ | ||||
|                             toPage.css('top', 0); | ||||
|                             window.scroll(0, toPage.data('lastScroll')); | ||||
|                             $('.scroll', toPage).each(function(){ | ||||
|                                 this.scrollTop = - $(this).data('lastScroll'); | ||||
|                             }); | ||||
|                         }, 0); | ||||
|                     } | ||||
|                 } else { | ||||
|                     fromPage.removeClass(finalAnimationName + ' out inmotion'); | ||||
|                     if (finalAnimationName) { | ||||
|                       toPage.removeClass(finalAnimationName); | ||||
|                     } | ||||
|                     bufferTime += 260; | ||||
|                 } | ||||
|  | ||||
|                 // In class is intentionally delayed, as it is our ghost click hack | ||||
|                 setTimeout(function(){ | ||||
|                     toPage.removeClass('in'); | ||||
|                     window.scroll(0,0); | ||||
|                 }, bufferTime); | ||||
|  | ||||
|                 fromPage.unselect(); | ||||
|  | ||||
|                 // Trigger custom events | ||||
|                 toPage.trigger('pageAnimationEnd', { | ||||
|                     direction:'in', animation: animation, back: goingBack | ||||
|                 }); | ||||
|                 fromPage.trigger('pageAnimationEnd', { | ||||
|                     direction:'out', animation: animation, back: goingBack | ||||
|                 }); | ||||
|             } | ||||
|  | ||||
|             return true; | ||||
|         } | ||||
|         function reverseAnimation(animation) { | ||||
|             var opposites={ | ||||
|                 'up' : 'down', | ||||
|                 'down' : 'up', | ||||
|                 'left' : 'right', | ||||
|                 'right' : 'left', | ||||
|                 'in' : 'out', | ||||
|                 'out' : 'in' | ||||
|             }; | ||||
|  | ||||
|             return opposites[animation] || animation; | ||||
|         } | ||||
|         function getOrientation() { | ||||
|             return orientation; | ||||
|         } | ||||
|         function goBack() { | ||||
|  | ||||
|             // Error checking | ||||
|             if (history.length < 1 ) { | ||||
|                 warn('History is empty.'); | ||||
|             } | ||||
|  | ||||
|             if (history.length === 1 ) { | ||||
|                 warn('You are on the first panel.'); | ||||
|                 window.history.go(-1); | ||||
|             } | ||||
|  | ||||
|             var from = history[0], | ||||
|                 to = history[1]; | ||||
|  | ||||
|             if (doNavigation(from.page, to.page, from.animation, true)) { | ||||
|                 return publicObj; | ||||
|             } else { | ||||
|                 warn('Could not go back.'); | ||||
|                 return false; | ||||
|             } | ||||
|  | ||||
|         } | ||||
|         function goTo(toPage, animation) { | ||||
|  | ||||
|             var fromPage = history[0].page; | ||||
|  | ||||
|             if (typeof animation === 'string') { | ||||
|                 for (var i=0, max=animations.length; i < max; i++) { | ||||
|                     if (animations[i].name === animation) { | ||||
|                         animation = animations[i]; | ||||
|                         break; | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             if (typeof toPage === 'string') { | ||||
|                 var nextPage = $(toPage); | ||||
|  | ||||
|                 if (nextPage.length < 1) { | ||||
|                     showPageByHref(toPage, { | ||||
|                         animation: animation | ||||
|                     }); | ||||
|                     return; | ||||
|                 } else { | ||||
|                     toPage = nextPage; | ||||
|                 } | ||||
|             } | ||||
|             if (doNavigation(fromPage, toPage, animation)) { | ||||
|                 return publicObj; | ||||
|             } else { | ||||
|                 warn('Could not animate pages.'); | ||||
|                 return false; | ||||
|             } | ||||
|         } | ||||
|         function hashChangeHandler(e) { | ||||
|             if (location.hash === history[0].hash) { | ||||
|                 warn('We are on the right panel'); | ||||
|                 return true; | ||||
|             } else if (location.hash === '') { | ||||
|                 goBack(); | ||||
|                 return true; | ||||
|             } else { | ||||
|                 if( (history[1] && location.hash === history[1].hash) ) { | ||||
|                     goBack(); | ||||
|                     return true; | ||||
|                 } else { | ||||
|                     // Lastly, just try going to the ID... | ||||
|                     warn('Could not find ID in history, just forwarding to DOM element.'); | ||||
|                     goTo($(location.hash), jQTSettings.defaultAnimation); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         function init(options) { | ||||
|             jQTSettings = $.extend({}, defaults, options); | ||||
|  | ||||
|             // Preload images | ||||
|             if (jQTSettings.preloadImages) { | ||||
|                 for (var i = jQTSettings.preloadImages.length - 1; i >= 0; i--) { | ||||
|                     (new Image()).src = jQTSettings.preloadImages[i]; | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             // Set appropriate icon (retina display available in iOS 4.2 and later.) | ||||
|             var precomposed = (jQTSettings.addGlossToIcon) ? '' : '-precomposed'; | ||||
|             if (jQTSettings.icon) { | ||||
|                 hairExtensions += '<link rel="apple-touch-icon' + precomposed + '" href="' + jQTSettings.icon + '" />'; | ||||
|             } | ||||
|             if (jQTSettings.icon4) { | ||||
|                 hairExtensions += '<link rel="apple-touch-icon' + precomposed + '" sizes="114x114" href="' + jQTSettings.icon4 + '" />'; | ||||
|             } | ||||
|             // Set startup screen | ||||
|             if (jQTSettings.startupScreen) { | ||||
|                 hairExtensions += '<link rel="apple-touch-startup-image" href="' + jQTSettings.startupScreen + '" />'; | ||||
|             } | ||||
|  | ||||
|             // Set viewport | ||||
|             if (jQTSettings.fixedViewport) { | ||||
|                 hairExtensions += '<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>'; | ||||
|             } | ||||
|  | ||||
|             // Set full-screen | ||||
|             if (jQTSettings.fullScreen) { | ||||
|                 hairExtensions += '<meta name="apple-mobile-web-app-capable" content="yes" />'; | ||||
|                 if (jQTSettings.statusBar) { | ||||
|                     hairExtensions += '<meta name="apple-mobile-web-app-status-bar-style" content="' + jQTSettings.statusBar + '" />'; | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             // Attach hair extensions | ||||
|             if (hairExtensions) { | ||||
|                 $head.prepend(hairExtensions); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function getAnimation(el) { | ||||
|             var animation; | ||||
|  | ||||
|             for (var i=0, max=animations.length; i < max; i++) { | ||||
|                 if (el.is(animations[i].selector)) { | ||||
|                     animation = animations[i]; | ||||
|                     break; | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             if (!animation) { | ||||
|                 warn('Animation could not be found. Using ' + jQTSettings.defaultAnimation + '.'); | ||||
|                 animation = jQTSettings.defaultAnimation; | ||||
|             } | ||||
|             return animation; | ||||
|         } | ||||
|  | ||||
|         function insertPages(nodes, animation) { | ||||
|  | ||||
|             var targetPage = null; | ||||
|  | ||||
|             // Call dom.createElement element directly instead of relying on $(nodes), | ||||
|             // to work around: https://github.com/madrobby/zepto/issues/312 | ||||
|             var div = document.createElement('div'); | ||||
|             div.innerHTML = nodes; | ||||
|  | ||||
|             $(div).children().each(function(index, node) { | ||||
|                 var $node = $(this); | ||||
|                 if (!$node.attr('id')) { | ||||
|                     $node.attr('id', 'page-' + (++newPageCount)); | ||||
|                 } | ||||
|  | ||||
|                 // Remove any existing instance | ||||
|                 $('#' + $node.attr('id')).remove(); | ||||
|  | ||||
|                 $body.append($node); | ||||
|                 $body.trigger('pageInserted', {page: $node}); | ||||
|  | ||||
|                 if ($node.hasClass('current') || !targetPage) { | ||||
|                     targetPage = $node; | ||||
|                 } | ||||
|             }); | ||||
|             if (targetPage !== null) { | ||||
|                 goTo(targetPage, animation); | ||||
|                 return targetPage; | ||||
|             } else { | ||||
|                 return false; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function orientationChangeHandler() { | ||||
|             $body.css('minHeight', 1000); | ||||
|             scrollTo(0,0); | ||||
|             var bodyHeight = window.innerHeight; | ||||
|             $body.css('minHeight', bodyHeight); | ||||
|  | ||||
|             orientation = Math.abs(window.orientation) == 90 ? 'landscape' : 'portrait'; | ||||
|             $body.removeClass('portrait landscape').addClass(orientation).trigger('turn', {orientation: orientation}); | ||||
|         } | ||||
|         function setHash(hash) { | ||||
|             // Sanitize | ||||
|             location.hash = '#' + hash.replace(/^#/, ''); | ||||
|         } | ||||
|         function showPageByHref(href, options) { | ||||
|  | ||||
|             var defaults = { | ||||
|                 data: null, | ||||
|                 method: 'GET', | ||||
|                 animation: null, | ||||
|                 callback: null, | ||||
|                 $referrer: null | ||||
|             }; | ||||
|  | ||||
|             var settings = $.extend({}, defaults, options); | ||||
|  | ||||
|             if (href != '#') { | ||||
|                 $.ajax({ | ||||
|                     url: href, | ||||
|                     data: settings.data, | ||||
|                     type: settings.method, | ||||
|                     success: function (data) { | ||||
|                         var firstPage = insertPages(data, settings.animation); | ||||
|                         if (firstPage) { | ||||
|                             if (settings.method == 'GET' && jQTSettings.cacheGetRequests === true && settings.$referrer) { | ||||
|                                 settings.$referrer.attr('href', '#' + firstPage.attr('id')); | ||||
|                             } | ||||
|                             if (settings.callback) { | ||||
|                                 settings.callback(true); | ||||
|                             } | ||||
|                         } | ||||
|                     }, | ||||
|                     error: function (data) { | ||||
|                         if (settings.$referrer) { | ||||
|                             settings.$referrer.unselect(); | ||||
|                         } | ||||
|                         if (settings.callback) { | ||||
|                             settings.callback(false); | ||||
|                         } | ||||
|                     } | ||||
|                 }); | ||||
|             } else if (settings.$referrer) { | ||||
|                 settings.$referrer.unselect(); | ||||
|             } | ||||
|         } | ||||
|         function submitHandler(e, callback) { | ||||
|  | ||||
|             $(':focus').trigger('blur'); | ||||
|  | ||||
|             e.preventDefault(); | ||||
|  | ||||
|             var $form = (typeof(e)==='string') ? $(e).eq(0) : (e.target ? $(e.target) : $(e)); | ||||
|  | ||||
|             if ($form.length && $form.is(jQTSettings.formSelector) && $form.attr('action')) { | ||||
|                 showPageByHref($form.attr('action'), { | ||||
|                     data: $form.serialize(), | ||||
|                     method: $form.attr('method') || "POST", | ||||
|                     animation: getAnimation($form), | ||||
|                     callback: callback | ||||
|                 }); | ||||
|                 return false; | ||||
|             } | ||||
|             return true; | ||||
|         } | ||||
|         function submitParentForm($el) { | ||||
|  | ||||
|             var $form = $el.closest('form'); | ||||
|             if ($form.length === 0) { | ||||
|                 warn('No parent form found'); | ||||
|             } else { | ||||
|                 warn('About to submit parent form'); | ||||
|                 $form.trigger('submit'); | ||||
|                 return false; | ||||
|             } | ||||
|             return true; | ||||
|         } | ||||
|         function supportForTransform3d() { | ||||
|  | ||||
|             var head, body, style, div, result; | ||||
|  | ||||
|             head = document.getElementsByTagName('head')[0]; | ||||
|             body = document.body; | ||||
|  | ||||
|             style = document.createElement('style'); | ||||
|             style.textContent = '@media (transform-3d),(-o-transform-3d),(-moz-transform-3d),(-webkit-transform-3d){#jqt-3dtest{height:3px}}'; | ||||
|  | ||||
|             div = document.createElement('div'); | ||||
|             div.id = 'jqt-3dtest'; | ||||
|  | ||||
|             // Add to the page | ||||
|             head.appendChild(style); | ||||
|             body.appendChild(div); | ||||
|  | ||||
|             // Check the result | ||||
|             result = div.offsetHeight === 3; | ||||
|  | ||||
|             // Clean up | ||||
|             style.parentNode.removeChild(style); | ||||
|             div.parentNode.removeChild(div); | ||||
|  | ||||
|             // Pass back result | ||||
|             warn('Support for 3d transforms: ' + result); | ||||
|             return result; | ||||
|         } | ||||
|         function supportIOS5() { | ||||
|             var support = false; | ||||
|             var REGEX_IOS_VERSION = /OS (\d+)(_\d+)* like Mac OS X/i; | ||||
|    | ||||
|             var agentString = window.navigator.userAgent; | ||||
|             if (REGEX_IOS_VERSION.test(agentString)) { | ||||
|                 support = (REGEX_IOS_VERSION.exec(agentString)[1] >= 5); | ||||
|             } | ||||
|             return support; | ||||
|         } | ||||
|         function touchStartHandler(e){ | ||||
|  | ||||
|             var $el = $(e.target), | ||||
|                 selectors = touchSelectors.join(', '); | ||||
|  | ||||
|             // Find the nearest tappable ancestor | ||||
|             if (!$el.is(selectors)) { | ||||
|                 $el = $el.closest(selectors); | ||||
|             } | ||||
|  | ||||
|             // Make sure we have a tappable element | ||||
|             if ($el.length && $el.attr('href')) { | ||||
|                 $el.addClass('active'); | ||||
|             } | ||||
|  | ||||
|             // Remove our active class if we move | ||||
|             $el.on($.support.touch ? 'touchmove' : 'mousemove', function(){ | ||||
|                 $el.removeClass('active'); | ||||
|             }); | ||||
|  | ||||
|             $el.on('touchend', function(){ | ||||
|                 $el.unbind('touchmove mousemove'); | ||||
|             }); | ||||
|  | ||||
|         } | ||||
|         function tapHandler(e){ | ||||
|  | ||||
|             if (e.isDefaultPrevented()) { | ||||
|                 return true; | ||||
|             } | ||||
|  | ||||
|             // Grab the target element | ||||
|             var $el = $(e.target); | ||||
|  | ||||
|             // Find the nearest tappable ancestor | ||||
|             if (!$el.is(touchSelectors.join(', '))) { | ||||
|                 $el = $el.closest(touchSelectors.join(', ')); | ||||
|             } | ||||
|  | ||||
|             // Make sure we have a tappable element | ||||
|             if (!$el.length || !$el.attr('href')) { | ||||
|                 warn('Could not find a link related to tapped element'); | ||||
|                 return true; | ||||
|             } | ||||
|  | ||||
|             // Init some vars | ||||
|             var target = $el.attr('target'), | ||||
|                 hash = $el.prop('hash'), | ||||
|                 href = $el.attr('href'); | ||||
|  | ||||
|             var params = { | ||||
|                 e: e, | ||||
|                 $el: $el, | ||||
|                 target: target, | ||||
|                 hash: hash, | ||||
|                 href: href, | ||||
|                 jQTSettings: jQTSettings | ||||
|             }; | ||||
|              | ||||
|             // Loop thru all handlers | ||||
|             for (var i=0, len=tapHandlers.length; i<len; i++) { | ||||
|                 var handler = tapHandlers[i]; | ||||
|                 var supported = handler.isSupported(e, params); | ||||
|                 if (supported) { | ||||
|                     var flag = handler.fn(e, params); | ||||
|                     return flag; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         function addDefaultTapHandlers() { | ||||
|             addTapHandler({ | ||||
|                 name: 'external-link', | ||||
|                 isSupported: function(e, params) { | ||||
|                     return params.$el.isExternalLink(); | ||||
|                 }, | ||||
|                 fn: function(e, params) { | ||||
|                     params.$el.unselect(); | ||||
|                     return true; | ||||
|                 } | ||||
|             }); | ||||
|             addTapHandler({ | ||||
|                 name: 'back-selector', | ||||
|                 isSupported: function(e, params) { | ||||
|                     return params.$el.is(params.jQTSettings.backSelector); | ||||
|                 }, | ||||
|                 fn: function(e, params) { | ||||
|                     // User clicked or tapped a back button | ||||
|                     goBack(params.hash); | ||||
|                 } | ||||
|             }); | ||||
|             addTapHandler({ | ||||
|                 name: 'submit-selector', | ||||
|                 isSupported: function(e, params) { | ||||
|                     return params.$el.is(params.jQTSettings.submitSelector); | ||||
|                 }, | ||||
|                 fn: function(e, params) { | ||||
|                     // User clicked or tapped a submit element | ||||
|                     submitParentForm(params.$el); | ||||
|                 } | ||||
|             }); | ||||
|             addTapHandler({ | ||||
|                 name: 'webapp', | ||||
|                 isSupported: function(e, params) { | ||||
|                     return params.target === '_webapp'; | ||||
|                 }, | ||||
|                 fn: function(e, params) { | ||||
|                     // User clicked or tapped an internal link, fullscreen mode | ||||
|                     window.location = params.href; | ||||
|                     return false; | ||||
|                 } | ||||
|             }); | ||||
|             addTapHandler({ | ||||
|                 name: 'no-op', | ||||
|                 isSupported: function(e, params) { | ||||
|                     return params.href === '#'; | ||||
|                 }, | ||||
|                 fn: function(e, params) { | ||||
|                     // Allow tap on item with no href | ||||
|                     params.$el.unselect(); | ||||
|                     return true; | ||||
|                 } | ||||
|             }); | ||||
|             addTapHandler({ | ||||
|                 name: 'standard', | ||||
|                 isSupported: function(e, params) { | ||||
|                     return params.hash && params.hash !== '#'; | ||||
|                 }, | ||||
|                 fn: function(e, params) { | ||||
|                     var animation = getAnimation(params.$el); | ||||
|                     // Internal href | ||||
|                     params.$el.addClass('active'); | ||||
|                     goTo( | ||||
|                         $(params.hash).data('referrer', params.$el),  | ||||
|                         animation,  | ||||
|                         params.$el.hasClass('reverse') | ||||
|                     ); | ||||
|                     return false; | ||||
|                 } | ||||
|             }); | ||||
|             addTapHandler({ | ||||
|                 name: 'external', | ||||
|                 isSupported: function(e, params) { | ||||
|                     return true; | ||||
|                 }, | ||||
|                 fn: function(e, params) { | ||||
|                     var animation = getAnimation(params.$el); | ||||
|        | ||||
|                     // External href | ||||
|                     params.$el.addClass('loading active'); | ||||
|                     showPageByHref(params.$el.attr('href'), { | ||||
|                         animation: animation, | ||||
|                         callback: function() { | ||||
|                             params.$el.removeClass('loading'); | ||||
|                             setTimeout($.fn.unselect, 250, params.$el); | ||||
|                         }, | ||||
|                         $referrer: params.$el | ||||
|                     }); | ||||
|                     return false; | ||||
|                 } | ||||
|             }); | ||||
|         }; | ||||
|  | ||||
|         // Get the party started | ||||
|         init(options); | ||||
|  | ||||
|         // Document ready stuff | ||||
|         $(document).ready(function RUMBLE() { | ||||
|             // Store some properties in a support object | ||||
|             if (!$.support) $.support = {}; | ||||
|             $.support.animationEvents = (typeof window.WebKitAnimationEvent != 'undefined'); | ||||
|             $.support.touch = (typeof window.TouchEvent != 'undefined') && (window.navigator.userAgent.indexOf('Mobile') > -1) && jQTSettings.useFastTouch; | ||||
|             $.support.transform3d = supportForTransform3d(); | ||||
|             $.support.ios5 = supportIOS5(); | ||||
|  | ||||
|             if (!$.support.touch) { | ||||
|                 warn('This device does not support touch interaction, or it has been deactivated by the developer. Some features might be unavailable.'); | ||||
|             } | ||||
|             if (!$.support.transform3d) { | ||||
|                 warn('This device does not support 3d animation. 2d animations will be used instead.'); | ||||
|             } | ||||
|  | ||||
|             // Define public jQuery functions | ||||
|             $.fn.isExternalLink = function() { | ||||
|                 var $el = $(this); | ||||
|                 return ($el.attr('target') == '_blank' || $el.attr('rel') == 'external' || $el.is('a[href^="http://maps.google.com"], a[href^="mailto:"], a[href^="tel:"], a[href^="javascript:"], a[href*="youtube.com/v"], a[href*="youtube.com/watch"]')); | ||||
|             }; | ||||
|             $.fn.makeActive = function() { | ||||
|                 return $(this).addClass('active'); | ||||
|             }; | ||||
|             $.fn.unselect = function(obj) { | ||||
|                 if (obj) { | ||||
|                     obj.removeClass('active'); | ||||
|                 } else { | ||||
|                     $('.active').removeClass('active'); | ||||
|                 } | ||||
|             }; | ||||
|  | ||||
|             // Add extensions | ||||
|             for (var i=0, max=extensions.length; i < max; i++) { | ||||
|                 var fn = extensions[i]; | ||||
|                 if ($.isFunction(fn)) { | ||||
|                     $.extend(publicObj, fn(publicObj)); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             // Add extensions tapHandlers | ||||
|             for (var i=0, max=extTapHandlers.length; i < max; i++) { | ||||
|                 addTapHandler(extTapHandlers[i]); | ||||
|             } | ||||
|             // Add default tapHandlers | ||||
|             addDefaultTapHandlers(); | ||||
|  | ||||
|             // Add animations | ||||
|             for (var j=0, max_anims=defaults.animations.length; j < max_anims; j++) { | ||||
|                 var animation = defaults.animations[j]; | ||||
|                 if(jQTSettings[animation.name + 'Selector'] !== undefined){ | ||||
|                     animation.selector = jQTSettings[animation.name + 'Selector']; | ||||
|                 } | ||||
|                 addAnimation(animation); | ||||
|             } | ||||
|  | ||||
|             // Create an array of stuff that needs touch event handling | ||||
|             touchSelectors.push(jQTSettings.touchSelector); | ||||
|             touchSelectors.push(jQTSettings.backSelector); | ||||
|             touchSelectors.push(jQTSettings.submitSelector); | ||||
|             $(touchSelectors.join(', ')).css('-webkit-touch-callout', 'none'); | ||||
|  | ||||
|             // Make sure we have a jqt element | ||||
|             $body = $('#jqt'); | ||||
|             var anatomy_lessons = []; | ||||
|  | ||||
|             if ($body.length === 0) { | ||||
|                 warn('Could not find an element with the id "jqt", so the body id has been set to "jqt". If you are having any problems, wrapping your panels in a div with the id "jqt" might help.'); | ||||
|                 $body = $(document.body).attr('id', 'jqt'); | ||||
|             } | ||||
|  | ||||
|             // Add some specific css if need be | ||||
|             if ($.support.transform3d) { | ||||
|                 anatomy_lessons.push('supports3d'); | ||||
|             } | ||||
|             if ($.support.ios5 && jQTSettings.useTouchScroll) { | ||||
|                 anatomy_lessons.push('touchscroll'); | ||||
|             } | ||||
|  | ||||
|             if (jQTSettings.fullScreenClass && window.navigator.standalone === true) { | ||||
|                 anatomy_lessons.push(jQTSettings.fullScreenClass, jQTSettings.statusBar); | ||||
|             } | ||||
|  | ||||
|             // Bind events | ||||
|              | ||||
|             $body | ||||
|                 .addClass(anatomy_lessons.join(' ')) | ||||
|                 .bind('click', clickHandler) | ||||
|                 .bind('orientationchange', orientationChangeHandler) | ||||
|                 .bind('submit', submitHandler) | ||||
|                 .bind('tap', tapHandler) | ||||
|                 .bind( $.support.touch ? 'touchstart' : 'mousedown', touchStartHandler) | ||||
|                 .trigger('orientationchange'); | ||||
|              | ||||
|             $(window).bind('hashchange', hashChangeHandler); | ||||
|  | ||||
|             var startHash = location.hash; | ||||
|  | ||||
|             // Determine what the initial view should be | ||||
|             if ($('#jqt > .current').length === 0) { | ||||
|                 $currentPage = $('#jqt > *:first-child').addClass('current'); | ||||
|             } else { | ||||
|                 $currentPage = $('#jqt > .current'); | ||||
|             } | ||||
|              | ||||
|             setHash($currentPage.attr('id')); | ||||
|             addPageToHistory($currentPage); | ||||
|  | ||||
|             if ($(startHash).length === 1) { | ||||
|                 goTo(startHash); | ||||
|             } | ||||
|         }); | ||||
|  | ||||
|         // Expose public methods and properties | ||||
|         publicObj = { | ||||
|             addAnimation: addAnimation, | ||||
|             animations: animations, | ||||
|             getOrientation: getOrientation, | ||||
|             goBack: goBack, | ||||
|             insertPages: insertPages, | ||||
|             goTo: goTo, | ||||
|             history: history, | ||||
|             settings: jQTSettings, | ||||
|             submitForm: submitHandler | ||||
|         }; | ||||
|         return publicObj; | ||||
|     }; | ||||
|      | ||||
|     $.jQTouch.prototype.extensions = []; | ||||
|     $.jQTouch.prototype.tapHandlers = []; | ||||
|  | ||||
|     // Extensions directly manipulate the jQTouch object, before it's initialized. | ||||
|     $.jQTouch.addExtension = function(extension) { | ||||
|         $.jQTouch.prototype.extensions.push(extension); | ||||
|     }; | ||||
|      | ||||
|     // Experimental tap hanlders that can bypass default jQTouch tap handling | ||||
|     $.jQTouch.addTapHandler = function(extension) { | ||||
|         $.jQTouch.prototype.tapHandlers.push(extension); | ||||
|     }; | ||||
|  | ||||
| })(); // Double closure, ALL THE WAY ACROSS THE SKY | ||||
		Reference in New Issue
	
	Block a user
	 Clipperz
					Clipperz