Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F860096
in-portal
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Apr 30, 8:49 AM
Size
4 KB
Mime Type
text/x-diff
Expires
Fri, May 2, 8:49 AM (42 m)
Engine
blob
Format
Raw Data
Handle
611790
Attached To
rINP In-Portal
in-portal
View Options
Index: branches/5.1.x/core/admin_templates/js/simple_grid.js
===================================================================
--- branches/5.1.x/core/admin_templates/js/simple_grid.js (revision 13878)
+++ branches/5.1.x/core/admin_templates/js/simple_grid.js (revision 13879)
@@ -1,183 +1,178 @@
function SimpleGrid($id_prefix, $field_mask, $show_order) {
this.ItemIDs = new Array ();
this.NextNumber = 0;
this.IDPrefix = $id_prefix;
this.FieldMask = $field_mask;
this.Container = this.getControl('container');
this.ShowOrder = $show_order;
}
SimpleGrid.prototype.registerRecord = function ($id) {
var $prev_id = this.lastID();
if ($prev_id !== false) {
this.getControl('button_' + $prev_id).value = '-';
}
$id = parseInt($id);
this.ItemIDs.push($id);
if ($id < 0 && Math.abs($id) > Math.abs(this.NextNumber)) {
this.NextNumber = $id;
}
if (this.ShowOrder) {
this.getControl('number_'+$id).innerHTML = this.ItemIDs.length;
}
this.processRecordDependancies($id);
}
SimpleGrid.prototype.renumberRecords = function () {
if (!this.ShowOrder) {
return ;
}
var $i = 0;
while ($i < this.ItemIDs.length) {
this.getControl('number_' + this.ItemIDs[$i]).innerHTML = $i + 1;
$i++;
}
}
SimpleGrid.prototype.nextNumber = function () {
return --this.NextNumber;
}
SimpleGrid.prototype.lastID = function () {
return this.ItemIDs.length ? this.ItemIDs.slice(this.ItemIDs.length - 1)[0] : false;
}
SimpleGrid.prototype.toggleRecord = function ($item_id) {
if (this.lastID() == $item_id) {
this.addRecord();
}
else {
this.removeRecord($item_id);
}
}
SimpleGrid.prototype.getControl = function ($name) {
return document.getElementById(this.IDPrefix + '_' + $name);
}
SimpleGrid.prototype.getField = function ($id, $field_name, $prepend, $append) {
$prepend = isset($prepend) ? $prepend + '_' : '';
$append = isset($append) ? '_' + $append : '';
return document.getElementById($prepend + this.FieldMask.replace('#FIELD#', $field_name).replace('#ID#', $id) + $append);
}
-SimpleGrid.prototype.markError = function ($item_id, $field_name, $error_found) {
+SimpleGrid.prototype.markError = function ($item_id, $field_name, $error_found, $error_message) {
if (!isset($error_found)) {
$error_found = true;
}
- var $field = this.getField($item_id, $field_name);
+ var $field = $( this.getField($item_id, $field_name) );
+
if ($error_found) {
- $field.style.backgroundColor = '#EF2C2C';
+ $field.css('background-color', '#EF2C2C').attr('title', $error_message === undefined ? '' : $error_message)
// TODO: duplicate focus events possible on one element, fix this later
- addEvent($field, 'focus',
+ .focus(
function($e) {
- if (!$e) {
- $e = window.event;
- }
-
- var $element = document.all ? $e.srcElement : $e.currentTarget;
- $element.style.backgroundColor = '';
+ $(this).css('background-color', '').attr('title', '');
}
-
);
}
else {
- $field.style.backgroundColor = '';
+ $field.css('background-color', '').attr('title', '');
}
}
SimpleGrid.prototype.validateRecord = function ($item_id) {
return true;
}
SimpleGrid.prototype.validate = function () {
var $i = 0;
var $is_valid = true;
while ($i < this.ItemIDs.length) {
if (!this.validateRecord(this.ItemIDs[$i])) {
$is_valid = false;
}
$i++;
}
return $is_valid;
}
SimpleGrid.prototype.addRecord = function ($after_item_id) {
var new_item_number = this.nextNumber();
var $item_mask = this.getControl('mask').value;
var $result_html = $item_mask.replace(/#NUMBER#/g, new_item_number);
var $div = document.createElement('DIV');
$div.id = this.IDPrefix + '_' + new_item_number;
if ($after_item_id === undefined) {
this.getControl('container').appendChild($div);
}
else {
$('#' + jq(this.IDPrefix + '_' + $after_item_id)).after($div);
}
$div.innerHTML = $result_html;
var $js_mask = this.getControl('js_mask').value;
var result_js = $js_mask.replace(/#NUMBER#/g, new_item_number);
eval(result_js);
this.updateTotals();
return new_item_number;
}
SimpleGrid.prototype.removeRecord = function ($number) {
var $index = array_search($number, this.ItemIDs);
if ($index == -1) {
// don't allow to delete missing rows
return false;
}
this.getControl('container').removeChild( this.getControl($number) );
this.ItemIDs.splice($index, 1);
this.renumberRecords();
this.updateTotals();
return true;
}
SimpleGrid.prototype.removeRecords = function () {
while (this.ItemIDs.length > 0) {
var $item_id = this.ItemIDs[this.ItemIDs.length - 1];
this.removeRecord($item_id);
}
}
SimpleGrid.prototype.updateTotals = function () {
// prototype
}
SimpleGrid.prototype.processRecordDependancies = function ($id) {
// prototype
}
SimpleGrid.prototype.each = function($callback) {
var $result = null;
for (var $i = 0; $i < this.ItemIDs.length; $i++) {
$result = $callback.call(this, this.ItemIDs[$i]);
if ($result === false) {
break;
}
}
}
Event Timeline
Log In to Comment