Permalink
Browse files

I accidentally some tabs

  • Loading branch information...
1 parent bf2eaf8 commit 7948b406e275871be305b383c582faa2e5a2e8e7 @jrowny committed Mar 1, 2012
Showing with 22 additions and 24 deletions.
  1. +22 −24 js/controllers.js
View
@@ -5,19 +5,19 @@ function AppCtrl($route, $scope, $browser, FormService, ElementService) {
//vars
var elements = $scope.elements = ElementService.query({elementId:'elements'}),
code = $scope.code = "",
- tree = $scope.tree = "";
+ tree = $scope.tree = "";
$scope.$on("render",function(){
- code = ""
- tree = "";
+ code = ""
+ tree = "";
if(FormService.drupalForm.length){
code += _.map(FormService.drupalForm, function(value){return toPHP(value,[]);}).join("\n\n");
- tree += "<ol class=\"sortable\">" + _.map(FormService.drupalForm, function(value){return toEditList(value);}).join("\n") + "</ol>";
+ tree += "<ol class=\"sortable\">" + _.map(FormService.drupalForm, function(value){return toEditList(value);}).join("\n") + "</ol>";
}else{
code = "//Empty form :(";
- tree = "<ul></ul>";
+ tree = "<ul></ul>";
}
- $('#code').html("");
+ $('#code').html("");
$('#code').text("<?php\n\n" + code + "\n\n?>");
$('#tree').html(tree)
$('#tree ol').nestedSortable({
@@ -44,11 +44,11 @@ function AppCtrl($route, $scope, $browser, FormService, ElementService) {
* Remove Form Controller (Confirmation)
*/
function RemoveFormCtrl($scope, $route, $location, $rootScope, FormService){
- $scope.confirmRemove = function(){
- FormService.remove($route.current.params.elementId);
- $rootScope.$broadcast("render");
+ $scope.confirmRemove = function(){
+ FormService.remove($route.current.params.elementId);
+ $rootScope.$broadcast("render");
$location.path("/");
- };
+ };
}
/**
@@ -60,23 +60,21 @@ function ElementFormCtrl(ElementService, FormService, $routeParams, $location, $
var element = $scope.element = {},
mode = $scope.mode = $location.$$path.split("/")[1];
- if(mode == "edit"){
- $scope.form = form = FormService.getById($routeParams.elementId);
- $scope.element = element = form.element;
- }else if(mode == "add"){
- //When adding a new element, initialize the form
- $scope.element = element = ElementService.get({elementId: $routeParams.elementId}, function(element) {
- $scope.form = form = FormService.newForm(element);
- //add default attributes
- for(var i = 0; i < element.attributes.length; i++){
- if(element.attributes[i].typical){
+ if(mode == "edit"){
+ $scope.form = form = FormService.getById($routeParams.elementId);
+ $scope.element = element = form.element;
+ }else if(mode == "add"){
+ //When adding a new element, initialize the form
+ $scope.element = element = ElementService.get({elementId: $routeParams.elementId}, function(element) {
+ $scope.form = form = FormService.newForm(element);
+ //add default attributes
+ for(var i = 0; i < element.attributes.length; i++){
+ if(element.attributes[i].typical){
form.attributes.push({"attribute":element.attributes[i],"value":element.attributes[i].value});
}
}
- });
- }
-
-
+ });
+ }
$scope.addAttribute = function(){
form.attributes.push({"attribute":element.attributes[0],"value":""});

0 comments on commit 7948b40

Please sign in to comment.