details:   /erp/devel/pi/rev/7065aa975c16
changeset: 12462:7065aa975c16
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Thu May 26 11:34:27 2011 +0200
summary:   Split ob-formitem-widgets.js in separate files

diffstat:

 
modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java
       |    46 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-form-button.js
               |    28 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-formitem-checkbox.js
         |    34 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-formitem-date.js
             |   243 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-formitem-datechooser.js
      |    60 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-formitem-datetime.js
         |   230 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-formitem-encrypted.js
        |    29 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-formitem-fk-filter.js
        |    28 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-formitem-fk.js
               |    36 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-formitem-link.js
             |    44 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-formitem-linktitle.js
        |    33 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-formitem-list-filter.js
      |    27 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-formitem-list.js
             |    86 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-formitem-minidaterange.js
    |    95 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-formitem-number.js
           |   488 ++
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-formitem-search-attribute.js
 |    51 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-formitem-search.js
           |   233 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-formitem-section-audit.js
    |    22 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-formitem-section.js
          |   137 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-formitem-text.js
             |    33 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-formitem-textarea.js
         |    48 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-formitem-time.js
             |    34 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-formitem-yesno.js
            |    32 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-formitem-widgets.js
               |  1668 ----------
 24 files changed, 2096 insertions(+), 1669 deletions(-)

diffs (truncated from 3870 to 300 lines):

diff -r ae223d78097f -r 7065aa975c16 
modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java
   Thu May 26 10:30:54 2011 +0200
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java
   Thu May 26 11:34:27 2011 +0200
@@ -85,8 +85,52 @@
         "web/org.openbravo.client.application/js/ob-utilities-date.js", true));
     globalResources.add(createStaticResource(
         "web/org.openbravo.client.application/js/ob-utilities-number.js", 
true));
+
     globalResources.add(createStaticResource(
-        "web/org.openbravo.client.application/js/ob-formitem-widgets.js", 
true));
+        "web/org.openbravo.client.application/js/form/ob-form-button.js", 
true));
+    globalResources.add(createStaticResource(
+        
"web/org.openbravo.client.application/js/form/ob-formitem-checkbox.js", true));
+    globalResources.add(createStaticResource(
+        
"web/org.openbravo.client.application/js/form/ob-formitem-datechooser.js", 
true));
+    globalResources.add(createStaticResource(
+        "web/org.openbravo.client.application/js/form/ob-formitem-date.js", 
true));
+    globalResources.add(createStaticResource(
+        
"web/org.openbravo.client.application/js/form/ob-formitem-datetime.js", true));
+    globalResources.add(createStaticResource(
+        
"web/org.openbravo.client.application/js/form/ob-formitem-encrypted.js", true));
+    globalResources.add(createStaticResource(
+        
"web/org.openbravo.client.application/js/form/ob-formitem-linktitle.js", true));
+    globalResources.add(createStaticResource(
+        "web/org.openbravo.client.application/js/form/ob-formitem-text.js", 
true));
+    globalResources.add(createStaticResource(
+        "web/org.openbravo.client.application/js/form/ob-formitem-link.js", 
true));
+    globalResources.add(createStaticResource(
+        "web/org.openbravo.client.application/js/form/ob-formitem-list.js", 
true));
+    globalResources.add(createStaticResource(
+        
"web/org.openbravo.client.application/js/form/ob-formitem-list-filter.js", 
true));
+    globalResources.add(createStaticResource(
+        "web/org.openbravo.client.application/js/form/ob-formitem-fk.js", 
true));
+    globalResources.add(createStaticResource(
+        
"web/org.openbravo.client.application/js/form/ob-formitem-fk-filter.js", true));
+    globalResources.add(createStaticResource(
+        
"web/org.openbravo.client.application/js/form/ob-formitem-minidaterange.js", 
true));
+    globalResources.add(createStaticResource(
+        "web/org.openbravo.client.application/js/form/ob-formitem-number.js", 
true));
+    globalResources.add(createStaticResource(
+        "web/org.openbravo.client.application/js/form/ob-formitem-search.js", 
true));
+    globalResources.add(createStaticResource(
+        
"web/org.openbravo.client.application/js/form/ob-formitem-search-attribute.js", 
true));
+    globalResources.add(createStaticResource(
+        "web/org.openbravo.client.application/js/form/ob-formitem-section.js", 
true));
+    globalResources.add(createStaticResource(
+        
"web/org.openbravo.client.application/js/form/ob-formitem-section-audit.js", 
true));
+    globalResources.add(createStaticResource(
+        
"web/org.openbravo.client.application/js/form/ob-formitem-textarea.js", true));
+    globalResources.add(createStaticResource(
+        "web/org.openbravo.client.application/js/form/ob-formitem-time.js", 
true));
+    globalResources.add(createStaticResource(
+        "web/org.openbravo.client.application/js/form/ob-formitem-yesno.js", 
true));
+
     globalResources.add(createStaticResource(
         "web/org.openbravo.client.application/js/ob-application-menu.js", 
false));
     
