--- /dev/null
+/**
+ * browse.js
+ */
+
+var TurbaBrowse = {
+ // Defined externally: contact1, contact2, contact3, copy1, copy2,
+ // submit1, submit2, delete1
+};
+
+function AnySelected()
+{
+ for (i = 0; i < document.contacts.elements.length; i++) {
+ if (document.contacts.elements[i].checked) {
+ return true;
+ }
+ }
+ return false;
+}
+
+function Add(select)
+{
+ if (!AnySelected()) {
+ window.alert(TurbaBrowse.contact1);
+ return false;
+ }
+
+ key = select[select.selectedIndex].value;
+ if (key == '') {
+ window.alert(TurbaBrowse.contact2);
+ return false;
+ }
+
+ if (key.indexOf(':') == -1 || key.lastIndexOf(':') == key.length - 1) {
+ var newList = window.prompt(TurbaBrowse.contact3, '');
+ if (newList != null && newList != '') {
+ if (key.lastIndexOf(':') == key.length - 1) {
+ key = key.substr(0, key.length - 1);
+ }
+ document.contacts.targetAddressbook.value = key;
+ document.contacts.targetNew.value = 1;
+ document.contacts.targetList.value = newList;
+ } else {
+ return false;
+ }
+ } else {
+ document.contacts.targetList.value = key;
+ }
+
+ Submit('add');
+}
+
+function CopyMove(action, select)
+{
+ if (!AnySelected()) {
+ window.alert(TurbaBrowse.contact1);
+ return false;
+ }
+
+ key = select[select.selectedIndex].value;
+ if (key == '') {
+ window.alert(TurbaBrowse.copymove);
+ return false;
+ }
+
+ document.contacts.targetAddressbook.value = key;
+ Submit(action);
+}
+
+function Submit(action)
+{
+ if (AnySelected()) {
+ if (action != 'delete' || window.confirm(TurbaBrowse.submit)) {
+ document.contacts.actionID.value = action;
+ document.contacts.submit();
+ }
+ } else {
+ window.alert(TurbaBrowse.contact1);
+ return false;
+ }
+}
+
+function SelectAll()
+{
+ for (var i = 0; i < document.contacts.elements.length; i++) {
+ document.contacts.elements[i].checked = document.contacts.checkAll.checked;
+ }
+}
+
+function confirmDelete(name)
+{
+ return window.confirm(TurbaBrowse.confirmdelete.replace('%s', name));
+}
return $menu;
}
+ /**
+ * Add browse.js javascript to page.
+ */
+ public function addBrowseJs()
+ {
+ $js = array();
+ $js_text = array(
+ 'confirmdelete' => _("Are you sure that you want to delete %s?"),
+ 'contact1' => _("You must select at least one contact first."),
+ 'contact2' => ("You must select a target contact list."),
+ 'contact3' => _("Please name the new contact list:"),
+ 'copymove' => _("You must select a target address book."),
+ 'submit' => _("Are you sure that you want to delete the selected contacts?"),
+ );
+
+ foreach ($js_text as $key => $val) {
+ $js[] = 'TurbaBrowse.' . $key . ' = ' . Horde_Serialize::serialize($val, Horde_Serialize::JSON, $GLOBALS['registry']->getCharset());
+ }
+
+ Horde::addScriptFile('browse.js', 'turba');
+ Horde::addInlineScript($js);
+ }
+
}
if (!is_array($targetDriver->map[$info_key]) ||
isset($targetDriver->map[$info_key]['attribute'])) {
$objectValue = $object->getValue($info_key);
-
+
// Get 'data' value if object type is image, the
// direct value in other case.
$objAttributes[$info_key] = isset($GLOBALS['attributes'][$info_key]) && $GLOBALS['attributes'][$info_key]['type'] == 'image' ? $objectValue['load']['data'] : $objectValue;
$templates = array();
if (isset($driver)) {
- $templates[] = '/browse/javascript.inc';
+ Turba::addBrowseJs();
// Read the columns to display from the preferences.
$sources = Turba::getColumns();
Horde::addScriptFile('effects.js', 'horde');
Horde::addScriptFile('redbox.js', 'horde');
Horde::addScriptFile('search.js', 'turba');
+if (isset($view) && is_object($view)) {
+ Turba::addBrowseJs();
+}
+
require TURBA_TEMPLATES . '/common-header.inc';
require TURBA_TEMPLATES . '/menu.inc';
echo $tabs->render($_SESSION['turba']['search_mode']);
echo $vbookView->render('vbook');
}
if (isset($view) && is_object($view)) {
- require TURBA_TEMPLATES . '/browse/javascript.inc';
require TURBA_TEMPLATES . '/browse/header.inc';
$view->display();
}
+++ /dev/null
-<script type="text/javascript">
-
-function AnySelected()
-{
- for (i = 0; i < document.contacts.elements.length; i++) {
- if (document.contacts.elements[i].checked) {
- return true;
- }
- }
- return false;
-}
-
-function Add(select)
-{
- if (!AnySelected()) {
- window.alert('<?php echo addslashes(_("You must select at least one contact first.")) ?>');
- return false;
- }
-
- key = select[select.selectedIndex].value;
- if (key == '') {
- alert('<?php echo addslashes(_("You must select a target contact list.")) ?>');
- return false;
- }
-
- if (key.indexOf(':') == -1 || key.lastIndexOf(':') == key.length - 1) {
- var newList = window.prompt('<?php echo addslashes(_("Please name the new contact list:")) ?>\n', '');
- if (newList != null && newList != '') {
- if (key.lastIndexOf(':') == key.length - 1) {
- key = key.substr(0, key.length - 1);
- }
- document.contacts.targetAddressbook.value = key;
- document.contacts.targetNew.value = 1;
- document.contacts.targetList.value = newList;
- } else {
- return false;
- }
- } else {
- document.contacts.targetList.value = key;
- }
-
- Submit('add');
-}
-
-function CopyMove(action, select)
-{
- if (!AnySelected()) {
- window.alert('<?php echo addslashes(_("You must select at least one contact first.")) ?>');
- return false;
- }
-
- key = select[select.selectedIndex].value;
- if (key == '') {
- alert('<?php echo addslashes(_("You must select a target address book.")) ?>');
- return false;
- }
-
- document.contacts.targetAddressbook.value = key;
- Submit(action);
-}
-
-function Submit(action)
-{
- if (AnySelected()) {
- if (action != 'delete' ||
- confirm('<?php echo addslashes(_("Are you sure that you want to delete the selected contacts?")) ?>')) {
- document.contacts.actionID.value = action;
- document.contacts.submit();
- }
- } else {
- window.alert('<?php echo addslashes(_("You must select at least one contact first.")) ?>');
- return false;
- }
-}
-
-function SelectAll()
-{
- for (var i = 0; i < document.contacts.elements.length; i++) {
- document.contacts.elements[i].checked = document.contacts.checkAll.checked;
- }
-}
-
-function confirmDelete(name)
-{
- return confirm('<?php echo addslashes(_("Are you sure that you want to delete %s?")) ?>'.replace('%s', name));
-}
-
-</script>