diff --git a/fields/pod.py b/fields/pod.py index dde9045..27cdb11 100644 --- a/fields/pod.py +++ b/fields/pod.py @@ -66,8 +66,8 @@ class Pod(Field): ''') + onclick=":'generatePod(this,%s,%s,%s,%s,%s,null,%s)' % (q(uid), \ + q(name), q(info.template), q(fmt), q(ztool.getQueryInfo()), gc)"/>''') pxView = pxCell = Px(''' - :search.translated ''') diff --git a/fields/workflow.py b/fields/workflow.py index 0e3ffbc..9f1682d 100644 --- a/fields/workflow.py +++ b/fields/workflow.py @@ -472,10 +472,10 @@ class UiTransition: css=ztool.getButtonCss(label, inButtons)"> + onclick=":'triggerTransition(%s,this,%s,%s)' % \ + (q(formId), q(transition.confirm), back)"/> = 0) { + if (node.elements[i].type == 'button') { clickOn(node.elements[i]); } + i = i - 1; + } + return; + } + // Disable any click on p_node to be protected against double-click + var cn = (node.className)? 'unclickable ' + node.className : 'unclickable'; + node.className = cn; + /* For a button, show the preloader directly. For a link, show it only after + a while, if the target page is still not there. */ + if (node.tagName != 'A') injectChunk(node, loadingButton); + else setTimeout(function(){injectChunk(node, loadingLink)}, 700); +} + function getAjaxHook(hookId, forceTop) { /* Gets the XHTML element whose ID is p_hookId: it will be the placeholder for the result of an ajax request. If p_hookId starts with ':', we search @@ -136,32 +160,22 @@ function getAjaxChunk(pos) { // This function is the callback called by the AJAX machinery (see function // askAjaxChunk below) when an Ajax response is available. // First, find back the correct XMLHttpRequest object - if ( (typeof(xhrObjects[pos]) != 'undefined') && - (xhrObjects[pos].freed == 0)) { - var hook = xhrObjects[pos].hook; - if (hook && (xhrObjects[pos].xhr.readyState == 1)) { - // The request has been initialized: display the waiting radar - var hookElem = getAjaxHook(hook); - if (hookElem) - injectChunk(hookElem, "
<\/div>", true); - } - if (xhrObjects[pos].xhr.readyState == 4) { - // We have received the HTML chunk - var hookElem = getAjaxHook(hook); - if (hookElem) { - var content = xhrObjects[pos].xhr.responseText; - var searchTop = hook[0] == ':'; - var injected = injectChunk(hookElem, content, false, searchTop); - // Call a custom Javascript function if required - if (xhrObjects[pos].onGet) { - xhrObjects[pos].onGet(xhrObjects[pos], injected); - } - // Display the Appy message if present - var msg = xhrObjects[pos].xhr.getResponseHeader('Appy-Message'); - if (msg) showAppyMessage(decodeURIComponent(escape(msg))); - } - xhrObjects[pos].freed = 1; + var rq = xhrObjects[pos]; + if ( (typeof(rq) != 'undefined') && (rq.freed == 0)) { + if ((!rq.hook) || (rq.xhr.readyState != 4)) return; + // We have received the HTML chunk + var hookElem = getAjaxHook(rq.hook); + if (hookElem) { + var content = rq.xhr.responseText; + var searchTop = rq.hook[0] == ':'; + var injected = injectChunk(hookElem, content, false, searchTop); + // Call a custom Javascript function if required + if (rq.onGet) rq.onGet(rq, injected); + // Display the Appy message if present + var msg = rq.xhr.getResponseHeader('Appy-Message'); + if (msg) showAppyMessage(decodeURIComponent(escape(msg))); } + rq.freed = 1; } } @@ -217,6 +231,8 @@ function askAjaxChunk(hook, mode, url, px, params, beforeSend, onGet) { if (mode == 'GET') { urlFull = urlFull + '?' + paramsFull; } + // Display the preloader + injectChunk(getAjaxHook(rq.hook), loadingZone, true); // Perform the asynchronous HTTP GET or POST rq.xhr.open(mode, urlFull, true); if (mode == 'POST') { @@ -651,8 +667,8 @@ function initSlaves(objectUrl, layoutType, requestValues, errors) { function submitAppyForm(button) { var f = document.getElementById('appyForm'); // On which button has the user clicked ? - f.button.value = button; - f.submit(); + f.button.value = button.id; + f.submit(); clickOn(button); } function submitForm(formId, msg, showComment, back) { @@ -661,8 +677,8 @@ function submitForm(formId, msg, showComment, back) { /* Submit the form and either refresh the entire page (back is null) or ajax-refresh a given part only (p_back corresponds to the id of the DOM node to be refreshed. */ - if (back) askAjax(back, formId); - else f.submit(); + if (back) { askAjax(back, formId); } + else { f.submit(); clickOn(f) } } else { // Ask a confirmation to the user before proceeding @@ -674,9 +690,9 @@ function submitForm(formId, msg, showComment, back) { } // Function used for triggering a workflow transition -function triggerTransition(formId, transitionId, msg, back) { +function triggerTransition(formId, node, msg, back) { var f = document.getElementById(formId); - f.transition.value = transitionId; + f.transition.value = node.id; submitForm(formId, msg, true, back); } @@ -789,8 +805,17 @@ function toggleCookie(cookieId, display, defaultValue) { createCookie(cookieId, newState); } +function podDownloadStatus(node, data) { + // Checks the status of cookie "podDownload" + var status = readCookie('podDownload'); + // Stop the timeout if the download is complete + if (status == 'false') return; + clearInterval(podTimeout); + for (var key in data) node.setAttribute(key, data[key]); +} + // Function that allows to generate a document from a pod template -function generatePod(uid, fieldName, template, podFormat, queryData, +function generatePod(node, uid, fieldName, template, podFormat, queryData, customParams, getChecked, mailing) { var f = document.getElementById('podForm'); f.objectUid.value = uid; @@ -814,7 +839,22 @@ function generatePod(uid, fieldName, template, podFormat, queryData, f.checkedSem.value = node['_appy_objs_sem']; } } + // Submitting the form at the end blocks the animated gifs on FF f.submit(); + // If p_node is an image, replace it with a preloader to prevent double-clicks + if (node.tagName == 'IMG') { + var data = {'src': node.src, 'class': node.className, + 'onclick': node.attributes.onclick.value}; + node.setAttribute('onclick', ''); + node.className = ''; + var src2 = node.src.replace(podFormat + '.png', 'loadingPod.gif'); + node.setAttribute('src', src2); + // Initialize the pod download cookie. "false" means: not downloaded yet + createCookie('podDownload', 'false'); + // Set a timer that will check the cookie value + podTimeout = window.setInterval(function(){ + podDownloadStatus(node, data)}, 700); + } } // Function that allows to (un-)freeze a document from a pod template @@ -961,7 +1001,7 @@ function doConfirm() { from the popup when relevant. */ var f = document.getElementById(action); transferComment(confirmForm, f); - f.submit(); + f.submit(); clickOn(f); } else if (actionType == 'url') { goto(action) } // Go to some URL else if (actionType == 'script') { eval(action) } // Exec some JS code @@ -970,7 +1010,7 @@ function doConfirm() { var f = document.getElementById(elems[0]); // Submit the form in elems[0] and execute the JS code in elems[1] transferComment(confirmForm, f); - f.submit(); + f.submit(); clickOn(f); eval(elems[1]); } else if (actionType == 'form-script') { @@ -1031,13 +1071,13 @@ function manageTab(tabId, action) { function showTab(tabId) { // 1st, show the tab to show manageTab(tabId, 'show'); - // Compute the number of tabs. + // Compute the number of tabs var idParts = tabId.split('_'); var prefix = idParts[0] + '_'; - // Store the currently selected tab in a cookie. + // Store the currently selected tab in a cookie createCookie('tab_' + idParts[0], tabId); var nbOfTabs = idParts[2]*1; - // Then, hide the other tabs. + // Then, hide the other tabs for (var i=0; i::_(className + '_plural') diff --git a/gen/wrappers/__init__.py b/gen/wrappers/__init__.py index e944131..88236c5 100644 --- a/gen/wrappers/__init__.py +++ b/gen/wrappers/__init__.py @@ -457,35 +457,35 @@ class AbstractWrapper(object): css=ztool.getButtonCss(label, small=False)"> - - - - - - +