booksSample.html

<HTML>

<HEAD>

<script>var dFrameFilePath = '../../../../../dFrame/'</script>

<script language="Javascript" src="../../../../../dFrame/dFrame/lib/DFrameAPI.js"></script>

<script language="Javascript">

//FormBuffer class

DFrameAPI.include('/dFrame/ext/formBuffer.js')

//Style

DFrameAPI.include('dFrame/styles/green/styleGreen.js')

DFrameAPI.onLoad = function(){

dFrameStyle.getDefaultBarStyle().setPos('LEFT')

openBooksDemo()

}

//================================ BOOKS =================================

var DFBooksBase

var DFBooksByAuthors

var DFOrder

var booksBuffer

function openBooksDemo() {

if (!DFBooksBase) {

//dFrameBuffer

booksBuffer = new FormBuffer()

//bg document for demo

DFBooksBase=new DFrame([0,0,100,100],'Order Demo',dFrameStyle)

DFBooksBase.addText([65,15], 'Select books and click \'Refresh Order\'')

}

DFBooksBase.show()

openBooksByAuthors()

}

//============================= List of books ================================

function openBooksByAuthors() {

if (!DFBooksByAuthors){

dFrameStyle.setBordersWidth(1)

pos=[10,2,60,50]

DFBooksByAuthors = new DFrame(pos,'List of books',dFrameStyle, DFBooksBase)

DFBooksByAuthors.addButton('Close', 'DFBooksBase.closeFrame()')

DFBooksByAuthors.addButton('Refresh Order','refreshOrder()')

DFBooksByAuthors.setMultipleTarget(false)

DFBooksByAuthors.setTarget('openShowBook()')

}

DFBooksByAuthors.setURL('./books/books.html')

}

//============================== Show one book if selected in the list or the order==

function openShowBook() {

if (!DFShowBook){

var DFShowBook=new DFrame([51,10,95,42],'Book detail', dFrameStyle, DFBooksBase)

DFShowBook.addButton('Close', 'thisDFrame.closeFrame()')

}

return DFShowBook

}

//============================== dFrame for order ============================

function refreshOrder() {

if (!DFOrder) {

var pos=[10,50,90,97]

pos[1] = [DFBooksByAuthors,'BOTTOM',5]

DFOrder=new DFrame(pos,'Order',dFrameStyle, DFBooksBase)

DFOrder.addButton('Close', 'DFBooksBase.closeFrame()')

DFOrder.setTarget('openShowBook()')

}

//Javascript code in orderForm.html form will read booksBuffer's datas and write it on the form

//2nd 'true' parameter: reload form even if already loaded

DFOrder.setURL('./books/orderForm.html', true , true)

}

function updateBothBookForms(parm, fieldName) {

//launched each time a checkbox of the list or the order is clicked (select or deselect)

//see HTML code in books.html or orderForm.html for parameters

if (parm == 'ViewToOrder'){

//click in the view

var source = DFBooksByAuthors

var target = DFOrder

} else {

//click in the order

var source = DFOrder

var target = DFBooksByAuthors

}

var elt = new FormBufferElement(source, 0, fieldName)

//update booksBuffer from elt

booksBuffer.updateElements(elt);

//update target's form[0]

booksBuffer.updateForm(target, 0, fieldName)

}

</script>

</HEAD>

</HTML>