Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

mod_base: fix formatting (tabs vs space).

  • Loading branch information...
commit 280d3349c5724b560fc72c17609efbad7837a345 1 parent 1197b66
@kaos kaos authored
View
312 modules/mod_base/lib/js/apps/z.widgetmanager.js
@@ -1,7 +1,7 @@
/* Admin widgetManager class
----------------------------------------------------------
-@package: Zotonic
+@package: Zotonic
@Author: Tim Benniks <tim@timbenniks.nl>
@Author: Marc Worrell <marc@worrell.nl>
@@ -10,9 +10,9 @@ Copyright 2009-2011 Tim Benniks
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,171 +23,171 @@ limitations under the License.
;(function($)
{
- $.extend(
- {
- widgetManager: function(context)
- {
- context = context || document.body;
- var stack = [context];
-
- while (stack.length > 0)
- {
- var objectOptions, defaults, element = stack.pop();
- if (typeof element.className == "string")
- {
- var objectClass = element.className.match(/do_[a-zA-Z0-9_]+/g);
- if (objectClass)
- {
- var n = objectClass.length;
- for (var i=0; i<n; i++)
- {
- var functionName = objectClass[i].substring(3);
- var defaultsName = functionName;
-
- if ('dialog' == functionName) functionName = 'show_dialog'; // work around to prevent ui.dialog redefinition
-
- if (typeof $(element)[functionName] == "function")
- {
- if ($.ui && $.ui[functionName] && $.ui[functionName].defaults)
- {
- defaults = $.ui[functionName].defaults;
- }
- else
- {
- defaults = {}
- }
- $(element)[functionName]( $.extend({}, defaults, $(element).metadata(defaultsName)) );
- }
- }
- }
- }
-
- if (element.childNodes)
- {
- for (var i = 0; i< element.childNodes.length; i++)
- {
- if (element.childNodes[i].nodeType != 3)
- {
- stack.unshift(element.childNodes[i]);
- }
- }
- }
- }
- },
-
- misc:
- {
- log: function(obj)
- {
+ $.extend(
+ {
+ widgetManager: function(context)
+ {
+ context = context || document.body;
+ var stack = [context];
+
+ while (stack.length > 0)
+ {
+ var objectOptions, defaults, element = stack.pop();
+ if (typeof element.className == "string")
+ {
+ var objectClass = element.className.match(/do_[a-zA-Z0-9_]+/g);
+ if (objectClass)
+ {
+ var n = objectClass.length;
+ for (var i=0; i<n; i++)
+ {
+ var functionName = objectClass[i].substring(3);
+ var defaultsName = functionName;
+
+ if ('dialog' == functionName) functionName = 'show_dialog'; // work around to prevent ui.dialog redefinition
+
+ if (typeof $(element)[functionName] == "function")
+ {
+ if ($.ui && $.ui[functionName] && $.ui[functionName].defaults)
+ {
+ defaults = $.ui[functionName].defaults;
+ }
+ else
+ {
+ defaults = {}
+ }
+ $(element)[functionName]( $.extend({}, defaults, $(element).metadata(defaultsName)) );
+ }
+ }
+ }
+ }
+
+ if (element.childNodes)
+ {
+ for (var i = 0; i< element.childNodes.length; i++)
+ {
+ if (element.childNodes[i].nodeType != 3)
+ {
+ stack.unshift(element.childNodes[i]);
+ }
+ }
+ }
+ }
+ },
+
+ misc:
+ {
+ log: function(obj)
+ {
var text = obj.toString();
- if(window.console)
- {
+ if(window.console)
+ {
console.log(text);
-
- if($.noticeAdd)
- {
- $.noticeAdd({
+
+ if($.noticeAdd)
+ {
+ $.noticeAdd({
text: 'Logging, check firebug: '+text,
- type: 'notice',
- stay: 0
- });
- }
- }
- else
- {
- if($.noticeAdd)
- {
- $.noticeAdd({
+ type: 'notice',
+ stay: 0
+ });
+ }
+ }
+ else
+ {
+ if($.noticeAdd)
+ {
+ $.noticeAdd({
text: 'logged: '+text,
- type: 'notice',
- stay: 0
- });
- }
- else
- {
+ type: 'notice',
+ stay: 0
+ });
+ }
+ else
+ {
alert(text);
- }
- }
- },
-
- warn: function(text, obj)
- {
- obj = obj || '';
-
- if(window.console)
- {
+ }
+ }
+ },
+
+ warn: function(text, obj)
+ {
+ obj = obj || '';
+
+ if(window.console)
+ {
console.warn(text, obj.toString());
- }
-
- if($.noticeAdd)
- {
- $.noticeAdd({
- text: text,
- type: 'notice',
- stay: 1
- });
- }
- },
-
- error: function(text, obj)
- {
- obj = obj || '';
-
- if(window.console)
- {
+ }
+
+ if($.noticeAdd)
+ {
+ $.noticeAdd({
+ text: text,
+ type: 'notice',
+ stay: 1
+ });
+ }
+ },
+
+ error: function(text, obj)
+ {
+ obj = obj || '';
+
+ if(window.console)
+ {
console.error(text, obj.toString());
if (obj.stack)
console.error(obj.stack);
- }
-
- if($.noticeAdd)
- {
- $.noticeAdd({
- text: text,
- type: 'error',
- stay: 1
- });
- }
- }
- }
- });
-
- $.fn.metadata = function(functionName)
- {
- var elem = this[0];
- var data_name = 'widget-'+functionName;
- var data = $(elem).data(data_name);
- if(data)
- {
- return data;
- }
- data = elem.getAttribute("data-"+functionName);
- if(!data)
- {
- var m = /{(.*)}/.exec(elem.className);
- if(m)
- {
- data = m[1];
- }
- else
- {
- data = "";
- }
- }
-
- try {
+ }
+
+ if($.noticeAdd)
+ {
+ $.noticeAdd({
+ text: text,
+ type: 'error',
+ stay: 1
+ });
+ }
+ }
+ }
+ });
+
+ $.fn.metadata = function(functionName)
+ {
+ var elem = this[0];
+ var data_name = 'widget-'+functionName;
+ var data = $(elem).data(data_name);
+ if(data)
+ {
+ return data;
+ }
+ data = elem.getAttribute("data-"+functionName);
+ if(!data)
+ {
+ var m = /{(.*)}/.exec(elem.className);
+ if(m)
+ {
+ data = m[1];
+ }
+ else
+ {
+ data = "";
+ }
+ }
+
+ try {
data = eval("({" + data.replace(/[\n\r]/g,' ') + "})");
} catch (e) {
console.error("Error evaluating widget data attribute:", data);
}
- $(elem).data(data_name, data);
- return data;
- };
-
- $.fn.widgetManager = function()
- {
- this.each(function() { $.widgetManager(this); });
- return this;
- };
+ $(elem).data(data_name, data);
+ return data;
+ };
+
+ $.fn.widgetManager = function()
+ {
+ this.each(function() { $.widgetManager(this); });
+ return this;
+ };
})(jQuery);
View
2,250 modules/mod_base/lib/js/apps/zotonic-1.0.js
@@ -1,7 +1,7 @@
/* Zotonic basic Javascript library
----------------------------------------------------------
-@package: Zotonic 2009
+@package: Zotonic 2009
@Author: Tim Benniks <tim@timbenniks.nl>
@Author: Marc Worrell <marc@worrell.nl>
@@ -10,9 +10,9 @@ Copyright 2009-2011 Tim Benniks, Marc Worrell
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -44,35 +44,35 @@ var z_language = "en";
function z_dialog_open(options)
{
- $.dialogAdd(options);
+ $.dialogAdd(options);
}
function z_dialog_close()
{
- $.dialogClose();
+ $.dialogClose();
}
function z_dialog_confirm(options)
{
- html = '<div class="confirm">' + options.text + '</div>'
- + '<div class="modal-footer">'
- + '<button class="btn z-dialog-cancel-button">'
- + (options.cancel||z_translate('Cancel'))
- + '</button>'
- + '<button class="btn btn-primary z-dialog-ok-button">'
- + (options.ok||z_translate('OK'))
- + '</button>'
- + '</div>';
- $.dialogAdd({
- title: (options.title||z_translate('Confirm')),
- text: html,
- width: (options.width)
- });
- $(".z-dialog-cancel-button").click(function() { z_dialog_close(); });
- $(".z-dialog-ok-button").click(function() {
- z_dialog_close();
- if (options.on_confirm) options.on_confirm();
- });
+ html = '<div class="confirm">' + options.text + '</div>'
+ + '<div class="modal-footer">'
+ + '<button class="btn z-dialog-cancel-button">'
+ + (options.cancel||z_translate('Cancel'))
+ + '</button>'
+ + '<button class="btn btn-primary z-dialog-ok-button">'
+ + (options.ok||z_translate('OK'))
+ + '</button>'
+ + '</div>';
+ $.dialogAdd({
+ title: (options.title||z_translate('Confirm')),
+ text: html,
+ width: (options.width)
+ });
+ $(".z-dialog-cancel-button").click(function() { z_dialog_close(); });
+ $(".z-dialog-ok-button").click(function() {
+ z_dialog_close();
+ if (options.on_confirm) options.on_confirm();
+ });
}
/* Growl messages
@@ -80,25 +80,25 @@ function z_dialog_confirm(options)
function z_growl_add(message, stay, type)
{
- stay = stay || false;
- type = type || 'notice';
-
- $.noticeAdd(
- {
- text: message,
- stay: stay,
- type: type
- });
-
- if(type == 'error' && window.console)
- {
- console.error(message);
- }
+ stay = stay || false;
+ type = type || 'notice';
+
+ $.noticeAdd(
+ {
+ text: message,
+ stay: stay,
+ type: type
+ });
+
+ if(type == 'error' && window.console)
+ {
+ console.error(message);
+ }
}
function z_growl_close()
{
- $.noticeRemove($('.notice-item-wrapper'), 400);
+ $.noticeRemove($('.notice-item-wrapper'), 400);
}
@@ -107,19 +107,19 @@ function z_growl_close()
function z_event_register(name, func)
{
- z_registered_events[name] = func;
+ z_registered_events[name] = func;
}
function z_event(name, extraParams)
{
- if (z_registered_events[name])
- {
- z_registered_events[name](ensure_name_value(extraParams));
- }
- else if (window.console)
- {
- console.error("z_event: no registered event named: '"+name+"'");
- }
+ if (z_registered_events[name])
+ {
+ z_registered_events[name](ensure_name_value(extraParams));
+ }
+ else if (window.console)
+ {
+ console.error("z_event: no registered event named: '"+name+"'");
+ }
}
/* Call the server side notifier for {postback_notify, Message, Context}
@@ -127,266 +127,266 @@ function z_event(name, extraParams)
function z_notify(message, extraParams)
{
- var trigger_id = '';
- if (extraParams != undefined && extraParams.z_trigger_id != undefined) {
- trigger_id = extraParams.z_trigger_id;
- extraParams.z_trigger_id = undefined;
- }
- var extra = ensure_name_value(extraParams);
- if (typeof extra != 'object')
- {
- extra = [];
- }
- extra.push({name: 'z_msg', value: message});
- z_queue_postback(trigger_id, 'notify', extra, true);
+ var trigger_id = '';
+ if (extraParams != undefined && extraParams.z_trigger_id != undefined) {
+ trigger_id = extraParams.z_trigger_id;
+ extraParams.z_trigger_id = undefined;
+ }
+ var extra = ensure_name_value(extraParams);
+ if (typeof extra != 'object')
+ {
+ extra = [];
+ }
+ extra.push({name: 'z_msg', value: message});
+ z_queue_postback(trigger_id, 'notify', extra, true);
}
/* Postback loop
---------------------------------------------------------- */
-function z_postback_check()
+function z_postback_check()
{
- if (z_postbacks.length == 0)
- {
- z_doing_postback = false;
- }
- else
- {
- if (z_postback_connected())
- {
- // Send only a single postback at a time.
- z_doing_postback = true;
-
- var o = z_postbacks.shift();
- z_do_postback(o.triggerID, o.postback, o.extraParams);
- }
- else
- {
- setTimeout("z_postback_check()", 10);
- }
- }
+ if (z_postbacks.length == 0)
+ {
+ z_doing_postback = false;
+ }
+ else
+ {
+ if (z_postback_connected())
+ {
+ // Send only a single postback at a time.
+ z_doing_postback = true;
+
+ var o = z_postbacks.shift();
+ z_do_postback(o.triggerID, o.postback, o.extraParams);
+ }
+ else
+ {
+ setTimeout("z_postback_check()", 10);
+ }
+ }
}
function z_opt_cancel(obj)
{
- if(typeof obj.nodeName == 'undefined')
- return false;
-
- var nodeName = obj.nodeName.toLowerCase();
- var nodeType = $(obj).attr("type");
-
- if (nodeName == 'input' && (nodeType == 'checkbox' || nodeType == 'radio'))
- {
- return true;
- }
- else
- {
- return false;
- }
+ if(typeof obj.nodeName == 'undefined')
+ return false;
+
+ var nodeName = obj.nodeName.toLowerCase();
+ var nodeType = $(obj).attr("type");
+
+ if (nodeName == 'input' && (nodeType == 'checkbox' || nodeType == 'radio'))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
}
-function z_httpdata( xhr, type, s )
-{
- // lifted from jq1.4.4
- var ct = xhr.getResponseHeader("content-type") || "",
- xml = type === "xml" || !type && ct.indexOf("xml") >= 0,
- data = xml ? xhr.responseXML : xhr.responseText;
-
- if ( xml && data.documentElement.nodeName === "parsererror" ) {
- $.error( "parsererror" );
- }
- if ( s && s.dataFilter ) {
- data = s.dataFilter( data, type );
- }
- if ( typeof data === "string" ) {
- if ( type === "json" || !type && ct.indexOf("json") >= 0 ) {
- data = $.parseJSON( data );
- } else if ( type === "script" || !type && ct.indexOf("javascript") >= 0 ) {
- $.globalEval( data );
- }
- }
- return data;
+function z_httpdata( xhr, type, s )
+{
+ // lifted from jq1.4.4
+ var ct = xhr.getResponseHeader("content-type") || "",
+ xml = type === "xml" || !type && ct.indexOf("xml") >= 0,
+ data = xml ? xhr.responseXML : xhr.responseText;
+
+ if ( xml && data.documentElement.nodeName === "parsererror" ) {
+ $.error( "parsererror" );
+ }
+ if ( s && s.dataFilter ) {
+ data = s.dataFilter( data, type );
+ }
+ if ( typeof data === "string" ) {
+ if ( type === "json" || !type && ct.indexOf("json") >= 0 ) {
+ data = $.parseJSON( data );
+ } else if ( type === "script" || !type && ct.indexOf("javascript") >= 0 ) {
+ $.globalEval( data );
+ }
+ }
+ return data;
}
-function z_queue_postback(triggerID, postback, extraParams, noTriggerValue)
+function z_queue_postback(triggerID, postback, extraParams, noTriggerValue)
{
- var triggerValue = '';
-
- if (triggerID != '' && !noTriggerValue)
- {
- var trigger = $('#'+triggerID).get(0);
- if (trigger)
- {
- if ($(trigger).is(":checkbox") || $(trigger).is(":radio"))
- {
- if ($(trigger).is(":checked"))
- {
- triggerValue = $(trigger).val() || 'on';
- }
- }
- else
- {
- var nodeName = trigger.nodeName.toLowerCase();
-
- if (nodeName == 'input' || nodeName == 'button' || nodeName == 'textarea' || nodeName == 'select')
- triggerValue = $(trigger).val() || '';
- }
- }
- }
-
- extraParams = extraParams || new Array();
- extraParams.push({name: 'triggervalue', value: triggerValue})
-
- var o = new Object();
- o.triggerID = triggerID;
- o.postback = postback;
- o.extraParams = extraParams;
- z_postbacks.push(o);
- z_postback_check();
+ var triggerValue = '';
+
+ if (triggerID != '' && !noTriggerValue)
+ {
+ var trigger = $('#'+triggerID).get(0);
+ if (trigger)
+ {
+ if ($(trigger).is(":checkbox") || $(trigger).is(":radio"))
+ {
+ if ($(trigger).is(":checked"))
+ {
+ triggerValue = $(trigger).val() || 'on';
+ }
+ }
+ else
+ {
+ var nodeName = trigger.nodeName.toLowerCase();
+
+ if (nodeName == 'input' || nodeName == 'button' || nodeName == 'textarea' || nodeName == 'select')
+ triggerValue = $(trigger).val() || '';
+ }
+ }
+ }
+
+ extraParams = extraParams || new Array();
+ extraParams.push({name: 'triggervalue', value: triggerValue})
+
+ var o = new Object();
+ o.triggerID = triggerID;
+ o.postback = postback;
+ o.extraParams = extraParams;
+ z_postbacks.push(o);
+ z_postback_check();
}
// Wait with sending postbacks till the websocket connection is open
function z_postback_connected()
{
- return !z_ws || z_ws.readyState != 0;
+ return !z_ws || z_ws.readyState != 0;
}
-function z_do_postback(triggerID, postback, extraParams)
+function z_do_postback(triggerID, postback, extraParams)
{
- // Get params...
- var params =
- "postback=" + urlencode(postback) +
- "&z_trigger_id=" + urlencode(triggerID) +
- "&z_pageid=" + urlencode(z_pageid) +
- "&" + $.param(extraParams);
-
- // logon_form and .setcookie forms are always posted, as they will set cookies.
- if ( z_ws
- && z_ws.readyState == 1
- && triggerID != "logon_form"
- && (triggerID == '' || !$('#'+triggerID).hasClass("setcookie")))
- {
- z_ws.send(params);
- }
- else
- {
- z_ajax(triggerID, params);
- }
+ // Get params...
+ var params =
+ "postback=" + urlencode(postback) +
+ "&z_trigger_id=" + urlencode(triggerID) +
+ "&z_pageid=" + urlencode(z_pageid) +
+ "&" + $.param(extraParams);
+
+ // logon_form and .setcookie forms are always posted, as they will set cookies.
+ if ( z_ws
+ && z_ws.readyState == 1
+ && triggerID != "logon_form"
+ && (triggerID == '' || !$('#'+triggerID).hasClass("setcookie")))
+ {
+ z_ws.send(params);
+ }
+ else
+ {
+ z_ajax(triggerID, params);
+ }
}
function z_ajax(triggerID, params)
{
- z_start_spinner();
-
- $.ajax({
- url: '/postback',
- type: 'post',
- data: params,
- dataType: 'text',
- success: function(data, textStatus)
- {
- z_stop_spinner();
-
- try
- {
- eval(data);
- z_init_postback_forms();
- }
- catch(e)
- {
+ z_start_spinner();
+
+ $.ajax({
+ url: '/postback',
+ type: 'post',
+ data: params,
+ dataType: 'text',
+ success: function(data, textStatus)
+ {
+ z_stop_spinner();
+
+ try
+ {
+ eval(data);
+ z_init_postback_forms();
+ }
+ catch(e)
+ {
$.misc.error("Error evaluating ajax return value: " + data, e);
- }
- setTimeout("z_postback_check()", 0);
- },
- error: function(xmlHttpRequest, textStatus, errorThrown)
- {
- z_stop_spinner();
-
- $.misc.error("FAIL: " + textStatus);
- z_unmask_error(triggerID);
- }
- });
+ }
+ setTimeout("z_postback_check()", 0);
+ },
+ error: function(xmlHttpRequest, textStatus, errorThrown)
+ {
+ z_stop_spinner();
+
+ $.misc.error("FAIL: " + textStatus);
+ z_unmask_error(triggerID);
+ }
+ });
}
function z_unmask(id)
{
- if (id)
- {
- var trigger = $('#'+id).get(0);
- try { $(trigger).unmask(); } catch (e) {};
- $(trigger).removeClass("z_error_upload");
- }
+ if (id)
+ {
+ var trigger = $('#'+id).get(0);
+ try { $(trigger).unmask(); } catch (e) {};
+ $(trigger).removeClass("z_error_upload");
+ }
}
function z_unmask_error(id)
{
- if (id)
- {
- z_unmask(id);
- $('#'+id).addClass("z_error_upload");
- }
+ if (id)
+ {
+ z_unmask(id);
+ $('#'+id).addClass("z_error_upload");
+ }
}
function z_progress(id, value)
{
- if (id)
- {
- var trigger = $('#'+id).get(0);
-
- if (trigger.nodeName.toLowerCase() == 'form')
- {
- try { $(trigger).maskProgress(value); } catch (e) {};
- }
- }
+ if (id)
+ {
+ var trigger = $('#'+id).get(0);
+
+ if (trigger.nodeName.toLowerCase() == 'form')
+ {
+ try { $(trigger).maskProgress(value); } catch (e) {};
+ }
+ }
}
function z_reload(args)
{
- var page = $('#logon_form input[name="page"]');
-
- if (page.length > 0 && page.val() != "") {
- window.location.href = window.location.protocol+"//"+window.location.host+page.val();
- } else {
- if (typeof args == "undefined")
- window.location.reload(true);
- else {
- var qs = ensure_name_value(args);
-
- if (qs.length == 1 && typeof args.z_language == "string") {
- var href;
-
- if ( window.location.pathname.substring(0,2+z_language.length) == "/"+z_language+"/") {
- href = window.location.protocol+"//"+window.location.host
- +"/"+args.z_language+"/"
- +window.location.pathname.substring(2+args.z_language.length);
- } else {
- href = window.location.protocol+"//"+window.location.host
- +"/"+args.z_language
- +window.location.pathname;
- }
- if (window.location.search == "")
- window.location.href = href;
- else
- window.location.href = href + "?" + window.location.search;
- } else {
- var href = window.location.protocol+"//"+window.location.host+window.location.pathname;
- if (window.location.search == "") {
- window.location.href = href + '?' + $.param(qs);
- } else {
- var loc_qs = $.parseQuery();
- for (var prop in loc_qs) {
- if (typeof loc_qs[prop] != "undefined" && typeof args[prop] == "undefined")
- qs.push({name: prop, value: loc_qs[prop]});
- }
- window.location.href = href+"?" + $.param(qs);
- }
- }
- }
- }
+ var page = $('#logon_form input[name="page"]');
+
+ if (page.length > 0 && page.val() != "") {
+ window.location.href = window.location.protocol+"//"+window.location.host+page.val();
+ } else {
+ if (typeof args == "undefined")
+ window.location.reload(true);
+ else {
+ var qs = ensure_name_value(args);
+
+ if (qs.length == 1 && typeof args.z_language == "string") {
+ var href;
+
+ if ( window.location.pathname.substring(0,2+z_language.length) == "/"+z_language+"/") {
+ href = window.location.protocol+"//"+window.location.host
+ +"/"+args.z_language+"/"
+ +window.location.pathname.substring(2+args.z_language.length);
+ } else {
+ href = window.location.protocol+"//"+window.location.host
+ +"/"+args.z_language
+ +window.location.pathname;
+ }
+ if (window.location.search == "")
+ window.location.href = href;
+ else
+ window.location.href = href + "?" + window.location.search;
+ } else {
+ var href = window.location.protocol+"//"+window.location.host+window.location.pathname;
+ if (window.location.search == "") {
+ window.location.href = href + '?' + $.param(qs);
+ } else {
+ var loc_qs = $.parseQuery();
+ for (var prop in loc_qs) {
+ if (typeof loc_qs[prop] != "undefined" && typeof args[prop] == "undefined")
+ qs.push({name: prop, value: loc_qs[prop]});
+ }
+ window.location.href = href+"?" + $.param(qs);
+ }
+ }
+ }
+ }
}
/* translations
@@ -394,9 +394,9 @@ function z_reload(args)
function z_translate(text)
{
- if (typeof z_translations != "undefined" && typeof z_translations[text] != "undefined")
- return z_translations[text];
- return text;
+ if (typeof z_translations != "undefined" && typeof z_translations[text] != "undefined")
+ return z_translations[text];
+ return text;
}
@@ -405,17 +405,17 @@ function z_translate(text)
function z_text_to_nodes(text)
{
- if (text == "") {
- return $(text);
- } else {
- var text1 = $.trim(text);
- var len = text1.length;
- if (text1.charAt(0) == "<" && text1.charAt(len-1) == ">") {
- return $(text);
- } else {
- return $("<span></span>"+text+"<span></span>").slice(1,-1);
- }
- }
+ if (text == "") {
+ return $(text);
+ } else {
+ var text1 = $.trim(text);
+ var len = text1.length;
+ if (text1.charAt(0) == "<" && text1.charAt(len-1) == ">") {
+ return $(text);
+ } else {
+ return $("<span></span>"+text+"<span></span>").slice(1,-1);
+ }
+ }
}
/* tinyMCE stuff
@@ -424,55 +424,55 @@ function z_text_to_nodes(text)
/* Initialize all non-initialized tinymce controls */
function z_tinymce_init()
{
- $(".tinymce-init:visible").each(function() {
- var self = $(this);
- setTimeout(function() {
- var ti = jQuery.extend({}, tinyInit);
- if (self.attr('dir')) {
- ti.directionality = self.attr('dir');
- }
- self.tinymce(ti);
- }, 200);
- }).removeClass('tinymce-init').addClass('tinymce');
+ $(".tinymce-init:visible").each(function() {
+ var self = $(this);
+ setTimeout(function() {
+ var ti = jQuery.extend({}, tinyInit);
+ if (self.attr('dir')) {
+ ti.directionality = self.attr('dir');
+ }
+ self.tinymce(ti);
+ }, 200);
+ }).removeClass('tinymce-init').addClass('tinymce');
}
-function z_tinymce_add(element)
+function z_tinymce_add(element)
{
- $("textarea.tinymce", element).each(function() {
- if (typeof $(this).tinymce == 'function') {
- var self = $(this);
- setTimeout(function() {
- if (typeof tinyInit == 'object') self.tinymce(tinyInit);
- else self.tinymce({});
- }, 200);
- } else if (typeof tinyMCE == 'object') {
- var mce_id = $(this).attr('id');
- setTimeout(function() { tinyMCE.execCommand('mceAddControl',false, mce_id); }, 200);
- }
- });
+ $("textarea.tinymce", element).each(function() {
+ if (typeof $(this).tinymce == 'function') {
+ var self = $(this);
+ setTimeout(function() {
+ if (typeof tinyInit == 'object') self.tinymce(tinyInit);
+ else self.tinymce({});
+ }, 200);
+ } else if (typeof tinyMCE == 'object') {
+ var mce_id = $(this).attr('id');
+ setTimeout(function() { tinyMCE.execCommand('mceAddControl',false, mce_id); }, 200);
+ }
+ });
}
function z_tinymce_save(element)
{
- var tiny = $("textarea.tinymce", element);
- if (tiny.length > 0) {
- if (typeof tiny.tinymce == "function") {
- tiny.each(function() { $(this).tinymce().save(); });
- } else if (typeof tinyMCE == 'object') {
- tinyMCE.triggerSave(true,true);
- }
- }
+ var tiny = $("textarea.tinymce", element);
+ if (tiny.length > 0) {
+ if (typeof tiny.tinymce == "function") {
+ tiny.each(function() { $(this).tinymce().save(); });
+ } else if (typeof tinyMCE == 'object') {
+ tinyMCE.triggerSave(true,true);
+ }
+ }
}
-function z_tinymce_remove(element)
+function z_tinymce_remove(element)
{
- $("textarea.tinymce", element).each( function() {
- if (typeof(tinyMCE) != 'undefined') {
- tinyMCE.execCommand('mceRemoveControl',false, $(this).attr('id'));
- } else if (typeof $(this).tinymce == 'function') {
- $(this).tinymce().remove();
- }
- });
+ $("textarea.tinymce", element).each( function() {
+ if (typeof(tinyMCE) != 'undefined') {
+ tinyMCE.execCommand('mceRemoveControl',false, $(this).attr('id'));
+ } else if (typeof $(this).tinymce == 'function') {
+ $(this).tinymce().remove();
+ }
+ });
}
@@ -482,66 +482,66 @@ function z_tinymce_remove(element)
function z_stream_start(host)
{
z_stream_host = host;
- if (!z_ws && !z_comet_is_running)
- {
- if ("WebSocket" in window)
- {
- z_websocket_start(host);
- }
- else
- {
- setTimeout(function() { z_comet(host); }, 2000);
- z_comet_is_running = true;
- }
- }
+ if (!z_ws && !z_comet_is_running)
+ {
+ if ("WebSocket" in window)
+ {
+ z_websocket_start(host);
+ }
+ else
+ {
+ setTimeout(function() { z_comet(host); }, 2000);
+ z_comet_is_running = true;
+ }
+ }
}
-function z_comet(host)
+function z_comet(host)
{
- if (host != window.location.host && window.location.protocol == "http:")
- {
- var url = window.location.protocol + '//' + host + "/comet/subdomain?z_pageid=" + urlencode(z_pageid);
- var comet = $('<iframe id="z_comet_connection" name="z_comet_connection" src="'+url+'" />');
- comet.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
- comet.appendTo("body");
- }
- else
- {
- z_comet_host()
- }
+ if (host != window.location.host && window.location.protocol == "http:")
+ {
+ var url = window.location.protocol + '//' + host + "/comet/subdomain?z_pageid=" + urlencode(z_pageid);
+ var comet = $('<iframe id="z_comet_connection" name="z_comet_connection" src="'+url+'" />');
+ comet.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
+ comet.appendTo("body");
+ }
+ else
+ {
+ z_comet_host()
+ }
}
function z_comet_host()
{
- $.ajax({
- url: window.location.protocol + '//' + window.location.host + '/comet',
- type:'post',
- data: "z_pageid=" + urlencode(z_pageid),
- dataType: 'text',
- success: function(data, textStatus)
- {
- z_comet_data(data);
- setTimeout(function() { z_comet_host(); }, 1000);
- },
- error: function(xmlHttpRequest, textStatus, errorThrown)
- {
- setTimeout(function() { z_comet_host(); }, 1000);
- }
- });
+ $.ajax({
+ url: window.location.protocol + '//' + window.location.host + '/comet',
+ type:'post',
+ data: "z_pageid=" + urlencode(z_pageid),
+ dataType: 'text',
+ success: function(data, textStatus)
+ {
+ z_comet_data(data);
+ setTimeout(function() { z_comet_host(); }, 1000);
+ },
+ error: function(xmlHttpRequest, textStatus, errorThrown)
+ {
+ setTimeout(function() { z_comet_host(); }, 1000);
+ }
+ });
}
function z_comet_data(data)
{
- try
- {
- eval(data);
- z_init_postback_forms();
- }
- catch (e)
- {
+ try
+ {
+ eval(data);
+ z_init_postback_forms();
+ }
+ catch (e)
+ {
$.misc.error("Error evaluating ajax return value: " + data, e);
- }
+ }
}
@@ -549,92 +549,92 @@ function z_websocket_restart()
{
if (z_ws) {
z_ws.close();
- z_ws_opened = false;
- setTimeout(function() { z_websocket_start(z_stream_host); }, 100);
+ z_ws_opened = false;
+ setTimeout(function() { z_websocket_start(z_stream_host); }, 100);
}
}
function z_websocket_start(host)
{
- var protocol = "ws:";
- if (window.location.protocol == "https:")
- {
- protocol = "wss:";
- }
- z_ws = new WebSocket(protocol+"//"+document.location.host+"/websocket?z_pageid="+z_pageid);
-
- z_ws.onopen = function() { z_ws_opened = true; };
- z_ws.onerror = function() { };
-
- z_ws.onclose = function (evt)
- {
- if (z_ws_opened)
- {
- // Try to reopen once, might be closed due to an server side error
- z_ws_opened = false;
- setTimeout(function() { z_websocket_start(host); }, 100);
- }
- else
- {
- // Failed opening websocket connection - try to start comet
- z_ws = undefined;
- setTimeout(function() { z_comet(host); }, 2000);
- z_comet_is_running = true;
- }
- };
-
- z_ws.onmessage = function (evt)
- {
- z_comet_data(evt.data);
- setTimeout("z_postback_check()", 0);
- };
+ var protocol = "ws:";
+ if (window.location.protocol == "https:")
+ {
+ protocol = "wss:";
+ }
+ z_ws = new WebSocket(protocol+"//"+document.location.host+"/websocket?z_pageid="+z_pageid);
+
+ z_ws.onopen = function() { z_ws_opened = true; };
+ z_ws.onerror = function() { };
+
+ z_ws.onclose = function (evt)
+ {
+ if (z_ws_opened)
+ {
+ // Try to reopen once, might be closed due to an server side error
+ z_ws_opened = false;
+ setTimeout(function() { z_websocket_start(host); }, 100);
+ }
+ else
+ {
+ // Failed opening websocket connection - try to start comet
+ z_ws = undefined;
+ setTimeout(function() { z_comet(host); }, 2000);
+ z_comet_is_running = true;
+ }
+ };
+
+ z_ws.onmessage = function (evt)
+ {
+ z_comet_data(evt.data);
+ setTimeout("z_postback_check()", 0);
+ };
}
/* Utility functions
---------------------------------------------------------- */
-function z_is_enter_key(event)
+function z_is_enter_key(event)
{
- return (event && event.keyCode == 13);
+ return (event && event.keyCode == 13);
}
function z_has_flash()
{
- if (navigator.plugins && navigator.plugins.length>0) {
- var type = 'application/x-shockwave-flash';
- var mimeTypes = navigator.mimeTypes;
- return (mimeTypes && mimeTypes[type] && mimeTypes[type].enabledPlugin);
- } else if(navigator.appVersion.indexOf("Mac")==-1 && window.execScript) {
- try {
- obj = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
- return true;
- } catch(err) {
- return false;
- }
- }
- return false;
+ if (navigator.plugins && navigator.plugins.length>0) {
+ var type = 'application/x-shockwave-flash';
+ var mimeTypes = navigator.mimeTypes;
+ return (mimeTypes && mimeTypes[type] && mimeTypes[type].enabledPlugin);
+ } else if(navigator.appVersion.indexOf("Mac")==-1 && window.execScript) {
+ try {
+ obj = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
+ return true;
+ } catch(err) {
+ return false;
+ }
+ }
+ return false;
}
function z_ensure_id(elt)
{
- var id = $(elt).attr('id');
- if (id == undefined) {
- id = z_unique_id();
- $(elt).attr('id', id);
- }
- return id;
+ var id = $(elt).attr('id');
+ if (id == undefined) {
+ id = z_unique_id();
+ $(elt).attr('id', id);
+ }
+ return id;
}
function z_unique_id()
{
- do {
- var id = '-z-' + z_unique_id_counter++;
- } while ($('#'+id).length > 0);
- return id;
+ do {
+ var id = '-z-' + z_unique_id_counter++;
+ } while ($('#'+id).length > 0);
+ return id;
}
@@ -643,84 +643,84 @@ function z_unique_id()
function z_start_spinner()
{
- if (z_spinner_show_ct++ == 0)
- {
- $(document.body).addClass('wait');
- $('#spinner').fadeIn(100);
- }
+ if (z_spinner_show_ct++ == 0)
+ {
+ $(document.body).addClass('wait');
+ $('#spinner').fadeIn(100);
+ }
}
-function z_stop_spinner()
+function z_stop_spinner()
{
- if (--z_spinner_show_ct == 0)
- {
- $('#spinner').fadeOut(100);
- $(document.body).removeClass('wait');
- }
+ if (--z_spinner_show_ct == 0)
+ {
+ $('#spinner').fadeOut(100);
+ $(document.body).removeClass('wait');
+ }
}
/* Drag & drop interface to the postback
---------------------------------------------------------- */
-function z_draggable(dragObj, dragOptions, dragTag)
+function z_draggable(dragObj, dragOptions, dragTag)
{
- dragObj.draggable(dragOptions).data("z_drag_tag", dragTag);
- z_drag_tag[dragObj.attr('id')] = dragTag;
+ dragObj.draggable(dragOptions).data("z_drag_tag", dragTag);
+ z_drag_tag[dragObj.attr('id')] = dragTag;
}
-function z_droppable(dropObj, dropOptions, dropPostbackInfo)
+function z_droppable(dropObj, dropOptions, dropPostbackInfo)
{
- dropOptions.greedy = true;
- dropOptions.drop = function(ev, ui)
- {
- var dragTag = $(ui.draggable[0]).data("z_drag_tag");
- var dragItem = new Array({name: 'drag_item', value: dragTag});
- z_queue_postback(this.id, dropPostbackInfo, dragItem, true);
- };
-
- $(dropObj).droppable(dropOptions);
+ dropOptions.greedy = true;
+ dropOptions.drop = function(ev, ui)
+ {
+ var dragTag = $(ui.draggable[0]).data("z_drag_tag");
+ var dragItem = new Array({name: 'drag_item', value: dragTag});
+ z_queue_postback(this.id, dropPostbackInfo, dragItem, true);
+ };
+
+ $(dropObj).droppable(dropOptions);
}
/* Sorter and sortables interface to the postback
---------------------------------------------------------- */
-function z_sortable(sortableObj, sortTag)
+function z_sortable(sortableObj, sortTag)
{
- sortableObj.data("z_sort_tag", sortTag);
+ sortableObj.data("z_sort_tag", sortTag);
}
-function z_sorter(sortBlock, sortOptions, sortPostbackInfo)
+function z_sorter(sortBlock, sortOptions, sortPostbackInfo)
{
- sortOptions.update = function()
- {
- var sortItems = "";
-
- for (var i = 0; i < this.childNodes.length; i++)
- {
- var sortTag = $(this.childNodes[i]).data("z_sort_tag")
- if (sortTag)
- {
- if (sortItems != "")
- {
- sortItems += ",";
- }
-
- sortItems += sortTag
- }
- }
-
- var sortItem = new Array({name: 'sort_items', value: sortItems});
-
- z_queue_postback(this.id, sortPostbackInfo, sortItem, true);
- };
- sortOptions.receive = function (ev, ui) {
- var $target = $(this).data().sortable.element;
- var $source = $(ui.sender);
- $target.data('z_sort_tag', $source.data('z_drag_tag'));
- };
- $(sortBlock).sortable(sortOptions);
+ sortOptions.update = function()
+ {
+ var sortItems = "";
+
+ for (var i = 0; i < this.childNodes.length; i++)
+ {
+ var sortTag = $(this.childNodes[i]).data("z_sort_tag")
+ if (sortTag)
+ {
+ if (sortItems != "")
+ {
+ sortItems += ",";
+ }
+
+ sortItems += sortTag
+ }
+ }
+
+ var sortItem = new Array({name: 'sort_items', value: sortItems});
+
+ z_queue_postback(this.id, sortPostbackInfo, sortItem, true);
+ };
+ sortOptions.receive = function (ev, ui) {
+ var $target = $(this).data().sortable.element;
+ var $source = $(ui.sender);
+ $target.data('z_sort_tag', $source.data('z_drag_tag'));
+ };
+ $(sortBlock).sortable(sortOptions);
}
@@ -729,22 +729,22 @@ function z_sorter(sortBlock, sortOptions, sortPostbackInfo)
function z_typeselect(ElementId, postbackInfo)
{
- if (z_input_updater)
- {
- clearTimeout(z_input_updater);
- z_input_updater = false;
- }
-
- z_input_updater = setTimeout(function()
- {
- var obj = $('#'+ElementId);
-
- if(obj.val().length >= 2)
- {
- obj.addClass('loading');
- z_queue_postback(ElementId, postbackInfo)
- }
- }, 400);
+ if (z_input_updater)
+ {
+ clearTimeout(z_input_updater);
+ z_input_updater = false;
+ }
+
+ z_input_updater = setTimeout(function()
+ {
+ var obj = $('#'+ElementId);
+
+ if(obj.val().length >= 2)
+ {
+ obj.addClass('loading');
+ z_queue_postback(ElementId, postbackInfo)
+ }
+ }, 400);
}
@@ -753,42 +753,42 @@ function z_typeselect(ElementId, postbackInfo)
function z_on_visible(CssSelector, Func)
{
- z_on_visible_checks.push({selector: CssSelector, func: Func});
- if (z_on_visible_timer == undefined) {
- z_on_visible_timer = setInterval(function() {
- z_on_visible_check();
- }, 350);
- }
+ z_on_visible_checks.push({selector: CssSelector, func: Func});
+ if (z_on_visible_timer == undefined) {
+ z_on_visible_timer = setInterval(function() {
+ z_on_visible_check();
+ }, 350);
+ }
}
function z_on_visible_check()
{
- for (var i = z_on_visible_checks.length-1; i>=0; i--) {
- var elt = $(z_on_visible_checks[i].selector).get(0);
- if (elt != undefined) {
- if ($(elt).is(":visible") && isScrolledIntoView(elt)) {
- z_on_visible_checks[i].func.call(elt);
- z_on_visible_checks.splice(i, 1);
- }
- }
- }
- if (z_on_visible_checks.length == 0) {
- clearInterval(z_on_visible_timer);
- z_on_visible_timer = undefined;
- }
+ for (var i = z_on_visible_checks.length-1; i>=0; i--) {
+ var elt = $(z_on_visible_checks[i].selector).get(0);
+ if (elt != undefined) {
+ if ($(elt).is(":visible") && isScrolledIntoView(elt)) {
+ z_on_visible_checks[i].func.call(elt);
+ z_on_visible_checks.splice(i, 1);
+ }
+ }
+ }
+ if (z_on_visible_checks.length == 0) {
+ clearInterval(z_on_visible_timer);
+ z_on_visible_timer = undefined;
+ }
}
function isScrolledIntoView(elem)
{
- var docViewTop = $(window).scrollTop();
- var docViewBottom = docViewTop + $(window).height();
+ var docViewTop = $(window).scrollTop();
+ var docViewBottom = docViewTop + $(window).height();
- var elemTop = $(elem).offset().top;
- var elemBottom = elemTop + $(elem).height();
+ var elemTop = $(elem).offset().top;
+ var elemBottom = elemTop + $(elem).height();
- return (elemBottom >= docViewTop) && (elemTop <= docViewBottom);
- // && (elemBottom <= docViewBottom) && (elemTop >= docViewTop);
+ return (elemBottom >= docViewTop) && (elemTop <= docViewBottom);
+ // && (elemBottom <= docViewBottom) && (elemTop >= docViewTop);
}
/* Form element validations
@@ -801,531 +801,531 @@ This function can be run multiple times.
function z_init_postback_forms()
{
- $("form[action*='postback']").each(function()
- {
- // store options in hash
- $(":submit,input:image", this).bind('click.form-plugin',function(e)
- {
- var form = this.form;
- form.clk = this;
-
- if (this.type == 'image')
- {
- if (e.offsetX != undefined)
- {
- form.clk_x = e.offsetX;
- form.clk_y = e.offsetY;
- }
- else if (typeof $.fn.offset == 'function')
- { // try to use dimensions plugin
- var offset = $(this).offset();
- form.clk_x = e.pageX - offset.left;
- form.clk_y = e.pageY - offset.top;
- }
- else
- {
- form.clk_x = e.pageX - this.offsetLeft;
- form.clk_y = e.pageY - this.offsetTop;
- }
- }
- });
- })
- .submit(function(event)
- {
- theForm = this;
- z_tinymce_save(theForm);
-
- submitFunction = function(ev) {
- var arguments = $(theForm).formToArray();
-
- try { $(theForm).mask("", 100); } catch (e) {};
-
- var postback = $(theForm).data("z_submit_postback");
- var action = $(theForm).data("z_submit_action");
- var form_id = $(theForm).attr('id');
- var validations = $(theForm).formValidationPostback();
-
- if(!postback)
- {
- postback = z_default_form_postback;
- }
-
- if(action)
- {
- setTimeout(action, 10);
- }
-
- var use_post = $(theForm).hasClass("z_cookie_form") || $(theForm).hasClass("z_logon_form");
- if (typeof(z_only_post_forms) != "undefined" && z_only_post_forms)
- {
- use_post = true;
- }
- else
- {
- var files = $('input:file', theForm).fieldValue();
- for (var j=0; j < files.length && !use_post; j++)
- {
- if (files[j])
- {
- use_post = true;
- }
- }
- }
-
- if (use_post)
- {
- $(theForm).postbackFileForm(form_id, postback, validations);
+ $("form[action*='postback']").each(function()
+ {
+ // store options in hash
+ $(":submit,input:image", this).bind('click.form-plugin',function(e)
+ {
+ var form = this.form;
+ form.clk = this;
+
+ if (this.type == 'image')
+ {
+ if (e.offsetX != undefined)
+ {
+ form.clk_x = e.offsetX;
+ form.clk_y = e.offsetY;
+ }
+ else if (typeof $.fn.offset == 'function')
+ { // try to use dimensions plugin
+ var offset = $(this).offset();
+ form.clk_x = e.pageX - offset.left;
+ form.clk_y = e.pageY - offset.top;
+ }
+ else
+ {
+ form.clk_x = e.pageX - this.offsetLeft;
+ form.clk_y = e.pageY - this.offsetTop;
+ }
+ }
+ });
+ })
+ .submit(function(event)
+ {
+ theForm = this;
+ z_tinymce_save(theForm);
+
+ submitFunction = function(ev) {
+ var arguments = $(theForm).formToArray();
+
+ try { $(theForm).mask("", 100); } catch (e) {};
+
+ var postback = $(theForm).data("z_submit_postback");
+ var action = $(theForm).data("z_submit_action");
+ var form_id = $(theForm).attr('id');
+ var validations = $(theForm).formValidationPostback();
+
+ if(!postback)
+ {
+ postback = z_default_form_postback;
+ }
+
+ if(action)
+ {
+ setTimeout(action, 10);
+ }
+
+ var use_post = $(theForm).hasClass("z_cookie_form") || $(theForm).hasClass("z_logon_form");
+ if (typeof(z_only_post_forms) != "undefined" && z_only_post_forms)
+ {
+ use_post = true;
+ }
+ else
+ {
+ var files = $('input:file', theForm).fieldValue();
+ for (var j=0; j < files.length && !use_post; j++)
+ {
+ if (files[j])
+ {
+ use_post = true;
+ }
+ }
+ }
+
+ if (use_post)
+ {
+ $(theForm).postbackFileForm(form_id, postback, validations);
if ($(theForm).hasClass("z_logon_form")) {
/* When a z_logon_form is posted, we post to a hidden iframe, to trick chrome into showing the "save password" option. The logon form submit cannot be cancelled because that blocks the form-remembering. */
return true;
}
- }
- else
- {
- theForm.clk = theForm.clk_x = theForm.clk_y = null;
- z_queue_postback(form_id, postback, arguments.concat(validations));
- }
- ev.stopPropagation();
- return false;
- };
-
- return z_form_submit_validated_delay(theForm, event, submitFunction);
- })
- .attr('action', '#pb-installed');
+ }
+ else
+ {
+ theForm.clk = theForm.clk_x = theForm.clk_y = null;
+ z_queue_postback(form_id, postback, arguments.concat(validations));
+ }
+ ev.stopPropagation();
+ return false;
+ };
+
+ return z_form_submit_validated_delay(theForm, event, submitFunction);
+ })
+ .attr('action', '#pb-installed');
}
-function z_form_submit_validated_delay(theForm, event, submitFunction)
+function z_form_submit_validated_delay(theForm, event, submitFunction)
{
- var validations = $(theForm).formValidationPostback();
-
- if (validations.length > 0 && !event.zIsValidated)
- {
- // There are form validations and they are not done yet.
- if (!event.zAfterValidation)
- {
- event.zAfterValidation = new Array();
- }
- event.zAfterValidation.push({ func: submitFunction, context: theForm });
- return true;
- }
- else
- {
- // No form validations, or already validated
- return submitFunction.call(theForm, event);
- }
+ var validations = $(theForm).formValidationPostback();
+
+ if (validations.length > 0 && !event.zIsValidated)
+ {
+ // There are form validations and they are not done yet.
+ if (!event.zAfterValidation)
+ {
+ event.zAfterValidation = new Array();
+ }
+ event.zAfterValidation.push({ func: submitFunction, context: theForm });
+ return true;
+ }
+ else
+ {
+ // No form validations, or already validated
+ return submitFunction.call(theForm, event);
+ }
}
function z_form_submit_validated_do(event)
{
- var ret = true;
-
- if (event.zAfterValidation)
- {
- $.each(event.zAfterValidation, function(){
- ret = typeof this.func == 'function' && this.func.call(this.context, event) && ret;
- });
- event.zAfterValidation.length = 0;
- }
- return ret;
+ var ret = true;
+
+ if (event.zAfterValidation)
+ {
+ $.each(event.zAfterValidation, function(){
+ ret = typeof this.func == 'function' && this.func.call(this.context, event) && ret;
+ });
+ event.zAfterValidation.length = 0;
+ }
+ return ret;
}
$.fn.postbackFileForm = function(trigger_id, postback, validations)
{
- var a = validations;
-
- a.push({name: "postback", value: postback});
- a.push({name: "z_trigger_id", value: trigger_id});
- a.push({name: "z_pageid", value: z_pageid});
- a.push({name: "z_comet", value: z_comet_is_running || z_ws});
-
- var $form = this;
- var options = {
- url: '/postback?' + $.param(a),
- type: 'POST',
- dataType: 'text/javascript'
- };
-
- // hack to fix Safari hang (thanks to Tim Molendijk for this)
- // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
- if ($.browser.safari)
- $.get('/close-connection', fileUpload);
- else
- fileUpload();
-
- // private function for handling file uploads (hat tip to YAHOO!)
- function fileUpload() {
- var form = $form[0];
-
- if ($(':input[name=submit]', form).length) {
- alert('Error: Form elements must not be named "submit".');
- return;
- }
-
- var opts = $.extend({}, $.ajaxSettings, options);
- var s = $.extend(true, {}, $.extend(true, {}, $.ajaxSettings), opts);
-
- var id = 'jqFormIO' + (new Date().getTime());
- var $io = $('<iframe id="' + id + '" name="' + id + '" src="about:blank" />');
- var io = $io[0];
-
- $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
-
- var xhr = { // mock object
- aborted: 0,
- responseText: null,
- responseXML: null,
- status: 0,
- statusText: 'n/a',
- getAllResponseHeaders: function() {},
- getResponseHeader: function() {},
- setRequestHeader: function() {},
- abort: function() {
- this.aborted = 1;
- $io.attr('src','about:blank'); // abort op in progress
- }
- };
-
- var g = opts.global;
-
- // trigger ajax global events so that activity/block indicators work like normal
- if (g && ! $.active++) $.event.trigger("ajaxStart");
- if (g) $.event.trigger("ajaxSend", [xhr, opts]);
-
- if (s.beforeSend && s.beforeSend(xhr, s) === false) {
- s.global && $.active--;
- return;
- }
- if (xhr.aborted)
- return;
-
- var cbInvoked = 0;
- var timedOut = 0;
-
- // add submitting element to data if we know it
- var sub = form.clk;
- if (sub) {
- var n = sub.name;
- if (n && !sub.disabled) {
- options.extraData = options.extraData || {};
- options.extraData['z_submitter'] = n;
- options.extraData[n] = sub.value;
- if (sub.type == "image") {
- options.extraData[name+'.x'] = form.clk_x;
- options.extraData[name+'.y'] = form.clk_y;
- }
- }
- }
- form.clk = form.clk_x = form.clk_y = null;
-
- // take a breath so that pending repaints get some cpu time before the upload starts
- setTimeout(function() {
- // make sure form attrs are set
- var t = $form.attr('target');
- var a = $form.attr('action');
-
- // update form attrs in IE friendly way
- form.setAttribute('target',id);
- if (form.getAttribute('method') != 'POST')
- form.setAttribute('method', 'POST');
- if (form.getAttribute('action') != opts.url)
- form.setAttribute('action', opts.url);
-
- // ie borks in some cases when setting encoding
- if (! options.skipEncodingOverride) {
- $form.attr({
- encoding: 'multipart/form-data',
- enctype: 'multipart/form-data'
- });
- }
-
- // support timout
- if (opts.timeout)
- setTimeout(function() { timedOut = true; cb(); }, opts.timeout);
-
- // add "extra" data to form if provided in options
- var extraInputs = [];
- try {
- if (options.extraData)
- for (var n in options.extraData)
- extraInputs.push(
- $('<input type="hidden" name="'+n+'" value="'+options.extraData[n]+'" />')
- .appendTo(form)[0]);
-
- // add iframe to doc and submit the form
- $io.appendTo('body');
- io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);
- form.submit();
- }
- finally {
- // reset attrs and remove "extra" input elements
- form.setAttribute('action',a);
- t ? form.setAttribute('target', t) : $form.removeAttr('target');
- $(extraInputs).remove();
- }
- }, 10);
-
- var domCheckCount = 3;
-
- function cb() {
- if (cbInvoked++) return;
-
- io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false);
-
- var ok = true;
- try {
- if (timedOut) throw 'timeout';
- // extract the server response from the iframe
- var data, doc;
-
- doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
- if (doc.body == null || doc.body.innerHTML == '') {
- if (--domCheckCount) {
- // in some browsers (Opera) the iframe DOM is not always traversable when
- // the onload callback fires, so we loop a bit to accommodate
-
- // MW: looks like this is not a timing issue but Opera triggering a
- // load event on the 100 continue.
- cbInvoked = 0;
- io.addEventListener('load', cb, false);
- return;
- }
- log('Could not access iframe DOM after 50 tries.');
- return;
- }
-
- xhr.responseText = doc.body ? doc.body.innerHTML : null;
-
- xhr.getResponseHeader = function(header){
- var headers = {'content-type': opts.dataType};
- return headers[header];
- };
-
- var ta = doc.getElementsByTagName('textarea')[0];
- xhr.responseText = ta ? ta.value : xhr.responseText;
- data = z_httpdata(xhr, opts.dataType);
- }
- catch(e){
- ok = false;
- $.event.trigger("ajaxError", [xhr, opts, e]);
- }
-
- // ordering of these callbacks/triggers is odd, but that's how $.ajax does it
- if (ok) {
- try {
- eval(data);
- } catch (e) {
- z_unmask_error(form.id);
- }
- if (g)
- {
- $.event.trigger("ajaxSuccess", [xhr, opts]);
- }
- } else {
- z_unmask_error(form.id);
- }
- if (g) $.event.trigger("ajaxComplete", [xhr, opts]);
- if (g && ! --$.active) $.event.trigger("ajaxStop");
- if (opts.complete) opts.complete(xhr, ok ? 'success' : 'error');
-
- // clean up
- setTimeout(function() {
- $io.remove();
- xhr.responseXML = null;
- }, 100);
- };
- };
+ var a = validations;
+
+ a.push({name: "postback", value: postback});
+ a.push({name: "z_trigger_id", value: trigger_id});
+ a.push({name: "z_pageid", value: z_pageid});
+ a.push({name: "z_comet", value: z_comet_is_running || z_ws});
+
+ var $form = this;
+ var options = {
+ url: '/postback?' + $.param(a),
+ type: 'POST',
+ dataType: 'text/javascript'
+ };
+
+ // hack to fix Safari hang (thanks to Tim Molendijk for this)
+ // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
+ if ($.browser.safari)
+ $.get('/close-connection', fileUpload);
+ else
+ fileUpload();
+
+ // private function for handling file uploads (hat tip to YAHOO!)
+ function fileUpload() {
+ var form = $form[0];
+
+ if ($(':input[name=submit]', form).length) {
+ alert('Error: Form elements must not be named "submit".');
+ return;
+ }
+
+ var opts = $.extend({}, $.ajaxSettings, options);
+ var s = $.extend(true, {}, $.extend(true, {}, $.ajaxSettings), opts);
+
+ var id = 'jqFormIO' + (new Date().getTime());
+ var $io = $('<iframe id="' + id + '" name="' + id + '" src="about:blank" />');
+ var io = $io[0];
+
+ $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
+
+ var xhr = { // mock object
+ aborted: 0,
+ responseText: null,
+ responseXML: null,
+ status: 0,
+ statusText: 'n/a',
+ getAllResponseHeaders: function() {},
+ getResponseHeader: function() {},
+ setRequestHeader: function() {},
+ abort: function() {
+ this.aborted = 1;
+ $io.attr('src','about:blank'); // abort op in progress
+ }
+ };
+
+ var g = opts.global;
+
+ // trigger ajax global events so that activity/block indicators work like normal
+ if (g && ! $.active++) $.event.trigger("ajaxStart");
+ if (g) $.event.trigger("ajaxSend", [xhr, opts]);
+
+ if (s.beforeSend && s.beforeSend(xhr, s) === false) {
+ s.global && $.active--;
+ return;
+ }
+ if (xhr.aborted)
+ return;
+
+ var cbInvoked = 0;
+ var timedOut = 0;
+
+ // add submitting element to data if we know it
+ var sub = form.clk;
+ if (sub) {
+ var n = sub.name;
+ if (n && !sub.disabled) {
+ options.extraData = options.extraData || {};
+ options.extraData['z_submitter'] = n;
+ options.extraData[n] = sub.value;
+ if (sub.type == "image") {
+ options.extraData[name+'.x'] = form.clk_x;
+ options.extraData[name+'.y'] = form.clk_y;
+ }
+ }
+ }
+ form.clk = form.clk_x = form.clk_y = null;
+
+ // take a breath so that pending repaints get some cpu time before the upload starts
+ setTimeout(function() {
+ // make sure form attrs are set
+ var t = $form.attr('target');
+ var a = $form.attr('action');
+
+ // update form attrs in IE friendly way
+ form.setAttribute('target',id);
+ if (form.getAttribute('method') != 'POST')
+ form.setAttribute('method', 'POST');
+ if (form.getAttribute('action') != opts.url)
+ form.setAttribute('action', opts.url);
+
+ // ie borks in some cases when setting encoding
+ if (! options.skipEncodingOverride) {
+ $form.attr({
+ encoding: 'multipart/form-data',
+ enctype: 'multipart/form-data'
+ });
+ }
+
+ // support timout
+ if (opts.timeout)
+ setTimeout(function() { timedOut = true; cb(); }, opts.timeout);
+
+ // add "extra" data to form if provided in options
+ var extraInputs = [];
+ try {
+ if (options.extraData)
+ for (var n in options.extraData)
+ extraInputs.push(
+ $('<input type="hidden" name="'+n+'" value="'+options.extraData[n]+'" />')
+ .appendTo(form)[0]);
+
+ // add iframe to doc and submit the form
+ $io.appendTo('body');
+ io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);
+ form.submit();
+ }
+ finally {
+ // reset attrs and remove "extra" input elements
+ form.setAttribute('action',a);
+ t ? form.setAttribute(