1
0
mirror of http://git.whoc.org.uk/git/password-manager.git synced 2025-10-31 19: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:
Clipperz
2013-01-09 10:03:53 +01:00
parent a9974c63bd
commit 644891059e
22 changed files with 3518 additions and 0 deletions

View 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');
}
})($);

View 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
};
});
}
})($);

View 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();
}
});
};
});
}
})($);

View 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
};
});
}
})($);

View 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');
}
})($);

View 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);

View 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};
});
}
})($);