diff options
author | mleibman <michael.leibman@gmail.com> | 2009-12-26 02:14:58 -0800 |
---|---|---|
committer | mleibman <michael.leibman@gmail.com> | 2009-12-26 02:14:58 -0800 |
commit | 1c45b9750cc863c0bce8044237ca2b8dd1ca3fd5 (patch) | |
tree | 9d080bb9b6e04752e72aa405642aecea6fc2839a /slick.editors.js | |
parent | 22045690ab4172c5ef31ac12d9c85e373d1dad1e (diff) | |
download | SlickGrid-1c45b9750cc863c0bce8044237ca2b8dd1ca3fd5.zip SlickGrid-1c45b9750cc863c0bce8044237ca2b8dd1ca3fd5.tar.gz SlickGrid-1c45b9750cc863c0bce8044237ca2b8dd1ca3fd5.tar.bz2 |
Code/CSS cleanup (thanks WebIDE!).
Diffstat (limited to 'slick.editors.js')
-rw-r--r-- | slick.editors.js | 480 |
1 files changed, 240 insertions, 240 deletions
diff --git a/slick.editors.js b/slick.editors.js index a59d2b7..1654666 100644 --- a/slick.editors.js +++ b/slick.editors.js @@ -67,130 +67,130 @@ var TextCellEditor = function($container, columnDef, value, dataContext) { var $input; var defaultValue = value; var scope = this; - + this.init = function() { $input = $("<INPUT type=text class='editor-text' />"); - - if (value != null) + + if (value != null) { $input[0].defaultValue = value; $input.val(defaultValue); } - + $input.appendTo($container); $input.focus().select(); - } - + }; + this.destroy = function() { $input.remove(); - } - + }; + this.focus = function() { $input.focus(); - } - + }; + this.setValue = function(value) { $input.val(value); defaultValue = value; - } - + }; + this.getValue = function() { return $input.val(); - } - + }; + this.isValueChanged = function() { return (!($input.val() == "" && defaultValue == null)) && ($input.val() != defaultValue); - } - + }; + this.validate = function() { - if (columnDef.validator) + if (columnDef.validator) { var validationResults = columnDef.validator(scope.getValue()); - if (!validationResults.valid) + if (!validationResults.valid) return validationResults; } - + return { valid: true, msg: null }; - } - + }; + this.init(); -} +}; var IntegerCellEditor = function($container, columnDef, value, dataContext) { var $input; var defaultValue = value; var scope = this; - + this.init = function() { $input = $("<INPUT type=text class='editor-text' />"); - - if (value != null) + + if (value != null) { $input[0].defaultValue = value; $input.val(defaultValue); } - + $input.appendTo($container); $input.focus().select(); - } - - + }; + + this.destroy = function() { $input.remove(); - } - + }; + this.focus = function() { $input.focus(); - } - + }; + this.setValue = function(value) { $input.val(value); defaultValue = value; - } - + }; + this.getValue = function() { - var val = $.trim($input.val()); + var val = $.trim($input.val()); return (val == "") ? 0 : parseInt($input.val(), 10); - } - + }; + this.isValueChanged = function() { return (!($input.val() == "" && defaultValue == null)) && ($input.val() != defaultValue); - } - + }; + this.validate = function() { - if (isNaN($input.val())) + if (isNaN($input.val())) return { valid: false, msg: "Please enter a valid integer" }; - + return { valid: true, msg: null }; - } - + }; + this.init(); -} +}; var DateCellEditor = function($container, columnDef, value, dataContext) { var $input; var defaultValue = value; var scope = this; - + this.init = function() { $input = $("<INPUT type=text class='editor-text' />"); - - if (value != null) + + if (value != null) { $input[0].defaultValue = value; $input.val(defaultValue); } - + $input.appendTo($container); $input.focus().select(); $input.datepicker({ @@ -199,424 +199,424 @@ var DateCellEditor = function($container, columnDef, value, dataContext) { buttonImage: "../images/calendar.gif" }); $input.width($input.width() - 18); - } - - + }; + + this.destroy = function() { - $input.datepicker("hide"); + $input.datepicker("hide"); $input.datepicker("destroy"); $input.remove(); - } - - + }; + + this.focus = function() { $input.focus(); - } - + }; + this.setValue = function(value) { $input.val(value); defaultValue = value; - } - + }; + this.getValue = function() { return $input.val(); - } - + }; + this.isValueChanged = function() { return (!($input.val() == "" && defaultValue == null)) && ($input.val() != defaultValue); - } - + }; + this.validate = function() { return { valid: true, msg: null }; - } - + }; + this.init(); -} +}; var YesNoSelectCellEditor = function($container, columnDef, value, dataContext) { var $select; var defaultValue = value; var scope = this; - + this.init = function() { $select = $("<SELECT tabIndex='0' class='editor-yesno'><OPTION value='yes'>Yes</OPTION><OPTION value='no'>No</OPTION></SELECT>"); - - if (defaultValue) + + if (defaultValue) $select.val('yes'); - else + else $select.val('no'); - + $select.appendTo($container); - + $select.focus(); - } - - + }; + + this.destroy = function() { $select.remove(); - } - - + }; + + this.focus = function() { $select.focus(); - } - + }; + this.setValue = function(value) { $select.val(value); defaultValue = value; - } - + }; + this.getValue = function() { return ($select.val() == 'yes'); - } - + }; + this.isValueChanged = function() { return ($select.val() != defaultValue); - } - + }; + this.validate = function() { return { valid: true, msg: null }; - } - + }; + this.init(); -} +}; var YesNoCheckboxCellEditor = function($container, columnDef, value, dataContext) { var $select; var defaultValue = value; var scope = this; - + this.init = function() { $select = $("<INPUT type=checkbox value='true' class='editor-checkbox' hideFocus>"); - - if (defaultValue) + + if (defaultValue) $select.attr("checked", "checked"); - + $select.appendTo($container); $select.focus(); - } - - + }; + + this.destroy = function() { $select.remove(); - } - - + }; + + this.focus = function() { $select.focus(); - } - + }; + this.setValue = function(value) { - if (value) + if (value) $select.attr("checked", "checked"); - else + else $select.removeAttr("checked"); - + defaultValue = value; - } - + }; + this.getValue = function() { return $select.attr("checked"); - } - + }; + this.isValueChanged = function() { return (scope.getValue() != defaultValue); - } - + }; + this.validate = function() { return { valid: true, msg: null }; - } - + }; + this.init(); -} +}; var PercentCompleteCellEditor = function($container, columnDef, value, dataContext) { var $input, $picker; var defaultValue = value; var scope = this; - + this.init = function() { $input = $("<INPUT type=text class='editor-percentcomplete' />"); - - if (value != null) + + if (value != null) { $input[0].defaultValue = value; $input.val(defaultValue); } - + $input.width($container.innerWidth() - 20); $input.appendTo($container); - + $picker = $("<div class='editor-percentcomplete-picker' />").appendTo($container); - + $picker.append("<div class='editor-percentcomplete-helper'><div class='editor-percentcomplete-wrapper'><div class='editor-percentcomplete-slider' /><div class='editor-percentcomplete-buttons' /></div></div>"); - + $picker.find(".editor-percentcomplete-buttons").append("<button val=0>Not started</button><br/><button val=50>In Progress</button><br/><button val=100>Complete</button>"); - + $input.focus().select(); - + $picker.find(".editor-percentcomplete-slider").slider({ - orientation: "vertical", - range: "min", + orientation: "vertical", + range: "min", value: defaultValue, slide: function(event, ui) { $input.val(ui.value) } }); - + $picker.find(".editor-percentcomplete-buttons button").bind("click", function(e) { $input.val($(this).attr("val")); $picker.find(".editor-percentcomplete-slider").slider("value", $(this).attr("val")); }) - } - - + }; + + this.destroy = function() { $input.remove(); $picker.remove(); - } - - + }; + + this.focus = function() { $input.focus(); - } - + }; + this.setValue = function(value) { $input.val(value); defaultValue = value; - } - + }; + this.getValue = function() { - var val = $.trim($input.val()); + var val = $.trim($input.val()); return (val == "") ? 0 : parseInt($input.val(), 10); - } - + }; + this.isValueChanged = function() { return (!($input.val() == "" && defaultValue == null)) && ($input.val() != defaultValue); - } - + }; + this.validate = function() { - if (isNaN($input.val())) + if (isNaN($input.val())) return { valid: false, msg: "Please enter a valid positive number" }; - + return { valid: true, msg: null }; - } - + }; + this.init(); -} +}; var TaskNameCellEditor = function($container, columnDef, value, dataContext) { var $input; var defaultValue = value; var scope = this; - + this.init = function() { $input = $("<INPUT type=text class='editor-text' />"); - - if (value != null) + + if (value != null) { $input[0].defaultValue = value; $input.val(defaultValue); } - + $input.appendTo($container); $input.focus().select(); - } - + }; + this.destroy = function() { $input.remove(); - } - + }; + this.focus = function() { $input.focus(); - } - + }; + this.setValue = function(value) { $input.val(value); defaultValue = value; - } - + }; + this.getValue = function() { return $input.val(); - } - + }; + this.isValueChanged = function() { return (!($input.val() == "" && defaultValue == null)) && ($input.val() != defaultValue); - } - + }; + this.validate = function() { - if (columnDef.validator) + if (columnDef.validator) { var validationResults = columnDef.validator(scope.getValue()); - if (!validationResults.valid) + if (!validationResults.valid) return validationResults; } - - if ($input.val() == "") + + if ($input.val() == "") return { valid: false, msg: "This field cannot be empty" }; - + return { valid: true, msg: null }; - } - + }; + this.init(); -} +}; var ResourcesCellEditor = function($container, columnDef, value, dataContext) { - var $input; + var $input; var defaultValue = []; var scope = this; - + this.init = function() { $input = $("<INPUT type=text class='editor-text' />"); - + var resources = dataContext ? dataContext["resources"] : null; - + defaultValue = resources ? resources.concat() : []; - - if (resources != null) + + if (resources != null) { $input[0].defaultValue = defaultValue.join(", "); $input.val(defaultValue.join(", ")); } - + $input.appendTo($container); $input.focus().select(); - } - + }; + this.destroy = function() { $input.remove(); - } - + }; + this.focus = function() { $input.focus(); - } - + }; + this.setValue = function(value) { defaultValue = value ? value : []; $input.val(defaultValue.join(", ")); - } - + }; + this.getValue = function() { - if ($input.val() == "") + if ($input.val() == "") return []; - + var names = $input.val().split(","); - - for (var i = 0; i < names.length; i++) + + for (var i = 0; i < names.length; i++) names[i] = $.trim(names[i]); - + return names; - } - + }; + this.isValueChanged = function() { // todo: implement return true; - } - + }; + this.validate = function() { - if (columnDef.validator) + if (columnDef.validator) { var validationResults = columnDef.validator(scope.getValue()); - if (!validationResults.valid) + if (!validationResults.valid) return validationResults; } - + // todo: implement - + return { valid: true, msg: null }; - } - + }; + this.init(); -} +}; var StarCellEditor = function($container, columnDef, value, dataContext) { var $input; var defaultValue = value; var scope = this; - - function toggle(e) { - if (e.type == "keydown" && e.which != 32) return; - - if ($input.css("opacity") == "1") - $input.css("opacity", 0.5); - else - $input.css("opacity", 1); - - e.preventDefault(); - e.stopPropagation(); - return false; - } - + + function toggle(e) { + if (e.type == "keydown" && e.which != 32) return; + + if ($input.css("opacity") == "1") + $input.css("opacity", 0.5); + else + $input.css("opacity", 1); + + e.preventDefault(); + e.stopPropagation(); + return false; + } + this.init = function() { $input = $("<IMG src='../images/bullet_star.png' align=absmiddle tabIndex=0 title='Click or press Space to toggle' />"); - - if (defaultValue) + + if (defaultValue) $input.css("opacity", 1); - else + else $input.css("opacity", 0.5); - $input.bind("click keydown", toggle); - + $input.bind("click keydown", toggle); + $input.appendTo($container); $input.focus(); - } - + }; + this.destroy = function() { - $input.unbind("click keydown", toggle); + $input.unbind("click keydown", toggle); $input.remove(); - } - + }; + this.focus = function() { $input.focus(); - } - + }; + this.setValue = function(value) { defaultValue = value; - - if (defaultValue) + + if (defaultValue) $input.css("opacity", 1); - else - $input.css("opacity", 0.2); - } - + else + $input.css("opacity", 0.2); + }; + this.getValue = function() { return $input.css("opacity") == "1"; - } - + }; + this.isValueChanged = function() { return (defaultValue == true) != scope.getValue(); - } - + }; + this.validate = function() { return { valid: true, msg: null }; - } - + }; + this.init(); -} +}; |