2011-05-18 16:46:22 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-05-16 20:19:32 -07:00
|
|
|
$(function() {
|
2011-05-18 16:46:22 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$( "#lineItemModal" ).dialog({
|
|
|
|
|
autoOpen: false,
|
|
|
|
|
height: 900,
|
|
|
|
|
width: 600,
|
|
|
|
|
modal: true,
|
|
|
|
|
buttons: {
|
|
|
|
|
"Add Line Item": function() {
|
|
|
|
|
//var thisShipmentInputs = $('#ShipmentAddForm').find('input,select,textarea');
|
|
|
|
|
|
|
|
|
|
$.post('/line_items/ajax_add', null, function(data) {
|
|
|
|
|
$( "#lineItemModal" ).dialog('close');
|
|
|
|
|
//window.location.reload(); //Change this to fetch a new copy of the table and update a <div>.
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
Cancel: function() {
|
|
|
|
|
$( this ).dialog( "close" );
|
|
|
|
|
//$("#ShipmentAddForm")[0].reset();
|
|
|
|
|
$("#principlesList").empty();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
close: function() {
|
|
|
|
|
|
|
|
|
|
$("#importFields").hide();
|
|
|
|
|
$("#principle").hide();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2011-05-16 20:19:32 -07:00
|
|
|
});
|
|
|
|
|
|
2011-05-18 16:46:22 -07:00
|
|
|
//Setup CKEditor toolbars
|
|
|
|
|
var config = {
|
|
|
|
|
toolbar:[
|
|
|
|
|
|
|
|
|
|
['Cut','Copy','Paste','PasteText','PasteFromWord','-','Scayt'],
|
|
|
|
|
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
|
|
|
|
|
['Image','Table','HorizontalRule','SpecialChar'],
|
|
|
|
|
'/',
|
|
|
|
|
['Styles','Format'],
|
|
|
|
|
['Bold','Italic','Strike'],
|
|
|
|
|
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
|
|
|
|
|
['Link','Unlink'],
|
|
|
|
|
['Maximize','-','About']
|
|
|
|
|
]
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$("#pageContentFactory").hide();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Add a new Page Element.
|
|
|
|
|
$("#addPage").button().click(function(event) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('.page').ckeditor(function() {
|
|
|
|
|
this.destroy();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var newPage = $('#pageContentFactory').clone();
|
|
|
|
|
newPage.removeAttr('id');
|
|
|
|
|
newPage.show();
|
|
|
|
|
|
2011-05-16 20:19:32 -07:00
|
|
|
|
|
|
|
|
|
2011-05-18 16:46:22 -07:00
|
|
|
var pageCount = $('.docPage').length;
|
|
|
|
|
|
|
|
|
|
//alert(pageCount);
|
|
|
|
|
|
|
|
|
|
pageCount++;
|
|
|
|
|
var model = 'DocPage';
|
|
|
|
|
var field = 'content';
|
|
|
|
|
var ID = getCakeID(model,pageCount, field);
|
|
|
|
|
var name = getCakeName(model, pageCount, field);
|
|
|
|
|
|
|
|
|
|
newPage.find('label').attr('for', ID);
|
|
|
|
|
|
|
|
|
|
newPage.find('textarea').attr('id', ID).attr('name', name);
|
|
|
|
|
newPage.addClass('docPage');
|
|
|
|
|
|
|
|
|
|
var hiddenName = getCakeName(model, pageCount, 'page_number');
|
|
|
|
|
|
|
|
|
|
newPage.append('<input type="hidden" name="'+hiddenName+'" value="'+pageCount+'">');
|
|
|
|
|
$('.pages').append(newPage);
|
|
|
|
|
|
|
|
|
|
$('.page').ckeditor(config);
|
2011-05-16 20:19:32 -07:00
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
2011-05-18 16:46:22 -07:00
|
|
|
//Open the LineItem dialog
|
|
|
|
|
$("#addLineItem").button().click(function() {
|
|
|
|
|
|
|
|
|
|
$( "#lineItemModal" ).dialog('open');
|
2011-05-16 20:19:32 -07:00
|
|
|
|
|
|
|
|
|
2011-05-18 16:46:22 -07:00
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#principleSelect").change(function() {
|
|
|
|
|
alert("OH YEAH LETS DO THIS");
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Initialize the editor.
|
|
|
|
|
// Callback function can be passed and executed after full instance creation.
|
|
|
|
|
$('.page').ckeditor(config);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Remove this Page
|
|
|
|
|
$(".removePage").live('click',function() {
|
|
|
|
|
|
|
|
|
|
$('.page').ckeditor(function() {
|
|
|
|
|
this.destroy();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$(this).parents(".docPage").remove();
|
|
|
|
|
|
|
|
|
|
$('.page').ckeditor(config);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|