From 1a80aa74ff4971df4835769d64b3ee783cddfd4a Mon Sep 17 00:00:00 2001 From: David Huynh Date: Sun, 8 Aug 2010 23:49:31 +0000 Subject: [PATCH] Extracted many html templates from js code into separate .html files. git-svn-id: http://google-refine.googlecode.com/svn/trunk@1149 7d457c2a-affb-35e4-300a-418c747d4874 --- .../views/data-table/add-column-dialog.html | 20 ++ .../scripts/views/data-table/cell-editor.html | 17 + .../cell-recon-preview-popup-header.html | 4 + .../cell-recon-search-for-match.html | 16 + .../views/data-table/column-header.html | 6 + .../views/data-table/data-table-cell-ui.js | 73 +--- .../data-table/data-table-column-header-ui.js | 332 ++++-------------- .../data-table/sorting-criterion-dialog.html | 46 +++ .../views/data-table/split-column-dialog.html | 55 +++ .../data-table/text-transform-dialog.html | 18 + 10 files changed, 257 insertions(+), 330 deletions(-) create mode 100644 main/webapp/modules/core/scripts/views/data-table/add-column-dialog.html create mode 100644 main/webapp/modules/core/scripts/views/data-table/cell-editor.html create mode 100644 main/webapp/modules/core/scripts/views/data-table/cell-recon-preview-popup-header.html create mode 100644 main/webapp/modules/core/scripts/views/data-table/cell-recon-search-for-match.html create mode 100644 main/webapp/modules/core/scripts/views/data-table/column-header.html create mode 100644 main/webapp/modules/core/scripts/views/data-table/sorting-criterion-dialog.html create mode 100644 main/webapp/modules/core/scripts/views/data-table/split-column-dialog.html create mode 100644 main/webapp/modules/core/scripts/views/data-table/text-transform-dialog.html diff --git a/main/webapp/modules/core/scripts/views/data-table/add-column-dialog.html b/main/webapp/modules/core/scripts/views/data-table/add-column-dialog.html new file mode 100644 index 000000000..10582d206 --- /dev/null +++ b/main/webapp/modules/core/scripts/views/data-table/add-column-dialog.html @@ -0,0 +1,20 @@ +
+
+
+
+ + + + + + + + + +
New column name
On error set to blank store error keep original
$EXPRESSION_PREVIEW_WIDGET$
+
+ +
\ No newline at end of file diff --git a/main/webapp/modules/core/scripts/views/data-table/cell-editor.html b/main/webapp/modules/core/scripts/views/data-table/cell-editor.html new file mode 100644 index 000000000..5d84e3402 --- /dev/null +++ b/main/webapp/modules/core/scripts/views/data-table/cell-editor.html @@ -0,0 +1,17 @@ + + + ' + - '' + - '' + - '' + - '' + - '
' + - '
' + - 'List of integers separated by commas, e.g., 5, 7, 15' + - '
' + - '' + - '' + - '
' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '

After Splitting

