diff options
Diffstat (limited to 'framework/Web/Javascripts')
-rw-r--r-- | framework/Web/Javascripts/TJavaScript.php | 12 | ||||
-rw-r--r-- | framework/Web/Javascripts/datepicker/datepicker.js | 230 | ||||
-rw-r--r-- | framework/Web/Javascripts/effects/controls.js | 10 | ||||
-rw-r--r-- | framework/Web/Javascripts/effects/dragdrop.js | 34 | ||||
-rw-r--r-- | framework/Web/Javascripts/effects/effects.js | 59 | ||||
-rw-r--r-- | framework/Web/Javascripts/effects/slider.js | 21 | ||||
-rw-r--r-- | framework/Web/Javascripts/prado/ajax.js | 92 |
7 files changed, 246 insertions, 212 deletions
diff --git a/framework/Web/Javascripts/TJavaScript.php b/framework/Web/Javascripts/TJavaScript.php index 75fc2438..aa5b88de 100644 --- a/framework/Web/Javascripts/TJavaScript.php +++ b/framework/Web/Javascripts/TJavaScript.php @@ -84,7 +84,7 @@ class TJavaScript else
return strtr($js,array("\t"=>'\t',"\n"=>'\n',"\r"=>'\r','"'=>'\"','\''=>'\\\'','\\'=>'\\\\'));
}
-
+
/**
* @return string considers the string as raw javascript function code
*/
@@ -93,16 +93,16 @@ class TJavaScript if(self::isFunction($js))
return $js;
else
- return 'javascript:'.$js;
+ return 'javascript:'.$js;
}
-
+
/**
* @return boolean true if string is raw javascript function code, i.e., if
* the string begins with <tt>javascript:</tt>
*/
public static function isFunction($js)
{
- return preg_match('/^\s*javascript:/', $js);
+ return preg_match('/^\s*javascript:/i', $js);
}
/**
@@ -119,9 +119,9 @@ class TJavaScript *
* For higher complexity data structures use {@link jsonEncode} and {@link jsonDecode}
* to serialize and unserialize.
- *
+ *
* Note: strings begining with <tt>javascript:</tt> will be considered as
- * raw javascript code and no encoding of that string will be enforced.
+ * raw javascript code and no encoding of that string will be enforced.
*
* @param mixed PHP variable to be encoded
* @param boolean whether the output is a map or a list.
diff --git a/framework/Web/Javascripts/datepicker/datepicker.js b/framework/Web/Javascripts/datepicker/datepicker.js index 4525c1ba..5fff5f0f 100644 --- a/framework/Web/Javascripts/datepicker/datepicker.js +++ b/framework/Web/Javascripts/datepicker/datepicker.js @@ -10,41 +10,41 @@ Object.extend(Prado.WebUI.TDatePicker, var year=now.getFullYear();
var month=now.getMonth();
var day=1;
-
+
var month_list = this.getMonthListControl(control);
var day_list = this.getDayListControl(control);
var year_list = this.getYearListControl(control);
-
+
var day = day_list ? $F(day_list) : 1;
var month = month_list ? $F(month_list) : now.getMonth();
var year = year_list ? $F(year_list) : now.getFullYear();
-
+
return new Date(year,month,day, 0, 0, 0);
},
-
+
getYearListControl : function(control)
{
return $(control.id+"_year");
},
-
+
getMonthListControl : function(control)
{
return $(control.id+"_month");
},
-
+
getDayListControl : function(control)
{
return $(control.id+"_day");
}
});
-Prado.WebUI.TDatePicker.prototype =
+Prado.WebUI.TDatePicker.prototype =
{
MonthNames : [ "January", "February", "March", "April",
"May", "June", "July", "August",
"September", "October", "November", "December"
],
- AbbreviatedMonthNames : ["Jan", "Feb", "Mar", "Apr", "May",
+ AbbreviatedMonthNames : ["Jan", "Feb", "Mar", "Apr", "May",
"Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
ShortWeekDayNames : ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ],
@@ -52,20 +52,20 @@ Prado.WebUI.TDatePicker.prototype = Format : "yyyy-MM-dd",
FirstDayOfWeek : 1, // 0 for sunday
-
+
ClassName : "TDatePicker",
FromYear : 2000, UpToYear: 2015,
-
+
initialize : function(options)
{
this.options = options || [];
- this.control = $(options.ID);
+ this.control = $(options.ID);
this.dateSlot = new Array(42);
this.weekSlot = new Array(6);
this.minimalDaysInFirstWeek = 4;
this.selectedDate = this.newDate();
-
+
//which element to trigger to show the calendar
if(this.options.Trigger)
{
@@ -77,45 +77,45 @@ Prado.WebUI.TDatePicker.prototype = this.trigger = this.control;
var triggerEvent = this.options.TriggerEvent || "focus";
}
-
+
Object.extend(this,options);
-
+
Event.observe(this.trigger, triggerEvent, this.show.bindEvent(this));
-
+
},
create : function()
{
if(typeof(this._calDiv) != "undefined")
return;
-
+
var div;
var table;
var tbody;
var tr;
var td;
-
+
// Create the top-level div element
this._calDiv = document.createElement("div");
this._calDiv.className = this.ClassName;
- this._calDiv.style.display = "none";
+ this._calDiv.style.display = "none";
this._calDiv.style.position = "absolute"
-
+
// header div
div = document.createElement("div");
div.className = "calendarHeader";
this._calDiv.appendChild(div);
-
+
table = document.createElement("table");
table.style.cellSpacing = 0;
div.appendChild(table);
-
+
tbody = document.createElement("tbody");
table.appendChild(tbody);
-
+
tr = document.createElement("tr");
tbody.appendChild(tr);
-
+
// Previous Month Button
td = document.createElement("td");
var previousMonth = document.createElement("input");
@@ -124,11 +124,11 @@ Prado.WebUI.TDatePicker.prototype = previousMonth.value = "<<";
td.appendChild(previousMonth);
tr.appendChild(td);
-
-
-
+
+
+
//
- // Create the month drop down
+ // Create the month drop down
//
td = document.createElement("td");
tr.appendChild(td);
@@ -144,9 +144,9 @@ Prado.WebUI.TDatePicker.prototype = this._monthSelect.appendChild(opt);
}
td.appendChild(this._monthSelect);
-
- //
+
+ //
// Create the year drop down
//
td = document.createElement("td");
@@ -163,8 +163,8 @@ Prado.WebUI.TDatePicker.prototype = this._yearSelect.appendChild(opt);
}
td.appendChild(this._yearSelect);
-
-
+
+
td = document.createElement("td");
var nextMonth = document.createElement("input");
nextMonth.className = "nextMonthButton button";
@@ -172,26 +172,26 @@ Prado.WebUI.TDatePicker.prototype = nextMonth.value = ">>";
td.appendChild(nextMonth);
tr.appendChild(td);
-
+
// Calendar body
div = document.createElement("div");
div.className = "calendarBody";
this._calDiv.appendChild(div);
var calendarBody = div;
-
- // Create the inside of calendar body
-
+
+ // Create the inside of calendar body
+
var text;
table = document.createElement("table");
table.align="center";
table.className = "grid";
-
+
div.appendChild(table);
var thead = document.createElement("thead");
table.appendChild(thead);
tr = document.createElement("tr");
thead.appendChild(tr);
-
+
for(i=0; i < 7; ++i) {
td = document.createElement("th");
text = document.createTextNode(this.ShortWeekDayNames[(i+this.FirstDayOfWeek)%7]);
@@ -199,11 +199,11 @@ Prado.WebUI.TDatePicker.prototype = td.className = "weekDayHead";
tr.appendChild(td);
}
-
+
// Date grid
tbody = document.createElement("tbody");
table.appendChild(tbody);
-
+
for(week=0; week<6; ++week) {
tr = document.createElement("tr");
tbody.appendChild(tr);
@@ -220,13 +220,13 @@ Prado.WebUI.TDatePicker.prototype = tmp.value = -1;
tmp.data = text;
this.dateSlot[(week*7)+day] = tmp;
-
+
Event.observe(td, "mouseover", this.hover.bindEvent(this));
Event.observe(td, "mouseout", this.hover.bindEvent(this));
-
+
}
}
-
+
// Calendar Footer
div = document.createElement("div");
div.className = "calendarFooter";
@@ -251,18 +251,18 @@ Prado.WebUI.TDatePicker.prototype = }
this.control.parentNode.appendChild(this._calDiv);
-
+
this.update();
this.updateHeader();
-
+
this.ieHack(true);
- // IE55+ extension
+ // IE55+ extension
previousMonth.hideFocus = true;
nextMonth.hideFocus = true;
todayButton.hideFocus = true;
// end IE55+ extension
-
+
// hook up events
Event.observe(previousMonth, "click", this.prevMonth.bindEvent(this));
Event.observe(nextMonth, "click", this.nextMonth.bindEvent(this));
@@ -272,18 +272,18 @@ Prado.WebUI.TDatePicker.prototype = Event.observe(this._yearSelect, "change", this.yearSelect.bindEvent(this));
// ie6 extension
- Event.observe(this._calDiv, "mousewheel", this.mouseWheelChange.bindEvent(this));
-
+ Event.observe(this._calDiv, "mousewheel", this.mouseWheelChange.bindEvent(this));
+
Event.observe(calendarBody, "click", this.selectDate.bindEvent(this));
-
+
Prado.Element.focus(this.control);
-
+
},
-
- ieHack : function(cleanup)
+
+ ieHack : function(cleanup)
{
// IE hack
- if(this.iePopUp)
+ if(this.iePopUp)
{
this.iePopUp.style.display = "block";
this.iePopUp.style.top = (this._calDiv.offsetTop -1 ) + "px";
@@ -299,7 +299,7 @@ Prado.WebUI.TDatePicker.prototype = if(!this.showing) return;
if (!ev) ev = document.parentWindow.event;
var kc = ev.keyCode != null ? ev.keyCode : ev.charCode;
-
+
if(kc == Event.KEY_RETURN || kc == Event.KEY_SPACEBAR || kc == Event.KEY_TAB)
{
this.setSelectedDate(this.selectedDate);
@@ -310,8 +310,8 @@ Prado.WebUI.TDatePicker.prototype = {
Event.stop(ev); this.hide();
}
-
- var getDaysPerMonth = function (nMonth, nYear)
+
+ var getDaysPerMonth = function (nMonth, nYear)
{
nMonth = (nMonth + 12) % 12;
var days= [31,28,31,30,31,30,31,31,30,31,30,31];
@@ -355,43 +355,43 @@ Prado.WebUI.TDatePicker.prototype = else
d -= 604800000; // -7 days
}
- else if (kc == Event.KEY_DOWN)
+ else if (kc == Event.KEY_DOWN)
{
if(ev.ctrlKey || ev.shiftKey) // +1 year
{
current.setDate( Math.min(current.getDate(), getDaysPerMonth(current.getMonth(),current.getFullYear() + 1)) ); // no need to catch dec -> jan for the year
d = current.setFullYear( current.getFullYear() + 1 );
}
- else
+ else
d += 7 * 24 * 61 * 60 * 1000; // +7 days
}
this.setSelectedDate(d);
- Event.stop(ev);
+ Event.stop(ev);
},
-
+
selectDate : function(ev)
{
var el = Event.element(ev);
while (el.nodeType != 1)
el = el.parentNode;
-
+
while (el != null && el.tagName && el.tagName.toLowerCase() != "td")
el = el.parentNode;
-
+
// if no td found, return
if (el == null || el.tagName == null || el.tagName.toLowerCase() != "td")
return;
-
+
var d = this.newDate(this.selectedDate);
var n = Number(el.firstChild.data);
if (isNaN(n) || n <= 0 || n == null)
return;
-
+
d.setDate(n);
this.setSelectedDate(d);
this.hide();
},
-
+
selectToday : function()
{
if(this.selectedDate.toISODate() == this.newDate().toISODate())
@@ -399,36 +399,36 @@ Prado.WebUI.TDatePicker.prototype = this.setSelectedDate(this.newDate());
},
-
+
clearSelection : function()
{
this.setSelectedDate(this.newDate());
this.hide();
},
-
+
monthSelect : function(ev)
{
this.setMonth(Form.Element.getValue(Event.element(ev)));
},
-
+
yearSelect : function(ev)
{
this.setYear(Form.Element.getValue(Event.element(ev)));
},
-
+
// ie6 extension
- mouseWheelChange : function (e)
+ mouseWheelChange : function (e)
{
if (e == null) e = document.parentWindow.event;
var n = - e.wheelDelta / 120;
var d = this.newDate(this.selectedDate);
var m = d.getMonth() + n;
this.setMonth(m);
-
+
return false;
},
- onChange : function()
+ onChange : function()
{
if(this.options.InputMode == "TextBox")
{
@@ -459,7 +459,7 @@ Prado.WebUI.TDatePicker.prototype = Event.fireEvent(day || month || year, "change");
}
},
-
+
formatDate : function()
{
return this.selectedDate ? this.selectedDate.SimpleFormat(this.Format,this) : '';
@@ -474,52 +474,52 @@ Prado.WebUI.TDatePicker.prototype = return new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0,0,0);
},
- setSelectedDate : function(date)
+ setSelectedDate : function(date)
{
if (date == null)
return;
this.selectedDate = this.newDate(date);
-
+
this.updateHeader();
this.update();
if (typeof(this.onChange) == "function")
- this.onChange();
+ this.onChange(this, date);
},
- getElement : function()
+ getElement : function()
{
return this._calDiv;
},
- getSelectedDate : function ()
+ getSelectedDate : function ()
{
return this.selectedDate == null ? null : this.newDate(this.selectedDate);
},
-
- setYear : function(year)
+
+ setYear : function(year)
{
var d = this.newDate(this.selectedDate);
d.setFullYear(year);
this.setSelectedDate(d);
},
- setMonth : function (month)
+ setMonth : function (month)
{
var d = this.newDate(this.selectedDate);
d.setMonth(month);
this.setSelectedDate(d);
},
- nextMonth : function ()
+ nextMonth : function ()
{
this.setMonth(this.selectedDate.getMonth()+1);
},
- prevMonth : function ()
+ prevMonth : function ()
{
this.setMonth(this.selectedDate.getMonth()-1);
},
-
+
getDatePickerOffsetHeight : function()
{
if(this.options.InputMode == "TextBox")
@@ -529,27 +529,27 @@ Prado.WebUI.TDatePicker.prototype = if(control) return control.offsetHeight;
var control = Prado.WebUI.TDatePicker.getMonthListControl(this.control);
- if(control) return control.offsetHeight;
+ if(control) return control.offsetHeight;
var control = Prado.WebUI.TDatePicker.getYearListControl(this.control);
- if(control) return control.offsetHeight;
+ if(control) return control.offsetHeight;
return 0;
},
-
- show : function()
+
+ show : function()
{
this.create();
-
+
if(!this.showing)
{
var pos = Position.positionedOffset(this.control);
-
+
pos[1] += this.getDatePickerOffsetHeight();
-
+
this._calDiv.style.display = "block";
this._calDiv.style.top = (pos[1]-1) + "px";
this._calDiv.style.left = pos[0] + "px";
-
+
this.ieHack(false);
this.documentClickEvent = this.hideOnClick.bindEvent(this);
this.documentKeyDownEvent = this.keyPressed.bindEvent(this);
@@ -560,7 +560,7 @@ Prado.WebUI.TDatePicker.prototype = this.selectedDate = date;
this.setSelectedDate(date);
}
- Event.observe(document,"keydown", this.documentKeyDownEvent);
+ Event.observe(document,"keydown", this.documentKeyDownEvent);
this.showing = true;
}
},
@@ -572,7 +572,7 @@ Prado.WebUI.TDatePicker.prototype = else
return Prado.WebUI.TDatePicker.getDropDownDate(this.control);
},
-
+
//hide the calendar when clicked outside any calendar
hideOnClick : function(ev)
{
@@ -585,12 +585,12 @@ Prado.WebUI.TDatePicker.prototype = within = within || el == this.trigger;
within = within || el == this.control;
if(within) break;
- el = el.parentNode;
+ el = el.parentNode;
}
while(el);
if(!within) this.hide();
},
-
+
hide : function()
{
@@ -599,28 +599,28 @@ Prado.WebUI.TDatePicker.prototype = this._calDiv.style.display = "none";
if(this.iePopUp)
this.iePopUp.style.display = "none";
- this.showing = false;
- Event.stopObserving(document.body, "click", this.documentClickEvent);
- Event.stopObserving(document,"keydown", this.documentKeyDownEvent);
- }
+ this.showing = false;
+ Event.stopObserving(document.body, "click", this.documentClickEvent);
+ Event.stopObserving(document,"keydown", this.documentKeyDownEvent);
+ }
},
-
- update : function()
+
+ update : function()
{
// Calculate the number of days in the month for the selected date
var date = this.selectedDate;
var today = (this.newDate()).toISODate();
-
+
var selected = date.toISODate();
var d1 = new Date(date.getFullYear(), date.getMonth(), 1);
var d2 = new Date(date.getFullYear(), date.getMonth()+1, 1);
var monthLength = Math.round((d2 - d1) / (24 * 60 * 60 * 1000));
-
+
// Find out the weekDay index for the first of this month
var firstIndex = (d1.getDay() - this.FirstDayOfWeek) % 7 ;
if (firstIndex < 0)
firstIndex += 7;
-
+
var index = 0;
while (index < firstIndex) {
this.dateSlot[index].value = -1;
@@ -628,7 +628,7 @@ Prado.WebUI.TDatePicker.prototype = this.dateSlot[index].data.parentNode.className = "empty";
index++;
}
-
+
for (i = 1; i <= monthLength; i++, index++) {
var slot = this.dateSlot[index];
var slotNode = slot.data.parentNode;
@@ -645,18 +645,18 @@ Prado.WebUI.TDatePicker.prototype = }
d1 = new Date(d1.getFullYear(), d1.getMonth(), d1.getDate()+1);
}
-
+
var lastDateIndex = index;
-
+
while(index < 42) {
this.dateSlot[index].value = -1;
this.dateSlot[index].data.data = String.fromCharCode(160);
this.dateSlot[index].data.parentNode.className = "empty";
++index;
}
-
+
},
-
+
hover : function(ev)
{
if(Event.element(ev).tagName)
@@ -667,7 +667,7 @@ Prado.WebUI.TDatePicker.prototype = Event.element(ev).removeClassName("hover");
}
},
-
+
updateHeader : function () {
var options = this._monthSelect.options;
@@ -678,7 +678,7 @@ Prado.WebUI.TDatePicker.prototype = options[i].selected = true;
}
}
-
+
options = this._yearSelect.options;
var year = this.selectedDate.getFullYear();
for(var i=0; i < options.length; ++i) {
@@ -687,8 +687,8 @@ Prado.WebUI.TDatePicker.prototype = options[i].selected = true;
}
}
-
+
}
-
-
+
+
};
\ No newline at end of file diff --git a/framework/Web/Javascripts/effects/controls.js b/framework/Web/Javascripts/effects/controls.js index de0261ed..ea5ce6ea 100644 --- a/framework/Web/Javascripts/effects/controls.js +++ b/framework/Web/Javascripts/effects/controls.js @@ -33,6 +33,9 @@ // useful when one of the tokens is \n (a newline), as it // allows smart autocompletion after linebreaks. +if(typeof Effect == 'undefined') + throw("controls.js requires including script.aculo.us' effects.js library"); + var Autocompleter = {} Autocompleter.Base = function() {}; Autocompleter.Base.prototype = { @@ -94,7 +97,7 @@ Autocompleter.Base.prototype = { }, fixIEOverlapping: function() { - Position.clone(this.update, this.iefix); + Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)}); this.iefix.style.zIndex = 1; this.update.style.zIndex = 2; Element.show(this.iefix); @@ -202,11 +205,13 @@ Autocompleter.Base.prototype = { markPrevious: function() { if(this.index > 0) this.index-- else this.index = this.entryCount-1; + this.getEntry(this.index).scrollIntoView(true); }, markNext: function() { if(this.index < this.entryCount-1) this.index++ else this.index = 0; + this.getEntry(this.index).scrollIntoView(false); }, getEntry: function(index) { @@ -531,7 +536,7 @@ Ajax.InPlaceEditor.prototype = { Element.hide(this.element); this.createForm(); this.element.parentNode.insertBefore(this.form, this.element); - Field.scrollFreeActivate(this.editField); + if (!this.options.loadTextURL) Field.scrollFreeActivate(this.editField); // stop the event to avoid a page refresh in Safari if (evt) { Event.stop(evt); @@ -636,6 +641,7 @@ Ajax.InPlaceEditor.prototype = { Element.removeClassName(this.form, this.options.loadingClassName); this.editField.disabled = false; this.editField.value = transport.responseText.stripTags(); + Field.scrollFreeActivate(this.editField); }, onclickCancel: function() { this.onComplete(); diff --git a/framework/Web/Javascripts/effects/dragdrop.js b/framework/Web/Javascripts/effects/dragdrop.js index be2a30f5..1528eced 100644 --- a/framework/Web/Javascripts/effects/dragdrop.js +++ b/framework/Web/Javascripts/effects/dragdrop.js @@ -5,6 +5,9 @@ /*--------------------------------------------------------------------------*/ +if(typeof Effect == 'undefined') + throw("dragdrop.js requires including script.aculo.us' effects.js library"); + var Droppables = { drops: [], @@ -204,21 +207,31 @@ var Draggables = { /*--------------------------------------------------------------------------*/ var Draggable = Class.create(); +Draggable._revertCache = {}; +Draggable._dragging = {}; + Draggable.prototype = { initialize: function(element) { var options = Object.extend({ handle: false, starteffect: function(element) { - element._opacity = Element.getOpacity(element); + element._opacity = Element.getOpacity(element); + Draggable._dragging[element] = true; new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7}); }, reverteffect: function(element, top_offset, left_offset) { var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02; - element._revert = new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur}); + Draggable._revertCache[element] = + new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur, + queue: {scope:'_draggable', position:'end'} + }); }, endeffect: function(element) { - var toOpacity = typeof element._opacity == 'number' ? element._opacity : 1.0 - new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity}); + var toOpacity = typeof element._opacity == 'number' ? element._opacity : 1.0; + new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity, + queue: {scope:'_draggable', position:'end'}, + afterFinish: function(){ Draggable._dragging[element] = false } + }); }, zindex: 1000, revert: false, @@ -264,6 +277,8 @@ Draggable.prototype = { }, initDrag: function(event) { + if(typeof Draggable._dragging[this.element] != undefined && + Draggable._dragging[this.element]) return; if(Event.isLeftClick(event)) { // abort on form elements, fixes a Firefox issue var src = Event.element(event); @@ -274,9 +289,9 @@ Draggable.prototype = { src.tagName=='BUTTON' || src.tagName=='TEXTAREA')) return; - if(this.element._revert) { - this.element._revert.cancel(); - this.element._revert = null; + if(Draggable._revertCache[this.element]) { + Draggable._revertCache[this.element].cancel(); + Draggable._revertCache[this.element] = null; } var pointer = [Event.pointerX(event), Event.pointerY(event)]; @@ -442,6 +457,7 @@ Draggable.prototype = { }, startScrolling: function(speed) { + if(!(speed[0] || speed[1])) return; this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed]; this.lastScrolled = new Date(); this.scrollInterval = setInterval(this.scroll.bind(this), 10); @@ -708,7 +724,7 @@ var Sortable = { if(!Element.isParent(dropon, element)) { var index; - var children = Sortable.findElements(dropon, {tag: droponOptions.tag}); + var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only: droponOptions.only}); var child = null; if(children) { @@ -869,7 +885,7 @@ var Sortable = { if (options.tree) { return Sortable.tree(element, arguments[1]).children.map( function (item) { - return [name + Sortable._constructIndex(item) + "=" + + return [name + Sortable._constructIndex(item) + "[id]=" + encodeURIComponent(item.id)].concat(item.children.map(arguments.callee)); }).flatten().join('&'); } else { diff --git a/framework/Web/Javascripts/effects/effects.js b/framework/Web/Javascripts/effects/effects.js index 0864323e..1f3d50bb 100644 --- a/framework/Web/Javascripts/effects/effects.js +++ b/framework/Web/Javascripts/effects/effects.js @@ -105,6 +105,9 @@ Array.prototype.call = function() { var Effect = { tagifyText: function(element) { + if(typeof Builder == 'undefined') + throw("Effect.tagifyText requires including script.aculo.us' builder.js library"); + var tagifyStyle = 'position:relative'; if(/MSIE/.test(navigator.userAgent)) tagifyStyle += ';zoom:1'; element = $(element); @@ -161,9 +164,8 @@ var Effect2 = Effect; // deprecated Effect.Transitions = {} -Effect.Transitions.linear = function(pos) { - return pos; -} +Effect.Transitions.linear = Prototype.K; + Effect.Transitions.sinoidal = function(pos) { return (-Math.cos(pos*Math.PI)/2) + 0.5; } @@ -353,7 +355,7 @@ Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), { initialize: function(element) { this.element = $(element); // make this work on IE on elements without 'layout' - if(/MSIE/.test(navigator.userAgent) && (!this.element.hasLayout)) + if(/MSIE/.test(navigator.userAgent) && (!this.element.currentStyle.hasLayout)) this.element.setStyle({zoom: 1}); var options = Object.extend({ from: this.element.getOpacity() || 0.0, @@ -393,8 +395,8 @@ Object.extend(Object.extend(Effect.Move.prototype, Effect.Base.prototype), { }, update: function(position) { this.element.setStyle({ - left: this.options.x * position + this.originalLeft + 'px', - top: this.options.y * position + this.originalTop + 'px' + left: Math.round(this.options.x * position + this.originalLeft) + 'px', + top: Math.round(this.options.y * position + this.originalTop) + 'px' }); } }); @@ -433,7 +435,7 @@ Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), { this.originalLeft = this.element.offsetLeft; var fontSize = this.element.getStyle('font-size') || '100%'; - ['em','px','%'].each( function(fontSizeType) { + ['em','px','%','pt'].each( function(fontSizeType) { if(fontSize.indexOf(fontSizeType)>0) { this.fontSize = parseFloat(fontSize); this.fontSizeType = fontSizeType; @@ -462,8 +464,8 @@ Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), { }, setDimensions: function(height, width) { var d = {}; - if(this.options.scaleX) d.width = width + 'px'; - if(this.options.scaleY) d.height = height + 'px'; + if(this.options.scaleX) d.width = Math.round(width) + 'px'; + if(this.options.scaleY) d.height = Math.round(height) + 'px'; if(this.options.scaleFromCenter) { var topd = (height - this.dims[0])/2; var leftd = (width - this.dims[1])/2; @@ -589,7 +591,7 @@ Effect.Puff = function(element) { Effect.BlindUp = function(element) { element = $(element); element.makeClipping(); - return new Effect.Scale(element, 0, + return new Effect.Scale(element, 0, Object.extend({ scaleContent: false, scaleX: false, restoreAfterFinish: true, @@ -604,28 +606,27 @@ Effect.BlindUp = function(element) { Effect.BlindDown = function(element) { element = $(element); var elementDimensions = element.getDimensions(); - return new Effect.Scale(element, 100, - Object.extend({ scaleContent: false, - scaleX: false, - scaleFrom: 0, - scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, - restoreAfterFinish: true, - afterSetup: function(effect) { - effect.element.makeClipping(); - effect.element.setStyle({height: '0px'}); - effect.element.show(); - }, - afterFinishInternal: function(effect) { - effect.element.undoClipping(); - } - }, arguments[1] || {}) - ); + return new Effect.Scale(element, 100, Object.extend({ + scaleContent: false, + scaleX: false, + scaleFrom: 0, + scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, + restoreAfterFinish: true, + afterSetup: function(effect) { + effect.element.makeClipping(); + effect.element.setStyle({height: '0px'}); + effect.element.show(); + }, + afterFinishInternal: function(effect) { + effect.element.undoClipping(); + } + }, arguments[1] || {})); } Effect.SwitchOff = function(element) { element = $(element); var oldOpacity = element.getInlineOpacity(); - return new Effect.Appear(element, { + return new Effect.Appear(element, Object.extend({ duration: 0.4, from: 0, transition: Effect.Transitions.flicker, @@ -645,7 +646,7 @@ Effect.SwitchOff = function(element) { } }) } - }); + }, arguments[1] || {})); } Effect.DropOut = function(element) { @@ -729,7 +730,7 @@ Effect.SlideDown = function(element) { }, arguments[1] || {}) ); } - + Effect.SlideUp = function(element) { element = $(element); element.cleanWhitespace(); diff --git a/framework/Web/Javascripts/effects/slider.js b/framework/Web/Javascripts/effects/slider.js index c0f1fc01..696992ca 100644 --- a/framework/Web/Javascripts/effects/slider.js +++ b/framework/Web/Javascripts/effects/slider.js @@ -64,7 +64,12 @@ Control.Slider.prototype = { this.alignY = parseInt(this.options.alignY || '0'); this.trackLength = this.maximumOffset() - this.minimumOffset(); - this.handleLength = this.isVertical() ? this.handles[0].offsetHeight : this.handles[0].offsetWidth; + + this.handleLength = this.isVertical() ? + (this.handles[0].offsetHeight != 0 ? + this.handles[0].offsetHeight : this.handles[0].style.height.replace(/px$/,"")) : + (this.handles[0].offsetWidth != 0 ? this.handles[0].offsetWidth : + this.handles[0].style.width.replace(/px$/,"")); this.active = false; this.dragging = false; @@ -137,8 +142,8 @@ Control.Slider.prototype = { }, setValue: function(sliderValue, handleIdx){ if(!this.active) { - this.activeHandle = this.handles[handleIdx]; - this.activeHandleIdx = handleIdx; + this.activeHandleIdx = handleIdx || 0; + this.activeHandle = this.handles[this.activeHandleIdx]; this.updateStyles(); } handleIdx = handleIdx || this.activeHandleIdx || 0; @@ -180,8 +185,11 @@ Control.Slider.prototype = { return(this.isVertical() ? this.alignY : this.alignX); }, maximumOffset: function(){ - return(this.isVertical() ? - this.track.offsetHeight - this.alignY : this.track.offsetWidth - this.alignX); + return(this.isVertical() ? + (this.track.offsetHeight != 0 ? this.track.offsetHeight : + this.track.style.height.replace(/px$/,"")) - this.alignY : + (this.track.offsetWidth != 0 ? this.track.offsetWidth : + this.track.style.width.replace(/px$/,"")) - this.alignY); }, isVertical: function(){ return (this.axis == 'vertical'); @@ -217,7 +225,8 @@ Control.Slider.prototype = { var handle = Event.element(event); var pointer = [Event.pointerX(event), Event.pointerY(event)]; - if(handle==this.track) { + var track = handle; + if(track==this.track) { var offsets = Position.cumulativeOffset(this.track); this.event = event; this.setValue(this.translateToValue( diff --git a/framework/Web/Javascripts/prado/ajax.js b/framework/Web/Javascripts/prado/ajax.js index 06c3d741..4f1c1ec9 100644 --- a/framework/Web/Javascripts/prado/ajax.js +++ b/framework/Web/Javascripts/prado/ajax.js @@ -1,4 +1,4 @@ -/**
+/**
* Prado AJAX service. The default service provider is JPSpan.
*/
Prado.AJAX = { Service : 'Prototype' };
@@ -11,10 +11,10 @@ Prado.AJAX.EvalScript = function(output) var match = new RegExp(Ajax.Updater.ScriptFragment, 'img');
var scripts = output.match(match);
- if (scripts)
+ if (scripts)
{
match = new RegExp(Ajax.Updater.ScriptFragment, 'im');
- setTimeout((function()
+ setTimeout((function()
{
for (var i = 0; i < scripts.length; i++)
eval(scripts[i].match(match)[1]);
@@ -27,21 +27,21 @@ Prado.AJAX.EvalScript = function(output) * AJAX service request using Prototype's AJAX request class.
*/
Prado.AJAX.Request = Class.create();
-Prado.AJAX.Request.prototype = Object.extend(Ajax.Request.prototype,
+Prado.AJAX.Request.prototype = Object.extend(Ajax.Request.prototype,
{
/**
* Evaluate the respond JSON data, override parent implementing.
* If default eval fails, try parsing the JSON data (slower).
*/
- evalJSON: function()
+ evalJSON: function()
{
- try
+ try
{
var json = this.transport.getResponseHeader('X-JSON'), object;
object = eval(json);
return object;
- }
- catch (e)
+ }
+ catch (e)
{
if(isString(json))
{
@@ -49,15 +49,15 @@ Prado.AJAX.Request.prototype = Object.extend(Ajax.Request.prototype, }
}
},
-
+
respondToReadyState: function(readyState) {
var event = Ajax.Request.Events[readyState];
var transport = this.transport, json = this.evalJSON();
-
+
if(event == 'Complete' && transport.status)
Ajax.Responders.dispatch('on' + transport.status, this, transport, json);
-
+
(this.options['on' + event] || Prototype.emptyFunction)(transport, json);
Ajax.Responders.dispatch('on' + event, this, transport, json);
@@ -66,15 +66,15 @@ Prado.AJAX.Request.prototype = Object.extend(Ajax.Request.prototype, || this.options['on' + (this.responseIsSuccess() ? 'Success' : 'Failure')]
|| Prototype.emptyFunction)(transport, json);
-
+
/* Avoid memory leak in MSIE: clean up the oncomplete event handler */
if (event == 'Complete')
this.transport.onreadystatechange = Prototype.emptyFunction;
}
-
+
});
-Prado.AJAX.Error = function(e, code)
+Prado.AJAX.Error = function(e, code)
{
e.name = 'Prado.AJAX.Error';
e.code = code;
@@ -85,7 +85,7 @@ Prado.AJAX.Error = function(e, code) * Post data builder, serialize the data using JSON.
*/
Prado.AJAX.RequestBuilder = Class.create();
-Prado.AJAX.RequestBuilder.prototype =
+Prado.AJAX.RequestBuilder.prototype =
{
initialize : function()
{
@@ -96,13 +96,13 @@ Prado.AJAX.RequestBuilder.prototype = {
return Prado.AJAX.JSON.stringify(data);
},
- build : function(data)
+ build : function(data)
{
var sep = '';
- for ( var argName in data)
+ for ( var argName in data)
{
if(isFunction(data[argName])) continue;
- try
+ try
{
this.body += sep + argName + '=';
this.body += encodeURIComponent(this.encode(data[argName]));
@@ -110,9 +110,9 @@ Prado.AJAX.RequestBuilder.prototype = throw Prado.AJAX.Error(e, 1006);
}
sep = '&';
- }
+ }
},
-
+
getAll : function()
{
this.build(this.data);
@@ -141,7 +141,7 @@ Prado.AJAX.RemoteObject.Request.prototype = Object.extend(Prado.AJAX.Request.pro },
/**
- * Call the remote object,
+ * Call the remote object,
* @param string the remote server url
* @param array additional arguments
*/
@@ -165,7 +165,7 @@ Prado.AJAX.RemoteObject.Request.prototype = Object.extend(Prado.AJAX.Request.pro /**
* Base proxy class for Prado RemoteObjects via AJAX.
- * e.g.
+ * e.g.
* <code>
* var TestObject1 = Class.create();
* TestObject1.prototype = Object.extend(new Prado.AJAX.RemoteObject(),
@@ -182,18 +182,18 @@ Prado.AJAX.RemoteObject.Request.prototype = Object.extend(Prado.AJAX.Request.pro * }
* });
*</code>
- * And client usage,
+ * And client usage,
* <code>
* var test1 = new TestObject1(); //create new remote object
* test1.method1(); //call the method, no onComplete hook
*
* var onComplete = { method1 : function(result){ alert(result) } };
* //create new remote object with onComplete callback
- * var test2 = new TestObject1(onComplete);
+ * var test2 = new TestObject1(onComplete);
* test2.method1(); //call it, on success, onComplete's method1 is called.
* </code>
*/
-Prado.AJAX.RemoteObject.prototype =
+Prado.AJAX.RemoteObject.prototype =
{
baseInitialize : function(handlers, options)
{
@@ -207,11 +207,11 @@ Prado.AJAX.RemoteObject.prototype = this.__callback = method;
return this.__service.invokeRemoteObject(url+"/"+method, args);
},
-
+
__onSuccess : function(transport, json)
{
if(this.__handlers[this.__callback])
- this.__handlers[this.__callback](json, transport.responseText);
+ this.__handlers[this.__callback](json, transport.responseText);
}
};
@@ -224,12 +224,12 @@ Prado.AJAX.Exception = * Server returns 505 exception. Just log it.
*/
"on505" : function(request, transport, e)
- {
+ {
var msg = 'HTTP '+transport.status+" with response";
Logger.error(msg, transport.responseText);
Logger.exception(e);
},
-
+
onComplete : function(request, transport, e)
{
if(transport.status != 505)
@@ -265,8 +265,8 @@ Prado.AJAX.Exception = //Add HTTP exception respones when logger is enabled.
Event.OnLoad(function()
-{
- if(typeof Logger != "undefined")
+{
+ if(typeof Logger != "undefined")
{
Logger.exception = Prado.AJAX.Exception.logException;
Ajax.Responders.register(Prado.AJAX.Exception);
@@ -274,7 +274,7 @@ Event.OnLoad(function() });
/**
- * Prado Callback service that provides component intergration,
+ * Prado Callback service that provides component intergration,
* viewstate (read only), and automatic form data serialization.
* Usage: <code>new Prado.AJAX.Callback('MyPage.MyComponentID.raiseCallbackEvent', options)</code>
* These classes should be called by the components developers.
@@ -283,7 +283,7 @@ Event.OnLoad(function() Prado.AJAX.Callback = Class.create();
Prado.AJAX.Callback.prototype = Object.extend(new Prado.AJAX.RemoteObject(),
{
-
+
/**
* Create and request a new Prado callback service.
* @param string|element the callback ID, must be of the form, <t>ClassName.ComponentID.MethodName</t>
@@ -294,14 +294,14 @@ Prado.AJAX.Callback.prototype = Object.extend(new Prado.AJAX.RemoteObject(), {
if(!isString(ID) && typeof(ID.id) != "undefined")
ID = ID.id;
- if(!isString(ID))
+ if(!isString(ID))
throw new Error('A Control ID must be specified');
this.baseInitialize(this, options);
this.options = options || [];
this.__service.post.data['__ID'] = ID;
this.requestCallback();
},
-
+
/**
* Get form data for components that implements IPostBackHandler.
*/
@@ -313,7 +313,7 @@ Prado.AJAX.Callback.prototype = Object.extend(new Prado.AJAX.RemoteObject(), {
var id = IDs[i];
if(id.indexOf("[]") > -1)
- this.__service.post.data['__data'][id] =
+ this.__service.post.data['__data'][id] =
this.collectArrayPostData(id);
else if(isObject($(id)))
this.__service.post.data['__data'][id] = $F(id);
@@ -325,12 +325,12 @@ Prado.AJAX.Callback.prototype = Object.extend(new Prado.AJAX.RemoteObject(), var elements = document.getElementsByName(name);
var data = [];
$A(elements).each(function(el)
- {
- if($F(el)) data.push($F(el));
+ {
+ if($F(el)) data.push($F(el));
});
return data;
},
-
+
/**
* Prepares and calls the AJAX request.
* Collects the data from components that implements IPostBackHandler
@@ -377,7 +377,7 @@ Prado.AJAX.Callback.Action = /**
- * Returns false if validation required and validates to false,
+ * Returns false if validation required and validates to false,
* returns true otherwise.
* @return boolean true if validation passes.
*/
@@ -406,20 +406,22 @@ Prado.AJAX.Callback.IDs = []; /**
* Simple AJAX callback interface, suitable for inline javascript.
* e.g., <code><a href="..." onclick="Prado.Callback('..', 'Hello');">Click me</a></code>
- * @param string callback ID
- * @param array parameters to pass to the callback service
+ * @param {String} callback ID
+ * @param {Array} parameters to pass to the callback service
+ * @param {Function} on callback success handler method
+ * @param {Object} additional callback options
*/
Prado.Callback = function(ID, params, onSuccess, options)
{
- var callback =
+ var callback =
{
'params' : [params] || [],
- 'onSuccess' : onSuccess || Prototype.emptyFunction,
+ 'onSuccess' : onSuccess || Prototype.emptyFunction,
'CausesValidation' : true
};
Object.extend(callback, options || {});
-
+
new Prado.AJAX.Callback(ID, callback);
return false;
}
\ No newline at end of file |