javascript_util_asset_pack 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,40 +1,40 @@
1
1
  class JavascriptUtilAssetPackGenerator < Rails::Generators::Base
2
2
  source_root File.expand_path('../templates', __FILE__)
3
-
3
+
4
4
  def manifest
5
5
  copy_spinner_gif
6
6
  update_layout_add_spinner
7
7
  update_layout_add_rails_env_to_js
8
- update_application_js
8
+ update_application_js
9
9
  run_safe_logger_generator
10
10
  end
11
-
12
- private
13
-
11
+
12
+ private
13
+
14
14
  def run_safe_logger_generator
15
15
  generate "javascript_safe_logger"
16
16
  end
17
-
17
+
18
18
  def update_application_js
19
- inject_into_file "app/assets/javascripts/application.js", "//= require util_pack\n", :before => "//= require_tree .\n",
20
- end
21
-
19
+ inject_into_file "app/assets/javascripts/application.js", "//= require util_pack\n", :before => "//= require_tree .\n"
20
+ end
21
+
22
22
  def copy_spinner_gif
23
23
  copy_file 'spinner.gif', 'app/assets/images/spinner.gif'
24
24
  end
25
-
25
+
26
26
  def update_layout_add_spinner
27
27
  inject_into_file "app/views/layouts/application.html.erb", :before => "</body>\n" do
28
28
  " <%= image_tag 'spinner.gif', :alt => 'Spinner Icon', :id => 'spinner', :style => 'display:none' %>\n"
29
29
  end
30
30
  end
31
-
31
+
32
32
  def update_layout_add_rails_env_to_js
33
33
  inject_into_file "app/views/layouts/application.html.erb", :before => "</head>\n" do
34
34
  <<-CONTENT
35
35
  <script>
36
36
  window.Rails = window.Rails || {};
37
- window.Rails.env = "<%= Rails.env.upcase %>";
37
+ window.Rails.env = "<%= Rails.env.upcase %>";
38
38
  </script>
39
39
  CONTENT
40
40
  end
@@ -1,5 +1,5 @@
1
1
  module JavascriptUtilAssetPack
2
+ # auto-wire to rails host
2
3
  class Engine < Rails::Engine
3
- # auto-wire to rails host
4
4
  end
5
5
  end
@@ -1,3 +1,3 @@
1
1
  module JavascriptUtilAssetPack
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 9
9
- version: 0.0.9
8
+ - 10
9
+ version: 0.0.10
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jesse House
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2012-03-01 00:00:00 -08:00
17
+ date: 2012-12-01 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -108,21 +108,13 @@ extensions: []
108
108
  extra_rdoc_files: []
109
109
 
110
110
  files:
111
- - .gitignore
112
- - Gemfile
113
- - README.rdoc
114
- - Rakefile
115
- - javascript_util_asset_pack.gemspec
116
- - lib/generators/javascript_util_asset_pack/USAGE
117
111
  - lib/generators/javascript_util_asset_pack/javascript_util_asset_pack_generator.rb
118
112
  - lib/generators/javascript_util_asset_pack/templates/spinner.gif
119
- - lib/javascript_util_asset_pack.rb
113
+ - lib/generators/javascript_util_asset_pack/USAGE
120
114
  - lib/javascript_util_asset_pack/engine.rb
121
115
  - lib/javascript_util_asset_pack/version.rb
122
- - vendor/assets/javascripts/util_pack/ajax_form.coffee
123
- - vendor/assets/javascripts/util_pack/index.js
124
- - vendor/assets/javascripts/util_pack/jquery_ajax_error.coffee
125
- - vendor/assets/javascripts/util_pack/spinner.coffee
116
+ - lib/javascript_util_asset_pack.rb
117
+ - README.rdoc
126
118
  has_rdoc: true
127
119
  homepage: https://github.com/house9/javascript_util_asset_pack
