Revision a583aa29 ui/static/synnefo.js
b/ui/static/synnefo.js | ||
---|---|---|
50 | 50 |
} |
51 | 51 |
}); |
52 | 52 |
|
53 |
|
|
54 |
// jquery hide event |
|
55 |
var _oldshow = $.fn.show; |
|
56 |
$.fn.show = function(speed, callback) { |
|
57 |
$(this).trigger('show'); |
|
58 |
return _oldshow.apply(this,arguments); |
|
59 |
} |
|
60 |
|
|
53 | 61 |
function ISODateString(d){ |
54 | 62 |
//return a date in an ISO 8601 format using UTC. |
55 | 63 |
//do not include time zone info (Z) at the end |
... | ... | |
1588 | 1596 |
$("a#metadata-scrollable").overlay().close(); |
1589 | 1597 |
} catch(err) {} |
1590 | 1598 |
} |
1599 |
|
|
1600 |
// action indicators |
|
1601 |
function init_action_indicator_handlers(machines_view) |
|
1602 |
{ |
|
1603 |
if (machines_view == "list") |
|
1604 |
{ |
|
1605 |
// totally different logic for list view |
|
1606 |
init_action_indicator_list_handlers(); |
|
1607 |
return; |
|
1608 |
} |
|
1609 |
|
|
1610 |
var has_active_indicators = function(el) |
|
1611 |
{ |
|
1612 |
return ($("img.spinner:visible", el.parent().parent()).length >= 1) || ($("img.wave:visible", el.parent().parent()).length >= 1) |
|
1613 |
} |
|
1614 |
|
|
1615 |
// action indicators |
|
1616 |
$(".action-container").live('mouseover', function(evn){ |
|
1617 |
var el = $(evn.currentTarget); |
|
1618 |
// we dont need the single-action class |
|
1619 |
var action_class = el.attr("class").replace("action-container",""); |
|
1620 |
// pass the hovered element action related class to the indicator image |
|
1621 |
$("div.action-indicator", el.parent().parent()).attr("class", "action-indicator " + action_class); |
|
1622 |
|
|
1623 |
// spinner || wave indicators already visible. dont show action image to avoid clutter |
|
1624 |
if (has_active_indicators(el)) |
|
1625 |
{ |
|
1626 |
return; |
|
1627 |
} |
|
1628 |
$("div.action-indicator", el.parent().parent()).show(); |
|
1629 |
}); |
|
1630 |
|
|
1631 |
// hide action indicator image on mouse out, spinner appear, wave appear |
|
1632 |
$(".action-container").live("mouseout", function(evn){ |
|
1633 |
var el = $(evn.currentTarget); |
|
1634 |
$("div.action-indicator").hide(); |
|
1635 |
|
|
1636 |
var pending_for_confirm_action = $(".confirm_single:visible", el.parent().parent()); |
|
1637 |
// if we mouse out and another action is in confirmation mode |
|
1638 |
if (!has_active_indicators(el)) |
|
1639 |
{ |
|
1640 |
// no actions pending |
|
1641 |
if (pending_for_confirm_action.length == 0) |
|
1642 |
{ |
|
1643 |
return; |
|
1644 |
} |
|
1645 |
|
|
1646 |
// find action pending and show icon |
|
1647 |
var action_container = $($(pending_for_confirm_action[0]).parent()); |
|
1648 |
var action_class = action_container.attr("class").replace("action-container",""); |
|
1649 |
$("div.action-indicator", action_container.parent().parent()).attr("class", "action-indicator " + action_class); |
|
1650 |
$("div.action-indicator").show(); |
|
1651 |
} |
|
1652 |
|
|
1653 |
}); |
|
1654 |
|
|
1655 |
$("img.spinner, img.wave").live('show', function(){ |
|
1656 |
$("div.action-indicator").hide(); |
|
1657 |
}); |
|
1658 |
} |
|
1659 |
|
|
1660 |
function init_action_indicator_list_handlers() |
|
1661 |
{ |
|
1662 |
var skip_actions = { 'console':'','connect':'','details':'' }; |
|
1663 |
|
|
1664 |
var has_pending_confirmation = function() |
|
1665 |
{ |
|
1666 |
return $(".confirm_multiple:visible").length >= 1 |
|
1667 |
} |
|
1668 |
|
|
1669 |
function update_action_indicator_icons(force_action, skip_pending) |
|
1670 |
{ |
|
1671 |
// pending action based on the element class |
|
1672 |
var pending_action = $(".selected", $(".actions"))[0]; |
|
1673 |
var selected = get_list_view_selected_machine_rows(); |
|
1674 |
|
|
1675 |
// reset previous state |
|
1676 |
list_view_hide_action_indicators(); |
|
1677 |
|
|
1678 |
if (pending_action == undefined && !force_action) |
|
1679 |
{ |
|
1680 |
// no action selected |
|
1681 |
return; |
|
1682 |
} |
|
1683 |
|
|
1684 |
if (force_action != undefined) |
|
1685 |
{ |
|
1686 |
// user forced action choice |
|
1687 |
var action_class = force_action; |
|
1688 |
} else { |
|
1689 |
// retrieve action name (reboot, stop, etc..) |
|
1690 |
var action_class = $(pending_action).attr("id").replace("action-",""); |
|
1691 |
} |
|
1692 |
|
|
1693 |
selected.each(function(index, el) { |
|
1694 |
if (has_pending_confirmation() && skip_pending) |
|
1695 |
{ |
|
1696 |
return; |
|
1697 |
} |
|
1698 |
var el = $(el); |
|
1699 |
var logo = $("img.list-logo", el); |
|
1700 |
$(".action-indicator", el).remove(); |
|
1701 |
var cls = "action-indicator " + action_class; |
|
1702 |
// add icon div |
|
1703 |
logo.after('<div class="' + cls + '"></div>'); |
|
1704 |
// hide os logo |
|
1705 |
$("img.list-logo", el).hide(); |
|
1706 |
}); |
|
1707 |
} |
|
1708 |
|
|
1709 |
// on mouseover we force the images to the hovered action |
|
1710 |
$(".actions a").live("mouseover", function(evn) { |
|
1711 |
var el = $(evn.currentTarget); |
|
1712 |
if (!el.hasClass("enabled")) |
|
1713 |
{ |
|
1714 |
return; |
|
1715 |
} |
|
1716 |
var action_class = el.attr("id").replace("action-",""); |
|
1717 |
if (action_class in skip_actions) |
|
1718 |
{ |
|
1719 |
return; |
|
1720 |
} |
|
1721 |
update_action_indicator_icons(action_class, false); |
|
1722 |
}); |
|
1723 |
|
|
1724 |
$(".actions a").live("click", function(evn) { |
|
1725 |
var el = $(evn.currentTarget); |
|
1726 |
el.addClass("selected"); |
|
1727 |
update_action_indicator_icons(undefined, false); |
|
1728 |
}); |
|
1729 |
|
|
1730 |
$(".actions a").live("mouseout", function(evn) { |
|
1731 |
update_action_indicator_icons(undefined, false); |
|
1732 |
}); |
|
1733 |
|
|
1734 |
$(".confirm_multiple button.no").click(function(){ |
|
1735 |
list_view_hide_action_indicators(); |
|
1736 |
}); |
|
1737 |
|
|
1738 |
$(".confirm_multiple button.yes").click(function(){ |
|
1739 |
list_view_hide_action_indicators(); |
|
1740 |
}); |
|
1741 |
|
|
1742 |
$("input[type=checkbox]").live('change', function(){ |
|
1743 |
// pending_actions will become empty on every checkbox click/change |
|
1744 |
// line 154 machines_list.html |
|
1745 |
pending_actions = []; |
|
1746 |
if (pending_actions.length == 0) |
|
1747 |
{ |
|
1748 |
$(".confirm_multiple").hide(); |
|
1749 |
$("a.selected").each(function(index, el){$(el).removeClass("selected")}); |
|
1750 |
} |
|
1751 |
update_action_indicator_icons(undefined, false); |
|
1752 |
}); |
|
1753 |
|
|
1754 |
} |
|
1755 |
|
|
1756 |
function list_view_hide_action_indicators() |
|
1757 |
{ |
|
1758 |
$("tr td .action-indicator").remove(); |
|
1759 |
$("tr td img.list-logo").show(); |
|
1760 |
} |
|
1761 |
|
|
1762 |
function get_list_view_selected_machine_rows() |
|
1763 |
{ |
|
1764 |
var table = $("table.list-machines"); |
|
1765 |
var rows = $("tr:has(input[type=checkbox]:checked)",table); |
|
1766 |
return rows; |
|
1767 |
} |
|
1768 |
|
Also available in: Unified diff