angular-ujs 0.4.11 → 0.4.12
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.
- checksums.yaml +4 -4
- data/package.json +1 -1
- data/vendor/assets/javascripts/angular-ujs.js +52 -27
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f143a5b5970e7e6e8a43edaddcec51a862cccdb2
|
4
|
+
data.tar.gz: 71d0f5edea2a764ad2adfd507559b9b41963f56b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec44eef948dfc055d3ea608c16796d093ccbc63881a3d499f6341bdee45860b262fe56cd26121e19828db0ce7a2d471e727711b527e260017ad6017b21ee21f1
|
7
|
+
data.tar.gz: 8c3dbb69a8f8f3a95e1fe8f71744811b505fe6ddd89aa60a780e904d4e192f8ce9e28a8666739a6a7e2cf44bce265850a3e2c03c238fddd87a2cfd7d4b7987bf
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "angular-ujs",
|
3
|
-
"version": "0.4.
|
3
|
+
"version": "0.4.12",
|
4
4
|
"description": "Unobtrusive scripting for AngularJS ( without jQuery dependency )",
|
5
5
|
"longDescription": "Ruby on Rails replacement for unobtrusive scripting library `jquery_ujs` implemented in AngularJS without jQuery dependency",
|
6
6
|
"main": "angular-ujs.js",
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/*! angular-ujs - v 0.4.
|
1
|
+
/*! angular-ujs - v 0.4.12 - Fri Mar 14 2014 12:56:09 GMT+0800 (CST)
|
2
2
|
* https://github.com/tomchentw/angular-ujs
|
3
3
|
* Copyright (c) 2014 [tomchentw](https://github.com/tomchentw);
|
4
4
|
* Licensed [MIT](http://tomchentw.mit-license.org)
|
@@ -6,6 +6,8 @@
|
|
6
6
|
/*global angular:false*/
|
7
7
|
(function(){
|
8
8
|
'use strict';
|
9
|
+
var bind;
|
10
|
+
bind = angular.bind;
|
9
11
|
function denyDefaultAction(event){
|
10
12
|
event.preventDefault();
|
11
13
|
event.stopPropagation();
|
@@ -21,40 +23,47 @@
|
|
21
23
|
}
|
22
24
|
return metas;
|
23
25
|
};
|
24
|
-
})).controller('noopRailsConfirmCtrl', function(){
|
25
|
-
|
26
|
+
})).controller('noopRailsConfirmCtrl', (function(){
|
27
|
+
var prototype = constructor.prototype;
|
28
|
+
prototype.allowAction = function(){
|
26
29
|
return true;
|
27
30
|
};
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
+
prototype.denyDefaultAction = denyDefaultAction;
|
32
|
+
function constructor(){}
|
33
|
+
return constructor;
|
34
|
+
}())).controller('RailsConfirmCtrl', (function(){
|
35
|
+
var prototype = constructor.prototype;
|
36
|
+
prototype.allowAction = function(){
|
31
37
|
var message;
|
32
|
-
message =
|
33
|
-
return angular.isDefined(message) &&
|
38
|
+
message = this.$attrs.confirm;
|
39
|
+
return angular.isDefined(message) && this.$window.confirm(message);
|
34
40
|
};
|
35
|
-
|
36
|
-
|
37
|
-
|
41
|
+
prototype.denyDefaultAction = denyDefaultAction;
|
42
|
+
constructor.$inject = ['$window', '$attrs'];
|
43
|
+
function constructor($window, $attrs){
|
44
|
+
this.$window = $window;
|
45
|
+
this.$attrs = $attrs;
|
46
|
+
}
|
47
|
+
return constructor;
|
48
|
+
}())).controller('noopRailsRemoteFormCtrl', (function(){
|
49
|
+
var prototype = constructor.prototype;
|
50
|
+
prototype.submit = function($form){
|
38
51
|
$form[0].submit();
|
39
52
|
return {
|
40
53
|
then: angular.noop
|
41
54
|
};
|
42
55
|
};
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
errorCallback = function(response){
|
49
|
-
$scope.$emit('rails:remote:error', response);
|
50
|
-
};
|
51
|
-
this.submit = function($form){
|
56
|
+
function constructor(){}
|
57
|
+
return constructor;
|
58
|
+
}())).controller('RailsRemoteFormCtrl', (function(){
|
59
|
+
var prototype = constructor.prototype;
|
60
|
+
prototype.submit = function($form){
|
52
61
|
var targetScope, modelName, data, key, value, config, METHOD, own$ = {}.hasOwnProperty;
|
53
62
|
targetScope = $form.scope();
|
54
|
-
modelName =
|
63
|
+
modelName = this.$attrs.remote;
|
55
64
|
data = {};
|
56
65
|
if (modelName + "" !== 'true') {
|
57
|
-
|
66
|
+
this.$parse(modelName).assign(data, targetScope.$eval(modelName));
|
58
67
|
} else {
|
59
68
|
for (key in targetScope) if (own$.call(targetScope, key)) {
|
60
69
|
value = targetScope[key];
|
@@ -75,9 +84,25 @@
|
|
75
84
|
'X-Http-Method-Override': METHOD
|
76
85
|
};
|
77
86
|
}
|
78
|
-
return
|
87
|
+
return this.$http(config).then(this.successCallback, this.errorCallback);
|
79
88
|
};
|
80
|
-
|
89
|
+
prototype.successCallback = function(response){
|
90
|
+
this.$scope.$emit('rails:remote:success', response);
|
91
|
+
};
|
92
|
+
prototype.errorCallback = function(response){
|
93
|
+
this.$scope.$emit('rails:remote:error', response);
|
94
|
+
};
|
95
|
+
constructor.$inject = ['$scope', '$attrs', '$parse', '$http'];
|
96
|
+
function constructor($scope, $attrs, $parse, $http){
|
97
|
+
this.$scope = $scope;
|
98
|
+
this.$attrs = $attrs;
|
99
|
+
this.$parse = $parse;
|
100
|
+
this.$http = $http;
|
101
|
+
this.successCallback = bind(this, this.successCallback);
|
102
|
+
this.errorCallback = bind(this, this.errorCallback);
|
103
|
+
}
|
104
|
+
return constructor;
|
105
|
+
}())).directive('confirm', function(){
|
81
106
|
function onClickHandler(confirmCtrl, event){
|
82
107
|
if (!confirmCtrl.allowAction()) {
|
83
108
|
confirmCtrl.denyDefaultAction(event);
|
@@ -85,7 +110,7 @@
|
|
85
110
|
}
|
86
111
|
function postLinkFn($scope, $element, $attrs, $ctrls){
|
87
112
|
var callback;
|
88
|
-
callback =
|
113
|
+
callback = bind(void 8, onClickHandler, $ctrls[0]);
|
89
114
|
$element.on('click', callback);
|
90
115
|
$scope.$on('$destroy', function(){
|
91
116
|
$element.off('click', callback);
|
@@ -118,7 +143,7 @@
|
|
118
143
|
$scope: $scope
|
119
144
|
});
|
120
145
|
}
|
121
|
-
callback =
|
146
|
+
callback = bind(void 8, onSubmitHandler, $element, $ctrls);
|
122
147
|
$element.on('submit', callback);
|
123
148
|
$scope.$on('$destroy', function(){
|
124
149
|
$element.off('submit', callback);
|
@@ -165,7 +190,7 @@
|
|
165
190
|
if (!$ctrls[1]) {
|
166
191
|
$ctrls[1] = $controller('noopRailsRemoteFormCtrl', controllerArgs);
|
167
192
|
}
|
168
|
-
callback =
|
193
|
+
callback = bind($ctrls, onClickHandler, $scope, $attrs, $ctrls);
|
169
194
|
$element.on('click', callback);
|
170
195
|
$scope.$on('$destroy', function(){
|
171
196
|
$element.off('click', callback);
|