author | Clipperz <info@clipperz.com> | 2013-01-09 09:03:53 (UTC) |
---|---|---|
committer | Clipperz <info@clipperz.com> | 2013-01-09 09:03:53 (UTC) |
commit | 644891059e1f37d0748bc34b9ca78c05fa748214 (patch) (unidiff) | |
tree | a746ee125d503088dc53dac823474e4295560947 /frontend/gamma/js/JQTouch/extensions | |
parent | a9974c63bdcef65f009420dce095d1e39da7e3b8 (diff) | |
download | clipperz-644891059e1f37d0748bc34b9ca78c05fa748214.zip clipperz-644891059e1f37d0748bc34b9ca78c05fa748214.tar.gz clipperz-644891059e1f37d0748bc34b9ca78c05fa748214.tar.bz2 |
Added JQTouch and Zepto libraries
JQTouch and Zepto are tentatively used for the mobile version of Clipperz.
No final commitment has been made, though.
Diffstat (limited to 'frontend/gamma/js/JQTouch/extensions') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/JQTouch/extensions/jqt.actionsheet.js | 159 | ||||
-rw-r--r-- | frontend/gamma/js/JQTouch/extensions/jqt.autotitles.js | 52 | ||||
-rw-r--r-- | frontend/gamma/js/JQTouch/extensions/jqt.floaty.js | 96 | ||||
-rw-r--r-- | frontend/gamma/js/JQTouch/extensions/jqt.location.js | 51 | ||||
-rw-r--r-- | frontend/gamma/js/JQTouch/extensions/jqt.menusheet.js | 137 | ||||
-rw-r--r-- | frontend/gamma/js/JQTouch/extensions/jqt.offline.js | 97 | ||||
-rwxr-xr-x | frontend/gamma/js/JQTouch/extensions/jqt.themeswitcher.js | 123 |
7 files changed, 715 insertions, 0 deletions
diff --git a/frontend/gamma/js/JQTouch/extensions/jqt.actionsheet.js b/frontend/gamma/js/JQTouch/extensions/jqt.actionsheet.js new file mode 100644 index 0000000..2a5f8d1 --- a/dev/null +++ b/frontend/gamma/js/JQTouch/extensions/jqt.actionsheet.js | |||
@@ -0,0 +1,159 @@ | |||
1 | /* | ||
2 | |||
3 | _/ _/_/ _/_/_/_/_/ _/ | ||
4 | _/ _/ _/ _/_/ _/ _/ _/_/_/ _/_/_/ | ||
5 | _/ _/ _/_/ _/ _/ _/ _/ _/ _/ _/ _/ | ||
6 | _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ | ||
7 | _/ _/_/ _/ _/ _/_/ _/_/_/ _/_/_/ _/ _/ | ||
8 | _/ | ||
9 | _/ | ||
10 | |||
11 | Documentation and issue tracking on Google Code <http://code.google.com/p/jqtouch/> | ||
12 | |||
13 | (c) 2012 by jQTouch project members. | ||
14 | See LICENSE.txt for license. | ||
15 | |||
16 | Author: Thomas Yip | ||
17 | */ | ||
18 | |||
19 | /* | ||
20 | |||
21 | _/ _/_/ _/_/_/_/_/ _/ | ||
22 | _/ _/ _/ _/_/ _/ _/ _/_/_/ _/_/_/ | ||
23 | _/ _/ _/_/ _/ _/ _/ _/ _/ _/ _/ _/ | ||
24 | _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ | ||
25 | _/ _/_/ _/ _/ _/_/ _/_/_/ _/_/_/ _/ _/ | ||
26 | _/ | ||
27 | _/ | ||
28 | |||
29 | Documentation and issue tracking on Google Code <http://code.google.com/p/jqtouch/> | ||
30 | |||
31 | (c) 2012 by jQTouch project members. | ||
32 | See LICENSE.txt for license. | ||
33 | |||
34 | Author: Thomas Yip | ||
35 | */ | ||
36 | |||
37 | (function($) { | ||
38 | var src = $("head script").last().attr("src") || ''; | ||
39 | var scriptpath = src.split('?')[0].split('/').slice(0, -1).join('/')+'/'; | ||
40 | var csspath = scriptpath + 'jqt.actionsheet.css'; | ||
41 | var link = $('<link href="' + csspath + '" rel="stylesheet">'); | ||
42 | $('head').append($(link)); | ||
43 | |||
44 | function hide(callback) { | ||
45 | var $target = $(this); | ||
46 | var data = $(this).data('actionsheet'); | ||
47 | var $source = data.source; | ||
48 | |||
49 | var timeout; | ||
50 | |||
51 | function cleanup() { | ||
52 | clearTimeout(timeout); | ||
53 | |||
54 | $source.removeClass('transition'); | ||
55 | $target.removeClass('inmotion transition'); | ||
56 | !callback || callback.apply(this, arguments); | ||
57 | }; | ||
58 | timeout = setTimeout(cleanup, 500); | ||
59 | |||
60 | if (data.shown) { | ||
61 | $(this).data('actionsheet', {}); | ||
62 | $target.one('webkitTransitionEnd', cleanup); | ||
63 | |||
64 | $source.addClass('transition'); | ||
65 | $target.removeClass('current').addClass('inmotion transition'); | ||
66 | $('#jqt').removeClass('actionopened'); | ||
67 | } | ||
68 | return $target; | ||
69 | } | ||
70 | |||
71 | function show(callback) { | ||
72 | var $target = $(this); | ||
73 | var data = $(this).data('actionsheet') || {}; | ||
74 | if (!data.shown) { | ||
75 | var $source = $('#jqt .current:not(.actionsheet)'); | ||
76 | |||
77 | $target.one('webkitTransitionEnd', function() { | ||
78 | $source.removeClass('transition'); | ||
79 | $target.removeClass('inmotion transition'); | ||
80 | !callback || callback.apply(this, arguments); | ||
81 | }); | ||
82 | |||
83 | data.shown = true; | ||
84 | data.source = $source; | ||
85 | $(this).data('actionsheet', data); | ||
86 | |||
87 | $source.addClass('transition'); | ||
88 | $target.addClass('inmotion transition'); | ||
89 | $('#jqt').addClass('actionopened'); | ||
90 | setTimeout(function() { | ||
91 | $target.addClass('current'); | ||
92 | }, 50); | ||
93 | } | ||
94 | return $target; | ||
95 | } | ||
96 | |||
97 | var methods = { | ||
98 | init: function(options) { | ||
99 | $(this).addClass('actionsheet'); | ||
100 | $(this).data({shown: false}); | ||
101 | }, | ||
102 | show: show, | ||
103 | hide: hide | ||
104 | }; | ||
105 | |||
106 | $.fn.actionsheet = function(method) { | ||
107 | if (methods[method]) { | ||
108 | if ($(this).is('.actionsheet')) { | ||
109 | return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); | ||
110 | } else { | ||
111 | var msg = 'Target is not a `actionsheet`. Action `' + method + '` is ignored.'; | ||
112 | console.warn(msg); | ||
113 | } | ||
114 | } else if ( typeof method === 'object' || ! method ) { | ||
115 | return methods.init.apply(this, arguments); | ||
116 | } else { | ||
117 | $.error( 'Method ' + method + ' does not exist on jQuery.tooltip' ); | ||
118 | } | ||
119 | }; | ||
120 | |||
121 | if ($.jQTouch) { | ||
122 | $.jQTouch.addTapHandler({ | ||
123 | name: 'open-actionsheet', | ||
124 | isSupported: function(e, params) { | ||
125 | return params.$el.is('.action'); | ||
126 | }, | ||
127 | fn: function(e, params) { | ||
128 | params.$el.removeClass('active'); | ||
129 | |||
130 | var $target = $(params.hash); | ||
131 | $target.actionsheet('show'); | ||
132 | |||
133 | return false; | ||
134 | } | ||
135 | }); | ||
136 | $.jQTouch.addTapHandler({ | ||
137 | name: 'follow-actionlink', | ||
138 | isSupported: function(e, params) { | ||
139 | if ($('#jqt').hasClass('actionopened')) { | ||
140 | return params.$el.is('.actionsheet a'); | ||
141 | } | ||
142 | return false; | ||
143 | }, | ||
144 | fn: function(e, params) { | ||
145 | params.$el.removeClass('active'); | ||
146 | |||
147 | var $target = params.$el.closest('.actionsheet'); | ||
148 | $target.actionsheet('hide', function() { | ||
149 | if (!params.$el.is('.dismiss')) { | ||
150 | params.$el.trigger('tap'); | ||
151 | } | ||
152 | }); | ||
153 | return false; | ||
154 | } | ||
155 | }); | ||
156 | } else { | ||
157 | console.error('Extension `jqt.actionsheet` failed to load. jQT not found'); | ||
158 | } | ||
159 | })($); | ||
diff --git a/frontend/gamma/js/JQTouch/extensions/jqt.autotitles.js b/frontend/gamma/js/JQTouch/extensions/jqt.autotitles.js new file mode 100644 index 0000000..94f3d9b --- a/dev/null +++ b/frontend/gamma/js/JQTouch/extensions/jqt.autotitles.js | |||
@@ -0,0 +1,52 @@ | |||
1 | /* | ||
2 | |||
3 | _/ _/_/ _/_/_/_/_/ _/ | ||
4 | _/ _/ _/ _/_/ _/ _/ _/_/_/ _/_/_/ | ||
5 | _/ _/ _/_/ _/ _/ _/ _/ _/ _/ _/ _/ | ||
6 | _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ | ||
7 | _/ _/_/ _/ _/ _/_/ _/_/_/ _/_/_/ _/ _/ | ||
8 | _/ | ||
9 | _/ | ||
10 | |||
11 | Created by David Kaneda <http://www.davidkaneda.com> | ||
12 | Maintained by Thomas Yip <http://beedesk.com/> | ||
13 | Sponsored by Sencha Labs <http://www.sencha.com/> | ||
14 | Special thanks to Jonathan Stark <http://www.jonathanstark.com/> | ||
15 | |||
16 | Documentation and issue tracking on GitHub <http://github.com/senchalabs/jQTouch/> | ||
17 | |||
18 | (c) 2009-2011 Sencha Labs | ||
19 | jQTouch may be freely distributed under the MIT license. | ||
20 | |||
21 | */ | ||
22 | |||
23 | (function($) { | ||
24 | if ($.jQTouch) | ||
25 | { | ||
26 | $.jQTouch.addExtension(function AutoTitles(jQT){ | ||
27 | |||
28 | var titleSelector='.toolbar h1'; | ||
29 | |||
30 | $(function(){ | ||
31 | $('#jqt').bind('pageAnimationStart', function(e, data){ | ||
32 | if (data.direction === 'in'){ | ||
33 | var $title = $(titleSelector, $(e.target)); | ||
34 | var $ref = $(e.target).data('referrer'); | ||
35 | if ($title.length && $ref && $title.text() === ''){ | ||
36 | $title.html($ref.text()); | ||
37 | } | ||
38 | } | ||
39 | }); | ||
40 | }); | ||
41 | |||
42 | function setTitleSelector(ts){ | ||
43 | titleSelector=ts; | ||
44 | } | ||
45 | |||
46 | return { | ||
47 | setTitleSelector: setTitleSelector | ||
48 | }; | ||
49 | |||
50 | }); | ||
51 | } | ||
52 | })($); | ||
diff --git a/frontend/gamma/js/JQTouch/extensions/jqt.floaty.js b/frontend/gamma/js/JQTouch/extensions/jqt.floaty.js new file mode 100644 index 0000000..c7e4485 --- a/dev/null +++ b/frontend/gamma/js/JQTouch/extensions/jqt.floaty.js | |||
@@ -0,0 +1,96 @@ | |||
1 | /* | ||
2 | |||
3 | _/ _/_/ _/_/_/_/_/ _/ | ||
4 | _/ _/ _/ _/_/ _/ _/ _/_/_/ _/_/_/ | ||
5 | _/ _/ _/_/ _/ _/ _/ _/ _/ _/ _/ _/ | ||
6 | _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ | ||
7 | _/ _/_/ _/ _/ _/_/ _/_/_/ _/_/_/ _/ _/ | ||
8 | _/ | ||
9 | _/ | ||
10 | |||
11 | Created by David Kaneda <http://www.davidkaneda.com> | ||
12 | Documentation and issue tracking on Google Code <http://code.google.com/p/jqtouch/> | ||
13 | |||
14 | Special thanks to Jonathan Stark <http://jonathanstark.com/> | ||
15 | and pinch/zoom <http://www.pinchzoom.com/> | ||
16 | |||
17 | (c) 2009 by jQTouch project members. | ||
18 | See LICENSE.txt for license. | ||
19 | |||
20 | */ | ||
21 | |||
22 | (function($) { | ||
23 | if ($.jQTouch) | ||
24 | { | ||
25 | $.jQTouch.addExtension(function Floaty(jQT){ | ||
26 | |||
27 | $.fn.makeFloaty = function(options){ | ||
28 | var defaults = { | ||
29 | align: 'top', | ||
30 | spacing: 20, | ||
31 | time: '.3s' | ||
32 | }; | ||
33 | |||
34 | var settings = $.extend({}, defaults, options); | ||
35 | |||
36 | settings.align = (settings.align == 'top') ? 'top' : 'bottom'; | ||
37 | |||
38 | return this.each(function(){ | ||
39 | var $el = $(this); | ||
40 | |||
41 | $el.css({ | ||
42 | '-webkit-transition': 'top ' + settings.time + ' ease-in-out', | ||
43 | 'display': 'block', | ||
44 | 'min-height': '0 !important' | ||
45 | }).data('settings', settings); | ||
46 | |||
47 | $(document).scroll(function(){ | ||
48 | if ($el.data('floatyVisible') === 'true') | ||
49 | { | ||
50 | $el.scrollFloaty(); | ||
51 | } | ||
52 | }); | ||
53 | $el.scrollFloaty(); | ||
54 | }); | ||
55 | }; | ||
56 | |||
57 | $.fn.scrollFloaty = function(){ | ||
58 | |||
59 | |||
60 | return this.each(function(){ | ||
61 | var $el = $(this); | ||
62 | var settings = $el.data('settings'); // Settings not being set as object w/Zepto | ||
63 | var wHeight = $('html').attr('clientHeight'); // WRONG | ||
64 | |||
65 | var newY = window.pageYOffset + | ||
66 | ((settings.align == 'top') ? | ||
67 | settings.spacing : wHeight - settings.spacing - $el.get(0).offsetHeight); | ||
68 | |||
69 | $el.css('top', newY).data('floatyVisible', true); | ||
70 | }); | ||
71 | }; | ||
72 | |||
73 | $.fn.hideFloaty = function(){ | ||
74 | return this.each(function(){ | ||
75 | var $el = $(this); | ||
76 | var oh = $el.get(0).offsetHeight; | ||
77 | |||
78 | $el.css('top', -oh-10).data('floatyVisible', false); | ||
79 | }); | ||
80 | }; | ||
81 | |||
82 | $.fn.toggleFloaty = function(){ | ||
83 | return this.each(function(){ | ||
84 | var $el = $(this); | ||
85 | if ($el.data('floatyVisible') === 'true'){ | ||
86 | $el.hideFloaty(); | ||
87 | } | ||
88 | else | ||
89 | { | ||
90 | $el.scrollFloaty(); | ||
91 | } | ||
92 | }); | ||
93 | }; | ||
94 | }); | ||
95 | } | ||
96 | })($); \ No newline at end of file | ||
diff --git a/frontend/gamma/js/JQTouch/extensions/jqt.location.js b/frontend/gamma/js/JQTouch/extensions/jqt.location.js new file mode 100644 index 0000000..9d53a1a --- a/dev/null +++ b/frontend/gamma/js/JQTouch/extensions/jqt.location.js | |||
@@ -0,0 +1,51 @@ | |||
1 | (function($) { | ||
2 | if ($.jQTouch) | ||
3 | { | ||
4 | $.jQTouch.addExtension(function Location(){ | ||
5 | |||
6 | var latitude, longitude, callback, callback2; | ||
7 | |||
8 | function updateLocation(fn, fn2) { | ||
9 | if (navigator.geolocation) | ||
10 | { | ||
11 | callback = fn; | ||
12 | callback2 = fn2; | ||
13 | navigator.geolocation.getCurrentPosition(savePosition, failResponse); | ||
14 | return true; | ||
15 | } else { | ||
16 | console.log('Device not capable of geo-location.'); | ||
17 | fn(false); | ||
18 | return false; | ||
19 | } | ||
20 | } | ||
21 | function failResponse(error){ | ||
22 | if (callback2) { | ||
23 | callback2(error); | ||
24 | } | ||
25 | } | ||
26 | function savePosition(position) { | ||
27 | latitude = position.coords.latitude; | ||
28 | longitude = position.coords.longitude; | ||
29 | if (callback) { | ||
30 | callback(getLocation()); | ||
31 | } | ||
32 | } | ||
33 | function getLocation() { | ||
34 | if (latitude && longitude) { | ||
35 | return { | ||
36 | latitude: latitude, | ||
37 | longitude: longitude | ||
38 | }; | ||
39 | |||
40 | } else { | ||
41 | console.log('No location available. Try calling updateLocation() first.'); | ||
42 | return false; | ||
43 | } | ||
44 | } | ||
45 | return { | ||
46 | updateLocation: updateLocation, | ||
47 | getLocation: getLocation | ||
48 | }; | ||
49 | }); | ||
50 | } | ||
51 | })($); \ No newline at end of file | ||
diff --git a/frontend/gamma/js/JQTouch/extensions/jqt.menusheet.js b/frontend/gamma/js/JQTouch/extensions/jqt.menusheet.js new file mode 100644 index 0000000..8d21aca --- a/dev/null +++ b/frontend/gamma/js/JQTouch/extensions/jqt.menusheet.js | |||
@@ -0,0 +1,137 @@ | |||
1 | /* | ||
2 | |||
3 | _/ _/_/ _/_/_/_/_/ _/ | ||
4 | _/ _/ _/ _/_/ _/ _/ _/_/_/ _/_/_/ | ||
5 | _/ _/ _/_/ _/ _/ _/ _/ _/ _/ _/ _/ | ||
6 | _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ | ||
7 | _/ _/_/ _/ _/ _/_/ _/_/_/ _/_/_/ _/ _/ | ||
8 | _/ | ||
9 | _/ | ||
10 | |||
11 | Documentation and issue tracking on Google Code <http://code.google.com/p/jqtouch/> | ||
12 | |||
13 | (c) 2012 by jQTouch project members. | ||
14 | See LICENSE.txt for license. | ||
15 | |||
16 | Author: Thomas Yip | ||
17 | */ | ||
18 | |||
19 | (function($) { | ||
20 | var src = $("head script").last().attr("src") || ''; | ||
21 | var scriptpath = src.split('?')[0].split('/').slice(0, -1).join('/')+'/'; | ||
22 | var csspath = scriptpath + 'jqt.menusheet.css'; | ||
23 | var link = $('<link href="' + csspath + '" rel="stylesheet">'); | ||
24 | $('head').append($(link)); | ||
25 | |||
26 | function hide(callback) { | ||
27 | var $target = $(this); | ||
28 | var data = $(this).data('menusheet'); | ||
29 | if (data.shown) { | ||
30 | $(this).data('menusheet', {}); | ||
31 | var $source = data.source; | ||
32 | $source.unbind('touchstart mousedown', data.closehandler); | ||
33 | $source.one('webkitTransitionEnd', function() { | ||
34 | $source.removeClass('inmotion transition in'); | ||
35 | $target.removeClass('inmotion out'); | ||
36 | !callback || callback.apply(this, arguments); | ||
37 | }); | ||
38 | |||
39 | $source.addClass('inmotion transition in'); | ||
40 | $target.addClass('inmotion out').removeClass('current'); | ||
41 | $('#jqt').removeClass('menuopened'); | ||
42 | } | ||
43 | return $target; | ||
44 | } | ||
45 | |||
46 | function show(callback) { | ||
47 | var $target = $(this); | ||
48 | var data = $(this).data('menusheet') || {}; | ||
49 | if (!data.shown) { | ||
50 | var $source = $('#jqt .current:not(.menusheet)'); | ||
51 | var closehandler = function() { | ||
52 | $target.menusheet('hide'); | ||
53 | return false; | ||
54 | }; | ||
55 | |||
56 | $source.one('webkitTransitionEnd', function() { | ||
57 | $source.one('touchstart mousedown', closehandler); | ||
58 | $source.removeClass('inmotion transition out'); | ||
59 | $target.removeClass('inmotion in'); | ||
60 | !callback || callback.apply(this, arguments); | ||
61 | }); | ||
62 | |||
63 | data.shown = true; | ||
64 | data.closehandler = closehandler; | ||
65 | data.source = $source; | ||
66 | $(this).data('menusheet', data); | ||
67 | |||
68 | $source.addClass('inmotion transition out'); | ||
69 | $target.addClass('current in'); | ||
70 | $('#jqt').addClass('menuopened'); | ||
71 | } | ||
72 | return $target; | ||
73 | } | ||
74 | |||
75 | var methods = { | ||
76 | init: function(options) { | ||
77 | $(this).addClass('menusheet'); | ||
78 | $(this).data({shown: false}); | ||
79 | }, | ||
80 | show: show, | ||
81 | hide: hide | ||
82 | }; | ||
83 | |||
84 | $.fn.menusheet = function(method) { | ||
85 | if (methods[method]) { | ||
86 | if ($(this).is('.menusheet')) { | ||
87 | return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); | ||
88 | } else { | ||
89 | var msg = 'Target is not a `menusheet`. Action `' + method + '` is ignored.'; | ||
90 | console.warn(msg); | ||
91 | } | ||
92 | } else if ( typeof method === 'object' || ! method ) { | ||
93 | return methods.init.apply(this, arguments); | ||
94 | } else { | ||
95 | $.error( 'Method ' + method + ' does not exist on jQuery.tooltip' ); | ||
96 | } | ||
97 | }; | ||
98 | |||
99 | if ($.jQTouch) { | ||
100 | $.jQTouch.addTapHandler({ | ||
101 | name: 'open-menusheet', | ||
102 | isSupported: function(e, params) { | ||
103 | return params.$el.is('.menu'); | ||
104 | }, | ||
105 | fn: function(e, params) { | ||
106 | params.$el.removeClass('active'); | ||
107 | |||
108 | var $target = $(params.hash); | ||
109 | $target.menusheet('show'); | ||
110 | |||
111 | return false; | ||
112 | } | ||
113 | }); | ||
114 | $.jQTouch.addTapHandler({ | ||
115 | name: 'follow-menulink', | ||
116 | isSupported: function(e, params) { | ||
117 | if ($('#jqt').hasClass('menuopened')) { | ||
118 | return params.$el.is('.menusheet a'); | ||
119 | } | ||
120 | return false; | ||
121 | }, | ||
122 | fn: function(e, params) { | ||
123 | params.$el.removeClass('active'); | ||
124 | |||
125 | var $target = params.$el.closest('.menusheet'); | ||
126 | $target.menusheet('hide', function() { | ||
127 | if (!params.$el.is('.dismiss')) { | ||
128 | params.$el.trigger('tap'); | ||
129 | } | ||
130 | }); | ||
131 | return false; | ||
132 | } | ||
133 | }); | ||
134 | } else { | ||
135 | console.error('Extension `jqt.menusheet` failed to load. jQT not found'); | ||
136 | } | ||
137 | })($); | ||
diff --git a/frontend/gamma/js/JQTouch/extensions/jqt.offline.js b/frontend/gamma/js/JQTouch/extensions/jqt.offline.js new file mode 100644 index 0000000..b333a16 --- a/dev/null +++ b/frontend/gamma/js/JQTouch/extensions/jqt.offline.js | |||
@@ -0,0 +1,97 @@ | |||
1 | /* | ||
2 | |||
3 | _/ _/_/ _/_/_/_/_/ _/ | ||
4 | _/ _/ _/ _/_/ _/ _/ _/_/_/ _/_/_/ | ||
5 | _/ _/ _/_/ _/ _/ _/ _/ _/ _/ _/ _/ | ||
6 | _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ | ||
7 | _/ _/_/ _/ _/ _/_/ _/_/_/ _/_/_/ _/ _/ | ||
8 | _/ | ||
9 | _/ | ||
10 | |||
11 | Created by David Kaneda <http://www.davidkaneda.com> | ||
12 | Documentation and issue tracking on Google Code <http://code.google.com/p/jqtouch/> | ||
13 | |||
14 | Special thanks to Jonathan Stark <http://jonathanstark.com/> | ||
15 | |||
16 | Lots of this code is specifically derived from Jonathan's book, | ||
17 | "Building iPhone Apps with HTML, CSS, and JavaScript" | ||
18 | |||
19 | (c) 2009 by jQTouch project members. | ||
20 | See LICENSE.txt for license. | ||
21 | |||
22 | */ | ||
23 | |||
24 | (function($) { | ||
25 | if ($.jQTouch) | ||
26 | { | ||
27 | $.jQTouch.addExtension(function Offline(){ | ||
28 | |||
29 | // Convenience array of status values | ||
30 | var cacheStatusValues = []; | ||
31 | cacheStatusValues[0] = 'uncached'; | ||
32 | cacheStatusValues[1] = 'idle'; | ||
33 | cacheStatusValues[2] = 'checking'; | ||
34 | cacheStatusValues[3] = 'downloading'; | ||
35 | cacheStatusValues[4] = 'updateready'; | ||
36 | cacheStatusValues[5] = 'obsolete'; | ||
37 | |||
38 | // Listeners for all possible events | ||
39 | var cache = window.applicationCache; | ||
40 | cache.addEventListener('cached', logEvent, false); | ||
41 | cache.addEventListener('checking', logEvent, false); | ||
42 | cache.addEventListener('downloading', logEvent, false); | ||
43 | cache.addEventListener('error', logEvent, false); | ||
44 | cache.addEventListener('noupdate', logEvent, false); | ||
45 | cache.addEventListener('obsolete', logEvent, false); | ||
46 | cache.addEventListener('progress', logEvent, false); | ||
47 | cache.addEventListener('updateready', logEvent, false); | ||
48 | |||
49 | // Log every event to the console | ||
50 | function logEvent(e) { | ||
51 | var online, status, type, message; | ||
52 | online = (isOnline()) ? 'yes' : 'no'; | ||
53 | status = cacheStatusValues[cache.status]; | ||
54 | type = e.type; | ||
55 | message = 'online: ' + online; | ||
56 | message+= ', event: ' + type; | ||
57 | message+= ', status: ' + status; | ||
58 | if (type == 'error' && navigator.onLine) { | ||
59 | message+= ' There was an unknown error, check your Cache Manifest.'; | ||
60 | } | ||
61 | console.log(message); | ||
62 | } | ||
63 | |||
64 | function isOnline() { | ||
65 | return navigator.onLine; | ||
66 | } | ||
67 | |||
68 | if (!$('html').attr('manifest')) { | ||
69 | console.log('No Cache Manifest listed on the <html> tag.') | ||
70 | } | ||
71 | |||
72 | // Swap in newly download files when update is ready | ||
73 | cache.addEventListener('updateready', function(e){ | ||
74 | // Don't perform "swap" if this is the first cache | ||
75 | if (cacheStatusValues[cache.status] != 'idle') { | ||
76 | cache.swapCache(); | ||
77 | console.log('Swapped/updated the Cache Manifest.'); | ||
78 | } | ||
79 | } | ||
80 | , false); | ||
81 | |||
82 | // These two functions check for updates to the manifest file | ||
83 | function checkForUpdates(){ | ||
84 | cache.update(); | ||
85 | } | ||
86 | function autoCheckForUpdates(){ | ||
87 | setInterval(function(){cache.update()}, 10000); | ||
88 | } | ||
89 | |||
90 | return { | ||
91 | isOnline: isOnline, | ||
92 | checkForUpdates: checkForUpdates, | ||
93 | autoCheckForUpdates: autoCheckForUpdates | ||
94 | } | ||
95 | }); | ||
96 | } | ||
97 | })(jQuery); \ No newline at end of file | ||
diff --git a/frontend/gamma/js/JQTouch/extensions/jqt.themeswitcher.js b/frontend/gamma/js/JQTouch/extensions/jqt.themeswitcher.js new file mode 100755 index 0000000..ef3a75d --- a/dev/null +++ b/frontend/gamma/js/JQTouch/extensions/jqt.themeswitcher.js | |||
@@ -0,0 +1,123 @@ | |||
1 | /* | ||
2 | |||
3 | _/ _/_/ _/_/_/_/_/ _/ | ||
4 | _/ _/ _/ _/_/ _/ _/ _/_/_/ _/_/_/ | ||
5 | _/ _/ _/_/ _/ _/ _/ _/ _/ _/ _/ _/ | ||
6 | _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ | ||
7 | _/ _/_/ _/ _/ _/_/ _/_/_/ _/_/_/ _/ _/ | ||
8 | _/ | ||
9 | _/ | ||
10 | |||
11 | Documentation and issue tracking on Google Code <http://code.google.com/p/jqtouch/> | ||
12 | |||
13 | (c) 2011 by jQTouch project members. | ||
14 | See LICENSE.txt for license. | ||
15 | |||
16 | */ | ||
17 | |||
18 | (function($) { | ||
19 | if ($.jQTouch) { | ||
20 | |||
21 | var scriptpath = $("script").last().attr("src").split('?')[0].split('/').slice(0, -1).join('/')+'/'; | ||
22 | |||
23 | $.jQTouch.addExtension(function ThemeSwitcher(jQT) { | ||
24 | |||
25 | var current, | ||
26 | link, | ||
27 | titles = {}, | ||
28 | defaults = { | ||
29 | themeStyleSelector: 'link[rel="stylesheet"][title]', | ||
30 | themeIncluded: [ | ||
31 | {title: 'jQTouch', href: scriptpath + '../themes/css/jqtouch.css'}, | ||
32 | {title: 'Apple', href: scriptpath + '../themes/css/apple.css'}, | ||
33 | {title: 'Vanilla', href: scriptpath + '../themes/css/vanilla.css'} | ||
34 | |||
35 | ] | ||
36 | }, | ||
37 | options = $.extend({}, defaults, jQT.settings); | ||
38 | |||
39 | function setStyleState(item, title) { | ||
40 | var $item = $(item); | ||
41 | |||
42 | if ($item.attr('title') === title) { | ||
43 | item.disabled = false; // workaround for Firefox on Zepto | ||
44 | $item.removeAttr('disabled'); | ||
45 | } else { | ||
46 | item.disabled = true; // workaround for Firefox on Zepto | ||
47 | $item.attr('disabled', true); | ||
48 | } | ||
49 | } | ||
50 | |||
51 | function initializeStyleState(item, title) { | ||
52 | // and, workaround for WebKit by initializing the 'disabled' attribute | ||
53 | if (!current) { | ||
54 | current = title; | ||
55 | } | ||
56 | setStyleState(item, current); | ||
57 | } | ||
58 | |||
59 | // public | ||
60 | function switchStyle(title) { | ||
61 | current = title; | ||
62 | $(options.themeStyleSelector).each(function(i, item) { | ||
63 | setStyleState(item, title); | ||
64 | }); | ||
65 | } | ||
66 | |||
67 | // collect title names, from <head> | ||
68 | $(options.themeStyleSelector).each(function(i, item) { | ||
69 | var $item = $(item); | ||
70 | var title = $item.attr('title'); | ||
71 | |||
72 | titles[title] = true; | ||
73 | |||
74 | initializeStyleState(item, title); | ||
75 | }); | ||
76 | |||
77 | // add included theme | ||
78 | for (var i=0; i < options.themeIncluded.length; i++) { | ||
79 | var hash = options.themeIncluded[i]; | ||
80 | if (!(hash.title in titles)) { | ||
81 | link = $('<link title="' + hash.title + '" href="' + hash.href + '" rel="stylesheet">'); | ||
82 | $('head').append($(link)); | ||
83 | |||
84 | titles[hash.title] = true; | ||
85 | |||
86 | initializeStyleState(link, hash.title); | ||
87 | } | ||
88 | } | ||
89 | |||
90 | if (options.themeSelectionSelector) { | ||
91 | // create UI items | ||
92 | for (var title in titles) { | ||
93 | var $item = $('<li><a href="#" data-title="' + title + '">' + title + '</a></li>'); | ||
94 | $(options.themeSelectionSelector).append($item); | ||
95 | } | ||
96 | |||
97 | // bind to UI items | ||
98 | $(options.themeSelectionSelector).delegate('* > a', 'tap', function(e) { | ||
99 | e.preventDefault(); | ||
100 | e.stopPropagation(); | ||
101 | |||
102 | var $a = $(this).closest('a'); | ||
103 | $a.removeClass('active'); | ||
104 | switchStyle($a.attr('data-title')); | ||
105 | |||
106 | // poor-man simulation of radio button behaviour | ||
107 | $(options.themeSelectionSelector).find('a').removeClass('selected'); | ||
108 | $a.addClass('selected'); | ||
109 | }); | ||
110 | |||
111 | // poor-man simulation of radio button behaviour | ||
112 | $(options.themeSelectionSelector).closest('#jqt > *').bind('pageAnimationEnd', function(e, data){ | ||
113 | if (data.direction === 'in') { | ||
114 | $(options.themeSelectionSelector).find('a[data-title="' + current + '"]').addClass('selected'); | ||
115 | } | ||
116 | }); | ||
117 | } | ||
118 | |||
119 | return {switchStyle: switchStyle}; | ||
120 | |||
121 | }); | ||
122 | } | ||
123 | })($); | ||