2015-06-11 01:43:59 +08:00
|
|
|
var LayoutEditor;
|
|
|
|
(function ($, LayoutEditor) {
|
|
|
|
|
|
|
|
LayoutEditor.Fieldset = function (data, htmlId, htmlClass, htmlStyle, isTemplated, legend, contentType, contentTypeLabel, contentTypeClass, hasEditor, children) {
|
|
|
|
LayoutEditor.Element.call(this, "Fieldset", data, htmlId, htmlClass, htmlStyle, isTemplated);
|
|
|
|
LayoutEditor.Container.call(this, ["Grid", "Content"], children);
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
this.isContainable = true;
|
|
|
|
this.dropTargetClass = "layout-common-holder";
|
|
|
|
this.contentType = contentType;
|
|
|
|
this.contentTypeLabel = contentTypeLabel;
|
|
|
|
this.contentTypeClass = contentTypeClass;
|
|
|
|
this.legend = legend || "";
|
|
|
|
this.hasEditor = hasEditor;
|
|
|
|
|
|
|
|
this.toObject = function () {
|
|
|
|
var result = this.elementToObject();
|
|
|
|
result.legend = this.legend;
|
|
|
|
result.children = this.childrenToObject();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
};
|
|
|
|
|
|
|
|
var getEditorObject = this.getEditorObject;
|
|
|
|
this.getEditorObject = function() {
|
|
|
|
var dto = getEditorObject();
|
|
|
|
return $.extend(dto, {
|
|
|
|
Legend: this.legend
|
|
|
|
});
|
2015-03-06 16:03:04 +08:00
|
|
|
}
|
2015-06-11 01:43:59 +08:00
|
|
|
|
|
|
|
this.setChildren = function (children) {
|
|
|
|
this.children = children;
|
|
|
|
_(this.children).each(function (child) {
|
|
|
|
child.parent = self;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
this.setChildren(children);
|
|
|
|
};
|
|
|
|
|
|
|
|
LayoutEditor.Fieldset.from = function (value) {
|
|
|
|
return new LayoutEditor.Fieldset(
|
|
|
|
value.data,
|
|
|
|
value.htmlId,
|
|
|
|
value.htmlClass,
|
|
|
|
value.htmlStyle,
|
|
|
|
value.isTemplated,
|
|
|
|
value.legend,
|
|
|
|
value.contentType,
|
|
|
|
value.contentTypeLabel,
|
|
|
|
value.contentTypeClass,
|
|
|
|
value.hasEditor,
|
|
|
|
LayoutEditor.childrenFrom(value.children));
|
|
|
|
};
|
|
|
|
|
|
|
|
LayoutEditor.registerFactory("Fieldset", function(value) {
|
|
|
|
return LayoutEditor.Fieldset.from(value);
|
|
|
|
});
|
|
|
|
|
|
|
|
})(jQuery, LayoutEditor || (LayoutEditor = {}));
|
2015-02-20 05:14:55 +08:00
|
|
|
var LayoutEditor;
|
|
|
|
(function ($, LayoutEditor) {
|
|
|
|
|
|
|
|
LayoutEditor.Form = function (data, htmlId, htmlClass, htmlStyle, isTemplated, name, formBindingContentType, contentType, contentTypeLabel, contentTypeClass, hasEditor, children) {
|
|
|
|
LayoutEditor.Element.call(this, "Form", data, htmlId, htmlClass, htmlStyle, isTemplated);
|
|
|
|
LayoutEditor.Container.call(this, ["Grid", "Content"], children);
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
this.isContainable = true;
|
|
|
|
this.dropTargetClass = "layout-common-holder";
|
|
|
|
this.contentType = contentType;
|
|
|
|
this.contentTypeLabel = contentTypeLabel;
|
|
|
|
this.contentTypeClass = contentTypeClass;
|
|
|
|
this.name = name || "Untitled";
|
|
|
|
this.formBindingContentType = formBindingContentType;
|
|
|
|
this.hasEditor = hasEditor;
|
|
|
|
|
|
|
|
this.toObject = function () {
|
|
|
|
var result = this.elementToObject();
|
|
|
|
result.name = this.name;
|
2015-02-27 17:08:32 +08:00
|
|
|
result.formBindingContentType = this.formBindingContentType;
|
2015-02-20 05:14:55 +08:00
|
|
|
result.children = this.childrenToObject();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
};
|
|
|
|
|
|
|
|
var getEditorObject = this.getEditorObject;
|
|
|
|
this.getEditorObject = function() {
|
|
|
|
var dto = getEditorObject();
|
|
|
|
return $.extend(dto, {
|
|
|
|
FormName: this.name,
|
|
|
|
FormBindingContentType: this.formBindingContentType
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setChildren = function (children) {
|
|
|
|
this.children = children;
|
|
|
|
_(this.children).each(function (child) {
|
|
|
|
child.parent = self;
|
2015-02-27 17:31:50 +08:00
|
|
|
self.linkChild(child);
|
2015-02-20 05:14:55 +08:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2015-02-27 17:31:50 +08:00
|
|
|
this.linkChild = function(element) {
|
|
|
|
var getEditorObject = element.getEditorObject;
|
|
|
|
element.getEditorObject = function () {
|
|
|
|
var dto = getEditorObject();
|
|
|
|
return $.extend(dto, {
|
|
|
|
FormBindingContentType: self.formBindingContentType
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-02-20 05:14:55 +08:00
|
|
|
this.setChildren(children);
|
|
|
|
};
|
|
|
|
|
|
|
|
LayoutEditor.Form.from = function (value) {
|
|
|
|
return new LayoutEditor.Form(
|
|
|
|
value.data,
|
|
|
|
value.htmlId,
|
|
|
|
value.htmlClass,
|
|
|
|
value.htmlStyle,
|
|
|
|
value.isTemplated,
|
|
|
|
value.name,
|
|
|
|
value.formBindingContentType,
|
|
|
|
value.contentType,
|
|
|
|
value.contentTypeLabel,
|
|
|
|
value.contentTypeClass,
|
|
|
|
value.hasEditor,
|
|
|
|
LayoutEditor.childrenFrom(value.children));
|
|
|
|
};
|
|
|
|
|
|
|
|
LayoutEditor.registerFactory("Form", function(value) { return LayoutEditor.Form.from(value); });
|
|
|
|
|
|
|
|
})(jQuery, LayoutEditor || (LayoutEditor = {}));
|
2015-06-10 03:59:03 +08:00
|
|
|
angular
|
|
|
|
.module("LayoutEditor")
|
|
|
|
.directive("orcLayoutFieldset", ["$compile", "scopeConfigurator", "environment",
|
|
|
|
function ($compile, scopeConfigurator, environment) {
|
|
|
|
return {
|
|
|
|
restrict: "E",
|
|
|
|
scope: { element: "=" },
|
|
|
|
controller: ["$scope", "$element",
|
|
|
|
function ($scope, $element) {
|
|
|
|
scopeConfigurator.configureForElement($scope, $element);
|
|
|
|
scopeConfigurator.configureForContainer($scope, $element);
|
|
|
|
$scope.sortableOptions["axis"] = "y";
|
|
|
|
$scope.edit = function () {
|
|
|
|
$scope.$root.editElement($scope.element).then(function (args) {
|
|
|
|
if (args.cancel)
|
|
|
|
return;
|
|
|
|
$scope.element.data = decodeURIComponent(args.element.data);
|
|
|
|
$scope.element.legend = args.elementEditorModel.legend;
|
|
|
|
$scope.$apply();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
],
|
|
|
|
templateUrl: environment.templateUrl("Fieldset"),
|
|
|
|
replace: true
|
|
|
|
};
|
|
|
|
}
|
|
|
|
]);
|
2015-06-11 01:43:59 +08:00
|
|
|
angular
|
|
|
|
.module("LayoutEditor")
|
|
|
|
.directive("orcLayoutForm", ["$compile", "scopeConfigurator", "environment",
|
|
|
|
function ($compile, scopeConfigurator, environment) {
|
|
|
|
return {
|
|
|
|
restrict: "E",
|
|
|
|
scope: { element: "=" },
|
|
|
|
controller: ["$scope", "$element",
|
|
|
|
function ($scope, $element) {
|
|
|
|
scopeConfigurator.configureForElement($scope, $element);
|
|
|
|
scopeConfigurator.configureForContainer($scope, $element);
|
|
|
|
$scope.sortableOptions["axis"] = "y";
|
|
|
|
$scope.edit = function () {
|
|
|
|
$scope.$root.editElement($scope.element).then(function (args) {
|
|
|
|
if (args.cancel)
|
|
|
|
return;
|
|
|
|
$scope.element.data = decodeURIComponent(args.element.data);
|
|
|
|
$scope.element.name = args.elementEditorModel.name;
|
|
|
|
$scope.element.formBindingContentType = args.elementEditorModel.formBindingContentType;
|
|
|
|
$scope.$apply();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
],
|
|
|
|
templateUrl: environment.templateUrl("Form"),
|
|
|
|
replace: true
|
|
|
|
};
|
2015-06-10 03:59:03 +08:00
|
|
|
}
|
2015-06-11 01:43:59 +08:00
|
|
|
]);
|
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkZpZ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lbWVudCgkc2NvcGUsICRlbGVtZW50KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2NvcGVDb25maWd1cmF0b3IuY29uZmlndXJlRm9yQ29udGFpbmVyKCRzY29wZSwgJGVsZW1lbnQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAkc2NvcGUuc29ydGFibGVPcHRpb25zW1wiYXhpc1wiXSA9IFwieVwiO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAkc2NvcGUuZWRpdCA9IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICRzY29wZS4kcm9vdC5lZGl0RWxlbWVudCgkc2NvcGUuZWxlbWVudCkudGhlbihmdW5jdGlvbiAoYXJncykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhcmdzLmNhbmNlbClcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICRzY29wZS5lbGVtZW50LmRhdGEgPSBkZWNvZGVVUklDb21wb25lbnQoYXJncy5lbGVtZW50LmRhdGEpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICRzY29wZS5lbGVtZW50LmxlZ2VuZCA9IGFyZ3MuZWxlbWVudEVkaXRvck1vZGVsLmxlZ2VuZDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkc2NvcGUuJGFwcGx5KCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBdLFxyXG4gICAgICAgICAgICAgICAgdGVtcGxhdGVVcmw6IGVudmlyb25tZW50LnRlbXBsYXRlVXJsKFwiRmllbGRzZXRcIiksXHJcbiAgICAgICAgICAgICAgICByZXBsYWNlOiB0cnVlXHJcbiAgICAgICAgICAgIH07XHJcbiAgICAgICAgfVxyXG4gICAgXSk7IiwiYW5ndWxhclxuICAgIC5tb2R1bGUoXCJMYXlvdXRFZGl0b3JcIilcbiAgICAuZGlyZWN0aXZlKFwib3JjTGF5b3V0Rm9ybVwiLCBbXCIkY29tcGlsZVwiLCBcInNjb3BlQ29uZmlndXJhdG9yXCIsIFwiZW52aXJvbm1lbnRcIixcbiAgICAgICAgZnVuY3Rpb24gKCRjb21waWxlLCBzY29wZUNvbmZpZ3VyYXRvciwgZW52aXJvbm1lbnQpIHtcbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgcmVzdHJpY3Q6IFwiRVwiLFxuICAgICAgICAgICAgICAgIHNjb3BlOiB7IGVsZW1lbnQ6IFwiPVwiIH0sXG4gICAgICAgICAgICAgICAgY29udHJvbGxlcjogW1wiJHNjb3BlXCIsIFwiJGVsZW1lbnRcIixcbiAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gKCRzY29wZSwgJGVsZW1lbnQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNjb3BlQ29uZmlndXJhdG9yLmNvbmZpZ3VyZUZvckVsZW1lbnQoJHNjb3BlLCAkZWxlbWVudCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBzY29wZUNvbmZpZ3VyYXRvci5jb25maWd1cmVGb3JDb
|