Changeset 1438
- Timestamp:
- 2010-02-18 16:02:44 (3 years ago)
- Location:
- trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms
- Files:
-
- 7 edited
-
basic-controls.js (modified) (15 diffs)
-
case.js (modified) (1 diff)
-
collection.js (modified) (3 diffs)
-
composite.js (modified) (2 diffs)
-
control.js (modified) (17 diffs)
-
date.js (modified) (4 diffs)
-
location.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/basic-controls.js
r1374 r1438 35 35 * @type Object 36 36 */ 37 InputControl.prototype.elements = {}; 38 $.extend(InputControl.prototype.elements, kf.Control.prototype.elements); 39 $.extend(InputControl.prototype.elements, { 40 input : { 41 create :"<input type='text'>", 42 select :":text,:password" 43 } 37 InputControl.prototype.templates = {}; 38 $.extend(InputControl.prototype.templates, kf.Control.prototype.templates); 39 $.extend(InputControl.prototype.templates, { 40 input:"<input type='text'/>" 44 41 }); 45 42 … … 48 45 * @param {Boolean} create Creates the elements if they don't exist yet 49 46 */ 50 InputControl.prototype.initElements = function( create) {47 InputControl.prototype.initElements = function() { 51 48 52 49 var $input = this.getElement(); 50 51 var selector = "input"; 52 if(! $input){ 53 // does not contain an input element TODO check if this is OK 54 this.setElement("input", $(this.getTemplate('input'))); 55 $input = this.getElement(); 56 } 57 if(! $input.is(selector)){ 58 $input.html(this.getTemplate('input')); 59 } 53 60 54 61 //default … … 56 63 this.password = false; 57 64 58 if ( !create &&$input.attr('type') == 'password') {65 if ($input.attr('type') == 'password') { 59 66 this.password = true; 60 } else if ( (! create && !!this.password && ($input.attr('type') == 'text')) || (create &&!!this.password) ){67 } else if ( (!!this.password && ($input.attr('type') == 'text')) || (!!this.password) ){ 61 68 // change type to 'password' if it's set via config 62 69 // type cannot be changed for newly created element, so it's cloned … … 110 117 * @type Object 111 118 */ 112 OutputControl.prototype.elements = {}; 113 $.extend(OutputControl.prototype.elements, kf.Control.prototype.elements); 114 $.extend(OutputControl.prototype.elements, { 115 input : { 116 create :"<span/>", 117 select :"span" 118 } 119 OutputControl.prototype.templates = {}; 120 $.extend(OutputControl.prototype.templates, kf.Control.prototype.templates); 121 $.extend(OutputControl.prototype.templates, { 122 input : "<span/>" 119 123 }); 120 124 … … 123 127 * @param {Boolean} create Creates the elements if they don't exist yet 124 128 */ 125 OutputControl.prototype.initElements = function( create) {129 OutputControl.prototype.initElements = function( ) { 126 130 127 131 var $output = this.getElement(); 132 var selector = "span"; 133 if(! $output){ 134 // does not contain an input element TODO check if this is OK 135 this.setElement("input", $(this.getTemplate('input'))); 136 $output = this.getElement(); 137 } 138 if(! $output.is(selector)){ 139 $output.html(this.getTemplate('input')); 140 } 128 141 129 142 //default … … 168 181 169 182 170 CheckBoxControl.prototype.elements = {}; 171 $.extend(CheckBoxControl.prototype.elements, kf.Control.prototype.elements); 172 $.extend(CheckBoxControl.prototype.elements, { 173 input : { 174 create :"<input type='checkbox'>", 175 select :"input[type='checkbox']" 176 } 183 CheckBoxControl.prototype.templates = {}; 184 $.extend(CheckBoxControl.prototype.templates, kf.Control.prototype.templates); 185 $.extend(CheckBoxControl.prototype.templates, { 186 input : "<input type='checkbox'>" 177 187 }); 178 188 179 189 180 190 /** Specific control element initialisation */ 181 CheckBoxControl.prototype.initElements = function( create) { 182 183 var $input = this.getElement(); 191 CheckBoxControl.prototype.initElements = function( ) { 192 193 var $input = this.getElement(); 194 195 var selector = "input[type='checkbox']"; 196 if(! $input){ 197 // does not contain an input element TODO check if this is OK 198 this.setElement("input", $(this.getTemplate('input'))); 199 $input = this.getElement(); 200 } 201 if(! $input.is(selector)) 202 $input.html(this.getTemplate('input')); 203 184 204 this._input = $input; 185 205 } … … 226 246 } 227 247 228 SelectionControl.prototype.elements = {}; 229 $.extend(SelectionControl.prototype.elements, kf.Control.prototype.elements); 230 $.extend(SelectionControl.prototype.elements, { 231 input : { 232 create :"<select>", 233 select :"select" 234 }, 235 refresh : { 236 create :"<button class='refresh'>", 237 select :"button.refresh" 238 } 248 SelectionControl.prototype.templates = {}; 249 $.extend(SelectionControl.prototype.templates, kf.Control.prototype.templates); 250 $.extend(SelectionControl.prototype.templates, { 251 input : "<select kauri-role='input'>", 252 refresh: "<button class='refresh' kauri-role='refresh'>" 239 253 }); 240 254 … … 243 257 */ 244 258 SelectionControl.prototype.options = {}; 259 260 SelectionControl.prototype.showRefresh = false; 245 261 246 262 /** Specific control element initialisation */ 247 SelectionControl.prototype.initElements = function( create) {263 SelectionControl.prototype.initElements = function( ) { 248 264 249 265 var type = this.getType(); 250 266 var $select = this.getElement(); 251 252 if (!create) { 253 // TODO read the options from the HTML - set them on the ready options object 254 255 // check multi-select and size: template setting overrides control-conf 256 type.multivalue = type.multivalue || !!$select.attr('multiple'); 257 this.size = this.size != undefined && this.size != 0 ? this.size : $select.attr('size'); 258 } 267 268 var selector = "select[kauri-role='input']"; 269 if(! $select){ 270 // does not contain an input element TODO check if this is OK 271 $select = $(this.getTemplate('input')) 272 this.setElement("input", $select); 273 } 274 if(! $select.is(selector)){ 275 $select.html(this.getTemplate('input')); 276 $select = $(selector,$select); 277 this.setElement("input", $select); 278 } 279 // TODO read the options from the HTML - set them on the ready options object 280 // check multi-select and size: template setting overrides control-conf 281 type.multivalue = type.multivalue || !!$select.attr('multiple'); 282 this.size = this.size != undefined && this.size != 0 ? this.size : $select.attr('size'); 259 283 260 284 // check multi-select and size … … 265 289 if (options.refreshable()) { 266 290 // find/create the refresh button 267 var $refresh = kf.ControlElements.lookup(this, kf.ControlElements.REV_REFRESH, create); 291 var $refresh = kf.ControlElements.lookup(this, kf.ControlElements.REV_REFRESH); 292 293 if(!$refresh && this.showRefresh){ 294 $(this.getTemplate("refresh")).insertAfter($select); 295 $refresh = $(":last-child",$refresh); 296 } 268 297 if ($refresh) { 269 298 $refresh.click( function(evt) { … … 282 311 SelectionControl.prototype.initEventWiring = function() { 283 312 284 var options = this.options;313 var options = this.options; 285 314 if (options.toShare() && options.initEventWiringDone) 286 315 return; // no need to re-init shared options, avoiding multiple updates when one suffices … … 309 338 */ 310 339 SelectionControl.prototype.updateOptions = function( userValues, labels) { 311 312 340 userValues = userValues || []; 313 341 labels = labels || userValues; … … 323 351 var last = userValues.length; 324 352 for ( var i = 0; i < last; i++) { 325 $ option = $("<option value='" + userValues[i] + "'>" + labels[i] + "</option>").appendTo($select);353 $("<option value='" + userValues[i] + "'>" + labels[i] + "</option>").appendTo($select); 326 354 } 327 355 … … 403 431 } 404 432 405 TextareaControl.prototype.elements = {}; 406 $.extend(TextareaControl.prototype.elements, kf.Control.prototype.elements); 407 $.extend(TextareaControl.prototype.elements, { 408 input : { 409 create :"<textarea/>", 410 select :"textarea" 411 } 433 TextareaControl.prototype.templates = {}; 434 $.extend(TextareaControl.prototype.templates, kf.Control.prototype.templates); 435 $.extend(TextareaControl.prototype.templates, { 436 input: "<textarea/>" 412 437 }); 413 438 414 439 /** Specific control element initialisation */ 415 TextareaControl.prototype.initElements = function( create) {440 TextareaControl.prototype.initElements = function( ) { 416 441 var $textarea = this.getElement(); 417 442 443 var selector = "textarea"; 444 if(! $textarea){ 445 // does not contain an input element TODO check if this is OK 446 this.setElement("input", $(this.getTemplate('input'))); 447 $textarea = this.getElement(); 448 } 449 if(! $textarea.is(selector)) 450 $textarea.html(this.getTemplate('input')); 451 418 452 // defaults 419 453 if (!this.cols) … … 425 459 } 426 460 427 if (!create) { 461 428 462 ($textarea.attr('cols') != -1)? (this.cols = $textarea.attr('cols')) : $textarea.attr('cols', this.cols); 429 463 ($textarea.attr('rows') != -1)? (this.rows = $textarea.attr('rows')) : $textarea.attr('rows', this.rows); … … 431 465 // the only way to check this, is by using an attribute selector 432 466 ($('textarea[readonly]' ,$('<div />').append($textarea.clone())).size() == 1)? (this.readonly = $textarea.attr('readonly')) : $textarea.attr('readonly', this.readonly); 433 } else {434 this.cols && $textarea.attr('cols', this.cols);435 this.rows && $textarea.attr('rows', this.rows);436 this.readonly && $textarea.attr('readonly', this.readonly);437 }438 467 } 439 468 -
trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/case.js
r1273 r1438 130 130 } 131 131 132 CaseControl.prototype.elements = {}; 133 $.extend(CaseControl.prototype.elements, kf.CompositeControl.prototype.elements); 134 $.extend(CaseControl.prototype.elements, { 135 layout : { 136 create : "<span/>" 137 } 132 CaseControl.prototype.templates = {}; 133 $.extend(CaseControl.prototype.templates, kf.CompositeControl.prototype.templates); 134 $.extend(CaseControl.prototype.templates, { 135 layout : "<span/>" 138 136 }); 139 137 -
trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/collection.js
r1267 r1438 61 61 this['<super.init>'](id, form, conf); 62 62 } 63 64 CollectionControl.prototype.initElements = function( create) { 63 $.extend(CollectionControl.prototype.templates, { 64 layout: "<tr><td ><span kauri-role='label'/><span kauri-role='input'/><span kauri-role='messages'/></td></tr>", 65 container: "<table kauri-role='container'></table>" 66 }); 67 68 CollectionControl.prototype.initElements = function( ) { 65 69 var me = this; 66 70 var children = this._children = []; 67 71 68 var addblock = kf.ControlElements.lookup(this, "add" , create);72 var addblock = kf.ControlElements.lookup(this, "add"); 69 73 if (addblock) { 70 74 addblock.click( function(evt) { … … 78 82 79 83 // sortable needs a class to identify the handle, so add one 80 var handleblock = kf.ControlElements.lookup(this, "handle" , create);84 var handleblock = kf.ControlElements.lookup(this, "handle"); 81 85 if (handleblock) { 82 86 handleblock.addClass("handleblock"); … … 215 219 216 220 217 // Make sure the item role is asso icated with the control221 // Make sure the item role is associated with the control 218 222 var $newItem = kf.ControlElements.lookup(childControl, "item", false); 219 223 -
trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/composite.js
r804 r1438 77 77 } 78 78 79 CompositeControl.prototype. elements = {};80 $.extend(CompositeControl.prototype. elements, kf.AbstractContainerControl.prototype.elements);81 $.extend(CompositeControl.prototype. elements, {82 container : null,83 layout : null79 CompositeControl.prototype.templates = {}; 80 $.extend(CompositeControl.prototype.templates, kf.AbstractContainerControl.prototype.templates); 81 $.extend(CompositeControl.prototype.templates, { 82 container: "<dl kauri-role='container'></dl>", 83 layout: "<dt kauri-role='label'/><dd><span kauri-role='input'/><span kauri-role='messages'/></dd>" 84 84 }); 85 85 86 CompositeControl.prototype.initElements = function( create) {86 CompositeControl.prototype.initElements = function( ) { 87 87 88 88 this._children = {}; … … 101 101 if (!container) { 102 102 throw "[CompositeControl#createChildElements] No container to work with."; 103 } else if (!container.is("dl")) { 104 container = $("<dl/>").appendTo(container); 105 this.setElement(kf.ControlElements.REV_CONTAINER, container); 106 } 107 108 // since there is no layout we will use our own default layout 109 var item = $("<dt kauri-role='label'/><dd kauri-role='item'/>").appendTo(container); 103 } 104 var item = $(this.getTemplate('layout')).appendTo(container); 110 105 return item; 111 106 } -
trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/control.js
r1430 r1438 174 174 // find all kauri-idref and kauri-role marked elements and index them 175 175 var kauriSelector = "[" + ControlElements.ATTR_IDREF + "],[" + ControlElements.ATTR_REV + "]"; 176 177 178 176 179 // begin by index space itself, 177 180 if (space.is(kauriSelector)) … … 184 187 185 188 return ($this.attr(ControlElements.ATTR_IDREF)!=undefined || revParents == null || revParents.length==0); 186 }); 189 }); 187 190 matching.each(indexor); 188 191 } … … 242 245 /** 243 246 * Finds the element assigned to the identified control for a specific kauri-form-relation (functional role), and creates it if 244 * not found. 247 * not found. + Sets the element in the control 245 248 * @param {Control} control 246 249 * @param {String} relation What relation the element has with the control (input, message, ...) … … 249 252 * @static 250 253 */ 251 ControlElements.lookup = function(control, relation, create){ 252 253 create = create || false; 254 254 ControlElements.lookup = function(control, relation){ 255 255 256 if (!relation) 256 257 throw "[ControlElements#lookup] no relation specified."; … … 259 260 260 261 var elm = form.getElementIndex(index, relation); // if marked with kauri- attributes we should find it in the indexes 261 var $elm ;262 263 if (!elm) { // look it up in some parent using a specific selector264 var lookupSpaces = form.getElementIndex(index) || [];265 var lastSpace = lookupSpaces.length;262 var $elm = null; 263 264 if (!elm) { 265 if(relation == ControlElements.REV_INPUT && form.getElementIndex(index).length == 1){ 266 elm = form.getElementIndex(index)[0]; 266 267 267 var selector = control.getElementSelector(relation); 268 if (selector) { 269 270 for (var i = 0; i < lastSpace; i++) { 271 var space = lookupSpaces[i]; 272 var $space = $(space); 273 if ($space.is(selector)) { 274 $elm = $space; 275 } 276 else { 277 var found = $(selector, $space); 278 if (found.size() > 0) 279 // arbitrarily take first hit 280 $elm = found.eq(0); 281 } 282 } 283 } 284 285 if (!$elm && lastSpace > 0 && create) { // still not found and a valid parent available, then consider creating: 286 var creator = control.getCreateElement(relation); 287 if (creator) { 288 $elm = $(creator).appendTo($(lookupSpaces[0])); 289 // TODO consider allowing pointers to "where" (relative to other elements) this new element should be added. 290 } 291 } 292 293 if ($elm) { 294 $elm.attr(ControlElements.ATTR_INDEX, index); 295 $elm.attr(ControlElements.ATTR_REV, relation); 296 elm = $elm.get(0); 297 form.addElementIndex(index, relation, elm); 268 $elm = $(elm); 269 270 if ($elm) { 271 $elm.attr(ControlElements.ATTR_INDEX, index); 272 $elm.attr(ControlElements.ATTR_REV, relation); 273 elm = $elm.get(0); 274 form.addElementIndex(index, relation, elm); 275 } 298 276 } 299 277 } … … 590 568 591 569 /** 592 * Holds the control-bound HTML elements per relation570 * Holds the control-bound HTML templates per relation 593 571 * @private 594 572 */ 595 Control.prototype._ elements;573 Control.prototype._templates; 596 574 597 575 /** … … 599 577 * @type Object 600 578 */ 601 Control.prototype.elements = { 602 messages: { 603 create: "<span></span>" 604 } 579 Control.prototype.templates = { 580 messages: "<span></span>" 605 581 }; 606 582 … … 630 606 631 607 /** 632 * Gets the element selector for an element with the specified relationship 633 * @param {String} relation The elements relationship with the control 634 * @return The element selector 635 * @type String 636 */ 637 Control.prototype.getElementSelector = function(relation){ 638 639 return this._getElementConfig(relation, 'select'); 640 } 641 642 /** 643 * Gets the create statement for an element with the specified relationship 608 * Gets the template for an element with the specified relationship 644 609 * @param {String} relation The elements relationship with the control 645 610 * @return The create statement 646 611 * @type String 647 612 */ 648 Control.prototype.getCreateElement = function(relation){ 649 650 return this._getElementConfig(relation, 'create'); 651 } 652 613 Control.prototype.getTemplate = function(relation){ 614 var templates = this.templates; 615 if (!templates) 616 return; 617 return templates[relation]; 618 } 619 653 620 /** 654 621 * Sets a html element (jQuery wrapped) for a specific relationship … … 674 641 return; 675 642 relation = relation || "input"; 676 return this._elements[relation]; 643 644 var $elements = this._elements[relation]; 645 return $elements; 677 646 } 678 647 … … 716 685 * @final To extend this behaviour for specific controls: override the initElements(create) method (no underscore). 717 686 */ 718 Control.prototype._initElements = function(create){ 719 720 create = create || false; 721 722 var $input = ControlElements.lookup(this, ControlElements.REV_INPUT, create); 723 if (!create && !$input) { // 2nd attempt after switching to create mode. 724 create = true; 725 $input = ControlElements.lookup(this, ControlElements.REV_INPUT, create); 726 } 727 728 if (!$input) 729 throw "[Control#_initElements] Cannot continue without a proper input element for this control. (" + 730 this.getAbsoluteId() + 731 ")"; 732 733 734 // add events to the control: valueChanged, validationFinished 735 this._makeEventHandler("validationFinished"); 736 this._makeEventHandler("valueChanged"); 687 Control.prototype._initElements = function(){ 688 689 var $input = ControlElements.lookup(this, ControlElements.REV_INPUT); 737 690 738 691 // Sets a label in the label element. … … 740 693 // In that case no default creation will happen! (additional requirement for element creation) 741 694 // But if a label is specifief in the template, then that takes precendence over what is in the fconf 742 var labelCreate = create && (this.label != undefined); 743 var $lbl = ControlElements.lookup(this, ControlElements.REV_LABEL, labelCreate); 695 var $lbl = ControlElements.lookup(this, ControlElements.REV_LABEL); 696 697 var $mark = ControlElements.lookup(this, ControlElements.REV_MARK); 698 if (!$mark) 699 this.setElement(ControlElements.REV_MARK, $input); // by default the input element doubles as marking 700 var $msg = ControlElements.lookup(this, ControlElements.REV_MESSAGES); 701 702 // add events to the control: valueChanged, validationFinished 703 this._makeEventHandler("validationFinished"); 704 this._makeEventHandler("valueChanged"); 705 744 706 if ($lbl && $lbl[0].childNodes.length == 0) { 745 707 var label = this.label != null ? this.label : this.getId(); … … 747 709 } 748 710 749 var $mark = ControlElements.lookup(this, ControlElements.REV_MARK, create);750 if (!$mark)751 this.setElement(ControlElements.REV_MARK, $input); // by default the input element doubles as marking752 var $msg = ControlElements.lookup(this, ControlElements.REV_MESSAGES, create);753 754 711 // allow control-specific initialization of containment elements 755 this.initContainerElements( create);712 this.initContainerElements(); 756 713 757 714 //initialize options 758 this.initOptions( create);715 this.initOptions(); 759 716 760 717 // allow control-specific initialization of specific functional elements 761 this.initElements( create);718 this.initElements(); 762 719 } 763 720 … … 849 806 * @see #_initElements(create) 850 807 */ 851 Control.prototype.initElements = function( create){808 Control.prototype.initElements = function(){ 852 809 853 810 } … … 1583 1540 * @type object 1584 1541 */ 1585 AbstractContainerControl.prototype.elements = {}; 1586 $.extend(AbstractContainerControl.prototype.elements, Control.prototype.elements); 1587 $.extend(AbstractContainerControl.prototype.elements, { 1588 input: { 1589 select: "div", 1590 create: "<div></div>" 1591 }, 1592 layout: { 1593 create: "<div><span kauri-role='label'/></div>" 1594 } 1542 AbstractContainerControl.prototype.templates = {}; 1543 $.extend(AbstractContainerControl.prototype.templates, Control.prototype.templates); 1544 $.extend(AbstractContainerControl.prototype.templates, { 1545 input: "<div><span kauri-role='label'/><span kauri-role='input'/><span kauri-role='messages'/></div>", 1546 layout: "<div><span kauri-role='label'/><span kauri-role='input'/><span kauri-role='messages'/></div>", 1547 container: "<div kauri-role='container'></div>" 1595 1548 }); 1596 1549 … … 1792 1745 AbstractContainerControl.prototype.initContainerElements = function(create){ 1793 1746 1794 var container = ControlElements.lookup(this, ControlElements.REV_CONTAINER, create); 1795 if (!container) { // default to complete input space 1747 var container = ControlElements.lookup(this, ControlElements.REV_CONTAINER); 1748 var $container = $(container); 1749 if (!container) { 1750 var creator = this.getTemplate(ControlElements.REV_CONTAINER); 1751 if (creator) { 1752 $container = $(creator).appendTo($(this.getElement("input"))); 1753 this.setElement(ControlElements.REV_CONTAINER, $container); 1754 } 1755 } 1756 1757 if (!$container) { // default to complete input space 1796 1758 this.setElement(ControlElements.REV_CONTAINER, this.getElement("input")); 1797 1759 } 1798 var layout = ControlElements.lookup(this, ControlElements.REV_LAYOUT, create); 1760 1761 var layout = ControlElements.lookup(this, ControlElements.REV_LAYOUT); 1762 if (!layout) { 1763 var creator = this.getTemplate(ControlElements.REV_LAYOUT); 1764 if (creator) { 1765 $layout = $(creator).appendTo($container); 1766 this.setElement(ControlElements.REV_LAYOUT, $layout); 1767 } 1768 } 1769 1799 1770 if (layout) { 1800 1771 layout.hide(); … … 1829 1800 var container = this.getElement(ControlElements.REV_CONTAINER); 1830 1801 var layout = this.getElement(ControlElements.REV_LAYOUT); 1802 1831 1803 var newElements 1832 1804 if (!(container && layout)) { … … 1834 1806 } 1835 1807 else { 1808 // there is a container and there is a layout 1836 1809 var childAtPosition = null; 1837 1810 if (position != undefined && (typeof position == "number")) { 1838 1811 childAtPosition = container.children(":nth-child(" + (position + 1) + ")"); 1839 1812 } 1813 var $layout = layout.clone(); 1814 if($layout.length>1){ 1815 var $wrap = $("<span/>"); 1816 $wrap.append($layout); 1817 $layout = $wrap; 1818 } 1819 1840 1820 if (childAtPosition != null && childAtPosition.length == 1) { 1841 newElements = layout.clone().insertBefore(childAtPosition[0]).show();1821 newElements = $layout.insertBefore(childAtPosition[0]).show(); 1842 1822 } else { 1843 newElements = layout.clone().appendTo(container).show();1823 newElements = $layout.appendTo(container).show(); 1844 1824 } 1825 1845 1826 newElements.attr(ControlElements.ATTR_REV, ControlElements.REV_ITEM); 1846 1827 } 1847 1828 1848 1829 newElements.attr(ControlElements.ATTR_IDREF, id); 1830 1831 1849 1832 1850 1833 var form = this.getForm(); -
trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/date.js
r1299 r1438 189 189 base :"wire-date", 190 190 pattern :"dd/mm/yy" 191 } 191 }, 192 193 "short-date-range" : { 194 base :"wire-date-range", 195 pattern :"dd/mm/yy - dd/mm/yy" 196 } 197 192 198 }); 193 199 … … 288 294 "date-range" : { 289 295 'base': "composite", 296 'user-format' :"short-date-range", 290 297 'members' : { 291 298 "start" : { base : "date"}, … … 317 324 * @type Object 318 325 */ 319 DateControl.prototype.elements = {}; 320 $.extend(DateControl.prototype.elements, kf.Control.prototype.elements); 321 $.extend(DateControl.prototype.elements, { 322 input : { 323 create :"<input type='text'>", 324 select :":text" 325 } 326 DateControl.prototype.templates = {}; 327 $.extend(DateControl.prototype.templates, kf.Control.prototype.templates); 328 $.extend(DateControl.prototype.templates, { 329 input :"<div><input type='text' kauri-role='input'/></div>" 326 330 }); 327 DateControl.prototype.initElements = function ( create) {331 DateControl.prototype.initElements = function ( ) { 328 332 var $input = this.getElement(); 333 334 var selector = "div > input"; 335 if(! $input){ 336 // does not contain an input element TODO check if this is OK 337 $input = $(this.getTemplate('input')) 338 this.setElement("input", $input); 339 } 340 if(! $input.is(selector)){ 341 $input.html(this.getTemplate('input')); 342 $input = $("div > input",$input); 343 } 344 329 345 var type = this.getType(); 330 346 331 if (!create) { 332 type.readonly = $input.attr("readonly"); 333 } else { 334 type.readonly && $input.attr("readonly", type.readonly); 335 } 336 347 type.readonly && $input.attr("readonly", type.readonly); 337 348 338 349 if (this.useDatePicker) { … … 342 353 buttonImage: "javascript:void(0);", // the image will actually be set with css so just pass a dummy img src 343 354 buttonImageOnly: true, 344 buttonText: "choose a date",345 355 showOn: "button", 346 356 yearRange: this.yearRange, 347 357 rangeSelect: this.isRange 358 // the buttonText option is removed because is always shown (image is set by css and so the alt is always shown) 348 359 }; 349 360 -
trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/location.js
r1221 r1438 45 45 GMapControl.prototype.apiKey = "ABQIAAAAOLLfFZQRGe8Hwl8R-4_7ABTb-vLQlFZmc2N8bgWI8YDPp5FEVBRSxdJTJfWoHiTs2nyCjV6ZpIuHvA"; 46 46 47 GMapControl.prototype. elements = {};48 $.extend(GMapControl.prototype. elements, kf.AbstractContainerControl.prototype.elements);49 $.extend(GMapControl.prototype. elements, {47 GMapControl.prototype.templates = {}; 48 $.extend(GMapControl.prototype.templates, kf.AbstractContainerControl.prototype.templates); 49 $.extend(GMapControl.prototype.templates, { 50 50 container : "<div/>" 51 51 }); 52 52 53 GMapControl.prototype.initElements = function( create) {53 GMapControl.prototype.initElements = function( ) { 54 54 var me = this; 55 55 var container = this.getElement(kf.ControlElements.REV_CONTAINER); … … 82 82 83 83 var val = me.getWireValue(); 84 if (val .latitude != null && val.longitude != null && val.zoom != null) {84 if (val && val.latitude != null && val.longitude != null && val.zoom != null) { 85 85 var mapVal = {latitude : new Number(val.latitude).valueOf(), longitude : new Number(val.longitude).valueOf(), zoom : new Number(val.zoom).valueOf()}; 86 86 me.setMapValue(mapVal); … … 102 102 this.valueChanged(function (evt) { 103 103 var val = me.getWireValue(); 104 if (val .latitude != null && val.longitude != null && val.zoom != null) {104 if (val && val.latitude != null && val.longitude != null && val.zoom != null) { 105 105 var mapVal = {latitude : new Number(val.latitude).valueOf(), longitude : new Number(val.longitude).valueOf(), zoom : new Number(val.zoom).valueOf()}; 106 106 me.setMapValue(mapVal);
Note: See TracChangeset
for help on using the changeset viewer.