browser_tzone 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,4 +12,6 @@
12
12
  //
13
13
  //= require jquery
14
14
  //= require jquery_ujs
15
- //= require_tree .
15
+ //= require jquery.cookie
16
+ //= require detect_timezone
17
+ //= require browser_tzone/set_time_zone
@@ -0,0 +1,6 @@
1
+ window.BrowserTZone ||= {}
2
+ BrowserTZone.setCookie = ->
3
+ $.cookie "browser.timezone", jstz.determine().name(), { expires: 365, path: '/' }
4
+
5
+ jQuery ->
6
+ BrowserTZone.setCookie()
@@ -0,0 +1,72 @@
1
+ /*!
2
+ * jQuery Cookie Plugin v1.3
3
+ * https://github.com/carhartl/jquery-cookie
4
+ *
5
+ * Copyright 2011, Klaus Hartl
6
+ * Dual licensed under the MIT or GPL Version 2 licenses.
7
+ * http://www.opensource.org/licenses/mit-license.php
8
+ * http://www.opensource.org/licenses/GPL-2.0
9
+ */
10
+ (function ($, document, undefined) {
11
+
12
+ var pluses = /\+/g;
13
+
14
+ function raw(s) {
15
+ return s;
16
+ }
17
+
18
+ function decoded(s) {
19
+ return decodeURIComponent(s.replace(pluses, ' '));
20
+ }
21
+
22
+ var config = $.cookie = function (key, value, options) {
23
+
24
+ // write
25
+ if (value !== undefined) {
26
+ options = $.extend({}, config.defaults, options);
27
+
28
+ if (value === null) {
29
+ options.expires = -1;
30
+ }
31
+
32
+ if (typeof options.expires === 'number') {
33
+ var days = options.expires, t = options.expires = new Date();
34
+ t.setDate(t.getDate() + days);
35
+ }
36
+
37
+ value = config.json ? JSON.stringify(value) : String(value);
38
+
39
+ return (document.cookie = [
40
+ encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value),
41
+ options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
42
+ options.path ? '; path=' + options.path : '',
43
+ options.domain ? '; domain=' + options.domain : '',
44
+ options.secure ? '; secure' : ''
45
+ ].join(''));
46
+ }
47
+
48
+ // read
49
+ var decode = config.raw ? raw : decoded;
50
+ var cookies = document.cookie.split('; ');
51
+ for (var i = 0, l = cookies.length; i < l; i++) {
52
+ var parts = cookies[i].split('=');
53
+ if (decode(parts.shift()) === key) {
54
+ var cookie = decode(parts.join('='));
55
+ return config.json ? JSON.parse(cookie) : cookie;
56
+ }
57
+ }
58
+
59
+ return null;
60
+ };
61
+
62
+ config.defaults = {};
63
+
64
+ $.removeCookie = function (key, options) {
65
+ if ($.cookie(key) !== null) {
66
+ $.cookie(key, null, options);
67
+ return true;
68
+ }
69
+ return false;
70
+ };
71
+
72
+ })(jQuery, document);
@@ -1,3 +1,3 @@
1
1
  module BrowserTzone
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browser_tzone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -67,8 +67,9 @@ extensions: []
67
67
  extra_rdoc_files: []
68
68
  files:
69
69
  - app/assets/javascripts/browser_tzone/application.js
70
- - app/assets/javascripts/browser_tzone/detect_timezone.js
71
- - app/assets/javascripts/set_time_zone.js.coffee
70
+ - app/assets/javascripts/browser_tzone/set_time_zone.js.coffee
71
+ - app/assets/javascripts/detect_timezone.js
72
+ - app/assets/javascripts/jquery.cookie.js
72
73
  - app/assets/stylesheets/browser_tzone/application.css
73
74
  - app/controllers/browser_tzone/application_controller.rb
74
75
  - app/helpers/browser_tzone/application_helper.rb
@@ -1,2 +0,0 @@
1
- jQuery ->
2
- $.cookie "browser.timezone", jstz.determine().name()