Adapt for prototype 1.9 and scriptaculous

This commit is contained in:
Dany De Bontridder 2011-10-29 20:59:04 +00:00
parent 726b4a0445
commit d1b42f6e97
19 changed files with 2713 additions and 1515 deletions

View file

@ -32,7 +32,7 @@ function update_predef(p_type,p_direct)
{ {
var jrn=g("p_jrn").value; var jrn=g("p_jrn").value;
var dossier=g("gDossier").value; var dossier=g("gDossier").value;
var querystring='?&gDossier='+dossier+'&l='+jrn+'&t='+p_type+'&d='+p_direct; var querystring='gDossier='+dossier+'&l='+jrn+'&t='+p_type+'&d='+p_direct;
g("p_jrn_predef").value=jrn; g("p_jrn_predef").value=jrn;
var action=new Ajax.Request( var action=new Ajax.Request(
"get_predef.php", "get_predef.php",
@ -78,7 +78,7 @@ function update_pj()
{ {
var jrn=g("p_jrn").value; var jrn=g("p_jrn").value;
var dossier=g("gDossier").value; var dossier=g("gDossier").value;
var querystring='?&gDossier='+dossier+'&l='+jrn; var querystring='gDossier='+dossier+'&l='+jrn;
var action=new Ajax.Request( var action=new Ajax.Request(
"get_pj.php", "get_pj.php",
{ {
@ -96,7 +96,7 @@ function update_bank()
{ {
var jrn=g('p_jrn').value; var jrn=g('p_jrn').value;
var dossier=g('gDossier').value; var dossier=g('gDossier').value;
var qs='?&gDossier='+dossier+'&op=bkname&p_jrn='+jrn; var qs='gDossier='+dossier+'&op=bkname&p_jrn='+jrn;
var action=new Ajax.Request( var action=new Ajax.Request(
"ajax_misc.php", "ajax_misc.php",
{ {
@ -141,7 +141,7 @@ function get_last_date()
{ {
var jrn=g('p_jrn').value; var jrn=g('p_jrn').value;
var dossier=g('gDossier').value; var dossier=g('gDossier').value;
var qs='?&gDossier='+dossier+'&op=lastdate&p_jrn='+jrn; var qs='gDossier='+dossier+'&op=lastdate&p_jrn='+jrn;
var action=new Ajax.Request( var action=new Ajax.Request(
"ajax_misc.php", "ajax_misc.php",
{ {
@ -303,7 +303,7 @@ function compute_ledger(p_ctl_nb)
g('e_quant'+p_ctl_nb).value=trim(g('e_quant'+p_ctl_nb).value); g('e_quant'+p_ctl_nb).value=trim(g('e_quant'+p_ctl_nb).value);
var quantity=g('e_quant'+p_ctl_nb).value; var quantity=g('e_quant'+p_ctl_nb).value;
var querystring='?&gDossier='+dossier+'&c='+qcode+'&t='+tva_id+'&p='+price+'&q='+quantity+'&n='+p_ctl_nb; var querystring='gDossier='+dossier+'&c='+qcode+'&t='+tva_id+'&p='+price+'&q='+quantity+'&n='+p_ctl_nb;
$('sum').hide(); $('sum').hide();
var action=new Ajax.Request( var action=new Ajax.Request(
"compute.php", "compute.php",
@ -591,7 +591,7 @@ function view_history_account(p_value,dossier)
id='det'+layer; id='det'+layer;
var popup={'id': id,'cssclass':'op_detail','html':loading(),'drag':true}; var popup={'id': id,'cssclass':'op_detail','html':loading(),'drag':true};
querystring='?gDossier='+dossier+'&act=de&pcm_val='+p_value+'&div='+id; querystring='gDossier='+dossier+'&act=de&pcm_val='+p_value+'&div='+id;
add_div(popup); add_div(popup);
var action=new Ajax.Request( var action=new Ajax.Request(
"ajax_history.php", "ajax_history.php",
@ -610,7 +610,7 @@ function view_history_account(p_value,dossier)
function update_history_account(obj) function update_history_account(obj)
{ {
try{ try{
var querystring="?div="+obj.div+"&gDossier="+obj.gDossier+"&pcm_val="+obj.pcm_val+"&ex="+obj.select.options[obj.select.selectedIndex].text; var querystring="div="+obj.div+"&gDossier="+obj.gDossier+"&pcm_val="+obj.pcm_val+"&ex="+obj.select.options[obj.select.selectedIndex].text;
var action=new Ajax.Request( var action=new Ajax.Request(
"ajax_history.php", "ajax_history.php",
{ {
@ -639,7 +639,7 @@ var popup={'id':
,'html': ,'html':
loading(),'drag': loading(),'drag':
true}; true};
querystring='?gDossier='+dossier+'&act=de&f_id='+p_value+'&div='+id; querystring='gDossier='+dossier+'&act=de&f_id='+p_value+'&div='+id;
add_div(popup); add_div(popup);
var action=new Ajax.Request( var action=new Ajax.Request(
"ajax_history.php", "ajax_history.php",
@ -658,7 +658,7 @@ var popup={'id':
function update_history_card(obj) function update_history_card(obj)
{ {
try{ try{
var querystring="?div="+obj.div+"&gDossier="+obj.gDossier+"&f_id="+obj.f_id+"&ex="+obj.select.options[obj.select.selectedIndex].text; var querystring="div="+obj.div+"&gDossier="+obj.gDossier+"&f_id="+obj.f_id+"&ex="+obj.select.options[obj.select.selectedIndex].text;
var action=new Ajax.Request( var action=new Ajax.Request(
"ajax_history.php", "ajax_history.php",
{ {
@ -682,7 +682,7 @@ function update_history_card(obj)
*/ */
function removeOperation(p_jr_id,dossier,div) function removeOperation(p_jr_id,dossier,div)
{ {
var qs="?gDossier="+dossier+"&act=rmop&div="+div+"&jr_id="+p_jr_id; var qs="gDossier="+dossier+"&act=rmop&div="+div+"&jr_id="+p_jr_id;
var action=new Ajax.Request( var action=new Ajax.Request(
"ajax_ledger.php", "ajax_ledger.php",
{ {
@ -701,7 +701,7 @@ function removeOperation(p_jr_id,dossier,div)
*/ */
function reverseOperation(obj) function reverseOperation(obj)
{ {
var qs="?"+$(obj).serialize(); var qs=$(obj).serialize();
g('ext'+obj.divname).style.display='none'; g('ext'+obj.divname).style.display='none';
g('bext'+obj.divname).style.display='none'; g('bext'+obj.divname).style.display='none';
@ -730,7 +730,7 @@ function modifyOperation(p_value,dossier)
,'html': ,'html':
loading(),'drag': loading(),'drag':
true}; true};
querystring='?gDossier='+dossier+'&act=de&jr_id='+p_value+'&div='+id; querystring='gDossier='+dossier+'&act=de&jr_id='+p_value+'&div='+id;
add_div(popup); add_div(popup);
var action=new Ajax.Request( var action=new Ajax.Request(
"ajax_ledger.php", "ajax_ledger.php",
@ -756,7 +756,7 @@ function viewOperation(p_value,p_dossier)
} }
function dropLink(p_dossier,p_div,p_jr_id,p_jr_id2) function dropLink(p_dossier,p_div,p_jr_id,p_jr_id2)
{ {
var querystring='?gDossier='+p_dossier; var querystring='gDossier='+p_dossier;
querystring+='&div='+p_div; querystring+='&div='+p_div;
querystring+='&jr_id='+p_jr_id; querystring+='&jr_id='+p_jr_id;
querystring+='&act=rmr'; querystring+='&act=rmr';
@ -800,7 +800,7 @@ function dsp_letter(obj)
{ {
try try
{ {
var queryString='?gDossier='+obj.gDossier+'&j_id='+obj.j_id+'&op=dl'+'&ot='+this.obj_type; var queryString='gDossier='+obj.gDossier+'&j_id='+obj.j_id+'&op=dl'+'&ot='+this.obj_type;
var action=new Ajax.Request( var action=new Ajax.Request(
"ajax_misc.php", "ajax_misc.php",
{ {
@ -893,14 +893,14 @@ function search_letter(obj)
} }
} }
/** /**
*@brief save an operation in ajax, it concerns only the *@brief save an operation in ajax, it concerns only the
* comment, the pj and the rapt * comment, the pj and the rapt
* the form elements are access by their name * the form elements are access by their name
*@param form *@param form
*/ */
function op_save(obj) function op_save(obj)
{ {
var queryString='?'+$(obj).serialize(); var queryString=$(obj).serialize();
queryString+="&lib="+obj.lib.value; queryString+="&lib="+obj.lib.value;
queryString+="&gDossier="+obj.gDossier.value; queryString+="&gDossier="+obj.gDossier.value;
var rapt2="rapt"+obj.whatdiv.value; var rapt2="rapt"+obj.whatdiv.value;

View file

@ -80,7 +80,7 @@ function search_poste(obj)
var dossier=$('gDossier').value; var dossier=$('gDossier').value;
var queryString="?gDossier="+dossier; var queryString="gDossier="+dossier;
queryString+="&op=sf"; queryString+="&op=sf";
try try
@ -155,7 +155,7 @@ function search_poste(obj)
function search_get_poste(obj) function search_get_poste(obj)
{ {
var dossier=$('gDossier').value; var dossier=$('gDossier').value;
var queryString="?gDossier="+dossier; var queryString="gDossier="+dossier;
queryString+="&op=sf"; queryString+="&op=sf";

View file

@ -20,7 +20,7 @@
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
/*! \file /*! \file
* \brief This file permit to use the AJAX function to fill up * \brief This file permit to use the AJAX function to fill up
* info from fiche * info from fiche
* *
*/ */
@ -91,7 +91,7 @@ function ajaxFid(p_ctl)
return; return;
} }
} }
var queryString="?FID="+trim($(p_ctl).value); var queryString="FID="+trim($(p_ctl).value);
if ( $(p_ctl).label) if ( $(p_ctl).label)
{ {
queryString+='&l='+$(p_ctl).label; queryString+='&l='+$(p_ctl).label;
@ -129,7 +129,7 @@ function ajaxFid(p_ctl)
} }
/*!\brief callback function for ajax /*!\brief callback function for ajax
* \param request : object request * \param request : object request
* \param json : json answer * \param json : json answer
\verbatim \verbatim
{"answer":"ok", {"answer":"ok",
"flabel":"none", "flabel":"none",
@ -180,14 +180,14 @@ function ajax_error_saldo(request,json)
alert('erreur : ajax fiche'); alert('erreur : ajax fiche');
} }
/*!\brief this function get the saldo /*!\brief this function get the saldo
* \param p_ctl the ctrl where we take the quick_code * \param p_ctl the ctrl where we take the quick_code
*/ */
function ajax_saldo(p_ctl) function ajax_saldo(p_ctl)
{ {
var gDossier=$('gDossier').value; var gDossier=$('gDossier').value;
var ctl_value=trim($(p_ctl).value); var ctl_value=trim($(p_ctl).value);
var jrn=$('p_jrn').value; var jrn=$('p_jrn').value;
queryString="?FID="+ctl_value; queryString="FID="+ctl_value;
queryString=queryString+'&gDossier='+gDossier+'&j='+jrn; queryString=queryString+'&gDossier='+gDossier+'&j='+jrn;
queryString=queryString+'&ctl='+ctl_value; queryString=queryString+'&ctl='+ctl_value;
/* alert(queryString); */ /* alert(queryString); */

View file

@ -120,7 +120,7 @@ function verify_ca(div)
function search_ca (p_dossier,p_target,p_source) function search_ca (p_dossier,p_target,p_source)
{ {
var pa_id=g(p_source).value; var pa_id=g(p_source).value;
var url="?gDossier="+p_dossier+"&c1="+p_target+"&c2="+pa_id; var url="gDossier="+p_dossier+"&c1="+p_target+"&c2="+pa_id;
var a=window.open("search_ca.php"+url,"CA recherche",'statusbar=no,scrollbars=yes,toolbar=no'); var a=window.open("search_ca.php"+url,"CA recherche",'statusbar=no,scrollbars=yes,toolbar=no');
a.focus(); a.focus();
} }

View file

@ -1,6 +1,6 @@
// script.aculo.us builder.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009 // script.aculo.us builder.js v1.9.0, Thu Dec 23 16:54:48 -0500 2010
// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // Copyright (c) 2005-2010 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// //
// script.aculo.us is freely distributable under the terms of an MIT-style license. // script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/ // For details, see the script.aculo.us web site: http://script.aculo.us/

View file

@ -76,7 +76,7 @@ function search_card(obj)
var div_style="top:"+sx+";width:60%;heigth:80%"; var div_style="top:"+sx+";width:60%;heigth:80%";
add_div({id:'search_card',cssclass:'op_detail',html:loading(),style:div_style,drag:true}); add_div({id:'search_card',cssclass:'op_detail',html:loading(),style:div_style,drag:true});
var action=new Ajax.Request ( 'ajax_card.php', var action=new Ajax.Request ( 'ajax_card.php',
{ {
method:'get', method:'get',
@ -95,13 +95,13 @@ function search_card(obj)
*@brief when you submit the form for searching a card *@brief when you submit the form for searching a card
*@param obj form *@param obj form
*@note the same as search_card, except it answer to a FORM and not *@note the same as search_card, except it answer to a FORM and not
* to a click event * to a click event
*/ */
function search_get_card(obj) function search_get_card(obj)
{ {
var dossier=$('gDossier').value; var dossier=$('gDossier').value;
var queryString="?gDossier="+dossier; var queryString="gDossier="+dossier;
queryString+="&op=fs"; queryString+="&op=fs";
if ( obj.elements['inp'] ) if ( obj.elements['inp'] )
@ -315,15 +315,15 @@ function fill_ipopcard(obj)
} }
// ctl=$(obj).id; // ctl=$(obj).id;
var queryString='?gDossier='+dossier; var queryString='gDossier='+dossier;
queryString+='&qcode='+qcode; queryString+='&qcode='+qcode;
queryString+='&ctl='+content; queryString+='&ctl='+content;
queryString+='&op=dc'; // dc for detail card queryString+='&op=dc'; // dc for detail card
if ( obj.readonly != undefined) { if ( obj.readonly != undefined) {
queryString+='&ro'; queryString+='&ro';
} }
if ( obj.nohistory != undefined) { if ( obj.nohistory != undefined) {
queryString+='&nohistory'; queryString+='&nohistory';
} }
@ -339,7 +339,7 @@ function fill_ipopcard(obj)
/** /**
*@brief *@brief
* \param request : object request * \param request : object request
* \param json : json answer * \param json : json answer
\code \code
\endcode \endcode
*/ */
@ -376,7 +376,7 @@ function successFill_ipopcard(req,json)
} }
} }
/** /**
*@brief show the ipopup for selecting a card type, it is a needed step before adding *@brief show the ipopup for selecting a card type, it is a needed step before adding
* a card * a card
*@param input field (obj) it must have the attribute ipopup *@param input field (obj) it must have the attribute ipopup
* possible attribute : * possible attribute :
@ -387,7 +387,7 @@ function successFill_ipopcard(req,json)
*/ */
function select_card_type(obj) function select_card_type(obj)
{ {
var dossier=$('gDossier').value; var dossier=$('gDossier').value;
// give a filter, -1 if not // give a filter, -1 if not
@ -414,7 +414,7 @@ function select_card_type(obj)
add_div(popup); add_div(popup);
var queryString='?gDossier='+dossier; var queryString='gDossier='+dossier;
queryString+='&ctl='+content; queryString+='&ctl='+content;
queryString+='&op=st'; // st for selecting type queryString+='&op=st'; // st for selecting type
if ( $(obj).win_refresh!=undefined) if ( $(obj).win_refresh!=undefined)
@ -478,7 +478,7 @@ function dis_blank_card(obj)
var dossier=$('gDossier').value; var dossier=$('gDossier').value;
var queryString='?gDossier='+dossier; var queryString='gDossier='+dossier;
queryString+='&ctl='+content; queryString+='&ctl='+content;
queryString+='&fd_id='+fd_id; queryString+='&fd_id='+fd_id;
queryString+=ref; queryString+=ref;
@ -507,7 +507,7 @@ function save_card(obj)
$(content).innerHTML=loading(); $(content).innerHTML=loading();
var dossier=$('gDossier').value; var dossier=$('gDossier').value;
var queryString='?gDossier='+dossier; var queryString='gDossier='+dossier;
queryString+='&ctl='+content; queryString+='&ctl='+content;
queryString+=data; queryString+=data;
queryString+='&op=sc'; // sc for save card queryString+='&op=sc'; // sc for save card
@ -532,7 +532,7 @@ function add_category(obj)
// show ipopup // show ipopup
showIPopup(obj.ipopup); showIPopup(obj.ipopup);
var dossier=$('gDossier').value; var dossier=$('gDossier').value;
var queryString='?gDossier='+dossier; var queryString='gDossier='+dossier;
queryString+='&op=ac'; queryString+='&op=ac';
queryString+='&ctl='+obj.ipopup+'_content'; queryString+='&ctl='+obj.ipopup+'_content';
if ( obj.type_cat) if ( obj.type_cat)
@ -581,7 +581,7 @@ function save_card_category(obj)
); );
} }
/** /**
*@brief Remove a definition of an attribut *@brief Remove a definition of an attribut
*@param attr_def.ad_id *@param attr_def.ad_id
*@param gDossier *@param gDossier
*@param table_id to rm the row *@param table_id to rm the row
@ -590,7 +590,7 @@ function save_card_category(obj)
function removeCardAttribut(ad_id,gDossier,table_id,row) function removeCardAttribut(ad_id,gDossier,table_id,row)
{ {
var queryString='?gDossier='+gDossier; var queryString='gDossier='+gDossier;
queryString+='&op=rmfa'; queryString+='&op=rmfa';
queryString+='&ctl=debug'; // debug id queryString+='&ctl=debug'; // debug id
queryString+='&ad_id='+ad_id; queryString+='&ad_id='+ad_id;

11
html/js/controls.js vendored
View file

@ -1,8 +1,8 @@
// script.aculo.us controls.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009 // script.aculo.us controls.js v1.9.0, Thu Dec 23 16:54:48 -0500 2010
// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // Copyright (c) 2005-2010 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// (c) 2005-2009 Ivan Krstic (http://blogs.law.harvard.edu/ivan) // (c) 2005-2010 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
// (c) 2005-2009 Jon Tirsen (http://www.tirsen.com) // (c) 2005-2010 Jon Tirsen (http://www.tirsen.com)
// Contributors: // Contributors:
// Richard Livsey // Richard Livsey
// Rahul Bhargava // Rahul Bhargava
@ -67,6 +67,7 @@ Autocompleter.Base = Class.create({
update.style.position = 'absolute'; update.style.position = 'absolute';
Position.clone(element, update, { Position.clone(element, update, {
setHeight: false, setHeight: false,
setWidth:true,
offsetTop: element.offsetHeight offsetTop: element.offsetHeight
}); });
} }
@ -781,7 +782,7 @@ Ajax.InPlaceCollectionEditor = Class.create(Ajax.InPlaceEditor, {
onComplete: Prototype.emptyFunction, onComplete: Prototype.emptyFunction,
onSuccess: function(transport) { onSuccess: function(transport) {
var js = transport.responseText.strip(); var js = transport.responseText.strip();
if (!/^\[.*\]$/.test(js)) if (!/^\[.*\]$/.test(js)) // TODO: improve sanity check
throw('Server returned an invalid collection representation.'); throw('Server returned an invalid collection representation.');
this._collection = eval(js); this._collection = eval(js);
this.checkForExternalText(); this.checkForExternalText();

354
html/js/dragdrop.js vendored
View file

@ -1,8 +1,7 @@
// script.aculo.us dragdrop.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008 // script.aculo.us dragdrop.js v1.9.0, Thu Dec 23 16:54:48 -0500 2010
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // Copyright (c) 2005-2010 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// (c) 2005-2007 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz) //
//
// script.aculo.us is freely distributable under the terms of an MIT-style license. // script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/ // For details, see the script.aculo.us web site: http://script.aculo.us/
@ -21,8 +20,7 @@ var Droppables = {
var options = Object.extend({ var options = Object.extend({
greedy: true, greedy: true,
hoverclass: null, hoverclass: null,
tree: false, tree: false
scrollid: null
}, arguments[1] || { }); }, arguments[1] || { });
// cache containers // cache containers
@ -35,7 +33,7 @@ var Droppables = {
options._containers.push($(containment)); options._containers.push($(containment));
} }
} }
if(options.accept) options.accept = [options.accept].flatten(); if(options.accept) options.accept = [options.accept].flatten();
Element.makePositioned(element); // fix IE Element.makePositioned(element); // fix IE
@ -43,43 +41,34 @@ var Droppables = {
this.drops.push(options); this.drops.push(options);
}, },
findDeepestChild: function(drops) { findDeepestChild: function(drops) {
deepest = drops[0]; deepest = drops[0];
for (i = 1; i < drops.length; ++i) for (i = 1; i < drops.length; ++i)
if (Element.isParent(drops[i].element, deepest.element)) if (Element.isParent(drops[i].element, deepest.element))
deepest = drops[i]; deepest = drops[i];
return deepest; return deepest;
}, },
isContained: function(element, drop) { isContained: function(element, drop) {
var containmentNode; var containmentNode;
if(drop.tree) { if(drop.tree) {
containmentNode = element.treeNode; containmentNode = element.treeNode;
} else { } else {
containmentNode = element.parentNode; containmentNode = element.parentNode;
} }
return drop._containers.detect(function(c) { return containmentNode == c }); return drop._containers.detect(function(c) { return containmentNode == c });
}, },
isAffected: function(point, element, drop) { isAffected: function(point, element, drop) {
if( drop.scrollid ){
Position.includeScrollOffsets = true;
scrolling_element = $(drop.scrollid)
var container_off = Element.cumulativeOffset(scrolling_element);
if( point[1] < container_off[1] || point[1] > Element.getHeight(scrolling_element) + container_off[1])
{return false;}
else if( point[0] < container_off[0] || point[0] > Element.getWidth(scrolling_element) + container_off[0])
{return false;}
}
return ( return (
(drop.element!=element) && (drop.element!=element) &&
((!drop._containers) || ((!drop._containers) ||
this.isContained(element, drop)) && this.isContained(element, drop)) &&
((!drop.accept) || ((!drop.accept) ||
(Element.classNames(element).detect( (Element.classNames(element).detect(
function(v) { return drop.accept.include(v) } ) )) && function(v) { return drop.accept.include(v) } ) )) &&
Position.within(drop.element, point[0], point[1]) ); Position.within(drop.element, point[0], point[1]) );
}, },
@ -99,12 +88,12 @@ var Droppables = {
show: function(point, element) { show: function(point, element) {
if(!this.drops.length) return; if(!this.drops.length) return;
var drop, affected = []; var drop, affected = [];
this.drops.each( function(drop) { this.drops.each( function(drop) {
if(Droppables.isAffected(point, element, drop)) if(Droppables.isAffected(point, element, drop))
affected.push(drop); affected.push(drop);
}); });
if(affected.length>0) if(affected.length>0)
drop = Droppables.findDeepestChild(affected); drop = Droppables.findDeepestChild(affected);
@ -113,7 +102,7 @@ var Droppables = {
Position.within(drop.element, point[0], point[1]); Position.within(drop.element, point[0], point[1]);
if(drop.onHover) if(drop.onHover)
drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element)); drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element));
if (drop != this.last_active) Droppables.activate(drop); if (drop != this.last_active) Droppables.activate(drop);
} }
}, },
@ -124,8 +113,8 @@ var Droppables = {
if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active)) if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active))
if (this.last_active.onDrop) { if (this.last_active.onDrop) {
this.last_active.onDrop(element, this.last_active.element, event); this.last_active.onDrop(element, this.last_active.element, event);
return true; return true;
} }
}, },
@ -133,25 +122,25 @@ var Droppables = {
if(this.last_active) if(this.last_active)
this.deactivate(this.last_active); this.deactivate(this.last_active);
} }
} };
var Draggables = { var Draggables = {
drags: [], drags: [],
observers: [], observers: [],
register: function(draggable) { register: function(draggable) {
if(this.drags.length == 0) { if(this.drags.length == 0) {
this.eventMouseUp = this.endDrag.bindAsEventListener(this); this.eventMouseUp = this.endDrag.bindAsEventListener(this);
this.eventMouseMove = this.updateDrag.bindAsEventListener(this); this.eventMouseMove = this.updateDrag.bindAsEventListener(this);
this.eventKeypress = this.keyPress.bindAsEventListener(this); this.eventKeypress = this.keyPress.bindAsEventListener(this);
Event.observe(document, "mouseup", this.eventMouseUp); Event.observe(document, "mouseup", this.eventMouseUp);
Event.observe(document, "mousemove", this.eventMouseMove); Event.observe(document, "mousemove", this.eventMouseMove);
Event.observe(document, "keypress", this.eventKeypress); Event.observe(document, "keypress", this.eventKeypress);
} }
this.drags.push(draggable); this.drags.push(draggable);
}, },
unregister: function(draggable) { unregister: function(draggable) {
this.drags = this.drags.reject(function(d) { return d==draggable }); this.drags = this.drags.reject(function(d) { return d==draggable });
if(this.drags.length == 0) { if(this.drags.length == 0) {
@ -160,24 +149,24 @@ var Draggables = {
Event.stopObserving(document, "keypress", this.eventKeypress); Event.stopObserving(document, "keypress", this.eventKeypress);
} }
}, },
activate: function(draggable) { activate: function(draggable) {
if(draggable.options.delay) { if(draggable.options.delay) {
this._timeout = setTimeout(function() { this._timeout = setTimeout(function() {
Draggables._timeout = null; Draggables._timeout = null;
window.focus(); window.focus();
Draggables.activeDraggable = draggable; Draggables.activeDraggable = draggable;
}.bind(this), draggable.options.delay); }.bind(this), draggable.options.delay);
} else { } else {
window.focus(); // allows keypress events if window isn't currently focused, fails for Safari window.focus(); // allows keypress events if window isn't currently focused, fails for Safari
this.activeDraggable = draggable; this.activeDraggable = draggable;
} }
}, },
deactivate: function() { deactivate: function() {
this.activeDraggable = null; this.activeDraggable = null;
}, },
updateDrag: function(event) { updateDrag: function(event) {
if(!this.activeDraggable) return; if(!this.activeDraggable) return;
var pointer = [Event.pointerX(event), Event.pointerY(event)]; var pointer = [Event.pointerX(event), Event.pointerY(event)];
@ -185,36 +174,36 @@ var Draggables = {
// the same coordinates, prevent needless redrawing (moz bug?) // the same coordinates, prevent needless redrawing (moz bug?)
if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return; if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return;
this._lastPointer = pointer; this._lastPointer = pointer;
this.activeDraggable.updateDrag(event, pointer); this.activeDraggable.updateDrag(event, pointer);
}, },
endDrag: function(event) { endDrag: function(event) {
if(this._timeout) { if(this._timeout) {
clearTimeout(this._timeout); clearTimeout(this._timeout);
this._timeout = null; this._timeout = null;
} }
if(!this.activeDraggable) return; if(!this.activeDraggable) return;
this._lastPointer = null; this._lastPointer = null;
this.activeDraggable.endDrag(event); this.activeDraggable.endDrag(event);
this.activeDraggable = null; this.activeDraggable = null;
}, },
keyPress: function(event) { keyPress: function(event) {
if(this.activeDraggable) if(this.activeDraggable)
this.activeDraggable.keyPress(event); this.activeDraggable.keyPress(event);
}, },
addObserver: function(observer) { addObserver: function(observer) {
this.observers.push(observer); this.observers.push(observer);
this._cacheObserverCallbacks(); this._cacheObserverCallbacks();
}, },
removeObserver: function(element) { // element instead of observer fixes mem leaks removeObserver: function(element) { // element instead of observer fixes mem leaks
this.observers = this.observers.reject( function(o) { return o.element==element }); this.observers = this.observers.reject( function(o) { return o.element==element });
this._cacheObserverCallbacks(); this._cacheObserverCallbacks();
}, },
notify: function(eventName, draggable, event) { // 'onStart', 'onEnd', 'onDrag' notify: function(eventName, draggable, event) { // 'onStart', 'onEnd', 'onDrag'
if(this[eventName+'Count'] > 0) if(this[eventName+'Count'] > 0)
this.observers.each( function(o) { this.observers.each( function(o) {
@ -222,7 +211,7 @@ var Draggables = {
}); });
if(draggable.options[eventName]) draggable.options[eventName](draggable, event); if(draggable.options[eventName]) draggable.options[eventName](draggable, event);
}, },
_cacheObserverCallbacks: function() { _cacheObserverCallbacks: function() {
['onStart','onEnd','onDrag'].each( function(eventName) { ['onStart','onEnd','onDrag'].each( function(eventName) {
Draggables[eventName+'Count'] = Draggables.observers.select( Draggables[eventName+'Count'] = Draggables.observers.select(
@ -230,7 +219,7 @@ var Draggables = {
).length; ).length;
}); });
} }
} };
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
@ -246,12 +235,12 @@ var Draggable = Class.create({
}, },
endeffect: function(element) { endeffect: function(element) {
var toOpacity = Object.isNumber(element._opacity) ? element._opacity : 1.0; var toOpacity = Object.isNumber(element._opacity) ? element._opacity : 1.0;
new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity, new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
queue: {scope:'_draggable', position:'end'}, queue: {scope:'_draggable', position:'end'},
afterFinish: function(){ afterFinish: function(){
Draggable._dragging[element] = false Draggable._dragging[element] = false
} }
}); });
}, },
zindex: 1000, zindex: 1000,
revert: false, revert: false,
@ -262,57 +251,57 @@ var Draggable = Class.create({
snap: false, // false, or xy or [x,y] or function(x,y){ return [x,y] } snap: false, // false, or xy or [x,y] or function(x,y){ return [x,y] }
delay: 0 delay: 0
}; };
if(!arguments[1] || Object.isUndefined(arguments[1].endeffect)) if(!arguments[1] || Object.isUndefined(arguments[1].endeffect))
Object.extend(defaults, { Object.extend(defaults, {
starteffect: function(element) { starteffect: function(element) {
element._opacity = Element.getOpacity(element); element._opacity = Element.getOpacity(element);
Draggable._dragging[element] = true; Draggable._dragging[element] = true;
new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7}); new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});
} }
}); });
var options = Object.extend(defaults, arguments[1] || { }); var options = Object.extend(defaults, arguments[1] || { });
this.element = $(element); this.element = $(element);
if(options.handle && Object.isString(options.handle)) if(options.handle && Object.isString(options.handle))
this.handle = this.element.down('.'+options.handle, 0); this.handle = this.element.down('.'+options.handle, 0);
if(!this.handle) this.handle = $(options.handle); if(!this.handle) this.handle = $(options.handle);
if(!this.handle) this.handle = this.element; if(!this.handle) this.handle = this.element;
if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) { if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) {
options.scroll = $(options.scroll); options.scroll = $(options.scroll);
this._isScrollChild = Element.childOf(this.element, options.scroll); this._isScrollChild = Element.childOf(this.element, options.scroll);
} }
Element.makePositioned(this.element); // fix IE Element.makePositioned(this.element); // fix IE
this.options = options; this.options = options;
this.dragging = false; this.dragging = false;
this.eventMouseDown = this.initDrag.bindAsEventListener(this); this.eventMouseDown = this.initDrag.bindAsEventListener(this);
Event.observe(this.handle, "mousedown", this.eventMouseDown); Event.observe(this.handle, "mousedown", this.eventMouseDown);
Draggables.register(this); Draggables.register(this);
}, },
destroy: function() { destroy: function() {
Event.stopObserving(this.handle, "mousedown", this.eventMouseDown); Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);
Draggables.unregister(this); Draggables.unregister(this);
}, },
currentDelta: function() { currentDelta: function() {
return([ return([
parseInt(Element.getStyle(this.element,'left') || '0'), parseInt(Element.getStyle(this.element,'left') || '0'),
parseInt(Element.getStyle(this.element,'top') || '0')]); parseInt(Element.getStyle(this.element,'top') || '0')]);
}, },
initDrag: function(event) { initDrag: function(event) {
if(!Object.isUndefined(Draggable._dragging[this.element]) && if(!Object.isUndefined(Draggable._dragging[this.element]) &&
Draggable._dragging[this.element]) return; Draggable._dragging[this.element]) return;
if(Event.isLeftClick(event)) { if(Event.isLeftClick(event)) {
// abort on form elements, fixes a Firefox issue // abort on form elements, fixes a Firefox issue
var src = Event.element(event); var src = Event.element(event);
if((tag_name = src.tagName.toUpperCase()) && ( if((tag_name = src.tagName.toUpperCase()) && (
@ -321,34 +310,34 @@ var Draggable = Class.create({
tag_name=='OPTION' || tag_name=='OPTION' ||
tag_name=='BUTTON' || tag_name=='BUTTON' ||
tag_name=='TEXTAREA')) return; tag_name=='TEXTAREA')) return;
var pointer = [Event.pointerX(event), Event.pointerY(event)]; var pointer = [Event.pointerX(event), Event.pointerY(event)];
var pos = Position.cumulativeOffset(this.element); var pos = this.element.cumulativeOffset();
this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) }); this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) });
Draggables.activate(this); Draggables.activate(this);
Event.stop(event); Event.stop(event);
} }
}, },
startDrag: function(event) { startDrag: function(event) {
this.dragging = true; this.dragging = true;
if(!this.delta) if(!this.delta)
this.delta = this.currentDelta(); this.delta = this.currentDelta();
if(this.options.zindex) { if(this.options.zindex) {
this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0); this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);
this.element.style.zIndex = this.options.zindex; this.element.style.zIndex = this.options.zindex;
} }
if(this.options.ghosting) { if(this.options.ghosting) {
this._clone = this.element.cloneNode(true); this._clone = this.element.cloneNode(true);
this.element._originallyAbsolute = (this.element.getStyle('position') == 'absolute'); this._originallyAbsolute = (this.element.getStyle('position') == 'absolute');
if (!this.element._originallyAbsolute) if (!this._originallyAbsolute)
Position.absolutize(this.element); Position.absolutize(this.element);
this.element.parentNode.insertBefore(this._clone, this.element); this.element.parentNode.insertBefore(this._clone, this.element);
} }
if(this.options.scroll) { if(this.options.scroll) {
if (this.options.scroll == window) { if (this.options.scroll == window) {
var where = this._getWindowScroll(this.options.scroll); var where = this._getWindowScroll(this.options.scroll);
@ -359,33 +348,33 @@ var Draggable = Class.create({
this.originalScrollTop = this.options.scroll.scrollTop; this.originalScrollTop = this.options.scroll.scrollTop;
} }
} }
Draggables.notify('onStart', this, event); Draggables.notify('onStart', this, event);
if(this.options.starteffect) this.options.starteffect(this.element); if(this.options.starteffect) this.options.starteffect(this.element);
}, },
updateDrag: function(event, pointer) { updateDrag: function(event, pointer) {
if(!this.dragging) this.startDrag(event); if(!this.dragging) this.startDrag(event);
if(!this.options.quiet){ if(!this.options.quiet){
Position.prepare(); Position.prepare();
Droppables.show(pointer, this.element); Droppables.show(pointer, this.element);
} }
Draggables.notify('onDrag', this, event); Draggables.notify('onDrag', this, event);
this.draw(pointer); this.draw(pointer);
if(this.options.change) this.options.change(this); if(this.options.change) this.options.change(this);
if(this.options.scroll) { if(this.options.scroll) {
this.stopScrolling(); this.stopScrolling();
var p; var p;
if (this.options.scroll == window) { if (this.options.scroll == window) {
with(this._getWindowScroll(this.options.scroll)) { p = [ left, top, left+width, top+height ]; } with(this._getWindowScroll(this.options.scroll)) { p = [ left, top, left+width, top+height ]; }
} else { } else {
p = Position.page(this.options.scroll); p = Position.page(this.options.scroll).toArray();
p[0] += this.options.scroll.scrollLeft + Position.deltaX; p[0] += this.options.scroll.scrollLeft + Position.deltaX;
p[1] += this.options.scroll.scrollTop + Position.deltaY; p[1] += this.options.scroll.scrollTop + Position.deltaY;
p.push(p[0]+this.options.scroll.offsetWidth); p.push(p[0]+this.options.scroll.offsetWidth);
@ -398,16 +387,16 @@ var Draggable = Class.create({
if(pointer[1] > (p[3]-this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[3]-this.options.scrollSensitivity); if(pointer[1] > (p[3]-this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[3]-this.options.scrollSensitivity);
this.startScrolling(speed); this.startScrolling(speed);
} }
// fix AppleWebKit rendering // fix AppleWebKit rendering
if(Prototype.Browser.WebKit) window.scrollBy(0,0); if(Prototype.Browser.WebKit) window.scrollBy(0,0);
Event.stop(event); Event.stop(event);
}, },
finishDrag: function(event, success) { finishDrag: function(event, success) {
this.dragging = false; this.dragging = false;
if(this.options.quiet){ if(this.options.quiet){
Position.prepare(); Position.prepare();
var pointer = [Event.pointerX(event), Event.pointerY(event)]; var pointer = [Event.pointerX(event), Event.pointerY(event)];
@ -415,24 +404,24 @@ var Draggable = Class.create({
} }
if(this.options.ghosting) { if(this.options.ghosting) {
if (!this.element._originallyAbsolute) if (!this._originallyAbsolute)
Position.relativize(this.element); Position.relativize(this.element);
delete this.element._originallyAbsolute; delete this._originallyAbsolute;
Element.remove(this._clone); Element.remove(this._clone);
this._clone = null; this._clone = null;
} }
var dropped = false; var dropped = false;
if(success) { if(success) {
dropped = Droppables.fire(event, this.element); dropped = Droppables.fire(event, this.element);
if (!dropped) dropped = false; if (!dropped) dropped = false;
} }
if(dropped && this.options.onDropped) this.options.onDropped(this.element); if(dropped && this.options.onDropped) this.options.onDropped(this.element);
Draggables.notify('onEnd', this, event); Draggables.notify('onEnd', this, event);
var revert = this.options.revert; var revert = this.options.revert;
if(revert && Object.isFunction(revert)) revert = revert(this.element); if(revert && Object.isFunction(revert)) revert = revert(this.element);
var d = this.currentDelta(); var d = this.currentDelta();
if(revert && this.options.reverteffect) { if(revert && this.options.reverteffect) {
if (dropped == 0 || revert != 'failure') if (dropped == 0 || revert != 'failure')
@ -445,67 +434,67 @@ var Draggable = Class.create({
if(this.options.zindex) if(this.options.zindex)
this.element.style.zIndex = this.originalZ; this.element.style.zIndex = this.originalZ;
if(this.options.endeffect) if(this.options.endeffect)
this.options.endeffect(this.element); this.options.endeffect(this.element);
Draggables.deactivate(this); Draggables.deactivate(this);
Droppables.reset(); Droppables.reset();
}, },
keyPress: function(event) { keyPress: function(event) {
if(event.keyCode!=Event.KEY_ESC) return; if(event.keyCode!=Event.KEY_ESC) return;
this.finishDrag(event, false); this.finishDrag(event, false);
Event.stop(event); Event.stop(event);
}, },
endDrag: function(event) { endDrag: function(event) {
if(!this.dragging) return; if(!this.dragging) return;
this.stopScrolling(); this.stopScrolling();
this.finishDrag(event, true); this.finishDrag(event, true);
Event.stop(event); Event.stop(event);
}, },
draw: function(point) { draw: function(point) {
var pos = Position.cumulativeOffset(this.element); var pos = this.element.cumulativeOffset();
if(this.options.ghosting) { if(this.options.ghosting) {
var r = Position.realOffset(this.element); var r = Position.realOffset(this.element);
pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY; pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY;
} }
var d = this.currentDelta(); var d = this.currentDelta();
pos[0] -= d[0]; pos[1] -= d[1]; pos[0] -= d[0]; pos[1] -= d[1];
if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) { if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) {
pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft; pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft;
pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop; pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop;
} }
var p = [0,1].map(function(i){ var p = [0,1].map(function(i){
return (point[i]-pos[i]-this.offset[i]) return (point[i]-pos[i]-this.offset[i])
}.bind(this)); }.bind(this));
if(this.options.snap) { if(this.options.snap) {
if(Object.isFunction(this.options.snap)) { if(Object.isFunction(this.options.snap)) {
p = this.options.snap(p[0],p[1],this); p = this.options.snap(p[0],p[1],this);
} else { } else {
if(Object.isArray(this.options.snap)) { if(Object.isArray(this.options.snap)) {
p = p.map( function(v, i) { p = p.map( function(v, i) {
return (v/this.options.snap[i]).round()*this.options.snap[i] }.bind(this)) return (v/this.options.snap[i]).round()*this.options.snap[i] }.bind(this));
} else { } else {
p = p.map( function(v) { p = p.map( function(v) {
return (v/this.options.snap).round()*this.options.snap }.bind(this)) return (v/this.options.snap).round()*this.options.snap }.bind(this));
} }
}} }}
var style = this.element.style; var style = this.element.style;
if((!this.options.constraint) || (this.options.constraint=='horizontal')) if((!this.options.constraint) || (this.options.constraint=='horizontal'))
style.left = p[0] + "px"; style.left = p[0] + "px";
if((!this.options.constraint) || (this.options.constraint=='vertical')) if((!this.options.constraint) || (this.options.constraint=='vertical'))
style.top = p[1] + "px"; style.top = p[1] + "px";
if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
}, },
stopScrolling: function() { stopScrolling: function() {
if(this.scrollInterval) { if(this.scrollInterval) {
clearInterval(this.scrollInterval); clearInterval(this.scrollInterval);
@ -513,14 +502,14 @@ var Draggable = Class.create({
Draggables._lastScrollPointer = null; Draggables._lastScrollPointer = null;
} }
}, },
startScrolling: function(speed) { startScrolling: function(speed) {
if(!(speed[0] || speed[1])) return; if(!(speed[0] || speed[1])) return;
this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed]; this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed];
this.lastScrolled = new Date(); this.lastScrolled = new Date();
this.scrollInterval = setInterval(this.scroll.bind(this), 10); this.scrollInterval = setInterval(this.scroll.bind(this), 10);
}, },
scroll: function() { scroll: function() {
var current = new Date(); var current = new Date();
var delta = current - this.lastScrolled; var delta = current - this.lastScrolled;
@ -536,7 +525,7 @@ var Draggable = Class.create({
this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000; this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000;
this.options.scroll.scrollTop += this.scrollSpeed[1] * delta / 1000; this.options.scroll.scrollTop += this.scrollSpeed[1] * delta / 1000;
} }
Position.prepare(); Position.prepare();
Droppables.show(Draggables._lastPointer, this.element); Droppables.show(Draggables._lastPointer, this.element);
Draggables.notify('onDrag', this); Draggables.notify('onDrag', this);
@ -550,10 +539,10 @@ var Draggable = Class.create({
Draggables._lastScrollPointer[1] = 0; Draggables._lastScrollPointer[1] = 0;
this.draw(Draggables._lastScrollPointer); this.draw(Draggables._lastScrollPointer);
} }
if(this.options.change) this.options.change(this); if(this.options.change) this.options.change(this);
}, },
_getWindowScroll: function(w) { _getWindowScroll: function(w) {
var T, L, W, H; var T, L, W, H;
with (w.document) { with (w.document) {
@ -572,7 +561,7 @@ var Draggable = Class.create({
H = documentElement.clientHeight; H = documentElement.clientHeight;
} else { } else {
W = body.offsetWidth; W = body.offsetWidth;
H = body.offsetHeight H = body.offsetHeight;
} }
} }
return { top: T, left: L, width: W, height: H }; return { top: T, left: L, width: W, height: H };
@ -589,11 +578,11 @@ var SortableObserver = Class.create({
this.observer = observer; this.observer = observer;
this.lastValue = Sortable.serialize(this.element); this.lastValue = Sortable.serialize(this.element);
}, },
onStart: function() { onStart: function() {
this.lastValue = Sortable.serialize(this.element); this.lastValue = Sortable.serialize(this.element);
}, },
onEnd: function() { onEnd: function() {
Sortable.unmark(); Sortable.unmark();
if(this.lastValue != Sortable.serialize(this.element)) if(this.lastValue != Sortable.serialize(this.element))
@ -603,11 +592,11 @@ var SortableObserver = Class.create({
var Sortable = { var Sortable = {
SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/, SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/,
sortables: { }, sortables: { },
_findRootElement: function(element) { _findRootElement: function(element) {
while (element.tagName.toUpperCase() != "BODY") { while (element.tagName.toUpperCase() != "BODY") {
if(element.id && Sortable.sortables[element.id]) return element; if(element.id && Sortable.sortables[element.id]) return element;
element = element.parentNode; element = element.parentNode;
} }
@ -618,22 +607,23 @@ var Sortable = {
if(!element) return; if(!element) return;
return Sortable.sortables[element.id]; return Sortable.sortables[element.id];
}, },
destroy: function(element){ destroy: function(element){
var s = Sortable.options(element); element = $(element);
var s = Sortable.sortables[element.id];
if(s) { if(s) {
Draggables.removeObserver(s.element); Draggables.removeObserver(s.element);
s.droppables.each(function(d){ Droppables.remove(d) }); s.droppables.each(function(d){ Droppables.remove(d) });
s.draggables.invoke('destroy'); s.draggables.invoke('destroy');
delete Sortable.sortables[s.element.id]; delete Sortable.sortables[s.element.id];
} }
}, },
create: function(element) { create: function(element) {
element = $(element); element = $(element);
var options = Object.extend({ var options = Object.extend({
element: element, element: element,
tag: 'li', // assumes li children, override with tag: 'tagname' tag: 'li', // assumes li children, override with tag: 'tagname'
dropOnEmpty: false, dropOnEmpty: false,
@ -647,17 +637,17 @@ var Sortable = {
delay: 0, delay: 0,
hoverclass: null, hoverclass: null,
ghosting: false, ghosting: false,
quiet: false, quiet: false,
scroll: false, scroll: false,
scrollSensitivity: 20, scrollSensitivity: 20,
scrollSpeed: 15, scrollSpeed: 15,
format: this.SERIALIZE_RULE, format: this.SERIALIZE_RULE,
// these take arrays of elements or ids and can be // these take arrays of elements or ids and can be
// used for better initialization performance // used for better initialization performance
elements: false, elements: false,
handles: false, handles: false,
onChange: Prototype.emptyFunction, onChange: Prototype.emptyFunction,
onUpdate: Prototype.emptyFunction onUpdate: Prototype.emptyFunction
}, arguments[1] || { }); }, arguments[1] || { });
@ -694,24 +684,24 @@ var Sortable = {
if(options.zindex) if(options.zindex)
options_for_draggable.zindex = options.zindex; options_for_draggable.zindex = options.zindex;
// build options for the droppables // build options for the droppables
var options_for_droppable = { var options_for_droppable = {
overlap: options.overlap, overlap: options.overlap,
containment: options.containment, containment: options.containment,
tree: options.tree, tree: options.tree,
hoverclass: options.hoverclass, hoverclass: options.hoverclass,
onHover: Sortable.onHover onHover: Sortable.onHover
} };
var options_for_tree = { var options_for_tree = {
onHover: Sortable.onEmptyHover, onHover: Sortable.onEmptyHover,
overlap: options.overlap, overlap: options.overlap,
containment: options.containment, containment: options.containment,
hoverclass: options.hoverclass hoverclass: options.hoverclass
} };
// fix for gecko engine // fix for gecko engine
Element.cleanWhitespace(element); Element.cleanWhitespace(element);
options.draggables = []; options.draggables = [];
options.droppables = []; options.droppables = [];
@ -724,14 +714,14 @@ var Sortable = {
(options.elements || this.findElements(element, options) || []).each( function(e,i) { (options.elements || this.findElements(element, options) || []).each( function(e,i) {
var handle = options.handles ? $(options.handles[i]) : var handle = options.handles ? $(options.handles[i]) :
(options.handle ? $(e).select('.' + options.handle)[0] : e); (options.handle ? $(e).select('.' + options.handle)[0] : e);
options.draggables.push( options.draggables.push(
new Draggable(e, Object.extend(options_for_draggable, { handle: handle }))); new Draggable(e, Object.extend(options_for_draggable, { handle: handle })));
Droppables.add(e, options_for_droppable); Droppables.add(e, options_for_droppable);
if(options.tree) e.treeNode = element; if(options.tree) e.treeNode = element;
options.droppables.push(e); options.droppables.push(e);
}); });
if(options.tree) { if(options.tree) {
(Sortable.findTreeElements(element, options) || []).each( function(e) { (Sortable.findTreeElements(element, options) || []).each( function(e) {
Droppables.add(e, options_for_tree); Droppables.add(e, options_for_tree);
@ -741,7 +731,7 @@ var Sortable = {
} }
// keep reference // keep reference
this.sortables[element.id] = options; this.sortables[element.identify()] = options;
// for onupdate // for onupdate
Draggables.addObserver(new SortableObserver(element, options.onUpdate)); Draggables.addObserver(new SortableObserver(element, options.onUpdate));
@ -753,7 +743,7 @@ var Sortable = {
return Element.findChildren( return Element.findChildren(
element, options.only, options.tree ? true : false, options.tag); element, options.only, options.tree ? true : false, options.tag);
}, },
findTreeElements: function(element, options) { findTreeElements: function(element, options) {
return Element.findChildren( return Element.findChildren(
element, options.only, options.tree ? true : false, options.treeTag); element, options.only, options.tree ? true : false, options.treeTag);
@ -770,7 +760,7 @@ var Sortable = {
var oldParentNode = element.parentNode; var oldParentNode = element.parentNode;
element.style.visibility = "hidden"; // fix gecko rendering element.style.visibility = "hidden"; // fix gecko rendering
dropon.parentNode.insertBefore(element, dropon); dropon.parentNode.insertBefore(element, dropon);
if(dropon.parentNode!=oldParentNode) if(dropon.parentNode!=oldParentNode)
Sortable.options(oldParentNode).onChange(element); Sortable.options(oldParentNode).onChange(element);
Sortable.options(dropon.parentNode).onChange(element); Sortable.options(dropon.parentNode).onChange(element);
} }
@ -781,26 +771,26 @@ var Sortable = {
var oldParentNode = element.parentNode; var oldParentNode = element.parentNode;
element.style.visibility = "hidden"; // fix gecko rendering element.style.visibility = "hidden"; // fix gecko rendering
dropon.parentNode.insertBefore(element, nextElement); dropon.parentNode.insertBefore(element, nextElement);
if(dropon.parentNode!=oldParentNode) if(dropon.parentNode!=oldParentNode)
Sortable.options(oldParentNode).onChange(element); Sortable.options(oldParentNode).onChange(element);
Sortable.options(dropon.parentNode).onChange(element); Sortable.options(dropon.parentNode).onChange(element);
} }
} }
}, },
onEmptyHover: function(element, dropon, overlap) { onEmptyHover: function(element, dropon, overlap) {
var oldParentNode = element.parentNode; var oldParentNode = element.parentNode;
var droponOptions = Sortable.options(dropon); var droponOptions = Sortable.options(dropon);
if(!Element.isParent(dropon, element)) { if(!Element.isParent(dropon, element)) {
var index; var index;
var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only: droponOptions.only}); var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only: droponOptions.only});
var child = null; var child = null;
if(children) { if(children) {
var offset = Element.offsetSize(dropon, droponOptions.overlap) * (1.0 - overlap); var offset = Element.offsetSize(dropon, droponOptions.overlap) * (1.0 - overlap);
for (index = 0; index < children.length; index += 1) { for (index = 0; index < children.length; index += 1) {
if (offset - Element.offsetSize (children[index], droponOptions.overlap) >= 0) { if (offset - Element.offsetSize (children[index], droponOptions.overlap) >= 0) {
offset -= Element.offsetSize (children[index], droponOptions.overlap); offset -= Element.offsetSize (children[index], droponOptions.overlap);
@ -813,9 +803,9 @@ var Sortable = {
} }
} }
} }
dropon.insertBefore(element, child); dropon.insertBefore(element, child);
Sortable.options(oldParentNode).onChange(element); Sortable.options(oldParentNode).onChange(element);
droponOptions.onChange(element); droponOptions.onChange(element);
} }
@ -828,34 +818,34 @@ var Sortable = {
mark: function(dropon, position) { mark: function(dropon, position) {
// mark on ghosting only // mark on ghosting only
var sortable = Sortable.options(dropon.parentNode); var sortable = Sortable.options(dropon.parentNode);
if(sortable && !sortable.ghosting) return; if(sortable && !sortable.ghosting) return;
if(!Sortable._marker) { if(!Sortable._marker) {
Sortable._marker = Sortable._marker =
($('dropmarker') || Element.extend(document.createElement('DIV'))). ($('dropmarker') || Element.extend(document.createElement('DIV'))).
hide().addClassName('dropmarker').setStyle({position:'absolute'}); hide().addClassName('dropmarker').setStyle({position:'absolute'});
document.getElementsByTagName("body").item(0).appendChild(Sortable._marker); document.getElementsByTagName("body").item(0).appendChild(Sortable._marker);
} }
var offsets = Position.cumulativeOffset(dropon); var offsets = dropon.cumulativeOffset();
Sortable._marker.setStyle({left: offsets[0]+'px', top: offsets[1] + 'px'}); Sortable._marker.setStyle({left: offsets[0]+'px', top: offsets[1] + 'px'});
if(position=='after') if(position=='after')
if(sortable.overlap == 'horizontal') if(sortable.overlap == 'horizontal')
Sortable._marker.setStyle({left: (offsets[0]+dropon.clientWidth) + 'px'}); Sortable._marker.setStyle({left: (offsets[0]+dropon.clientWidth) + 'px'});
else else
Sortable._marker.setStyle({top: (offsets[1]+dropon.clientHeight) + 'px'}); Sortable._marker.setStyle({top: (offsets[1]+dropon.clientHeight) + 'px'});
Sortable._marker.show(); Sortable._marker.show();
}, },
_tree: function(element, options, parent) { _tree: function(element, options, parent) {
var children = Sortable.findElements(element, options) || []; var children = Sortable.findElements(element, options) || [];
for (var i = 0; i < children.length; ++i) { for (var i = 0; i < children.length; ++i) {
var match = children[i].id.match(options.format); var match = children[i].id.match(options.format);
if (!match) continue; if (!match) continue;
var child = { var child = {
id: encodeURIComponent(match ? match[1] : null), id: encodeURIComponent(match ? match[1] : null),
element: element, element: element,
@ -863,16 +853,16 @@ var Sortable = {
children: [], children: [],
position: parent.children.length, position: parent.children.length,
container: $(children[i]).down(options.treeTag) container: $(children[i]).down(options.treeTag)
} };
/* Get the element containing the children and recurse over it */ /* Get the element containing the children and recurse over it */
if (child.container) if (child.container)
this._tree(child.container, options, child) this._tree(child.container, options, child);
parent.children.push (child); parent.children.push (child);
} }
return parent; return parent;
}, },
tree: function(element) { tree: function(element) {
@ -885,15 +875,15 @@ var Sortable = {
name: element.id, name: element.id,
format: sortableOptions.format format: sortableOptions.format
}, arguments[1] || { }); }, arguments[1] || { });
var root = { var root = {
id: null, id: null,
parent: null, parent: null,
children: [], children: [],
container: element, container: element,
position: 0 position: 0
} };
return Sortable._tree(element, options, root); return Sortable._tree(element, options, root);
}, },
@ -909,7 +899,7 @@ var Sortable = {
sequence: function(element) { sequence: function(element) {
element = $(element); element = $(element);
var options = Object.extend(this.options(element), arguments[1] || { }); var options = Object.extend(this.options(element), arguments[1] || { });
return $(this.findElements(element, options) || []).map( function(item) { return $(this.findElements(element, options) || []).map( function(item) {
return item.id.match(options.format) ? item.id.match(options.format)[1] : ''; return item.id.match(options.format) ? item.id.match(options.format)[1] : '';
}); });
@ -918,14 +908,14 @@ var Sortable = {
setSequence: function(element, new_sequence) { setSequence: function(element, new_sequence) {
element = $(element); element = $(element);
var options = Object.extend(this.options(element), arguments[2] || { }); var options = Object.extend(this.options(element), arguments[2] || { });
var nodeMap = { }; var nodeMap = { };
this.findElements(element, options).each( function(n) { this.findElements(element, options).each( function(n) {
if (n.id.match(options.format)) if (n.id.match(options.format))
nodeMap[n.id.match(options.format)[1]] = [n, n.parentNode]; nodeMap[n.id.match(options.format)[1]] = [n, n.parentNode];
n.parentNode.removeChild(n); n.parentNode.removeChild(n);
}); });
new_sequence.each(function(ident) { new_sequence.each(function(ident) {
var n = nodeMap[ident]; var n = nodeMap[ident];
if (n) { if (n) {
@ -934,16 +924,16 @@ var Sortable = {
} }
}); });
}, },
serialize: function(element) { serialize: function(element) {
element = $(element); element = $(element);
var options = Object.extend(Sortable.options(element), arguments[1] || { }); var options = Object.extend(Sortable.options(element), arguments[1] || { });
var name = encodeURIComponent( var name = encodeURIComponent(
(arguments[1] && arguments[1].name) ? arguments[1].name : element.id); (arguments[1] && arguments[1].name) ? arguments[1].name : element.id);
if (options.tree) { if (options.tree) {
return Sortable.tree(element, arguments[1]).children.map( function (item) { return Sortable.tree(element, arguments[1]).children.map( function (item) {
return [name + Sortable._constructIndex(item) + "[id]=" + return [name + Sortable._constructIndex(item) + "[id]=" +
encodeURIComponent(item.id)].concat(item.children.map(arguments.callee)); encodeURIComponent(item.id)].concat(item.children.map(arguments.callee));
}).flatten().join('&'); }).flatten().join('&');
} else { } else {
@ -952,16 +942,16 @@ var Sortable = {
}).join('&'); }).join('&');
} }
} }
} };
// Returns true if child is contained within element // Returns true if child is contained within element
Element.isParent = function(child, element) { Element.isParent = function(child, element) {
if (!child.parentNode || child == element) return false; if (!child.parentNode || child == element) return false;
if (child.parentNode == element) return true; if (child.parentNode == element) return true;
return Element.isParent(child.parentNode, element); return Element.isParent(child.parentNode, element);
} };
Element.findChildren = function(element, only, recursive, tagName) { Element.findChildren = function(element, only, recursive, tagName) {
if(!element.hasChildNodes()) return null; if(!element.hasChildNodes()) return null;
tagName = tagName.toUpperCase(); tagName = tagName.toUpperCase();
if(only) only = [only].flatten(); if(only) only = [only].flatten();
@ -977,8 +967,8 @@ Element.findChildren = function(element, only, recursive, tagName) {
}); });
return (elements.length>0 ? elements.flatten() : []); return (elements.length>0 ? elements.flatten() : []);
} };
Element.offsetSize = function (element, type) { Element.offsetSize = function (element, type) {
return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')]; return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')];
} };

4
html/js/effects.js vendored
View file

@ -1,6 +1,6 @@
// script.aculo.us effects.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009 // script.aculo.us effects.js v1.9.0, Thu Dec 23 16:54:48 -0500 2010
// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // Copyright (c) 2005-2010 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// Contributors: // Contributors:
// Justin Palmer (http://encytemedia.com/) // Justin Palmer (http://encytemedia.com/)
// Mark Pilgrim (http://diveintomark.org/) // Mark Pilgrim (http://diveintomark.org/)

View file

@ -31,7 +31,7 @@ function detail_extension(p_code)
{ {
var dossier=$("gDossier").value; var dossier=$("gDossier").value;
showIPopup("dtext"); showIPopup("dtext");
var queryString='?gDossier='+dossier; var queryString='gDossier='+dossier;
queryString+='&ex_id='+p_code; queryString+='&ex_id='+p_code;
queryString+='&action=de'; // de for detail extension queryString+='&action=de'; // de for detail extension
@ -51,7 +51,7 @@ function new_extension()
{ {
var dossier=$("gDossier").value; var dossier=$("gDossier").value;
showIPopup("dtext"); showIPopup("dtext");
var queryString='?gDossier='+dossier; var queryString='gDossier='+dossier;
queryString+='&action=ne'; // ne for new extension queryString+='&action=ne'; // ne for new extension
var action=new Ajax.Request ( 'ajax_extension.php', var action=new Ajax.Request ( 'ajax_extension.php',
@ -106,7 +106,7 @@ function extension_save(p_obj_form)
try try
{ {
var dossier=$("gDossier").value; var dossier=$("gDossier").value;
var queryString='?gDossier='+dossier; var queryString='gDossier='+dossier;
queryString+='&action=se'; // se save extension queryString+='&action=se'; // se save extension
// Data must be taken here // Data must be taken here
try try
@ -171,7 +171,7 @@ function successSave(req)
function extension_remove(ex_id) function extension_remove(ex_id)
{ {
var dossier=$("gDossier").value; var dossier=$("gDossier").value;
var queryString='?gDossier='+dossier; var queryString='gDossier='+dossier;
queryString+='&ex_id='+ex_id; queryString+='&ex_id='+ex_id;
queryString+='&action=re'; // re for remove extension queryString+='&action=re'; // re for remove extension
var action=new Ajax.Request ( 'ajax_extension.php', var action=new Ajax.Request ( 'ajax_extension.php',

View file

@ -33,7 +33,7 @@
*/ */
function remove_document(p_dossier,p_id) function remove_document(p_dossier,p_id)
{ {
queryString="?gDossier="+p_dossier+"&a=rm&d_id="+p_id; queryString="gDossier="+p_dossier+"&a=rm&d_id="+p_id;
var action=new Ajax.Request ( var action=new Ajax.Request (
"show_document.php", "show_document.php",
{ {
@ -98,7 +98,7 @@ function removeStock(s_id,p_dossier)
{ {
return; return;
} }
queryString="?gDossier="+p_dossier+"&op=rm_stock&s_id="+s_id; queryString="gDossier="+p_dossier+"&op=rm_stock&s_id="+s_id;
var action=new Ajax.Request ( var action=new Ajax.Request (
"ajax_misc.php", "ajax_misc.php",
{ {
@ -133,7 +133,7 @@ function successRemoveStock(request,json)
$(doc).style.color="red"; $(doc).style.color="red";
// $(doc).href="javascript:alert('Stock Effacé')"; // $(doc).href="javascript:alert('Stock Effacé')";
$(doc).style.textDecoration="line-through"; $(doc).style.textDecoration="line-through";
} catch (e) } catch (e)
{ {
alert("success_box"+e.message); alert("success_box"+e.message);
} }

View file

@ -15,7 +15,7 @@ function modifyModeleDocument(p_value,dossier)
'style':style 'style':style
}; };
querystring='?gDossier='+dossier+'&op=mod_doc&id='+p_value+'&div=mod_doc'; querystring='gDossier='+dossier+'&op=mod_doc&id='+p_value+'&div=mod_doc';
if ( ! $('mod_doc')) if ( ! $('mod_doc'))
{ {
add_div(popup); add_div(popup);
@ -32,7 +32,7 @@ function modifyModeleDocument(p_value,dossier)
} }
/** /**
*@brief receive answer from ajax and just display it into the IBox *@brief receive answer from ajax and just display it into the IBox
* XML must contains at least 2 fields : code is the ID of the IBOX and * XML must contains at least 2 fields : code is the ID of the IBOX and
* html which is the contain * html which is the contain
*/ */
function modify_document_success_box(req,json) function modify_document_success_box(req,json)

3649
html/js/prototype.js vendored

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
// script.aculo.us scriptaculous.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009 // script.aculo.us scriptaculous.js v1.9.0, Thu Dec 23 16:54:48 -0500 2010
// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // Copyright (c) 2005-2010 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// //
// Permission is hereby granted, free of charge, to any person obtaining // Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the // a copy of this software and associated documentation files (the
@ -24,7 +24,7 @@
// For details, see the script.aculo.us web site: http://script.aculo.us/ // For details, see the script.aculo.us web site: http://script.aculo.us/
var Scriptaculous = { var Scriptaculous = {
Version: '1.8.3', Version: '1.9.0',
require: function(libraryName) { require: function(libraryName) {
try{ try{
// inserting via DOM fails in Safari 2.0, so brute force approach // inserting via DOM fails in Safari 2.0, so brute force approach
@ -37,7 +37,7 @@ var Scriptaculous = {
document.getElementsByTagName('head')[0].appendChild(script); document.getElementsByTagName('head')[0].appendChild(script);
} }
}, },
REQUIRED_PROTOTYPE: '1.6.1', REQUIRED_PROTOTYPE: '1.6.0.3',
load: function() { load: function() {
function convertVersionString(versionString) { function convertVersionString(versionString) {
var v = versionString.replace(/_.*|\./g, ''); var v = versionString.replace(/_.*|\./g, '');
@ -54,7 +54,7 @@ var Scriptaculous = {
Scriptaculous.REQUIRED_PROTOTYPE); Scriptaculous.REQUIRED_PROTOTYPE);
var js = /scriptaculous\.js(\?.*)?$/; var js = /scriptaculous\.js(\?.*)?$/;
$$('head script[src]').findAll(function(s) { $$('script[src]').findAll(function(s) {
return s.src.match(js); return s.src.match(js);
}).each(function(s) { }).each(function(s) {
var path = s.src.replace(js, ''), var path = s.src.replace(js, ''),
@ -65,4 +65,4 @@ var Scriptaculous = {
} }
}; };
Scriptaculous.load(); Scriptaculous.load();

View file

@ -24,7 +24,7 @@
* *
*/ */
/** /**
* callback function when we just need to update a hidden div with an info * callback function when we just need to update a hidden div with an info
* message * message
*/ */
function infodiv(req,json) function infodiv(req,json)
@ -378,13 +378,13 @@ function change_month(obj)
} }
/** /**
*@brief basic answer to ajax on success, it will fill the DOMID code with *@brief basic answer to ajax on success, it will fill the DOMID code with
* the code. In that case, you need to create the object before the Ajax.Request * the code. In that case, you need to create the object before the Ajax.Request
*The difference with success box is that *The difference with success box is that
*@see add_div removeDiv success_box is that the width and height are not changed ajax_misc.php *@see add_div removeDiv success_box is that the width and height are not changed ajax_misc.php
*@parameter code is the ID of the object containing the html (div, button...) *@parameter code is the ID of the object containing the html (div, button...)
*@parameter value is the html code, with it you fill the ctl element *@parameter value is the html code, with it you fill the ctl element
*/ */
function success_misc(req) function success_misc(req)
{ {
@ -466,7 +466,7 @@ function success_cat_doc_remove(req)
} }
/** /**
*@brief display the popup with vat and explanation *@brief display the popup with vat and explanation
*@param obj with 4 attributes gdossier, ctl,popup *@param obj with 4 attributes gdossier, ctl,popup
*/ */
function popup_select_tva(obj) function popup_select_tva(obj)
{ {
@ -533,7 +533,7 @@ function success_popup_select_tva(req)
/** /**
*@brief display the popup with vat and explanation *@brief display the popup with vat and explanation
*@param obj with 4 attributes gdossier, ctl,popup *@param obj with 4 attributes gdossier, ctl,popup
*/ */
function set_tva_label(obj) function set_tva_label(obj)
{ {
@ -595,7 +595,7 @@ function set_wait(name)
} }
/** /**
*@brief add dynamically a object for AJAX *@brief add dynamically a object for AJAX
*@param obj. *@param obj.
* the attributes are * the attributes are
* - style to add style * - style to add style
* - id to add an id * - id to add an id
@ -650,7 +650,7 @@ new Draggable(obj.id,{starteffect:function()
} }
/** /**
* remove a object created with add_div * remove a object created with add_div
* @param elt id of the elt * @param elt id of the elt
*/ */
function removeDiv(elt) function removeDiv(elt)
{ {
@ -704,7 +704,7 @@ function show_box(obj)
} }
/** /**
*@brief receive answer from ajax and just display it into the IBox *@brief receive answer from ajax and just display it into the IBox
* XML must contains at least 2 fields : ctl is the ID of the IBOX and * XML must contains at least 2 fields : ctl is the ID of the IBOX and
* code is the HTML to put in it * code is the HTML to put in it
*@see fill_box *@see fill_box
*/ */
@ -913,7 +913,7 @@ function display_periode(p_dossier,p_id)
{ {
alert("display_periode "+e.message); alert("display_periode "+e.message);
} }
} }
function success_display_periode(req) function success_display_periode(req)
{ try { try
@ -951,7 +951,7 @@ function save_periode(obj)
{ {
try try
{ {
var queryString="?"+$(obj).serialize()+"&op=save_per"; var queryString=$(obj).serialize()+"&op=save_per";
var action = new Ajax.Request( var action = new Ajax.Request(
"ajax_misc.php" , "ajax_misc.php" ,
@ -971,13 +971,13 @@ function save_periode(obj)
return false; return false;
} }
/** /**
*@brief basic answer to ajax on success, it will fill the ctl with *@brief basic answer to ajax on success, it will fill the ctl with
* the code. In that case, you need to create the object before the Ajax.Request * the code. In that case, you need to create the object before the Ajax.Request
*The difference with success box is that *The difference with success box is that
*@see add_div removeDiv success_box is that the width and height are not changed *@see add_div removeDiv success_box is that the width and height are not changed
*@parameter ctl is the ID of the object containing the html (div, button...) *@parameter ctl is the ID of the object containing the html (div, button...)
*@parameter code is the html code, with it you fill the ctl element *@parameter code is the html code, with it you fill the ctl element
*/ */
function fill_box(req) function fill_box(req)
{ {
try{ try{
@ -989,7 +989,7 @@ function fill_box(req)
var code_html=getNodeText(html[0]); // Firefox ne prend que les 4096 car. var code_html=getNodeText(html[0]); // Firefox ne prend que les 4096 car.
code_html=unescape_xml(code_html); code_html=unescape_xml(code_html);
$(name_ctl).innerHTML=code_html; $(name_ctl).innerHTML=code_html;
} }
catch (e) { catch (e) {
alert(e.message);} alert(e.message);}
try{ try{
@ -1001,13 +1001,13 @@ function fill_box(req)
} }
/** /**
*display a popin to let you modified a predefined operation *display a popin to let you modified a predefined operation
*@param dossier_id *@param dossier_id
*@param od_id from table op_predef *@param od_id from table op_predef
*/ */
function mod_predf_op(dossier_id,od_id) function mod_predf_op(dossier_id,od_id)
{ {
var target="mod_predf_op"; var target="mod_predf_op";
if ( $(target)) if ( $(target))
{ {
removeDiv(target); removeDiv(target);
} }
@ -1016,11 +1016,11 @@ function mod_predf_op(dossier_id,od_id)
var str_style="top:"+sx+";left:"+sy; var str_style="top:"+sx+";left:"+sy;
var div={id:target, cssclass:'op_detail',style:str_style,html:loading(),drag:1}; var div={id:target, cssclass:'op_detail',style:str_style,html:loading(),drag:1};
add_div(div); add_div(div);
var qs="?gDossier="+dossier_id+'&op=mod_predf&id='+od_id; var qs="gDossier="+dossier_id+'&op=mod_predf&id='+od_id;
var action=new Ajax.Request ( 'ajax_misc.php', var action=new Ajax.Request ( 'ajax_misc.php',
{ {
method:'get', method:'get',
@ -1034,7 +1034,7 @@ function mod_predf_op(dossier_id,od_id)
function save_predf_op(obj) function save_predf_op(obj)
{ {
var querystring="?"+$(obj).serialize()+'&op=save_predf'; var querystring=$(obj).serialize()+'&op=save_predf';
// Create a ajax request to get all the person // Create a ajax request to get all the person
var action = new Ajax.Request ('ajax_misc.php', var action = new Ajax.Request ('ajax_misc.php',
{ {
@ -1045,5 +1045,5 @@ function save_predf_op(obj)
} }
); );
return false; return false;
} }

View file

@ -1,6 +1,6 @@
// script.aculo.us slider.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009 // script.aculo.us slider.js v1.9.0, Thu Dec 23 16:54:48 -0500 2010
// Copyright (c) 2005-2009 Marty Haught, Thomas Fuchs // Copyright (c) 2005-2010 Marty Haught, Thomas Fuchs
// //
// script.aculo.us is freely distributable under the terms of an MIT-style license. // script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/ // For details, see the script.aculo.us web site: http://script.aculo.us/

View file

@ -1,6 +1,6 @@
// script.aculo.us sound.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009 // script.aculo.us sound.js v1.9.0, Thu Dec 23 16:54:48 -0500 2010
// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // Copyright (c) 2005-2010 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// //
// Based on code created by Jules Gravinese (http://www.webveteran.com/) // Based on code created by Jules Gravinese (http://www.webveteran.com/)
// //

View file

@ -1,8 +1,8 @@
// script.aculo.us unittest.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009 // script.aculo.us unittest.js v1.9.0, Thu Dec 23 16:54:48 -0500 2010
// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // Copyright (c) 2005-2010 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// (c) 2005-2009 Jon Tirsen (http://www.tirsen.com) // (c) 2005-2010 Jon Tirsen (http://www.tirsen.com)
// (c) 2005-2009 Michael Schuerig (http://www.schuerig.de/michael/) // (c) 2005-2010 Michael Schuerig (http://www.schuerig.de/michael/)
// //
// script.aculo.us is freely distributable under the terms of an MIT-style license. // script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/ // For details, see the script.aculo.us web site: http://script.aculo.us/

View file

@ -41,8 +41,8 @@
* *
* Set the hidden field or input field to be set by javascript with the function set_attribute * Set the hidden field or input field to be set by javascript with the function set_attribute
* call the input method. After selecting a value the update_value function is called. If you need * call the input method. After selecting a value the update_value function is called. If you need
* to modify the queryString before the request is sent, you'll use the set_callback; the first * to modify the queryString before the request is sent, you'll use the set_callback; the first
* parameter is the INPUT field and the second the queryString, the function must returns a * parameter is the INPUT field and the second the queryString, the function must returns a
* queryString * queryString
*\code *\code
// insert all the javascript files // insert all the javascript files
@ -50,8 +50,8 @@
echo js_include('scriptaculous.js'); echo js_include('scriptaculous.js');
echo js_include('effects.js'); echo js_include('effects.js');
echo js_include('controls.js'); echo js_include('controls.js');
// //
$W1=new ICard(); $W1=new ICard();
$W1->label="Client ".HtmlInput::infobulle(0) ; $W1->label="Client ".HtmlInput::infobulle(0) ;
$W1->name="e_client"; $W1->name="e_client";
@ -60,18 +60,18 @@
$W1->table=0; $W1->table=0;
// If double click call the javascript fill_ipopcard // If double click call the javascript fill_ipopcard
$W1->set_dblclick("fill_ipopcard(this);"); $W1->set_dblclick("fill_ipopcard(this);");
// Type of card : deb, cred or all // Type of card : deb, cred or all
$W1->set_attribute('typecard','deb'); $W1->set_attribute('typecard','deb');
$W1->extra='deb'; $W1->extra='deb';
// Add the callback function to filter the card on the jrn // Add the callback function to filter the card on the jrn
$W1->set_callback('filter_card'); $W1->set_callback('filter_card');
// when value selected in the autcomplete // when value selected in the autcomplete
$W1->set_function('fill_data'); $W1->set_function('fill_data');
// when the data change // when the data change
$W1->javascript=sprintf(' onchange="fill_data_onchange(\'%s\');" ', $W1->javascript=sprintf(' onchange="fill_data_onchange(\'%s\');" ',
$W1->name); $W1->name);
@ -83,9 +83,9 @@
$f_client=$client_label->input("e_client_label",$e_client_label); $f_client=$client_label->input("e_client_label",$e_client_label);
$f_client_qcode=$W1->input(); $f_client_qcode=$W1->input();
// Search button for card // Search button for card
$f_client_bt=$W1->search(); $f_client_bt=$W1->search();
* \endcode * \endcode
For searching a card, you need a popup, the script card.js and set For searching a card, you need a popup, the script card.js and set
the values for card, popup filter_card callback the values for card, popup filter_card callback
@ -95,10 +95,10 @@ $card->name="acc";
$card->extra="all"; $card->extra="all";
$card->set_attribute('typecard','all'); $card->set_attribute('typecard','all');
$card->set_callback('filter_card'); $card->set_callback('filter_card');
echo $card->input(); echo $card->input();
echo $card->search(); echo $card->search();
// example 2 // example 2
$w=new ICard("av_text".$attr->ad_id); $w=new ICard("av_text".$attr->ad_id);
// filter on frd_id // filter on frd_id
$sql=' select fd_id from fiche_def where frd_id in ('.FICHE_TYPE_CLIENT.','.FICHE_TYPE_FOURNISSEUR.','.FICHE_TYPE_ADM_TAX.')'; $sql=' select fd_id from fiche_def where frd_id in ('.FICHE_TYPE_CLIENT.','.FICHE_TYPE_FOURNISSEUR.','.FICHE_TYPE_ADM_TAX.')';
@ -107,7 +107,7 @@ $w->set_attribute('ipopup','ipopcard');
$w->set_attribute('typecard',$filter); $w->set_attribute('typecard',$filter);
$w->set_attribute('inp',"av_text".$attr->ad_id); $w->set_attribute('inp',"av_text".$attr->ad_id);
$w->set_attribute('label',"av_text".$attr->ad_id."_label"); $w->set_attribute('label',"av_text".$attr->ad_id."_label");
$w->extra=$filter; $w->extra=$filter;
$w->extra2=0; $w->extra2=0;
$label=new ISpan(); $label=new ISpan();
@ -129,8 +129,8 @@ class ICard extends HtmlInput
$this->javascript=''; $this->javascript='';
} }
/*!\brief set the javascript callback function /*!\brief set the javascript callback function
* by default it is update_value called BEFORE the querystring is send * by default it is update_value called BEFORE the querystring is send
* *
*\param $p_name callback function name *\param $p_name callback function name
*/ */
function set_callback($p_name) function set_callback($p_name)
@ -214,7 +214,7 @@ class ICard extends HtmlInput
'</span>', '</span>',
$this->name); $this->name);
$div=sprintf('<div id="%s_choices" class="autocomplete"></div>', $div=sprintf('<div id="%s_choices" class="autocomplete"></div>',
$this->name); $this->name);
$query=dossier::get().'&e='.urlencode($this->typecard); $query=dossier::get().'&e='.urlencode($this->typecard);
@ -249,7 +249,7 @@ class ICard extends HtmlInput
/** /**
*@brief return a string containing the button for displaying *@brief return a string containing the button for displaying
* a search form. When clicking on the result, update the input text file * a search form. When clicking on the result, update the input text file
* the common used attribute as * the common used attribute as
* - jrn the ledger * - jrn the ledger
* - label the field to update * - label the field to update
* - name name of the input text * - name name of the input text
@ -346,7 +346,7 @@ class ICard extends HtmlInput
ajaxFid(text); ajaxFid(text);
} }
</script> </script>
EOF; EOF;
echo "<form>"; echo "<form>";
$l=new IText('ctl_label'); $l=new IText('ctl_label');