[PATCH] Supports Kimchi on LE systems v4
by Ramon Medeiros
Changes:
v4:
Add ppc64le to distroloaders, avoiding to select a template with a
mismatch architecture
v3:
Create a new entry for ppc64le arch
Create key for keyboard type
v2:
Improve coding by removing duplicated actions
Fix typo
On LE systems, some changes on libvirt xml is needed. The input device
for keyboard is not kbd anymore, the architecture is still ppc64 and the
qemu binary is not qemu-kvm as in the other archs.
Signed-off-by: Ramon Medeiros <ramonn(a)linux.vnet.ibm.com>
---
src/kimchi/config.py.in | 11 +++++++++--
src/kimchi/distroloader.py | 4 +++-
src/kimchi/osinfo.py | 30 ++++++++++++++++++++++++++++--
src/kimchi/vmtemplate.py | 4 +++-
4 files changed, 43 insertions(+), 6 deletions(-)
diff --git a/src/kimchi/config.py.in b/src/kimchi/config.py.in
index a952fb3..f207e3f 100644
--- a/src/kimchi/config.py.in
+++ b/src/kimchi/config.py.in
@@ -68,12 +68,19 @@ def find_qemu_binary(find_emulator=False):
raise Exception("Unable to get qemu binary location: %s" % e)
try:
xml = connect.getCapabilities()
+
+ # On Little Endian system, the qemu binary is
+ # qemu-system-ppc64, not qemu-system-ppc64le as expected
+ arch = platform.machine()
+ if arch == "ppc64le":
+ arch = "ppc64"
+
if find_emulator:
expr = "/capabilities/guest/arch[@name='%s']\
- /emulator" % platform.machine()
+ /emulator" % arch
else:
expr = "/capabilities/guest/arch[@name='%s']\
- /domain[@type='kvm']/emulator" % platform.machine()
+ /domain[@type='kvm']/emulator" % arch
res = xpath_get_text(xml, expr)
location = res[0]
except Exception, e:
diff --git a/src/kimchi/distroloader.py b/src/kimchi/distroloader.py
index 64505f4..de43238 100644
--- a/src/kimchi/distroloader.py
+++ b/src/kimchi/distroloader.py
@@ -30,7 +30,9 @@ from kimchi.utils import kimchi_log
ARCHS = {'x86_64': ['x86_64', 'amd64', 'i686', 'x86', 'i386'],
'amd64': ['x86_64', 'amd64', 'i686', 'x86', 'i386'],
- 'ppc64': ['ppc', 'ppc64']}
+ 'ppc64': ['ppc', 'ppc64'],
+ 'ppc64le': ['ppc64', 'ppc64le']}
+
class DistroLoader(object):
diff --git a/src/kimchi/osinfo.py b/src/kimchi/osinfo.py
index 0e16b50..d13dd92 100644
--- a/src/kimchi/osinfo.py
+++ b/src/kimchi/osinfo.py
@@ -29,7 +29,8 @@ from kimchi.config import paths
SUPPORTED_ARCHS = {'x86': ('i386', 'i686', 'x86_64'),
- 'power': ('ppc', 'ppc64')}
+ 'power': ('ppc', 'ppc64'),
+ 'ppc64le':('ppc64le')}
common_spec = {'cpus': 1, 'memory': 1024, 'disks': [{'index': 0, 'size': 10}],
@@ -47,11 +48,28 @@ template_specs = {'x86': {'old': dict(common_spec, disk_bus='ide',
'power': {'old': dict(common_spec, disk_bus='scsi',
nic_model='spapr-vlan',
cdrom_bus='scsi',
+ kbd_type="kbd",
kbd_bus='usb', mouse_bus='usb',
tablet_bus='usb', memory=1280),
'modern': dict(common_spec, disk_bus='virtio',
nic_model='virtio',
- cdrom_bus='scsi', kbd_bus='usb',
+ cdrom_bus='scsi',
+ kbd_bus='usb',
+ kbd_type="kbd",
+ mouse_bus='usb', tablet_bus='usb',
+ memory=1280)},
+ 'ppc64le': {'old': dict(common_spec, disk_bus='virtio',
+ nic_model='virtio',
+ cdrom_bus='scsi',
+ kbd_bus='usb',
+ kbd_type="keyboard",
+ mouse_bus='usb', tablet_bus='usb',
+ memory=1280),
+ 'modern': dict(common_spec, disk_bus='virtio',
+ nic_model='virtio',
+ cdrom_bus='scsi',
+ kbd_bus='usb',
+ kbd_type="keyboard",
mouse_bus='usb', tablet_bus='usb',
memory=1280)}}
@@ -63,6 +81,10 @@ modern_version_bases = {'x86': {'debian': '6.0', 'ubuntu': '7.10',
'power': {'rhel': '6.5', 'fedora': '19',
'ubuntu': '14.04',
'opensuse': '13.1',
+ 'sles': '11sp3'},
+ 'ppc64le': {'rhel': '6.5', 'fedora': '19',
+ 'ubuntu': '14.04',
+ 'opensuse': '13.1',
'sles': '11sp3'}}
@@ -94,6 +116,10 @@ def lookup(distro, version):
params['os_version'] = version
arch = _get_arch()
+ # set up arch to ppc64 instead of ppc64le due to libvirt compatibility
+ if params["arch"] == "ppc64le":
+ params["arch"] = "ppc64"
+
if distro in modern_version_bases[arch]:
if LooseVersion(version) >= LooseVersion(
modern_version_bases[arch][distro]):
diff --git a/src/kimchi/vmtemplate.py b/src/kimchi/vmtemplate.py
index e41a959..0a3f8ea 100644
--- a/src/kimchi/vmtemplate.py
+++ b/src/kimchi/vmtemplate.py
@@ -245,9 +245,11 @@ class VMTemplate(object):
mouse = """
<input type='mouse' bus='%(mouse_bus)s'/>
"""
+
keyboard = """
- <input type='kbd' bus='%(kbd_bus)s'> </input>
+ <input type='%(kbd_type)s' bus='%(kbd_bus)s'> </input>
"""
+
tablet = """
<input type='tablet' bus='%(kbd_bus)s'> </input>
"""
--
1.8.3.1
9 years, 11 months
[PATCH V3] UI: Adding selectmenu widget for kimchi new UI
by Wen Wang
V2 -> V3:
Fix margin errors
V1 -> V2:
1) Fix bug of multiple open menu-list
2) Menu-list showed on top of other content
Signed-off-by: Wen Wang <wenwang(a)linux.vnet.ibm.com>
---
ui/css/theme-default/selectmenu-flat.css | 88 +++++++++++++++++++++
ui/js/widgets/selectmenu-flat.js | 130 +++++++++++++++++++++++++++++++
2 files changed, 218 insertions(+)
create mode 100644 ui/css/theme-default/selectmenu-flat.css
create mode 100644 ui/js/widgets/selectmenu-flat.js
diff --git a/ui/css/theme-default/selectmenu-flat.css b/ui/css/theme-default/selectmenu-flat.css
new file mode 100644
index 0000000..0f91d80
--- /dev/null
+++ b/ui/css/theme-default/selectmenu-flat.css
@@ -0,0 +1,88 @@
+/*
+ * Project Kimchi
+ *
+ * Copyright IBM, Corp. 2015
+ *
+ * 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.
+ */
+
+.select-content {
+ position: relative;
+ height: 30px;
+ width: 170px;
+}
+
+.selected-box {
+ width: 75%;
+ height: 30px;
+ border: 1px solid #d8d8d8;
+ border-radius: 3px;
+ cursor: pointer;
+ background: #FFFFFF;
+ float: right;
+}
+
+.select-val {
+ display: none;
+}
+
+.select-label {
+ line-height: 32px;
+ vertical-align: middle;
+ position: relative;
+ margin-left: 20px;
+}
+
+.select-icon {
+ position: relative;
+ float: right;
+ line-height: 30px;
+ vertical-align: middle;
+ padding-right: 10px;
+ padding-left: 10px;
+ color: #555555;
+ font-size: 10px;
+}
+
+.select-icon:hover {
+ background: #FCFCFC;
+}
+
+.selectmenu-opt {
+ background: #FFFFFF;
+}
+
+.selectmenu-list {
+ border: 1px solid #d8d8d8;
+ width: 99%;
+ position: absolute;
+ top: 31px;
+ cursor: pointer;
+ padding: 0;
+ margin: 0;
+}
+
+.selectmenu-list li {
+ list-style: none;
+ position: relative;
+ height: 20px;
+ padding: 5px 0 5px 20px;
+ line-height: 21px;
+ vertical-align: middle;
+ border-bottom: 1px solid #d8d8d8;
+ z-index: 3;
+}
+
+.selectmenu-opt:hover {
+ background: #FCFCFC;
+}
diff --git a/ui/js/widgets/selectmenu-flat.js b/ui/js/widgets/selectmenu-flat.js
new file mode 100644
index 0000000..6bf791b
--- /dev/null
+++ b/ui/js/widgets/selectmenu-flat.js
@@ -0,0 +1,130 @@
+/*
+ * Project Kimchi
+ *
+ * Copyright IBM, Corp. 2015
+ *
+ * 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.
+ */
+
+
+// How to use:
+// $(".selector").selectmenuFlat({
+// content: [1,2,3,4,5,6], //Set content of the select menu
+// selected: 2 // set the selected option, starts from "1"
+// });
+// $(".selector").selectmenuFlat("value", "4"); //Set value.
+// var t = $(".selector").selectmenuFlat("value"); //Get value
+// console.log(t);
+
+
+ (function( $ ) {
+ $.widget("kimchi.selectmenuFlat", {
+
+ options: {
+ content: null,
+ name: null,
+ selected: null,
+ parentid: null
+ },
+
+ _create: function() {
+ var that = this;
+ var name = that.options.name || $(this.element).attr("id");
+ var value = that.options.content;
+ var parentid = $(this.element).attr("id");
+ that.options.parentid = parentid;
+ var html = "<div class='selected-box'>" +
+ "<input class='select-val'>" +
+ "<span class='select-label'></span>" +
+ "<span class='select-icon icon-down-open'></span>" +
+ "</div>";
+ $(html).appendTo(that.element);
+ html = that._setValue(value);
+ $(html).appendTo(that.element);
+ $("#" + parentid).addClass("select-content");
+ var sel = that.options.selected || 1;
+ sel = that.options.content[Number(sel) -1];
+ that.options.selected = $.inArray(sel, that.options.content) + 1;
+ $(".select-val", "#" + parentid).text(sel);
+ $(".select-label", "#" + parentid).text(sel);
+ $(".selected-box", "#" + parentid).on("click", this._toggleOpt);
+ $(".selectmenu-opt", "#" + parentid).on("click", function() {
+ var selectedText = $(this).text();
+ that.options.selected = $.inArray(selectedText, that.options.content) +1;
+ $(".selected-box .select-label", "#" + parentid).text(selectedText);
+ $(".select-val", "#" + parentid).text(selectedText);
+ $(".selectmenu-list", "#" + parentid).prop("style", "display:none");
+ $(".select-icon", "#" + parentid).removeClass("icon-up-open");
+ $(".select-icon", "#" + parentid).addClass("icon-down-open").css({
+ "border-left": "none"
+ });
+ });
+ $(document).mouseup(function(e) {
+ var container = $(".selectmenu-opt");
+ if(!container.is(e.target) && container.has(e.target).length === 0 && $(".select-icon").hasClass("icon-up-open")) {
+ $(".selectmenu-list", "#" + parentid).prop("style", "display:none");
+ $(".select-icon", "#" + parentid).removeClass("icon-up-open");
+ $(".select-icon", "#" + parentid).addClass("icon-down-open").css({
+ "border-left": "none"
+ });
+ }
+ });
+ },
+
+ _setValue: function(value) {
+ var that = this;
+ var html = "<ul class='selectmenu-list' style='display:none'>";
+ var name = this.options.name || $(this.element).attr("id");
+ $.each(value, function(index, data) {
+ that.options.content[index] = data.toString();
+ html += "<li id='" + name + index + "' class='selectmenu-opt'>" + data + "</li>";
+ });
+ html += "</ul>";
+ return html;
+ },
+
+ _toggleOpt: function() {
+ var thisButton = $(this).parent().attr("id");
+ if($(".select-icon", "#" + thisButton).hasClass("icon-down-open")) {
+ $(".selectmenu-list", "#" + thisButton).prop("style", "display");
+ $(".select-icon", "#" + thisButton).removeClass("icon-down-open");
+ $(".select-icon", "#" + thisButton).addClass("icon-up-open").css({
+ "border-left": "1px solid #d8d8d8"
+ });
+ } else {
+ $(".selectmenu-list", "#" + thisButton).prop("style", "display:none");
+ $(".select-icon", "#" + thisButton).removeClass("icon-up-open");
+ $(".select-icon", "#" + thisButton).addClass("icon-down-open").css({
+ "border-left": "none"
+ });
+ }
+ },
+
+ value: function(value) {
+ var parentid = this.options.parentid;
+ if(!value) {
+ return $(".selected-box .select-val", "#" + parentid).text();
+ }
+ if (value <= this.options.content.length) {
+ this.options.selected = value;
+ var selectedText = this.options.content[value-1];
+ $(".selected-box .select-label", "#" + parentid).text(selectedText);
+ $(".selected-box .select-val", "#" + parentid).text(selectedText);
+ }
+ },
+
+ _destroy: function() {
+ this.element.remove();
+ }
+ });
+ })(jQuery);
\ No newline at end of file
--
2.1.0
9 years, 11 months
[PATCH V4] UI: Adding new widget of menu to kimchi new UI
by Wen Wang
V3 -> V4:
Fix margin errors
V2 -> V3:
Fix margin errors
V1 -> V2:
1) Fix the bug of multiple menu opened in the same time.
2) Make menu appear in the top level.
Signed-off-by: Wen Wang <wenwang(a)linux.vnet.ibm.com>
---
ui/css/theme-default/menu-flat.css | 89 +++++++++++++++++++++++++++++
ui/js/widgets/menu-flat.js | 114 +++++++++++++++++++++++++++++++++++++
2 files changed, 203 insertions(+)
create mode 100644 ui/css/theme-default/menu-flat.css
create mode 100644 ui/js/widgets/menu-flat.js
diff --git a/ui/css/theme-default/menu-flat.css b/ui/css/theme-default/menu-flat.css
new file mode 100644
index 0000000..385a312
--- /dev/null
+++ b/ui/css/theme-default/menu-flat.css
@@ -0,0 +1,89 @@
+/*
+ * Project Kimchi
+ *
+ * Copyright IBM, Corp. 2015
+ *
+ * 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.
+ */
+
+.menu-content {
+ position: relative;
+ height: 35px;
+ width: 170px;
+}
+
+.menu-box {
+ width: 100%;
+ height: 30px;
+ border-radius: 3px 3px 0 3px;
+ cursor: pointer;
+ vertical-align: middle;
+ background: #4E4D4F;
+ color: #EDEDED;
+ float: right;
+ position: relative;
+ padding-bottom: 5px;
+}
+
+.menu-label {
+ position: relative;
+}
+
+.menu-icon-front,
+.list-icon-front {
+ position: relative;
+ font-size: 17px;
+ line-height: 32px;
+ padding-right: 10px;
+ padding-left: 5px;
+ color: #EDEDED;
+}
+
+.menu-icon {
+ position: relative;
+ float: right;
+ line-height: 35px;
+ padding-right: 10px;
+ padding-left: 10px;
+ color: #CFCFCF;
+ font-size: 10px;
+ border-top-right-radius: 3px;
+}
+
+.menu-container {
+ border: 1px solid #999999;
+ width: 100px;
+}
+
+.menu-list {
+ position: absolute;
+ z-index: 3;
+ float: right;
+ width: 100%;
+ top: 35px;
+ padding-left: 0;
+ cursor: pointer;
+ background: #3A393B;
+ margin: 0;
+}
+
+.menu-list li {
+ list-style: none;
+ position: relative;
+ color: #EDEDED;
+ border-top: 1px groove black;
+}
+
+.menu-list li:first-child {
+ border: none;
+}
diff --git a/ui/js/widgets/menu-flat.js b/ui/js/widgets/menu-flat.js
new file mode 100644
index 0000000..8d1a546
--- /dev/null
+++ b/ui/js/widgets/menu-flat.js
@@ -0,0 +1,114 @@
+/*
+ * Project Kimchi
+ *
+ * Copyright IBM, Corp. 2015
+ *
+ * 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.
+ */
+
+ // How to use:
+ // $("#test-bar").menuFlat({
+ // content: [1,2,3,4,5,6], //Set content of the menu.
+ // icon: "icon-edit-alt", //Set icon of the menu button.
+ // listIconList: ["icon-edit-alt","icon-edit-alt","icon-edit-alt","icon-edit-alt","icon-edit-alt","icon-user"]
+ // //Set icons of the menu list.
+ // // name is optional which set the name of the menu list.
+ // });
+ // $("#test-bar0").on("click", function() {
+ // alert("hello");
+ // });
+ // $("#test-bar1").on("click", function() {
+ // console.log("hello");
+ // });
+
+
+ (function( $ ) {
+ $.widget("kimchi.menuFlat", {
+
+ options: {
+ content: null,
+ name: null,
+ parentid: null,
+ icon: null,
+ listIconList: null
+ },
+
+ _create: function() {
+ var that = this;
+ var name = that.options.name || $(this.element).attr("id");
+ var value = that.options.content;
+ var icon = that.options.icon || "";
+ var parentid = $(this.element).attr("id");
+ $("#" + parentid).addClass("menu-content");
+ that.options.parentid = parentid;
+ var html = "<div class='menu-box' id='manu-" + name + "'>" +
+ "<span class='menu-icon-front " + icon + "'></span>" +
+ "<span class='menu-label'>"+ name + "</span>" +
+ "<span class='menu-icon icon-down-open'></span>" +
+ "</div>";
+ $(html).appendTo(that.element);
+ html = that._setValue(value);
+ $(html).appendTo(that.element);
+ $(".menu-box", "#" + parentid).on("click", that._toggleOpt);
+ $(".menu-opt", "#" + parentid).on("click", that._toggleOpt);
+ $(document).mouseup(function(e) {
+ var container = $(".menu-opt");
+ if(!container.is(e.target) && container.has(e.target).length === 0 && $(".menu-icon").hasClass("icon-up-open")) {
+ $(".menu-list", "#" + parentid).prop("style", "display:none");
+ $(".menu-icon", "#" + parentid).removeClass("icon-up-open");
+ $(".menu-icon", "#" + parentid).addClass("icon-down-open").css({
+ "background": "#4E4D4F"
+ });
+ }
+ });
+ },
+
+ _setValue: function(value) {
+ var that = this;
+ var name = that.options.name;
+ var html = "<ul class='menu-list' name='" + name + "' style='display:none'>";
+ var name = this.options.name || $(this.element).attr("id");
+ $.each(value, function(index, data) {
+ that.options.content[index] = data.toString();
+ var liIcon = that.options.listIconList[index] || "";
+ html += "<li id='" + name + index + "' class='menu-opt'>" +
+ "<span class='list-icon-front " + liIcon + "'></span>" +
+ "<span>" + data + "</span>" +
+ "</li>";
+ });
+ html += "</ul>"
+ return html;
+ },
+
+ _toggleOpt: function() {
+ var thisButton = $(this).parent().attr("id") || $(this).parent().parent().attr("id");
+ if($(".menu-icon", "#" + thisButton).hasClass("icon-down-open")) {
+ $(".menu-list", "#" + thisButton).prop("style", "display");
+ $(".menu-icon", "#" + thisButton).removeClass("icon-down-open");
+ $(".menu-icon", "#" + thisButton).addClass("icon-up-open").css({
+ "background": "#3A393B"
+ });
+ } else {
+ $(".menu-list", "#" + thisButton).prop("style", "display:none");
+ $(".menu-icon", "#" + thisButton).removeClass("icon-up-open");
+ $(".menu-icon", "#" + thisButton).addClass("icon-down-open").css({
+ "background": "#4E4D4F"
+ });
+ }
+ },
+
+ _destroy: function() {
+ this.element.remove();
+ }
+ });
+ })(jQuery);
\ No newline at end of file
--
2.1.0
9 years, 11 months
[PATCH V3] UI: Adding new widget of menu to kimchi new UI
by Wen Wang
V2 -> V3:
Fix margin errors
V1 -> V2:
1) Fix the bug of multiple menu opened in the same time.
2) Make menu appear in the top level.
Signed-off-by: Wen Wang <wenwang(a)linux.vnet.ibm.com>
---
ui/css/theme-default/menu-flat.css | 90 +++++++++++++++++++++++++++++
ui/js/widgets/menu-flat.js | 114 +++++++++++++++++++++++++++++++++++++
2 files changed, 204 insertions(+)
create mode 100644 ui/css/theme-default/menu-flat.css
create mode 100644 ui/js/widgets/menu-flat.js
diff --git a/ui/css/theme-default/menu-flat.css b/ui/css/theme-default/menu-flat.css
new file mode 100644
index 0000000..194c4c7
--- /dev/null
+++ b/ui/css/theme-default/menu-flat.css
@@ -0,0 +1,90 @@
+/*
+ * Project Kimchi
+ *
+ * Copyright IBM, Corp. 2015
+ *
+ * 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.
+ */
+
+.menu-content {
+ position: relative;
+ height: 35px;
+ width: 170px;
+}
+
+.menu-box {
+ width: 100%;
+ height: 30px;
+ border-radius: 3px 3px 0 3px;
+ cursor: pointer;
+ vertical-align: middle;
+ background: #4E4D4F;
+ color: #EDEDED;
+ float: right;
+ position: relative;
+ padding-bottom: 5px;
+}
+
+.menu-label {
+ position: relative;
+}
+
+.menu-icon-front,
+.list-icon-front {
+ position: relative;
+ font-size: 17px;
+ line-height: 32px;
+ padding-right: 10px;
+ padding-left: 5px;
+ color: #EDEDED;
+}
+
+.menu-icon {
+ position: relative;
+ float: right;
+ line-height: 35px;
+ padding-right: 10px;
+ padding-left: 10px;
+ color: #CFCFCF;
+ font-size: 10px;
+ border-top-right-radius: 3px;
+}
+
+.menu-container {
+ border: 1px solid #999999;
+ width: 100px;
+}
+
+.menu-list {
+ position: absolute;
+ z-index: 3;
+ float: right;
+ width: 99%;
+ top: 35px;
+ padding-left: 0;
+ cursor: pointer;
+ background: #3A393B;
+ padding: 0;
+ margin: 0;
+}
+
+.menu-list li {
+ list-style: none;
+ position: relative;
+ color: #EDEDED;
+ border-top: 1px groove black;
+}
+
+.menu-list li:first-child {
+ border: none;
+}
diff --git a/ui/js/widgets/menu-flat.js b/ui/js/widgets/menu-flat.js
new file mode 100644
index 0000000..8d1a546
--- /dev/null
+++ b/ui/js/widgets/menu-flat.js
@@ -0,0 +1,114 @@
+/*
+ * Project Kimchi
+ *
+ * Copyright IBM, Corp. 2015
+ *
+ * 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.
+ */
+
+ // How to use:
+ // $("#test-bar").menuFlat({
+ // content: [1,2,3,4,5,6], //Set content of the menu.
+ // icon: "icon-edit-alt", //Set icon of the menu button.
+ // listIconList: ["icon-edit-alt","icon-edit-alt","icon-edit-alt","icon-edit-alt","icon-edit-alt","icon-user"]
+ // //Set icons of the menu list.
+ // // name is optional which set the name of the menu list.
+ // });
+ // $("#test-bar0").on("click", function() {
+ // alert("hello");
+ // });
+ // $("#test-bar1").on("click", function() {
+ // console.log("hello");
+ // });
+
+
+ (function( $ ) {
+ $.widget("kimchi.menuFlat", {
+
+ options: {
+ content: null,
+ name: null,
+ parentid: null,
+ icon: null,
+ listIconList: null
+ },
+
+ _create: function() {
+ var that = this;
+ var name = that.options.name || $(this.element).attr("id");
+ var value = that.options.content;
+ var icon = that.options.icon || "";
+ var parentid = $(this.element).attr("id");
+ $("#" + parentid).addClass("menu-content");
+ that.options.parentid = parentid;
+ var html = "<div class='menu-box' id='manu-" + name + "'>" +
+ "<span class='menu-icon-front " + icon + "'></span>" +
+ "<span class='menu-label'>"+ name + "</span>" +
+ "<span class='menu-icon icon-down-open'></span>" +
+ "</div>";
+ $(html).appendTo(that.element);
+ html = that._setValue(value);
+ $(html).appendTo(that.element);
+ $(".menu-box", "#" + parentid).on("click", that._toggleOpt);
+ $(".menu-opt", "#" + parentid).on("click", that._toggleOpt);
+ $(document).mouseup(function(e) {
+ var container = $(".menu-opt");
+ if(!container.is(e.target) && container.has(e.target).length === 0 && $(".menu-icon").hasClass("icon-up-open")) {
+ $(".menu-list", "#" + parentid).prop("style", "display:none");
+ $(".menu-icon", "#" + parentid).removeClass("icon-up-open");
+ $(".menu-icon", "#" + parentid).addClass("icon-down-open").css({
+ "background": "#4E4D4F"
+ });
+ }
+ });
+ },
+
+ _setValue: function(value) {
+ var that = this;
+ var name = that.options.name;
+ var html = "<ul class='menu-list' name='" + name + "' style='display:none'>";
+ var name = this.options.name || $(this.element).attr("id");
+ $.each(value, function(index, data) {
+ that.options.content[index] = data.toString();
+ var liIcon = that.options.listIconList[index] || "";
+ html += "<li id='" + name + index + "' class='menu-opt'>" +
+ "<span class='list-icon-front " + liIcon + "'></span>" +
+ "<span>" + data + "</span>" +
+ "</li>";
+ });
+ html += "</ul>"
+ return html;
+ },
+
+ _toggleOpt: function() {
+ var thisButton = $(this).parent().attr("id") || $(this).parent().parent().attr("id");
+ if($(".menu-icon", "#" + thisButton).hasClass("icon-down-open")) {
+ $(".menu-list", "#" + thisButton).prop("style", "display");
+ $(".menu-icon", "#" + thisButton).removeClass("icon-down-open");
+ $(".menu-icon", "#" + thisButton).addClass("icon-up-open").css({
+ "background": "#3A393B"
+ });
+ } else {
+ $(".menu-list", "#" + thisButton).prop("style", "display:none");
+ $(".menu-icon", "#" + thisButton).removeClass("icon-up-open");
+ $(".menu-icon", "#" + thisButton).addClass("icon-down-open").css({
+ "background": "#4E4D4F"
+ });
+ }
+ },
+
+ _destroy: function() {
+ this.element.remove();
+ }
+ });
+ })(jQuery);
\ No newline at end of file
--
2.1.0
9 years, 11 months
[PATCH] UI: Sample of menu/button/radio/checkbox/seletmenu/textbox
by Wen Wang
Signed-off-by: Wen Wang <wenwang(a)linux.vnet.ibm.com>
---
...u-button-radio-checkbox-text-select-sample.html | 83 ++++++++++++++++++++++
1 file changed, 83 insertions(+)
create mode 100644 ui/js/widgets/samples/menu-button-radio-checkbox-text-select-sample.html
diff --git a/ui/js/widgets/samples/menu-button-radio-checkbox-text-select-sample.html b/ui/js/widgets/samples/menu-button-radio-checkbox-text-select-sample.html
new file mode 100644
index 0000000..4ec6105
--- /dev/null
+++ b/ui/js/widgets/samples/menu-button-radio-checkbox-text-select-sample.html
@@ -0,0 +1,83 @@
+<!--Sample code of menu/button/radio/checkbox/text/select-->
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>Demo</title>
+ <script src="../../../libs/jquery-1.10.0.min.js"></script>
+ <script src="../../../libs/jquery-ui.min.js"></script>
+ <script src="../menu-flat.js"></script>
+ <script src="../button-flat.js"></script>
+ <script src="../radio-flat.js"></script>
+ <script src="../checkbox-flat.js"></script>
+ <script src="../textbox-flat.js"></script>
+ <script src="../selectmenu-flat.js"></script>
+ <link rel="stylesheet" href="../../../libs/themes/base/jquery-ui.min.css">
+ <link rel="stylesheet" href="../../../css/theme-default/menu-flat.css">
+ <link rel="stylesheet" href="../../../css/theme-default/button-flat.css">
+ <link rel="stylesheet" href="../../../css/theme-default/radio-flat.css">
+ <link rel="stylesheet" href="../../../css/theme-default/checkbox-flat.css">
+ <link rel="stylesheet" href="../../../css/theme-default/textbox-flat.css">
+ <link rel="stylesheet" href="../../../css/theme-default/selectmenu-flat.css">
+ <link rel="stylesheet" href="../../../css/fontello/css/animation.css">
+ <link rel="stylesheet" href="../../../css/fontello/css/fontello.css">
+ </head>
+ <body>
+ <div id="menu"></div>
+ <div style="height:50px"><div id="select"></div></div>
+ <div class="radio-demo"></div>
+ <div class="checkbox-demo"></div>
+ <input class="text-demo">
+ <button class="button-demo">submit</button>
+ <script>
+ $(document).ready(function() {
+ $("#menu").menuFlat({
+ content: [1,2,3,4,5,6], //Set content of the menu.
+ icon: "icon-edit-alt", //Set icon of the menu button.
+ listIconList: ["icon-edit-alt","icon-edit-alt","icon-edit-alt","icon-edit-alt","icon-edit-alt","icon-user"]
+ //Set icons of the menu list.
+ // name is optional which set the name of the menu list.
+ });
+ $("#menu0").on("click", function() {
+ alert("hello");
+ });
+ $("#menu1").on("click", function() {
+ console.log("hello");
+ });
+ $("#select").selectmenuFlat({
+ content: [1,2,3,4,5,6], //Set content of the select menu
+ selected: 2 // set the selected option, starts from "1"
+ });
+ $("#select").selectmenuFlat("value", "4"); //Set value.
+ var t = $("#select").selectmenuFlat("value"); //Get value
+ console.log(t);
+ $(".radio-demo").radioFlat({
+ id: "t", //Base id of the radio set.
+ name: "test", //name of the radio.
+ whichChecked: 2, //First selected position, starts from 1.
+ content: ["apple", "banana", "orange", "cherry"] //set the content array.
+ });
+ $(".radio-demo").click(function() {
+ console.log($(".radio-demo").radioFlat("value")); //this is how to get the value of selected radio value
+ });
+ $(".checkbox-demo").checkboxFlat({
+ id: "t", //Checkbox base id.
+ name: "test", //Checkbox name.
+ content: ["apple", "banana", "orange", "cherry"], //Contents of the checkbox set.
+ checked: [1,3] //Set the checked item, which starts with number 1.
+ });
+ $(".checkbox-demo").click(function() {
+ console.log($(".selector").checkboxFlat("value")); //Get value of the checked checkbox.
+ });
+ $(".text-demo").textboxFlat({
+ hint: "hint"
+ });
+ $(".text-demo").css({
+ "height": "30px",
+ "width": "200px"
+ });
+ $(".button-demo").buttonFlat();
+ });
+ </script>
+ </body>
+</html>
\ No newline at end of file
--
2.1.0
9 years, 11 months
[PATCH] UI: Sample of message widget
by Wen Wang
Signed-off-by: Wen Wang <wenwang(a)linux.vnet.ibm.com>
---
ui/js/widgets/samples/message-sample.html | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
create mode 100644 ui/js/widgets/samples/message-sample.html
diff --git a/ui/js/widgets/samples/message-sample.html b/ui/js/widgets/samples/message-sample.html
new file mode 100644
index 0000000..e93a29a
--- /dev/null
+++ b/ui/js/widgets/samples/message-sample.html
@@ -0,0 +1,30 @@
+<!--Sample code of message-->
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>Gauge Demo</title>
+ <script src="../../../libs/jquery-1.10.0.min.js"></script>
+ <script src="../../../libs/jquery-ui.min.js"></script>
+ <script src="../message-flat.js"></script>
+ <link rel="stylesheet" href="../../../libs/themes/base/jquery-ui.min.css">
+ <link rel="stylesheet" href="../../../css/theme-default/message-flat.css">
+ <link rel="stylesheet" href="../../../css/fontello/css/animation.css">
+ <link rel="stylesheet" href="../../../css/fontello/css/fontello.css">
+ </head>
+ <body>
+ <div class="message-demo"></div>
+ <script>
+ $(document).ready(function() {
+ $(".message-demo").messageFlat({
+ contentMain: "This is a test", //Content you are going to add
+ contentConfirm: "Sure?", //Content that inform user whether they want to continue.
+ //Default value is: "Are you sure you want to go on?"
+ confirm: function() {
+ alert("comfirmed")
+ }
+ });
+ });
+ </script>
+ </body>
+</html>
\ No newline at end of file
--
2.1.0
9 years, 11 months
[PATCH] UI: Sample of list widget
by Wen Wang
Signed-off-by: Wen Wang <wenwang(a)linux.vnet.ibm.com>
---
ui/js/widgets/samples/list-sample.html | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
create mode 100644 ui/js/widgets/samples/list-sample.html
diff --git a/ui/js/widgets/samples/list-sample.html b/ui/js/widgets/samples/list-sample.html
new file mode 100644
index 0000000..e9a3c71
--- /dev/null
+++ b/ui/js/widgets/samples/list-sample.html
@@ -0,0 +1,27 @@
+<!--Sample code of list-->
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>Gauge Demo</title>
+ <script src="../../../libs/jquery-1.10.0.min.js"></script>
+ <script src="../../../libs/jquery-ui.min.js"></script>
+ <script src="../list-flat.js"></script>
+ <link rel="stylesheet" href="../../../libs/themes/base/jquery-ui.min.css">
+ <link rel="stylesheet" href="../../../css/theme-default/list-flat.css">
+ <link rel="stylesheet" href="../../../css/fontello/css/animation.css">
+ <link rel="stylesheet" href="../../../css/fontello/css/fontello.css">
+ </head>
+ <body>
+ <div class="list-demo"></div>
+ <script>
+ $(document).ready(function() {
+ $(".list-demo").listFlat({
+ title: "Hello World" //Set title.
+ });
+ $(".list-demo").listFlat("addItem", "Hello", "2015", "icon-user", "button1");
+ //Add one item of the list, parameters are: name, info, icon and button-id
+ });
+ </script>
+ </body>
+</html>
\ No newline at end of file
--
2.1.0
9 years, 11 months
[PATCH V2] UI: Adding selectmenu widget for kimchi new UI
by Wen Wang
V1 -> V2:
1) Fix bug of multiple open menu-list
2) Menu-list showed on top of other content
Signed-off-by: Wen Wang <wenwang(a)linux.vnet.ibm.com>
---
ui/css/theme-default/selectmenu-flat.css | 86 ++++++++++++++++++++
ui/js/widgets/selectmenu-flat.js | 130 +++++++++++++++++++++++++++++++
2 files changed, 216 insertions(+)
create mode 100644 ui/css/theme-default/selectmenu-flat.css
create mode 100644 ui/js/widgets/selectmenu-flat.js
diff --git a/ui/css/theme-default/selectmenu-flat.css b/ui/css/theme-default/selectmenu-flat.css
new file mode 100644
index 0000000..272fe22
--- /dev/null
+++ b/ui/css/theme-default/selectmenu-flat.css
@@ -0,0 +1,86 @@
+/*
+ * Project Kimchi
+ *
+ * Copyright IBM, Corp. 2015
+ *
+ * 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.
+ */
+
+.select-content {
+ position: relative;
+ height: 30px;
+ width: 170px;
+}
+
+.selected-box {
+ width: 75%;
+ height: 30px;
+ border: 1px solid #d8d8d8;
+ border-radius: 3px;
+ cursor: pointer;
+ background: #FFFFFF;
+ float: right;
+}
+
+.select-val {
+ display: none;
+}
+
+.select-label {
+ line-height: 32px;
+ vertical-align: middle;
+ position: relative;
+ margin-left: 20px;
+}
+
+.select-icon {
+ position: relative;
+ float: right;
+ line-height: 30px;
+ vertical-align: middle;
+ padding-right: 10px;
+ padding-left: 10px;
+ color: #555555;
+ font-size: 10px;
+}
+
+.select-icon:hover {
+ background: #FCFCFC;
+}
+
+.selectmenu-opt {
+ background: #FFFFFF;
+}
+
+.selectmenu-list {
+ border: 1px solid #d8d8d8;
+ width: 100%;
+ position: absolute;
+ top: 31px;
+ cursor: pointer;
+}
+
+.selectmenu-list li {
+ list-style: none;
+ position: relative;
+ height: 20px;
+ padding: 5px 0 5px 20px;
+ line-height: 21px;
+ vertical-align: middle;
+ border-bottom: 1px solid #d8d8d8;
+ z-index: 3;
+}
+
+.selectmenu-opt:hover {
+ background: #FCFCFC;
+}
diff --git a/ui/js/widgets/selectmenu-flat.js b/ui/js/widgets/selectmenu-flat.js
new file mode 100644
index 0000000..6bf791b
--- /dev/null
+++ b/ui/js/widgets/selectmenu-flat.js
@@ -0,0 +1,130 @@
+/*
+ * Project Kimchi
+ *
+ * Copyright IBM, Corp. 2015
+ *
+ * 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.
+ */
+
+
+// How to use:
+// $(".selector").selectmenuFlat({
+// content: [1,2,3,4,5,6], //Set content of the select menu
+// selected: 2 // set the selected option, starts from "1"
+// });
+// $(".selector").selectmenuFlat("value", "4"); //Set value.
+// var t = $(".selector").selectmenuFlat("value"); //Get value
+// console.log(t);
+
+
+ (function( $ ) {
+ $.widget("kimchi.selectmenuFlat", {
+
+ options: {
+ content: null,
+ name: null,
+ selected: null,
+ parentid: null
+ },
+
+ _create: function() {
+ var that = this;
+ var name = that.options.name || $(this.element).attr("id");
+ var value = that.options.content;
+ var parentid = $(this.element).attr("id");
+ that.options.parentid = parentid;
+ var html = "<div class='selected-box'>" +
+ "<input class='select-val'>" +
+ "<span class='select-label'></span>" +
+ "<span class='select-icon icon-down-open'></span>" +
+ "</div>";
+ $(html).appendTo(that.element);
+ html = that._setValue(value);
+ $(html).appendTo(that.element);
+ $("#" + parentid).addClass("select-content");
+ var sel = that.options.selected || 1;
+ sel = that.options.content[Number(sel) -1];
+ that.options.selected = $.inArray(sel, that.options.content) + 1;
+ $(".select-val", "#" + parentid).text(sel);
+ $(".select-label", "#" + parentid).text(sel);
+ $(".selected-box", "#" + parentid).on("click", this._toggleOpt);
+ $(".selectmenu-opt", "#" + parentid).on("click", function() {
+ var selectedText = $(this).text();
+ that.options.selected = $.inArray(selectedText, that.options.content) +1;
+ $(".selected-box .select-label", "#" + parentid).text(selectedText);
+ $(".select-val", "#" + parentid).text(selectedText);
+ $(".selectmenu-list", "#" + parentid).prop("style", "display:none");
+ $(".select-icon", "#" + parentid).removeClass("icon-up-open");
+ $(".select-icon", "#" + parentid).addClass("icon-down-open").css({
+ "border-left": "none"
+ });
+ });
+ $(document).mouseup(function(e) {
+ var container = $(".selectmenu-opt");
+ if(!container.is(e.target) && container.has(e.target).length === 0 && $(".select-icon").hasClass("icon-up-open")) {
+ $(".selectmenu-list", "#" + parentid).prop("style", "display:none");
+ $(".select-icon", "#" + parentid).removeClass("icon-up-open");
+ $(".select-icon", "#" + parentid).addClass("icon-down-open").css({
+ "border-left": "none"
+ });
+ }
+ });
+ },
+
+ _setValue: function(value) {
+ var that = this;
+ var html = "<ul class='selectmenu-list' style='display:none'>";
+ var name = this.options.name || $(this.element).attr("id");
+ $.each(value, function(index, data) {
+ that.options.content[index] = data.toString();
+ html += "<li id='" + name + index + "' class='selectmenu-opt'>" + data + "</li>";
+ });
+ html += "</ul>";
+ return html;
+ },
+
+ _toggleOpt: function() {
+ var thisButton = $(this).parent().attr("id");
+ if($(".select-icon", "#" + thisButton).hasClass("icon-down-open")) {
+ $(".selectmenu-list", "#" + thisButton).prop("style", "display");
+ $(".select-icon", "#" + thisButton).removeClass("icon-down-open");
+ $(".select-icon", "#" + thisButton).addClass("icon-up-open").css({
+ "border-left": "1px solid #d8d8d8"
+ });
+ } else {
+ $(".selectmenu-list", "#" + thisButton).prop("style", "display:none");
+ $(".select-icon", "#" + thisButton).removeClass("icon-up-open");
+ $(".select-icon", "#" + thisButton).addClass("icon-down-open").css({
+ "border-left": "none"
+ });
+ }
+ },
+
+ value: function(value) {
+ var parentid = this.options.parentid;
+ if(!value) {
+ return $(".selected-box .select-val", "#" + parentid).text();
+ }
+ if (value <= this.options.content.length) {
+ this.options.selected = value;
+ var selectedText = this.options.content[value-1];
+ $(".selected-box .select-label", "#" + parentid).text(selectedText);
+ $(".selected-box .select-val", "#" + parentid).text(selectedText);
+ }
+ },
+
+ _destroy: function() {
+ this.element.remove();
+ }
+ });
+ })(jQuery);
\ No newline at end of file
--
2.1.0
9 years, 11 months
[PATCH V2] UI: Adding new widget of menu to kimchi new UI
by Wen Wang
V1 -> V2:
1) Fix the bug of multiple menu opened in the same time.
2) Make menu appear in the top level.
Signed-off-by: Wen Wang <wenwang(a)linux.vnet.ibm.com>
---
ui/css/theme-default/menu-flat.css | 88 ++++++++++++++++++++++++++++
ui/js/widgets/menu-flat.js | 114 +++++++++++++++++++++++++++++++++++++
2 files changed, 202 insertions(+)
create mode 100644 ui/css/theme-default/menu-flat.css
create mode 100644 ui/js/widgets/menu-flat.js
diff --git a/ui/css/theme-default/menu-flat.css b/ui/css/theme-default/menu-flat.css
new file mode 100644
index 0000000..140fc18
--- /dev/null
+++ b/ui/css/theme-default/menu-flat.css
@@ -0,0 +1,88 @@
+/*
+ * Project Kimchi
+ *
+ * Copyright IBM, Corp. 2015
+ *
+ * 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.
+ */
+
+.menu-content {
+ position: relative;
+ height: 35px;
+ width: 170px;
+}
+
+.menu-box {
+ width: 100%;
+ height: 30px;
+ border-radius: 3px 3px 0 3px;
+ cursor: pointer;
+ vertical-align: middle;
+ background: #4E4D4F;
+ color: #EDEDED;
+ float: right;
+ position: relative;
+ padding-bottom: 5px;
+}
+
+.menu-label {
+ position: relative;
+}
+
+.menu-icon-front,
+.list-icon-front {
+ position: relative;
+ font-size: 17px;
+ line-height: 32px;
+ padding-right: 10px;
+ padding-left: 5px;
+ color: #EDEDED;
+}
+
+.menu-icon {
+ position: relative;
+ float: right;
+ line-height: 35px;
+ padding-right: 10px;
+ padding-left: 10px;
+ color: #CFCFCF;
+ font-size: 10px;
+ border-top-right-radius: 3px;
+}
+
+.menu-container {
+ border: 1px solid #999999;
+ width: 100px;
+}
+
+.menu-list {
+ position: absolute;
+ z-index: 3;
+ float: right;
+ width: 100%;
+ top: 35px;
+ padding-left: 0;
+ cursor: pointer;
+ background: #3A393B
+}
+
+.menu-list li {
+ list-style: none;
+ position: relative;
+ color: #EDEDED;
+ border-top: 1px groove black;
+}
+
+.menu-list li:first-child {
+ border: none;
+}
diff --git a/ui/js/widgets/menu-flat.js b/ui/js/widgets/menu-flat.js
new file mode 100644
index 0000000..8d1a546
--- /dev/null
+++ b/ui/js/widgets/menu-flat.js
@@ -0,0 +1,114 @@
+/*
+ * Project Kimchi
+ *
+ * Copyright IBM, Corp. 2015
+ *
+ * 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.
+ */
+
+ // How to use:
+ // $("#test-bar").menuFlat({
+ // content: [1,2,3,4,5,6], //Set content of the menu.
+ // icon: "icon-edit-alt", //Set icon of the menu button.
+ // listIconList: ["icon-edit-alt","icon-edit-alt","icon-edit-alt","icon-edit-alt","icon-edit-alt","icon-user"]
+ // //Set icons of the menu list.
+ // // name is optional which set the name of the menu list.
+ // });
+ // $("#test-bar0").on("click", function() {
+ // alert("hello");
+ // });
+ // $("#test-bar1").on("click", function() {
+ // console.log("hello");
+ // });
+
+
+ (function( $ ) {
+ $.widget("kimchi.menuFlat", {
+
+ options: {
+ content: null,
+ name: null,
+ parentid: null,
+ icon: null,
+ listIconList: null
+ },
+
+ _create: function() {
+ var that = this;
+ var name = that.options.name || $(this.element).attr("id");
+ var value = that.options.content;
+ var icon = that.options.icon || "";
+ var parentid = $(this.element).attr("id");
+ $("#" + parentid).addClass("menu-content");
+ that.options.parentid = parentid;
+ var html = "<div class='menu-box' id='manu-" + name + "'>" +
+ "<span class='menu-icon-front " + icon + "'></span>" +
+ "<span class='menu-label'>"+ name + "</span>" +
+ "<span class='menu-icon icon-down-open'></span>" +
+ "</div>";
+ $(html).appendTo(that.element);
+ html = that._setValue(value);
+ $(html).appendTo(that.element);
+ $(".menu-box", "#" + parentid).on("click", that._toggleOpt);
+ $(".menu-opt", "#" + parentid).on("click", that._toggleOpt);
+ $(document).mouseup(function(e) {
+ var container = $(".menu-opt");
+ if(!container.is(e.target) && container.has(e.target).length === 0 && $(".menu-icon").hasClass("icon-up-open")) {
+ $(".menu-list", "#" + parentid).prop("style", "display:none");
+ $(".menu-icon", "#" + parentid).removeClass("icon-up-open");
+ $(".menu-icon", "#" + parentid).addClass("icon-down-open").css({
+ "background": "#4E4D4F"
+ });
+ }
+ });
+ },
+
+ _setValue: function(value) {
+ var that = this;
+ var name = that.options.name;
+ var html = "<ul class='menu-list' name='" + name + "' style='display:none'>";
+ var name = this.options.name || $(this.element).attr("id");
+ $.each(value, function(index, data) {
+ that.options.content[index] = data.toString();
+ var liIcon = that.options.listIconList[index] || "";
+ html += "<li id='" + name + index + "' class='menu-opt'>" +
+ "<span class='list-icon-front " + liIcon + "'></span>" +
+ "<span>" + data + "</span>" +
+ "</li>";
+ });
+ html += "</ul>"
+ return html;
+ },
+
+ _toggleOpt: function() {
+ var thisButton = $(this).parent().attr("id") || $(this).parent().parent().attr("id");
+ if($(".menu-icon", "#" + thisButton).hasClass("icon-down-open")) {
+ $(".menu-list", "#" + thisButton).prop("style", "display");
+ $(".menu-icon", "#" + thisButton).removeClass("icon-down-open");
+ $(".menu-icon", "#" + thisButton).addClass("icon-up-open").css({
+ "background": "#3A393B"
+ });
+ } else {
+ $(".menu-list", "#" + thisButton).prop("style", "display:none");
+ $(".menu-icon", "#" + thisButton).removeClass("icon-up-open");
+ $(".menu-icon", "#" + thisButton).addClass("icon-down-open").css({
+ "background": "#4E4D4F"
+ });
+ }
+ },
+
+ _destroy: function() {
+ this.element.remove();
+ }
+ });
+ })(jQuery);
\ No newline at end of file
--
2.1.0
9 years, 11 months
CPU discussion (RE: psutil.NUM_CPUS)
by Christy Perez
After my confusion on Paulo's patch a few weeks ago, I thought I had
just gotten confused, and so I put psutil.NUM_CPUS in my SMT/HT patch.
However, testing now on x86, I'm noticing a difference in the way Power
and x86 report CPUS.
On my laptop:
<cpu>
<arch>x86_64</arch>
<model>SandyBridge</model>
<vendor>Intel</vendor>
<topology sockets='1' cores='2' threads='2'/>
psutil.NUM_CPUS returns 4
On a Power7 system with 16 cores, 4 threads/core (so 64 total threads),
psutil.NUM_CPUS returns 16.
And this is, it turns out, because (and this sounds odd) for *guests* to
be able to do SMT on Power, SMT has to be disabled. So, psutil.NUM_CPUS
will not report the number of vCPUs that are available to guests. The
same change would happen on x86 if you disabled HT, I assume.
So, revisiting this difference that I noticed but wasn't able to
articulate very well last time, do we want to make a change to the host
code to use ppc64_cpu if the arch is Power, instead of psutil.NUM_CPUS?
SMT *is* off, so, technically this isn't correct, but I think we should
provide this information with guests in mind since we are a
virtualization platform.
Regards,
- Christy
9 years, 11 months