redmine_extensions 0.2.7 → 0.2.8
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/app/assets/javascripts/redmine_extensions/blocking_render.js +28 -3
- data/app/assets/javascripts/redmine_extensions/blocking_schedule.js +37 -13
- data/app/assets/javascripts/redmine_extensions/blocking_utils.js +13 -7
- data/app/assets/javascripts/redmine_extensions/dynamic_loading.js +32 -4
- data/lib/redmine_extensions/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80de0c2943007be3336e1a07b280a51ce0f26738
|
4
|
+
data.tar.gz: a5f3b74b3f06ff90aa22ea3e7f3780aaa2926224
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11e228ee7c6304db152af464882c1da6f07e016206024295d964efabc79c0ab9c7571ea201154aabaa1c623001154a29157d9b5811b0393ac06e6fd0c5f0a379
|
7
|
+
data.tar.gz: 9d7bffff1fb3dec3c63ba5892c18936b00376c6cb904626f9f6fb4e8c4ba2994a81bff5a11ed88b434bddb73dbd5a3b8842f11477624215ceb42ddbdf39cd8a4
|
@@ -15,6 +15,14 @@
|
|
15
15
|
var renderPhase = false;
|
16
16
|
var lastTime = 0.0;
|
17
17
|
/**
|
18
|
+
* Wrapper for safe execution of [body] function only in read phase to prevent force-redraws.
|
19
|
+
* @example
|
20
|
+
* // fill storage with values from DOM
|
21
|
+
* var storage = {};
|
22
|
+
* EasyGem.read(function(){
|
23
|
+
* this.offset = $element.offset();
|
24
|
+
* this.scrollTop = $(window).scrollTop();
|
25
|
+
* }, storage);
|
18
26
|
* @param {RenderFunction} body
|
19
27
|
* @param {Object} [context]
|
20
28
|
*/
|
@@ -26,7 +34,13 @@
|
|
26
34
|
}
|
27
35
|
};
|
28
36
|
/**
|
29
|
-
*
|
37
|
+
* Wrapper for safe execution of [body] function only in render phase to prevent force-redraws.
|
38
|
+
* @example
|
39
|
+
* var left = $element.css("left");
|
40
|
+
* EasyGem.render(function(){
|
41
|
+
* $element.css({left: (left + 5) + "px"});
|
42
|
+
* });
|
43
|
+
* @param {RenderFunction} body - obtain execution time as first parameter
|
30
44
|
* @param {Object} [context]
|
31
45
|
*/
|
32
46
|
EasyGem.render = function (body, context) {
|
@@ -37,8 +51,19 @@
|
|
37
51
|
}
|
38
52
|
};
|
39
53
|
/**
|
54
|
+
* Complex and most-safe wrapper for DOM-manipulation code
|
55
|
+
* Execute [read] and [render] function only in proper phases.
|
56
|
+
* @example
|
57
|
+
* // prevents layout thrashing
|
58
|
+
* $table.find("td.first_column").each(function() {
|
59
|
+
* EasyGem.readAndRender(function() {
|
60
|
+
* return this.width();
|
61
|
+
* }, function(width, time) {
|
62
|
+
* this.next().width(width);
|
63
|
+
* }, $(this));
|
64
|
+
* });
|
40
65
|
* @param {RenderFunction} read
|
41
|
-
* @param {RenderFunction} render
|
66
|
+
* @param {RenderFunction} render - function(readResult, time) callback
|
42
67
|
* @param {Object} [context]
|
43
68
|
*/
|
44
69
|
EasyGem.readAndRender = function (read, render, context) {
|
@@ -75,7 +100,7 @@
|
|
75
100
|
renderQueue = [];
|
76
101
|
for (var i = 0; i < queue.length; i++) {
|
77
102
|
var pack = queue[i];
|
78
|
-
pack.body.call(pack.ctx,
|
103
|
+
pack.body.call(pack.ctx, pack.value, time);
|
79
104
|
}
|
80
105
|
renderQueue = [];
|
81
106
|
}
|
@@ -14,6 +14,10 @@
|
|
14
14
|
var lateArray = [];
|
15
15
|
/** @type {Array.<?ScheduleTask>} */
|
16
16
|
var prerequisiteArray = [];
|
17
|
+
/**
|
18
|
+
* Predefined getters for [require] function. Just specify the name of the module
|
19
|
+
* @type {{jquery: jquery, jqueryui: jqueryui, c3: c3, ckeditor: ckeditor}}
|
20
|
+
*/
|
17
21
|
var moduleGetters = {
|
18
22
|
jquery: function () {
|
19
23
|
return window.jQuery;
|
@@ -21,10 +25,10 @@
|
|
21
25
|
jqueryui: function () {
|
22
26
|
return window.jQuery && jQuery.Widget;
|
23
27
|
},
|
24
|
-
c3:function () {
|
28
|
+
c3: function () {
|
25
29
|
return window.c3;
|
26
30
|
},
|
27
|
-
ckeditor:function () {
|
31
|
+
ckeditor: function () {
|
28
32
|
return window.CKEDITOR;
|
29
33
|
}
|
30
34
|
};
|
@@ -82,7 +86,7 @@
|
|
82
86
|
if (prerequisiteArray.length === 0) return 0;
|
83
87
|
var count = 0;
|
84
88
|
for (var i = 0; i < prerequisiteArray.length; i++) {
|
85
|
-
if(executeOnePrerequisite(prerequisiteArray[i])) {
|
89
|
+
if (executeOnePrerequisite(prerequisiteArray[i])) {
|
86
90
|
count++;
|
87
91
|
prerequisiteArray[i] = null;
|
88
92
|
}
|
@@ -148,9 +152,10 @@
|
|
148
152
|
*/
|
149
153
|
EasyGem.schedule = {
|
150
154
|
/**
|
151
|
-
* Functions, which should be executed right after "DOMContentLoaded" event
|
155
|
+
* Functions, which should be executed right after "DOMContentLoaded" event.
|
152
156
|
* @param {Function} func
|
153
|
-
* @param {number} [priority]
|
157
|
+
* @param {number} [priority=0] - Greater the priority, sooner [func] are called. Each 5 priority delays execution
|
158
|
+
* by 30ms. Also negative values are accepted.
|
154
159
|
*/
|
155
160
|
main: function (func, priority) {
|
156
161
|
mainArray.push({func: func, priority: priority || 0})
|
@@ -158,8 +163,19 @@
|
|
158
163
|
/**
|
159
164
|
* Functions, which should wait for [prerequisite] fulfillment
|
160
165
|
* After that [func] is executed with return value of [prerequisite] as parameter
|
161
|
-
* @
|
162
|
-
*
|
166
|
+
* @example
|
167
|
+
* // execute function after jQuery and window.logger are present
|
168
|
+
* EasyGem.schedule.require(function($,logger){
|
169
|
+
* logger.log($.fn.jquery);
|
170
|
+
* },'jQuery',function(){
|
171
|
+
* return window.logger;
|
172
|
+
* });
|
173
|
+
* @param {Function} func - function which will be called when all prerequisites are met. Results of prerequisites
|
174
|
+
* are send into [func] as parameters
|
175
|
+
* @param {...(SchedulePrerequisite|string)} prerequisite - more than one prerequisite can be specified here
|
176
|
+
* as rest parameters. Function or String are accepted. If String is used,
|
177
|
+
* predefined getter from [moduleGetters] or getter defined by [define]
|
178
|
+
* are called.
|
163
179
|
*/
|
164
180
|
require: function (func, prerequisite) {
|
165
181
|
if (arguments.length > 2) {
|
@@ -186,19 +202,27 @@
|
|
186
202
|
}
|
187
203
|
},
|
188
204
|
/**
|
189
|
-
* Functions, which should be executed after several
|
190
|
-
*
|
205
|
+
* Functions, which should be executed after several loops after "DOMContentLoaded" event.
|
206
|
+
* Each 5 levels of priority increase delay by one stack.
|
191
207
|
* @param {Function} func
|
192
|
-
* @param {number} [priority]
|
208
|
+
* @param {number} [priority=0]
|
193
209
|
*/
|
194
210
|
late: function (func, priority) {
|
195
211
|
lateArray.push({func: func, priority: priority || 0})
|
196
212
|
},
|
197
213
|
/**
|
198
|
-
* Define module, which will be loaded by [require] function with [name]
|
199
|
-
* Only one instance will be created
|
214
|
+
* Define module, which will be loaded by [require] function with [name] prerequisite
|
215
|
+
* Only one instance will be created and cached also for future use.
|
216
|
+
* If no one request the module, getter is never called.
|
217
|
+
* @example
|
218
|
+
* EasyGem.schedule.define('Counter', function () {
|
219
|
+
* var count = 0;
|
220
|
+
* return function () {
|
221
|
+
* console.log("Count: " + count++);
|
222
|
+
* }
|
223
|
+
* });
|
200
224
|
* @param {string} name
|
201
|
-
* @param {Function} getter
|
225
|
+
* @param {Function} getter - getter or constructor
|
202
226
|
*/
|
203
227
|
define: function (name, getter) {
|
204
228
|
moduleGetters[name.toLocaleLowerCase()] = getter;
|
@@ -1,3 +1,10 @@
|
|
1
|
+
/**
|
2
|
+
* Duplication of $.extend(), so whole jQuery dont have to be loaded
|
3
|
+
* @param {boolean|Object} deep
|
4
|
+
* @param {Object} target
|
5
|
+
* @param {Object} [source]
|
6
|
+
* @return {Object}
|
7
|
+
*/
|
1
8
|
EasyGem.extend = function (deep, target, source) {
|
2
9
|
var copyIsArray;
|
3
10
|
if (typeof deep !== "boolean") {
|
@@ -5,7 +12,7 @@ EasyGem.extend = function (deep, target, source) {
|
|
5
12
|
target = deep;
|
6
13
|
deep = false;
|
7
14
|
}
|
8
|
-
if (
|
15
|
+
if (source === undefined) return target;
|
9
16
|
if (typeof target !== "object") {
|
10
17
|
target = {};
|
11
18
|
}
|
@@ -16,19 +23,18 @@ EasyGem.extend = function (deep, target, source) {
|
|
16
23
|
|
17
24
|
// Prevent never-ending loop
|
18
25
|
if (trg === src) continue;
|
19
|
-
if (deep && src &&
|
20
|
-
|
21
|
-
|
26
|
+
if (deep && src && typeof src === "object") {
|
27
|
+
copyIsArray = Array.isArray(src);
|
22
28
|
if (copyIsArray) {
|
23
29
|
copyIsArray = false;
|
24
30
|
var clone = trg && Array.isArray(trg) ? trg : [];
|
25
31
|
|
26
32
|
} else {
|
27
|
-
clone = trg && (typeof
|
33
|
+
clone = trg && (typeof trg === "object") ? trg : {};
|
28
34
|
}
|
29
35
|
|
30
36
|
// Never move original objects, clone them
|
31
|
-
target[name] =
|
37
|
+
target[name] = EasyGem.extend(deep, clone, src);
|
32
38
|
|
33
39
|
// Don't bring in undefined values
|
34
40
|
} else if (src !== undefined) {
|
@@ -37,4 +43,4 @@ EasyGem.extend = function (deep, target, source) {
|
|
37
43
|
}
|
38
44
|
return target;
|
39
45
|
};
|
40
|
-
EASY.extend = EasyGem.extend;
|
46
|
+
EASY.extend = EasyGem.extend;
|
@@ -1,11 +1,31 @@
|
|
1
1
|
EasyGem.dynamic = {
|
2
|
+
_alreadyLoaded: {},
|
3
|
+
/**
|
4
|
+
* Append Javascript <script> tag to page
|
5
|
+
* @example
|
6
|
+
* EasyGem.dynamic.jsTag("/plugin_assets/my_plugin/javascripts/counter.js");
|
7
|
+
* EasyGem.schedule.require(function(counter){
|
8
|
+
* setInterval(counter.count(), 1000);
|
9
|
+
* }, function(){
|
10
|
+
* return window.utils.counter;
|
11
|
+
* })
|
12
|
+
* @param {String} src - absolute path to requested file
|
13
|
+
*/
|
2
14
|
jsTag: function (src) {
|
15
|
+
if (this._alreadyLoaded[src]) return;
|
16
|
+
this._alreadyLoaded[src] = true;
|
3
17
|
var jsScript = document.createElement("script");
|
4
18
|
jsScript.setAttribute("src", src);
|
5
19
|
jsScript.setAttribute("defer", "true");
|
6
20
|
document.head.appendChild(jsScript);
|
7
21
|
},
|
22
|
+
/**
|
23
|
+
* Append CSS <link> tag to page
|
24
|
+
* @param {String} src - absolute path to requested file
|
25
|
+
*/
|
8
26
|
cssTag: function (src) {
|
27
|
+
if (this._alreadyLoaded[src]) return;
|
28
|
+
this._alreadyLoaded[src] = true;
|
9
29
|
var link = document.createElement('link');
|
10
30
|
link.rel = "stylesheet";
|
11
31
|
link.type = "text/css";
|
@@ -13,14 +33,22 @@ EasyGem.dynamic = {
|
|
13
33
|
link.media = "all";
|
14
34
|
document.head.appendChild(link);
|
15
35
|
},
|
16
|
-
|
36
|
+
/**
|
37
|
+
* Load multiple JS files into page
|
38
|
+
* @param {Array.<String>} array
|
39
|
+
*/
|
40
|
+
jsTags: function (array) {
|
17
41
|
for (var i = 0; i < array.length; i++) {
|
18
|
-
this.jsTag(array[i]
|
42
|
+
this.jsTag(array[i]);
|
19
43
|
}
|
20
44
|
},
|
21
|
-
|
45
|
+
/**
|
46
|
+
* Load multiple CSS files into page
|
47
|
+
* @param {Array.<String>} array
|
48
|
+
*/
|
49
|
+
cssTags: function (array) {
|
22
50
|
for (var i = 0; i < array.length; i++) {
|
23
|
-
this.cssTag(array[i]
|
51
|
+
this.cssTag(array[i]);
|
24
52
|
}
|
25
53
|
}
|
26
54
|
};
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redmine_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Easy Software Ltd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|