From: Lucio <luciojhc(a)linux.vnet.ibm.com>
---
plugins/kimchi/ui/js/src/kimchi.host.js | 2 +-
plugins/kimchi/ui/js/src/kimchi.utils.js | 25 -----------------
ui/js/src/wok.popable.js | 2 +-
ui/js/src/wok.utils.js | 43 ++++++++++++++++++++++++++++++
4 files changed, 45 insertions(+), 27 deletions(-)
create mode 100644 ui/js/src/wok.utils.js
diff --git a/plugins/kimchi/ui/js/src/kimchi.host.js
b/plugins/kimchi/ui/js/src/kimchi.host.js
index 7fdf820..0b4ffd0 100644
--- a/plugins/kimchi/ui/js/src/kimchi.host.js
+++ b/plugins/kimchi/ui/js/src/kimchi.host.js
@@ -219,7 +219,7 @@ kimchi.host_main = function() {
var progressArea = $('#' + progressAreaID)[0];
$('#software-updates-progress-container').removeClass('hidden');
$(progressArea).text('');
- !kimchi.isElementInViewport(progressArea) &&
+ !wok.isElementInViewport(progressArea) &&
progressArea.scrollIntoView();
$(updateButton).text(i18n['KCHUPD6007M']).prop('disabled', true);
diff --git a/plugins/kimchi/ui/js/src/kimchi.utils.js
b/plugins/kimchi/ui/js/src/kimchi.utils.js
index f26a560..b22e2ed 100644
--- a/plugins/kimchi/ui/js/src/kimchi.utils.js
+++ b/plugins/kimchi/ui/js/src/kimchi.utils.js
@@ -17,31 +17,6 @@
*/
/**
- * To check whether a given DOM node is entirely within the viewport
- * of a browser.
- * @param {DOMObject} el The given DOM node to check.
- *
- * @returns {true|false|undefined}
- * true if the node is within viewport, or
- * false if the node is not entirely visible, or
- * undefined if the given parameter is invalid.
- */
-kimchi.isElementInViewport = function(el) {
- if (!el || !el.getBoundingClientRect) {
- return undefined;
- }
-
- var rect = el.getBoundingClientRect();
-
- return (
- rect.top >= 0 &&
- rect.left >= 0 &&
- rect.bottom <= (window.innerHeight || document.documentElement.clientHeight)
&&
- rect.right <= (window.innerWidth || document.documentElement.clientWidth)
- );
-};
-
-/**
* To change the byte to proper unit.
* @param number needed to change unit.
* @param digits after the decimal point.
diff --git a/ui/js/src/wok.popable.js b/ui/js/src/wok.popable.js
index 19f1555..7c01a0e 100644
--- a/ui/js/src/wok.popable.js
+++ b/ui/js/src/wok.popable.js
@@ -28,7 +28,7 @@ wok.popable = function() {
// Scroll the popup menu into viewport if invisible.
!$(popup).is(':visible') ||
- kimchi.isElementInViewport(popup) ||
+ wok.isElementInViewport(popup) ||
popup.scrollIntoView();
});
};
diff --git a/ui/js/src/wok.utils.js b/ui/js/src/wok.utils.js
new file mode 100644
index 0000000..5756323
--- /dev/null
+++ b/ui/js/src/wok.utils.js
@@ -0,0 +1,43 @@
+/*
+ * Project Kimchi
+ *
+ * Copyright IBM, Corp. 2013-2014
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * To check whether a given DOM node is entirely within the viewport
+ * of a browser.
+ * @param {DOMObject} el The given DOM node to check.
+ *
+ * @returns {true|false|undefined}
+ * true if the node is within viewport, or
+ * false if the node is not entirely visible, or
+ * undefined if the given parameter is invalid.
+ */
+wok.isElementInViewport = function(el) {
+ if (!el || !el.getBoundingClientRect) {
+ return undefined;
+ }
+
+ var rect = el.getBoundingClientRect();
+
+ return (
+ rect.top >= 0 &&
+ rect.left >= 0 &&
+ rect.bottom <= (window.innerHeight || document.documentElement.clientHeight)
&&
+ rect.right <= (window.innerWidth || document.documentElement.clientWidth)
+ );
+};
+
--
1.7.1