Skip to content

Commit

Permalink
Fixed indentation, renamed ico to icon, improved icon creation and up…
Browse files Browse the repository at this point in the history
…dating logic
  • Loading branch information
falxcerebri committed Sep 22, 2016
1 parent 463bfe2 commit 02f8215
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 84 deletions.
2 changes: 1 addition & 1 deletion contextMenu.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@
height: 20px;
left: 0px;
top: 3px;

position: absolute;
}
/*context menu css end */
47 changes: 13 additions & 34 deletions contextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
var name = selector[i].name,
disable = selector[i].disable,
fun = selector[i].fun,
ico = selector[i].ico,
icon = selector[i].icon,
img = selector[i].img,
title = selector[i].title,
className = selector[i].className,
Expand All @@ -126,42 +126,21 @@
//update class name
className != undefined && elm.attr('class', className);

//update image
var imgIcon = elm.find('.iw-mIcon');
if(imgIcon.length) imgIcon[0].remove();

//update image or icon
if (img) {
var imgIcon = elm.find('.iw-mIcon');
if (imgIcon.length) {
imgIcon[0].src = img;
} else {
elm.prepend('<img src="' + img + '" align="absmiddle" class="iw-mIcon" />');
}
elm.prepend('<img src="' + img + '" align="absmiddle" class="iw-mIcon" />');
} else if (icon) {
elm.prepend('<span align="absmiddle" class="iw-mIcon '+icon+'" />');
}

//update ico
if (ico) {
var imgIcon = elm.find('.iw-mIcon');
if (imgIcon.length) {
if(imgIcon[0].tagName.toLowerCase() === "span"){
var classList = ["iw-mIcon"];
if(typeof ico == "string")
classList.push(ico);
else
classList.push.apply(classList, ico);
imgIcon[0].classList = classList
} else {
imgIcon[0].remove()
elm.prepend('<span align="absmiddle" class="iw-mIcon '+ico.toString().replace(",", " ")+'" />');
}
} else {
elm.prepend('<span align="absmiddle" class="iw-mIcon '+ico.toString().replace(",", " ")+'" />');
}
}


//to change submenus
if (subMenu) {
elm.contextMenu('update', subMenu);
}
}

}

iMethods.onOff(menu);
Expand Down Expand Up @@ -702,17 +681,17 @@
fun = selObj.fun || function() {},
subMenu = selObj.subMenu,
img = selObj.img || '',
ico = selObj.ico || '',
icon = selObj.icon || '',
title = selObj.title || "",
className = selObj.className || "",
disable = selObj.disable,
list = $('<li title="' + title + '" class="' + className + '">' + name + '</li>');

if (img) {
list.prepend('<img src="' + img + '" align="absmiddle" class="iw-mIcon" />');
} else if (ico) {
list.prepend('<span align="absmiddle" class="' + ("iw-mIcon "+ico.toString().replace(","," "))+'" />');
}
} else if (icon) {
list.prepend('<span align="absmiddle" class="' + "iw-mIcon "+icon+'" />');
}
//to add disable
if (disable) {
list.addClass('iw-mDisable');
Expand Down
94 changes: 47 additions & 47 deletions contextMenu.less
Original file line number Diff line number Diff line change
Expand Up @@ -16,63 +16,63 @@
@color6: #e6e6e6; // Appears 1 time

.iw-contextMenu {
-moz-box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
-webkit-box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
border: 1px solid @color6;
box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
display: none;
z-index: 1000;
li.iw-mDisable {
opacity: .3;
}
-moz-box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
-webkit-box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
border: 1px solid @color6;
box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
display: none;
z-index: 1000;
li.iw-mDisable {
opacity: .3;
}
}
.iw-cm-menu {
background: @color5;
color: @color0;
margin: 0px;
padding: 0px;
li {
border-bottom: 1px solid @color4;
cursor: pointer;
list-style: none;
padding-left: 30px;
padding-right: 20px;
padding-top: 5px;
padding-bottom: 5px;
position: relative;
}
background: @color5;
color: @color0;
margin: 0px;
padding: 0px;
li {
border-bottom: 1px solid @color4;
cursor: pointer;
list-style: none;
padding-left: 30px;
padding-right: 20px;
padding-top: 5px;
padding-bottom: 5px;
position: relative;
}
}
.iw-mOverlay {
background: @color1;
height: 100%;
left: 0px;
opacity: .5;
position: absolute;
top: 0px;
width: 100%;
background: @color1;
height: 100%;
left: 0px;
opacity: .5;
position: absolute;
top: 0px;
width: 100%;
}
.iw-mSelected {
background-color: @color2;
color: @color3;
background-color: @color2;
color: @color3;
}
.iw-cm-arrow-right {
border-bottom: 5px solid transparent;
border-left: 5px solid @color0;
border-top: 5px solid transparent;
height: 0;
margin-top: -3px;
position: absolute;
right: 3px;
top: 50%;
width: 0;
border-bottom: 5px solid transparent;
border-left: 5px solid @color0;
border-top: 5px solid transparent;
height: 0;
margin-top: -3px;
position: absolute;
right: 3px;
top: 50%;
width: 0;
}
.iw-mSelected>.iw-cm-arrow-right {
border-left: 5px solid @color1;
border-left: 5px solid @color1;
}
.iw-mIcon {
height: 20px;
left: 0px;
top: 3px;
width: 20px;
position: absolute;
height: 20px;
left: 0px;
top: 3px;
width: 20px;
position: absolute;
}
2 changes: 1 addition & 1 deletion contextMenu.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 02f8215

Please sign in to comment.