Fix print.

This commit is contained in:
Paulo Gustavo Veiga 2012-05-19 00:13:06 -03:00
parent 4546aaad98
commit 6a6efd58f4
2 changed files with 56 additions and 103 deletions

View File

@ -71,12 +71,12 @@ jQuery.fn.dialogForm = function(options) {
var containerId = this[0].id; var containerId = this[0].id;
var url = options.url; var url = options.url;
var acceptButtonLabel = options.acceptButtonLabel;
// Clean previous dialog content ... // Clean previous dialog content ...
$("#" + containerId + " div[id='errorMessage']").text("").removeClass("ui-state-highlight"); $("#" + containerId + " div[id='errorMessage']").text("").removeClass("ui-state-highlight");
$('#' + containerId + ' .btn-accept').click(function() { var acceptBtn = $('#' + containerId + ' .btn-accept');
acceptBtn.click(function() {
var formData = {}; var formData = {};
$('#' + containerId + ' input').each(function(index, elem) { $('#' + containerId + ' input').each(function(index, elem) {
formData[elem.name] = elem.value; formData[elem.name] = elem.value;
@ -93,12 +93,14 @@ jQuery.fn.dialogForm = function(options) {
var resourceId = jqXHR.getResponseHeader("ResourceId"); var resourceId = jqXHR.getResponseHeader("ResourceId");
var redirectUrl = options.redirect; var redirectUrl = options.redirect;
redirectUrl = redirectUrl.replace("{header.resourceId}", resourceId); redirectUrl = redirectUrl.replace("{header.resourceId}", resourceId);
$(acceptBtn).button('loading');
$("#" + containerId).modal('hide');
window.location = redirectUrl; window.location = redirectUrl;
} else if (options.postUpdate) { } else if (options.postUpdate) {
options.postUpdate(formData); options.postUpdate(formData);
} }
$(this).dialog("close");
}, },
error: function(jqXHR, textStatus, errorThrown) { error: function(jqXHR, textStatus, errorThrown) {
if (jqXHR.status == 400) { if (jqXHR.status == 400) {

View File

@ -129,52 +129,11 @@
<!--Buttons--> <!--Buttons-->
<script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
$(function() { $(function() {
$("#actionButtons .show-tags").button({
icons: { primary: "ui-icon-folder-open" }
}).click(function() {
if ($("#tags").css("opacity") == 0) {
$("#tags").css("opacity", 1);
$("#mindmapListTable").animate({
width: "77%"
}, 1000);
} else {
$("#mindmapListTable").animate({
width: "100%"
}, 1000, function() {
$("#tags").css("opacity", 0);
});
}
});
$("#actionButtons .share").button({
icons: { primary: "ui-icon-transferthick-e-w" }
}).click(function() {
var selectedMaps = $('#mindmapListTable').dataTableExt.getSelectedMapsIds();
var html2 = $('#share-dialog-modal p span').html(selectedMaps.toString());
if (selectedMaps.length > 0) {
$("#share-dialog-modal").dialog({
height: 140,
modal: true,
buttons: {
"Delete": function() {
$(this).dialog("close");
},
Cancel: function() {
$(this).dialog("close");
}
}
});
}
});
// Creation buttons actions ... // Creation buttons actions ...
$("#newBtn").click( $("#newBtn").click(
function() { function() {
$("#new-dialog-modal").dialogForm({ $("#new-dialog-modal").dialogForm({
modal: true, modal: true,
acceptButtonLabel : "Create",
cancelButtonLabel : "Cancel",
redirect: "c/map/{header.resourceId}/edit.htm", redirect: "c/map/{header.resourceId}/edit.htm",
url : "../service/maps" url : "../service/maps"
}); });
@ -184,7 +143,6 @@
window.open('c/map/import.htm'); window.open('c/map/import.htm');
}); });
$("#duplicateBtn").click(function() { $("#duplicateBtn").click(function() {
// Map to be cloned ... // Map to be cloned ...
var tableElem = $('#mindmapListTable'); var tableElem = $('#mindmapListTable');
@ -201,8 +159,6 @@
// Initialize dialog ... // Initialize dialog ...
$("#duplicate-dialog-modal").dialogForm({ $("#duplicate-dialog-modal").dialogForm({
modal: true, modal: true,
acceptButtonLabel : "Duplicate",
cancelButtonLabel : "Cancel",
redirect: "c/map/{header.resourceId}/edit.htm", redirect: "c/map/{header.resourceId}/edit.htm",
url : "../service/maps/" + mapId url : "../service/maps/" + mapId
}); });
@ -210,45 +166,40 @@
}); });
$("#renameBtn").click(function() { $("#renameBtn").click(function() {
// Map to be cloned ... // Map to be cloned ...
var tableElem = $('#mindmapListTable'); var tableElem = $('#mindmapListTable');
var rows = tableElem.dataTableExt.getSelectedRows(); var rows = tableElem.dataTableExt.getSelectedRows();
if (rows.length > 0) { if (rows.length > 0) {
// Obtain map name ... // Obtain map name ...
var dataTable = tableElem.dataTable(); var dataTable = tableElem.dataTable();
var rowData = dataTable.fnGetData(rows[0]); var rowData = dataTable.fnGetData(rows[0]);
// Fill dialog with default values ... // Fill dialog with default values ...
var mapId = rowData.id; var mapId = rowData.id;
$("#rename-dialog-modal input[name='title']").attr('value', rowData.title); $("#rename-dialog-modal input[name='title']").attr('value', rowData.title);
$("#rename-dialog-modal input[name='description']").attr('value', rowData.description); $("#rename-dialog-modal input[name='description']").attr('value', rowData.description);
// Set title ...
$('#renameDialogTitle').text("Rename '" + rowData.title + "'");
// Set title ... // Initialize dialog ...
$('#renameDialogTitle').text("Rename '" + rowData.title + "'"); $("#rename-dialog-modal").dialogForm({
modal: true,
type: 'PUT',
postUpdate: function(reqBodyData) {
// Remove old entry ...
dataTable.fnDeleteRow(rowData);
// Add a new one...
// Initialize dialog ... rowData.title = reqBodyData.title;
$("#rename-dialog-modal").dialogForm({ rowData.description = reqBodyData.description;
modal: true, dataTable.fnAddData(rowData);
type: 'PUT', },
acceptButtonLabel : "Rename", url : "../service/maps/" + mapId + "/title"
cancelButtonLabel : "Cancel",
postUpdate: function(reqBodyData) {
// Remove old entry ...
dataTable.fnDeleteRow(rowData);
// Add a new one...
rowData.title = reqBodyData.title;
rowData.description = reqBodyData.description;
dataTable.fnAddData(rowData);
},
url : "../service/maps/" + mapId
});
}
}); });
}
});
$("#deleteBtn").click(function() { $("#deleteBtn").click(function() {
var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds(); var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds();
@ -270,29 +221,28 @@
} }
}); });
$("#actionButtons .printMap").button({ $("#printBtn").click(function() {
icons: { primary: "ui-icon-print" } var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds();
}).click(function() { if (mapIds.length > 0) {
var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds(); window.open('c/map/' + mapIds[0] + '/print.htm');
if (mapIds.length > 0) { }
window.open('c/map/' + mapIds[0] + '/print.htm'); });
}
});
$("#actionButtons .publishMap").button({ $("#actionButtons .publishMap").click(function() {
icons: { primary: "ui-icon-print" } });
}).click(function() {
});
$("#actionButtons .shareMap").button({ $("#actionButtons .shareMap").click(function() {
icons: { primary: "ui-icon-print" } });
}).click(function() {
}); $("#actionButtons .tagMap").click(function() {
});
$("#actionButtons .share").click(function() {
});
$("#actionButtons .tags").click(function() {
});
$("#actionButtons .tagMap").button({
icons: { primary: "ui-icon-print" }
}).click(function() {
});
}); });
// Register time update functions .... // Register time update functions ....
@ -329,9 +279,10 @@
<span class="caret"></span> <span class="caret"></span>
</button> </button>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li id="duplicateBtn"><a href="#" onclick="return false"><i class="icon-plus-sign"></i> Duplicate</a></li> <li id="duplicateBtn"><a href="#" onclick="return false"><i class="icon-plus-sign"></i>
Duplicate</a></li>
<li id="renameBtn"><a href="#" onclick="return false"><i class="icon-edit"></i> Rename</a></li> <li id="renameBtn"><a href="#" onclick="return false"><i class="icon-edit"></i> Rename</a></li>
<li id="printMap"><a href="#" onclick="return false"><i class="icon-print"></i> Print</a></li> <li id="printBtn"><a href="#" onclick="return false"><i class="icon-print"></i> Print</a></li>
<li id="publishMap"><a href="#" onclick="return false"><i class="icon-globe"></i>Publish</a></li> <li id="publishMap"><a href="#" onclick="return false"><i class="icon-globe"></i>Publish</a></li>
<li id="exportMap"><a href="#" onclick="return false"><i class="icon-download-alt"></i> Export</a> <li id="exportMap"><a href="#" onclick="return false"><i class="icon-download-alt"></i> Export</a>
</li> </li>
@ -370,7 +321,7 @@
</form> </form>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn btn-primary btn-accept">Create</button> <button class="btn btn-primary btn-accept" data-loading-text="Creating ...">Create</button>
<button class="btn btn-cancel">Close</button> <button class="btn btn-cancel">Close</button>
</div> </div>
</div> </div>