iam 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -31,7 +31,7 @@ Also you may log in using user_id (e.g. 42):
31
31
  Add gem to your gemfile:
32
32
 
33
33
  ```ruby
34
- gem 'iam', '~> 0.1.8'
34
+ gem 'iam', '~> 0.1.9'
35
35
  ```
36
36
  ##Configuration
37
37
 
data/Rakefile CHANGED
@@ -16,22 +16,29 @@ desc 'Precompile vendor assets'
16
16
  task :precompile do |t|
17
17
  precompile_sass
18
18
  precompile_coffee
19
+ uglify_js
19
20
  end
20
21
 
21
22
  def precompile_sass
22
- Dir[File.join('**', '*.sass')].each do |file|
23
+ Dir[File.join('vendor', 'assets', 'stylesheets', '*.sass')].each do |file|
23
24
  system "sass #{file} > #{file.gsub('.sass', '')}"
24
25
  p "File #{file} precompiled"
25
26
  end
26
27
  end
27
28
 
28
29
  def precompile_coffee
30
+ Dir[File.join('vendor', 'assets', 'javascripts', '*.coffee')].each do |file|
31
+ system "coffee -c #{file}"
32
+ p "File #{file} precompiled"
33
+ end
34
+ end
35
+
36
+ def uglify_js
29
37
  require 'uglifier'
30
38
 
