DATABIND : Add dataSourceFile class 16/20116/1
authorHeekyoung, Oh <heekyoung.oh@samsung.com>
Mon, 28 Apr 2014 07:17:43 +0000 (16:17 +0900)
committerHeekyoung, Oh <heekyoung.oh@samsung.com>
Mon, 28 Apr 2014 07:17:43 +0000 (16:17 +0900)
a. can access the file included app
b. can read xml or json data type of file

Change-Id: I4ebb18d16cce19601d830c98ebe2fd0303d92d64
Signed-off-by: Heekyoung, Oh <heekyoung.oh@samsung.com>
templates/Template/Tizen Web UI Builder/1.EmptyProject/project/tizen-ui-builder-fw/uibinding.js
templates/Template/Tizen Web UI Builder/2.SinglePageProject/project/tizen-ui-builder-fw/uibinding.js
templates/Template/Tizen Web UI Builder/3.MultiPageProject/project/tizen-ui-builder-fw/uibinding.js
templates/Template/Tizen Web UI Builder/4.NavigationProject/project/tizen-ui-builder-fw/uibinding.js

index 8c65339..036f588 100644 (file)
                return _self;
        };
 
+       /**
+        * datasource - file
+        */
+       uibinding.dataSourceFile = function () {
+               if (arguments.length !== 1) {
+                       return null; 
+               }
+
+               var _self = this;
+               _self.options = {
+                               path: "",
+                               dataType: "json"
+               };
+
+               var args = Array.prototype.slice.call(arguments, 0);
+               var new_options = args.shift();
+               _self._create(new_options);
+               return _self;
+       };
+       uibinding.dataSourceFile.prototype = new uibinding.dataSource();
+       uibinding.dataSourceFile.prototype.constructor = uibinding.dataSourceFile;
+       uibinding.dataSourceFile.prototype._create = function (obj) {
+               var _self = this;
+               if (arguments.length > 0) {
+                       _self._updateOptions(obj);
+               }
+       };
+       uibinding.dataSourceFile.prototype._update = function () {
+               var _self = this;
+               $.get(_self.options.path, function (data) {
+                       _self.data = _self._toJson(data, _self.options.dataType);
+                       _self.fireHandler("success");
+               }).fail(function () {
+                       _self.fireHandler("error");
+               });
+       };
+       uibinding.dataSourceFile.prototype.update = function () {
+               var _self = this;
+               _self._update();
+               return this;
+       };
 
 })(jQuery);
 
index 8c65339..036f588 100644 (file)
                return _self;
        };
 
+       /**
+        * datasource - file
+        */
+       uibinding.dataSourceFile = function () {
+               if (arguments.length !== 1) {
+                       return null; 
+               }
+
+               var _self = this;
+               _self.options = {
+                               path: "",
+                               dataType: "json"
+               };
+
+               var args = Array.prototype.slice.call(arguments, 0);
+               var new_options = args.shift();
+               _self._create(new_options);
+               return _self;
+       };
+       uibinding.dataSourceFile.prototype = new uibinding.dataSource();
+       uibinding.dataSourceFile.prototype.constructor = uibinding.dataSourceFile;
+       uibinding.dataSourceFile.prototype._create = function (obj) {
+               var _self = this;
+               if (arguments.length > 0) {
+                       _self._updateOptions(obj);
+               }
+       };
+       uibinding.dataSourceFile.prototype._update = function () {
+               var _self = this;
+               $.get(_self.options.path, function (data) {
+                       _self.data = _self._toJson(data, _self.options.dataType);
+                       _self.fireHandler("success");
+               }).fail(function () {
+                       _self.fireHandler("error");
+               });
+       };
+       uibinding.dataSourceFile.prototype.update = function () {
+               var _self = this;
+               _self._update();
+               return this;
+       };
 
 })(jQuery);
 
index 8c65339..036f588 100644 (file)
                return _self;
        };
 
+       /**
+        * datasource - file
+        */
+       uibinding.dataSourceFile = function () {
+               if (arguments.length !== 1) {
+                       return null; 
+               }
+
+               var _self = this;
+               _self.options = {
+                               path: "",
+                               dataType: "json"
+               };
+
+               var args = Array.prototype.slice.call(arguments, 0);
+               var new_options = args.shift();
+               _self._create(new_options);
+               return _self;
+       };
+       uibinding.dataSourceFile.prototype = new uibinding.dataSource();
+       uibinding.dataSourceFile.prototype.constructor = uibinding.dataSourceFile;
+       uibinding.dataSourceFile.prototype._create = function (obj) {
+               var _self = this;
+               if (arguments.length > 0) {
+                       _self._updateOptions(obj);
+               }
+       };
+       uibinding.dataSourceFile.prototype._update = function () {
+               var _self = this;
+               $.get(_self.options.path, function (data) {
+                       _self.data = _self._toJson(data, _self.options.dataType);
+                       _self.fireHandler("success");
+               }).fail(function () {
+                       _self.fireHandler("error");
+               });
+       };
+       uibinding.dataSourceFile.prototype.update = function () {
+               var _self = this;
+               _self._update();
+               return this;
+       };
 
 })(jQuery);
 
index 8c65339..036f588 100644 (file)
                return _self;
        };
 
+       /**
+        * datasource - file
+        */
+       uibinding.dataSourceFile = function () {
+               if (arguments.length !== 1) {
+                       return null; 
+               }
+
+               var _self = this;
+               _self.options = {
+                               path: "",
+                               dataType: "json"
+               };
+
+               var args = Array.prototype.slice.call(arguments, 0);
+               var new_options = args.shift();
+               _self._create(new_options);
+               return _self;
+       };
+       uibinding.dataSourceFile.prototype = new uibinding.dataSource();
+       uibinding.dataSourceFile.prototype.constructor = uibinding.dataSourceFile;
+       uibinding.dataSourceFile.prototype._create = function (obj) {
+               var _self = this;
+               if (arguments.length > 0) {
+                       _self._updateOptions(obj);
+               }
+       };
+       uibinding.dataSourceFile.prototype._update = function () {
+               var _self = this;
+               $.get(_self.options.path, function (data) {
+                       _self.data = _self._toJson(data, _self.options.dataType);
+                       _self.fireHandler("success");
+               }).fail(function () {
+                       _self.fireHandler("error");
+               });
+       };
+       uibinding.dataSourceFile.prototype.update = function () {
+               var _self = this;
+               _self._update();
+               return this;
+       };
 
 })(jQuery);