globalResources.add(createStaticResource("web/org.openbravo.client.application/js/ob-tab.js",
diff -r ae223d78097f -r 7065aa975c16 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-form-button.js
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-form-button.js
   Thu May 26 11:34:27 2011 +0200
@@ -0,0 +1,28 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use. this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2011 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+// == OBFormButton ==
+// The default form button.
+isc.ClassFactory.defineClass('OBFormButton', Button);
+
+isc.OBFormButton.addProperties({
+  autoFit: true,
+  baseStyle: 'OBFormButton',
+  titleStyle: 'OBFormButtonTitle'
+});
diff -r ae223d78097f -r 7065aa975c16 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-formitem-checkbox.js
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-formitem-checkbox.js
     Thu May 26 11:34:27 2011 +0200
@@ -0,0 +1,34 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use. this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2011 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+// == OBCheckboxItem ==
+// Item used for Openbravo yes/no fields.
+isc.ClassFactory.defineClass('OBCheckboxItem', CheckboxItem);
+
+isc.OBCheckboxItem.addProperties({
+  operator: 'equals',
+  // no validation on change or exit here
+  textBoxStyle: 'OBFormFieldLabel',
+  showValueIconOver: true,
+  showValueIconFocused: true,
+  defaultValue: false,
+  checkedImage: 
'[SKIN]/../../org.openbravo.client.application/images/form/checked.png',
+  uncheckedImage: 
'[SKIN]/../../org.openbravo.client.application/images/form/unchecked.png'
+});
+
diff -r ae223d78097f -r 7065aa975c16 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-formitem-date.js
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-formitem-date.js
 Thu May 26 11:34:27 2011 +0200
@@ -0,0 +1,243 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use. this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2011 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+// == OBDateItem ==
+// OBDateItem inherits from SmartClient DateItem
+// adds autocomplete and formatting based on the Openbravo date pattern
+isc.ClassFactory.defineClass('OBDateItem', isc.DateItem);
+
+isc.OBDateItem.addProperties({
+  operator: 'equals',
+  // ** {{{ pickerConstructor }}} **
+  // Picker constructor class
+  pickerConstructor: 'OBDateChooser',
+  useSharedPicker: true,
+  
+  // ** {{{ dateFormat }}} **
+  // Dateformat function
+  dateFormat: OB.Format.date,
+  
+  // ** {{{ useTextField }}} **
+  // use text field for date entry
+  useTextField: true,
+  
+  // ** {{{ changeOnKeypress }}} **
+  // Fire change event on key press.
+  changeOnKeypress: true,
+  
+  // is done by the blur event defined here
+  validateOnExit: false,
+  validateOnChange: false,
+  
+  textAlign: 'left',
+  
+  // to prevent infinite looping as setFormErrors will also blur
+  inBlur: false,
+
+  dateParts : [],
+
+  init: function() {
+    var i, dateFormatUpper, index = 0, currentTime;
+    dateFormatUpper = this.dateFormat.toUpperCase();
+    this.dateSeparator = this.dateFormat.toUpperCase().replace(/D/g, '')
+        .replace(/M/g, '').replace(/Y/g, '').substr(0, 1);
+    for (i = 0; i < dateFormatUpper.length; i++) {
+      if (this.isSeparator(dateFormatUpper, i)) {
+        index++;
+      } else {
+        this.dateParts[index] = dateFormatUpper.charAt(i);
+      }
+    }
+    currentTime = new Date();
+    this.currentMonth = String(currentTime.getMonth() + 1);
+    if (this.currentMonth.length === 1) {
+      this.currentMonth = '0' + this.currentMonth;
+    }
+    this.currentDay = String(currentTime.getDate());
+    if (this.currentDay.length === 1) {
+      this.currentDay = '0' + this.currentDay;
+    }
+    this.currentYear = String(currentTime.getFullYear());
+
+    this.Super('init', arguments);
+  },
+
+  // compare while ignoring milli difference
+  compareValues: function (value1, value2) {
+    // not a date let the super class do it
+    if (!isc.isA.Date(value1) || !isc.isA.Date(value2)) {
+      return this.Super('compareValues', arguments);
+    }
+    var difference = value1.getTime() - value2.getTime();
+    if (difference < -1000) {
+      return true;
+    } else if (difference > 1000) {
+      return false;
+    } else {
+      return true;
+    }
+  },
+  
+  // ** {{{ blur }}} **
+  // Called when the focus leaves the field (sets value and validates)
+  blur: function(){
+    var newValue = this.blurValue(), oldValue = this.getValue(), editRow;
+    
+    if (oldValue !== newValue) {
+      this.storeValue(OB.Utilities.Date.OBToJS(newValue, this.dateFormat));
+    }
+    if (!this.inBlur) {
+      this.inBlur = true;
+      this.checkOBDateItemValue();
+      this.inBlur = false;
+    }
+    return this.Super('blur', arguments);
+  },
+  
+  blurValue: function() {
+    return this.parseValue();
+  },
+
+  parseValue: function() {
+    var i, str = this.getValue(), parts = [ '', '', '' ], partIndex = 0, 
result;
+    if (!str || isc.isA.Date(str)) {
+      return str;
+    }
+    for (i = 0; i < str.length; i++) {
+      if (this.isNumber(str, i)) {
+        if (this.reachedLength(parts[partIndex], partIndex)) {
+          partIndex++;
+        }
+        if (partIndex === 3) {
+          break;
+        }
+        parts[partIndex] = parts[partIndex] + str.charAt(i);
+      } else if (this.isSeparator(str, i)) {
+        partIndex++;
+      } else {
+        // invalid date
+        return str;
+      }
+      if (partIndex === 3) {
+        break;
+      }
+    }
+    for (i = 0; i < 3; i++) {
+      parts[i] = this.expandPart(parts[i], i);
+    }
+    return parts[0] + this.dateSeparator + parts[1] + this.dateSeparator
+        + parts[2];
+  },
+
+  expandPart : function(part, index) {
+    var year;
+    if (this.reachedLength(part, index)) {
+      return part;
+    }
+    if (part === '') {
+      if (this.dateParts[index] === 'D') {
+        return this.currentDay;
+      } else if (this.dateParts[index] === 'M') {
+        return this.currentMonth;
+      } else {
+        return this.currentYear;
+      }
+    } else if (this.dateParts[index] === 'Y') {
+      year = parseInt(part, 10);
+      if (year <= 50) {
+        return String(2000 + year);
+      } else if (year < 100) {
+        return String(1900 + year);
+      } else {
+        return '2' + part;
+      }

------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery, 
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now. 
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to