31
- Dir[File.join('**', '*.coffee')].each do |file|
32
- js_code = %x(coffee -p -c #{file})
33
- js_file = file.gsub /coffee\Z/, 'js'
34
- File.open(js_file, 'w') { |f| f << Uglifier.compile(js_code) }
35
- p "File #{file} precompiled"
39
+ Dir[File.join('vendor', 'assets', 'javascripts', '*.js')].each do |file|
40
+ uglified_file = file.gsub /js\Z/, 'ujs'
41
+ File.open(uglified_file, 'w') { |f| f << Uglifier.compile(File.read(file)) }
42
+ p "File #{file} uglified"
36
43
  end
37
44
  end
@@ -1,3 +1,3 @@
1
1
  module Iam
2
- VERSION = '0.1.8'
2
+ VERSION = '0.1.9'
3
3
  end
@@ -10,7 +10,7 @@ module Rack
10
10
  end
11
11
 
12
12
  def js_code
13
- "<script type='text/javascript'>#{typed_asset('javascripts', 'iam.js', 'jquery.cookie.js')}</script>"
13
+ "<script type='text/javascript'>#{typed_asset('javascripts', 'iam.ujs', 'jquery.cookie.ujs')}</script>"
14
14
  end
15
15
 
16
16
  def typed_asset(type, *files)
@@ -1,2 +1,101 @@
1
1
  // Generated by CoffeeScript 1.3.3
2
- (function(){$(function(){var e,t,n,r,i,s,o,u,a,f,l,c,h,p;return e=$("#iam-menu"),p="/iam/log_in_as/:id",c="/iam/menu",o=!1,s="",t=["alt","ctrl","shift"],i=function(){return $(".iam-settings-header").on("click",function(){return $(".iam-settings").toggle()}),$("#iam-menu").on("click","td",function(){var e,t;e=$(this).parents("tr"),t=e.attr("href");if(t)return l(t)}),$.each(t,function(){var e,t;return e=$(".iam-"+this+"-settings input"),t="iam-"+this+"-checked",e[0].checked=$.cookie(t)==="true",e.on("click",function(){return $.cookie(t,this.checked)})})},r=function(e){var t;return t=$("<div class='iam-notice'>"+e+"</div>"),$("body").append(t),t.fadeIn(200).delay(1e3).fadeOut(600)},l=function(t){return $.post(t,function(t){return e.hide(),window.location.reload(),r(t.notice)})},a=function(e){return String.fromCharCode(e)==="À"},n=function(e){var n,r,i,s;for(i=0,s=t.length;i<s;i++){n=t[i],r=$.cookie("iam-"+n+"-checked")==="true";if(r!==e[""+n+"Key"])return!1}return!0},u=function(){return $(document.getSelection().focusNode).find("input, textarea").length>0},h=function(e){var t;if(e.match(/^\d+$/))return t=p.replace(/:id/,e),l(t);if(e)return r(""+e+" is invalid id.")},f=function(){return o?(h(s),$("#iam-menu").remove()):$.get(c,function(e){return $("body").append(e),i()}),s=""},$(document).on("keydown",function(t){var r;if(!u()&&a(t.keyCode)&&n(t))return f(),o=!o,e.toggle();if(48<=(r=t.keyCode)&&r<=57)return s+=String.fromCharCode(t.keyCode)})})}).call(this);
2
+ (function() {
3
+
4
+ $(function() {
5
+ var $menu, controlKeys, controlKeysMatch, iamNotice, initialize, input, inputMode, inputSelected, isTilde, logInByInput, logInByLink, menuLink, processInput, templateLink;
6
+ $menu = $('#iam-menu');
7
+ templateLink = '/iam/log_in_as/:id';
8
+ menuLink = '/iam/menu';
9
+ inputMode = false;
10
+ input = '';
11
+ controlKeys = ['alt', 'ctrl', 'shift'];
12
+ initialize = function() {
13
+ $('.iam-settings-header').on('click', function() {
14
+ return $('.iam-settings').toggle();
15
+ });
16
+ $('#iam-menu').on('click', 'td', function() {
17
+ var $tr, link;
18
+ $tr = $(this).parents('tr');
19
+ link = $tr.attr('href');
20
+ if (link) {
21
+ return logInByLink(link);
22
+ }
23
+ });
24
+ return $.each(controlKeys, function() {
25
+ var $checkbox, cookieName;
26
+ $checkbox = $(".iam-" + this + "-settings input");
27
+ cookieName = "iam-" + this + "-checked";
28
+ $checkbox[0].checked = $.cookie(cookieName) === 'true';
29
+ return $checkbox.on('click', function() {
30
+ return $.cookie(cookieName, this.checked);
31
+ });
32
+ });
33
+ };
34
+ iamNotice = function(notice) {
35
+ var $notice;
36
+ $notice = $("<div class='iam-notice'>" + notice + "</div>");
37
+ $('body').append($notice);
38
+ return $notice.fadeIn(200).delay(1000).fadeOut(600);
39
+ };
40
+ logInByLink = function(link) {
41
+ return $.post(link, function(data) {
42
+ $menu.hide();
43
+ window.location.reload();
44
+ return iamNotice(data.notice);
45
+ });
46
+ };
47
+ isTilde = function(code) {
48
+ return String.fromCharCode(code) === 'À';
49
+ };
50
+ controlKeysMatch = function(e) {
51
+ var key, keyOn, _i, _len;
52
+ for (_i = 0, _len = controlKeys.length; _i < _len; _i++) {
53
+ key = controlKeys[_i];
54
+ keyOn = $.cookie("iam-" + key + "-checked") === 'true';
55
+ if (keyOn !== e["" + key + "Key"]) {
56
+ return false;
57
+ }
58
+ }
59
+ return true;
60
+ };
61
+ inputSelected = function() {
62
+ return $(document.getSelection().focusNode).find('input, textarea').length > 0;
63
+ };
64
+ processInput = function(input) {
65
+ var link;
66
+ if (input.match(/^\d+$/)) {
67
+ link = templateLink.replace(/:id/, input);
68
+ return logInByLink(link);
69
+ } else {
70
+ if (input) {
71
+ return iamNotice("" + input + " is invalid id.");
72
+ }
73
+ }
74
+ };
75
+ logInByInput = function() {
76
+ if (inputMode) {
77
+ processInput(input);
78
+ $('#iam-menu').remove();
79
+ } else {
80
+ $.get(menuLink, function(menu) {
81
+ $('body').append(menu);
82
+ return initialize();
83
+ });
84
+ }
85
+ return input = '';
86
+ };
87
+ return $(document).on('keydown', function(e) {
88
+ var _ref;
89
+ if (!inputSelected() && isTilde(e.keyCode) && controlKeysMatch(e)) {
90
+ logInByInput();
91
+ inputMode = !inputMode;
92
+ return $menu.toggle();
93
+ } else {
94
+ if ((48 <= (_ref = e.keyCode) && _ref <= 57)) {
95
+ return input += String.fromCharCode(e.keyCode);
96
+ }
97
+ }
98
+ });
99
+ });
100
+
101
+ }).call(this);
@@ -0,0 +1,2 @@
1
+ // Generated by CoffeeScript 1.3.3
2
+ (function(){$(function(){var e,t,n,r,i,s,o,u,a,f,l,c,h,p;return e=$("#iam-menu"),p="/iam/log_in_as/:id",c="/iam/menu",o=!1,s="",t=["alt","ctrl","shift"],i=function(){return $(".iam-settings-header").on("click",function(){return $(".iam-settings").toggle()}),$("#iam-menu").on("click","td",function(){var e,t;e=$(this).parents("tr"),t=e.attr("href");if(t)return l(t)}),$.each(t,function(){var e,t;return e=$(".iam-"+this+"-settings input"),t="iam-"+this+"-checked",e[0].checked=$.cookie(t)==="true",e.on("click",function(){return $.cookie(t,this.checked)})})},r=function(e){var t;return t=$("<div class='iam-notice'>"+e+"</div>"),$("body").append(t),t.fadeIn(200).delay(1e3).fadeOut(600)},l=function(t){return $.post(t,function(t){return e.hide(),window.location.reload(),r(t.notice)})},a=function(e){return String.fromCharCode(e)==="À"},n=function(e){var n,r,i,s;for(i=0,s=t.length;i<s;i++){n=t[i],r=$.cookie("iam-"+n+"-checked")==="true";if(r!==e[""+n+"Key"])return!1}return!0},u=function(){return $(document.getSelection().focusNode).find("input, textarea").length>0},h=function(e){var t;if(e.match(/^\d+$/))return t=p.replace(/:id/,e),l(t);if(e)return r(""+e+" is invalid id.")},f=function(){return o?(h(s),$("#iam-menu").remove()):$.get(c,function(e){return $("body").append(e),i()}),s=""},$(document).on("keydown",function(t){var r;if(!u()&&a(t.keyCode)&&n(t))return f(),o=!o,e.toggle();if(48<=(r=t.keyCode)&&r<=57)return s+=String.fromCharCode(t.keyCode)})})}).call(this);
@@ -0,0 +1,10 @@
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(e,t,n){function i(e){return e}function s(e){return decodeURIComponent(e.replace(r," "))}var r=/\+/g,o=e.cookie=function(r,u,a){if(u!==n){a=e.extend({},o.defaults,a),u===null&&(a.expires=-1);if(typeof a.expires=="number"){var f=a.expires,l=a.expires=new Date;l.setDate(l.getDate()+f)}return u=o.json?JSON.stringify(u):String(u),t.cookie=[encodeURIComponent(r),"=",o.raw?u:encodeURIComponent(u),a.expires?"; expires="+a.expires.toUTCString():"",a.path?"; path="+a.path:"",a.domain?"; domain="+a.domain:"",a.secure?"; secure":""].join("")}var c=o.raw?i:s,h=t.cookie.split("; ");for(var p=0,d=h.length;p<d;p++){var v=h[p].split("=");if(c(v.shift())===r){var m=c(v.join("="));return o.json?JSON.parse(m):m}}return null};o.defaults={},e.removeCookie=function(t,n){return e.cookie(t)!==null?(e.cookie(t,null,n),!0):!1}})(jQuery,document);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iam
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -267,7 +267,9 @@ files:
267
267
  - spec/support/database_cleaner.rb
268
268
  - vendor/assets/javascripts/iam.coffee
269
269
  - vendor/assets/javascripts/iam.js
270
+ - vendor/assets/javascripts/iam.ujs
270
271
  - vendor/assets/javascripts/jquery.cookie.js
272
+ - vendor/assets/javascripts/jquery.cookie.ujs
271
273
  - vendor/assets/stylesheets/.sass-cache/99c7326b15538dc9b4651af91a5f076fe779d5ec/iam.css.sassc
272
274
  - vendor/assets/stylesheets/iam.css
273
275
  - vendor/assets/stylesheets/iam.css.sass