Guess cell type
Remove this column
' + - '' + - '' - ); - var bodyElmts = DOM.bind(body); - - footer.html( - '' + - '' - ); - var footerElmts = DOM.bind(footer); - var level = DialogSystem.showDialog(frame); - var dismiss = function() { - DialogSystem.dismissUntil(level - 1); - }; + var dismiss = function() { DialogSystem.dismissUntil(level - 1); }; - footerElmts.okButton.click(function() { + elmts.cancelButton.click(dismiss); + elmts.okButton.click(function() { var mode = $("input[name='split-by-mode']:checked")[0].value; var config = { columnName: self._column.name, mode: mode, - guessCellType: bodyElmts.guessCellTypeInput[0].checked, - removeOriginalColumn: bodyElmts.removeColumnInput[0].checked + guessCellType: elmts.guessCellTypeInput[0].checked, + removeOriginalColumn: elmts.removeColumnInput[0].checked }; if (mode == "separator") { - config.separator = bodyElmts.separatorInput[0].value; + config.separator = elmts.separatorInput[0].value; if (!(config.separator)) { alert("Please specify a separator."); return; } - config.regex = bodyElmts.regexInput[0].checked; + config.regex = elmts.regexInput[0].checked; - var s = bodyElmts.maxColumnsInput[0].value; + var s = elmts.maxColumnsInput[0].value; if (s) { var n = parseInt(s,10); if (!isNaN(n)) { @@ -1137,7 +990,7 @@ DataTableColumnHeaderUI.prototype._doSplitColumn = function() { } } } else { - var s = "[" + bodyElmts.lengthsTextarea[0].value + "]"; + var s = "[" + elmts.lengthsTextarea[0].value + "]"; try { var a = JSON.parse(s); } catch (e) { @@ -1164,8 +1017,6 @@ DataTableColumnHeaderUI.prototype._doSplitColumn = function() { ); dismiss(); }); - - footerElmts.cancelButton.click(dismiss); }; DataTableColumnHeaderUI.prototype._doTransposeColumnsIntoRows = function() { @@ -1264,8 +1115,6 @@ DataTableColumnHeaderUI.prototype._doTransposeRowsIntoColumns = function() { }; DataTableColumnHeaderUI.prototype._showSortingCriterion = function(criterion, hasOtherCriteria) { - var self = this; - criterion = criterion || { column: this._column.name, valueType: "string", @@ -1274,61 +1123,19 @@ DataTableColumnHeaderUI.prototype._showSortingCriterion = function(criterion, ha blankPosition: 2 }; - var frame = DialogSystem.createDialog(); - frame.width("400px"); + var self = this; + var frame = $(DOM.loadHTML("core", "scripts/views/data-table/sorting-criterion-dialog.html")); + var elmts = DOM.bind(frame); - var header = $('
').addClass("dialog-header").text("Sort by " + this._column.name).appendTo(frame); - var body = $('
').addClass("dialog-body").appendTo(frame); - var footer = $('
').addClass("dialog-footer").appendTo(frame); + elmts.dialogHeader.text('Sort by ' + this._column.name); - body.html( - '
' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '
Sort cell values asPosition blanks and errors
' + - '
' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '
text case-sensitive
numbers
dates
booleans
' + - '
' + - '
    ' + - '

    Drag and drop to re-order

    ' + - '
    ' + - ' ' + - ' ' + - '' + - '
    ' - ); - - var bodyElmts = DOM.bind(body); - - bodyElmts.valueTypeOptions.find("input[type='radio'][value='" + criterion.valueType + "']") + elmts.valueTypeOptions + .find("input[type='radio'][value='" + criterion.valueType + "']") .attr("checked", "checked"); var setValueType = function(valueType) { - var forward = $("#sorting-dialog-direction-forward"); - var reverse = $("#sorting-dialog-direction-reverse"); + var forward = elmts.directionForwardLabel; + var reverse = elmts.directionReverseLabel; if (valueType == "string") { forward.html("a - z"); reverse.html("z - a"); @@ -1343,19 +1150,22 @@ DataTableColumnHeaderUI.prototype._showSortingCriterion = function(criterion, ha reverse.html("true then false"); } }; - bodyElmts.valueTypeOptions.find("input[type='radio']").change(function() { - setValueType(this.value); - }); + elmts.valueTypeOptions + .find("input[type='radio']") + .change(function() { + setValueType(this.value); + }); if (criterion.valueType == "string" && criterion.caseSensitive) { - bodyElmts.caseSensitiveCheckbox.attr("checked", "checked"); + elmts.caseSensitiveCheckbox.attr("checked", "checked"); } - bodyElmts.directionOptions.find("input[type='radio'][value='" + (criterion.reverse ? "reverse" : "forward") + "']") + elmts.directionOptions + .find("input[type='radio'][value='" + (criterion.reverse ? "reverse" : "forward") + "']") .attr("checked", "checked"); if (hasOtherCriteria) { - bodyElmts.sortAloneContainer.show(); + elmts.sortAloneContainer.show(); } var validValuesHtml = '
  • Valid Values
  • '; @@ -1379,31 +1189,23 @@ DataTableColumnHeaderUI.prototype._showSortingCriterion = function(criterion, ha positionsHtml = [ validValuesHtml, blankValuesHtml, errorValuesHtml ]; } } - bodyElmts.blankErrorPositions.html(positionsHtml.join("")).sortable().disableSelection(); + elmts.blankErrorPositions.html(positionsHtml.join("")).sortable().disableSelection(); - footer.html( - '' + - '' - ); - var footerElmts = DOM.bind(footer); - var level = DialogSystem.showDialog(frame); - var dismiss = function() { - DialogSystem.dismissUntil(level - 1); - }; + var dismiss = function() { DialogSystem.dismissUntil(level - 1); }; setValueType(criterion.valueType); - footerElmts.cancelButton.click(dismiss); - footerElmts.okButton.click(function() { + elmts.cancelButton.click(dismiss); + elmts.okButton.click(function() { var criterion2 = { column: self._column.name, - valueType: bodyElmts.valueTypeOptions.find("input[type='radio']:checked")[0].value, - reverse: bodyElmts.directionOptions.find("input[type='radio']:checked")[0].value == "reverse" + valueType: elmts.valueTypeOptions.find("input[type='radio']:checked")[0].value, + reverse: elmts.directionOptions.find("input[type='radio']:checked")[0].value == "reverse" }; var valuePosition, blankPosition, errorPosition; - bodyElmts.blankErrorPositions.find("li").each(function(index, elmt) { + elmts.blankErrorPositions.find("li").each(function(index, elmt) { var kind = this.getAttribute("kind"); if (kind == "value") { valuePosition = index; @@ -1417,11 +1219,11 @@ DataTableColumnHeaderUI.prototype._showSortingCriterion = function(criterion, ha criterion2.errorPosition = errorPosition - valuePosition; if (criterion2.valueType == "string") { - criterion2.caseSensitive = bodyElmts.caseSensitiveCheckbox[0].checked; + criterion2.caseSensitive = elmts.caseSensitiveCheckbox[0].checked; } self._dataTableView._addSortingCriterion( - criterion2, bodyElmts.sortAloneContainer.find("input")[0].checked); + criterion2, elmts.sortAloneContainer.find("input")[0].checked); dismiss(); }); diff --git a/main/webapp/modules/core/scripts/views/data-table/sorting-criterion-dialog.html b/main/webapp/modules/core/scripts/views/data-table/sorting-criterion-dialog.html new file mode 100644 index 000000000..8c3d4936d --- /dev/null +++ b/main/webapp/modules/core/scripts/views/data-table/sorting-criterion-dialog.html @@ -0,0 +1,46 @@ +
    +
    +
    +
    + + + + + + + + + +
    Sort cell values asPosition blanks and errors
    +
    + + + + + + + + + + + + + + + + +
    text case-sensitive
    numbers
    dates
    booleans
    +
    +
      +

      Drag and drop to re-order

      +
      + + + +
      +
      + +
      \ No newline at end of file diff --git a/main/webapp/modules/core/scripts/views/data-table/split-column-dialog.html b/main/webapp/modules/core/scripts/views/data-table/split-column-dialog.html new file mode 100644 index 000000000..6591849f3 --- /dev/null +++ b/main/webapp/modules/core/scripts/views/data-table/split-column-dialog.html @@ -0,0 +1,55 @@ +
      +
      +
      +
      + + +
      +
      + + + + + + + + + + + + + + + + + + + + + + + + + +

      How to Split Column

      by separator
      Separator regular expression
      Split into columns at most (leave blank for no limit)
      by field lengths
      List of integers separated by commas, e.g., 5, 7, 15
      +
      +
      + + + + + + + + + + + +

      After Splitting

      Guess cell type
      Remove this column
      +
      +
      + +
      \ No newline at end of file diff --git a/main/webapp/modules/core/scripts/views/data-table/text-transform-dialog.html b/main/webapp/modules/core/scripts/views/data-table/text-transform-dialog.html new file mode 100644 index 000000000..313299d40 --- /dev/null +++ b/main/webapp/modules/core/scripts/views/data-table/text-transform-dialog.html @@ -0,0 +1,18 @@ +
      +
      +
      +
      + + + + + + + +
      $EXPRESSION_PREVIEW_WIDGET$
      On error set to blank
      store error
      keep original
      Re-transform until no change
      up to times
      +
      + +
      \ No newline at end of file