128
120
  licenses: []
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- pkg/*
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- # Specify your gem's dependencies in javascript_util_asset_pack.gemspec
4
- gemspec
data/Rakefile DELETED
@@ -1 +0,0 @@
1
- require 'bundler/gem_tasks'
@@ -1,25 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "javascript_util_asset_pack/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "javascript_util_asset_pack"
7
- s.version = JavascriptUtilAssetPack::VERSION
8
- s.authors = ["Jesse House"]
9
- s.email = ["jesse.house@gmail.com"]
10
- s.homepage = "https://github.com/house9/javascript_util_asset_pack"
11
- s.summary = %q{
12
- Rails 3.1 javascript Util asset pack, show hide spinner, global jquery error handler, etc...
13
- }
14
- s.description = File.open('README.rdoc') { |f| f.read }
15
-
16
- s.rubyforge_project = "javascript_util_asset_pack"
17
-
18
- s.add_dependency 'rails', '~> 3.1'
19
- s.add_dependency 'javascript_safe_logger', '~> 0.0.4'
20
-
21
- s.files = `git ls-files`.split("\n")
22
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
- s.require_paths = ["lib"]
25
- end
@@ -1,15 +0,0 @@
1
- class AjaxForm
2
- constructor: (selector, callback = null) ->
3
- $(selector).submit (e) ->
4
- e.preventDefault()
5
- form = this
6
- success = if callback? then callback else () -> log "no success callback"
7
-
8
- $.ajax $(form).attr('action'),
9
- type: "POST"
10
- data: $(form).serialize()
11
- success: success
12
-
13
- window.Util ?= {}
14
- window.Util.AjaxForm = AjaxForm
15
-
@@ -1,3 +0,0 @@
1
- //= require ./spinner
2
- //= require ./ajax_form
3
- //= require ./jquery_ajax_error
@@ -1,41 +0,0 @@
1
- jQuery(document).ajaxError (event, xhr, settings, exception) ->
2
- baseMessage = "Error: "
3
- friendly = baseMessage
4
- local = "#{baseMessage}#{xhr.status}, #{xhr.statusText} #{exception}\n#{settings.url}"
5
-
6
- if xhr.status is 404
7
- friendly = "#{friendly}Page not found"
8
- else if xhr.status is 401
9
- friendly = "#{friendly}Access Denied"
10
- else if xhr.status is 422
11
- friendly = "Your submission has one or more errors. \n\nPlease correct the following issues: \n"
12
- validationErrors = jQuery.parseJSON(xhr.responseText)
13
- if jQuery.isArray(validationErrors)
14
- friendly = friendly + " - #{error}\n" for error in validationErrors
15
- local = friendly + "\n\n"
16
- else
17
- friendly = "#{friendly}an exception has occurred\nPlease try again"
18
-
19
- window.Util.spinner.hide()
20
-
21
- if window.Rails?.env is "DEVELOPMENT"
22
- contentType = xhr.getResponseHeader("content-type")
23
- if contentType?.indexOf('html') > -1
24
- body = "<div>#{xhr.responseText}</div>"
25
- fragment = $(body).find "h1"
26
- local = "#{local} \n#{fragment.text()}"
27
- fragment = $(body).find "pre"
28
-
29
- if fragment.length > 0
30
- fragment.each () -> local = "#{local}\n#{$(this).text()}"
31
-
32
- else
33
- # json, text, xml, etc... add specific parsing later if needed
34
- local = "#{local}"
35
-
36
- lengthOfVisibleErrorMessage = if local.length > 350 then 350 else local.length
37
- message = local.substring(0, lengthOfVisibleErrorMessage)
38
- alert "#{message}...\n\n - Check browser console for more info.\n - This message for development only."
39
-
40
- else
41
- alert friendly
@@ -1,31 +0,0 @@
1
- class Spinner
2
- constructor: (spinnerId) ->
3
- @spinnerId = spinnerId
4
-
5
- hide: () ->
6
- jQuery(@spinnerId).hide()
7
-
8
- nextTo: (controlID, topOffset = 0, leftOffset = 14) ->
9
- if controlID?
10
- $control = jQuery(controlID)
11
- return null if $control.length is 0
12
-
13
- offset = $control.offset()
14
- top = parseInt(offset.top + topOffset)
15
- left = parseInt(offset.left + leftOffset + $control.width())
16
-
17
- # sometimes things are not what they seem, use the parent coordinates if needed
18
- if left < 0
19
- left = jQuery(controlID).parent().offset().left + leftOffset
20
-
21
- # show spinner
22
- jQuery(@spinnerId)
23
- .css('position', 'absolute')
24
- .css('top', "#{top}px")
25
- .css('left', "#{left}px ")
26
- .show()
27
- .css('z-index', 33010)
28
-
29
- window.Util ?= {}
30
- window.Util.spinner = new Spinner('#spinner')
31
-