cell = row.insertCell(row.cells.length);
add_css_class(cell, "my_opac_info_table_header");
- cell.appendChild(mktext("Notify Email"));
+ cell.appendChild(mktext("Notify Email / Phone"));
cell = row.insertCell(row.cells.length);
add_css_class(cell, "my_opac_info_table_header");
- cell.appendChild(mktext("Notify Phone"));
+ cell.appendChild(mktext("Cancel"));
for( var idx = 0; idx != holds.length; idx++ ) {
_doCallbackDance(table, holds[idx]);
formats = modsFormatToMARC(record.types_of_resource()[0]);
cell.appendChild(_mkFormatList(formats));
+ cell.noWrap = "nowrap";
+ cell.setAttribute("nowrap", "nowrap");
cell = row.insertCell(row.cells.length);
add_css_class(cell, "my_opac_profile_cell");
cell = row.insertCell(row.cells.length);
add_css_class(cell, "my_opac_profile_cell");
- cell.appendChild(mktext(hold.email_notify()));
+ cell.appendChild(_buildChangeEmailNotify(hold));
+ cell.appendChild(elem("br"));
+ cell.appendChild(_buildChangePhoneNotify(hold));
+
cell = row.insertCell(row.cells.length);
+ var a = elem("a",{href:"javascript:void(0);",
+ style:"text-decoration:underline"},null, "Cancel");
+ a.onclick = function(){_cancelHoldRequest(hold);};
add_css_class(cell, "my_opac_profile_cell");
- cell.appendChild(mktext(hold.phone_notify()));
+ cell.appendChild(a);
+}
+
+function _cancelHoldRequest(hold) {
+ alert("Canceling hold " + hold.id());
+}
+
+function _buildChangeEmailNotify(hold) {
+ var a = elem("a",{href:"javascript:void(0);",
+ style:"text-decoration:underline"},null, hold.email_notify());
+ var et1 = elem("input",{type:"text",size:"20"});
+ var et2 = elem("input",{type:"text",size:"20"});
+ var box = new PopupBox(a);
+ var but = elem("input",{type:"submit",value:"Submit"});
+ var can = elem("input",{type:"submit",value:"Cancel"});
+
+ but.onclick = function(){
+ var ret = _submitUpdateNotifyEmail(hold);
+ if(ret) box.hide();
+ }
+ can.onclick = function(){ box.hide(); };
+
+ box.title("Change Holds Notification Email");
+ box.addText("Enter new notification email");
+ box.addNode(et1);
+ box.lines(1);
+ box.addText("Repeat email");
+ box.addNode(et2);
+ box.lines();
+ box.makeGroup([ but, can ]);
+
+ a.onclick = function(){box.show();}
+ return a;
+}
+
+/* return true to show success */
+function _submitUpdateNotifyEmail(hold) {
+ alert("updating email for hold " + hold.id());
+ return true;
+}
+
+function _submitUpdateNotifyPhone(hold) {
+ alert("updating phone for hold " + hold.id());
+ return true;
+}
+
+
+function _buildChangePhoneNotify(hold) {
+ var a = elem("a",{href:"javascript:void(0);",
+ style:"text-decoration:underline"},null, hold.phone_notify());
+ var et1 = elem("input",{type:"text",size:"10"});
+ var box = new PopupBox(a);
+ var but = elem("input",{type:"submit",value:"Submit"});
+ var can = elem("input",{type:"submit",value:"Cancel"});
+
+ but.onclick = function(){
+ var ret = _submitUpdateNotifyPhone(hold);
+ if(ret) box.hide();
+ }
+ can.onclick = function(){ box.hide(); };
+
+ box.title("Change Holds Notification Phone Number");
+ box.addText("Enter new notification number");
+ box.addNode(et1);
+ box.lines();
+ box.makeGroup([ but, can ]);
+
+ a.onclick = function(){box.show();}
+ return a;
}
-/* returns [ xoffset, yoffset ] of the target node */
-function getXYOffsets(target) {
+/* returns [ xoffset, yoffset ] of the target node
+ object (if provided) is used as the box that will be displayed */
+function getXYOffsets(target, object) {
var x = findPosX(target);
var y = findPosY(target);
var height = getObjectHeight(target);
- var xpos = x;
+ var xpos;
+
+ if(object)
+ xpos = x - getObjectWidth(object) + getObjectWidth(target);
+ else xpos = x;
var offsety = y + height;
var offsetx = xpos;
- if(IE) { /*HACK XXX*/
+/*
+ if(IE) {
offsety = parseInt(offsety) + 15;
offsetx = parseInt(offsetx) + 8;
}
+*/
debug("getXYOffset y: " + offsety + " x: " + offsetx );
- return [x, y];
+ return [offsetx, offsety];
}
}
+/* return [ x, y ] for the window */
+function getWindowSize() {
+ var doc = getDocument();
+ var win = getWindow();
+ if (IE)
+ return [doc.body.offsetWidth, doc.body.offsetHeight ];
+ return [ win.innerWidth, win.innerHeight ];
+}
+
--- /dev/null
+/* @target is the object next to which the box should pop up.
+ */
+function PopupBox(target, body) {
+ this.target = target;
+ this.div = elem("div");
+ add_css_class(this.div,"popup_box");
+ add_css_class(this.div,"hide_me");
+ if(body) this.div.appendChild(body);
+ getDocument().body.appendChild(this.div);
+}
+
+PopupBox.prototype.setBody = function(body) {
+ if(body) this.div.appendChild(body);
+}
+
+PopupBox.prototype.addNode = function(node) {
+ if(node) {
+ this.div.appendChild(node);
+ this.lines();
+ }
+}
+
+PopupBox.prototype.addText = function(text) {
+ if(text) {
+ this.div.appendChild(mktext(text));
+ this.lines();
+ }
+}
+
+PopupBox.prototype.lines = function(count) {
+ if(count == null) count = 1;
+ for( var x = 0; x < count; x++ ) {
+ this.div.appendChild(elem("br"));
+ }
+}
+
+PopupBox.prototype.title = function(title) {
+
+ if(title != null) {
+
+ var div = elem("div");
+ add_css_class(div, "popup_box_title");
+ div.appendChild(mktext(title));
+ this.lines();
+
+ if(this.div.firstChild)
+ this.div.insertBefore(div, this.div.firstChild);
+ else
+ this.div.appendChild(div);
+ }
+}
+
+
+PopupBox.prototype.show = function() {
+
+ remove_css_class(this.div,"hide_me");
+
+ var A = getXYOffsets(this.target, this.div);
+ var newx = A[0];
+ var newy = A[1];
+
+ var W = getWindowSize();
+ var wx = W[0];
+ var wy = W[1];
+
+
+ var x = getObjectWidth(this.div);
+ var y = getObjectHeight(this.div);
+
+ //alert(wx + " : " + wy + " : " + x + " : " + y + " : " + newx + " : " + newy);
+
+ if( (newx + x) > wx )
+ newx = newx - x;
+
+ if( (newy + y) > wy )
+ newy = newy - y - getObjectHeight(this.target);
+
+ this.div.style.left = newx;
+ this.div.style.top = newy;
+
+ add_css_class(this.div,"show_me");
+}
+
+PopupBox.prototype.hide = function() {
+ remove_css_class(this.div,"show_me");
+ add_css_class(this.div,"hide_me");
+}
+
+/* pass in an array of DOM nodes and they will
+ be displayed as a group along the box */
+PopupBox.prototype.makeGroup = function(buttons) {
+
+ var table = elem("table");
+ add_css_class(table, "popup_box_buttons");
+ var row = table.insertRow(0);
+
+ for(var i = 0; i!= buttons.length; i++) {
+ var cell = row.insertCell(row.cells.length);
+ cell.appendChild(buttons[i]);
+ }
+
+ this.div.appendChild(elem("br"));
+ this.div.appendChild(table);
+}