oxymoron 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9bc0b4a2bc12a7d9377e2f4dc90ea3d045eb85ae
4
- data.tar.gz: 43859c4cfa58dc84c60fc95d34eb5474d03969e6
3
+ metadata.gz: ba2cfcac8057d43bfb870dd02aaa0924f6488d8c
4
+ data.tar.gz: b3b9d2905e004ac1814eedc8d9ecfebc65493001
5
5
  SHA512:
6
- metadata.gz: 92457106bff8e557875a22fea33e90393cbf8c03eabff082bcbfee16866b16ed9f266df74fee89609c88bce25396895668a4aff0adaa2edfa4386459bf77e338
7
- data.tar.gz: 037d991888c83b6bc7ae5420c098ea8c72e92f6c184b453d83f540a2ae35f5ab1ff67e95a47ae4343ce2defa0a748ab4f331fce415caf13188a4838c039d4a96
6
+ metadata.gz: a7a46692f762bb48385842735922fa99b93ca67d7b1e4e9660328413471edc299587223d0376967bb2e72b3138c3520ea1fa8ab588f7c8f07a737880511c3b24
7
+ data.tar.gz: 1040515932287e6d02810f0a5e903b485d10fce8183d584369a4a082660113dfe577235c52e88ad9008abbd911c64e155870be020f37a3e5b585c8ba7f5100fb
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [Example application](https://github.com/storuky/oxymoron_app)
4
4
 
5
+ [Basic forum based on Oxymoron](https://github.com/storuky/forum)
5
6
  ##Setup
6
7
 
7
8
  Add it to your Gemfile:
@@ -79,7 +80,7 @@ class ApplicationController < ActionController::Base
79
80
  false
80
81
  else
81
82
  index
82
- 'application' # или другой лейаут
83
+ 'application' # or other layout
83
84
  end
84
85
  }
85
86
 
@@ -1,6 +1,5 @@
1
1
  <%= render_oxymoron_assets "directives/content_for.js"%>
2
2
  <%= render_oxymoron_assets "directives/fileupload.js"%>
3
- <%= render_oxymoron_assets "directives/checklist_model.js"%>
4
3
  <%= render_oxymoron_assets "directives/click_outside.js"%>
5
4
 
6
5
  angular.module("oxymoron.directives", ['oxymoron.directives.fileupload', 'oxymoron.directives.contentFor', 'oxymoron.directives.checklistModel', 'oxymoron.directives.clickOutside'])
@@ -2,24 +2,33 @@ angular.module("oxymoron.services.sign", [])
2
2
  .service('Sign', ['$http', function ($http) {
3
3
  var Sign = this;
4
4
 
5
- Sign.out = function () {
5
+ Sign.out = function (callback) {
6
6
  $http.delete(Routes.destroy_user_session_path())
7
7
  .success(function () {
8
- window.location = "/";
8
+ if (callback)
9
+ callback()
10
+ else
11
+ window.location = "/";
9
12
  })
10
13
  }
11
14
 
12
- Sign.in = function (form) {
13
- $http.post(Routes.user_session_path(), {user: form})
15
+ Sign.in = function (user, callback) {
16
+ $http.post(Routes.user_session_path(), {user: user})
14
17
  .success(function () {
15
- window.location.reload();
18
+ if (callback)
19
+ callback();
20
+ else
21
+ window.location.reload();
16
22
  })
17
23
  }
18
24
 
19
- Sign.up = function (form) {
20
- $http.post(Routes.user_registration_path(), {user: form})
25
+ Sign.up = function (user, callback) {
26
+ $http.post(Routes.user_registration_path(), {user: user})
21
27
  .success(function () {
22
- window.location.reload();
28
+ if (callback)
29
+ callback();
30
+ else
31
+ window.location.reload();
23
32
  })
24
33
  }
25
34
  }])
@@ -1,3 +1,3 @@
1
1
  module Oxymoron
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oxymoron
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kononenko Paul
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-02 00:00:00.000000000 Z
11
+ date: 2016-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print
@@ -104,7 +104,6 @@ files:
104
104
  - app/assets/javascripts/oxymoron/config/http.js
105
105
  - app/assets/javascripts/oxymoron/config/states.js.erb
106
106
  - app/assets/javascripts/oxymoron/directives.js.erb
107
- - app/assets/javascripts/oxymoron/directives/checklist_model.js
108
107
  - app/assets/javascripts/oxymoron/directives/click_outside.js
109
108
  - app/assets/javascripts/oxymoron/directives/content_for.js
110
109
  - app/assets/javascripts/oxymoron/directives/fileupload.js
@@ -1,141 +0,0 @@
1
- angular.module("oxymoron.directives.checklistModel", [])
2
- .directive('checklistModel', ['$parse', '$compile', function($parse, $compile) {
3
- // contains
4
- function contains(arr, item, comparator) {
5
- if (angular.isArray(arr)) {
6
- for (var i = arr.length; i--;) {
7
- if (comparator(arr[i], item)) {
8
- return true;
9
- }
10
- }
11
- }
12
- return false;
13
- }
14
-
15
- // add
16
- function add(arr, item, comparator) {
17
- arr = angular.isArray(arr) ? arr : [];
18
- if(!contains(arr, item, comparator)) {
19
- arr.push(item);
20
- }
21
- return arr;
22
- }
23
-
24
- // remove
25
- function remove(arr, item, comparator) {
26
- if (angular.isArray(arr)) {
27
- for (var i = arr.length; i--;) {
28
- if (comparator(arr[i], item)) {
29
- arr.splice(i, 1);
30
- break;
31
- }
32
- }
33
- }
34
- return arr;
35
- }
36
-
37
- // http://stackoverflow.com/a/19228302/1458162
38
- function postLinkFn(scope, elem, attrs) {
39
- // exclude recursion, but still keep the model
40
- var checklistModel = attrs.checklistModel;
41
- attrs.$set("checklistModel", null);
42
- // compile with `ng-model` pointing to `checked`
43
- $compile(elem)(scope);
44
- attrs.$set("checklistModel", checklistModel);
45
-
46
- // getter / setter for original model
47
- var getter = $parse(checklistModel);
48
- var setter = getter.assign;
49
- var checklistChange = $parse(attrs.checklistChange);
50
- var checklistBeforeChange = $parse(attrs.checklistBeforeChange);
51
-
52
- // value added to list
53
- var value = attrs.checklistValue ? $parse(attrs.checklistValue)(scope.$parent) : attrs.value;
54
-
55
-
56
- var comparator = angular.equals;
57
-
58
- if (attrs.hasOwnProperty('checklistComparator')){
59
- if (attrs.checklistComparator[0] == '.') {
60
- var comparatorExpression = attrs.checklistComparator.substring(1);
61
- comparator = function (a, b) {
62
- return a[comparatorExpression] === b[comparatorExpression];
63
- };
64
-
65
- } else {
66
- comparator = $parse(attrs.checklistComparator)(scope.$parent);
67
- }
68
- }
69
-
70
- // watch UI checked change
71
- scope.$watch(attrs.ngModel, function(newValue, oldValue) {
72
- if (newValue === oldValue) {
73
- return;
74
- }
75
-
76
- if (checklistBeforeChange && (checklistBeforeChange(scope) === false)) {
77
- scope[attrs.ngModel] = contains(getter(scope.$parent), value, comparator);
78
- return;
79
- }
80
-
81
- setValueInChecklistModel(value, newValue);
82
-
83
- if (checklistChange) {
84
- checklistChange(scope);
85
- }
86
- });
87
-
88
- function setValueInChecklistModel(value, checked) {
89
- var current = getter(scope.$parent);
90
- if (angular.isFunction(setter)) {
91
- if (checked === true) {
92
- setter(scope.$parent, add(current, value, comparator));
93
- } else {
94
- setter(scope.$parent, remove(current, value, comparator));
95
- }
96
- }
97
-
98
- }
99
-
100
- // declare one function to be used for both $watch functions
101
- function setChecked(newArr, oldArr) {
102
- if (checklistBeforeChange && (checklistBeforeChange(scope) === false)) {
103
- setValueInChecklistModel(value, scope[attrs.ngModel]);
104
- return;
105
- }
106
- scope[attrs.ngModel] = contains(newArr, value, comparator);
107
- }
108
-
109
- // watch original model change
110
- // use the faster $watchCollection method if it's available
111
- if (angular.isFunction(scope.$parent.$watchCollection)) {
112
- scope.$parent.$watchCollection(checklistModel, setChecked);
113
- } else {
114
- scope.$parent.$watch(checklistModel, setChecked, true);
115
- }
116
- }
117
-
118
- return {
119
- restrict: 'A',
120
- priority: 1000,
121
- terminal: true,
122
- scope: true,
123
- compile: function(tElement, tAttrs) {
124
- if ((tElement[0].tagName !== 'INPUT' || tAttrs.type !== 'checkbox') && (tElement[0].tagName !== 'MD-CHECKBOX') && (!tAttrs.btnCheckbox)) {
125
- throw 'checklist-model should be applied to `input[type="checkbox"]` or `md-checkbox`.';
126
- }
127
-
128
- if (!tAttrs.checklistValue && !tAttrs.value) {
129
- throw 'You should provide `value` or `checklist-value`.';
130
- }
131
-
132
- // by default ngModel is 'checked', so we set it if not specified
133
- if (!tAttrs.ngModel) {
134
- // local scope var storing individual checkbox model
135
- tAttrs.$set("ngModel", "checked");
136
- }
137
-
138
- return postLinkFn;
139
- }
140
- };
141
- }]);