loadjs 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2013 YOURNAME
1
+ Copyright 2013 Guido Marucci Blas
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -1,3 +1,3 @@
1
1
  module Loadjs
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,11 +1,36 @@
1
1
  function load(options, fn) {
2
2
  $(function(){
3
- if (options.controller != $("body").data("controller")) {
4
- return;
5
- }
6
- if (typeof options.action === "undefined" ||
7
- options.action == $("body").data("action")) {
8
- fn();
3
+ var body = $("body");
4
+ var currentController = body.data("controller");
5
+ var currentAction = body.data("action");
6
+
7
+ if (typeof options === "string") {
8
+ var splitOption = options.split("#");
9
+ if (splitOption[0] != currentController || splitOption[1] != currentAction) {
10
+ return;
11
+ }
12
+ fn(controller, action);
13
+ } else if (typeof options.controllers !== "undefined") {
14
+ for (var controller in options.controllers) {
15
+ var actions = options.controllers[controller];
16
+ if (controller == currentController && actions.length == 0) {
17
+ fn(controller, action);
18
+ } else {
19
+ for (var i = 0, length = actions.length; i < length; ++i) {
20
+ if (actions[i] == currentAction) {
21
+ fn(controller, action);
22
+ break;
23
+ }
24
+ }
25
+ }
26
+ }
27
+ } else {
28
+ if (options.controller != currentController) {
29
+ return;
30
+ }
31
+ if (typeof options.action === "undefined" || options.action == currentAction) {
32
+ fn(controller, action);
33
+ }
9
34
  }
10
35
  });
11
36
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loadjs
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:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-20 00:00:00.000000000 Z
12
+ date: 2013-04-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -101,7 +101,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
101
101
  version: '0'
102
102
  segments:
103
103
  - 0
104
- hash: -3814256120695105595
104
+ hash: -2462525434442556114
105
105
  required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  none: false
107
107
  requirements:
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  version: '0'
111
111
  segments:
112
112
  - 0
113
- hash: -3814256120695105595
113
+ hash: -2462525434442556114
114
114
  requirements: []
115
115
  rubyforge_project:
116
116
  rubygems_version: 1.8.23